Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

COM1 - external switch launch a SubVI

Solved!
Go to solution

Hello everybody,

I would like launch a SubVI with external switch (maker or breaker), that means: I need a start signal. Is this possible about the COM1. I have tried with PIN2 (RxD) and PIN5 (GND). But unfortunately I couldn't find a solution.

 

Does anybody have a idea?

Thanks

greetings zäpfle

 

0 Kudos
Message 1 of 13
(4,533 Views)

I don't fully understand your question, but it sounds as if you're trying to use the serial port as a poor man's digital I/O port. Well, you can certainly do this, but I'd use the DTR or DTS line rather than the RX line since you can use a VISA Property Node to get the line state. You could monitor the state of the line and then trigger the code you need when the line state goes high (or low, depending on which direction you need).

 

To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

0 Kudos
Message 2 of 13
(4,527 Views)

Thanks for your reply.

A switch should be between two PIN's (RS232), but I don't know between which PIN's (see attachement). If I hit the switch to on, than I would like get a signal or status in the LV program. I can try a "loopback", that means I send a signal (e.g. a word, from PIN3 TxD) and receive this signal (PIN2 RxD), after I hit the switch to on. The problem is I have to send the signal without a break.

Do you mean this is a solution?

greetings zäpfle

0 Kudos
Message 3 of 13
(4,501 Views)

I attach a example. If I connect PIN3 (TxD) with PIN2 (RxD), in the indicator "read buffer" appears the word "Test". The problem is: the program runs very slowly.

How can I improve this?

greetings zäpfle

0 Kudos
Message 4 of 13
(4,499 Views)

It's slow because you've enabled a termination character for the read but you are not sending any. The read is timing out wating for 1000 bytes. Append a LF to the write or disable the termination character and use VISA Bytes at Serial Port to determine how many bytes to read instead of your 1000 constant.

0 Kudos
Message 5 of 13
(4,476 Views)

 


@zäpfle wrote:

Thanks for your reply.

A switch should be between two PIN's (RS232), but I don't know between which PIN's (see attachement).


A switch does not need to be between two pins. It can be between a pin and a voltage source or ground. If you want to use one of the serial port pins then you should familiarize yourself with the RS-232 protocol and the RS-232 pins.

 

 

 


@zäpfle wrote:

I attach a example. If I connect PIN3 (TxD) with PIN2 (RxD), in the indicator "read buffer" appears the word "Test". The problem is: the program runs very slowly.

How can I improve this?


It's slow because VISA Read is waiting for 1000 bytes. You've configured the VISA Configure Serial Port to have VISA Read end once it sees the termination character. You have provided none, so VISA Read just sits there waiting and waiting until it times out. Please read the documentation on the VIs and functions you are trying to use.

 

0 Kudos
Message 6 of 13
(4,473 Views)

Hello,

I solved the problem with the pins and the speed.

 

But now I have a new one.

I would like the SubVI "Untiteld_1_LV86.vi" insert into the VI "Serial Write and Read_Ereignis.vi". The LED sould be controllable with a external switch. (LabvIEW 8.6)

If I push the external switch the first time the LED sould be ON, if I push the external switch the second time the LED sould be OFF, if i push the external switch the third time the LED sould be ON etc.

 

Do you have a idea?

 

Thanks and greetings

zäpfle

 

 

0 Kudos
Message 7 of 13
(4,417 Views)

I have no idea why you're trying to set up multiple loops, and use a subVI that has its own loop and have a global variable that disassociated from your code. You are making this way more complicated than it needs to be. You already have a loop that's monitoring the serial port. That's the only one you need. Place a shift register in that loop. That and some Boolean logic will solve your problem.

 

0 Kudos
Message 8 of 13
(4,401 Views)

I modified your example somewhat. Is this what you are looking for? or do you really have to use SubVI's and other methods that would make this way more difficult than it need just like said.

 

Kas

0 Kudos
Message 9 of 13
(4,393 Views)

Unfortunately, is your example not exactly what I looking for.

If I push a external button (COM1, Pin2 and Pin3), at the "VISA Reads" output "read buffer" appears the Input (from Visa Write) in this example is it "Test" as long as I push the button. The LED is ON. If I push the button again, the LED is OFF untill I push the button again.

 

The mechanical Action of this external Button is comparable with Latch until released.

 

I attach a example, which nearly works. The problem is: How long is the button pressed. If the button too short or to long pressed, the program doesn't work correct.  

I need a program, in which the time (pressed time) hasn't a influence.

 

I hope I could explain the problem.

 

Do you have a idea.

 

Thanks and greetings

 

zäpfle

0 Kudos
Message 10 of 13
(4,377 Views)