How to not draw power when system is not active

hello,

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);
}

Thanks in advance!

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).

1 Like

Is there any load on the servo when it is in either of its two positions ?

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.

would be better to make this an if/else if. what would happen if both buttons were pressed a the same time

  if (digitalRead(5)) {
    servoPos = 0;                 //closed position
  }
  else if (digitalRead(7)) {
     servoPos = 180;              //open position
  }

That is not possible, it will always draw current with the switch closed.

Doesn't a Servo also require power to hold a constant position against a load? Verses a stepper motor?

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

image8 (1)

theres only a switch with 2 positions so no buttons
someting like this: servo with switch - Wokwi ESP32, STM32, Arduino Simulator

hopefully you see my point

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.

1 Like

alright, thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.