]> www.fi.muni.cz Git - tinyboard.git/blob - projects/step-up/README
Experimental step-up driver for chain of 5630 LEDs.
[tinyboard.git] / projects / step-up / README
1 Simple bike lights:
2
3 Step-up converter with current feedback measurement
4 Battery voltage monitor
5 Status LED
6 Button
7
8 CPU: ATtiny45
9
10 Step-up converter:
11         Driven by PWM output OC1B (PB4 pin) with MOSFET.
12         Current feedback measured at ADC3 (PB3 pin).
13         Output on the PB4 header (pin 1 is negative, pin 2 is positive side).
14 Battery voltage monitor:
15         Uses ADC1 (PB2 pin), voltage is divided using 1M5 and 100K resistors,
16                 low-pass filter added on input (R30 capacitor, R32 resistor)
17 Status LED:
18         Uses PB1 pin, R22 resistor, positive side is PB1 header pin 2,
19                 negative side is PB1 header pin 1
20 Button:
21         Connected to PB0 header pin 2 using R12 0-Ohm link R12,
22         negative side is PB1 pin 1 (alternatively PB0 pin 1 could be
23         used instead - 0-Ohm link R15 needs to be added). Internal
24         pull-up resistor of ATtiny itself provides the voltage.
25         Pins 2 and 3 of PB2 header are shorted, and 100K resistor R3x
26         is added between pins 1 and 2.
27
28
29 Bill of materials:
30
31 C1,C2   1.5uF tantalum
32 C3,C51  10uF ceramic
33 D50     SS24 Schottky diode (SMB package, 40V, 2A)
34 L50     470uH, 390mA, 200 mil pin distance (probably too big for 20mA LEDs :-)
35 PB4     two-pin header soldered to pins 1 and 2 of PB4
36 Q50     IRLML6344TRPBF N-channel MOSFET, 30V, 5A, SOT-23 package
37 R30,R40 220nF capacitor (not resistor!)
38 R32     15K
39 R33     1M5
40 R3x     100K (see above)
41 R45     1K5
42 R50     15K
43 R12,R51,R53     0R00 (zero-ohm link)
44 R55     3R0 (can safely measure currents from ~1 mA up, for higher currents use lower value)
45 U1      ATtiny45-20SU
46 U2      MCP1703T-5V
47
48
49 Pin-out:
50
51 PB0 header:
52         2: button +
53 PB1 header:
54         2: status LED +
55         1: status LED -, button -
56 PB4 header:
57         2: LED string +
58         1: LED string -
59
60 Firmware:
61
62 The firmware is a dumbed-down version of firmware for my other
63 project: http://www.fi.muni.cz/~kas/bike-lights/, modified
64 for ATtiny45.
65
66
67 Theory of operation:
68
69 After power-up, the firmware sets up the CPU and powers it down,
70 waiting for a long button press. In this condition the system
71 takes about 8uA from the 9V battery. So a typical 500 mAh 9V battery
72 would last about 2604 days in this mode.
73
74 When the button is pressed for a sufficiently long time, the CPU
75 wakes up, switches the status LED on (providing visual feedback),
76 and starts blinking.
77
78 The firmware main loop is timed by ADC interrupt. It continuously measures
79 the voltage on R55 feedback resistor, and adjusts the PWM value on OC1B
80 to match the expected current through the LED string. Occasionally
81 the ADC is switched to the battery voltage sensing, and the battery
82 voltage is read. If the battery is critically low, the system
83 is switched to the power-saving light pattern (see below).
84
85 The step-up converter has four target values of current (2 mA,
86 6 mA, 12 mA, and 20 mA as of this writing, see pwmled.c). The blinking pattern
87 is adjusted separately from the target value in the firmware.
88
89 The firmware recognizes short and long button presses. The short one
90 cycles through all blinking modes, the long one switches the system off and on.
91
92 The status LED has two blinking modes:
93 - in the normal one, it is off by default, and uses a series of
94         short switch-on blinks to display the battery voltage
95         (the number of blinks is voltage above 7V in 0.5V steps).
96 - when an error occurs, the status LED stays on by default, and displays
97         the error condition as a series of short switch-off blinks:
98         - one blink is a "power low" condition
99         - three blinks is "step-up error" (a LED string disconnected,
100                 for example).
101 - when the long (-enough) button press is detected, i.e. when powering on
102         or off, the LED is switched on to provide a visual feedback
103         of long-enough button press.
104
105 The blinking modes and patterns are currently set up as follows:
106 1. power-saving minimal mode
107         - a single short blink at minimum current
108 2. blinking mode 1
109         - 2 and 3 blinks at the second-lowest current
110 3. blinking mode 2
111         - 2 and 3 blinks at the third-lowest current
112 4. blinking mode 3
113         - 2 and 3 blinks at the highest current
114 5. steady light at the minimum current
115 6. steady light at the second-lowest current
116 7. steady light at the third-lowest current
117 8. steady light at the highest current
118
119 The system starts up set to mode 3, and switches to mode 1 when
120 the power is critically low. Other modes can be chosen via short
121 button press.
122