07-23-2017 08:15 AM
I have attached a VI.
A separate MCU board, sends data on computer COM port, in ascii format as below:
$-999.999;-999.999?
Total length of string is 19 max. It can be less than 19 also, for example number is small like $9.999;9.999?
VI, continuously scans for 38 bytes of string, Then serach for $ & then take out two numbers in between from them. In VI,number separted are in string Voltage & Current.
Now sometimes, I read incorrect string also. So is there anyway to check the Voltage & Current strings, if they contain valid number between -999.999 to 999.999
07-23-2017 10:58 AM
So how does the received string look like when you get an error?
To analyze the problem, that's where you need to start. Could it be that sometimes you receive incomplete strings or have frame shifts where the numbers are spread over multiple reads? Why not define a termination character (e.g. ?) for the communication?
How fast does the data arrive at the serial port? Waiting 1s between reads seems like a long time.
I assume that you are aware that your "VISA close" can never execute.
To identify the problem: As a first step log the received strings into an array, wait until the problem happens, stop the program (where is your stop button???) and then analyze the strings. It should be obvious and is probably one of the above mentioned issues.
07-23-2017 11:29 AM
I have two suggestions.
Bob Schor