Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servo Detach() function #1

Open
mano1979 opened this issue Jun 24, 2020 · 5 comments
Open

Servo Detach() function #1

mano1979 opened this issue Jun 24, 2020 · 5 comments

Comments

@mano1979
Copy link

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
Copy link
Owner

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

@mano1979
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

mano1979 commented Jul 7, 2020

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:
arduino/Arduino#3860

adham-elarabawy added a commit that referenced this issue Jul 9, 2020
@adham-elarabawy
Copy link
Owner

I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants