High resolution pwm

I need 32 bit pwm...

I imagine there should be a simple IC for this.. like spi in, pwm out.. can anyone recommend one?

perhaps there is a way to do it with timers and interrupts on Arduino.. i think i heard mention of chaining 2 16bit timers once.. anyone have knowledge of this stuff?

before you get all "you cant possibly need that" or "arduino cant reach those frequencies"

Im controlling an AC servo, "virtual gearing" gives it super high resolution.. meaning i need to send it like 100s of khz, closer to 1mhz, pwm to get close to top speed (super quiet and smooth this way)

I am using my own code at present, and it works, but when i get to lower end of the resolution (from duty cycle of 10 to 9) the speed increments are larger and larger.. so accelerations and deceleration is bumpy to say the least.

basically i don't need a duty cycle in the nanoseconds(gigahertz), but i do want a duty-cycle with resolution of at bare minimum100ns( 0.1mhz).. preferably more like 10ns or even smaller

in short my current custom code (resolution of like 1us or so) still needs to be able to step from 9us to 9.9us or 9.99us duty cycle.. not just jump straight to 10us.. i want smooth acceleration

bare in mind this mcu also needs to listen to its serial hardware and receive commands... so any chaining 2 16bit timer solution might not be feasible as there is is plenty of other functionallity running concurrently.. so im thinking an external dedicated pwm IC is my best option.. just having trouble finding any ICs

at present I'm considering using an rp2040 with isolating level shifters, one core listens on spi for incoming settings from arduino, one core uses software to flip-flop the pwm to the servo... but there has got to be a cheaper easier simple IC solution.. right?.... right??

help much appreciated.

P.S. yes I know my AC servo controller probably has speed settings in the docs.. but i have plenty of external sensors,, and I do this kind of project frequently now.. I really want to control all the stepping manually...

and I don't want to decrease the controller "micro stepping" resolution.. Iove this smooth quiet high resolution

What is the best oncle Google gives You?

1 MHz PWM with 4-10 ns duty-resolution means that you don't need a "32bit PWM", the 8bit PWM will be enough for your task. But you need a controller with clock frequency 100 MHz or more.

The RP2040 chip itself costs less than $5, what a cheaper solution do you expect to find? You can try, of course, some of little known mcu from China, W801-W806 for example, but in this case you will have to write the code for it from scratch, understanding the Chinese documentation

So, 4 billion levels at 1 MHz. That's a 4 THz (Terahertz, 1000 GHz) clock. I don't think you are going to get anywhere near there.

Or did you mean you need 32 levels of PWM at 1 MHz?

The Arduino UNO can do 62.5 ns steps (16 MHz). You can get:
16 levels (4 bits) at 1 MHz
32 levels (5 bits) at 500 kHz
64 levels (6 bits) at 250 kHz

I need a range of 1hz to 500khz(min)
and i want a resolution of 1mhz (min best would be at least 10mhz)

i was also thinking just to use spi shift registers, timers, and a flipflop to build one.. but it just seems like there must be a nice high resolution pwm IC out there somewhere... and if not. i prefer my hacky idea of just using RP2040 and software over the pile of components and ICs needed to build my own

cant find anything to fit the bill

I'm hoping to find something that us not an mcu.. just a dedicated IC for high resolution pwm

using an RP2040 is my hacky backup plan

Do you understand exactly what the frequency and resolution of the PWM are? - I don't think so

How can there be a signal with a frequency of 1 Hz and a resolution of 100 kHz (0.1 MHz) ?

PWM resolution is not measured in hertz or megahertz. Until you start expressing your thoughts correctly, you will not succeed.

yes i do

i thought it was obvious I'm using "resoltuion of 1mhz" to mean the same as 1us

*there was a typo i corrected.. with correction it reads

I need a range of 1hz to 500khz(min)
and i want a resolution of 1mhz (min best would be at least 10mhz)

so simply put, I want resolution of .1us on a range of 1hz to 1mhz
1 / 0.0000001=10 000 000

I need a resolution of 10 million steps

Could you show a model or datasheet of the servo?

I doubt if you understood the spec correctly. Servo rarely require high frequencies to control

I am using this brand this time

but I have used several brands and they ALL use super high frequency by factory default (100s of khz to reach top RPM

I control it similar to a stepper.. i use the IO pins on the controller and use the PULL and DIR pins to control it

just to clarify, by "IO pins on the controller"

I should have said "the IO in the DB44 on the motor driver" to be more correct

I can change the setting on the driver to reduce the "virtual gearing" (or micro stepping in the language of steppers.. just these systems have 2 values which represent "virtual gears" and you set the number of teeth on each to control the step resolution.. this way is easier when dealing with gear boxes and gear ratios because you can just create "virtual gearing" which will match and compute easily with the rest of your physical gearing)

so i CAN "reduce the micro stepping" and use a low frequency... but then it gets noisier and move less smoothly

it is not a PWM resolution. Technically speaking, you just need a change of frequency in range 1 Hz tp 500 KHz with many steps between it.
As far I see you don't need PWM at all, you just need square wave with variable frequency.

Therefore, you need a dedicated IC called "frequency generator".

shit.. you are right... again my bad using poor language.. PWM was definitely wrong terminology.. you are correct.. I often control these things with pwm and just modify the PWM registers to control frequency.. but I can see how i completely screwed up my description of problem (or set up interrupts on the PWm and count X PWM cycles to flipflop an output pin.. basically use PWM interrupt as base for a frequency generator.. but all involved PWM and I failed to explain extra stuff)

regardless.. i did search for frequency generators but i am still failing to find ICs for the task

ooohh.. wait.. i found the AD9833 by drilling on " frequency generator IC" keyword

thank you.. this is what I need I think.. 28 bits resolution should be enough
and it seems i can use an external clock to control the range

thank you for the help

I apologize for my lazy question writing.. i whipped it out using "roughly accurate language" but the liberties I took with terminology created immense confusion...my bad

thank you for working through it and helping me find my answer

If your questions were answered, please mark the thread as solved.

Sounds like 500 kHz at 16 MHz resolution (32 steps) would fulfill your requirements. An Arduino UNO/Nano/Mega can do that.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.