I am new to arduino,
I want to control a servo with a switch, very basic.
It is connected to a battery so i dont want it to draw power when it is in closed position.
Is that possible? if yes, how?
Here's my code:
#include <Servo.h>
Servo myservo;
int servoPos = 0;
void setup() {
// put your setup code here, to run once:
myservo.attach(6);
pinMode(5, INPUT_PULLUP);
pinMode(7, INPUT_PULLUP);
}
void loop() {
if (digitalRead(5)) {
servoPos = 0; //closed position
}
if (digitalRead(7)) {
servoPos = 180; //open position
}
myservo.write(servoPos);
}
I believe that servos require an input signal to hold a constant position. So it must constantly draw power to maintain position (and of course to move to a new position).
there's the power drawn by the circuitry and the power drawn by the motor when that circuitry drives the motor to move it.
the motor is driven when it is not at the target position indicated by the signal. a load shifts it minisculy away from the target requiring that power be applied to the motor.
there should be little if any power to the motor if there is no load.
yes. as i explained. but only if the load is strong enough to overcome gear friction and cause a miniscule difference in the actual and target positions
the internal circuitry generates a comparable pulse based on the internal pot measureng the position of the servo. this internal pulse is Exclusive-ORed with the external to generate an error signal pulse driving the motor. That pulse to the motor is zero when both are the same. a Load creates a miniscule shift in the pot resulting in a restoring pulse to the motor, drawing power
and that since servoPos is global, it's value doesn't need to be set each time thru loop, just when it's value is changed. Momentary switches could be used. you could try changing the workwi sim to use momentary buttons
Thanks. So, the load of an indicator needle on a gage may not overcome the friction of the servo's drive mechanism but a an airplane's control surfaces holding position against aerodynamic forces probably would. @mattijs did not specify the application.
Also, even if the servo requires no motor power to hold position, it still requires input pulses to specify that position. So, whatever device is supplying the pulses must dissipate power. Plus, power will always be dissipated in the servo's control electronics. @mattijs's requirement of "dont (sic) want to draw power" was poorly specified.