LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating outputs inside case and sequence structures.

I am having problems creating a control program for a solenoid that I am working on.  (This control program is a small apart of a much larger program)

There are three states that happen to turn on the solenoid.
1) The high current stage is turned on
2) Both current stages are turned on
3) The high current stage is turned off and the low current stage remains on until turned off.

There is a state where the solenoid is off, both states turned off.

I made a Labview program that attempts to create these three states, using a sequence and a case statement. (see attached) You can click on "request open" and see in "global_solenoid_current.vi" that the switches operate properly and the low current LED does not turn off until "request closed" is clicked.  (I had to use global variables in order for this bit of code to work in my main program)  The global variables update in the sequence, but they do not update the LED's on the front panel in the properly.  How may I allow these LED's to operate properly?

Again there are many constraints with this piece of code since it is in a larger control program with an over-all while loop.
-I cannot put a permanent while loop around the solenoid control code since it exists within another large while loop. If the smaller loop executes then the next iteration of the main loop never occurs until the smaller loop ends.
-Also, one must be careful not to have one unstoppable sequence since it would repeat in every iteration of the larger main loop. 
-I tried a state machine, but that did not seem to work well.  The sequence repeats over and over.
0 Kudos
Message 1 of 2
(2,104 Views)

You need to understand dataflow.

In your program, you only read the globals exactly once/call of the subVI and write the output to the LEDs of the program. Thus the indicators get updated exactly once at an undefined time with repect to the other code.

As a bandaid fix, you could remove the global variable reads and write to locals of the LEDs in the various frames where the LEDs need to change. Also don't do unecessary global reads and writes. For example, if both cases are False, you read a global, then write the just read value back within nanoseconds. This is a completely useless operation if you think about it. Right?

Somehow, the program does not feel right at all, but I would need to see the rest of the code for a final analysis. There has to be a better way to do this!

 

0 Kudos
Message 2 of 2
(2,091 Views)