From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

control the rs232 to generate a signal

I want to use the RS 232 or any other standard computer port in order to create a 0 or 1 trigger signal. What I want is to control the output of an external device using as an input this signal and feeding it into the TTL trigger input.

It is very simple really (the external machine does not care about voltage level so it will work with 5 or 1v)

BUT I do not have a clue about labview


So if any one could point me to the correct direction

THANKS
0 Kudos
Message 1 of 11
(6,074 Views)
Hi,
the question is whether you want to transmit a single bit, or if you want your signal to go high and stay there. In the first case, COM port should work fine, in the second case however, you should use the paralell port.
If you use the parallel port, you'll also be able to control the length of time the signal stays high more easily (it's simply to turn it high and then low).
Pins 2 thru 9 on the parallel port are output pins representing bits 0 - 7. These you can turn high or low programmatically. If you need a signal ground, that's pin 16. Also, you should tie pins 11 and 12 to another ground pin (either of the pins 18 - 25, but NOT pin 24 which is ground for the "Busy" line). Then, you'll be able to control the voltage output on the different pins (2-9) by turning the individual lines on or off.

Attached is an example code which should allow you to control the output signal on the different parallel port pins.

So basically: find pins 11 and 12, tie these to pin 18 (or 19, or 20, or 21, or 22, or 23, or 25).
find pin 2; this is bit 0. find pin 16; this is the signal GND.
measure the voltage between these two pins.
use the attached example to turn "bit 0" on and off (i.e. turn the top light on the array on and off by clicking on it); see the changes in voltage on pin 2.
If it works, reshape the code according to your own needs.

Good luck!
0 Kudos
Message 2 of 11
(6,068 Views)
This approach will really not be very reliabel and fast. If you can live with dealys of some ms, here it goes:
You need a LabVIEW installation with VISA serial support. This covers both the serial and the parallel port.
Start LabVIEW and create a new virtual instrument (VI). Open its block diagram (BD) and right-click on any place you like on the white BD. Choose from the Functions-Window the icon 'instrument I/O' and from there 'serial'. From serial, you choose 'VISA configure serial port' and, in a second and third approach, 'VISA Bytes at serial Ports' and 'VISA close'.
Drop all icons (VIs) on the BD. Press ^H to open the help window - you will see usage infos to those VIs.
Data exchange in LabVIEW is 'data flow', and it flows along wires you have to wire to connect proper ports on subVIs.
Right click on the port 'VISA ressource name' of 'VISA configure serial port' (top left) and chose 'create control. Connect the 'duplicate VISA ressource name' (top right) with the same port on 'VISA Bytes at serial Ports' (top left again). Connect the appropriate output (top right) with the input of 'VISA close'.
Right-click onto the blue text 'Bytes at serial port' in 'VISA Bytes at serial Ports' (this is one property of that serial connection.) and chose properties. Navigate to 'modem line settings' and chose any of the 'line xxx state's. Create a control for this property and your first program is ready.
Switch to the front panel (FP), chose an apropriate serial port and a line setting and run your code (^R or the big arrow under the -menu.

You should take a look at NIs examples (Help/example finder), search for 'serial' for a deeper insight into LabVIEW.

Have fun and
Greetings from Germany!
0 Kudos
Message 3 of 11
(6,063 Views)
Thanks a lot for your immediate answers, I will try them the next days. Meanwhile I will try to clarify my needs. What I want is to have a signal out of the serial (or any similar port) that will be 0 generally and then 1 for a period of some seconds. I need 0 to be 0V and 1 can be between 1 and 5V. The accuracy of the start end that I need is approximately some milliseconds.
0 Kudos
Message 4 of 11
(6,058 Views)
In that case you should go for the parallel port solution, as it will allow you to keep the signal high (approx. 5V) (or low for that matter) for as long as you wish, and you'll be able to switch its state between low (= 0V) and high (= 5V) with sufficient precision if we're talking no faster than milliseconds here. For the RS232 solution, it'll be hard to keep the line high for longer periods of time.
Have fun, and let us know how it works out.

m,-
0 Kudos
Message 5 of 11
(6,055 Views)
It's easy to control the time of the serial control lines (not Tx) by using a VISA property node and using Modem Line Settings but you have to use the parallel port because the output voltage levels of a serial port are not TTL.
0 Kudos
Message 6 of 11
(6,047 Views)
Hello everybody,

Dennis can you explain me a bit more detailed the thing about keeping the serial port high or low?

I do not need 5V, I have tested the device I want to trigger and the triggering works even down to 1-2V

I have made my first attempt to create a vi for what I want to achieve and at the moment I am just trying to understand what this vi is actually doing :-))

Thanks a lot for all your help
yours
Vasilis
0 Kudos
Message 7 of 11
(6,012 Views)
On the Instrrument I/O>VISA>VISA Advanced palette is the VISA Property Node. Drop this onto your diagram. Right click on it and select Change to Write. Right click again and select Properties>Modem Line State. Pick one of the serial port outputs (i.e. RTS State) and then right click the property and select Create Control or Create Constant. You can assert or unassert the line and it will stay in that state until you change it.
0 Kudos
Message 8 of 11
(5,995 Views)


@Dennis Knutson wrote:
...it will stay in that state until you change it.



... or (at least in earlier LV versions) until LV is quitted.
0 Kudos
Message 9 of 11
(5,992 Views)
You're right. I should have mentioned that.
0 Kudos
Message 10 of 11
(5,990 Views)