PDA

View Full Version : [Project] Sinusoidal Servo control using MATLAB



shulnak09
02-08-2019, 01:53 PM
I am working on a project which involves actuation of a part that has to move sinusoidaly. Suppose, I have to continuously move my servo to and fro between two positions such that the rpm is not fixed through out the cycle, rather it has to vary according to different mathematical functions like a sine function.

Is it possible to actuate Dynamixel 12A in similar fashion using MATLAB only?

Any help would be great

jwatte
02-09-2019, 01:14 PM
The best you can do is to send a very high speed stream of updates -- say, 100 Hz -- for where you want the position to be.

Let the control algorithm and damping inherent in the servo then drive the speed curve. This will given okay results, although they will be jittery at low velocities. This is not so much because of the control algorithm, but because of the limited resolution in the position sensor (1024 or 4096 for the AX / MX series.)

You can also attempt to send a "target velocity" update together with the "target position," but I've found that to be very hard to get to work smoothly; presumably because of the same encoder resolution problem multiplying out by the small size of the control loop timestamp.

shulnak09
02-10-2019, 08:22 PM
Hi Jwatte

Thanks for the reply. Are you suggesting that I need to implement the sine function as an array of elements with 100 data being written into the motor per second through MATLAB. I know with lower resolution of AX/ MX series controlling becomes very difficult.

Today, I tried with Arduino and Matlab, the servo control works fine but with Matlab only (which my professor wants since we need to reset arduino with new code), it becomes difficult. I used the ReadWrite.m (protocol 1.0) provided by the Dynamixel Github to actuate the motor. I am able to control the goal position and speed but not able to give speed as a variable between two goal position.

Can you look at the code once and suggest any modifications to have sine output?

https://drive.google.com/file/d/1dqIkyG51fr0nFjR940M5zUfX7wLR84r7/view?usp=sharing

I am very new to this field and have just started with coding in MATLAB. So any suggestion or tutorials to study will be of great help.

Thanks and regards
Anshul

jwatte
02-11-2019, 12:13 PM
I don't know how fast Matlab can run -- can it run at 100 Hz itself? If not, then you're going to have to live with whatever it can do ...