Servo motor still generates heat after myservo.detach();

Thread Starter

Gabriel Cruz

Joined Oct 17, 2017
9
Hi, I have a project wherein the servo will be triggered after a pre set time using a Real Time Clock. The servo motor will "turn off" after 60 seconds. But the servo motor is still generating heat. Why is that? Here's my code.


C:
#include <DS1307.h>
#include <Servo.h>

Servo myservo;

int setHour = 22;
int setMin = 26;
int pos=0;
int uled = 9;

DS1307  rtc(SDA, SCL);
Time t;
void start();

void setup()
{
  pinMode(uled, OUTPUT);
  Serial.begin(9600);
  rtc.begin();
  myservo.attach(9);
}

void loop()
{
  t = rtc.getTime();

  Serial.print(rtc.getDOWStr());
  Serial.print(" ");

  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  Serial.println(rtc.getTimeStr());

  if (t.hour == setHour && t.min == setMin)
  {
    start();
  }
  else if (t.hour != setHour && t.min != setMin)
  {
    delay(250);
    myservo.detach();
  }
}

void start()
{
{
  for (pos = 0; pos <= 60; pos += 1) {
  
    myservo.write(pos);            
    delay(10);                      
  }
  for (pos = 60; pos >= 0; pos -= 1) {
    myservo.write(pos);            
    delay(10);                    
  }
}
}
 

Thread Starter

Gabriel Cruz

Joined Oct 17, 2017
9
In my code, isn't it that if the trigger (set hour and set min) is OFF, PWM pin 9 should not suppose to supply any voltage and therefore, the motor will not work. If I'm not right, kindly enlighten me. Thanks!
 

MrSoftware

Joined Oct 29, 2013
2,273
Check the data sheet for your servo. What is its behavior when there is no input signal. Does it "hold" its current position? You could test this yourself. Try to manually turn the servo when there is no input signal. Does it rotate freely, or does it fight you?
 

MaxHeadRoom

Joined Jul 18, 2013
30,772
What is the nature of the servo?
How is it driven past the output between the control and the motor?
I see it is a RC servo!!
I wish those posting about servo's would mention the nature of them, RC is quite a bit different from industrial servo's!
Max.
 

mcgyvr

Joined Oct 15, 2009
5,394
Servos like that have 3 wires.. power/ground/signal..
As soon as you apply power its using energy/dissipating heat..
Its in a "hold" position and is attempting to resist movement until a signal to change position is given on the signal wire..
"holding" is not a mechanical process but rather electrical and requires energy and thus generates heat..

You need to disconnect its power if you do not want it to draw power when not being signaled..
 

MrSoftware

Joined Oct 29, 2013
2,273
If the effort to manually move it is greater when there is no signal, than it is when there is no power at all, then the servo is fighing to stay in position. As mentioned above, to turn it "off" you need to remove power completely. You can use a mosfet or small relay controlled by your arduino to control the power to the servo.
 

Thread Starter

Gabriel Cruz

Joined Oct 17, 2017
9
Hi guys. I followed what you have said. I added a 5V relay that would "cut off" the power after the specified time. It works perfectly fine. The servo isn't resisting at all after the specified time. Here's my code for future references.

I would like to use this overnight and I'm planning to use a powerbank to supply the arduino. Will my arduino get fried in the process? Do I need to add any additional safety feature?



#include <DS1307.h>
#include <Servo.h>

Servo myservo;

int setHour = 10;
int setMin = 30;
int pos=0;
int uled = 9;


DS1307 rtc(SDA, SCL);
Time t;
void start();

void setup()
{
pinMode(uled, OUTPUT);
Serial.begin(9600);
rtc.begin();
myservo.attach(9);
pinMode(1, OUTPUT);
}

void loop()
{
t = rtc.getTime();

Serial.print(rtc.getDOWStr());
Serial.print(" ");

Serial.print(rtc.getDateStr());
Serial.print(" -- ");

Serial.println(rtc.getTimeStr());

if (t.hour == setHour && t.min == setMin)
{
start();
}
else if (t.hour != setHour && t.min != setMin)
{
delay(250);
myservo.detach();
digitalWrite(1, HIGH);
delay(250);


}
}

void start()
{
{
for (pos = 0; pos <= 60; pos += 1) {

myservo.write(pos);
delay(10);
}
for (pos = 60; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(10);
}
}
}
 
Top