-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add the ability to draw arcs #8
Comments
I think the radius + angle works very well. I am seeing an issue on the arc-command branch - the penup and pendown commands no longer work. It looks like the changes to Timer2 are making it fire more interrupts, and these are causing timing issues with the delayMicroseconds() call in Mirobot::servoHandler(). It may be worth making sure any interrupt handlers do the minimum amount of work possible to minimize problems like these, but since I needed a quick fix I just disabled interrupts in servoHandler which works well enough in this case. Hope that helps. |
Glad the curves are working well - annoying it broke the pen lift :-) The timer interrupts are firing a lot more often because we need to run the steppers at different rates, but all it does for the majority of the time is just decrement a counter. I’ll have a play and see what I can do to coax it to work. It might be that the delay in there is being interrupted and breaking (I never liked the delay approach anyway as everything else is nicely non-blocking!) |
The curves are great, thank you! To avoid the delay could the pulse generation be handled by a PWM timer? I think the servo is conveniently on a PWM capable pin, if so then the timer could be set up for the correct pulse and a end-of-timer signal handler could manage stopping the timer after the 15 pulses. Just a thought. |
That's a good plan. I used to drive the servos via PWM but moved to the current method because it saves a lot of power and stops any jitter in the servo by not driving it when it's in the desired state. Will need to check which timer drives the PWM on that pin and make sure it doesn't clash with the stepper timing. |
@dgym take a look at the arc-command branch again - I've just pushed a commit which should fix the servo. Some background on what I did:
In the end I just disabled interrupts for the stepper driver once all steppers had stopped turning which seems to have fixed the issue. Give it a try and let me know how you get on. |
Hello, thank you for looking into this, that sounds like a good solution. I'll let you know how I get on when I next have a bot to try it on. |
That patch works very nicely thank you. I haven't seen any other issues and the arcs are really appreciated. |
Excellent! Thanks for testing. |
It would be nice to be able to draw arcs with Mirobot. Still need to figure out a reasonable way of specifying the arc radius and length that will make sense via the UI. e.g.
{"cmd":"arcleft", "arg":[50, 100]}
would draw a 50mm radius arc, curving to the left for 100 degrees
The text was updated successfully, but these errors were encountered: