I need some help porting code using PWM16.h to this library #2
-
Hi everyone I have Artisan’s roaster sketch running fine on my Arduino Uno Rev 3. I purchased an Uno WiFi Rev 2 and the sketch won’t compile because the PWM16 lib is not supported for the new chipset. I understand how PWM works and can see what the current library is doing, can someone tell me looking at this code What would I need to change to use this new mega avr lib? See the ssr variable Also please tell me if I am completely off on what I am asking. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi @glennblock #define pwmN128Hz 127 // TOP values for various frequencies
#define pwmN64Hz 255
#define pwmN60Hz 272 // approx.; exact = 272.0667
#define pwmN50Hz 327 // approx.; exact = 326.68
#define pwmN32Hz 511
#define pwmN30Hz 545 // approx.; exact = 545.1333
#define pwmN16Hz 1023
#define pwmN8Hz 2047
#define pwmN4Hz 4095
#define pwmN2Hz 8191
#define pwmN1Hz 16383
#define pwmN1sec 16383
#define pwmN2sec 32767
#define pwmN4sec 65535 As you're using very low frequency, I suggest you start with the megaAVR_Slow_PWM library, designed specifically for low-frequency applications Check Features Very simple to convert from PWM16 to megaAVR_Slow_PWM library. Check the simple example
In PWM16 library, the function
The matching functions you possibly can use are
Good Luck, |
Beta Was this translation helpful? Give feedback.
-
@khoih-prog the newer version of the PWM16 also supports fast PWM on IO3. https://github.com/Roastr/TC4-Shield/blob/main/applications/libraries/trunk/libraries/PWM16/PWM16.h which the sketch also uses. I tried including both fast and slow versions but I am getting errors due to redeclarations of variables. Does megaAVR_PWM support both fast and slow?
|
Beta Was this translation helpful? Give feedback.
Hi @glennblock
https://github.com/nicolaskruchten/arduino/blob/fc8b5804fc2da155384c528dfd2be0d629bba816/libraries/PWM16/PWM16.h#L96-L109
As you're using very low frequency, I suggest you start with the megaAVR_Slow_PWM library, designed specificall…