LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using RS232 to transmit HEX numbers

I've been playing with this for a while but does anyone know to transmit and recieve HEX numbers using the RS232 COM1 port and the VISA vi? I keep running into the problem of transmitting numbers greater than 7F. It seems that the VISA will convert these numbers into FF because there is no ASCII codes greater than 7F. Ideas or work arounds?
0 Kudos
Message 1 of 4
(3,051 Views)
Use the Type Cast function.  If your numeric is a U32, Type Cast will produce an Ascii string with 4 bytes.  If it is a U16, Type Cast will produce a 2 byte string, and so on.  The attached picture shows how it works.  The top string display is the actual Ascii characters (normal display) and the bottom is a string display set to hex display.  You can wire either one into the Serial Port Write vi.
 

Message Edited by tbob on 10-09-2006 04:31 PM

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 4
(3,045 Views)
I have done this quite often and the string palette has some functions that will make this rather easy.  Use the String/Number Functions palette, under here you will see the function "Number to Hexadecimal String" and the "Hexadecimal String to Number" ... This will do what you need it to do - you can also set the width of the hexadecimal number as an input into the Number to Hexadecimal string function.  Then send the string through the VISA send vi.  Let us know how these suggestions work out for you.

Greycat
0 Kudos
Message 3 of 4
(3,021 Views)
ASCII does go all the way up to FF. My own prefered method is using the Byte Array to String function (also from the string palette).

___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(3,012 Views)