3
\$\begingroup\$

I'm looking for a way to generate a high speed PWM signal into a high impedance input gate driver IC. This would be used to replace a lab bench waveform generator. Preferably I would use something like an Arduino so I can use also use the ADC and do my feedback digitally. Unfortunately Arduino does not have that combination of frequency and resolution.

The next best option would be a PWM controller that can be controlled with something like I2C so I could just control it with something like an Arduino.

I've looked high and low, but so far I'm striking out. I need at least 10 bits of resolution because my duty cycle is low (3-5%) and is relatively sensitive to small changes.

\$\endgroup\$
5
  • \$\begingroup\$ Any decent microcontroller (perhaps even some arduinos) can generate PWM at this frequency. \$\endgroup\$
    – Eugene Sh.
    Commented Jan 11, 2016 at 16:32
  • 1
    \$\begingroup\$ @EugeneSh. Actually, to achieve 30kHz output with HW PWM module, in Fast PWM mode, you need, at 10bits, 1024*30kHz = 30.7MHz PWM clock. There are still many that allow it (Even ATTiny's), but it's not just any decent MCU. And clever as they are Arduino has built no Tiny or XMega platforms that make it really easy to do. As far as I can see. Although the Mega328 on the Pro and Pro mini do allow a lot of variable PWM size playing around that can get you up to 500kHz at few bits and 19kHz at 10bit and any other number. \$\endgroup\$
    – Asmyldof
    Commented Jan 11, 2016 at 17:15
  • \$\begingroup\$ To expand on above: Seems Arduino Zero and Due can both do it, as they run an ARM core at >40MHz. But, at 8bit HW (10bit can be done with some clever firmware) the Tiny45 can do you 250kHz, with its 64MHz Fast peripheral clock, built in PLL. \$\endgroup\$
    – Asmyldof
    Commented Jan 11, 2016 at 17:22
  • \$\begingroup\$ @Asmyldof The Arduino Due looks like it has a clock frequency of 84MHz. As far as I know, if I set the resolution to 10bits the PWM frequency will be a set 84MHz/1024=82KHz. Would there then be a way to actually adjust the frequency to something like 60KHz? Or If I set it for 11bits (84MHz/2048=41KHz), could I then adjust the frequency to be 30KHz? \$\endgroup\$
    – BDP
    Commented Jan 11, 2016 at 18:52
  • \$\begingroup\$ LTC6992 uses analogue as an input to generate PWM. \$\endgroup\$
    – Andy aka
    Commented Jan 11, 2016 at 19:01

4 Answers 4

1
\$\begingroup\$

Since the Arduino Due was mentioned above (and I can't comment yet), I'll mention on that here.

On the Arduino Due, you can use the compare module for PWM, eg. By changing the "TOP" (what the timer counts up to - this sets the frequency) using the RC register in the AT91SAM chip, you can adjust the frequency (and resolution). To get 30 kHz, you end up having more than 10-bit resolution (with a 1:1 prescaler).

I see there is also a separate PWM block in the chip. I haven't played around with that, but the datasheet should reveal more.

\$\endgroup\$
3
  • \$\begingroup\$ Yeah, it looks like I can set the prescaler to 64 to take the 84MHz clock down to 1.3125MHz. Divided by 256 that is about 5KHz per, so I could then set the "top" to be 6 to get 30KHz. Does that sound right? And then do you know if I can set the duty cycle resolution using analogWriteResolution() to set the duty cycle to 10-bits of accuracy? \$\endgroup\$
    – BDP
    Commented Jan 11, 2016 at 22:32
  • \$\begingroup\$ TOP limits your resolution since your timer counts up to it. Your resolution is log2(TOP). You want TOP to be at least 1023 to have minimum 10-bit duty cycle resolution. For the analogWriteResolution(), here's some information: arduino.cc/en/Reference/AnalogWriteResolution For the Due, it doesn't seem from that that you can set the resolution to 10 bits. I haven't used this chip for a while now. I could write a simple demo code if I can find my Due. \$\endgroup\$
    – Tahmid
    Commented Jan 11, 2016 at 23:40
  • \$\begingroup\$ Basically, I just need the PWM output to have a duty cycle that can be varied between about 3% and 10% in 0.1% increments or smaller. This PWM needs to have a frequency of 30KHz, and ideally could be varied between 30KHz and 60KHz in increments of 10KHz. Is this going to be possible with the Due? \$\endgroup\$
    – BDP
    Commented Jan 13, 2016 at 16:46
3
\$\begingroup\$

A number of microcontrollers can do this. You want 30 kHz PWM with 10 bits of duty cycle resolution. That means the PWM generator needs a clock of (30 kHz)(1023) = 30.7 MHz. A EP series dsPIC 33 or PIC 24 can run at, and clock its pwm generators, at nearly twice that frequency. There are also some "high speed" PWM generators available on these parts that have their own oscillator and PLL, and run the PWM at about 1 GHz.

What you're asking for really isn't all that exotic.

\$\endgroup\$
2
  • \$\begingroup\$ I know a 30KHz PWM at 10bits isn't exotic, but I'm trying to find a relatively simple solution. I've got experience with both PIC and PSOC, but would much rather find a simple solution than have to write the firmware. Are you familiar with any of these high speed PWM generators that can be controlled with something like I2C or uART? I much prefer to use a digital feedback loop. \$\endgroup\$
    – BDP
    Commented Jan 11, 2016 at 18:57
  • \$\begingroup\$ This is almost identical to the answer I was going to give. @BrettPrudhom there really is no work to do with this peripheral other than to set it up. You just write the required duty to a register and off it goes. I have used it for motor control. You can get 15bit at 30kHz. Ideal for a waveform generator. This is much easier than writing communications interface to send instructions to external device via I2C etc. \$\endgroup\$ Commented Jan 17, 2016 at 14:09
1
\$\begingroup\$

Not the most elegant of solutions, but current sink LED drivers are an option if you need a chip that gives a PWM output without ending up with a lot of channels. You can simply use a pull-up resistor to pull it high if you decide to do this.

\$\endgroup\$
0
\$\begingroup\$

As noted above, there are a number of micros that can do this, e.g. most ARMs. They tend to also have a few ADCs on-board and a few high-res timers that will run at tens of MHz.

However if you know that your duty cycle is always "low" then you're not actually using 10 bits of resolution. Assuming you have an output filter that converts the PWM to an analogue voltage, an 8-bit PWM will give you 4x coarser resolution as 10-bit over a fixed voltage range... or the same resolution over 1/4 of the voltage range.

If your duty cycle is always under 1/4, you could use an 8-bit PWM at 8MHz with a filter and then scale the output down by 4x using an opamp, voltage divider or whatever. That'd give you 31250Hz without needing a faster, wider timer.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.