Vous êtes sur la page 1sur 2

23/03/2011 How to Convert Between Hexadecimal a…

Improve your ni.com experience. Login or Create a user profile.

12 ratings: 4.16 out of 5 Rate this Document

How to Convert Between Hexadecimal and ASCII in LabVIEW


Primary Software: LabVIEW Development Systems>>LabVIEW Base Package
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I am communicating with an instrument which sends back information in the form of hexadecimal
values. For instance, instead of sending the letter ‘L’, it sends back its corresponding hexadecimal
representation ‘4C’. How can I programmatically convert this hexadecimal representation into its
corresponding ASCII representation in LabVIEW? What if I need to send information back to the
instrument in the form of a hexadecimal equivalent?

Solution:
Converting to ASCII from Hexadecimal
In order to convert a hexadecimal string into an ASCII string, you must first convert the hexadecimal
string to its decimal representation using the Scan Value function, which is found in the functions
palette under Programming»String»String/Number Conversion. You can then convert the decimal
representation to its ASCII string equivalent using the Type Cast function, found in the Functions
Palette under Mathematics»Numeric»Data Manipulation.

Converting to Hexadecimal from ASCII


In order to convert a ASCII string into a hexadecimal string, you must first convert the ASCII string to its
decimal representation using the Type Cast function, which is found in the functions palette under
Mathematics»Numeric»Data Manipulation. You can then convert the decimal representation to its
hexadecimal string equivalent using the Number to Hexadecimal String function, found in the
Functions Palette under Programming»String»String/Number Conversion.

The links below provide example VIs in NI Community that accomplish these conversions.

Related Links:
KnowledgeBase 28OBO5SG: Table of ASCII Characters and Their Code Equivalents
KnowledgeBase 3B8F04XR: How Do I Convert a Hex String to a Normal String?
Developer Zone Community: Converting Between Hexadecimal and ASCII in LabVIEW

Attachments:

Report Date: 24/03/2009


Last Updated: 21/10/2009
…ni.com/…/894CF5FE064971BF8625758… 1/2
23/03/2011 How to Convert Between Hexadecimal a…
Last Updated: 21/10/2009
Document ID: 4VNI8J1V

Your Feedback! Poor | Excellent Yes No


Document Quality? Answ ered Your Question?
1 2 3 4 5
Document needs work? Please tell us why.

Please Contact NI for all product and support inquiries.

My Profile | RSS | Privacy | Legal | Contact NI


© 2011 National Instruments Corporation. All rights reserved.
| E-Mail this Page

…ni.com/…/894CF5FE064971BF8625758… 2/2

Vous aimerez peut-être aussi