Saturday 7 April 2012

LM317 PCB Layout

Here we go...it's PCB layout time!  Here is the schematic re-drawn and ready for PCB layout.  I have added a 5V fixed supply to the circuit because I would like to add a digital voltmeter to the circuit so we can monitor what the output voltage is set at.  After investigating panel meters on-line I found that they require a separate supply in order to work correctly.  Other than this the circuit is the same as in the previous post.


Now that we have designed the variable power supply it's time to make a printed circuit board to mount the components onto and route the connection tracks.  For PCB layout I use Eagle Cad from Cadstar because it's free up to a point, has great component libraries and support via forums from thousands of people.  

There are thousands of PCB layout tutorials for eagle available so I'm not going to go through the nuances of doing PCB layout unless requested.  I don't consider myself very good at this particular aspect of electronics.  I know the theory but I don't have much experience in the practical.  Professionally I sub-contract PCB layout out to someone else but because this is for me personally and anyone reading this the following guidelines are always good:
  • Lay out the components on a suitably sized PCB first.
  • Set the grid size to something sensible.  I used 1.27mm and 0.635mm for my grid size
  • One you have a general idea of the component location select a suitable track size.  Thicker for more current carrying capability.
  • Try not to cross tracks. 
  • Once you have all of the tracks routed perform an electrical rules check
  • Tear-drop the pads once you have completed all of the above tasks.
  • Finally resize the PCB if you can.  Less board = cheaper manufacturing costs
I shy away from auto-routing functions in PCB layout tools as they always seem to do a poor job!  I have heard of other people find these work well but I have had mixed results.  I have always found for more simple circuits it is much better to route the tracks by hand.  The PCB layout for this circuit is shown below:


I chose a thick track size on purpose as I wanted to be sure that there would be enough current carrying capacity in all of the tracks.  This might be a bit overkill but it at least it saves on copper.  I also didn't use a ground plane on this design as it isn't really necessary.

All that is left to do now is to actually make the PCB.  When I do this I use the toner transfer method of making a PCB.  That involves printing out the design in reverse (like in the above picture) on a laser printer.  I then get a piece of blank PCB.  I'm going to use a 160mm x 100mm blank PCB and cut it down to size.  I'm then going to clean the PCB thoroughly and then placing the print out of the layout ink-side down (actual size) onto the copper, and using a clothes iron, transfer the pattern.  The iron should be set to as high as possible - ENSURE there is no steam or water in the iron.  Firmly press and iron the paper for about 5 minutes.  Then switch off the iron and wait for the PCB to cool...it will be too hot to handle.  Once cooled run the PCB under water to 'soak off the paper'.  What should have occurred is that the design has transferred from the paper onto the copper of the PCB.  If it hasn't worked clean the PCB off and repeat the process.  Next etch the PCB in ferric chloride or Muriatic acid...whichever you prefer.  I use ferric chloride because I find it gives me a better etch and because Muriatic acid (Swimming Pool Cleaner) is hard to get hold of in the UK.

That's about it for now.  Next post will be the actual building and soldering of the supply with photographs!  For those that might be interested here is a good tutorial on PCB layout:

http://www.alternatezone.com/electronics/files/PCBDesignTutorialRevA.pdf - From the EEVBlog! Kudos to David L. Jones

Here are the eagle files for this project so that if people wish to make this power supply for themselves!

LM317 design files on Github

Update: I found having constructed the above circuit that there was a mistake in both the schematic and the PCB.  I have updated both to resolve the issue.  I missed out a connection on the schematic which prevented the supply from going low.  The variable resistor needs a link from the middle pin (wiper) to the top pin so that the voltage output of the LM317 can be reduced down to 1.25V


Here is the component placement in case someone needs it!

Tuesday 3 April 2012

Power supplies part III

Still getting on with the job of designing a linear power supply!

Last post talked about smoothing and why large electrolytic capacitors are used to remove ripple.  This post is going to talk about voltage regulators.

The voltage output from the previous circuit although now nice and smooth will not be constant.  As soon as an electronic 'load' or impedance to use the proper term is placed across the positive and zero volt terminals the voltage will drop because there is not a constant current present to drive the load.  The circuit that fixes this problem is called a voltage regulator.  There are many different types of circuits for making voltage regulators and they all have their place.  I don't intend going into all the different types of regulator here.  If people are interested the web sites below maybe useful:

http://en.wikipedia.org/wiki/Power_supply#Linear_regulated_power_supply - Wikipedia!

http://www.eevblog.com/2011/11/28/eevblog-221-lab-power-supply-design-part-1/ - the excellent EEVBlog by Dave L. Jones!

http://www.allaboutcircuits.com/vol_3/chpt_9/2.html - All about circuits....I highly recommend this site!  Its
great for electronics theory.

Essentially a voltage regulator is a special circuit that provides a constant voltage to a current controlled device which keeps the output to the load constant whether the load or the supply are changing.  We know that the supply isn't constant as the transformer is supplied with an AC voltage which switches polarity every 10ms and the load attached to the output may not be constant either.

The constant voltage output is usually achieved by using a special diode called a Zener diode.  These devices are a special kind of diode which allow current to flow in both directions once a certain voltage is applied to the anode.  Zener diodes are used to provide a constant voltage reference.  Check out all about circuits page in zener diodes for more information here:

http://www.allaboutcircuits.com/vol_3/chpt_3/11.html

The next part of the regulator would be made up of a series pass transistor.  This is normally a high current transistor which is permanently switched on by the zener diode and a resistor and is used to keep the current output constant. So by implementing the circuit below we have a constant voltage regulator.  To keep the theory simple I have selected a 12V zener diode and that is what decides our output voltage for the power supply.

If we were to implement the circuit above it would provide us with a constant 12V (all right 11.643V) output whatever load was attached.  However there are better and easier ways of implementing the above circuit (Series voltage regulator) using an integrated circuit known as the three terminal voltage regulator.

There are literally hundreds of different types of three terminal linear voltage regulators - some of the more popular ones are the ubiquitous 78 series which are a fixed voltage output linear regulator.  Another might be the LT38 series.

For my power supply though I wanted an adjustable voltage output and so I'm going to use an adjustable voltage regulator - the venerable but useful LM317.  There are many manufacturers of this device but they all perform the same function.  The datasheet and application note for this regulator from Texas Instruments are here:

http://www.ti.com/lit/ds/symlink/lm117.pdf - Datasheet

The circuit will now look like this.  This circuit is directly taken from the information provided in the datasheet.  All the information needed to design the circuit is there.  Datasheets are like rosetta stones to electronics design engineers.  When they are well written they can make our lives so much simpler!


You may have noticed I have added some extra components to our circuit.  R1 is what is known as a 'bleeder' resistor.  This is so that when power is removed from the circuit the energy stored in the electrolytic capacitors is safely drained away.  Otherwise the capacitors can remain charged for a very long time and store a lot of energy which will be released when someone (normally me) shorts the output by mistake.  The diodes D4 and D3 are protection diodes for the regulator IC.  They protect the regulator from short circuits and transients caused by capacitors discharging.  The resistor R5 and the LED are for indication purposes.  Its always good to have visual indication that the power supply is switched on!  The variable resistor R3 is to allow the user to vary the output voltage from 1.25V to about 40V.  R4 is part of the voltage divider which sets the output voltage.  C4 and C6 are ripple smoothing capacitors for the output.  Finally I added a voltmeter so that we can see what the output voltage is set at when using the circuit.

Well...thats it for now folks.  More to come soon!  Enjoy and take care - Alex