My vi is attached.
In the 'Check for Equilib' case, there is a while loop that takes data from a pressure gauge and compares it against data taken equilibTime seconds previous. equilibTime is hooked up to a wait(ms) function inside the while loop. Currently it appears that the code in the loop runs, and then the loop waits so many seconds before the next iteration. I would like to reverse this process, i.e. in each iteration, the loop will wait so many seconds and then run the rest of the code in the loop. I want to do this because I don't want there to be any delay between then time the 'check for equilib' code finishes and the start of the 'add shot' case.
Can anybody suggest an elegant way of implementing this?
As a quick fix why don't you execute it then in a stacked sequence structure inside your while loop in Check for Equilib case. Wait first for so many milliseconds and then execute the code in the next sequence frame. An ellegant or preferred way (we all hate sequences in LV) is to have a simple state machine inside your Check for Equilib case with Wait state first and your code as the case in the state machine. This should solve your delay problem.
By the way, a better way to implement State Machines is to use enumerated type definition with your states wired to the case selector input. This makes it easier to modify the cases and avoid errors with misspelling of strings.
No. Use Flat sequences they are far preferable to stacked sequences. Functionally they are the same. But a flat sequence is easier to read, doesn't hide code, and you don't have to worry about backwards wiring caused by sequence locals in stacked sequence.
Note, you have two oddities in your lower while loop.
1. Write a value to an indicator's terminal node and to a local variable of the same indicator is pointless. They do the same thing.
2. Reading from a local variable of an indicator and writing to its terminal node is just as pointless, as you aren't doing anything.
In your middle loop "Add shot" case, you have the local variable of DC estimate righting to a right hand side shift register, but you never use the left hand shift register. So you are saving that value for future loop iterations, but never use it.