open-quadruped icon indicating copy to clipboard operation
open-quadruped copied to clipboard

Servo Detach() function

Open mano1979 opened this issue 4 years ago • 5 comments

I wondered if you could add a function like this to the servo control code. It is to detach the servos and thus make them loose power. This is handy for shutting the robot down in an emergency for example. i am not familiar enough with your code yet so i can not implement it myself.

Here is the piece of code from the normal arduino Servo.cpp:

void Servo::detach() { servos[this->servoIndex].Pin.isActive = false; timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex); if(isTimerActive(timer) == false) { finISR(timer); } }

mano1979 avatar Jun 24 '20 15:06 mano1979

Great Idea! I will put this on the to-do list.

adham-elarabawy avatar Jun 24 '20 21:06 adham-elarabawy

Also, is this teensy code complete? I cannot find any pin definitions anywhere. Where do you tell it to use the GPIO 2-12 for the servos?

mano1979 avatar Jun 25 '20 09:06 mano1979

I haven't properly documented everything yet. The plan is to do that sometime this week.

I tried to servo.detach() that you mentioned, but it doesn't really release the servos in the way that I expected. Most servos hold their positions when you detach them, not actually release servo power. This behavior is equivalent to my estop functionality on the teensy, which halts all the servos as soon as 'e' or 'E' is sent over serial, so I think servo.detach is redundant.

adham-elarabawy avatar Jun 30 '20 06:06 adham-elarabawy

I found this topic online that explains why it doesn't work and a possible workaround. it seems the timers on the teensy aren't reset when a servo is detached, keeping the PWM signal alive ( if i understood right).

I first found this https://forum.arduino.cc/index.php?topic=70998.0 leading to this: https://github.com/arduino/Arduino/issues/3860

mano1979 avatar Jul 07 '20 16:07 mano1979

I'll take a look.

adham-elarabawy avatar Jul 11 '20 12:07 adham-elarabawy