PWM functions #2924
Replies: 2 comments 1 reply
-
Moved to a discussion since it seems more of a question than a bug. If something does fall out we can open specific issues. You should set the Use either
Note that not all combinations of range and frequency are actually achievable in the HW. For example, at high PWM frequencies you can't actually have very large ranges because the clocking just doesn't work, and vice versa for very low frequencies. Your code can still pass in data with the requested range, but it will be adjusted to what the real HW can perform behind the scenes. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the clarification. Documentation would be helpful but this would involve coordinating with Arduino.cc |
Beta Was this translation helpful? Give feedback.
-
I am using PWM to control a solenoid that can not have full voltage for more than 2ms.
I'm finding limited documentation for analogWriteRange() and analogWriteResolution()
Is there a suggested order for these as they seem do to interact
For example if I have the following driving a Darlington Solenoid driver (UL2803) with 12V output (Common)
Because 12 bits is range 0-4095 and I'm only getting fractions of a volt for FULL at 100
It seems that if I ask for 12 bit resolution then Range of 0-100 means all I get is 0 to 100/4096
I thought Range was setting a scale and documentation isn't clear what that means.
If I change FULL to 4095 (or should I use 4096?) I get the expected range (thus why I used FULL/7 instead of 14%)
Should FULL be 4095? Then would I set Range to FULL+1? (or it doesn't matter?)
I read the code in wiring_analog.cpp but it's not straightforward, with lots of scaling games to make things fit, but not as I expected.
Finally, although analogWrite() takes care of everything for the analog output (PWM mode setting...)
do I need to set pinMode(MyPin, OUTPUT); for the digitalWrite() to work? and will that be saved? (looks like it)
Thanks as always for your great support.
Beta Was this translation helpful? Give feedback.
All reactions