12-17-2023 05:56 PM
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
12-18-2023 01:14 AM
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.:
12-18-2023 10:36 AM
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.
12-18-2023 04:21 PM
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
12-18-2023 04:24 PM
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
12-18-2023 05:04 PM
@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.
12-19-2023 04:04 AM
If you change those cluster into an array of cluster, most things will solve itself and you'll cut down your code by 80%.