Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

use serial port to detect when an instrument is on/off

I am developing a control system for an autonomous vehicle.  I would like to have remote control of th motors until I have moved the vehicle a safe distance from the shore and then turn the remote control off and have LabVIEW begin the control system.  I am trying to use a case structure to have the RTS line check for a 1 or 0.  If a 1 is received, then the remote control is "on" and the correct case is chosen and if a 0 is received then the remote control is off and the case with the control system is chosen.  However, I recently read up on the RTS and DTR lines and it seems like they cannot be used for this type of operation.  Can someone help me out with a better solution for this problem?

My second problem is also with DTR and RTS lines but for a different function.  I have a while loop waiting for a 1 or 0 from a PIC on the DTR or RTS line.  If a 1 is received I would like to break the while loop and move to the next step.

Should I change both of these to just use the VISA serial Read function?

Thanks for any help.
0 Kudos
Message 1 of 9
(4,960 Views)
Someone please help.  Is there anyone that can answer either question that I posted?  I'm on a tight deadline to figure this out and I'm completely stuck with the rest of the project until I figure out how to make these two steps work.

Thanks
0 Kudos
Message 2 of 9
(4,931 Views)
Hi

do you know the visa functions to play with DTR  / RTS lines? or do you have a question as : is this the right thing to do.

Depending on rs232 is asking for problems in the future, but it should work for the next few years.
greetings from the Netherlands
0 Kudos
Message 3 of 9
(4,912 Views)
My first question would be: is it possible to read the RTS and DTR lines.  All I get is asserted, unasserted and unknown. I need to get a 1 or a 0 so I can compare that to a value and enter the correct case.  Or is it easier to use the Rx, Tx, Gnd lines to read the serial port and use VISA Serial Read.  I have tried doing the second option but I'm still not seeing any success.  On the oscilloscope I see a +5V when the RC controller is turned off and I see 0V when the RC controller is on.  I want to transfer that high and low to LabVIEW through the serial port.
0 Kudos
Message 4 of 9
(4,912 Views)
Asserted/unasserted, and unknown are the only valid outputs of a serial line. It is not possible to read the actual voltage levels. The actual voltage levels will vary in any case depending on the uart used, the power supply, etc. A valid signal is +3 to +15 or -3 to -15. You can wire the output of the VISA property node directly to a case statement since it is an enum. Inside the case statement you can convert to Booleans or a 1 or 0.  A voltage level of 0 volts is unknown. Check http://en.wikipedia.org/wiki/RS-232#Voltage_levels for more details on RS232.
0 Kudos
Message 5 of 9
(4,903 Views)
So, I should use VISA Serial Read and send the Read Buffer output directly into the decision node for the case statement?  My problem is that I'm not seeing anything on the read buffer.  It's like I'm not reading anything, but I can see the voltage level change.  If I use the RTS line then if the RC is on or off I always get asserted.  I thought I should be able to convert the read buffer to a number and compare that to a 0 or 1 and use a boolean comparison to choose the correct case.  Is this not possible.  I wanted to just use the VISA Serial Read block and send the read buffer to Frac/Exp String to Number converter block and get a 1 or 0.  Then compare to that number to a constant and get a True or False to choose the case.  Can you explain in more detail how to do what you were recommending?  I'm not sure I understand what you are suggesting.

Thanks.

0 Kudos
Message 6 of 9
(4,900 Views)
If you are able to detect a change in the CTS or DTR lines, then you could wire the output of the property node you are using to a case statement as shown below. The device connected to your serial port would have to be capable of controlling these lines. I don't understand your statement about the RTS line. This is an output from the computer. If you want to monitor the RTS line of the connected device, then you should be monitoring CTS and you will also need the correct cable.
 
I'm not sure what your problem is with the read buffer. Does VISA Bytes at Serial Port say there is data there? If it does, you should be able to read that number of bytes. You could only directly convert that to a number if the data in the buffer represents a number (hex or ASCII).
 
Maybe if you could explain what the RC on/off actually does. Does is it change the control lines or change the data being sent?
0 Kudos
Message 7 of 9
(4,889 Views)
The read buffer reads the characters sent on the serial line DTR/RTS etc are statuslines that are read via the property nodes as Dennis pointed out.

greetings from the Netherlands
0 Kudos
Message 8 of 9
(4,882 Views)
Ok I think I figure it out by using the ADC pins on the PIC and reading my levels from there.  Thanks for all of the help.  If I run into any more problems I will come back.

Thanks
0 Kudos
Message 9 of 9
(4,881 Views)