LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mixing VIs, statechart & PIDs

OK, so as a newbie I probably haven't taken on the most elemental project to start with ... but it's to brew beer with.

 

I've modified one of the example VIs that contains a GUI (Trigger) loop and a statechart loop.  My statechart describes the states of the brewing process with rudimentary guards in place.  I am having difficulties figuring out the following:

 

1. I presume that if during a state I need to control a temp with PID.vi, I place that in the Action tab of the state.  I'm setting the SetPoint to a contant and the process value to a thermometer control (to manuall adj). I leave the rest of the PID inputs default.  When the state is activated, the output value of PID.vi jumps to an initial value (48), then remains there no matter what I set the process control to 

 

2.  A similar problem occurs with a countdown timer  .. initial time of the count and no decrement ...

 

... as I write this it occurs to me (a procedural c++ programmer) that the state is executing once and only once, and that I need to place these controls in some sort of loop on the Action tab.

 

...so I may have answered my own question, but a headnod would be appreciated ....

0 Kudos
Message 1 of 6
(2,695 Views)

Hi ggeisen,

 

Headnod!

 

If the control is not inside the loop, then its value will only be read once. This value will be reused in each loop iteration. If you want the value of the control to be monitored as the program is runnning, then you're right, it goes inside the loop. Let us know if you have other questions, and good luck with the brewing!

Andy H.
National Instruments
0 Kudos
Message 2 of 6
(2,653 Views)

@MegaHertz: I've places a PID.vi inside a While loop on the State Entry Action page.  An input is connected through the loop boundry to the Process input of the PID. A SetValue is set via constant.  How do I get the Input.pv to be continuously read during the loop execution?  It seems no matter wat I set the Input.pv value to (via thermometer Control from the calling VI) the value does not change on the inside of the loop AND thus the PID does not react to any process value changes.

 

I've attached the StateChart and parent VI.

 

Thanks for any suggestions/assistance

Download All
0 Kudos
Message 3 of 6
(2,594 Views)

... obviously I need to re-read the Control, from inside the loop inside the State, but I am not sure how to do this.  Eventually this will be connected to an AI

0 Kudos
Message 4 of 6
(2,585 Views)

OK, so the PID is running in a while loop, within the action of a state .... but now the state no longer sees any changes (or doesn't look) to its inputs.  If I turn on trace, it seems all data flow activity has stopped, except w/in the state action.

 

This probably has something to so with the external trigger mechanism, but I can't figure out how the get the state to read/use the new process value input.

 

Can anyone help or whip up a quick example?

0 Kudos
Message 5 of 6
(2,559 Views)

Hi ggeisen,

 

It looks like you've wired a false constant into the conditional terminal of the while loop in your Mash entry action. Given this, it makes sense that the code is getting stuck on this step, as the loop never stops running. To modify the code, you at least need to build in some logic that will stop the loop on some condition.

 

Ideally, however, you shouldn't use loops with the Statechart module at all. It would be better to insert a transition that returns back to the same state until the necessary condition is met.

Andy H.
National Instruments
0 Kudos
Message 6 of 6
(2,544 Views)