PDA

View Full Version : Multi slow speed PWM



willem
- 10th August 2006, 18:45
Dear readers,
I wonder if it's possible within Darrel Taylor's very nice program Multi_SPWM to set the PWM value more accurate, let's say by using a 10 bit value.
Because there is quite a lot assembly code I didn't manage to find out myself..
Any hint where to modify (if possible at all...) are kindly appreciated!

Within my application I need to control 5 different LED light sources independent and quite precise. (using the very nice Zetex ZXLD1350 LED driver).

The PWM frequency has to be 200Hz (5ms period) and the puls widht should be controllable from 0 up to about 1ms in 10us steps. So the current 8 bit PWM value supported by Multi_SPWM.pbp works basicly fine but is not sufficient....
I'm planning to run on 20MHz PIC16F628..

TNX for you advice

Willem

Darrel Taylor
- 11th August 2006, 00:51
Hi willem,

That's asking a little too much from a PIC.

For 200hz, with 10-bit resolution, it would require 204,800 interrupts per second.

Running at 20mhz, the PIC can execute 5,000,000 instructions per second, which leaves 24 instructions per interrupt. That's not even enough to save/restore the Context for the interrupts, let alone turn things on and off accordingly.

Sorry!
<br>

willem
- 11th August 2006, 08:06
Hi Darrel,
Great to have your reply that quick!!

Ok for reaching the limits of the PIC for a 200Hz / 10bit res. PWM.

If I lower the frequency, this should give some "space"?

I found some (promising..?) info (see below) concerning the PWM module running in 10 bit resolution and would like to "play around" based on your Multi_SPWM finding out where it "ends".....

Any suggestions where to start, or is it in your opinion still a too busy task for a PIC and do I have definitively look around for an other solution?

Again thanks for your advise!!

Greetings,
Willem

************************************************** ******

On the 16Cxx parts with built-in PWM generators, how do I use 10-bit resolution instead of eight-bit?
Think of the PWM as always using 10-bit mode internally, with a period of four times the 8-bit number in the period register, a duty-cycle of four times the 8-bit number in the duty-cycle register plus the two-bit number in CCPx X and CCPxY, and a basic time-unit of Tosc. That is, if you're using a 4 MHz oscillator, with the period register set to 100, the period will be 4 * 100 oscillator periods (4 * 100 * 0.25 microseconds), or 100 microseconds. If the duty-cycle register is set to 25 and CCPxX and CCPxY are both "0", the duty cycle will be 4 * 25 + 0 oscillator periods ([4 * 25 + 0] * 0.25 microseconds), or 25 microseconds.
CCPxX and CCPxY contain the two lowest-order bits of the 10-bit duty-cycle register. When you use "8-bit" mode, you're just setting those two low-order bits to "00", which effectively sets the PWM duty cycle to four times the number in the duty-cycle register. To use 10-bit mode, just put the low 2 bits of your desired duty-cycle in CCPxX and CCPxY, with the upper eight bits in the duty-cycle register.
************************************************** *****

Darrel Taylor
- 11th August 2006, 17:21
Sure, you could use the CCP modules. But you'd need to run the pic at 4mhz to get it down to a minimum frequency of 245hz. And then you would only have 2 channels. So it would take 3 PICs to get all 5 channels.

You could use 12F683's that have one CCP module each. Used along with timer1 they can produce 16-bit PWM. But it would take 5 - 12F683's to get your required 5 PWM's.

You might take a look at the PIC18F4331.

It has 4-14bit pwm's and 2 normal CCP modules. The chip is supported by PBP, but the 14-bit PWM modules are not. So you would need to manipulate the registers manualy. But at least you could get all 5 PWM's from the same chip.

DT

Darrel Taylor
- 12th August 2006, 03:46
Another good chip is the 18F6720 which has 5 CCP modules

DT

mister_e
- 12th August 2006, 11:17
Darrel.. FYI, Microchip says...Please consider using device PIC18F6722

Nice PIC so far... probably enough to fade 5 leds and 2-3 other task ;)

willem
- 14th August 2006, 07:51
Dear Darrel, Steve,

Thanks again for your info and suggestions!
It maybe good for me to have a look at the problem from the other side; i.e.
the PWM requirements for my dimming device.
If I can make a setup accepting PWM over the full 5ms for a 0-100% light control it would be perfect to and Multi-SPWM could do the job.

I'll keep you informed.

Willem