Hi all!
I’m currently trying to use Matlab to control servos through the Mini Maestro-18 servo controller. I’ve been using the sample code that I’ve found in these forums:
function moveServo(s,x,port)
x = max(500,x);
x = min(5500,x);
ser1 = serial(port);
set(ser1, 'InputBufferSize', 2048);
set(ser1, 'BaudRate', 9600);
set(ser1, 'DataBits', 8);
set(ser1, 'Parity', 'none');
set(ser1, 'StopBits', 1);
fopen(ser1); %initialize
AA = [170,12,4,s, binvec2dec(bitget(x,8:13)), binvec2dec(bitget(x,1:7))];
fwrite(ser1, AA);
fclose(ser1);
delete(ser1);
end
Pretty standard stuff, with the parameters modified to match the Mini Maestro user guide. When I send the command through Matlab, the green led indicator flashes to show that the message was sent, but the servo doesn’t move at all.
For the longest time I thought it was just some issue with the Matlab code, but then I also used the Serial Transmitter Tool and even tried some sample byte sequences as shown in the user guide, but the same thing would happen. I can’t even get the serial transmitter to read the servo position.
Has anyone else had issues with serial communication with the Mini Maestro-18 board? The only other issue I can think of is that there might be something wrong with how I connected the board, but it works fine through the Maestro Control Center, and all I’m doing is sending commands through the USB connection. Some older forum posts mention that I should be using the jumper to specify the code protocol, but with these Maestro boards, that should be done automatically based on the first byte that gets sent, right?
Also, I’m a bit confused about how serial control will work. Once I send the target move command (assuming that I’m able to at some point), does the servo hold this position actively? I feel as though there should be some “enable” command much like how the Control Center can enable/disable servos.
Thanks for everyone’s time!
Ray