OK, I got some numbers wrong.

If your 16bit value was 0x3000, then the 10bit would be 0x0c0 and the

6bit would be 0.

The PWM output would be 192/1024 for all cycles, so there would be no

dithering.Â But 192/1024 is exactly equal to 12288/65536, so no

dithering is needed.

That's what I get for doing hex arithmetic in my head!

Kerry

On 9/7/2017 11:26 AM, Kerry wrote:

{Quote hidden}> I guess I should have been more clear.

>

> The leftmost 10 bits becomes the variable 10bit and the rightmost 6 bits

> becomes the variable 6bit, as in:

>

> 16bit = 0x1234 = 0b0001 0010 0011 0100

> 10bit = 0b0001 0010 00 = 0x0048

> 6bit = 0b11 0100 = 0x34

>

> If your 16bit value was 0x0001, then the 10bit would be 0 and the 6bit

> would be 1.

> The PWM output would be 0 for 63 cycles, the 1/1024 for 1 cycle.

> If your 16bit value was 0x3000, then the 10bit would be 0x300 and the

> 6bit would be 0.

> The PWM output would be 768/1024 for all cycles, so there would be no

> dithering.Â But 768/1024 is exactly equal to 12288/65536, so no

> dithering is needed.

>

> Does that help?

>

> Kerry

>

>

> On 9/7/2017 12:26 AM, Jim Ruxton wrote:

>> Thanks Kerry,

>>

>> This looks interesting , I don't quite follow it however. How would

>> this work if my 16 bit value was 0x0001 for example. In that case there

>> would be no dithering would there as the 6 bit value would be 0 so I

>> would be left with 10 bit PWM or am I missing something here. Thanks for

>> any clarification.

>>

>> Jim

>>

>>

>>

>> On 2017-09-06 07:41 PM, Kerry wrote:

>>> I think you would need to dither it.

>>>

>>> Set up an interrupt for each PWM cycle. Separate the 16 bit word into

>>> 10bit and 6bit.

>>>

>>> In interrupt:

>>> Acc += 6bit;

>>> if(Acc>0x3f) // If bit 7 set

>>> {

>>> Acc &= 0x3f; // Clear 7th bit

>>> set_PWM(10bit+1); // Extra long cycle

>>> }

>>> else

>>> set_PWM(10bit); // "Normal" cycle

>>>

>>>

>>> It will average out to your 16 bit value.

>>>

>>> Kerry

>>>

>>>

>>>

>>>

>>> On 9/6/2017 4:41 PM, Jim Ruxton wrote:

>>>> I got a reality check today when I thought I would try setting up a PIC

>>>> for 24 KHz 16 bit PWM . I had been using 10 bit and wanted to up the

>>>> resolution. After doing some calculations using something like the PIC

>>>> 16F1779 with integrated 16 bit PWM , I would require a 1.6 GHz clock to

>>>> achieve 16 bits at 24 kHz . Just curious what other folks would use for

>>>> such an application. Highest frequency one could get using 16 bit PWM

>>>> with a 32 MHz clock is about 488 Hz.

>>>>

>>>> Thanks,

>>>>

>>>> Jim

>>>>

--

http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive

View/change your membership options at

mailman.mit.edu/mailman/listinfo/piclist