Page 1 of 1

Best method for pulse timing and filtering?

Posted: Sun Mar 09, 2025 6:54 pm
by Lancsrick
Ok that's a vague title so let's expand on that.

INPUT1 is a light gate, 1 when intact, 0 when broken and wired to a GPIO digital input.
There are 4 separate light gates in the real case, but I'll just take one for simplicity.

I'm interested in two attributes:
1) When did the beam get broken?
2) Was the broken duration >= a value (say 50ms for this example)

At the moment I'm thinking of using an ANYEDGE interrupt (Interrupt routine will capture both the esp_timer value and also the GPIO level then exit). Within the app_main I'll then be running a loop to handle the resultant queue of datapoints, can discard any that are shown to have a duration of less than 50ms and get on with the rest of the code.

Would this be an appropriate method or is there a slicker way? It's best part of 2 decades since I last did a microprocessor project!

Some notes for clarity:
- I don't care about real time, just time since the timer was started (accuracy to 1ms)
- no interest in frequency, this is an "event" usage case
- Max time interval before full program reset will be about 30 sec
- Expected valid number of transitions will be less than 20. How many do I think will actually get triggered? Well that remains to be seen, but I'll guess than it will definitely be less than 200.

Many thanks for any and all advice!

Re: Best method for pulse timing and filtering?

Posted: Sun Mar 09, 2025 8:06 pm
by MicroController
With the given timing requirements all being 1ms or longer, the ANYEDGE GPIO interrupt + timestamp is a very reasonable, possibly the best approach.

Re: Best method for pulse timing and filtering?

Posted: Mon Mar 10, 2025 1:59 am
by Sprite
You could also use the RMT if interrupt latency is making your measurement not accurate enough, but with an 1ms precision requirement, an interrupt would work just as well I think.