Go Down

Topic: Servo gone crazy: moves without me sending command. (Read 2 times) previous topic - next topic

ldfka


Quote
Now that I almost fish assembling my robot

I love the idea of fish assembling a robot, what sort of fish bass, bream or salmon?


I meant 'finish', never mind my tuna brain :D

The reason why a servo moves like this is that it's input line is floating. This can be due to not initialising the pins connecting the servo as an output. I see in your code you don't do this, so add those lines and try again.


OK will try the code bellow. But though it use to work fine with this code. And I expect the servo controller to initialise the servo correctly.
Could you be more precise about what you mean by 'input line is floating'?

Thanks a lot for your help.

Grumpy_Mike

When a line is an input it is not exerting any voltage pull in any direction. Doing a digitalWrite() on an input pin turns on an off the 30K internal pull up resistor. This is too high an impedance for some of your servos (your bad ones) but it looks like it is just enough for your other servos, but it is not very good.

Quote
And I expect the servo controller to initialise the servo correctly

You might expect it but no.

For more on floating inputs, see:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

johnwasser


Quote
And I expect the servo controller to initialise the servo correctly

You might expect it but no.


That call to pinMode( pin, OUTPUT) in the Servo library looks like it should initialize the pin correctly:
Code: [Select]

uint8_t Servo::attach(int pin, int min, int max)
{
  if(this->servoIndex < MAX_SERVOS ) {
    pinMode( pin, OUTPUT) ;                                 // set servo pin to output
    servos[this->servoIndex].Pin.nbr = pin; 
    // todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
    this->min  = (MIN_PULSE_WIDTH - min)/4; //resolution of min/max is 4 uS
    this->max  = (MAX_PULSE_WIDTH - max)/4;
    // initialize the timer if it has not already been initialized
    timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
    if(isTimerActive(timer) == false)
      initISR(timer);   
    servos[this->servoIndex].Pin.isActive = true;  // this must be set after the check for isTimerActive
  }
  return this->servoIndex ;
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

ldfka


When a line is an input it is not exerting any voltage pull in any direction. Doing a digitalWrite() on an input pin turns on an off the 30K internal pull up resistor. This is too high an impedance for some of your servos (your bad ones) but it looks like it is just enough for your other servos, but it is not very good.

Quote
And I expect the servo controller to initialise the servo correctly

You might expect it but no.

For more on floating inputs, see:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html


Hmm not sure I understood this, to me I'm using an output which send a pulse of X ms to the servo and not an input.
Maybe it would help me if you tell me between which pin of the servo you advise to put a pull up resistor?

Thanks!

Grumpy_Mike

Quote
to me I'm using an output which send a pulse of X ms to the servo and not an input.

So initialise the pin as an output, you were not doing that in your code.

Go Up