LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ASCII to decimal conversion function

I use LabVIEW 6.1
I'm reading an instrument using RS-232 and the "Serial Port Read.vi"
The vi reads 3 bytes in ASCII format I need to convert it to decimal or hexadecimal in order to calculate the instrument output.
It is possible to do it offline (when the vi isn't running) by rigth clicking on the indicator connected to the "string read" output of the "Serial Port Read.vi" and changing the display to "Hex Display" but i need to do it while the vi is running.
Can someone help
Thnxs a lot
Danny
0 Kudos
Message 1 of 48
(32,984 Views)
Why not simply add another display which has the property "Hex Display" already set. You could put the display next to the ASCII one and see both as the vi is running.

-JLV-
Message 2 of 48
(32,979 Views)
Look under:

Functions
All Functions
String
String/Number Conversion

Les.Hammer@CompleteTest.com
Message 3 of 48
(32,979 Views)
Dear Joe

Thanks for your reply.

I didn't explained myself well.

The data that I read from the instrument comes in ASCII format. If I leave the indicator in "normal display" then what I see are 3 numbers, letters or simbols - representing the 3 bytes that were read.
I need to convert this numbers/letters/simbols to their hexadecimal or their decimal representation and then to convert this representation to a number to be able to perform some calculations on the recieved number.
In other words, I need a function that converts ASCII string to hexadecimal or decimal. I know that there are tables for this convertions (and one also exists in the LabVIEW help) but the question is if LabVIEW has a function that performs this task.
In the Function >> St
ring >>String/Number Conversion I found only conversions from decimal or hexadecimal string to number, but not from ASCII string to hexadecimal or decimal string or to number.
I hope now my problem is more clear

Thanks for your help,

Danny
0 Kudos
Message 4 of 48
(32,979 Views)
All
I've succuded to peform my task using the "String to Byte Array" which is located at the: Functions>>Numeric>>Conversions palette.

Thanks all

Danny
Message 5 of 48
(32,979 Views)
Hi
 
I need to convert from DEC to ASCII, do you know how I can do this?
 
Simon
LabVIEW 8.6 / 2009 / 2010
Vision Development Module 8.6 / 2009 / 2010
VBAI 3.6 / 2010
0 Kudos
Message 6 of 48
(32,432 Views)


SCMAJA wrote:
I need to convert from DEC to ASCII, do you know how I can do this?

Your question does not make a lot of sense. "DEC" (I assume you mean decimal) is already a number shown as formatted ASCII characters, so there is no conversion needed.
 
Please tell us what you have and what you want. Do you possibly have a numeric type that you want to format?
0 Kudos
Message 7 of 48
(32,412 Views)

Sorry if I wasn't specific enough.

I want to convert from ASCII code to Decimal code

Take a look at this:

Hex Oct Dec ASCII Msg
00 000 0 NUL
01 001 1 SOH GTL
02 002 2 STX
03 003 3 ETX
04 004 4 EOT SDC
05 005 5 ENQ PPC
06 006 6 ACK
07 007 7 BEL
08 010 8 BS GET
09 011 9 HT TCT
0A 012 10 LF
0B 013 11 VT
0C 014 12 FF
0D 015 13 CR
0E 016 14 SO
0F 017 15 SI
10 020 16 DLE
11 021 17 DC1 LLO
12 022 18 DC2
13 023 19 DC3
14 024 20 DC4 DCL
15 025 21 NAK PPU
16 026 22 SYN
17 027 23 ETB
18 030 24 CAN SPE
19 031 25 EM SPD
1A 032 26 SUB
1B 033 27 ESC
1C 034 28 FS
1D 035 29 GS
1E 036 30 RS
1F 037 31 US
20 040 32 SP MLA0
21 041 33 ! MLA1
22 042 34 " MLA2
23 043 35 # MLA3
24 044 36 $ MLA4
250 45 37 % MLA5
26 046 38 & MLA6
27 047 39 ' MLA7
28 050 40 ( MLA8
29 051 41 ) MLA9
2A 052 42 * MLA10
2B 053 43 + MLA11
2C 054 44 , MLA12
2D 055 45 MLA13
2E 056 46 . MLA14
2F 057 47 / MLA15
30 060 48 0 MLA16
31 061 49 1 MLA17
32 062 50 2 MLA18
33 063 51 3 MLA19
34 064 52 4 MLA20
35 065 53 5 MLA21
36 066 54 6 MLA22
37 067 55 7 MLA23
38 070 56 8 MLA24
39 071 57 9 MLA25
3A 072 58 : MLA26
3B 073 59 ; MLA27

Like if I want to have the ASCII code 2 in Decimal then I get the number 50, if I want ASCI code SOH in Decimal I get 1, do you know what I mean?

Simon

LabVIEW 8.6 / 2009 / 2010
Vision Development Module 8.6 / 2009 / 2010
VBAI 3.6 / 2010
0 Kudos
Message 8 of 48
(32,397 Views)

Just typecast it to a U8 numeric.

 



Message Edited by altenbach on 11-15-2007 12:07 AM
Message 9 of 48
(32,389 Views)

where i can find this u8 conversion.

 

i m unable to find

0 Kudos
Message 10 of 48
(31,911 Views)