LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeating a digital boolean output a set time

Hello

First of all, let me state that i am -extremely- new at Labview.

I am in coorporation with at very busy professor of mine, trying to make a high pressure air pump switch on and off for a dynamics lab. As of this reason, this is self-study and very new terrain for a sctructural engineering student as myself, because this is considered mechanical engineering here.

I'm using a USB-6001 device, to witch is connected two valves that i have succeded in being able to get to switch on and off, using the following code.

Benjamin11_1-1623224878254.png

 

however, i would like to be able to make it run on its 'own' like for example:

On: 5 minutes

Off: 10 minutes
Repeat until stopped.

I've tried to youtube and search around in here, to which i found something about state machines and timed loops, but have not been succesfull (or well enough educated yet) in finding something that i could apply to this. 

Have you guys got any hints for me, or can give me guidance in any way? 

 

I hope my question is understandable, otherwise feel free to ask me elaborate.

 

 

0 Kudos
Message 1 of 8
(1,948 Views)

Hi Benjamin,

 


@Benjamin11 wrote:

however, i would like to be able to make it run on its 'own' like for example:

On: 5 minutes

Off: 10 minutes
Repeat until stopped.

Have you guys got any hints for me, or can give me guidance in any way? 


The "simplest" solution would be to use two "wait time" controls per loop with a Select node. When the DO is TRUE you select the "ON wait time" and when DO is FALSE then you select the other wait time. To switch between on/off with ach iteration you use a shift register with a NOT function…

 


@Benjamin11 wrote:

First of all, let me state that i am -extremely- new at Labview.

I've tried to youtube and search around in here, to which i found something about state machines and timed loops, but have not been succesfull (or well enough educated yet) in finding something that i could apply to this. 

Have you guys got any hints for me, or can give me guidance in any way? 


When you very new to LabVIEW you should consider all those "Training resources" offered in the header of this LabVIEW board!

Additionally LabVIEW comes with a huge example VI library and lots of example projects, including statemachine examples. You really should learn about them as that "simplest solution" above really is NOT a good solution for your "dynamics lab"!

 

(What kind of "dynamics" do you analyze with wait times in the minute range? :D)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(1,939 Views)

@GerdW wrote:

Hi Benjamin,

 

The "simplest" solution would be to use two "wait time" controls per loop with a Select node. When the DO is TRUE you select the "ON wait time" and when DO is FALSE then you select the other wait time. To switch between on/off with ach iteration you use a shift register with a NOT function…

 

Yeah i realize my lack of education in this, when i'm confused already. I will try to decipher what you've written.



When you very new to LabVIEW you should consider all those "Training resources" offered in the header of this LabVIEW board!

Additionally LabVIEW comes with a huge example VI library and lots of example projects, including statemachine examples. You really should learn about them as that "simplest solution" above really is NOT a good solution for your "dynamics lab"!

 

(What kind of "dynamics" do you analyze with wait times in the minute range? :D)


I've gone through Core 1, and sniffed a bit around in Core 2.

- it was just the examples my proff used. but i guess the times are not of the matter as i reckon they can be changed easily when it is set up 🙂

0 Kudos
Message 3 of 8
(1,924 Views)

@Benjamin11 wrote:


- it was just the examples my proff used. but i guess the times are not of the matter as i reckon they can be changed easily when it is set up 🙂


Although it's probably true that you can easily change the times, you might choose a different design depending on the values.

In the example above, if you have a wait time in one chunk of ~minutes, your program will feel quite unresponsive in general (because, for example, you'll click stop and then have to wait probably 1-2x the period, where the multiplier depends on how much has already passed - you wait the remaining part of the current iteration and then all of the next).

 

If the wait times are ~1-5s, maybe that's fine and you don't make it more complicated just to avoid unresponsiveness, instead you wait the max 10 seconds.

 

If the periods are longer, you might instead prefer to break them into repeated smaller chunks where you don't do anything except check if you should exit, for example, if not, keep counting down. There's I believe an Express VI that can do this for you, but you could implement it yourself using a Shift Register and probably a Select node (from the Comparisons palette, I believe), along with some subtracts and the Tick Count (ms) node or Get Date/Time in Seconds (either could work, I think they're both in the Timing palette).


GCentral
0 Kudos
Message 4 of 8
(1,867 Views)

@Benjamin11 wrote:

...I'm using a USB-6001 device, to witch is connected two valves that i have succeded in being able to get to switch on and off, using the following code.

 

...however, i would like to be able to make it run on its 'own' like for example:

On: 5 minutes

Off: 10 minutes
Repeat until stopped.


Of, so you have two valves and just one set of timing. Should both valves go on and off at the same time or at different times? Why are they in separate loops?

 

Can you describe a full state diagram with all timings and possible states (both on, both off, only one on, only the other one on, etc.)

 

Easiest would be a state machine with one toplevel loop running at a reasonable loop rate checking elapsed time (and polling the stop button) and switching state when needed. To start, study e.g. this example, then expand to your requirements)

0 Kudos
Message 5 of 8
(1,858 Views)

 


@cbutcher wrote:

@Benjamin11 wrote:


- it was just the examples my proff used. but i guess the times are not of the matter as i reckon they can be changed easily when it is set up 🙂


Although it's probably true that you can easily change the times, you might choose a different design depending on the values.

In the example above, if you have a wait time in one chunk of ~minutes, your program will feel quite unresponsive in general (because, for example, you'll click stop and then have to wait probably 1-2x the period, where the multiplier depends on how much has already passed - you wait the remaining part of the current iteration and then all of the next).

 

If the wait times are ~1-5s, maybe that's fine and you don't make it more complicated just to avoid unresponsiveness, instead you wait the max 10 seconds.

 

If the periods are longer, you might instead prefer to break them into repeated smaller chunks where you don't do anything except check if you should exit, for example, if not, keep counting down. There's I believe an Express VI that can do this for you, but you could implement it yourself using a Shift Register and probably a Select node (from the Comparisons palette, I believe), along with some subtracts and the Tick Count (ms) node or Get Date/Time in Seconds (either could work, I think they're both in the Timing palette).


Hi!

So as you stated, my program can feel a bit unresposive with the solution i have come up with.

i did the folllowing:

Benjamin11_0-1623661628616.png

Is there a way to implement a manual on/off switch, as when i press stop, it sometimes leaves it on "true"?




regards

0 Kudos
Message 6 of 8
(1,787 Views)

@Benjamin11 wrote:

Is there a way to implement a manual on/off switch, as when i press stop, it sometimes leaves it on "true"?




regards


Just insert another Write after the While-Loop - before you close the task.

 

Regards, Jens

Kudos are welcome...
Message 7 of 8
(1,784 Views)

That did it, thank you!

0 Kudos
Message 8 of 8
(1,778 Views)