LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

conversion of binary to number

Hello,
 
I have a signal conditioner controlled through serial communication with ASCII commands. Once the start command is received, there is a continuous stream of offset binary data sent and read through the serial Read Indicator. The manual informs me that I must first condition the offset binary values by subtracting 2048 from the raw values to produce a 2's complement value,  it also mentions that the data is encoded in 12 bits so negative numbers must be properly sign extended to move the data into 16 bit words used by the PC. I am not familiar with binary numbers and am unsure on where to start. If someone could provide some insight and suggestions on what my first step would be to converting the binary values into number format, that would be greatly appreciated.
 
Thank you in advance,
Jena
0 Kudos
Message 1 of 8
(3,486 Views)
You can right click on a numeric control, select properties, data format <tab>, and select binary if you need to see the values in binary. Other wise just perform the computations as normal i.e. <output value - 2048> for that portion, the visible data format isn't important. I think for the 12 bit to 16 bit just put the value into an I16 indicator. Basically everything else is done for you behind the scenes, you may want/need to use a "To I16" vi from the Numeric/Conversions pallete
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 2 of 8
(3,472 Views)
The serial read indicator is a string which will need to be converted to a number.  Can you attach some data that you are reading via the serial read indicator?


Message Edited by AMac on 04-07-2008 03:53 PM
0 Kudos
Message 3 of 8
(3,461 Views)

Hi,

I am not sure which string conversion function in Labview to use so that I can access the binary numbers being sent into the Read indicator. The signal conditioner reads 6 channels (Fx, Fy, Fz, Mx, My, Mz) and outputs the values from these channels in binary format to the read indicator. I need to convert these values from binary to number format so that I may use the values from the third channel, Fz in future comparison functions to control an actuator which is placing load onto the load cell.

My data currently being read through the read indicator is a repeat of the following (I believe this should be zero as I first performed an autozero of the software before the signal conditioner sent out the following):

(ÿ7ÿGÿWÿ

Thanks,

Jena

 

0 Kudos
Message 4 of 8
(3,453 Views)
If I change the settings on the read indicator, my data takes the form:
 
W\00\b\00\18\00(\FF7\FFG\FFW\00\b\00\18\00(\FF7\FFG\FFW (using Backslash Codes)
 
or
 
1800 28FF 37FF 47FF 5700 0800 1800 28FF 37FF 47FF 5700 0800 1800 28FF 37FF 47FF 5700 0800 1800 28FF 37FF 47FF (using hexidecimal)
 
or as shown previous message using Normal.
 
What would be the best way to convert these values into numbers?
 
Thanks
Jena
 
 
0 Kudos
Message 5 of 8
(3,416 Views)

Hi Jena,

i don´t know which format your data bat, but you can use the "String to Byte Array" function and then the "Split Numbers" and "Join Numbers" function to get your variables out of the string.

Mike

0 Kudos
Message 6 of 8
(3,411 Views)
If you have the whole string do this.
Or there are similar functions for sigle elements
________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
Download All
0 Kudos
Message 7 of 8
(3,404 Views)
That won't work because he's not receiving the string the way you think it is. The hex display is an interpretation of the underlying byte values. It is not the same as number written out in hex as a string. Your conversion assumes he's getting the character 1, followed by the character 8, followed by the character 0, followed by the character 0, followed by a space character.

The simplest way is to use the Type Cast function, 'cause that's what it's there for. Wire in an array of the datatype you want. The thing to keep in mind is that even though the data may be fundamentally 12 bits you need to deal with multiples of 8 because a serial read will read bytes, not bits. Thus, you can convert your string to an array of I16 numbers like this:



Message Edited by smercurio_fc on 04-08-2008 01:07 PM
0 Kudos
Message 8 of 8
(3,384 Views)