From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop, timed structure of event structure is better?

Hi

 

I am developing an application for control of different hardware devices (microscope, digital camera, piezo-drives). My question is related with while loop, timed structure and event structure. Which instrument is more suitable. I am using image processing functions too.

 

Best regards

0 Kudos
Message 1 of 19
(3,328 Views)

Depends on your application and work done by your VI. 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Message 2 of 19
(3,326 Views)

Event Structures belong inside of While loops 95% of the time.  They are great for user interface.  So if you just want control as in something quick happens when you press a button, use the Event Structure.

 

If you need something to happen at an approximate loop rate, use a While loop with a Wait (ms) inside of it to limit the loop rate.

 

In Windows, you really shouldn't use a Timed Loop.  It adds a bunch of overhead and complexity for little to no gain over a normal While loop.  If you need precise timing on something, go get a Real Time device.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 19
(3,303 Views)

Hi,

 

Thank you for your answer. My next question is:

Is it correct to use more than one event structure for multiple devices for control in one while loop or I have to use multiple event structures for multiple devices in one or multiple while loops.

 

Best regards

 

 

 

 

 

 

0 Kudos
Message 4 of 19
(3,265 Views)

You should not have multiple event strucutres in parallel in the same loop, because the loop can only go to the next iteration once all event structures have fired. They will all step on each others toes, gumming up the gears.

 

The solution really depends on many things that we don't know from your sparse description.

 

What is "controlling"? Are you talking about pure human interaction or are you talking about programmatic orchestration of several instruments? If "controlling" an instrument is done by sending short commands, you can use a single event structure with mutltiple event cases.

 

You should stick with established design patterns. We need significantly more details to give more targeted advice.

Message 6 of 19
(3,252 Views)

Thank you for the answers.

 

I control one digital camera, microscope and two robots, actuated by peizo-actuators, along XYZ axis.  After the starting of the application all devices are configured and the camera starts working, By buttons I control the robots and the microscope. According to the results from the image processing it is possible to start some tasks of the robots and microscope too. 

This is shortly my task for automation.

 

I am using the driver of the camera Jenoptik ProGres XT 5 core from the manufacture and therefore for using IMAQ function I make some image processing. Therefore I receive a small delay during the image visualization of each frame. Is it necessary to use any hardware device as FPGA module for making real time applications thus accelerating the image processing or it is not necessary?

 

Best regards

 

0 Kudos
Message 7 of 19
(3,244 Views)

tiho wrote:

I control one digital camera, microscope and two robots, actuated by peizo-actuators, along XYZ axis.  After the starting of the application all devices are configured and the camera starts working, By buttons I control the robots and the microscope. According to the results from the image processing it is possible to start some tasks of the robots and microscope too. 

This is shortly my task for automation.


Based on that description, I would make a bunch of loops, one for each device and another one for GUI iteraction.  Use queues to send commands to each loop (different queue for each device loop).  That way anybody can send a command to somebody else (ie your vision loop sends a series of commands to your robot based on some automated algorthm and you can still send commands from button presses).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 19
(3,223 Views)

Hi

 

Thank you for your answer. As I understood from your message I have to use different while loops for different devices. What means to use queues for different loops. May I use in all while loops event structures. Now I control all devices in one while loop and one event structure in it. The control is not so stable. I don't know how to increse the stability of the software control.

 

5 times the device is working well and on the 6th time something happens and everything is going wrong.

0 Kudos
Message 9 of 19
(3,167 Views)

Queues are a way to send messages.

 

He's saying have multiple loops in a style something like this:

User Input

Camera

Device 1

Device 2

Device 3

 

In User Input, you have your Event Structure and you read all user input.  You send messages to the other loops with the queues based on this input.

 

Each of the other loops reads from their queue.  They get these messages and they perform an action based on the message received.  While they are performing this action, the user input loop is still reading more input so you can give another device instructions.

Message 10 of 19
(3,146 Views)