Greetings,
I have adopted two programs that work individually and I want to combine them.
1- A micro-CNC Arduino UNO program from
that allows me to send a Gcode command line to a Shapeoko CNC via Arduino IDE GUI Tools>Serial Monitor such as G91;G01X1000Y0F1;G01X0Y900F1;G01X-1000Y0F1;G01X0Y-900F1;
that moves the CNC bit along a 2D rectangular path.
2- A windows PC resident Gobetwino program from
to read from a file on the PC line by line and send it to the serial port.
Would it be possible to combine these two programs so the micro-CNC would be commanded via a Gobetwino to read a Gcode machine code file (resident on PC) one line at the time thoroughly to do a machining job?
The marginally Clever program for Arduino has the following structures
- setup
- loop
- process command
- Parse each command
void loop() {
// listen for commands
while(Serial.available() > 0) { // if something is available
char c=Serial.read(); // get it
...........
processCommand()
void processCommand() {
// look for commands that start with 'G'
int cmd=parsenumber('G',-1);
switch(cmd) {
...
cmd=parsenumber('M',-1);
switch(cmd) {
...
float parsenumber(char code,float val) {
char *ptr=buffer;
while(ptr && *ptr && ptr<buffer+sofar) {
if(*ptr==code) {
return atof(ptr+1);
}
ptr=strchr(ptr,' ')+1;
}
return val;
}
and for Gobetwino:
- setup
- loop
- read serial string
void readSerialString (char *strArray,long timeOut) {
// Wait up to timeOut miliseconds for data to arrive at the serial port, then read the data and put it in the char array strArray
long startTime=millis();
int i;
while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray = Serial.read();
- i++;*
- }*
}
So when I run the Gobetwino program and I can see the Gcode line on its serial window, Does Arduino also see the same line? So why it doesn't respond? Is it a matter of data format? or should I write it again to the serial port?