Tips for to "de-pwm" a signal? #371
Replies: 3 comments 7 replies
-
Take the signal to an event input, and set an unused TCB (TCB2 is used for millis by default). TCBn.CTRLB = TCB_CNTMODE_TIMEOUT_gc; //timeout check mode |
Beta Was this translation helpful? Give feedback.
-
Thanks for this - this looks useful. I get a logic high after the signal stops, so if I feed that into an LUT configured as an S-R latch (as per "tips and tricks", I'm thinking that should give me a clean view of start with a one PWM cycle lag on stop. Gotta wrap my head around the routing of the events and the truth table, but is this halfway plausible? Next step will be to bust out my dev board and 'scope :-) |
Beta Was this translation helpful? Give feedback.
-
A missing pulse detector can be pretty easy to implement in hardware. Use a pnp transistor on your active low pulse to shunt out a little capacitor that otherwise floats up to Vdd on a pullup. But if you want to avoid external hardware, let's see.. Can you count on the signal being less than 100% duty cycle? In that case, I might be inclined to trigger an interrupt on every negative edge (it's active low, right?) which, at a minimum, records the time, for instance "LastNegativeEdgeTime". While recording the time of the negative edge you can also immediately assume that the duty cycle is not 0%, maybe check a flag to see if you're already doing whatever is required there, and if not, do it. For the less time-critical (stand down?) event, you could simply look, at any convenient time, perhaps even just in the main service loop (and after consulting a flag to see if it even was running previously) at how long it's been since the last negative edge and decide when you think it's been long enough to declare things "off" and take whatever action that entails. I've filled in some blanks with my imagination here so please set me straight where required. |
Beta Was this translation helpful? Give feedback.
-
Wasn't quite sure how to phrase this question so my webs searching hasn't been very fruitful.
I'm looking for an efficient way to ignore any PWM component of a signal and determine if it's "on" or "off" (ie: if duty cycle >0, it's on). PWM frequency could potentially vary from 1kHz to 8kHz - it's coming from an external source that will be unknown at design time.
I have an inkling that the CCL could likely help here, maybe combined with a one-shot set to a fraction longer than the frequency?
My work-in-progress project is using a DA32 and one B timer alongside LUT0 and TRUTH0 to handle the rest of the flow.
Wondering if there's a standard approach for doing this. If there's some terminology I'm missing, I'm happy to keep searching.
FWIW, I need relatively small latency (1 uS or better) for the off->on transition, the off->on transition is less important.
Beta Was this translation helpful? Give feedback.
All reactions