( https://www.instructables.com/ex/i/C2303A881DE510299AD7001143E7E506/ )
"????-- a project that uses another project as a stepping stone for further refinement, improvement, or application to a totally different problem. The community of DIYers that we're all a part of can really do some amazing things working together as a community. Innovation rarely happens in a vacuum. The obvious next step is to let the community help refine and evolve ideas that aren't yet ready to be finished projects."
We submit this now so that other iPod enthusiasts could pickup where we left off.
There are (at least) two reasons this charger _does not_ work:
1. The transistor doesn't let enough current flow to fully charge the inductor. The other option is a FET, but a FET needs a minimum of 5 volts to switch fully on. This is discussed in the SMPS section.
2. The inductor is simply not big enough. The charger doesn't produce nearly enough current for the iPod. We didn't have an accurate way to measure the iPod charging current (save cutting apart the origional charging cable) until our parts arrived from Mouser. The inductors recommended are nowhere near large enough for this project. A suitable substitution might be the coil Nick de Smith uses on his MAX1771 SMPS. Its a 2 or 3 amp coil from digikey:
( http://www.desmith.net/NMdS/Electronics/NixiePSU.html#bom )
This device can provide a small amount of power to a USB or firewire device, but not enough to charge an (3G) iPod. It WILL power, but not charge, a totally dead 3G iPod.
Step 1: Switch Mode Altoids IPOD Charger Using 3 'AA' Batteries
Standard disclaimers apply. High voltage....deadly...etc. Think about how much your iPod is worth to you before connecting it to this little stun gun in a tin can.
For all the math and dirty details of SMPS, read the nixie tube boost converter instructable:
Read on to see how the nixie tube SMPS design was adapted to be an iPod charger....
A ton of previous work inspired this project. One of the first DIY chargers used a combination of 9 volt and AA batteries to charge an iPod through the firewire port (works for all iPods, mandatory for 3G iPods):
This design has the problem of uneven discharge among the batteries. An updated version used only 9 volt batteries:
The design below appeared on Make and Hackaday while this instructable was written. It is a simple design for a 5 volt USB charger (this type will not charge earlier iPods, such as the 3G). It uses a 9 volt battery with a 7805 5 volt regulator. A stable 5 volts is provided, but the extra 4 volts from the battery is burned off as heat in the regulator.
All of these designs have one item in common: 9 volt batteries. I think 9 volters are wimpy and expensive. While researching for this instructable I noted that an 'Energizer' NiMH 9 volt is only rated 150 mAh. 'Duracell' doesn't make rechargeable 9 volters.
A 'Duracell' or 'Energizer' NiMH 'AA' has a healthy 2300 mAh of power, or more (up to 2700 mAh ratings on newer rechargeables). In a pinch, disposable alkaline AA batteries are available everywhere at a reasonable price. Using 3 'AA' batteries nets us 2700mAh at ~ 4 volts, compared to 150mAh at 9 or 18 (2x9 volts) volts. With this much power we can live with switching losses and extra energy eaten up by the SMPS microcontroller.
Step 2: SMPS
We want between 8 and 30 volts to charge an iPod through the firewire port. Lets design this SMPS for 12 volts output. This is not an immediately deadly voltage, but well within the firewire voltage range.
There are several single chip solutions that can boost the voltage from a few batteries to 12 (or more) volts. This project is NOT based on one of these. Instead, we will use a programmable microcontroller from Microchip, the PIC 12F683. This lets us design the SMPS with junk-box parts, and keeps us close to the hardware. A single chip solution would obfuscate most of the operation of the SMPS and promote vendor lock-in. The 8 pin PIC 12F682 was chosen for its small size and cost (less than $1). Any microcontroller can be used (PIC/AVR) that has a hardware pulse width modulator (PWM), two analog digital converters (ADC), and a voltage reference option (internal or external Vref). I love the 8 pin 12F683 and use it for everything. On occasion I have used it as a precision 8 Mhz external clock source for older PICs. I wish Microchip would send me a whole tube of them.
The device is battery powered. Battery discharge and temperature change will result in voltage drift. In order for the PIC to maintain a set output voltage (12 volts) a stable voltage reference is needed. This needs to be a very low voltage reference so it is effective over the range of output from 3 AA batteries. A 2.7 volt zener diode was originally planned, but the local electronics shop had a 2 volt "stabistor" diode. It was used the same as a zener reference, but inserted "backwards" (actually forwards). The stabistor seems to be quite rare (and expensive, ~0.75 euro cents), so we made a second version with a 2.5 volt reference from microchip (MCP1525). If you don't have access to the stabistor or Microchip (or other TO-92) reference, a 2.7 volt zener could be used.
There are two voltage feedback circuits that connect to ADC pins on the PIC. The first allows the PIC to sense output voltage. The PIC pulses the transistor in response to these measurements, maintaining a desired numerical reading on the ADC (I call this the 'set-point'). The PIC measures battery voltage through the second (I will call this supply voltage or Vsupply). Optimal inductor on-time depends on the supply voltage. The PIC firmware reads the ADC value and calculates the optimal on-time for the transistor and inductor (the period/duty cycle values of the PWM). It is possible to enter exact values into your PIC, but if the power supply is changed the values are no longer optimal. While running from batteries, the voltage will decrease as the batteries discharge, necessitating a longer on-time. My solution was to let the PIC calculate all of this and set its own values.
Both dividers were designed so that the range of voltages is well under the 2.5 volt reference. The supply voltage is divided by a 100K and 22K resistor, giving 0.81 at 4.5 volts (fresh batteries) to 0.54 at 3 volts (dead batteries). The output/high voltage is divided through 100K and 10K resistors (22K for USB output). We eliminated the trimmer resistor used in the nixie SMPS. This makes the initial adjustment a little spotty, but eliminates a large component. At 12 volts output the feedback is approximately 1 volt.
FETs are the standard 'switch' in SMPSs. FETs switch most efficiently at voltages higher than that supplied by 3 AA batteries. A Darlington transistor was used instead because it is a current switched device. The TIP121 has a gain of 1000 minimum Ã¢Â€Â“ any similar transistor can probably be used. A simple diode (1N4148) and resistor (1K) protect the PIC PWM pin from any stray voltage coming from the transistor base.
I am quite fond of the C&D power inductors available at Mouser. They are small and dirt cheap. For the USB version of the charger a 220uH inductor was used (22R224C). The firewire version uses a 680 uH inductor (22R684C). These values were chosen through experimentation. Theoretically, any value inductor should work if the PIC firmware is configured properly. In reality, however, the coil buzzed with values less than 680uH in the firewire version. This is probably related to the use of a transistor, instead of a FET, as the switch. I would greatly appreciate any expert advice in this area.
A cheap super/ultra fast 100 volt 1 amp rectifier from Mouser (see part list) was used. Other low voltage rectifiers can be used. Make sure your diode has a low forward voltage and fast recovery (30ns seems to work well). The right Schottky should work great, but watch out for heat, ringing, and EMI. Joe on the switchmode mailing list suggested: (website:http://groups.yahoo.com/group/switchmode/ )
"I think since Schottky's are faster and have high junction capacitance like you were saying, you could get a little more ringing and EMI. But, it would be more efficient. Hmm, I wonder if you used a 1N5820, the 20v breakdown could replace your Zener diode if you require low current for your Ipod."
Input/Output Capacitors and Protection
A 100uf/25v electrolytic input capacitor stores energy for the inductor. A 47uf/63v electrolytic and 0.1uf/50V metal film capacitor smooth the output voltage.
A 1 watt 5.1 volt zener is placed between the input voltage and ground. In normal use 3 AAs should never provide 5.1 volts. If the user manages to over power the board, the zener will clamp the supply to 5.1 volts. This will protect the PIC from damage Ã¢Â€Â“ until the zener burns out. A resistor could replace the jumper wire to make a true zener voltage regulator, but would be less efficient (see PCB section).
To protect the iPod, a 24 volt 1 watt zener diode was added between the output and ground. In normal use this diode should do nothing. If something goes horribly wrong (output voltage rises to 24) this diode should clamp the supply at 24 volts (well below the firewire max of 30 volts). The inductor used outputs max ~0.8 watts at 20 volts, so a 1watt zener should dissipate any excess voltage without burning out.
Step 3: PCB
This was a difficult PCB to design. There is limited space left in our tin after the volume of 3 AA batteries is deducted. The tin used is not a genuine altoids tin, it is a free box of mints promoting a website. It should be about the same size as an altoids tin. There were no Altoids tins to be found in the Netherlands.
A plastic battery holder from the local electronics shop was used to hold the 3 AA batteries. Leads were soldered directly to the clips on it. Power is supplied to the PCB through the two jumper holes, making battery placement flexible. A better solution might be some sort of nice PCB mountable battery clips. I haven't found these.
The LED is bent at 90 degrees to go out a hole in the tin. The TIP121 is also bent at 90 degrees, but not set flat!!!** A diode and two resistors are run under the transistor to save space. In the picture you can see that the transistor is bent, but soldered such that it floats one centimeter over the components. To avoid accidental shorts, cover this area with hot glue or a hunk of that rubbery stickie tack stuff. The MCP1525 voltage reference is located under the TIP121 in the MCP version of the PCB. It makes a very effective spacer. 3 components were put on the back side: the decoupling cap for the PIC, and the two large zeners (24 volt and 5.1volt). Only one jumper wire is needed (2 for the MCP version).
Unless you want to run the device continuously, put a small switch in-line with wire from the battery power to the circuit board. A switch was not mounted on the PCB to save space and keep placement flexible.
**Eagle has a routing restriction on the to-220 package that interrupts the ground plane. I used the library editor to remove the b-restrict and other layers from the TIP121 footprint. You could also add a jumper wire to solve this problem if you, like me, hate the eagle library editor. Inductor coil and modified to-220 footprint are in the Eagle library included in the project archive.
Part list (Mouser part number provided for some parts, others came out of the junk box):
Part Value (voltage ratings are minimum, bigger is okay)
C4 47uF/63V (mouser #140-XRL63V47, $0.10)
D1 Rectifier Diode SF12 (mouser #821-SF12 ), $0.22 -or- others
D2 1N4148 small signal diode (mouser #78-1N4148, $0.03)
D3 (Firewire) 24 Volt Zener/1 W (mouser #512-1N4749A , $0.09)
D3 (USB) 5.6 Volt Zener/1 W (mouser #78-1N4734A, $0.07)
D4 5.1 Volt Zener/1W (mouser #78-1N4733A , $0.07)
IC1 PIC 12F683 & 8 pin dip socket (socket optional/recommended, ~$1.00 total)
L1 (Firewire) 22R684C 680uH/0.25 amp inductor coil (mouser # 580-22R684C , $0.59)
L1 (USB) 22R224C 220uH/0.49amp inductor coil (mouser # 580-22R224C , $0.59)
LED1 5mm LED
Q1 TIP-121 Darlington driver or similar
R2 (Firewire) 10K
R2 (USB) 22K
R6 330 OHM
VREF1 Microchip MCP1525 (MCP version PCB) (mouser #579-MCP1525ITO, $0.55) -or-
2.7 volt/400ma zener with 10K resistor (R3) (zener reference version PCB) -or-
2 volt stabistor with 10K resistor (R3) (zener reference version PCB)
X1 Firewire/IEEE1394 6 pin right angle, horizontal PCB mount connector:
Kobiconn (mouser #154-FWR20, $1.85) -or-
EDAC (mouser #587-693-006-620-003, $0.93)
Step 4: FIRMWARE
Complete details of the SMPS firmware are outlined in the nixie SMPS instructable. For all the math and dirty details of SMPS, read my nixie tube boost converter instructable:
The firmware is written in MikroBasic, the compiler is free for programs up to 2K (http://www.mikroe.com/ ).
If you need a PIC programmer, consider my enhanced JDM2 programmer board also posted at instructables (https://www.instructables.com/ex/i/6D80A0F6DA311028931A001143E7E506/?ALLSTEPS ).
Basic firmware operation:
1.When power is applied the PIC starts.
2.PIC delays for 1 second to allow voltages to stabilize.
3.PIC reads the supply voltage feedback and calculates optimal duty cycle and period values.
4.PIC logs the ADC reading, duty cycle, and period values to the EEPROM. This allows some trouble shooting and helps diagnose catastrophic failures. EEPROM address 0 is the write pointer. One 4 byte log is saved each time the SMPS is (re-)started. The first 2 bytes are ADC high/low, third byte is lower 8 bits of duty cycle value, fourth byte is the period value. A total of 50 calibrations (200 bytes) are logged before the write pointer rolls over and starts again at EEPROM address 1. The most recent log will be located at pointer-4. These can be read out of the chip using a PIC programmer. The upper 55 bytes are left free for future enhancements.
5.PIC enters endless loop - high voltage feedback value is measured. If it is below the desired value the PWM duty cycle registers are loaded with the calculated value - NOTE: the lower two bits are important and must be loaded into CPP1CON<5:4>, upper 8 bits go into CRP1L. If the feedback is above the desired value, the PIC loads the duty cycle registers with 0. This is a 'pulse skip' system. I decided on pulse skip for two reasons: 1) at such high frequencies there isn't a lot of duty width to play with (0-107 in our example, much less at higher supply voltages), and 2) frequency modulation is possible, and gives a lot more room for adjustment (35-255 in our example), but ONLY DUTY IS DOUBLE BUFFERED IN HARDWARE. Changing the frequency while the PWM is operating can have 'strange' effects.
The firmware gets a few updates from the nixie tube SMPS version.
1.The pin connections are changed. One LED is eliminated, a single led indicator is used. Pin out is shown in the image. Descriptions in red are default PIC pin assignments that cannot be changed.
2.The analog digital converter is now referenced to an external voltage on pin 6, rather than the supply voltage.
3.As the batteries drain the supply voltage will change. The new firmware takes a supply voltage measurement every few minutes and updates the pulse width modulator settings. This "recalibration" keeps the inductor operating efficiently as the batteries discharge.
4.Internal oscillator set to 4 MHz, a safe operating speed to about 2.5 volts.
5.Fixed logging so nothing needs to be set in EEPROM to start at position 1 on a fresh PIC. Easier to grasp for beginners.
6.Inductor discharge time (off-time) is now calculated in firmware. The previous multiplier (one-third on-time) is inadequate for such small boosts. The only way to maintain efficiency throughout the battery discharge was to extend the firmware to calculate the true off-time. The modifications are experimental, but have since been incorporated into the final firmware.
From TB053 we find the off-time equation:
0=((volts_in-volts_out)/coil_uH)*fall_time + coil_amps
Mangle this to:
L_Ipeak is a constant already used in the firmware (see firmware section). Volts_in is already calculated to determine the inductor on-time. Volts_out is a known constant (5/USB or 12/Firewire). This should work for all positive values of V_out-V_in. If you get negative values, you have bigger troubles! All equations are calculated in the helper spreadsheet included with the NIXIE smps instructable.
The following line was added to the constants section of the firmware described in the CALIBRATION step:
const v_out as byte=5 'output voltage to determine off-time
Step 5: CALIBRATION
const v_out as byte=12 'output voltage to determine off-time, 5 USB, 12 Firewire
const v_ref as float=2.5 '2.5 for MCP1525, 1.72 for my stabistor, ~2.7 for a zener.
const supply_ratio as float=5.54 'supply ratio multiplier, calibrate for better accuracy
const osc_freq as float=4 'oscillator frequency
const L_Ipeak as float=170 'coil uH * coil amps continuous (680*0.25=170, round down)
const fb_value as word=447 'output voltage set point
These values can be found at the top of the firmware code. Find the values and set as follows:
This is the output voltage we want to achieve. This variable will NOT change the output voltage on its own. This value is used to determine the amount of time the inductor requires to fully discharge. It is an enhancement made to the USB firmware that was ported to the firewire version. Enter 12, that is our firewire target voltage (or 5 for USB). See the Firmware:Changes:Step6 for complete details of this addition.
This is the voltage reference of the ADC. This is needed to determine the actual supply voltage and calculate the inductor coil charge time. Enter 2.5 for the MCP1525, or measure the exact voltage. For a zener or stabistor reference, measure the exact voltage:
1.WITHOUT THE PIC INSERTED - Connect a wire from ground (socket PIN8) to socket pin 5. This prevents the inductor and transistor from heating while the power is on, but PIC is not inserted.
2.Insert batteries/turn on power.
3.Using a multimeter measure the voltage between the PIC voltage reference pin (socket PIN6) and ground (socket pin8). My exact value was 1.7 volts for the stabistor, and 2.5 volts for the MSP1525.
4.Enter this value as the v_ref constant in the firmware.
The supply voltage divider consists of a 100K and 22K resistor. Theoretically the feedback should equal the supply voltage divided by 5.58 (see Table 1. Supply Voltage Feedback Network Calculations). In practice, resistors have various tolerances and are not exact values. To find the exact feedback ratio:
4.Measure the supply voltage (Supply V) between socket pin 1 and ground (socket pin 8), or between the battery terminals.
5.Measure the supply feedback voltage (SFB V) between socket pin 3 and ground (socket pin 8).
6.Divide Supply V by SFB V to get an exact ratio. You can also use "Table 2. Supply Voltage Feedback Calibration".
7.Enter this value as the supply_FB constant in the firmware.
Simply the oscillator frequency. The 12F683 internal 8Mhz oscillator is divided by 2, a safe operating speed to about 2.5 volts.
8.Enter a value of 4.
Multiply the inductor coil uH by the maximum continuous amps to get this value. In the example the 22r684C is a 680uH coil with a rating of 0.25 amps continuous. 680*0.25=170 (round to lower integer if needed). Multiplying the value here eliminates one 32 bit floating point variable and calculation that would otherwise have to be done on the PIC. This value is calculated in "Table 3: Coil Calculations".
9.Multiply the inductor coil uH by the maximum continuous amps: 680uH coil with a rating of 0.25 amps continuous =170 (use next lowest integer â€“ 170).
10. Enter this value as the L_Ipeak constant in the firmware.
This is the actual integer value the PIC will use to determine if the high voltage output is above or below the desired level. We need to calculate this because we don't have a trimmer resistor for fine adjustment.
11.Use Table 4 to determine the ratio between the output and feedback voltage. (11.0)
12.Next, enter this ratio and your exact voltage reference in "Table 5. High Voltage Feedback ADC Set Value" to determine the fb_value. (447 with a 2.5 volt reference).
13.After you program the PIC, test the output voltage. You may need to make minor adjustments to the feedback set value and recompile the firmware until you get exactly 12 volts output.
Because of this calibration, the transistor and inductor should never become warm. Nor should you hear a ringing sound from the inductor coil. Both of these conditions indicate a calibration error. Check the data log in the EEPROM to help determine where your problem might be.
Step 6: TESTING
Step 7: VARIATIONS:USB
1.Swap in a USB 'A' type connector (mouser #571-7876161, $0.85)
2.Change the output voltage resistor divider (change R2 (10K) to 22K).
3.Change output protection zener (D3) to 5.6 volt 1 watt (mouser #78-1N4734A, $0.07). A 5.1 volt zener would be more exact, but zeners have error like resistors. If we try to hit a 5 volt target and our 5.1 volt zener has 10% error on the low side, all our efforts will burn up in the zener.
4.Change inductor coil (L1) to 220uH, 0.49amp (mouser # 580-22R224C , $0.59). Enter new calibration constants, as per the calibration section: Set V_out to 5 volts. Step 8&9: L_Ipeak=220*0.49=107.8=107 (round to next lowest integer, if required).
5.Modify the output set point, recalculate Table 4 and Table 5 in the spreadsheet. Table 4 â€“ enter 5 volts as the output and replace the 10K resistor with 22K (as per step 2). We find that at 5 volts output, with a 100K/22K divider network, feedback (E1) will be 0.9 volts. Next, make any change to the voltage reference in Table 5, and find the ADC set point. With a 2.5 volt reference (MCP1525) the setpoint is 369.
6.Sample constants for USB version:
const v_out as byte=5 'output voltage to determine off-time, 5 USB, 12 Firewire
const v_ref as float=2.5 '2.5 for MCP1525, 1.72 for my stabistor, ~2.7 for a zener.
const supply_ratio as float=5.54 'supply ratio multiplier, calibrate for better accuracy
const osc_freq as float=4 'oscillator frequency
const L_Ipeak as float=107 'coil uH * coil amps continuous (220*0.49=107, round down)
const fb_value as word=369 'output voltage set point
Firmware and PCB for the USB version are included in the project archive. Only the MCP voltage reference version was converted to USB.