-
Notifications
You must be signed in to change notification settings - Fork 5
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
Support >256 PWM levels #2
Comments
arduino is a 8bit mcu, if we try to use more than 8bit to store pwm levels, we have to do uint16_t arithmetic, that's like 2 times slower. the "timer frequency" is calculated as and say, we now want 512 levels, even if we still do 256 levels but store the levels in a uint16_t, the isr load is bumped by a factor of 2. |
Thanks for the information! I was thinking of using preprocessor directive to switch the support for >256 PWM levels so the performance hit would only be incurred if the feature is needed. I do think 256 levels is sufficient for most applications. I've made some attempts at this but haven't been successful yet. It sounds like you're saying it is actually possible to accomplish this(at a cost) so that's good to know. I've managed to get around the issue by never fully turning the LEDs off but it was previously enough of a problem that I thought it worth considering adding this functionality. |
i was thinking about something like
and use |
maybe something like this... for 256 levels we have to use uint16_t... because we do |
@Palatis I really appreciate you giving me this information! Now that I know this is possible and you have pointed me in the right direction I'm sure I can achieve my goal. This is a bit above my current programming skills so it will take me a little while to get there but it will also provide an opportunity to learn new things in the process. |
this paradigm is called c++ template meta-programming. this whole softpwm library wouldn't be possible without it. |
When using this library with LEDs there is a large difference between PWM levels at low brightness so the option of more PWM levels than 256 would be useful.
The text was updated successfully, but these errors were encountered: