06-09-2021 02:54 AM
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.
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.
06-09-2021 03:08 AM - edited 06-09-2021 03:09 AM
Hi Benjamin,
@Benjamin11 wrote:
however, i would like to be able to make it run on its 'own' like for example:
On: 5 minutesOff: 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)
06-09-2021 03:24 AM
@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 🙂
06-09-2021 12:20 PM
@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).
06-09-2021 02:07 PM
@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 minutesOff: 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)
06-14-2021 04:08 AM
@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:
Is there a way to implement a manual on/off switch, as when i press stop, it sometimes leaves it on "true"?
regards
06-14-2021 04:11 AM
@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
06-14-2021 04:39 AM
That did it, thank you!