LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

motorola serial data parsing

I am trying to read and parse serial data from a motorola HCS08 microcontroller. This unit is part of the Freescale development kit. The data string format is: x{data}y{data}z{data}. Data is in hex value. This is a big-endian output and I am not sure what function to use with Labview 7.1.

I have based the VI on the Visa serial read VI + the match pattern function. Would like to extract the data, convert to decimal values and store in a spreadsheet file. Any help is greatly appreciated.

PGH
0 Kudos
Message 1 of 10
(4,099 Views)
try this to parse your data. 7.0  format
Message 2 of 10
(4,092 Views)
Thanks Unclebump for the VI. Your VI has helped me greatly. I wired it to the serial read VI, and modified the operators by removing the brackets. My operators are now %x %y %z. I'm guessing the output tokens are data for each character string. Motorola tells me that the data is from an ADC, which is hex that needs to be converted to decimal format (0-255). Now I will try to convert to numerical values to fill the string array.
 
Thanks again,
 
winskate
pgh@pherrmann.com
0 Kudos
Message 3 of 10
(4,060 Views)
The parse data works fine using a manual string input, however when string is sent from the processor, it is all in hex values. Attached is a sample of data: the first two lines are data received in hyperterminal, and following lines are hex converted with Vedit. I believe the strings need to be byte seperated, scanned for hex character and then extract the data values for each axis (xyz) and sent to an array.

Any help for doing this in LV 7.1 would be greatly appreciated.

PGH


0 Kudos
Message 4 of 10
(4,044 Views)

Sorry for the delay, I was on vacation yesterday. See what this link gets you. Search hex to ascii in the discussion forums.

 

http://digital.ni.com/public.nsf/websearch/77c8f61d36f5a23086256634005acb38

0 Kudos
Message 5 of 10
(4,019 Views)
This might get you started. 7.0 format
0 Kudos
Message 6 of 10
(4,007 Views)
Thanks for all the help, I'm getting close now. I have seperated the data values for each axis, now I need to convert the characters to (0-255) decimal values. I would like to place the values into a horizontal array and write to a spreadsheet. Any help would be appreciated.

PGHSmiley Tongue
0 Kudos
Message 7 of 10
(3,981 Views)

PGH,

To convert your data from a string back to a number, simply use the reverse of the same conversion method you used before (String to Byte Array.vi). Since your data is in an array of strings, you will need to use a for loop to index the array and convert each character one-by-one. Since the String to Byte Array.vi returns a number that is already within an array, you will need to insert it into a pre-existing array rather than index into an array (which would create a 2D array). I've posted a picture below about this concept.

Once you have an array of numeric data, you can simply connect it to the Write to Spreadsheet File.vi.

Kind Regards,

Message Edited by AESulzer on 11-22-2005 05:19 PM

E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 8 of 10
(3,964 Views)
Thanks for the help. I am having a problem using the serial visa VI. I can view the hex data streaming in, however the conversion function does not pass the data through. If I paste a hex string (78 AE 79 AE 7A AE) into the conversion function it works fine. I have attached 2 VI's, can you help?
Download All
0 Kudos
Message 9 of 10
(3,956 Views)

PGH,

I can not execute your code to see the behavior because I do not have the same hardware setup that you have, but I would recommend simply debugging your code. For instance, have you looked at what string is actually being returned by the VISA Read (either by attaching an indicator to the output or by using probes)? Perhaps the data you are receiving is actually a real string and not hex data afterall, or perhaps the wrong command to get the data is being written and no data is being returned. I would definitely check that VISA Read output -- it will tell you a lot.

Kind Regards,

E. Sulzer
Applications Engineer
National Instruments
0 Kudos
Message 10 of 10
(3,918 Views)