LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple (digital) edge detector?

Solved!
Go to solution

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 ?

0 Kudos
Message 1 of 4
(794 Views)
Solution
Accepted by topic author TakeANap

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 ?


  • What about PtByPt-BooleanCrossing?
  • What about a feedback node with a CompoundArithmetic, set to X AND NOT(Y), to detect rising edges? (Apply other boolean algebra to detect falling edges or any edges.)
  • What's the reason to omit shift registers/feedback nodes? Please remember: THINK DATAFLOW! In LabVIEW wires and shift register keep data, but not some indicators!

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(788 Views)

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.)

TakeANap_0-1687959494029.png

 

0 Kudos
Message 3 of 4
(766 Views)
Solution
Accepted by topic author TakeANap

Hi Nap,

 


@TakeANap wrote:

TakeANap_0-1687959494029.png


  • Using CompoundArithmetic (with their Invert option for inputs/outputs) eliminates those NOT functions.
  • Changing direction of the feedback node (right-click option) helps to maintain left-to-right wiring.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(758 Views)