View previous topic :: View next topic |
Author |
Message |
in_nursery
Joined: 25 Oct 2012 Posts: 51
|
CCP capture |
Posted: Tue Jul 14, 2015 10:16 am |
|
|
Hi all
I use the capture mode for reading a signal frequency.
I use capture on rising edge.
But my signal is not very clean, I have rebound at the falling edge.
This is how my signal looks like.
___|¨¨¨¨¨¨¨¨¨¨¨¨¨¨|_|¨|_|¨|_|¨|________________________|¨¨¨¨
Is there a software way to ignore this rebound ?
Thanks in advance |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Jul 14, 2015 1:24 pm |
|
|
It can be done to some extent. For instance, you could add code to reject any period shorter than a particular count. However it is going to use quite a bit of processor time, and restrict the range of frequencies that can be supported. A hardware solution is likely to be much better.
In the ISR, calculate the 'delta' from the last edge, and if it is less than a figure corresponding to your maximum frequency, exit immediately, and don't update the 'old', and don't flag the new value as ready. |
|
|
in_nursery
Joined: 25 Oct 2012 Posts: 51
|
|
Posted: Tue Jul 14, 2015 1:31 pm |
|
|
Ttelmah
Quote: | In the ISR, calculate the 'delta' from the last edge, and if it is less than a figure corresponding to your maximum frequency, exit immediately, and don't update the 'old', and don't flag the new value as ready. |
It's what I done but as you say I will try to solve it by hardware |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue Jul 14, 2015 1:43 pm |
|
|
The proper way to do it in hardware is to start by looking at the actual signal processing (hysteresis), and possibly add a PLL.
Problem with the software is 'which edge to actually use'... |
|
|
|