LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Program structure for event handling and periodic tasks

 Consider a vi with two main tasks:

1- Handling the user interaction with some controls

2- Performing iterative tasks

For example, a program may have several controls, menu items and ... which could be handled with an event structure easily. Parallel to this, some data should be tranferred periodically (e.g. via VISA Read/Write). The iteration time is low, i.e. 1 or 2 ms.

 

Which structure is better to implement such tasks:

1- One event structure. The iterative task is performed in Event Timeout call. 

2- One event structure + a parallel while loop, each performing one of above-mentioned tasks. The while loop may be controlled (i.e. transfer start or stop) with a flag variable, which is set in the Event structure. 

3- Using a while loop and state machine. Event handling is more complicated by this way.

 

 

0 Kudos
Message 1 of 4
(3,263 Views)

@iman_h wrote:

Parallel to this, some data should be tranferred periodically (e.g. via VISA Read/Write). The iteration time is low, i.e. 1 or 2 ms.


That should be all the information you need. If it's supposed to happen in parallell, put it in a parallell loop. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 4
(3,256 Views)

I would suggest a Queued Message Handler.

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
Message 3 of 4
(3,255 Views)

Hi iman,

 

I would seperate UI event handling and DAQ/VISA into their own loops.

Using a 3rd loop for data processing might be recommended too…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 4
(3,252 Views)