Motivation
After getting a new bicycle I have started thinking about making my own lights for it. I have been playing with electronics many years ago in my teen-age years, but I have been doing only software since then. So I have got this as an opportunity to find out what progress the world of DYI electronics has made, and to learn programming of microcontrollers. This page describes work in progress, don't expect a final solution yet.
Features
- LED drivers for high-power LEDs:
- Atmel AVR Tiny CPU, programmable in-system (various blinking modes, etc.).
- Power: 7 to 12 V battery pack (either lithium or NiMH).
- Ambient light sensor (for automatically setting the mode depending on the conditions).
- Battery voltage monitoring.
- Cycle computer illumination LED.
- Two status LEDs.
- Two buttons for adjusting modes, switching on/off, etc.
- Software on/off.
- High-power software switched output driven by a MOSFET transistor (I don't know the purpose yet, I just had a spare pin and MOSFET :-).
News
- 2012-10-29
- After thorough manual verification :-), I have sent the PCB gerber files to the fab. I have used iteadstudio 5x5 cm 2-layer service. Hopefully I did not miss anything important.
Source code repository
The project is licensed under GNU General Public License, version 2 (only). Here is the Git repository with schematics, datasheets, and firmware. You can browse the firmware source code (for Atmel AVR and GNU compiler toolchain), and schematics (designed using gEDA project). Feel free to send me comments, notes, or improvements. You can even clone the design and use it for your purposes, as long as the licensing conditions are met.
git clone https://www.fi.muni.cz/~kas/git/bike-lights.git
Schematics
The schematics has been designed using gschem from the gEDA suite, and is available here in the git repository.
PCB


These images have been generated by pcb program from the gEDA suite using this file.
Design notes
- CPU
- Atmel Tiny861a AVR, 1.8-5 V power input, DIL-20 package, three PWM channels, 8 KB program memory, 512 B RAM, many ADC channels and general-purpose I/O pins.
- Step-down converters
- Driven by Microchip MCP14628 synchronous buck driver (one PWM input, drives two MOSFETs). MOSFETs are International Rectifier IRL6372PBF (two "digital" transistors in a single SO-8 package). Current regulation is done by measuring voltage on a 0.033 Ω resistor serially connected to the LED. For the 2500 mA converter, a large 220 μH/2.5 A coil is used together with 47 μF electrolytic capacitor; the ADC for regulation works in single-ended mode. For the smaller converter, a smaller 470 uH/450 mA coil and a 10 μF ceramic capacitor is used, and the ADC works in differential mode.
- Step-up converter
- The MOSFET (one half of IRL6372PBF) is driven directly from the ATTiny pin. The converter contains a generic Schottky diode, a 470 uH/450 mA coil, and a 10 μF ceramic capacitor. Current regulation is also done by measuring voltage on a 0.033 Ω resistor by ATTiny ADC in differential mode.
- Power regulator
- The power source for the CPU is made from Microchip MCP1710AT +5V 250 mA low drop out, low idle current regulator. The power source can be disconnected using a jumper in order to avoid power leakage to the high-current parts during the in-system programming, which has its own power source.
- Ambient light sensor
- Vishay TEPT5700 photodiode is used as an ambient light sensor. In order to remain under the 1.1 V (the maximum value of ATTiny A/D converter in single-ended mode), it is accompanied by two resistors, so the voltage range is between about 0.25 and 1 V.
- Battery voltage sensor
- Made from 1M5 and 100K resistors, read by a single-ended ATTiny ADC pin.
Links, resources
- Mark Haun's LED bike light - a similar project to this one; for one LED, with a different step-down converter chip, creative-commons
- Buck converter page at Wikipedia
- Boost converter page at Wikipedia
- MCP 14628 synchronous buck driver datasheet
- ATTiny861a datasheet
- AVR libc homepage