From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview basics question - Cahnging boolean state based on input signal

Solved!
Go to solution

Hello all

 

I would like to have the state of a boolean indicator change based on a simulated sinusoidal signal. I have partially succeeded in doing this but need help to further develop this.

 

See the attached vi. At present the boolean changes from false to true when the signal value is greater than 8 or less than -8.

 

The further development I require is:

Once the signal goes over 8 (and the boolean becomes true), I would like it to become false again at a value of 9, but only after the peak value has been passed i.e. when the signal is decreasing.

 

Likewise on the negative side of the graph, I'd like the boolean to become true at -8, remain true until after the peak value has been passed and then change back to false when the value becomes greater than -9.

 

Any suggeastions?

Thanks

 

 

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

Maybe try using a shift register to compare the current value with the previous value, allowing you to know if the signal is on its way up or on its way back down.

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

First of all, your simulated signal is only putting out a single scaler.  Change your From Dynamic Data setting to only put out a single scaler.

Secondly, your case structures can be easily reduced down to a few boolean functions.  The boolean functions would make it a lot easier to read.

 

I recommend building up a Truth Table.  From there you should be able to easier find the boolean logic needed.

 

Use a Feedback Node to hold the previous value of the signal.  If the new is greather than the old, then the signal is rising.  Else it is falling.


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 3 of 9
(2,909 Views)
Solution
Accepted by topic author tone5

Whilst Crossrulz was replying I was having a bit of a look.

Dont let me spoil your fun with the attached VI. Have a go yourself.

Message 4 of 9
(2,902 Views)

@Phil_ wrote:

Whilst Crossrulz was replying I was having a bit of a look.

Dont let me spoil your fun with the attached VI. Have a go yourself.


Yeah, I was having a little fun myself.  Made it a lot simpler.  But I'm not going to give away all of the logic.  The deleted section is just 5 logic gates.  I'll let you figure out what goes where.


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
Message 5 of 9
(2,891 Views)

Is there a reason you have gone for a feedback node instead of shift register?

Style or technical?

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

Many thanks for your suggestion. A great help and a valuable learning exercise.

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

crossrulz - thanks for your suggestion. It looks like it'll provide a neat solution. Unfortunately I've not yet been able to find the remaining 5 logic gates and how to wire them. I could probably work it out, but being a mechanical engineer and thus not having a programming background its taking me a long time. Also, I have a test rig which need to be up and running asap. It looks like the solution from Phil_ will work. Thanks anyway

0 Kudos
Message 8 of 9
(2,829 Views)

@Phil_ wrote:

Is there a reason you have gone for a feedback node instead of shift register?

Style or technical?


Purely style in this case.  The feedback node removed some crossing wires.

 


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 9 of 9
(2,797 Views)