adham-elarabawy / open-quadruped

An open-source 3D-printed quadrupedal robot. Intuitive gait generation through 12-DOF Bezier Curves. Full 6-axis body pose manipulation. Custom 3DOF Leg Inverse Kinematics Model accounting for offsets.
https://adhamelarabawy.com
Other
365 stars 68 forks source link

Servo Detach() function #1

Open mano1979 opened 4 years ago

mano1979 commented 4 years ago

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

adham-elarabawy commented 4 years ago

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

mano1979 commented 4 years ago

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?

adham-elarabawy commented 4 years ago

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.

mano1979 commented 4 years ago

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

adham-elarabawy commented 4 years ago

I'll take a look.