LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Alternate to Nested case structures ?

I have a complete machine control sequence as a State Machine (SM) .

The SM must run only when the following cases are true and immediatley stop if any of these become false :

1. Emergency button not pressed.
2. Temperature within bounds.
3. System safety flag ON.
4. Cycle Start command is ON.
5. All analog parameters within bound.

I have implemented the above as a 5 level nested case structure starting with item 1as outermost ( top most priority) . The innermost structure ( Parameters within bound )  has the SM in its true case.

And all of above are inside a 50ms Timed Loop.

The multiple levels of nesting, combined with the numerous shift registers and some 70 odd SM states, makes the coding and wiring a complex jungle of colours. Is there no other elegant way of handling such multiple "health" criteria to run a SM ? Just to see the bottom of the Timed loop I have to scroll down furiously !!

Help please . Thanks.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 16
(6,518 Views)
One option is to build an Array of all these conditions (booleans).  Then use the 'And Array Elements' from the Boolean palette -- if the result of this is True you execute the state. 
 
Regards,
 
-Khalid
0 Kudos
Message 2 of 16
(6,512 Views)
Why you nested cases, if all you want to do is a boolean operation?
Use the compount arithmetic in the boolean box, right click to choose the type of operation 
(And do a complete systemtest of your algebraSmiley Wink, it's just 5 inputs)
 
 
if A then
  if B then
     if C then
 
or just
 
If  A AND B AND C
 
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 3 of 16
(6,504 Views)
Hello Khalid /  Henrik,

Thanks and  what you recommended must be fine. But there is one more issue - each of the 5 "health" conditions, when they fail, need to be handled differently : ( Sorry for not mentioning that earlier.)

- Like if the Emergency is locked, then all DOT / AOT are set to zero immediatlety.
- If the Cycle Start vanishes then I need to do some file saving routines and also switch of AOT / DOT in a particular sequence
--- and so on for other 3 cases also.

The DOT / AOT array node is common to all cases of the state machine and thus cannot be updated or written from outside of it.

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 4 of 16
(6,503 Views)
You could create a boolean array and convert it to U32 with "Boolean Array to Number".  The 0 case is everyting fine, 1 case is the first condition false, 2 case is the second, 4 case the third, 8 is the fifth, etc.  You would have to decide what to do when multiple things happen at once.... I.e. does one chase trump all the others?  If so, make that one default.  If you want a more complicated hiearchy, you can assign muliple values to a single case.
Message 5 of 16
(6,485 Views)
like this ?
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 6 of 16
(6,479 Views)
I am curious, Henrik.  Why bundle into a cluster and then convert to array?  Why not create the array directly?
0 Kudos
Message 7 of 16
(6,478 Views)

you are right ,   Smiley HappySmiley Happy

 

long day long week TGIF Smiley Very HappySmiley Very Happy
 
Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


Message 8 of 16
(6,464 Views)
Here is another method.  Bundle, convert to an array, And array elements to get True/False.  Inside the case, unbundle.  Now you have access to all elements inside the case to do whatever you need to do.
 

Message Edited by tbob on 03-03-2006 09:36 AM

- tbob

Inventor of the WORM Global
Message 9 of 16
(6,463 Views)
The Boolean Array to Number  function is the exact solution that I was looking for. Quite elegant and simple.

5 star thanks to both Jasonhill and Henrik . 

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 16
(6,435 Views)