LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read hex value from RS-232 ??

Hi,

I sending data from my PIC to the COM1 serial port and have labview read that using the VISA Read. I can correctly read the hex value and display is using a string indicator, but how do i use this hex value in futher calculations ? I am unable to convert is to a decimal number, i tried to use the hexadecimal string to decimal number function but it wont work. Are there any solutions ??

Thank you
Gagan
0 Kudos
Message 1 of 13
(4,834 Views)
When you say the hexidecimal string to number function don't work, exactly what do you mean? Does the number come out wrong? Once a string is converted into a number, the computer stores and handles the number in binary format, a series of ones and zeros. Please be more clear on your problem or post an example.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 13
(4,820 Views)
Hi,

After using the Hexadecimal String to Decimal number function when i try to display the number on an indicator all i see is 0. But the string indicator shows the correct value (when displayed in HEX).All i want to do is use the recieved data to make some futher numeric calculations, is there any way to do this ?

Thanks
0 Kudos
Message 3 of 13
(4,815 Views)
There is a function "hexadecimal string to number" under the functions->strings->string/number conversion palete. The number this function returns is the numerical representation of your string. See enclosed file.

hope it helps
Pawel
0 Kudos
Message 4 of 13
(4,814 Views)
Hi,

I have attached the VI that i am trying to execute, to be more clear the string indicator shows the correct value of the displayed recieved byte in hex. But the numeric indicator shows a 0 ??

Thanks
0 Kudos
Message 5 of 13
(4,806 Views)
Depending on the number of bytes and the endian nature of what you're getting, direct use of the Typecast primitive (Advanced>Data Manipulation palette) will work by itself or with a little help moving bytes using Split Number and Join Number primitives (same palette):

There have been a few recent posts on the topic with several example VIs.

http://forums.ni.com/ni/board/message?board.id=170&message.id=105851&query.id=0
http://forums.ni.com/ni/board/message?board.id=170&message.id=104302&query.id=0#M104302
http://forums.ni.com/ni/board/message?board.id=170&message.id=105158#M105158

The "whatever String to Number" functions translate strings of ascii code into the corresponding number, (e.g. a 4 byte string "FFFF" (0x 4646 4646) into a U32 with a value of 65535, etc.)
=====================================================
Fading out. " ... J. Arthur Rank on gong."
0 Kudos
Message 6 of 13
(4,606 Views)
When you can only see the hex when turning on hex display of the string, you can't use the string conversion Hexidecimal to Number. You can use either String to Byte Array or a type cast. See the attached picture.
Message 7 of 13
(4,790 Views)
Your string indicator is set for hex display. What you will see here is the ASCII code of the characters being received by RS232, not the actual characters. Change your indicator to Normal display and you will see the actual string being received. Since the numeric value you are seeing is 0, I suspect the string being received is not a valid hex number.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 13
(4,774 Views)
Hi,

Thanks for your response. If i send hex value 0xff what i see in the string as hex is ff. So i am getting the exact hex value but i still unable to use it as a numeric value for calculations ??

Thanks
Gagan
0 Kudos
Message 9 of 13
(4,770 Views)
I would also recomend trying the type cast function.
0 Kudos
Message 10 of 13
(4,566 Views)