LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

conversion of a binary data stream to decimal numbers

Hi
 
I am having great difficult working out how to convert my binary data stream to decimal numbers.
 

The data I am reading back is in the format of a binary string, starting with the Most Significant Bit (MSB) of the first word, then the corresponding Least Significant Bit (LSB), where a word is two bytes long. A carriage return indicates message termination.  The return message starts with ‘bin,’ followed by the number of bytes requested. No delimiters are used to separate the data, but a carriage return is appended onto the end of the data.

bin,<first word msb><first word lsb>...<last word lsb><CR>

e.g. bin,$ro¬z1;@*...etc

Does anybody know of any examaple vi that can help me convert this data from binary to decimal numbers?

Many Thanks

Ash

 

 

 

0 Kudos
Message 1 of 5
(4,007 Views)

Ash

Can you post your VI with example data?

thanks

David

0 Kudos
Message 2 of 5
(3,997 Views)
Hi Ashley,

after getting the string you can strip the first 4 characters. After this try a typecasting to array of U16. If the numbers are not correct, you can add a swap bytes operation to the resulting array.

Message Edited by GerdW on 09-13-2006 02:46 PM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 5
(3,994 Views)
Hi David
 
Attached is my vi
 
This is the data format:
 
bin,E€H€I€I€I€H€I€G€H€HI€I€K€I€I€I€I€I€H€II€I€H€I€I€I€K€I€I€HI€I€I€H€I€K€I€I€J€KI€K€I€I€I€H€I etc...... <cr>
 
I take the data in chunks in a while loop which terminates when there are no bytes left at the port. 
 
I hope this explains the probelm beter.  I am going to try Gerds suggestion and see how I get on.
 
Many thanks
 
Ash
 
 
 
0 Kudos
Message 4 of 5
(3,972 Views)

Gerd, what is the name of the first function that you used to remove the first 4 characters... I am searching high and cannot find it 😞

 

edit:

10 mins of searching.. I post this question and find the string subset function 30 seconds later.......

Message Edited by labstew on 04-26-2007 02:49 PM

0 Kudos
Message 5 of 5
(3,837 Views)