Skip to content

Add frequencyio.FrequencyIn #1614

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

Merged
merged 16 commits into from
Mar 4, 2019
Merged

Conversation

sommersoft
Copy link

Its time again to try and get this in. Updates since #1144:

  • Instead of putting this in pulseio, this creates a new frequencyio to better manage inclusion/exclusion. Most of the smaller builds (M0 basic, CPX, etc) were exceeding flash size.

  • Now uses a single "reference TC" for interrupts/results calculation, and "capture TCs" for frequency sensing. This keeps the interrupts from flooding the MCU, but does eliminate 1 timer available for capture. I've had up to 2MHz input detected with no detrimental effects to the VM, USB, or REPL.

  • Since the "capture TCs" now use a simple count-of-events based on a time period, I added a capture_period property. Notes about this are in the documentation. There is some math-assumption built in to the frequency calculation, since the reference TC will not catch the time periods exactly.

  • I'm getting a variance of 10% maximum on readings. Using a sample average has proven the best way to smooth this out. Here are some example Mu screenshots with a 2KHz signal:

mu_plot_code_before_start

mu_plot_end

To anyone testing/reviewing: please, don't be gentle with it! Break it. Criticize (constructively)! All of that is appreciated on my end. 😄

NOTE: I have left the previous SAMD21 code in, even though it isn't included by default. I still need to go back through and test it with a custom build, but I would like to leave it as an available option.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! In the long run maybe the DPLL1 stuff might be factored out into samd-peripherals, in case other code wants to do similar stuff, but it's fine for now. This has been a long road, but it's also been tested a lot as a result.

@dhalbert dhalbert merged commit e633965 into adafruit:master Mar 4, 2019
@sommersoft
Copy link
Author

In the long run maybe the DPLL1 stuff might be factored out into samd-peripherals, in case other code wants to do similar stuff

Yeah, that is totally doable I think. I can work that soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants