-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
applet.interface.freq_counter: implement a frequency and duty-cycle counter #216
base: main
Are you sure you want to change the base?
Conversation
5fc5921
to
6f5c590
Compare
Just an idea: add a feature to also report maximum deviation to give the user an idea how stable the signal was. If there was for example a glitch in the signal, or a flaky connection, the results would be off without the user noticing. How I think this could be implemented:
In the python part of the applet you calculate the difference of the first cycle to the average and shift max-longer/max-shorter by this amount. then report the bigger of the two as max deviation. This is just an enhancement idea, no feature requirement. If you don't want to complicate the code any further, I'm totally ok with merging it without this addition. |
I like this idea, and the implementation you outlined might typically give a good indication if it's not a stable signal... however if the average matches up with the first cycle, then that indication is somewhat lost. Additionally, the major reason I opted for averaging over n-cycles, is that for higher frequencies, we'll start to get a bit of aliasing due to the I'm looking at collecting the lo/hi cycles for each of min_lo / max_lo / min_hi / max_hi, in addition to the total counts that I'm already collecting... this would let us give better indication of outliers or glitches, but it increases the complexity quite a bit... Let me have a play? |
I've reworked this somewhat, and have produced the following output from a 2MHz input signal, with 300kHz FM @ 1kHz.
... and the following from a "glitch clock training signal". (Note the outliers: ~1% duty cycle, and ~21ns time hi).
This is becoming a data presentation problem... I'd like to include +/- percentages, but it's already fairly messy. There is additionally, the unfortunate situation where the "minimum X over a single cycle" is reported as more than the average. This is the aliasing I was referring to earlier. (this is the same "glitch clock training signal", but with no glitch over the n-cycles).
Actually, no: this is because I'm not storing the min/max period... and I'm thus calculating the "min frequency" from the available data, rather than using grounded / actual data... |
6a04e9e
to
fee7fd6
Compare
Acually, yes... this is aliasing... what a ride. I implemented min/max for the whole cycle too, and it didn't improve the results:
I think at this point, it's better to "lie" about the figures, by not excluding the |
…eriods during the run
…ering the 'total' stats in the min/max summary
This implements a basic frequency and duty-cycle counter...
It counts
n
(according to--count
) rising or falling edges (according to--edge
), and produces basic analysis of the signal, as below.This will only produce sensible results for a periodic / stable signal.