Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

output ascii "code" to serial port

Solved!
Go to solution
Hi all, I'm sure this is a simple problem, but I have been trying and flailing. Hopefully it will take someone smarter than me almost no time at all. I'm trying to communicate with a relay box over the serial port (http://www.controlanything.com/Relay/Device/R45PRO ). It has a simple control set and looks like it should be easy. Unfortunately, the box is waiting receive a number (an "ASCII Code" as their manual describes it) rather than a normal ASCII character. So, if I try to send it "254" which is what tells it listen for a command, the VISA write function sends it 50,53,52 or some such. I've searched and found a bunch of examples for fixing these kind of problems on the read side, but none of them seem to work for me. I'm now resorting to trying deranged things like converting a number to a boolean array and back to a string, but that isn't doing me any good either. I've also tried to just send it a string constant in HEX and just write FE hoping that will get it into listening mode... but then I can't figure out how to add a \n character to the end. If anyone has any suggestions, I'd greatly appreciate them. Thanks, mike
0 Kudos
Message 1 of 3
(3,803 Views)
Solution
Accepted by topic author mooseo

What did you search for? The same question has been asked hundreds of times.

 

First, learn to right click. If you had done this on your string control/constant, you would have seen the Hex Display and '\' Code Display options.

 

If you want, you can use a U8 to define a single byte. Use the typecast function and wire the output to the VISA Write.

 

You can use a U8 array and either the typecast or Byte Array to String. The Flatten to String can be used instead of the typecast if you want.

0 Kudos
Message 2 of 3
(3,798 Views)
Thanks for the help, and sorry for the stupid question. The answer turned out to be equally silly; I needed to power cycle the relay board after I moved a jumper.
0 Kudos
Message 3 of 3
(3,756 Views)