LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I set a trigger that only changes between true and false when voltage goes above threshold and not when it goes below again?

Solved!
Go to solution

I am using a laser beam to detect if a fish swims between two tanks (A and B). Every time the fish swims between either one of the tanks it breaks the laser beam. When the laser is broken it has an output of 5V and when it is not broken its output is 0V. How do I set a trigger that only changes from false to true when the voltage goes above a threshold, but stay either true when the voltage goes below again and does not change to false until the voltage goes above the threshold again? I thought it would be rather simple to do but can't find any examples online on how to do it.

I am using a NI USB-6008 with the DAQmx driver.

0 Kudos
Message 1 of 19
(2,719 Views)

Keep the previous value in a shift register (initialized with FALSE) and OR that with the comparison result. The output goes back to the shift register.

Message 2 of 19
(2,698 Views)

Thank you for your quick answer!

 

I made a quick simple program to see if I could get a Boolean switch to turn on and off every time I went above a threshold of 5 with a slide controller. I must not understand your explanation completely because I can only get the switch to stay on and not turn off again. 

Math808_0-1587620257084.png

 

0 Kudos
Message 3 of 19
(2,692 Views)
Solution
Accepted by topic author Math808

Hi Math,

 

try this:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 19
(2,682 Views)

@Math808 wrote:

How do I set a trigger that only changes from false to true when the voltage goes above a threshold, but stay either true when the voltage goes below again and does not change to false until the voltage goes above the threshold again?

Ah sorry, I did not completely understand your requirements. What is "stays "either" true". Is there an "or" somewhere?

 

My suggestion will stay true forever. Don't forget to initialize the shift register.

 

Can you lost all possible states and transitions of your system?

 

  • Start with FALSE.
  • Voltage goes from below to above: TRUE
  • Voltage remains above: TRUE
  • Voltage goes below: TRUE
  • Voltage goes from below to above once more: FALSE
  • What now??? (e.g. if it is above and FALSE and goes now below, etc....)

 

 

0 Kudos
Message 5 of 19
(2,666 Views)
Solution
Accepted by topic author Math808

Here's an alternative, pretty similar.

 

altenbach_0-1587630263077.png

 

Message 6 of 19
(2,651 Views)

Thank you for the great answers, it is much appreciated.

 

We have decided to make it even more complicated. To make sure we know the fish actually went from tank A to tank B and vice versa and is not just breaking the laser in the middle and swimming back to tank A, we are putting in two lasers horizontally between the tanks. This means if tank A is the true condition, it should only switch to tank B or the false condition if laser 1 is broken followed by laser 2 and then laser 1 is restored followed by laser 2, or in other terms, voltage input 1 increases above threshold followed by voltage input 2 going above the threshold then voltage input 1 goes below threshold followed by voltage input 2 going below the threshold. It should then again be able to switch to tank B or the false condition if the opposite happens: if laser 2 is broken followed by laser 1 and then laser 2 is restored followed by laser 1.

I was thinking of making a queued state machine, but that would only give me one direction.

 

Best regards

Mathias

0 Kudos
Message 7 of 19
(2,582 Views)
  • So what is the final result you want?
  • Just Indicate in which tank the fish is?
  • Is there only one fish?
  • Do you know the starting position of the fish?
  • Is the distance between the two lasers larger or smaller than the fish?

If you just want to indicate which tank the Fish currently is and the sensor spacing is smaller than the fish:

>>>Simple: Whatever sensor went from TRUE to FALSE last?

Message 8 of 19
(2,577 Views)

We are creating whats called a shuttle-box or a choice system. In short, the system consists of two mesocosm tanks (A and B) between which a fish can swim freely. When the fish enters tank A suspended sediment levels continue to rise and when it enters tank B sediment levels continue to reduce. By swimming back and forth, the fish can behaviorally choose the maximal sediment load it encounters as it hunts for food or shelter. That means when the fish is tank A I need to turn on a set of pumps going into the tank and when it goes over to tank B I need to turn does pumps off and a new set of pumps turn on.

 

Yes, there is only one fish and I will know the starting position of the fish. The distance between the lasers is much smaller than the fish. The tunnel between the two tanks will be perfectly sized for the fish so it will not be able to only break one of the sensors or something like that. It can only break them in one of the before mention sequences depending on which tank it is traveling to and from.

 

I think I see what you mean that makes sense, so I should set up a condition where if sensor 1 went from true to false last it is in tank A and if sensor 2 went from true to false last it is in tank B?

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

Maybe something like this?

 

(Whenever both sensors are OFF, it detects which one turned off last....)

Message 10 of 19
(2,546 Views)