• AVR Freaks

Helpful ReplyHot!PIC16F1773 16 bit PWM Resolution at 1MHz

Author
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
2019/02/24 07:57:23 (permalink)
0

PIC16F1773 16 bit PWM Resolution at 1MHz

Hi,

I'm trying to replace several buck/boosts with a DIY chip. Originally I was going to use 10 bit PWM's with the NCO trick to give greater resolution. I've now simplified with the PIC16F1773, however I'm unsure if I can achieve the high resolution required to run small value inductors.

The FET's I'm using are low capacitance of roughly 50ns for switch off, switch on, ramp up and down.

If I run what would be the equivalent of a 1MHz buck controller (so a period of 1000ns), then the PWM only has a duty of 3 steps. As you can see the resolution for the PIC16F1773 is 500ns. 

Perhaps this is good enough, but I assume 1MHz buck controllers are using much smaller steps than 500ns.

I feel like I'm missing a trick, please advise if you can!

Much appreciated,

Andrew




Attached Image(s)

#1
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 08:25:20 (permalink)
0
Similarly let's say I take a 32MHz PIC and a 10 bit PWM.

The maximum frequency is 32MHz/1024 = 31.25KHz

31.25KHz has a period of 32000ns which /1024 gives a resolution of 31.25ns.

So my understanding is the 10bit PWM is much faster.
#2
NorthGuy
Super Member
  • Total Posts : 5480
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 08:36:51 (permalink)
0
You need higher FOSC. If your FOSC is 32 MHz, you get the minimum PWM step of 31.25 ns. For 1000 ns period, this gives you 32 steps of resolution. This can be achieved with 5-bit PWM, thus even standard 10-bit PWM is more than adequate.
 
If you want to go below 31.25 ns, you need a faster clock, which you cannot get with PIC16. Since NCO runs from the same clock source, I cannot see how it may help.
 
If you want higher resolution, look at dsPIC33EP16GS202 (or similar) which can give you 1.04 ns resolution on High Speed PWM.
 
#3
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 08:47:53 (permalink)
0
Thanks, that's what I thought. I think 31.25ns will be adequate especially since the FET turn on/off is 50ns and 1024 steps should give enough ripple control. I don't know what the "standard" is for small buck topology.

What is confusing is why the 16 bit PWM's on the PIC16F1773 are so much slower. Perhaps the chip is targeting large current bucks where the FET's are slower.  (PS the max FOSC is 16MHz on this chip).

Cheers!

Andrew
post edited by acharnley - 2019/02/24 08:50:04
#4
NorthGuy
Super Member
  • Total Posts : 5480
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 09:26:21 (permalink)
+1 (1)
acharnley
Thanks, that's what I thought. I think 31.25ns will be adequate especially since the FET turn on/off is 50ns and 1024 steps should give enough ripple control.

 
You don't get 1024 steps. There are only 32 of 31.25 ns intervals in the 1000 ns period. Thus, there's no way you can get more than 32 steps.
 
acharnley
 (PS the max FOSC is 16MHz on this chip).



It is definitely 32 MHz.
#5
Mysil
Super Member
  • Total Posts : 3325
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 09:55:20 (permalink) ☄ Helpfulby acharnley 2019/02/24 15:06:39
+2 (2)
Hi,
The 16 bit PWM peripheral is not that much slower,
but you cannot achieve 16 bit resolution, with a short PWM period. 
Also the 16 bit PWM peripheral can select FOSC as Clock source,
so with 32 MHz clock frequency after PLL / 1 MHz PWM period frequency,
you can still use only 5 bits of PWM resolution.
 
So it doesn't matter if you use 10 bit PWM peripheral, 16 bit PWM peripheral, or CCP peripheral in PWM mode.
PIC18 devices may run with 64 MHz system clock frequency after PLL, so may give 6 bits PWM resolution.
 
16 bit PWM peripherals are not any benefit for high speed switching like you are trying,
they give more advantage for Lighting control at much lower frequency, where human perception at low intensity is wery high.
 
    Mysil
post edited by Mysil - 2019/02/24 10:01:51
#6
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 15:05:40 (permalink)
0
NorthGuy
acharnley
Thanks, that's what I thought. I think 31.25ns will be adequate especially since the FET turn on/off is 50ns and 1024 steps should give enough ripple control.

 
You don't get 1024 steps. There are only 32 of 31.25 ns intervals in the 1000 ns period. Thus, there's no way you can get more than 32 steps.
 
acharnley
 (PS the max FOSC is 16MHz on this chip).



It is definitely 32 MHz.




I wonder why buck chips give a MHz spec. For example the MCP1642 (this is one of the chips I'm replacing) runs at 1MHz. It doesn't have a wide voltage range, but if I assume it has a 10 bit PWM that means it's using a much larger interval than I believe I need. I Googled for an answer on what sort of interval length small buck converters use but didn't find an answer. 

The 10 bit PWM isn't clocked at FOSC as it uses a 10 bit timer, so 32MHz / 4 / 1024 = 32us period (31.25KHz)

32us / 1024 = 31.25ns interval
 
post edited by acharnley - 2019/02/24 15:22:33
#7
Mysil
Super Member
  • Total Posts : 3325
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 16:38:53 (permalink)
0
Hi,
There still seem to be some misunderstanding.
10bit PWM peripheral and CCP peripheral in PWM mode work the same way:
They all use a 8 bit Timer that is clocked by FOSC/4, that is the Instruction count clock. 
Then, there are 2 hidden timer bits, that are clocked by FOSC directly, these are Instruction phase clock bits.
You may look at these as a 1/4 prescaler that are Not visible to Timer2, 
but is used by the 10 bit Duty Cycle Comparator.
Thus for 1 MHz PWM period with 32 MHz system clock frequency,
PR2 Period register must be 7.
Duty Cycle registers  PWMxDCH <7:0>: PWMxDCL<7:6>  values between  32 and 0 may be useable.  Duty cycle value 32 or higher will not match, so will result in full On (or full Off) output.
 
Math in message #7 is wrong: 32MHz / 4 / 1024 = 32us period (31.25KHz) = 7.812 kHz

Correct Maximum period is: 32 000 000 Hz / 4 / 256 = 31 250 Hz
Useable period is: 32 000 000 Hz / 4 / 8 = 1 000 000 Hz, is  1 us period.
 
    Mysil
 
#8
PStechPaul
Super Member
  • Total Posts : 2290
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: online
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 16:42:22 (permalink)
+2 (2)
A PWM boost converter like the MCP1642 is almost certainly an analog / digital logic design, which does not have a specific PWM resolution. The PWM would be accomplished by means of feedback and comparators.
 
https://www.microchip.com/wwwproducts/en/MCP1642
 

 
#9
cobusve
Super Member
  • Total Posts : 492
  • Reward points : 0
  • Joined: 2012/04/02 16:15:40
  • Location: Chandler
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/24 22:21:06 (permalink)
0
There area many ways to achieve feedback in power converters, using a ramp and comparator you can generate a PWM with essentially infinite resolution, you can build one of these with some of the small 8-bit microcontrollers like the 16F170x family.
 
If you want a 16-bit PWM on a 1MHz signal you are asking for 65535 divisions on a 1MHz signal, which can only be accomplished by using a 65GHz clock, this is of course faster than any processor I have seen, so probably not a realistic requirement if you want to generate the signal using a digital PWM.
 
There are techniques which will give you an approximation of this by dithering the PWM, e.g. DDS or NCO based PWM's, but I think what you are asking for is not very realistic.

Also take a look at https://www.microforum.cc/ - a great resource for information on PIC and AVR microcontrollers and embedded programming in general. You can also post questions to the experts there.
#10
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 00:22:41 (permalink)
0
Ok, I'll drop the 1MHz and focus on the interval and resolution. Check my math:

With a 10 bit PWM and FOSC running at 32MHz I can achieve 1024 steps of 31.25ns. Switching to a PIC18 @ 64MHz can half this. All things being linear (unlikely) a 100V input with 1024 steps gives 0.1V accuracy. 

Since the feedback is ADC based the response is limited by the ADC, somewhere in the region of 45KHz / [ADC channels], unless I were to use additional math to skip duty values when the output/wanted delta is large the 16 bit resolution would get in the way.

I've already explorer the NCO dithering route, and keen to learn about the ramp and comparator technique @cobusve.

I guess what I need to discover is whether a 31.25ns interval is good enough. With FET's that take 50ns to turn on/ramp/off it sounds like it is, but alas I'm really just guessing!






#11
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 03:25:27 (permalink)
0
With 10 bit PWM and 31.25ns clock, you're only getting a 32us period, which is 31.25 kHz.

Nearly there...
#12
NorthGuy
Super Member
  • Total Posts : 5480
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 09:31:28 (permalink)
0
Fast switching is used mainly to reduce the size of inductors/capacitors. If you want to use big inductors and capacitors, you can use slower switching. This will also achieve better efficiency. Load response will be slower of course.
 
You cannot really make a good fast switcher with PIC16. If you need fast, use dsPIC33EP16GS202 instead.
 
There is also a well known oscillation problem: If you design an oscillator, it'll never oscillate, but if you design a power supply, it will. You may need some compensation networks to deal with oscillations. It make take long time to design.
 
If you just want to supply power, use a ready-made power chip, where the designers (hopefully) took care of everything.
 
#13
NorthGuy
Super Member
  • Total Posts : 5480
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 09:31:29 (permalink)
0
Duplicate
 
post edited by NorthGuy - 2019/02/25 09:33:02
#14
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 10:52:57 (permalink)
0
Honestly I would, far less to go wrong. Here's why I can't. 
 
I need a buck which does 5V to 100V, high efficiency (sync)
 
I need a boost which does 0v to 5V from lowest possible voltage and with pass-through. The MCP1642 looked perfect until I hit the 800mA pass-through limitation.

Defo considering dsPIC33EP16GS202. Already moved to PIC18 for the 64MHz speed. 

Question still stands though, is 32ns not enough already (when the FET's take 50ns to turn on and off fully)? Maybe regulation will be weak but 16ns with the PIC18 sounds better. Do I really need 1-2ns control offered by the dsPIC33EP16GS202?
#15
NorthGuy
Super Member
  • Total Posts : 5480
  • Reward points : 0
  • Joined: 2014/02/23 14:23:23
  • Location: Northern Canada
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 12:03:33 (permalink)
0
acharnley
I need a buck which does 5V to 100V, high efficiency (sync)

 
This would be boost. If you only look at nominals (it'll be much worse in the real word), you'll need 0.95 duty cycle. With 1 MHz switching rate, you'll be able to do 30/32 = 0.9375, which gives you 80V or 31/32 = 0.9685, which will give you 160V. PIC18 will add 61/64 = 0.953 which will give you 110V. If you want any resemblance of precision you need to move to much slower switching rates.
#16
Mysil
Super Member
  • Total Posts : 3325
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 12:04:32 (permalink)
0
Hi,
Do Not confuse the time needed by FET switch to turn off,
with resolution in PWM duty cycle.
 
Edit:
I am probably mistaken, although there is also discontinous mode conversion possible for boost conversion,
that is also more complicated to design.
 
 
For a 1 MHz PWM Period frequency, there will still be 1000 ns between pulses,
and the pulse length may vary only in 31 ns steps:  31 ns, 62 ns, 94 ns, 125 ns, 156 ns ...
Or with a PIC18 at 64 MHz with 16 ns steps: 15ns, 31 ns, 47 ns ...
You will have to monitor the output voltage anyway, and adjust for variations caused by power supply voltage, or load current.
 
If you succeed in designing and coding your regulation algorithm to only need to adjust PWM duty cycle one step up, and one step down to keep output voltage on target, then you have a good design.
 
A lot will depend on the design of your Switching and LC circuits, and on properties of the Load.
Is load expected to change suddenly? How will you handle startup and overcurrent events?
 
Are you sure that you will achieve the efficency you aim for, with 1MHz PWM period?
switching losses will increase with higher frequency.
Do you have FET gate driver circuits to ensure 50 ns switch off time?
 
    Mysil
 
post edited by Mysil - 2019/02/25 12:35:00
#17
acharnley
Super Member
  • Total Posts : 305
  • Reward points : 0
  • Joined: 2016/05/01 06:51:28
  • Location: 0
  • Status: offline
Re: PIC16F1773 16 bit PWM Resolution at 1MHz 2019/02/25 14:49:16 (permalink)
0
Hi, 

Earlier 5v to 100v I meant input voltage, with 5v out.

I have MIC4605 driving the buck (the one that goes 100v to 5v) and a very fast FAN3226 for the 0-5v boost. In both cases I'm driving NFET's using 16V (the PIC has a third boost circuit but a large 100uH inductor and very low current so this one isn't problematic) so they'll turn on/off quickly, plus the FET's are low capacitance so 25-50ns total turn on/off/ramp worst case. Luckily I have a lot of capacitance and relatively slow input voltage changes.

Northguy -> sticking with 62.50KHz, 16ns intervals, 1024 steps (PIC18) - forget the 1MHz. 

I'm not handling overcurrent at all, the FET's can handle a short. The MIC4605 handles shoot-through and I'll use the PIC's CWG to do the same for the FAN3226. I have another thread going where I'm enquiring about reverse current flow from the super capacitors.
post edited by acharnley - 2019/02/25 16:03:06
#18
Jump to:
© 2019 APG vNext Commercial Version 4.5