Hi all thanks for the help so far. Robin 2, your guide is fantastic. With your help I have made significant progress and am almost there. I modified my code and tested it using serial monitor with an arduino connected to my computer, like that it works perfectly.
However, when I connect it to the machine that I am trying to pull the data from (a Haas VF-2 CNC mill) it just says zero. I know I can communicate with the machine because I have gotten it to report jumbled versions of the message with various old versions of my code. I have also communicated with the machine using Putty and a laptop. But, it will not work for some reason.
Could you please look at what I have below and see if you can suggest anything I might be missing? thanks in advance again.
Here is what I have:
-Haas’s website says the machine will respond with this format: Begins with > and ends with /r/n (aren’t those slashes backwards? Could that be a clue?) Here is link to Haas’s info if that helps. https://diy.haascnc.com/reference-docs/next-generation-control-machine-data-collection#gsc.tab=0
-When I communicate with the machine through putty with my laptop it works and the response is shown in attached picture
-Here is the relevant portion of the code I using:
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = ‘>’;
char endMarker = ‘/r/n’;
char rc;
while (Serial.available() > 0 && newData == false) {
Serial.write(“Q600 3022 \n”);
delay (500);
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = ‘\0’; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
Attached also is the entire (somewhat messy and glued together) code I’m using if it helps. For context, I am reading the timer value off the Haas, doing some logic, and showing a number on an LCD display as well as on a web page. Right now I’m just trying to even communicate with the haas and read it’s value correctly. The rest of the code works without problems.
sketch_jul19a.ino (9.11 KB)