12-06-2022 05:36 PM
This one has me stumped on how to do it properly.
I am currently using the wait function, which I know is wrong, but it is allowing me to work while I try to fix it.
I need to switch an output high for a set time. Then after that time switch a different output high. Repeat until count is reached.
This is one cycle. I have hardcoded the timing on these, but actually have an input for time on my front panel before I hit cycle.
I can get it to cycle the correct number of times with a for loop, but would like to be able to cancel the test mid cycle.
As you guys know, can't do that with a wait command.
This is my extend or retract only code. I have it in an event loop looking for value change on Extend full or Retract full buttons.
They work great and allow me to cancel. I have tried a state machine, but for some reason can't get it through a full cycle.
This is running in my while loop.
When the Boolean is high my output is high.
The parts of the VI that won't load have to do with Labjack hardware. U6 to be precise.
I need to operate an actuator to the extend position then to the retract position while reading the feedback circuit.
I am currently reading 4 analog inputs. (only using 2 at the moment, 2 for future sensors)
I am controlling the 2 analog outputs to switch a pair of SSRs that power the electric actuator.
My main loop is running at approx 20 ms.
As any of you that open my vi will find readily apparent, I could use better coding practices.
Solved! Go to Solution.
12-06-2022 11:48 PM - edited 12-06-2022 11:51 PM
Instead of a sequence worm, just create a state machine and things will fall in place.
(sorry cannot see your code. consider "save for previous" (2020 or older) before attaching)
I would also recommend a few basic tutorials. Most likely you don't need any local variables and sequence structures. A one-iteration FOR loop is just a glorified sequence frame. Why are they even there?
12-07-2022 06:26 AM
I attempted a state machine. But can't get it to hold until my first condition is met.
Hence the flat sequence that at least gets me testing for the time being.
But it's not something I want to release to my techs.
I either get both outputs on, or it runs the first bit and then stops.
I created a state machine with what I am trying to accomplish and saved it to version 14.
12-07-2022 06:41 AM
Well....... turns out I just really needed to verify my variables are set correctly.
While playing with the stand alone code I found that I had "time retract" instead of "time extend" extend selected in the state machines second state.
This messed up what I was trying to do.
Thank you for watching this episode of the S#!t show and encouraging me on!
12-07-2022 07:45 AM - edited 12-07-2022 07:52 AM
Hi nerd,
@TheRednecknerd wrote:
Thank you for watching this episode of the S#!t show and encouraging me on!
Ok, some more suggestions for improvement: