LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send hexadecimal number with COM?

Dear All,
I want to send hexadecimal number to COM. But I find the VISA write.vi only read string.
I have tried to use number to hexadecimal string.vi, but the result is not fit for me.
For example, I write 16 to the control, after number to hexadecimal string.vi, I get 10, but it send 31 30 out(the ASCII of 10).I hope it send 10 out.
Whan can I do?
Thank you!
0 Kudos
Message 1 of 8
(3,471 Views)

Wire a string constant to the Visa write function. Right click on it and select hex display. Type 10 into the string constant.

Here is a link to the ASCII charts and the equivalent values in hex/decimal/octal/character.

http://digital.ni.com/public.nsf/allkb/47CFD9C7682DCB2A86256FF800781EB7

Message Edited by unclebump on 08-23-2006 04:51 AM

Message 2 of 8
(3,469 Views)
And if you make some numeric calculations and get the result 16 (decimal) and want to send this calculated number to COM, use "flatten to string" from the palette numeric->data manipulation



Greets, Dave


Message Edited by daveTW on 08-23-2006 12:12 PM

Greets, Dave
Message 3 of 8
(3,462 Views)
Thank you for your reply.
I haven't found the data manipulation. I use LV7.1. Is it concluded in LV7.1?
Thank you.
0 Kudos
Message 4 of 8
(3,450 Views)
Yes, it is. I made a screenshot where it is to find on my computer.



Greets, Dave

Message Edited by daveTW on 08-23-2006 02:18 PM

Greets, Dave
Message 5 of 8
(3,448 Views)
In this case, Type Cast will produce the same results.  The Type Cast function is to the left of the Flatten to String function.  If you are using an array of hex numbers, it is better to use Type Cast.  With an array Flatten to String adds some extra character to the beginning of the string.  I don't really know what the extra character is for.
- tbob

Inventor of the WORM Global
Message 6 of 8
(3,431 Views)
Yes, tbob, your'e right. The "flatten to string" prepends the array-size to the data, so if you flatten some complex data structures (like arrays of clusters of arrays) then you can unflatten it if you feed the same data type into "unflatten from string". "Type Cast" doesn't accept arrays of structures with not-fixed size or clusters with variable-sized members.#
I made a little test, it's shown below (all numerics are I32):



You can see, before each variable-size data is given the size (arrays & strings) and that "flatten to string" creates "packed" data.

Greets, Dave

Message Edited by daveTW on 08-23-2006 06:55 PM

Greets, Dave
Message 7 of 8
(3,425 Views)

Thank you for you reply!

I have test it, using a wire to connect COM1 and COM2, I use my vi to send the data out with COM1, and COM2 receive it properly.

Thank you again.

0 Kudos
Message 8 of 8
(3,402 Views)