LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling states in a state machine more than once

Solved!
Go to solution

Mark idea was basically what I had in mind before reading Mark's post. The only difference is that I would have used a FOR loop auto-indexed with the pressure adjust array (since there is no requirement to repeat the increase-decrease sequence continuously). In the loop you set the pressure and then read the measurements.

 

Another improvement would be to put the pressure adjustment values in a configuration file so you don't have to modify the code if you decide to change these values.

 

Ben64

0 Kudos
Message 11 of 18
(1,260 Views)

Is this the correct way to take Mark's post and put it within a state? Ignore the title of the case "Set Low Pressure" I didn't change the title to "Set Pressure" yet. I don't think this is correct because nothing is calling the "Min pressure" to test that first.

RightPath.jpg

 

 

0 Kudos
Message 12 of 18
(1,254 Views)

That is basically it. One change you need to make though is to use a counter in a shift register rather than the 'i' value of the loop. Since you can have other states occur between your setting the pressure you need th e"set Pressure state to have its own counter. Simply add a shift register and initialize it to 0. Run it through your state machine but only increment it when you set the pressure. Use this value as the index into you pressure array. Also, the example I post could easy accept the min and max pressures as input as well as the array of set points. Nothing needs to be hard coded. It was hard coded in the example purely to make it simple.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 13 of 18
(1,236 Views)

@Mark_Yedinak wrote:

That is basically it. One change you need to make though is to use a counter in a shift register rather than the 'i' value of the loop. Since you can have other states occur between your setting the pressure you need th e"set Pressure state to have its own counter. Simply add a shift register and initialize it to 0. Run it through your state machine but only increment it when you set the pressure. Use this value as the index into you pressure array. Also, the example I post could easy accept the min and max pressures as input as well as the array of set points. Nothing needs to be hard coded. It was hard coded in the example purely to make it simple.


Hey Mark,

 

Thanks for the response. Would I still need the Quotient & Remainder function if I'm going to add a shift register and initialize it to 0? To increment it only when I set pressure, do I wire a +1 to it from the state? Also, if I want it to set the lowest pressure before it starts incrementing by 20%, how would this accomplish that since the "Min pressure" isn't wired to anything except the case structure?

 

Sorry if the questions are stupid, still learning

0 Kudos
Message 14 of 18
(1,228 Views)
Solution
Accepted by topic author buickgn

Since you mentioned that you would be repeating this for other data sets you could use the Remainder method or you could use the counter directly. If you use the counter directly you need to reset it to zero for each data set. The case statement I have could be used to set your minimum pressure. When the index is 0 set the minimum pressure. Otherwise set the calculated pressure. And yes, to increment the index simply put a +1 on the wire in the set pressure case. All other cases the wire simply passes through.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 15 of 18
(1,225 Views)

So then I need to put another case structure inside the "Set Pressure" case to accomplish this, correct?

0 Kudos
Message 16 of 18
(1,220 Views)

Not necessarily. You can have an explicit state for setting the minimum pressure. This would be my preferred method. If you haven't already done so you may want to put your state diagram on paper to define all the states and there transitions. This can be very helpful whem implementing it in code.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 17 of 18
(1,218 Views)

Understood, thank you for your help. I appreciate it greatly. Kudos to you, sir!

Message 18 of 18
(1,215 Views)