LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ASCII to decimal conversion function

Hi ehsa,

this function is called TypeCast. It's found in the "data manipulation" palette... You can use it to convert from one datatype to any other depending on the type input, so be careful to connect the correct type definition!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 48
(8,329 Views)
is there any other possible way. my requirement is same as previous question is.
 
that is i am sending data of 8bits which is 0 to 255 but in labview i am receiving it as ASCII character.
 
even if use conversion then its not possible to use all 256 possibilities like some special characters received in ASCII.
 
what to do if i want my data in decimal number same as i sent from microcontroller coming from P1 and sent via serial. i need same data of all 256 numbers..........
 
plz help me out
 
thanks very much
0 Kudos
Message 12 of 48
(8,312 Views)

Sorry, but I don't understand what the problem is. With 8 bits (0-255), you have 256 combinations and you can represent everything that is in ASCII.

0 Kudos
Message 13 of 48
(8,308 Views)
If you get data from the Serial port you will most likely get multiple characters, to convert these to U8 you can use the following code:


Ton



Message Edited by TonP on 06-12-2008 07:56 AM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 14 of 48
(8,300 Views)
ok let me explain my problem.
 
i am receiving 8 bit data on controller port1. i am sending this data to serial link without any changing. range is 0 to 255.
 
when i receive this data using VISA, labview assumes this data is ASCII code but it should ba taken as a number. 0 to 255
if i apply above U8 conversion which is not clear to me even yet then their are some codes of ASCII which are not available on keyboard like some initial characters.
 
if you can plz tell me the conversion of all 256 ASCII characters(i am unable to use above conversion feature, i hv found that, but dont know how to make a table and where to get all ASCII codes) to numbers then it will be great. if some other way is possible then it will be also helping to me. 
 
thanks very much
0 Kudos
Message 15 of 48
(8,297 Views)
Hi ehsa,

each ASCII is represented by an 8bit number (aka U8). The "above conversion" will do exactly what you need! Only thing that remains is to index the byte you need from your resulting U8 array. And maybe adapt the representation to whatever suits best (decimal, hex, binary?).
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 48
(8,287 Views)
A string is not ASCII.

ASCII is a representation of bit-values.
The example I posted will show a list of all the values you receive.
To change this to an ASCII representation feed this to an array containing this enum.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 17 of 48
(8,282 Views)
thanks;
 
i have got the idea but i am unable to use thsi conversion.
plz guide me. what is type field, x field, all the three wires what are they doing and if i need my data again result in decimal number then what to connect with these wires.
 
thanks
0 Kudos
Message 18 of 48
(8,281 Views)
Why don't you attach a small VI that contains the data you have (e.g. as a diagram constant) and what you want to do with it.


ehsanelahimirza wrote:
i have got the idea but i am unable to use thsi conversion.
plz guide me. what is type field, x field, all the three wires what are they doing and if i need my data again result in decimal number then what to connect with these wires.

It is impossible to tell which post you are referrring to. Could you be a bit more specific on where you need help? Remember that all tools also have an online help. Did you read it?
0 Kudos
Message 19 of 48
(8,277 Views)
i am reffering to the post in which i was told to use U8 conversion .
 
i am receiving ASCII in VISA read buffer and want to use it after converting it to number which i sent from microcontroller after receving on port1.
 
my problem is that i cant use ASCII directly. i am sending data of 8bits=1byte to labview range is from 0 to 255.
 
i need result from VISA read buffer in same form like 0 to 255
 
thanks
0 Kudos
Message 20 of 48
(8,266 Views)