Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find FTDI command to turn on relay?

Solved!
Go to solution

Hi,

 

I have a USB to serial Relay that I have a standalone .exe file that runs it just fine. It is a GUI that you can click the buttons and it turns the relays on and off.  But I want to automate it, and it doesn't have any documentation.  I cannot figure out what command to send it to toggle the relays.  How would I go about doing this?

 

I tried programming a while loop to just input the next integer value in, to see if I could ever see a change...but so far, nothing.  I'm not sure what I'm missing.  I'm using NI VISA to communicate with it, and it seems to be communicating, as I am getting a return value from VISA write.

 

Any ideas?

 

John

0 Kudos
Message 1 of 7
(4,456 Views)
You'll get a return value if nothing is connected.

Have you tried portmon from microsoft?
0 Kudos
Message 2 of 7
(4,452 Views)

No, I haven't tried that. I'll see if I can get that to work.

 

So, if I use MAX and use the "Open VISA test panel" and then try changing an attribute value, sometimes it changes the "current value" to what I input and other times I'll get a return string of characters that seems to be an error code. I can't figure out if this means if it is communicating or not.

 

0 Kudos
Message 3 of 7
(4,443 Views)

I don't know what attribute you are changing and I don't know return string you are getting since you have not provided those details.

 

In any case, the attributes affect the local serial port and it does not matter if that port is connected to an instrument or not. Same thing with a VISA write. Unless you are doing handshaking, when you do a write, there is nothing about serial communication that can tell whether something is at the other end and you will not get any sort of error if nothing is there.

 

Randomly sending data that you make up is not going to work. If the vendor does not provide an api and you cannot capture the commands with Portmon, find some other hardware that the vendor will support.

0 Kudos
Message 4 of 7
(4,441 Views)

Thank you for pointing out PortMon...it gave me what I needed. I can now see what the codes are to turn on the relays.

 

I was sucessful in turning on the relays, but not turning them off.

 

Portmon returns the codes for turning on the relay (lets say relay 1) to be FF 01 01 and the length to be 3. I tried to input this("255 1 1") as a num control to  string using VISA write, and it didnt' work. Portmon said the command I gave it was 32 35 35 31 31, and a length of 5.  So I found the character which corresponded to FF, which is ÿ, and is Unicode U+0255 and input that and the unicode character U+0001 twice. This worked and the relay turned on. But to turn off the relay, I'm not sure how to input the unicode key U+0000, as when I do, nothing happens (I realize this is the "null" character).  My question now is, how do I get the null character to input into a string control? or can I change the VISA write to accept a number input?

0 Kudos
Message 5 of 7
(4,432 Views)
Solution
Accepted by topic author John Roehling

You can write click on your string control and select Hex Display. You can take an integer and typecast that to a string. You can have an array of U8 and use the Byte Array to String function.

0 Kudos
Message 6 of 7
(4,430 Views)

Thanks Dennis, you have been a great help!!

0 Kudos
Message 7 of 7
(4,422 Views)