Open mano1979 opened 4 years ago
Great Idea! I will put this on the to-do list.
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?
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.
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
I'll take a look.
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); } }