Jump to content

Signed Byte


Recommended Posts


I'm using Visa to read the packet from my hardware (sensor).

And as you know in Read Serial returns a string. I can convert the string to unsigned byte using

( Sring to unsigned byte array operator).

But I need to read them as a signed byte.

Any idea ?

Thank you.

Link to post

What data are you trying to retrive from the string (Integer, float, 8bit, 32bit, complex,...).

I'm assuming that the data returned is in raw form and not an ascii string.

if you take the output which you say gives you an unsigned byte and wire it to an indicator that is a signed byte (U8 wired to a I8) you should see the converted data. To see this is very simple. Just place a numeric control and a numeric indicator on the screen. Change the representation of the control to U8 and the representation of the indicator to I8. Make the Control value 207, run the VI and you should see -49 in the indicator.

If you alread know this :oops: , I must have misunderstood the question. In that case reply with some more detail of the end result you are looking for.

If not than this should get you moving along the right path. :thumbup:

-Norman J. Kirchner Jr.

Engineering Specialists, Inc.


Link to post

Hi njkirchner,

Thank you for your help.

I'm trying to comm. with an inertial sensor. in the documentation is written "Each sensor

data value is represented in the data packet as a 16bit signed short (the MSB-most

significant byte and LSB - least significant byte)".

and in the table that describes the packets shows for example

Temperature (MSB) 19

Temperature (LSB) 20

"numbers relate to the byte number in the packet"

these are raw data and if i want to convert them I've to do some operations on them.


In order to do that I've to marge the bytes to become 16bit signed.


my approach was to read the data using Read Visa. that returns a string of byte. Convert the string to unsigned byte array. and using Join Numbers (under ADVANCED-->DATA MANIPULATION --> joing number) I connected the MSB and LSB to HI and LO input of Joing number.


Is this a right way ?

Thank you.

Link to post
  • 2 months later...
      Temperature (MSB)      19

      Temperature (LSB)          20

      "numbers relate to the byte number in the packet"

these are raw data and if i want to convert them I've to do some operations on them.

Your approach will work too, but since your data is really a 16 byte short in big endian format you could take advantage of the fact that LabVIEW's flattened stream format is also normalized to be in big endian.

Just pick out the interesting bytes and wire them to the Type Cast function in Advanced->Data Manipulation. Wire a int16 constant to the middle terminal e voila you get your numeric 16 bit signed value. This is simple fast and will work on any LabVIEW platform independant of the underlying endianess of the CPU, since LabVIEW takes care of the necessary (if necessary) byte swapping for you.

If the number in the stream would be in little endian format you would just have to add a Byte Swap node from the same palette to the wire after the Type Cast. Really swaps bytes twice on little endian machines (only Intel CPUs ;-) but it's most probably still faster than doing the byte extraction and joining on your own.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.