06-28-2023 07:39 AM
Can someone show an LV code that detects when a digital signal change (=flank) ?
The following code lives in a while loop.
The code is a 1) "Switch until released" linked to a 2) black box and a subsequent 3) case statement with a beeper.
The Black box output gives one (1) pulse at a flank change of the switch. It would be best if the output outputs 0 for no change, 1 for a positive edge and 2 for a negative edge.
It is allowed to have a local memory in the form of an LED or something. I don't want any shift register in the loop. Error wire is ok.
How should the black box be constructed so the beeper only beeps on time for each switch-change ?
Solved! Go to Solution.
06-28-2023 08:00 AM - edited 06-28-2023 08:03 AM
Hi Nap,
@TakeANap wrote:
It is allowed to have a local memory in the form of an LED or something. I don't want any shift register in the loop. Error wire is ok.
How should the black box be constructed so the beeper only beeps on time for each switch-change ?
Suggestion:
@TakeANap wrote:
The Black box output gives one (1) pulse at a flank change of the switch. It would be best if the output outputs 0 for no change, 1 for a positive edge and 2 for a negative edge.
Then you need to create your own subVI to output those values, but I (strongly) recommend to output a typedef'd enum instead of 0/1/2…
06-28-2023 08:39 AM
Unfortunately, I do not have PtByPt toolbox in my 2020 license. However, I solved the problem with the feedback node. It turned out exactly how I wanted it.
I have never used Feedback nodes even though I have an idea of what they do. Due to time pressure (at work) I never tested this function. Now I took the time to try it.
I normally use fairly large Clusters with a lot of variables that I shift in a main loop. Sometimes I don't want to create this Cluster/shift structure just for a simple edge detector. Maybe it's bad in the long run?
Anyway, thanks for the suggestion.
(I saw your prototype after I have made the one below.)
06-28-2023 08:54 AM - edited 06-28-2023 08:54 AM
Hi Nap,
@TakeANap wrote: