Mega 2560 16 bit pwm enable?

Hey Team.

I have a question. I need to get a higher resolution than 255 on pwm channels.

the problem I’m driving a low current coil 1.8 ohms up to 1.1 amps(max 1.98v) from a 14.5volt car power system.

I need to have at least 200 steps from 0-1.98 volts for accurate control. the more the better.

I know i could run a buck converter to drop the voltage. but i’m trying to minimize the parts that i use. on my project.

and it needs to run at a minimum of 20khz to not hear the coil. (this part i already figured out and have my mega running at 31khz)

is there an I2C ADC add on board that will do what i need?

Hi! @magnaride
The hardware PWM on the Mega is limited to 8 bits (0-255). Try to get the Board extenders. For example cheap based on PCA9685 chip with the 12-bit resolution (0 - 4095).

https://www.amazon.com/16-Channel-12-bit-Servo-Driver-Interface/dp/B00EIB0U7A/ref=sr_1_1?dchild=1&keywords=pwm+12+bit&qid=1605701470&sr=8-1
https://www.amazon.com/Dorhea-PCA9685-Interface-Controller-Raspberry/dp/B07RMTN4NZ/ref=sr_1_3?dchild=1&keywords=pwm+12+bit&qid=1605701446&sr=8-3

The module works via I2C. I didn’t find a XOD library for this module in our libraries base, so probably you’ll have to write it yourself. The good news is that it’s not complicated at all.


I found that controller and have used it, the issue is now that it only operates at 1.6hz and that is far too low to drive a coil and not hear it

I have a solution. 16-bit PWM-enabled GPIO expander on STM32 with I2C communication. But I do not know the upper limit for pwm freq. In theory it should be much more than 8KHz


that looks really interesting, i’m betting we don’t have a node for it yet.

I suppose i could always use a Teensy as well and replace the Mega 2560 all together