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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structures-best way to implement this UI?

I am trying to write a VI to control & read data from 4 different "channels" (each measuring a DUT) at once.  I have written all the VI's for initializing instruments, communicating with the devices (VISA, GPIB), setting bias, reading data, etc...that has all completed. I just need to write the overall program with the user interface to allow the user to control these 4 channels & display the measured data.....as it turns out, this is the tricky part! My head is spinning from trying to figure out how to handle all the possible events. 🙂

 

Basically for each channel, I want the user to be able to

 

-enable/disable it  for measurement (e.g. if  there is no device loaded in Ch.3, we don't want to measure Ch.3..maybe disable/grey everything)

 

-set bias conditions (only if channel enabled). Allow user to change bias "in real-time" by increment/decrementing (e.g. incrementing from 5.00 V to 5.01 V, for example).

 

-turn biasing on/off (again, only if channel is enabled)

 

Also,  I want each channel to display its measured data (e.g current, temperature reading)..every second or so. No graphs or anything fancy (for now! :)), just numeric indicator. 

 

Honestly, this all sounds so simple but I'm having trouble figuring out the best way to implement this, due to the fact that 1) there are multiple channels needing to be monitored for events  2) large number of user events that could occur (seems like at least 4 per channel - enabling/disabling, turning bias on/off, incrementing/decrementing bias values, etc ), Also the if a channel IS enabled, i want to be continously reading/displaying the data.  What is the best way to handle this? Should i have 4 separate while loops, each with an event structure to handle events for that particular channel..or will that give me grief somewhre? 

 

Also, I have another nagging question. Pretty much all the examples I see re: Event Structures and booleans involve latched booleans, eg. buttons that are just pressed once and pop back up...e.g. buttons you press to tell it to complete a task (e.g. "Acquire Data" or "Stop") , and once it's pressed it's over and reset.  In my case, some of the booleans would not be latched...e.g. the "Enable Ch.2" button would be 'TRUE" as long as i want Ch. 2 to be read....does that make sense? Then, say hours later,  if i did want to disable that channel,  i would change it to "FALSE" and while that would be an "value change", the new value would not be "TRUE"..does that make sense? So  not sure if that would be dealt with the same way in an Event Structure. 

 

Hope this all makes sense and many thanks in advance for any help!!! 🙂

 

 

0 Kudos
Message 1 of 7
(2,706 Views)

You're halfway there. I'd say the best solution is a producer/consumer structure, the event structure is used to generate queued commands to the consumer loop.

All data is handled in the consumer loop, where you among other things have an array of clusters of channel/instrument settings. (I usually have several cluster, one for test data, one for instrument settings, one for general settings and so on)

The event structure can have a 1 sec timeout, in which you queue up a Measure command.

In the consumer, in the measure state you loop through your instruments and if enabled you measure them and update their indicators.

The general (smart) way to setup the queue is with a cluster containing 2 elements, a typedef'd Command and a variant.

This way you can send data with the command in any form which is then interpreted in the consumer.

If, e.g. you press the Enable button on a channel, you can enqueue Enable and the channel number.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 7
(2,694 Views)

are you controlling the enable/disable channel via a button from your vi front panel? if you are controlling it yourself from a button then you can change the button mechanical setup and select it accordingly, click on button and then right click you will see a dropdown menu listing a 'mechanical .. ' option also. in this you can select what your button should behave.

0 Kudos
Message 3 of 7
(2,658 Views)

yamaeda - thanks for this!  i had been thinking about doing a producer/consumer structure but wasn't sure. i guess the only question left if i should have four of these (one set for each channel) or if it is better to just have one big one and have just different channels be different events. 

 

tirmizi - thanks, and i did figure out how to change the mechnaical action property on the boolean from front panel, so that it does remain on even after it was released. i guess the question i have is how a value change of this is handled in the Event Structure. pretty much all the example i see of Event Structure have a latched boolean, so that any value change would be "true" (e.g. pressing a "start" button). However in my case, the action depends on what the value was changed to...whether it was True to False (e.g. want to turn bias off), or False to True (e.g. want to turn bias on). I was thinking of putting a case structure inside an event structure for this, but then i remember reading somewhere that was bad form, for some reason..but it seems like the only way. 

 

 

 

0 Kudos
Message 4 of 7
(2,622 Views)

With switch action, the boolean value change event will occur either way, whether it is true to false, or false to true.  You can use the NewVal node inside the event, or use the terminal itself.  There is nothing preventing you from using a case structure inside an event, I don't know where you would have read it was bad form.  (Putting a long running while loop inside of an event case is a bad idea.)

 

Whether you need a case structure or not depends on exactly what you are trying to do, or if you are doing different actions whether new value is true, or false.

0 Kudos
Message 5 of 7
(2,603 Views)

@neets wrote:

yamaeda - thanks for this!  i had been thinking about doing a producer/consumer structure but wasn't sure. i guess the only question left if i should have four of these (one set for each channel) or if it is better to just have one big one and have just different channels be different events. 

 

 

 


1 set and an array of channels. 😉

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(2,505 Views)

@RavensFan wrote:

<snip>

There is nothing preventing you from using a case structure inside an event, I don't know where you would have read it was bad form.  (Putting a long running while loop inside of an event case is a bad idea.)

<snip>


It could just be a learning error.  Maybe the advice actually was, "It's generally bad to put an event structure inside a case statement."

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 7
(2,486 Views)