LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with serial port synchronization.

Hello to all!
 
I have an oxygen analyser, the equipment has a serial port for communication, being based the communication on the AK communication protocol.
In order to request to the equipment that responds with the measured value, the following command in hexadecimal is sent:  (02 78474B4FE20 03), obtaining like hexadecimal answer the following: (02 58474B4FE203220323038353030 03), in which it is included the measured value.
I need to have the measurement from equipment in a PC, using the AK protocol and the serial port. For this, I have made a (vi) that it writes the read measure command in the serial port, wait a time (150ms) and read the port, this way everything works correctly, but there is a problem and it is that the communication is very slow due to the delay between the writing and the reading.
If I eliminate the delay, the synchronization between the writing and the reading is lost, appearing readings of value 0. I think that is because the PC read the port and the analyser not yet has responded to the request from PC, and this happens in spite of using the options of synchronization of visa read and visa write vi's, (Do I/O synchronously).
I would need to design a (vi) that hoped that the equipment had sent the last data, and then it sends the reading request again, being able this way to make the communication more fast and to eliminate the erroneous readings.
I have attached two examples, first is (vi) that works well, but has the problem of being slow due to the delay, and the second analyzes the received message to know when this complete and then it writes another message of read to analyser, but it appears to me an error (ocurred AT sights read... Time out) after minutes.
I would thank any aid that somebody could offer to me.
Greetings and thanks!
0 Kudos
Message 1 of 5
(4,402 Views)
I don't have a serial port connected on this machine at the moment (they are becoming rare on laptops!) but try this code as a starting place. I notice in your second example you are basing the read on receiving a specific string, in the one I've made you can set the bytes at port compare to a number equivalent in length. I haven't tried it, as I mentioned before, so I appologize for any errors in my code.
 
P.M.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 5
(4,385 Views)

I have a LV7.0, i can not open the file. Can you send me in LV7.0 format?

Thanks!

0 Kudos
Message 3 of 5
(4,365 Views)

here it is

P.M.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 4 of 5
(4,348 Views)
Is it right, that all communication start with x02 and end with x03 ? (and that x03 is only send as a termination character?)
 
If YES then you can set the termination character in the Serial init to x03 , choose a maximum timeout  and max character to read and you're done
 
Some instruments can be setup in a way to continuously send out the most recent value. Like that you get the max. measuring speed.
 
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 5
(4,334 Views)