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!
Best method for pulse timing and filtering?
-
MicroController
- Posts: 2670
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Best method for pulse timing and filtering?
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?
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.
Who is online
Users browsing this forum: Bytespider, ChatGPT-User, meta-externalagent, PerplexityBot, PetalBot and 4 guests
