Hello im working on a project and I am planning on using the a command from the library:
command getM1CurrentMilliamps()
together with the [dual-g2-high-power-motor-shield] on my arduino Mega
qoating the github page
(The current readings returned by getM1CurrentMilliamps and getM2CurrentMilliamps will be noisy and unreliable if you are using a PWM frequency below about 5 kHz.)
so i came across a way to raise te pwm singnal using TCCR2B = TCCR2B & B11111000 | B00000010; for some of the pins my question is if there is any harm done to the shield or arduino when raising to a higher pwm?
Yes, it is safe to use higher PWM frequencies up to a point. We generally recommend using 20kHz, since it is above the audible range so you won’t hear it. Our Arduino library for the G2 High-Power Motor Driver Shields uses 20kHz signals if you’re using a board based on the ATmega168, ATmega328P, or ATmega32U4. On other boards (such as the Arduino Mega), the library uses analogWrite() to generate PWM signals (which is at 490 Hz by default on the pins used by the driver).
It wouldn’t be trivial to get 20kHz on pins 9 and 10, but you could try changing the default frequency of analogWrite() on those pins to around 31kHz (which is still fine for these drivers) by calling: