LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting timer under two different conditions

Solved!
Go to solution

I have a system that detects if a fish is in Tank C or Tank D. When the fish is in either tank a pump within that tank will turn OFF for a set time (30 sec) and a pump will turn ON for a different set time (5 sec). However, if the fish moves from one tank to the other tank I want one of two things to happen: 1: if the pump is OFF while the fish moves to the other tank I want the OFF timer to reset from 0 and run to 30 sec again or 2: if the pump is ON I want it to finish the 5 sec pump time and then have the pump OFF for 30 sec

 

Example of scenario 1: fish is in tank C and the pump is OFF and has been for 13 sec when the fish swims to tank D. The timer would then reset and the pump would be OFF for 30 sec and the ON for 5 sec etc. until the fish moves to the other tank again.

Example of scenario 2: the fish is in tank C and the pump just turn on and has been on for only 2 sec when the fish swims into tank D. The pump should then stay on for the full 5 sec and then the pump OFF time starts at 0 again.

 

I have attached a VI of the relevant code below. 

I am struggling to find a way to make it function in this specific way and I appreciate any help.

0 Kudos
Message 1 of 9
(2,134 Views)

Before struggling using LabVIEW to solve this homework problem, take paper and pencil and make some drawings trying to show "pictorially" what is going on.  You can use a picture of a Clock to show when the timer starts, show the fish moving around, etc.

 

Especially when starting to learn Programming, the tendency is to worry about "how" to solve the problem, rather than "what" am I trying to do.  Don't fret the details, instead concentration on "what", and maybe on "when".  LabVIEW is unusual in its integration of "Time" as part of the Language (comes from its use by Engineers to solve what Engineers do best, "Make Things Run Properly".

 

Bob Schor

0 Kudos
Message 2 of 9
(2,126 Views)

This is not a homework problem, it's part of a program I am building for an experimental setup. Regardless, I appreciate the device. I have already been sitting with it for a while and visualized it in different ways and I know "what" it is I want to do, but I really need to figure out the "how". If you could provide any sort of help pointing me towards how this could be done or just what kinda function I could be using I would much appreciate it. I am playing around with a state machine atm but can't seem to make it work that way.

 

Thank you.

0 Kudos
Message 3 of 9
(2,116 Views)

To be specific, how exactly do I get it the OFF timer to reset when the fish travels from one tank to the other while the pump is OFF instead of just continuing. Its the only part of my program I cant make work.

0 Kudos
Message 4 of 9
(2,107 Views)

@Math808 wrote:

This is not a homework problem, it's part of a program I am building for an experimental setup.


If you show a program basically stolen from elsewhere, please provide a link and proper references to give us all some context. We don't want to start over from scratch every time the same problem pops up!.

 

Combining several conditions into one result is the basis of boolean logic. Do you fully understand the current program (since you haven't really authored it!)? All you need is a simple extension along the same lines. Try it!

0 Kudos
Message 5 of 9
(2,052 Views)

(Y'all know this is the same poster from the other thread, right? A link might be helpful but it's not a different student with the same problem.)

 

OP, if I understand right, you can boil your logic to:

 

-If a fish switches tanks and the pump is OFF, reset the timer.

-If a fish switches tanks and the pump is ON, finish the 5 seconds- in other words, keep the timing the same, no resets.

 

If so, then you really just need to reset the timer when the fish switches tanks AND the pump is off. That's some pretty simple logic.

 

Basically, reset = switch AND NOT pump on

 

I'd advise to first get a timer going that does the cycle you need it to with no resets, logic, etc.

Next, add in the ability to reset it by pressing a button.

Next, replace the button with boolean logic indicating switch AND NOT pump on.

0 Kudos
Message 6 of 9
(2,043 Views)

@BertMcMahan wrote:

(Y'all know this is the same poster from the other thread, right? A link might be helpful but it's not a different student with the same problem.).


And a very (very!) old problem (April 2020, July 2021Nov 2021 , and probably more...) I hope the original fish are still alive 😄

0 Kudos
Message 7 of 9
(2,038 Views)

I probably deserve being grilled here. You are very much correct, it is the code that I have received help with before, and for that, I am very appreciative. The experiment has been running great because of your code and I apologize for not providing a link to the code you provided me with. I just have to add this simple function to the existing code, i.e. of resetting the timer, I apologize if it offended you all by asking for help.

 

I know exactly what my program needs to do and it is simply making the timer reset if the fish moves during an OFF period, I just cant figure it out. If any one of you would like to provide me with any sort of guidance I would truly appreciate it.

0 Kudos
Message 8 of 9
(2,018 Views)
Solution
Accepted by topic author Math808

Give this a go:

Reset timer help 2.png

 

Again, for solving this kind of problem, try to break it down into manageable chunks. Once you have your boolean logic figured out, now try to find those signals, such as "Did the fish move?" (an output) and "Reset timer" (an input).

 

I also changed the mechanical action of your buttons to Latch when Released, which means they automatically reset when you click them instead of having to click them twice. Just a little easier to test.

Message 9 of 9
(1,986 Views)