Author Topic: PIC16f1782 based Switching PSU  (Read 19228 times)

0 Members and 2 Guests are viewing this topic.

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
PIC16f1782 based Switching PSU
« on: February 15, 2015, 05:47:07 pm »
Decided it was time to have a look at some of the newer 8bit offerings from Microchip, been using 16F628 16F684 etc for a long time, but the new generation does look quite interesting, lots of features and very cheap.

So I thought it would be interesting to try do something with the PSMC (programmable switchmode) based on my previous experiments using a dsPIC33/pic24h (https://www.eevblog.com/forum/projects/multiphase-buck-converter-controlled-by-uc-with-cv-and-cc/msg342537/#msg342537)

Would be interesting to do something similar with this little 8 bit.

Feature wise, it's got 12 bit ADCs (single ended/differential), Fast comparators, Rail-to-rail opamps, programmable reference, 8 bit DAC, UART, I2C, EEPROM, CCP, PSMC (64MHz resolution), loads of timers and interrupts, but only 2 kB of flash and 256 bytes RAM.

Full details: http://ww1.microchip.com/downloads/en/DeviceDoc/40001579E.pdf

Anyway, first step, being able to plug it into a breadboard:



Experience tells me that a bread board features test, before making a PCB, is well worth the time, otherwise too many assumptions easily turn out not to be true.

« Last Edit: February 15, 2015, 05:49:45 pm by jaxbird »
Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: PIC16f1782 based Switching PSU
« Reply #1 on: February 15, 2015, 06:01:12 pm »
PIC16F1788  has 16K flash and 2048 data RAM and it is not much more expensive, not to mention there are 8 k and 4k flash types in between.
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #2 on: February 15, 2015, 06:08:10 pm »
PIC16F1788  has 16K flash and 2048 data RAM and it is not much more expensive, not to mention there are 8 k and 4k flash types in between.

Thanks, yeah, it's nice they do have offerings with the same feature set and different amounts of FLASH and RAM, I am hoping I can squeeze what I need into the 2kB, should be sufficient, but if things get out of hand, it's always nice to be able to just upgrade to the next available instead of having to go into some time consuming hand optimized assembly rewrite.

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #3 on: February 15, 2015, 06:15:05 pm »
Feature testing, no issues so far:




I want to have 2 phases offset by 180 degrees, it does not support that directly, but with a bit of workaround it does it just fine. The PSMC modules do have quite a lot of modes and features, everything from single PWM to 3 phase motor control pwn, push-pull with or without complementary outputs etc.

I'll try with 250kHz, giving 8 bit resolution.

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: PIC16f1782 based Switching PSU
« Reply #4 on: February 15, 2015, 06:24:12 pm »
Your attempt to cut cost with a 2K flash doesn't make sense. The 16K flash part is only 1.25 more expensive, but trying to optimize your code to fit into 2k would be 1000.25% more expensive in programming total time spent and the perhaps the ultimate result of all this extra effort would likely compromise functionality and ease of use, etc..you gain little, but perhaps loose time, performance and overall quality of the finished product..that is unless you are seeking to make something so simple it might not be nice to work with.
« Last Edit: February 15, 2015, 06:31:21 pm by Paul Price »
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #5 on: February 15, 2015, 06:25:25 pm »
My only issue is a fluffy fat cat that likes to sleep on my table as soon as I go make a cup of coffee  :P

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #6 on: February 15, 2015, 06:29:14 pm »
Your attempt to cut cost with a 2K flash doesn't make sense. The 16K flash part is only  125% more expensive, but trying to optimize your code to fit into 2k would be 1000.25% more expensive in time spent and likely compromise quality.

I think you misunderstood me, I don't expect to have any issues with the 2kB Flash limit (I might get wiser) but generally with 8 bits, I never use floats and do calculations in integers shifting left and right for precision etc.

If I get into trouble, I'll surely update before considering serious optimizations.

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline SeanB

  • Super Contributor
  • ***
  • Posts: 16281
  • Country: za
Re: PIC16f1782 based Switching PSU
« Reply #7 on: February 15, 2015, 06:30:22 pm »
Pay more attention to the cat, or place a hot resistor in the middle of the table.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: PIC16f1782 based Switching PSU
« Reply #8 on: February 15, 2015, 06:42:34 pm »
Perhaps the cat has realized that the 16K part is readily available in a 28-pin skinny-dip, so no breakout adapter card is necessary at all.
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #9 on: February 15, 2015, 06:47:47 pm »
Pay more attention to the cat, or place a hot resistor in the middle of the table.

:)... I'm sure something hot would do it, but not only warm, that just attracts cats.

But on a serious note, I do need to be careful when working with higher voltages. I don't think my better part would be proud of me if I electrocute any of the cats :)


Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #10 on: February 15, 2015, 06:50:56 pm »
Perhaps the cat has realized that the 16K part is readily available in a 28-pin skinny-dip, so no breakout adapter card is necessary at all.

Possible, but she seems more interested in tuna... puny human technology only invokes limited interest unless it's warm and worth sleeping on.


Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #11 on: February 15, 2015, 07:01:23 pm »
Anyway, pinout for the pinout puzzle game. It does have quite a few remappable features, which is very nice when trying to use a lot of the included features.



Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #12 on: February 15, 2015, 07:13:55 pm »
Nice work. Looking forward to seeing what will come out of this.

================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #13 on: February 15, 2015, 07:15:39 pm »
Quote
It does have quite a few remappable features

Remappable pins are coming to the lower range mcus. Still, the 24F parts excel in that.

Why did you decide to start this instead of finishing the 24F project?
================================
https://dannyelectronics.wordpress.com/
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #14 on: February 19, 2015, 01:14:38 pm »
Time to build a prototype on PCB. Made a little board that hopefully will work as intended.

Made it double sided to get better ground.


Front:



back:



Came out OK, but it was a pain as I broke a bit half way though.

« Last Edit: February 19, 2015, 01:17:52 pm by jaxbird »
Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #15 on: February 19, 2015, 01:23:48 pm »
Quote
It does have quite a few remappable features

Remappable pins are coming to the lower range mcus. Still, the 24F parts excel in that.

Why did you decide to start this instead of finishing the 24F project?

Yeah, I love the remappable features in pic24, makes it so much easier to do layouts and sometimes saves your ass when you make mistakes :)

The initial project was really just playing around to see how well it would work, but something useful could be made out of it, the performance was pretty good. I used the pic24H part in that project (identical to dspic33).

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline Pjotr

  • Frequent Contributor
  • **
  • Posts: 461
  • Country: nl
Re: PIC16f1782 based Switching PSU
« Reply #16 on: February 19, 2015, 01:25:25 pm »
The intial release of the series had a lot of bugs, they seem to have corrected most of them in the latest revsion.

I wonder. We have had finally lengthy discussions about those bugs some years ago with engineers of Microchip. They were well aware of the bugs, but nothing of it in the data sheet errata about it. Also they didn't plan to to fix them. Made the Pics unusable for the converter then (a phase shifted H-bridge).
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #17 on: February 19, 2015, 01:34:12 pm »
Well if all he is doing is a dual phase converter the chip already has PSMC so once he sets the registers up that only takes maybe 50bytes. Thats about what I use to set up comparators ,DAC,opamps on a PIC16F1708 if that. I guess it depends what else he has in mind. I would be more concerned on the silcon revision. The intial release of the series had a lot of bugs, they seem to have corrected most of them in the latest revsion.

I don't expect to need more than 1k. Feature wise, I'll be using 4xADC, 1xReference, 2xComparator, 2xOpAmp, Timer(s) and ADC interrupts, plus various IO pins for display, LED etc.

I did check the errata, appears they got most of the bugs fixed, errata only goes to revision 4, but according to my pickit the ones I got are revision 6, so I don't expect any surprises. (well I guess it wouldn't be a surprise if you expected it :))


Edit: And of course the PSMC module, I use the push-pull mode (without complementary) to get 2 phases, and to get more than 50% duty cycle, I just invert the outputs.

« Last Edit: February 19, 2015, 01:45:23 pm by jaxbird »
Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #18 on: February 19, 2015, 02:20:49 pm »
Started populating the board, just the basics to get it up and running, power, MCU, display and ICSP.




All good so far, but then again, it's not really doing much yet :)


Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #19 on: February 19, 2015, 03:56:02 pm »
More progress, getting close to functional:





Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #20 on: February 19, 2015, 04:14:35 pm »
While the top side is kept nice old school looking (aesthetic design decision :)), the bottom is somewhat more interesting:



Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #21 on: February 19, 2015, 04:21:45 pm »
Feature wise, the goals are:

Input: 10-28V

Output: 0-20V, 0 - 4A (buck only, so max Vout = Vin - a few 100mV)

CV/CC capable, 2 phase design for minimal ripple.

Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #22 on: February 19, 2015, 05:02:34 pm »
A couple of quick ripple measurements (20MHz limited, using ground spring, between out+ and out-)

12V in 5V out, 1A load:





12V in 5V out 2A load:





Looks almost too good to be true.
Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5319
  • Country: gb
Re: PIC16f1782 based Switching PSU
« Reply #23 on: February 19, 2015, 05:35:54 pm »
Very nice!

I spent some time with an MCP19111 over a year ago, in an attempt to make a synchronous buck SMPS whose switching frequency could be controlled with the intention of using it to do a 2S Li-Ion charger from 12 to 14V. The possibility of using such a device seemed most enticing.

In the end it was all too hard, the device would not work without external current sensing devices if trying to use on 8.4V, which negated its benefits of reducing BOM line items. The datasheet says it could be done with a simple potential divider to get the voltage levels back to the device's range, but that's just not gonna work when you look a bit further into it!

Before that I spent a short amount of time on their dsPIC33s on an SMPS design, but turns out there's zero point using them on a low power device: the high resolution PWMs required in the PID loop dissipate way too much power, more than the CPU core in fact.

Maybe I should take another look at this as a solution.
 

Offline jaxbirdTopic starter

  • Frequent Contributor
  • **
  • Posts: 778
  • Country: 00
Re: PIC16f1782 based Switching PSU
« Reply #24 on: February 19, 2015, 06:05:48 pm »
Very nice!

I spent some time with an MCP19111 over a year ago, in an attempt to make a synchronous buck SMPS whose switching frequency could be controlled with the intention of using it to do a 2S Li-Ion charger from 12 to 14V. The possibility of using such a device seemed most enticing.

In the end it was all too hard, the device would not work without external current sensing devices if trying to use on 8.4V, which negated its benefits of reducing BOM line items. The datasheet says it could be done with a simple potential divider to get the voltage levels back to the device's range, but that's just not gonna work when you look a bit further into it!

Before that I spent a short amount of time on their dsPIC33s on an SMPS design, but turns out there's zero point using them on a low power device: the high resolution PWMs required in the PID loop dissipate way too much power, more than the CPU core in fact.

Maybe I should take another look at this as a solution.

Thanks :)

I think this little 16F178x is close to perfectly configured for a Li-ion charger, you get 2x switch mode module, fast comparators for improved voltage and current control (pulse skipping etc), opamps for amplifying current shunt, internal reference for accuracy, fairly high res ADCs (12 bit/100ksps) for monitoring. built in DAC. and a lot cheaper than a dspic33

So far I've been impressed by this little 8 bit.

The switch mode module is quite flexible:



« Last Edit: February 19, 2015, 06:07:21 pm by jaxbird »
Analog Discovery Projects: http://www.thestuffmade.com
Youtube random project videos: https://www.youtube.com/user/TheStuffMade
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf