06-10-2022 11:32 AM
Dear all,
I need to use the first rising edge of a gate pulse to switch on a case structure,and then ignore the values occurring after this rising edge until the next iteration of the loop in which the case structure (and the rising edge trigger detection code) are contained.
I am trying to adapt the attached code (which I use for a similar operation) but I cannot figure out why it is not doing what I am expecting it do to... (the top boolean tunnel to the right of the while loop is the one I would use to switch to true the case structure)
suggestions most welcome!
06-10-2022 12:55 PM
We prefer actual VIs over truncated code picture. We cannot see what's in the other case, we cannot see what's outside the visible area, etc. Where is the toplevel loop? Why all these coercion dots? What does your ms timer display actually tell you?
06-10-2022 04:19 PM
Not sure what your data looks like and just guessing from the image you attached.
I think something like this would be more apt. (A For Loop). You can use "Wire Probes", "Highlighted Execution", "Stepping" to start debugging and finding answers to your Whys. See which step of your logic is not working as needed.
I believe something like this may also work for you.
This is not a solution to your problem but just an idea to look at your image file from a different perspective.
06-13-2022 05:40 AM
dear altenbach, the other case is empty, the case selector was wired to a true constant for testing purposes and never got rid of it...
The conditioning bits are used to tell if the rising edge occurs within the 1st or 2nd ms after the whole thing is turned on.
06-15-2022 07:46 AM
The first solution provided by xonmyth743 does what I need. the issue I am facing now is that I need this code to reset, but once the first rising edge has been found, the next iterations will keep the output state locked to "true"! I guess I need to bring the boolean back to false at the end of the last iteration of the conditional for loop, tired a few things but none worked...
06-15-2022 08:35 AM
Can you post the most recent code for version 2019?
06-15-2022 11:42 AM
I only have labview 2013, here is the code anyway. I think the boolean is switching now, but I am not sure the way I am doing it is the best
06-15-2022 04:15 PM
Attached VIs work as you mentioned. Value property node is not needed.
06-15-2022 04:28 PM
Here's another method. Note your method cannot handle fast switching, ie, more than one transition in stream. Have not tested extensively, please check. 2013 Version attached.
06-16-2022 11:47 AM
hi all, so my testing vi works fine but when I set it to trigger on the rising edge of the actual gate signal (which lasts >30 ms, 5.5 V amplitude and arrives at a "random" time, but hundreds of ms after the rising edge detection .vi has started to run) it behaves erratically, as in:
-sometimes it looks like it is doing what it should do;
-sometimes it detects the rising edge of a gate pulse different from the first one (I have a train of 30 gates but I want to ignore all but the first one);
-sometimes it does not detect any trigger.
It is worth mentioning that the .vi in my code is placed inside a timed sequence, whose start is delayed by 500 ms from another timed sequence (which contains the gate pulses source), both are synced to the same (software) 1khz clock which resets at each iteration. Could that be the cause of the unreliability of the code?
Something I should have mentioned earlier is that I need to find my rising edge with sub-ms precision, as in since the rising edge is found I need to set the input value of the case structure selctor to "true" as fast as possible to record data at 1 kHz, without missing the first events!