Shop OBEX P1 Docs P2 Docs Learn Events
NEGEDGE detector w/ feedback? — Parallax Forums

NEGEDGE detector w/ feedback?

This is a documented feature of the propeller (table 2-7 in the manual) without any documentation. Does anyone know how to make this work? It looks like the perfect solution for switch closure detection which I have previously had to code around. Ideas??

Comments

  • JonnyMacJonnyMac Posts: 9,102
    edited 2020-08-29 17:11
    That feature counts the 1->0 transitions into the phsx accumulator. The feedback version is useful for slow and noisy signals that might flutter around the pin threshold voltage, causing an erroneous count.

    If you wanted to use this to detect a switch state change, you'd need to clear the associated phsx register before checking. I don't know if this is any less code than standard debouncing, and, in fact, does not debounce the switch input.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2020-08-30 00:19
    The NEGEDGE and POSEDGE modes without feedback are good for counting switch closures that are already debounced.

    The feedback is negative, not positive. Adding the feedback, via a resistor and to a capacitor on the input pin, causes the input to hover at the input switching threshold. If you then apply a small mV level AC signal to the input (via a capacitor) the Prop can count the frequency. However, there are caveats. At zero signal it defaults not to zero frequency, but to a very high noisy frequency, so the signal has to be “big enough” to override the noise. And there is a low frequency limit, as the feedback tries to track the input. Kind of specialized, not helpful I think for switch inputs.

    Maybe if you run the feedback through another inverter, giving positive feedback, it could give snap action hysteresis to help with slower noisy transitions.
Sign In or Register to comment.