From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wjat is the VI for converting decimal number to ascii since my all thye commands have to given in ascii format

I had sent one previous problem two days before on a inserting commands to controll a motor. This is continuation of that. Now I need to know that is there any VI available to convert decimal numbers to ascii characters since the encoder detects only the ascii characters and as on byte also. So how can I convert all the inputs to the serial port write to ascii commands  and I need the output from the serial port read to be decimal characters. So can you please help me by showing the VI's which fit to this problem or if there is no direct VI what I have to do to overcome this problem

0 Kudos
Message 1 of 10
(3,018 Views)

Look under "string:/string/number" pallette on the block diagram. The return (reads of the serial port) will have the additional complexity if all the returned values aren't numeric values (like if there is a reading with units, i.e. "1.5V")

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 10
(3,002 Views)

this is not the answer I want I need the way to convert a decimal number to the corresponding ascii value.

0 Kudos
Message 3 of 10
(2,982 Views)

@perumpadapu wrote:

this is not the answer I want I need the way to convert a decimal number to the corresponding ascii value.


You need to be much more specific.

 

What is a "decimal number"? (a numeric integer data type? a string containing a single decimal character? someting else?)

 

If you have a single character string, you can typecast it to a U8 integer to get the ASCII value. For longer strings, you could use "string to byte array" to get an array of values.

 

Please attach a small VI that contains your "decimal number" as a diagram constant. Then tell us what the desired output should be.

 

 

0 Kudos
Message 4 of 10
(2,974 Views)

I need to get  ascii value d for the 100 and etc . Is it possible to write such a program and get result in labview 6i. If possible can You send a vi of that.

0 Kudos
Message 5 of 10
(2,971 Views)

@perumpadapu wrote:

I need to get  ascii value d for the 100 and etc . Is it possible to write such a program and get result in labview 6i. If possible can You send a vi of that.


You are still not making yourself clear. is "100" a numeric or is it a string with the three characters "1, 0, 0".

 

If 100 is an U8 numeric, you can simply typecaset as I already said earlier.

 

LabVIEW 6i is over 10 years old and prehistoric, so I cannot attach a VI, but here's a picture. You should be able to recreate the VI from it.

 

0 Kudos
Message 6 of 10
(2,964 Views)

Altenbach,

 

Do you go to sleep with your PC?  How early do you get up to prepare a full response with that much details so early in the morning?

It's not even 8am here...

0 Kudos
Message 7 of 10
(2,954 Views)

Well, it is 5am here on the west coast. 😄 Some friends just left for the airport, so I had to be up anyway....

Message 8 of 10
(2,949 Views)

your example may confuse as in 6.x the diagram terminals weren't shown as icons. 🙂

 

typecast will result in additional, unprintable, characters before the "d" in the example he refers to. I have the numeric value going into a build array to make the single value into an array (one element), then the "byte array to string" as you show.

 

Can't post images or code from here.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 9 of 10
(2,945 Views)

LV_Pro wrote:

typecast will result in additional, unprintable, characters before the "d" in the example he refers to. I have the numeric value going into a build array to make the single value into an array (one element), then the "byte array to string" as you show.


Typecasting an U8 to a string will give exactly one character (e.g.decimal 100(U8) --> "d"), no extra garbage, exactly the same as your suggestion. Where do you see unprintable characters?

If I change the display format of my string to hex, all I see is "64" as expected.

0 Kudos
Message 10 of 10
(2,931 Views)