LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RS-422 : data with 2 TermChar (Event based program)

Hello Everyone,

 

I'm using Labview (8.6) to make a program that interacts with a measurement system.

The communication with the device is done trough a serial (Rs-422) port. The device sends messages at 5Hz rate after a request from the PC.

The structure of the messages sent by the device is always the same, with a known minimal length and a two-character terminaison.19200 baud , parity=none, bitstop=1, databits=8.

 

I'm trying to make an Event based program. Please find attached the example of vi that I use (8.5 version).

 

I have a lot of warnings and after 50 cycles an error comes if I don’t use the VISA Disable Event and VISA Discard Event. Il seems that the event FIFO is never emptied event if I use the  VISA Wait On Event at each iteration of the loop.

The warnings and error are also attached. It seems that I haven’t good understood the event based programming. Can someone give me an explanation, how does it work or give me another proposition to identify the end of a serial message with 2 TermChar.

 

Thank you in advance for your support. 

Download All
0 Kudos
Message 1 of 5
(3,324 Views)

Hi MUserSTM,

      Is this still an issue?  Maybe the problem can be reproduced by having a simple VI write data to a COM port, and loop that to another COM port that your VI is listening on.  There are a couple of USB/Serial adapters on my desk. 

 

If you're still fighting with this, please reply and attach your most recent code!

 

Cheers.

0 Kudos
Message 2 of 5
(3,261 Views)
Hi VIagra, I'm still fighting with the problem. Your idea to simulate the device by sending the messages from one port to another is really clever. I'll try to this as soon as possible. My comprehension of the VISA Event interruptions is still poor. Could you please give me an explanation of how does it work.  It seems that VISA Wait On Event does not consume an event from the FIFO on each iteration. Is it normal that I have to use VISA Disable Event and VISA Discard Event in each iteration of the loop?

 

Best regards

0 Kudos
Message 3 of 5
(3,231 Views)

Hi MUserSTM,

      There were a bunch of little problems, but the core problem - that the Event queue fills-up after 50 events - has a very strange solution:

It can be caused when the "event" output terminal is wired on the "VISA Wait Event"!?

 

Run the attached VI - it seems to work with event output unwired.  Then click "Enable BUG" - it calls VISA Wait Event with "event" output wired and PRESTO! the full queue error after ~50 loops.

 

For future reference, the Detect Break Event.vi Example can also detect the "Serial-Term Char" event.

 

By the way, I've had problems using the "Bytes at port" node so programmed around it.

 

Also, your app will, theoretically, loop at 5KHz - in my experience, that's a pretty fast loop - does your program need to react instantly, based on a message value?  If not, I'd be inclined to forget the event handling and just read multiple messages periodically.

 

Cheers!.

 

Download All
0 Kudos
Message 4 of 5
(3,205 Views)

 Corrections Smiley Tongue


VIagra wrote:

      There were a bunch of little problems, but the core problem


 

 Should be: "There were several little problems in ExempleRS232.vi,but the core problem..."

 


VIagra wrote:

...  your app will, theoretically, loop at 5KHz - in my experience, that's a pretty fast loop - does your program need to react instantly, based on a message value?  If not, I'd be inclined to forget the event handling and just read multiple messages periodically..


Should be: "that's a pretty fast serial IO loop"

and: "I'd be inclined to forget the event handling and just read multiple messages much more slowly - say @ 10Hz."

 

Cheers!

0 Kudos
Message 5 of 5
(3,194 Views)