12-07-2020 03:12 PM
I have a sensor constantly reading values during a loop, and I need to have a boolean toggle to 1 when a maximum value is reached, and then to 0 when a minimum value is reached. I will be reading a sinusoidal pressure measurement and it is important to know if I am on the ascent or descent. For instance, let's say min: (less than or eq) 2, max: (greater than or eq) 5. The issue I am having is that I am a novice and only able to set a boolean to be 1 if it is = or > than a value. This is an issue because a value of 3.5 could have a boolean of 0 or 1 depending if it is in the ascent or descent. I'd also strongly prefer not to read the slope real time to determine this, as I don't think it would be accurate and reliable.
I'm sure this is very simple to an expert, does anyone have a vi that can do this?
12-07-2020 03:40 PM
@jd555 wrote:
I'm sure this is very simple to an expert, does anyone have a vi that can do this?
Yes, it is very simple, but we can help better if you show us your failed attempts (attach your broken VI!), so we get more context. Nobody wants to start from scratch with too many vague points. 😉
12-07-2020 04:09 PM
@altenbach wrote:
... too many vague points.
Some vague points:
12-07-2020 05:04 PM
Here is a rough waveform that I have obtained as well as my VI (although it is quite messy)
12-07-2020 05:43 PM
Of course cause and effect is not quite clear. I assume the slope changes sign because the new measurement is out of range (above or below). Basically we are dealing with a simple on/off control with a deadband. I think there are quite a few examples here. Just do a search.
Maybe the attached will give you some ideas..... (Many things can probably be simplified)
12-08-2020 12:03 PM
It's certainly not out of range, my sensor is accurate from 0-5 PSI, and I can precisely control my solenoid valves to maintain this. I have also validated it with other sensors. My only issue is that I can't write a code that doesn't rely on using 2 loops.
12-09-2020 10:43 AM - edited 12-09-2020 11:00 AM
@jd555 wrote:
My only issue is that I can't write a code that doesn't rely on using 2 loops.
Why not and why do you think you need two loops?
@jd555 wrote:
It's certainly not out of range, my sensor is accurate from 0-5 PSI, and I can precisely control my solenoid valves to maintain this.
I meant outside of the desired control limits, forcing a change in boolean.