Go Down

Topic: [issue] Loosing connectivity to my servo (Read 926 times) previous topic - next topic

yokankun

Hello,

I'm a newbie at arduino and I'm having an issue with my project.

I'm controling a modified servo for continuous rotation with my arduino uno and a IR remote. The project is to make a clock for a theater play. The clock will quickly move forward or backward to do a "time travel"  :)

The project is working but only for a random time period (10min to several hours) the motor doesn't move anymore. My code is not very clean but I tried several modification to check is a specific part was the issue without success. The easy way is to do a hard reset on the board or manually plugin/unpluging the servo. The arduino is powered with a 12V 1.5A DC power. I also must says that my soldering on the servo was not very clean...  :smiley-red:

I first tought the servo attach and detach was the issue but I tried a code only with one attach in the setup fct and the issue was still here.

Would you have an idea of the issue or a way to debug it ?

Thanks for your help!  :)

Code: [Select]


#include <IRremote.h>
#include <Servo.h>

int IR_PIN = 11;
int SERVO_PIN = 10;
int cpt_time = 0;
Servo myservo;

int SERVO_STOP = 72;
IRrecv irrecv(IR_PIN);
decode_results results;


void setup()
{
  irrecv.enableIRIn(); // Start the receiver
  Serial.begin(9600);
}

void loop() {
  if (irrecv.decode(&results)) {               //received something on IR
    myservo.attach(SERVO_PIN);          //prepare the motor
    myservo.write(SERVO_STOP);         //don't move
    if (results.value==16712445) {          //goes backward - |<<
      Serial.println("-- Starting backward");
       myservo.write(110);                       
       delay(25000);                                     //go back to 9pm
       Serial.println("-- Finished Backward");
    }
    if (results.value==16761405) {  //goes forward - >>|
      Serial.println("++ Started Forward");
       myservo.write(1);
       delay(22000);                               //go to 10am
       Serial.println("++ Finished forward");
    } 
    if (results.value==16748655) {  //correct time - forward
       myservo.write(68);
       delay(600);   
    }
    myservo.detach();
    irrecv.resume(); // Receive the next value
    cpt_time=0;
    Serial.println("Resumed listening");
  }
  //simulate a standard clock. Uses if to avoid a long delay to allow remote to work
  if(cpt_time==800){
    myservo.attach(SERVO_PIN);   
    myservo.write(SERVO_STOP);
    myservo.write(69);
    delay(80); 
    myservo.detach();
    cpt_time=0;
    Serial.println("Tic Tac");
  }
  else{
    delay(50);
    cpt_time++;
  }
 
}

MarkT

Definitely call attach once only in setup, there's no point detaching and re-attaching, its
likely to give the servo hiccups!

Your power may be the issue, not the code - can you draw, photograph or describe the
whole circuit set-up for us?  You have separate supply for the servo to the Arduino right?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

yokankun

Hi,

Thanks for your answer! If I don't detach my servo, it moves a little all the time, probably due to my bad soldering... But i tried without the detatch and re attach, I have the same issue.

I power everything through the arduino, my servo is a MG996r. Is that too much for the arduino to handle ?



DC 12V, 1.5A ---> Ardnuino uno <--(pin11) IR sensor(PNA4602)
                                   |   
                                   |
                              (pin11)
                        MG996r Servo     

Thanks

Robin2

Your diagram does not show where the servo is getting its power. If it is drawing from the Arduino 5v pin that may cause a problem if the servo draws a lot of current even for a very brief period. It is best to power the servo separately from the Arduino and to connect the Arduino GND to the servo power GND.

Try temporarily powering the servo from 4 AA NiMh cells.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

MarkT

Definitely avoid powering any servo, motor or relay from the 5V rail, its a good
way to fry the Arduino.

Inductive loads and delicate digital electronics should never share a supply rail
because one inductive voltage spike can trash all the semiconductors on the
board.  Also things like motors and servos pull large currents at stall, pulling the
voltage down and reseting the controller...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

yokankun

Thanks both for your answer. I'm now trying with an external 5V 1A powersupply for the motor and sensor and power my arduino through the usb from my pc. It seems to have resolved the issue.

So I'll need two power supply to be clean or can the arduino take it's power from the external 5V source as long as the power for the servo goes not through it (diagram below)? Or would it be cleaner to power my arduino with some AA battery and my motor with the 5V power ?

Is that correct ?

[5V] ---> Proto board   - - - > Motor + sensor
                          |                                        |
                          |                                        |
                     Arduino                              |
                          |                                        |
[GND]--------------------------------


Thank you!

Go Up