Switch mode voltage regulator with atTiny

Go To Last Post
26 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Hi friends, I have been playing with the event system, the CCL block and such on the newer ATtinies and ATmegas.

Here I describe how it is possible to use these blocks to build switch mode regulators that run completely independent of the CPU core once they are configured:

https://sm6vfz.wordpress.com/202...

 

I have not seen anyone else doing something similar. But if it has been done, please post a link here!

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for posting it is educational.

Construction is not not good due to the lack of overcurrent protection (current comparison on drain resistor is essential), so impractical in actual use, but shows programming cases very well.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

xavu9c8ws wrote:
Construction is not not good due to the lack of overcurrent protection (current comparison on drain resistor is essential), so impractical in actual use

It is not 100% perfect as is, but I wouldn't call it impractical at all. The maximum duty-cycle for the transistor is fixed so it cannot draw too much current through the inductor. In that sense a current sense resistor is not necessary.

And full protection against short circuits at the output cannot be done with any boost regulator since there is no transistor in the inductor-diode-output-path.

 

 

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is interesting to look at the circuits for boosting voltage using AVRs,  but I would use a separate dedicated circuit module board for switching regulation.  Like this one:https://www.ebay.com/itm/DC-Dual...

 For a few dollars, you get exact components on an expertly-laid out PCB.  And you don't have to spend your time debugging and troubleshooting "cookie cutter" electronic circuits.  And these boards are less likely to fail in the field than a switch-mode power supply running off a microcontroller's timer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

That's nice!! I'd add a gate resistor (maybe 20 ohms)  & a small cap  at pin7  (your output will have noise).

 

Your construction is atrocious...get a copper clad board & build on it...you will be glad you did!!  The large copper areas provides low inductance, and gnd plane (or  use plane on the bottom layer). 

Very easy to modify & measure things.  Here is one I made up not long ago with the AVR (it started out a lot neater!). Use a dremel tool to cut out & shape your areas.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Dec 13, 2020 - 10:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

 

Your construction is atrocious...get a copper clad board & build on it.

 

Get some pad per hole, PTH board.  Vector used to sell it (haven't bought any in a while because I had a bunch of it).  Newark, digi-key, mouser etc.... used to carry it.

 

If you don't make the connections too tight, it's easy to rewire.  All the wiring on bottom, all the components on top, easy to work with.  Then if you only need a one off, you can neaten it up and finalize it on the same board.

 

(these worked great, but they were lower frequency, I'd be a little more neater with this at higher frequencies.  But these days, I just make a PCB)

(and from a long time ago)

 

 

Just gettin' started, again....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He he, "atrocious"..! If you browse through my other projects you will find more "dead-bug" circuits but also neat PCB's.

 

And yeah, a gate resistor (larger than 20 Ohm probably) would do good for EMC. The switch node of any switched-mode regulator is otherwise a source of radiation if the switching is very fast. Adding resistance to the gate slows it down but you pay with more losses in the transistor.

There are many such things that can be improved but I think it is outside the scope of this simple demonstrative circuit.

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your construction is atrocious...

 

It is a very good thing that people can't rummaging through my old projects...

They would never stop laughing at some of the "atrocious" constructions!

 

There is an old say that I really love:

 

"You can't argue with success!"

 

It means that I might well have 10 reasons why what you are doing simply won't work, or how you have it hooked up simply can't work as you desire it to do so, but at the end of the day if it works, it works!

 

Benchtop tinkering often looks ugly!

 

Once a concept is tested and working, then it is a simple matter of tweaking for better performance, etc., or turning the (working) demo over to another team for refinement and production.

 

JC 

Last Edited: Mon. Dec 14, 2020 - 09:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

He he, "atrocious"..! If you browse through my other projects you will find more "dead-bug" circuits 

By atrocious, I mean in terms of electronic connections rather than neatness, per se.  For switchmode apps you want low inductance connections (wide copper interconnects) & gnd plane.  Your construction can be neat as a pin & completely atrocious...such as using wirewrap wire to build a 5 amp power supply, or neglecting bypass caps.

At least having you components floating in the air reduces leakage!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. Dec 15, 2020 - 02:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
For switchmode apps you want low inductance connections (wide copper interconnects) & gnd plane

Not necessarily. What you mainly want is small loop areas. It is often better to have tracks for ground returns than simply relying on a big ground-plane where the main current takes the shortest line-of-sight path and not necessarily reduces loop area. High frequency noise then also propagates over a big plane rather than stay confined to a given return path.

And sometimes you want some inductance in certain paths to dampen high-frequency currents.

But good EMI switch mode power supply is always a design that has to be made case by case and no thumb-rules can replace experience.

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What you mainly want is small loop areas. 

NO, that is not the main thought.  You mainly want solid  connections, THEN you can focus on small loop area (though in reality you try optimizing both at once).  Having small loop area is meaningless if certain component are not properly connected with low inductance (wide) connections, since the circuit will not work or be very unstable in the first place.  So you will often have filled polygon planes rather than traces connecting inductors, capacitors, fets, etc.

 

Yes smallest loop antennas are very desirable, for emi, we are discussing connections being made with long thin wires. & many ground loops.  Thin traces or wires will cause great grief if high current pulses are flowing.

You do not want signals over here to be something different a few inches away.    Of course, putting the parts close together can help a lot.  

 

You do bring up an important & excellent point that, simply making good connections is only half the job.  EMI is not to be forgotten.

 

compiled from a few sources on SMPS layout:

 

The purpose of the ground plane is to provide a low-impedance ground reference point for all of the circuits connected to it. The controller IC, the sensing networks, the power MOSFETS and so on. It's important to avoid using slots in the plane, because then the return current has to take a detour around the slot, which increases the stray inductance in the path. Make all of the power (high current) traces as short, direct, and thick as possible. It is a good practice on a standard PCB board to make the traces an absolute minimum of 15 mils (0.381mm) per Ampere. The
inductor, output capacitors, and output diode should be as close to each other possible.

 This will also reduce lead inductance and resistance as well, which in turn reduces noise spikes, ringing, and resistive
losses that produce voltage errors. The grounds of the IC, input capacitors, output capacitors, and output  diode (if applicable) should be connected close together directly to a ground plane. It would also be a
good idea to have a ground plane on both sides of the PCB.

 

The AC current return paths should be matched to the respective forward current paths as much as possible. The best way to do this is to use a full ground plane in close proximity on the next adjacent PCB layer. By minimizing the loop area and making the return path closely follow the forward current path, the opposing magnetic fields will tend to cancel each other out. 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Avrcandies, in order to have the low-inductance paths you want while simultaneously keeping loop areas small and also avoiding switch ground-currents to propagate to other circuits, I would go for a local ground plane only for the switching circuit. If one has more than two layers in the PCB one can then keep the main ground plane solid and connect to the switch ground plane in one point only.

 

But, the whole point of this project and thread was not do discuss switch mode circuit layouts. I was to point out that DC/DC-regulators now can be built with an AVR only.

It would be interesting if anyone had comments regarding the implementation as defined by the code/software.

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Pure beauty, respect for this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was to point out that DC/DC-regulators now can be built with an AVR only.

Well, they have been built for quite some time using AVR PWM...but using your logic method seems quite interesting---since perhaps, you don't need the high freq PLL timing, instead rely on fast logic response, such as for hysteretic mode control, or even current mode control...the use of logic components seems like it can give a lot more flexibility.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

 

When some goes takes the time to make what is, to me, a very good contribution it is disappointing to see them nitpicked.

 

As some one who has done such a project and looked for examples and found very few I thank you, a good contribution to the forum.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I agree totally and I'm glad I'm not alone.

 

I sincerely hope this doesn't cause that the poster stops posting such interesting ideas.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is a really cool project and which should be quite easy to replicate with students. Ultimately, I want to design a power supply with MPPT for bike hub generators.

Where did you get the proto board?

Cheers,

JG

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgeisler wrote:

Where did you get the proto board?

 

Oh, the proto board I drew myself with Kicad some time ago and ordered cheaply at jlcpcb.

Let me know if you want the files.

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you would share the files that would be awesome. Can you upload them to the forum or shall  I PM you my email address?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgeisler wrote:

If you would share the files that would be awesome. Can you upload them to the forum or shall  I PM you my email address?

Unfortunately I couldn't find my files. But I started drawing this again. There will be pads for an ATtiny214/414/814/1614, with all I/O pins going to 2.54 mm headers and a separate header for UPDI/programming. I'll also place a LED on one pin. And add a LM317 in SOT223 so that it can get 3.3V or 5V from a 12V etc supply. Any more wishes?

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

vfz wrote:

But I started drawing this again.

 

Oh wow. That would not have been necessary. I didn't mean to cause you so much work. But of course I'd be really grateful for your offer.

The LM317 and the LEDD are a good idea. Does the ATtinyX14 need any external components, like capacitors for power or analog reference smoothing, or a crystal, or some RC-circuit for programming reset? Apart from this, I don't think that anything else should be on a proto-board.

Cheers,

JG

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jgeisler wrote:

Does the ATtinyX14 need any external components, like capacitors for power or analog reference smoothing, or a crystal, or some RC-circuit for programming reset?

Not really. It has internal oscillator etc.

You can now check out the board at: https://github.com/danupp/ATtiny...

Use the gerber files as is or modify yourself in KiCad!

 

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is a switching supply?  How so?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

This is a switching supply?  How so?

Are you refrerring to the board above? It is a general prototyping board that is very similar to the one I used to build the switching supply.

Long time AVR user but more fond of analog electronics than compiler details...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you refrerring to the board above? It is a general prototyping board that is very similar to the one I used to build the switching supply.

Oh, that explains it..I thought your were posting your final switching power supply board design.  I got suspicious when I saw no inductor or transformer!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

vfz wrote:

You can now check out the board at: https://github.com/danupp/ATtiny...

 

That's very cool. Thanks a lot!