Sometimes, we want to let users configure different states of a program, adjusting timing on a sequence of outputs. This is an example of how that might be done.
This project is about CLD difficulty, and is one example of how you might let a user configure a sequence of outputs during runtime.
This code might be used in a factory or manufacturing line. Here, the user will specify the settings for a number of on/off valves, and one variable valve. They can be settable to the nearest 10 ms (plus or minus operating system jitter, of course). Exposing these as an array lets the user create an arbitrary length vector of these sequence steps. each with user-configurable timing.
Here is the front panel while in the Idle state, where the user can edit the sequence:
And once the user pushes Run, here is the front panel as it runs, with its status being shown on the screen:
To accomplish this, I started with the basic State Machine template. There are states for program initialization, letting the user edit the sequence, initializing the sequence, running the sequence, ending the sequence, and stopping the program:
Once we are running the sequence, we traverse the array of steps, and make use of a functional global variable to keep track of timing:
Once the timing on one state has expired, we pass on to the next. Upon completing the sequence, we return to the idle state.
The VI uses a couple of DAQ VI's. I set up simulated instruments at the time since I had none of my own at my desk.