Mini Maestro 12-Channel USB Servo Controller use to matlab

cargo is coming tomorrow
I need sample code for the example running matlab r2010a
I’m not an expert in MATLAB
be very happy codes can express this step by step
help pls

Thank you in advance would


You might find this post and code helpful:

The Mini Maestro 12’s serial protocol is a superset of the Micro Maestro’s protocol, so that code should work for either controller.

When you get it working, please post your code here and tell us anything else you had to do. This will help future people who are in your position.


I’m trying, but does not work
I’m not a good matlab user
can not send data
I’m doing wrong or Another need the extra code

What COM port did you choose in your code and why? Could you post your code here? What serial mode is Maestro currently configured to use? Could you explain what you mean by “it doesn’t work”? What do you expect to happen, and what actually happens? Are you able to control servos from the Maestro Control Center?


s2 = serial('COM8',...
'Baudrate',9600, ...
'DataBits',8, ...
'Parity','none', ...


com 8 is my command port

Are you able to control servos from the Maestro Control Center?
yes i can make it work
i control the servos as i wish.

What do you expect to happen, and what actually happens?
i want the servos to fix on data which i send

i didn’t make any adjustments on the card. i’ve contacted who is owner of the video at this link: ( . He’s shown me similar codes too. As a result, i couldn’t see the servos movement (not even a little bit movement). There’s something missing but what? Please help. Apologizes for my English. Thanks in advance

You need to use the Maestro Control Center to set the Maestro’s serial mode to USB Dual Port. Please try that and see if it helps.


I’m finding a very very strange incongruence between MATLAB and the manual.

Right now, if I set mode to 132, I get a percentage of full range as predefined for each channel as follows:

fwrite(s,[132,4,0, setting],‘uint8’)

where setting is 1…127. 1 gives the bottom of the range, and 127 gives the max. Nothing absolute, which the manual implied: “If the channel is configured as a servo, then the target represents the pulse width to transmit in units of quarter-microseconds.”

Also the short code “Set Target (Mini SSC protocol)” i.e. mode 255 doesnt work properly at all… It sets the servo to what looks like somewhere between 0 pulse and near 1800 pulses, on an absolute range. Just trying to understand, any ideas?

I am not sure what you mean by “nothing absolute”. The commands you mentioned are fully documented in the Maestro user’s guide, and the documentation for the Set Target command goes through an example command step-by-step to show you how the bytes of that command correspond to a target value. In the Status tab, the Maestro Control Center tells you exactly what the target value of each channel has been set to, in microseconds. How about you try sending a specific sequence of bytes to the Maestro from Matlab and then make sure the target shown in the Status tab is correct. If you think it is incorrect, please tell me the bytes you sent, what target value you see in the Maestro Control Center, and what value you would expect to see, and why you would expect to see it.



Im trying to use the code in Matlab and it transmit correctly (i think that because the led on the controller blinks when i click on RUN button on Matlab) my servo doesnt move. :frowning: . I also tried to prove other IDs on the board. I have no problem on Polulu Maestro Control Center, it Works.

I also dont know why to use UART fixed band rate, or USB Dual port, I have tried both, and my servo still unnamovible Apologize for my english. Hope you can help me :slight_smile:

Atte.Yazmin :smiley:


Are you able to move the servo properly by dragging its slider in the Status tab of the Maestro Control Center?


Adjusting the bytes that you send can be a little confusing. I have a simple MATLAB program that I use to adjust an ND filter. It takes an input of 0-100 and should be easy to follow.

function [servPort] = ND(density)
if density<=100 || density>=0
    position=round(1024+(1968-1024)*density/100);%adjust these values to move light and dark points
    servPort = serial('com5', 'BaudRate', 9600, 'InputBufferSize', 2048, 'DataBits', 8, 'Parity', 'none', 'StopBits', 1);
    valOne = bitand((position * 4),127);
    valTwo = bitshift(bitand((position *4),16256),-7);
    fwrite(servPort, [132,servo,valOne,valTwo]);
    disp('ND density seting must be between 0 and 100')

It is a little slow because it opens and closes the serial port each time, but it works.