Closed sailhobie closed 5 years ago
looking at it a bit more I see that in the .h file you define Timer 1 PWM pins for the mega as 11, 12 and for uno et al as 9, 10. If I am reading it correctly, if a person were using the Mega 2560 and used default pins listed (ie. 9, 10) then
if( _M1PWM == _M1PWM_TIMER1_PIN && _M2PWM == _M2PWM_TIMER1_PIN)
would not be true and the timer frequency would not be changed for Timer 1.
Part2- looks like I would need to add pin 44 in .h file among some other changes
The read me should be updated to reference the change which allows PWM on the Mega for Timer 1 (pins 11, and 12). The default PWM pins on the Mega will also need to be adjusted in the .cpp file (should probably do some kind of switch case for the default pins... should be in the next release)
We should not use Pins 9,10 on the Mega as per the readme listed library conflicts
for best results avoid using pins 4, 9, 10, 13, 44, 45, or 46 for PWM
as for your question
if a person were using the Mega 2560 and used default pins listed (ie. 9, 10)
Then the PWM frequency changes and PWM functionality do not apply, and the pins will use pseudo-PWM via digital write.
Yes, you can pass pins 44, 45 to the constructor object as per the examples in the readme. but the pins will not use true PWM, and you need to make sure you do not have library conflicts (library conflicts with the servo library caused me lots of hard to find problems).
There are several libraries out there (TimerOne, TimerTwo, TimerThree, TimerFour, and TimerFive) which give PWM timer frequency controls beyond what is integrated into this library. I haven't personally dove into working with them and this library; but that likely be the best option for controlling all the other PWM frequency timers for this library. (likely need to comment out all the Timer stuff in the .cpp when using the Timer libraries)
Closing as no activity, Feel free to reopen if needed.
Just trying to understand the code a bit more and looks like you have PWM1 and PWM2 pins listed as default 9, 10 in DualVNH5019MotorShieldMod3.cpp but later reference them to Timer 1 in comments and README however aren't they associated with Timer 2 for the Mega?
Also, wondering if I can use pins 44, and 45 by declaring those pins for PWM3 and PWM4 when constructing the object without issue as they are on the same timer. Or would I have to edit other parts? The reason is I am using the sensor shield (v2) and 44 and 45 make for easier cabling as opposed to 45 and 46
Thanks for the library