11-18-2024 10:52 AM
Hello! I am a student learning Labview and I want to control a single Boolean with a case structure. I want to be able to send an EMG signal to turn the boolean on, and keep it on, and then send the same EMG signal to turn the boolean back off.
Currently, and what I show in my attachment, I have the case where two peaks turns the boolean on and three peaks or more detected turns the boolean off, and anything one and below keeps the same state. I want to change the logic so the one peak turns the boolean on and then once on, one peak will turn the boolean off but I'm struggling to come up with the right logic.
11-18-2024 11:15 AM - edited 11-18-2024 11:18 AM
Hi lib,
@lib_ wrote:
I want to change the logic so the one peak turns the boolean on and then once on, one peak will turn the boolean off but I'm struggling to come up with the right logic.
Hint: you want to negate the state of the Boolean each time you call the "1" case!?
11-18-2024 11:38 AM
A collage of truncated pictures is not suitable to troubleshoot this. So what you call EMG signal is just an integer count, right? We can't even tell the datatype!
Can you list all possible states and transitions and the desired boolean result for each?
What is the code architecture? If there is no toplevel loop (and you are using "continuous run"), your feedback node will constantly initialize.
Please attach a working code draft. Vi, not picture! (Do a "save for previous, 2020 or below so more can see it)
11-20-2024 09:09 AM
Sorry to not give you the full context! I am only talking about the wiring path on the top of the block diagram, we are conditioning a signal from electrodes connected to the forehead, and then using the find peaks to find the max peaks every 3 seconds. we set a defined width of 1000 so that the peak has to last one second to be counted. depending on the peaks counted are the different cases in the case structure. I have the same questions still, how can i change the logic so that one long peak (1 second) turns the boolean true, then keeps it true , and then once already true the same signal (one long peak) turns the boolean to false.
11-20-2024 10:38 AM
You did not "save for previous". I currently cannot look at VIs saved in 2024, maybe later). Also please clean up your file name. Long tails of "...(1) (1).." are distracting..
11-20-2024 02:50 PM
Spend some time learning about State machine.
It looks like your project could benefit in implementing such an architecture.
If peak is detected - go to state where Boolean TRUE
If another peak is detected, go to state where Boolean False,
and then goes on and on.
11-20-2024 04:55 PM
@lib_ wrote:
I have the same questions still, how can i change the logic so that one long peak (1 second) turns the boolean true, then keeps it true , and then once already true the same signal (one long peak) turns the boolean to false.
You are mixing peak counts and peak duration but your case only selects based on count.
Let's assume you want to toggle the boolean whenever the count is exactly one, but leave it unchanged for any other counts (0, 2, 3, etc.). Here's how that could look like. Should be easy to patch it into your code.