LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

crossing value detection

Hello,

 

I need to detect when some variable cross set value.

Same like zero crossing function PtByPt, but instead of zero, should be defined value.

I created some VI (in attachment), but it detect every crossing, and I need to detect only first time...

It should be detected in both directions (rising and falling).

 

This is related to climate chamber, and temperature oscillation.  

IMG_20191224_135309.jpg

 

Thanks.

 

0 Kudos
Message 1 of 3
(3,543 Views)

So you want your loop to stop when a change is detected?  A simple OR on your Detected and Stop button to stop your loop can handle that.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(3,516 Views)

I don't know if you know about sub-VIs, which allow you to write LabVIEW Functions for yourself that can implement such things as you are proposing.  I'm suggesting you write a sub-VI called "First Crossing" (or something like that, to remind you what it does) that has the following properties:

  • It has two inputs, Signal and Threshold, and one output, "First Crossing", a Boolean.
  • On only the first call, it reads Signal and Threshold, and outputs First Crossing.  On all other calls, it ignores Threshold.
    • Question -- what is the output on the first call?  [You should be able to work out what it must be].
    • Question -- why is Threshold ignored except on the first call?
    • Question -- in a sub-VI, do you know how to "remember" Threshold?  Do you know how to detect "Fiirst Call"?
  • When Signal "crosses" Threshold (going up) the first time, "First Crossing" is set to True, otherwise it is set to False.
    • Before you get the First Crossing, what determines the value of First Crossing?
    • After you get the First Crossing, what determines the value of First Crossing?

Here is the Front Panel of such a sub-VI (I haven't yet written the Block Diagram).  Like almost all of the sub-VIs that I write, it uses the 4-2-2-4 Connector Pane (the default connector that LabVIEW now uses for new sub-VIs), which helps when wiring sub-VIs together (the wires line up nicely).  I've wired Error In and Error Out to the lower corners, good practice as it facilitates Error handling and also helps enforce sequential execution of your code when this is desirable.  Finally, I've created a simple Icon for this sub-VI, so when I use it, it will show up as a little Green Box with the words "First Crosing" on the front to remind me what it does (I took some liberties with the spelling in the interest of legibility).

First Crossing FP.png

 

I presume you have a loop somewhere that looks at the data points of your Signal.  Feed each data point into this VI (along with Threshold, at least the first time you call it) and (when you finish the code on the Block Diagram) use the First Crossing? output to execute whatever you want to do when the First Crossing occurs.

 

Note that by creating a sub-VI, I've isolated the data that you need (Signal always, Threshold at least the first call) and "hidden" it away from the code for acquiring your data and "doing something" with it.  Keeping the Block Diagram "simple" is an important step in writing LabVIEW Code that "does what you want" -- it almost always "does what you tell it to do", of course ...

 

Bob Schor

 

0 Kudos
Message 3 of 3
(3,281 Views)