Thanks a lot Kerry for the clarification. I guess this would mean=20 however that a 1 dimming level would effectively be a PWM signal at a=20 frequency of 24kHz/64 =3D 375 Hz (assuming the 10 bit PWM is 24 kHz) . The= =20 reason I am so concerned about the low level ie. 1 is that my=20 application is LED dimming at a high frequency. Currently my LED at a=20 PWM level of 1/1024 snaps on at too high a level. I would like it to=20 come on lower at the first level of dimming. 375 Hz is too low a=20 frequency for my application. Jim On 2017-09-07 12:56 PM, Kerry wrote: > 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: >> 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 =3D 0x1234 =3D 0b0001 0010 0011 0100 >> 10bit =3D 0b0001 0010 00 =3D 0x0048 >> 6bit =3D 0b11 0100 =3D 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 fo= r >>> 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 +=3D 6bit; >>>> if(Acc>0x3f) // If bit 7 set >>>> { >>>> Acc &=3D 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 P= IC >>>>> 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 PI= C >>>>> 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 f= or >>>>> such an application. Highest frequency one could get using 16 bit PWM >>>>> with a 32 MHz clock is about 488 Hz. >>>>> >>>>> Thanks, >>>>> >>>>> Jim >>>>> --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .