12-24-2019 07:04 AM
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.
Thanks.
12-24-2019 07:39 AM
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.
12-25-2019 04:57 PM
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:
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).
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