Page 2 of 2

Re: Using matlab to control Makergear

Posted: Fri Jul 21, 2017 3:06 pm
by hanming
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

arduino=serial('COM3','BaudRate',115200); % create serial communication object on port COM4
arduino.Terminator = {10, 13};
fopen(arduino); % initiate arduino communication
count = 0;
while arduino.BytesAvailable > 0
    echo = fscanf(arduino);
    count = count + 1;
fprintf(arduino, 'G01 X100 Y100');
fclose(arduino); % end communication with arduino

Re: Using matlab to control Makergear

Posted: Mon Jul 24, 2017 3:09 am
by Tim
Hmm. I was trying various things using just straight-up fopen, fread, and fwrite, and just adding "\n\r" (characters 10 and 13) at the end of the string. I was using octave, not Matlab, and octave doesn't implement serial() except through the instrument-control package. According to what worked for you, that should have done something. But I didn't get a response to "G28". But what is the ".." in your "G28.." line?

Re: [Complete script] Using matlab to control Makergear

Posted: Wed Jul 26, 2017 9:10 pm
by hanming
I don't think the .. means anything. I get that from my serial spy, when repetier send each command. But everything works without it. I have my code updated in my first post.