LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically increase sequence size

Hi everyone,

 

I'm fairly new to Labview and I'm having a hard time doing some fairly basic tasks.

Currently I want to programmatically change to size of a sequence. 

I need to automate a sequence of valves to open and I would like the amount of steps to change based on a number.

Currently I have 9 clusters (one per step) with a timer to change how long a step takes, however this doesn't seem the right way of doing it especially as it's not sizable. I'll attach some screenshots that will hopefully help explain. (each button is a valve)

 

I'm also trying to completely stop valves from opening or closing depending on some pressure sensors as if there is pressure and the wrong valve opens it could break a lot of expensive flowmeters.

 

Regards,

Andrea

Interface.PNG

block diagram.PNG

0 Kudos
Message 1 of 7
(404 Views)

Hi Nizzo,

 


@Nizzo wrote:

Currently I want to programmatically change to size of a sequence. 

I need to automate a sequence of valves to open and I would like the amount of steps to change based on a number.


This is the wrong way to create your program/algorithm!

Instead of trying to add/delete frames in your sequence you should use a simple state machine!

Then it becomes very easy to define the number of "steps" (aka iterations) of the loop around that state machine…

 


@Nizzo wrote:

I'm also trying to completely stop valves from opening or closing depending on some pressure sensors as if there is pressure and the wrong valve opens it could break a lot of expensive flowmeters.


This also becomes very easy once you create a simple state machine! You can check your conditions in each iteration of the loop around your state machine…

 

Btw.:

  • All those "Steps" clusters belong into an array of clusters - or even use a simple 2D array of booleans!
  • When using an array of clusters: place the wait time inside the cluster. Otherwise use a numeric  array to define the time for each step…
  • Why are there all those coercion dots? Why don't you define the wait time as U32?
  • Why are there so many generic control labels? Why don't you define reasonable control labels?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(368 Views)

It seems that you are asking how to have a program modify itself.  That's usually impossible, and where it is possible, it's almost always a very bad idea.

 

Instead of having a bunch of separate controls use an array.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 7
(328 Views)

Hi GerdW,

 

How would I go about using a state machine for this? 

From my understanding a state machine inside a loop just does the same thing over and over and changes depending on variables. How do I program it to give a different input each time it comes around?

 

My complete idea is to have this page to create/modify an automation, each "step" will then have a selection box to automate valves/motors/pumps (depending what's needed) and I can see how a state machine can take care of that. However I'm struggling to understand how a state machine can increase or decrease the number of steps, because it would do the same thing over and over if it was the iterations of the loop, or am I understanding this wrong?

 

 

Questions about your tips:

 

1-2) I ended up using 1D arrays for each step, However how would I go about:

   a) Getting only the time from a cluster

   b) Splitting the second dimension of the array into each step.

3) That was just ignorance, I did change it to U32 and the coercion dot went away.

4) Right now I'm just trying to figure all this stuff out. So there is a lot of changing and I've been too lazy to rename everything every time I need to restart. But everything will be labelled properly by the end.

 

I really wanna tank you for your help, it's very appreciated.

 

Regards,

Andrea

 

0 Kudos
Message 4 of 7
(303 Views)

Hi Paul,

 

I could move to 2D arrays lie GerdW said however I would still need to change the size of the second dimension, wouldn't that still be considered changing the program?

 

regards,

Andrea

0 Kudos
Message 5 of 7
(302 Views)

@Nizzo wrote:

Hi Paul,

 

I could move to 2D arrays lie GerdW said however I would still need to change the size of the second dimension, wouldn't that still be considered changing the program?

 

regards,

Andrea


No.  Changing data size is not changing the program.  Also, on controls that are arrays, the number of elements displayed is a property that is writable at runtime. 

0 Kudos
Message 6 of 7
(292 Views)

If you change those cluster into an array of cluster, most things will solve itself and you'll cut down your code by 80%.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 7 of 7
(254 Views)