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