Slower PWM on imp005


#1

Hi all,

I am using the imp005 on a project and need PWM at 300-400 hz. Does anyone have any suggestion of how we might reduce the frequency of the imp005’s PWM? Or is there a reliable PWM generator I can add on to some pins?

A.

#2

It can’t go that low frequency - it’s a hardware limitation. Do you need variable duty cycle, or just a variable frequency clock? An external flip-flop will halve the frequency, you can cascade these.

There are i2c devices that can do slow PWMs eg https://www.nxp.com/products/interfaces/ic-bus/ic-led-controllers/16-channel-12-bit-pwm-fm-plus-ic-bus-led-controller:PCA9685 … you can get breakouts for this from Adafruit etc. They will go slow enough to drive servos but are generally intended for LED control.


#3

The frequency is static, the duty cycle is variable.
If we are halving it then 600-800 hz should be achievable from the imp005 but I would prefer a breakout board for stability reasons.

Adafruit has this: https://www.adafruit.com/product/815
We are waiting to test one of these: https://www.adafruit.com/product/1455
Other than SPI vs I2C, they look the same for my application.


#4

When you halve it with a flip flop, you’re fixed at 50% duty cycle (regardless of the duty cycle of the PWM output of the imp).

The SPI part, from what I could see, doesn’t allow you to set the frequency (not obviously anyway).

The I2C one I suggested will absolutely give you 12 bit resolution in the 600-800Hz range (prescaler of 10 = 25MHz/4096/10=610Hz… 9 gives you 678Hz, 8 gives you 762Hz).

The accuracy of the internal oscillator isn’t specced so maybe you want to pick the middle one, or if you need something really exact, you could connect an imp PWM to the PCA9685 EXTCLK input and then use a low divider - that way you get a crystal-derived PWM base frequency. You’d need to play around with available imp005 PWM rates (set 50% duty cycle) and 9685 prescalers to find the best fit for your application.


#5

Yep, spot on.

We don’t need to be exact. The instructions were “300hz to 400hz”. I’ll test it out and see if the internal clock can stay stable within that range. Sadly, Adafruit have pulled the EXTCLK pin to GND so I’m hoping that it works well.


#6

It’s only really lightly tied to ground (especially if you buy a clone board like https://www.amazon.com/16-Channel-12-bit-PCA9685-Arduino-Raspberry/dp/B071G24ZP1 ) - look closely, easy to cut that trace and feed a clock in if required.