Speeding up servo writing from Matlab using Arduino

2 views (last 30 days)
Munir Suleman
Munir Suleman on 19 Aug 2019
Answered: Pratyay Pande on 23 Aug 2021
Hi all
I currently have a set up of 20 servo motors that move according to something i'm moving. (i.e. theres something capturing the position of the thing i'm moving and those values are mapped to positions of the servos). I'm using matlab to write the position to the servos which are connected to the Arduino Mega.
My problem is that I want it to be moving smoothly, or atlest smoother than it is now. Since the thing i'm using to capture my motion is at 90fps, for a smooth motion I need the code to run as quickly as it can. I think the 'writePosition' function is really slow. It took 0.2sec to run through 20 'writePosition's.
My question is, is there a quicker way to send the servo position from Matlab to the arduino for a large number of servos?
Thanks!

Answers (1)

Pratyay Pande
Pratyay Pande on 23 Aug 2021
This is a known limitation due to our API using the Arduino write command rather than the writeMicroSeconds command. The development team is aware of this issue and may consider this enhancement for a future release.
As a temporary workaround, you can create a custom add-on library and upload it to the Arduino board. This library can call the writeMicroSeconds command as desired. You can refer to the link here to see the documentation on this feature.
If you are using Windows, you can also refer to this post for information on low-latency communication with an Arduino board.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by