Hello,
I have a Micro Maestro 6-Channel USB Servo Controller, an external power supply and a Modelcraft WG-90MG Servo. The command port is COM3, the TTL port is COM4. My Servo is connected to channel 5. Controlling the Servo via the “Pololu Maestro Control center” works fine. So the first hurdle is overcome.
Now I would like to control my Servo via Matlab (for the first trial, just bring it into a specific position). Unfortunately, I’m an absolute newbie regarding electro-technical stuff. By reading some code snippets in the internet, I think I have at least now found out how to establish a connection between Matlab and the Pololu (though I’m not sure whether the parameters are correct ):
port = 'COM3'; % Opens COM Port associated with Pololu
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); % Make communication between MATLAB and Pololu
% fwrite(ser1, [128, 5, 5, 0, binvec2dec(bitget(4500,8:13)), binvec2dec(bitget(4500,1:7))]);
fwrite(ser1, ???what comes here???);
fclose(ser1); % Closes communication line between MATLAB and Pololu
delete(ser1);
However, where I get stuck is the line where it comes to actually send a servo command to the Pololu. I just don’t know what I have to put into this line (I mean the second input parameter of the fwrite() function)? How do I tell Pololu “Move the Servo on channel 5 to position X”? I have already looked at the User guide here: pololu.com/docs/0J40/5.e, but unfortunately I just do not understand it, sorry.
I would be very happy to get some advice from you.