Speeding up servo writing from Matlab using Arduino

9 次查看(过去 30 天)
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!

回答(1 个)

Pratyay Pande
Pratyay Pande 2021-8-23
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by