09-16-2014 04:01 PM
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.
09-16-2014 04:28 PM - edited 09-16-2014 04:33 PM
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.
09-16-2014 04:34 PM
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.
09-16-2014 04:51 PM
Here is a view of how you might close the program gracefully.
09-16-2014 04:55 PM
09-16-2014 05:03 PM
try putting a wait function with a small value (50) in the bottom loop. It may be a processor hog.
09-16-2014 05:24 PM
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.
09-16-2014 05:24 PM - edited 09-16-2014 05:24 PM
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?
09-17-2014 06:51 AM
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.
09-17-2014 09:09 AM
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.