LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer Consumer Event Structure with Continuous Display

I'm trying to figure out the best way to utilize a consumer-producer queue structure using an event structure, but need my display continuously updated.  I'm controlling several power supplies.  My producer loop has an event structure that responds to GUI events.  The consumer loop takes these events and sends commands to the power supplies depending on the event.

The added capability is to continuously read the power supply voltage and current and display on the GUI if the PS are ON.

 

I've tried creating a separate While loop.  This doesn't seem to work.  The program stops responding to events.  

 

Any suggestions would be appreciated.

0 Kudos
Message 1 of 16
(4,064 Views)

Post your code.  It's hard to diagnose without it.

 

It sounds like either your producer loop is being stopped and no longer is putting things on the queue for your consumer loop OR your consumer loop is stuck in one of it's states.

0 Kudos
Message 2 of 16
(4,048 Views)

Can you post some code so we can see why it isn't working?  I have 3 loops in my application that does exactly what you mention. 

 

The first loop (producer) is a DAQ loop that is continuously displaying voltage, current and RPM (even when supply is off).  I use a queue to send data to my third loop (consumer). 

The second loop is an event loop which sends commands to my state machine.

The third loop is a state machine that takes commands and runs test sequences. 

I have a fourth loop for error logging but it is a new addition....an afterthought, if you will (since I hate dealing with errors).

 

Here is a general layout of my architecture.

 

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 16
(4,038 Views)

Here is a view of how you might close the program gracefully. 

 

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 16
(4,030 Views)
Thanks for the replies. I've attached my code. I'm able to turn on my first supply and the readings are shown...but afterwards, the GUI doesn't respond. I think it gets stuck in the display while loop.
0 Kudos
Message 5 of 16
(4,025 Views)

try putting a wait function with a small value (50) in the bottom loop.  It may be a processor hog.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 16
(4,020 Views)

You use a lot of sequence structures to handle operations....one frame for each supply.  The code appears to be exactly the same for each supply.  I would consider looking into an array of clusters for your front panel controls and feed them into a for loop with your code in a subVI.  Makes for easier maintainability.  With your current design, a change to one power supply would need to be repeated 7 more times. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 7 of 16
(4,008 Views)

Could it be that you are piling up read commands in the queue so your set commands never stood a chance at being processed because they are way in the back of the queue?  (I haven't seen the code so I'm just guessing - I have LV 2009.)  Maybe you can queue the set commands at the opposite end so they are acted on immediately?

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 8 of 16
(4,007 Views)

I would put the querrying for the current settings in your consumer loop.  Just use the timeout capability of the Dequeue Element.  To make it cleaner, add a value to the beginning of your enum, since that will be the default when there is a timeout.


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
0 Kudos
Message 9 of 16
(3,967 Views)

PS1 has an added VISA command "STAT:PROT:ENABLE?"  Not sure what this does but since it is not there on the other supplies, I am curious about it.  VISA is trying to read 10 bytes after issuing this command.  Depending on your timeout settings, it may get hung here waiting for all 10 bytes.  I'm not certain that is how VISA operates but it may be worth looking at.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 10 of 16
(3,946 Views)