11-30-2009 11:03 AM
Hi friends!
I'm getting almos crazy here with a problem that surely is simple to solve:
The main VI has an inditator to show the operator a certain value of the process. In the background ther is a state machine running the process control. To let things simple, lets say there are 3 states: Calculation, Actuation and Waiting Response. The whole structure should work like this:
#1 In the calculation state read the process value and determine de desired output
#2 In the Actuation state the output is applied to the process
#3 In the Waiting Response state the machine awaits until the previously applied output affects the process
As the indicator is updated continuously, it is connected an acquisition VI in the most external loop. The problem is that the value used in the Calculation step is just the same connected to this indicator. So, as I could debug, just after the machine leaves the Calculatoin state, the data acquisiton hardware deliver a new reading of the process, an it keeps doing this continuously. In that way, when the machine comes back to the Calculation state, several external loop cycles after, the value avaiable in the tunnel us an old one, the one that arrived just after leaving Calculation state, not the last one the acquisition hardwre read.
It is important that the acquisition VI stays in the outer loop, in order to get the indicator updated. The number of states and their functionality is also quite imutable. It seems to me that all my problems would desapear if the case structure used in the state machine could use hust the last value received from the hardware.
I'm awfull sorry for the los text, but does anyone have an idea of what could be don in this case?
Thanks so much
Leo
Solved! Go to Solution.
11-30-2009 11:50 AM
11-30-2009 12:08 PM
You could use notifiers. Send a notification in your hardware loop.
Use a wait for notification with timeout 0 to get the latest value.
This will look similar to the producer-consumer design pattern, if you are familiar with this.
Felix
11-30-2009 12:33 PM
If you are using a shift register in the loop where the data acq is going on, and the new data is overwriting the old acquisition data using a bundle by name to write the new data into the cluster, then the newest data should be available whenever the other functions need to run. The attached example is crude, but does what I was trying to say. If that works...then great.
State machine goes in the top loop...might add a third loop for the events creator.
Good luck.
Hummer1
11-30-2009 12:56 PM
Thank you for your reply, zenthoef.
My problem is not ensuring the indicator has the latest vallue, but the case structure. In fact, the indicator is updated online, so it has always the most recent value.
11-30-2009 01:02 PM
Dear Felix,
I guess that's an intersting point of view. I'm afraid that with a wait for notification the case structure will still reading only the the first, thus the oldest, value. I'll try to deveop something with this suggestion and report you back as soon as I have some results.
Thanks
Leo
11-30-2009 01:05 PM
Thank you Hammer1.
I'm not in my PC right now, so it may take some time for me to feed you bck about your example.
Leo
11-30-2009 01:32 PM
Sorry, my first example doesn't work. Here is an example using a 1 element queue that works like I think you want it to.
Hummer1
11-30-2009 01:37 PM
Wrong example ... Here is the correct example...
Hummer1
11-30-2009 01:40 PM
Keep linking to wrong example...just a second.
Hummer1