Using Timers in Labview

We are a second year rookie team with alot of learning to do in labview.
We are trying to create a timer using Labview with no success
Here is what is needed.

With the touch of one button…
We want to activate a pneumatic cylinder up and down. Then right afterward we want a PG motor with a jaguar to turn on and off in a short period automatically.

This is to load our shooter with a cylinder, then reload the cylinder from a hopper with a pg motor.

Would anyone out be willing to send us some sample Labview code to make this work. We understand we will need to test the actual timing of this, but getting a look at some sample code would be greatly helpful.

Thanks so much for being such a great resource for a rookie team

jalmos

When I have access to LabView then I’ll post what I have.

Here’s a rather busy example of doing a sequence like you describe.
A sequence like this goes in the Periodic Tasks.vi due to the delays involved.

The right way to do this in LabVIEW is with a state machine.

A state machine basically works like this:
-You store the state of the machine as an integer number or enum
-Every loop, you run code conditionally based on the current state, and evaluate if you should change to another state
–If you decide to change, then you set the new number or enum of the state
–If you don’t want to change, then you set the same number as the currents tate
-We will also keep a loop counter which we will use to decide to transition.

In LV, you would implement this as a shift register or feedback node, integer number, and case structure. The number has to be integer, not float, with a blue wire.

You would then define each state, and assign it a number. Alternatively, you can use an enum, and define each state both a number and a name. The result is the same, since an enum can act like a number when you want it to. It looks like your states are:
-idle
-fire_open
-fire_close
-reload_wait
-reload_run
and they always run in that order.

I would then create a feedback node or shift register for a loop counter, and case structure with a panel for each of the 5 states.

Most of the cases will look similar, and basically do this:
-Add 1 to the loop counter
-Check if the loop counter is >= a threshold
–If yes, increment the state number and set the loop counter to zero
–Else leave the state number and loop counter the same.
-For the highest state, you will have to set state to 0 instead of increment it
-For the idle state, you will not use a timer, but the push of a button to increment the state number and reset the loop counter.

What’s cool about state machines is you can modify the code in each state to create fairly complex transitions between any states, just by setting the state number correctly.

I’ll post a VI of it later. This can go anywhere in the code without blocking, and can be interrupted by overriding the state (the flat sequence can’t easily be interrupted).