I'm using Adafruit 16-Channel 12-bit PWM/Servo Shield with Arduino Uno controller
In setup()
I have a number of default positions with PWM commands for motors with plug of USB to PC and turning on
I'm trying to figure out, how to avoid setup()
commands, or any other signals during process to servos, in case if shield is not powered from power adapter, which is 6V 8Amp in my case, to not send signal to servo while it is not powered by power supply
1 Answer 1
I would propose a circuit like the following:
schematic
simulate this circuit – Schematic created using CircuitLab
The voltage divider (consisting of the resistors) will divide the 6V to 5V for the Arduinos digital input. The values are not critical, they can be made higher, but maintain the relationship to still get the 5V. The diode will prevent current to flow from the shield into the voltage divider, when the shield is powered through other means. Now you can simply do a digitalRead()
on the corresponding digital input pin of your Arduino, to check, if the power was applied.
Please notice, that the diode will reduce the voltage a little by it's forward voltage (depends on the diode). But that shouldn't be a big problem.
-
Thank you for answer. Can you clarify, if this way I could monitor power to the servos using one of "digital input pins" with resistor divider to divide that down to 5v or less for the Arduino Uno, what is a difference of using "analog pin" in this case, I found number of close guides: 1. Measuring DC Voltage 2. Arduino Battery 3. Energy meterlf80– lf802019年05月21日 17:09:22 +00:00Commented May 21, 2019 at 17:09
-
From your question I assumed, that you use a normal power adapter, which means, that the 6V for the shield are already regulated beforehand. I think of a wall wart. In this case there are inly two possibilities: 6V or no voltage at all. Then the digital pin is sufficient. If you have a battery connected there and want to also sense the low voltage case, you can use an analog pin.chrisl– chrisl2019年05月21日 17:43:21 +00:00Commented May 21, 2019 at 17:43
-
Hello, I could not yet use this scheme to check result. Something is incorrect for particular shield. I've soldered scheme exactly as you shown, 2 resistors 1.0 and 5.07, diode 1N4148. Without anything power jack shows 6.56V, shield turns on. Through scheme voltage runs from 6.29 to 6.52V, shield does not turns on, seems like it is not enough voltagelf80– lf802019年05月25日 07:40:11 +00:00Commented May 25, 2019 at 7:40
-
The shield should also work with voltages down to 5V. Is the green LED on the shield on? Does it work, if you bridge the diode? Is it mounted the right way? (Putting it in reverse will block the voltage to reach the shield)chrisl– chrisl2019年05月25日 08:34:37 +00:00Commented May 25, 2019 at 8:34
-
Yes cathode (pole with black line) directed with output wire to the shield, should prevent flow from the shield into divider. Anode pole directed to 1kΩ resistor from plus. Voltage from VCC and GND runs 6.18, 6.29, 6.52V... Green LED on the shield off, shield does not works. Without scheme direct meter test shows 6.56V, green led on, shield works. I did not tried bridge the diodelf80– lf802019年05月25日 09:15:34 +00:00Commented May 25, 2019 at 9:15
value = digitalRead(pin_number)
. Youc an then do whatever you want with this, for exmple check in an if statement, if the result isHIGH
orLOW
by doingif(value){...} else {...}
. I don't know, what I should write there in my answer.