Re: Using matlab to control Makergear
Posted: Fri Jul 21, 2017 3:06 pm
Ah, problem solved! Thanks to Josh's explanation of the gcode line number and checksum value, which can be omitted in all together. It seems that matlab has several ways of sending new line command, and this is the matlab code that worked.
Code: Select all
clear all
clc
arduino=serial('COM3','BaudRate',115200); % create serial communication object on port COM4
arduino.Terminator = {10, 13};
fopen(arduino); % initiate arduino communication
pause(5);
count = 0;
while arduino.BytesAvailable > 0
echo = fscanf(arduino);
disp(echo);
count = count + 1;
end
fprintf(arduino,'G28..');
disp('home');
pause(5);
fprintf(arduino, 'G01 X100 Y100');
disp('move');
pause(5);
fclose(arduino); % end communication with arduino