Skip to content
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

"Variable" PWM #9

Open
3 tasks
stylesuxx opened this issue Sep 1, 2022 · 6 comments · Fixed by #145, #151 or #154
Open
3 tasks

"Variable" PWM #9

stylesuxx opened this issue Sep 1, 2022 · 6 comments · Fixed by #145, #151 or #154
Assignees
Labels
Milestone

Comments

@stylesuxx
Copy link
Contributor

stylesuxx commented Sep 1, 2022

Allows the PWM frequency to be adjusted as a setting and does not require the firmware to be re-flashed.

This is actually also part of the branch mentioned in #8

Questions:

  • Looking at the Makefile I am wondering if this will only work on H MCUs
  • Why are the testfiles only built against a subset of the H MCUs (L MCUs have a TODO...)
  • Why are there no "0" deadtime options anymore

See PR #19

@stylesuxx stylesuxx added this to the v0.18 milestone Sep 1, 2022
@Quick-Flash
Copy link

As you know the codebase better, is it possible to set a pwm value that is not a 24, 48, or 96khz value?

@stylesuxx
Copy link
Contributor Author

Well, 12kHz you could set - everything else, not without major changes.

PCA0PWM is the register you have to set, CLSEL (Cycle Length Select) has three bits but only 4 possible values corresponding to: 8, 9, 10, or 11 bit.

Which other values would you be interested in and why?

@Quick-Flash
Copy link

Well, 12kHz you could set - everything else, not without major changes.

PCA0PWM is the register you have to set, CLSEL (Cycle Length Select) has three bits but only 4 possible values corresponding to: 8, 9, 10, or 11 bit.

Which other values would you be interested in and why?

Well, non integer values would be the first step in proper variable pwm. Personally 12khz could be interesting, I had one toothpick that was unflyable on anything but 24khz, and running that low would be quite interesting to see for some aircraft.

So from what you've said it sounds like some sort of counter is set that determines how long before the next time it fires. Sounds like it could be possible to make it non 12, 24, 48, 96 khz. Maybe one of these days I need to give assembly another try.

@stylesuxx
Copy link
Contributor Author

EFM8 does not have a FPU. You can for sure run different duty cycles than that. You should really check out the reference manual, it has the formula on how to calculate settings for different duty cycles. But, you are opening a massive can of worms. Dithering for example is hard coded for each frequency, so making it really dynamic will be a huge quest.

@Quick-Flash
Copy link

Quick-Flash commented Sep 16, 2022

I wonder how it would act if we quickly switch pwm freq. To try and estimate another freq.

@stylesuxx
Copy link
Contributor Author

I don't think this will work at all, from what I see this will affect other functionality too and will most likely mess things up. That's why it's done in the setup phase - once. You need to set one register, then set the PWM register, then again reset the first register and reconfigure quite some stuff. I recommend you take a look at the commit in the PWM branch, this should give you a feeling for what would be needed to change PWM freq on the fly.

@stylesuxx stylesuxx removed this from the v0.18 milestone Sep 17, 2022
@stylesuxx stylesuxx linked a pull request Oct 2, 2022 that will close this issue
@stylesuxx stylesuxx linked a pull request Feb 13, 2023 that will close this issue
@stylesuxx stylesuxx added this to the v0.20.0 milestone Feb 21, 2023
@stylesuxx stylesuxx modified the milestones: v0.20.0, v0.21.0 May 21, 2023
@damosvil damosvil linked a pull request Jul 18, 2023 that will close this issue
@stylesuxx stylesuxx linked a pull request Jul 28, 2023 that will close this issue
@damosvil damosvil linked a pull request Aug 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment