Speeding up servo writing from Matlab using Arduino

9 ビュー (過去 30 日間)
Munir Suleman
Munir Suleman 2019 年 8 月 19 日
回答済み: Pratyay Pande 2021 年 8 月 23 日
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 Center および File ExchangeMATLAB 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