LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Iterate through a cluster of errs so I can implement my guard clause in my state machine

alex_b2_0-1755506700861.png

I have a cluster of 3 error clusters. Each error cluster relates to a translation stage. I would like to have a guard clause in my state machine but the case structure only allows 1 error cluster to be wired to it at a time. I have used a for loop in the hope of passing out a single error cluster at a time.

 

I think I am on the wrong track here... I would appreciate some advice on a better alternative.

Thank you for your time

Alex

0 Kudos
Message 1 of 8
(167 Views)

Use Build Array instead of Bundle, then autoindex the array into the For loop.

However the Case structure must be into the loop. Whether this is appropriate for your program or not cannot be assessed without additional details.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 2 of 8
(146 Views)

Hi Alex,

 

in the example as shown in your image you should use BuildArray instead of Bundle to get an array of clusters (as already suggested).

When your question is more general "how to process each element of a cluster of same elements" then you could use ClusterToArray to convert the cluster (consisting of elements of the same datatype!) into an array.

 

In the end you get an array where you can apply an autoindexing FOR loop!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(111 Views)

Good morning, Alex.

 

     I'm curious why you need three Error lines on Shift Registers within a State Machine.  Can a single State give rise to two separate Error Lines, each of which are capable of generating an Error, meaning the State can have 0, 1, or 2 Errors within it?  [I can envision such a scenario, but I'll discuss it later ...].

 

     I use a Channel Message Handler as my model for a State Machine.  The Message consists of "Next State" (an Enum) and "Arg" (a Variant, in case I need to pass something "into" the State).  At the end of the Case Structure that encapsulates the State's code, there is an (optional) "Send Message" sub-VI that has as inputs the new "Next State" and any other Argument you need to pass (often unwired).  Between the exit from the Case and the exit from the surrounding While, there is an Error Handler routine that checks for Errors.

  • If there are no Errors, it just passes on the incoming Message (a Cluster of Next State and Arg) to the input side of the While Loop.
  • If there is an Error, it first bundles the "Error State" as Next State and the passed-in bundle that has "what would be done if there were no error" as the variant "Arg" part of the Cluster.  It then clears the Error Line so when the State Machine loops, it goes to Error State with the information about what caused the Error in the variant Arg component of the Cluster.

The net effect is that instead of going to "my next state", it goes to "Error State" with an Argument that tells what State caused the Error and the Error itself.  Now you can write code to do something with this information, including, if you want, to simply log it, and then (since you know what was going to be done next if there were no error) simply exiting the Error State and going to the "Next State".  [I don't advocate this -- I'd say "Save the Error Information to a file, and do a graceful shut-down, if possible".]

 

Bob Schor

Message 4 of 8
(89 Views)

Thank you both for the solution, but sadly it has raised further questions. The whole programme is shown below.

alex_b2_1-1755522627466.png

 

 

The producer loop will actually generate an image(5-10 per sec) to the user, once I receive my camera, for know I just generate a number. The consumer loop will be an event state machine.  It will deal with things like move only x,y or z, scan over x-y plane (nested loop) from x_min to x_max in steps of delx and y_ to y_max in step of del_y and a few other things.

 

I see now that the guard clause will send only the last err cluster, so I have now connected the error wires to the case structure. I want to use these to ensure sequential operation of the stages.  However, with so many error wires it is starting to look a mess..

 

Thank you once again.

Alex

 

0 Kudos
Message 5 of 8
(77 Views)

Hi Alex,

 


@alex_b2 wrote:

The producer loop will actually generate an image(5-10 per sec) to the user, once I receive my camera, for know I just generate a number. The consumer loop will be an event state machine.  It will deal with things like move only x,y or z, scan over x-y plane (nested loop) from x_min to x_max in steps of delx and y_ to y_max in step of del_y and a few other things.

 

I see now that the guard clause will send only the last err cluster, so I have now connected the error wires to the case structure. I want to use these to ensure sequential operation of the stages.  However, with so many error wires it is starting to look a mess..


This XYZ stage is just one device, so why do you need 3 error wires for a single device?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(72 Views)

Hello Gerd,

The x,y z stage is not a single stage. There are 3 actuators (Thorlabs DRV014) which are connected to a stepper motor controller (Thorlabs BSC203) and controlled independently. The x & y actuators will move a sensor, which I will raster over the plane parallel to the table. The z stage will move a light spot up and down, normal to the table.

 

Thanks for your input.

Alex

0 Kudos
Message 7 of 8
(50 Views)

If you want to stop on any error while keeping error info separate for each stage, use Merge Errors to get a single output error wire (it's similar to an OR).

To Merge Errors you can wire the three error wires separately, or an array of errors.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 8 of 8
(46 Views)