LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write ASCI HEX commands to the serial port by default ?

Hi

I have an instrument that can be controlled by sending asci commands via the
serial port. According to the manual the machine should respond to the ASCI
commands 0,1,2,3,4,5 etc etc. However if I send these strings in normal
mode to the machine using the serial port write nothing happens. If however
I send the equuvalent HEX ASCI commands (i.e Hex 31 for ASCI 1) by setting
the wired input to the serial write as HEX, the machine behaves as it
should. The problem is that some of the commands I want to send are
retrieved from digital controls on the front panel. I have sucessfully
converted the numerical values to the equivalent HEX form (i.e 5000 is HEX
35303030) but of course when I wire this string
as the input to the serial
write it interprets it as ASCI and not HEX. How do I tell the standard
serial port write provided by Labview to expect HEX commands instead of ASCI
commands.? Or is there another oprion for me.?

I appologise that this is a little long winded and hope you understand my
problem. Any help would be appreciated.

Cheers

Richard
0 Kudos
Message 1 of 3
(3,286 Views)
The serial port write only accepts strings, so to send 5000 in ASCII Hex, use the backslash character. So 5000 would become \35\30\30\30. This will send the hex numbers 35, 30, 30, 30 rather than the ASCII for 3, 5, 3, 0, ... This should help. Give it a try.

Rob
0 Kudos
Message 2 of 3
(3,285 Views)
Richard;

Try with an array. Create a numerical U8 (Unsigned Byte) 1-dimensional array, change the format to Hexadecimal, and write there the command. Then use the "Byte Array to String" function to convert the command to the string you send to the serial port.

Let us know.

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 3 of 3
(3,285 Views)