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 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