From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How separate date from serial port (RS-232)?

Hello, excuse me for my English (I am from Russia).

Problem. I resive binary date from my device by com port. That string (8 byte, speed 57600):

MARK1--low_byte1--hi_byte1--END1--MARK2--low_byte2--hi_byte2-END1, etceteras. (MARK - number of channel, low_byte - 1-st byte from 10-bit ADC, hi_byte - from 10-bit ADC)

As you can see, it is a multichannel (2 channel) system data acquisition(homemade).

I need disjoint this packet for digital graph.

How i can disjoint date?

Thank you!

Message Edited by mihalis on 06-27-2005 07:13 AM

0 Kudos
Message 1 of 8
(3,038 Views)
Hello Mihalis, one way to do this is to convert the string to a byte array (in function palette, String -> String/Array/Path Conversion), then index out the desired elements and composing the final value with Join Numbers (Advanced -> Data Manipulation)

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 8
(3,019 Views)
Hello mihalis,
I would parse the binary data stream in the "smallest repeating increment". Build your RS232 communications to continuously stream the binary data into your host application. In the host application continuously read the stream looking for this "smallest repeating increment". Each time a complete "smallest repeating increment" is found parse (perhaps more than one kind of parse for more than one type of message) that into the numbers you need. Ignore inclomplete or non-conforming "smallest repeating increments", and wait for the next complete conforming "smallest repeating increment". The advantage of this method is that you do not store the raw serial port information in blocks in memory, and the memory use can be constant so it can run "in-place" in memory which will make it fast so it can keep up with your 57600 speed.
..
Specifically in your example: look for the "smallest repeating increment" MARK(n)--low_byte(n)--hi_byte(n)--END(n)and convert these into the numeric representation, store or pass to the applicaiton only the numeric. For your two channel applicaion your numbers will be interleaved: Ch1,Ch2,Ch1,Ch2 etc.. If you build these into a one dimensional array you can use the LabVIEW function "Decimate 1D Array" to get separate 1D arrays of each channel. You might also build a cluster of the two channels or directly build a 2D array, these later examples would work better if you treat the two channels as one "smallest repeating increment" MARK1--low_byte1--hi_byte1--END1--MARK2--low_byte2--hi_byte2-END2, with the advantage of preventing channels from getting mixed up.
..
I do not know where in these data the date is. If you have a separate source for the date and time, read that each time you parse a "smallest repeating increment" and place the date and time into a cluster with the two channels of data and build an array of these. Graph these two channels vs. date and time by using the XY graph. For each channel make an array of clusters of dateTime in cluster oder 0 and channel data in cluster order 1 and build these each into an array then cluster these arrays to display on you XY graph, this will be a plot of both channels vs. time.
..
I hope that helps.
0 Kudos
Message 3 of 8
(2,991 Views)
Thank you for the reply Paolo and BoxTrooper! You answers is very helpful for me. My computer was broken, and i can not answer to you.

Paulo, you say: "one way to do this is to convert the string to a byte array (in function palette, String -> String/Array/Path Conversion), then index out the desired elements and composing the final value with Join Numbers (Advanced -> Data Manipulation)." How i can "index out" desired elements?

Thank you very much!

Message Edited by mihalis on 07-01-2005 12:01 AM

0 Kudos
Message 4 of 8
(2,950 Views)
Mihalis,
the attached vi uses several functions extremely usefull for this type of problem :
-the type cast function convert a data stream to (nearly) any type of data structure,
- the unbundle by name, in association with the for loop allows the direct reading of the data elements, the swap byte do the indian format conversion.

Hope this helps...
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Message 5 of 8
(2,933 Views)
Hi Mihalis, I simply meant that once you have the byte array, you can extract the desired elements one at a time by using the function "Index Array", to be found in the Array function palette.
I apologize for my obscure jargon.

Ciao dall'Italia

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 8
(2,923 Views)

Hello Paolo! It`s all right! I am understand you. (Some problem with English Smiley Happy).

Thak you,  "chilly charly" and BoxTrooper for help!!!

I now LabView  less then 2 weeks, therefore to many simple questions. 

 

Message Edited by Mihalis on 07-01-2005 08:03 PM

0 Kudos
Message 7 of 8
(2,895 Views)
Hello all ! Sorry, but I need you help again.
 
I use the attached vi, but I can`t unbundle by name my string fron com-port. I can`t understand, how vi work.
 
Please, explain me, how i can unbundle my string whith this vi. In my first messege i give format of my string.
And how a can plot graph of both channals?
Thank you!
0 Kudos
Message 8 of 8
(2,849 Views)