I used Matlab Instrument Control Toolbox, and below is my code. However, the code cannot drive the board to output the signal, could anyone help check if my command signal is correct or not?
I used an oscilloscope to check the last port (port 5, index starts at 0) for my Maestro 6. When I use the Pololu Maestro Control Center, the port will output a periodic square wave, with duty cycle being adjusted when I drag the bar left and right. However, when I switch to Matlab, the oscilloscope values always read at 0.
DCMotor = serial(âCOM3â,âBaudrateâ,9600,âDataBitsâ,8,âParityâ,ânoneâ,âInputBufferSizeâ,16384);
fopen(DCMotor); %Open the motor
%% Maestro 6 controller
fwrite(DCMotor,170,âuint8â) %Initialize the Motor
pause(0.1)
fwrite(DCMotor ,[132,5,112,46],âuint8â); % write to port 6th port (0,1,2,3,4,5), Compact protocal
txdata = [âAAâ;â06â;â04â;â05â;â70â;â2Eâ];
%Convert to decimal format
txdata_dec = hex2dec(txdata);
%Write using the UINT8 data format
fwrite(DCMotor,txdata_dec,âuint8â); % Pololu protocal
%%
fclose(DCMotor); %Close the motor