LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Asynchronous Serial Data Processing

I am trying to figure out how to take an asychronous serial data stream into labview and build a case structure to process the data. I have a microcontroller sending data RS-232 into an RS-232 to usb converter. I have successfully read the port in the Measurement Visa session, so I know Labview sees the data. I just cant get anything going in a VI. Here is what I need to do. I will have a data stream coming into LabVIEW. I will have an ASCII character followed by a data Byte (or possible a word (2 bytes)if necesary). There will be four cases. The four cases are Engine Temp, Engine RPM, Altitude, and Acceleration (3 axis). So the microcontroller will be sampling sensors and sending the data out to LabVIEW. The code for the micr
ocontroller currently precedes the raw data with an ASCII Character, so for instance, the microcontroller will sample engine RPM, then it sends ASCII " r " and then the data byte. How do I set up a case structure whereby I can get labview to recognize "if ASCII " r " comes in, the following byte is routed to a gauge" (with some intermediate math of course), then when ASCII " t " comes, the following Word is a temp data to go to a temp gauge, so on so forth. This is sort of a ghetto input setup, but it works. There is no handshaking or anything of that nature. Just LabVIEW reading the serial input stream. Hopefully this makes sense. Let me know where I can find the info I need. Cant find it on the site here. Thanks in advance. Jeremiah
Message 1 of 3
(2,856 Views)
hi,

first: create a state diagram (on paper or whatever tool) of how you want procede with your byte stream.
think of identical ASCII-byte-code and your data byte, timeout and incorrect data, etc.

read out your (visa) com port byte by byte and create a state-engine in LV. look into examples and search for templates or vi you might use.
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 ǝɥʇ'


Message 2 of 3
(2,856 Views)
I assume in LabVIEW your data will come in as a string. When you receive the string extract the first character of the string (Parse String) and wire it to the case selector of a Case Structure. Route the rest of the string separately into the case. Create different cases for each of the possible data items ('r', 't', etc.). You can create additional cases by right clicking on the edge of the Case structure and selecting 'Add Case After'. Name each case using the cursor tool and typing your desired selection string (e.g. 'r') in the label of each case.

In each of these cases process the string according to the data it represents (convert from string to number, scale the value) and then write it to the front panel display or store it otherwise.

S
ee the attached example.

Christian L
authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
Message 3 of 3
(2,855 Views)