From: Jan "Yenya" Kasprzak Date: Fri, 3 May 2013 15:30:09 +0000 (+0200) Subject: step-up/README: detailed description of the project X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=aea7cb9af6c9ccd3c7dea1f5e5e71d4c3f6cc0bc;p=tinyboard.git step-up/README: detailed description of the project --- diff --git a/projects/step-up/README b/projects/step-up/README index a7a2a86..2d4c661 100644 --- a/projects/step-up/README +++ b/projects/step-up/README @@ -1,9 +1,29 @@ -Step-up converter with current feedback measurement. +Simple bike lights: + +Step-up converter with current feedback measurement +Battery voltage monitor +Status LED +Button CPU: ATtiny45 -Driven by PWM output OC1B (PB4 pin) with MOSFET. -Current feedback measured at ADC3 (PB3 pin). -Output on the PB4 header (pin 1 is negative, pin 2 is positive side). + +Step-up converter: + Driven by PWM output OC1B (PB4 pin) with MOSFET. + Current feedback measured at ADC3 (PB3 pin). + Output on the PB4 header (pin 1 is negative, pin 2 is positive side). +Battery voltage monitor: + Uses ADC1 (PB2 pin), voltage is divided using 1M5 and 100K resistors, + low-pass filter added on input (R30 capacitor, R32 resistor) +Status LED: + Uses PB1 pin, R22 resistor, positive side is PB1 header pin 2, + negative side is PB1 header pin 1 +Button: + Connected to PB0 header pin 2 using R12 0-Ohm link R12, + negative side is PB1 pin 1 (alternatively PB0 pin 1 could be + used instead - 0-Ohm link R15 needs to be added). Internal + pull-up resistor of ATtiny itself provides the voltage. + Pins 2 and 3 of PB2 header are shorted, and 100K resistor R3x + is added between pins 1 and 2. Bill of materials: @@ -14,18 +34,89 @@ D50 SS24 Schottky diode (SMB package, 40V, 2A) L50 470uH, 390mA, 200 mil pin distance (probably too big for 20mA LEDs :-) PB4 two-pin header soldered to pins 1 and 2 of PB4 Q50 IRLML6344TRPBF N-channel MOSFET, 30V, 5A, SOT-23 package -R40 220nF capacitor (not resistor!) +R30,R40 220nF capacitor (not resistor!) +R32 15K +R33 1M5 +R3x 100K (see above) R45 1K5 R50 15K -R51,R53 0R00 (zero-ohm link) +R12,R51,R53 0R00 (zero-ohm link) R55 3R0 (can safely measure currents from ~1 mA up, for higher currents use lower value) U1 ATtiny45-20SU U2 MCP1703T-5V +Pin-out: + +PB0 header: + 2: button + +PB1 header: + 2: status LED + + 1: status LED -, button - +PB4 header: + 2: LED string + + 1: LED string - + Firmware: The firmware is a dumbed-down version of firmware for my other project: http://www.fi.muni.cz/~kas/bike-lights/, modified for ATtiny45. + +Theory of operation: + +After power-up, the firmware sets up the CPU and powers it down, +waiting for a long button press. In this condition the system +takes about 8uA from the 9V battery. So a typical 500 mAh 9V battery +would last about 2604 days in this mode. + +When the button is pressed for a sufficiently long time, the CPU +wakes up, switches the status LED on (providing visual feedback), +and starts blinking. + +The firmware main loop is timed by ADC interrupt. It continuously measures +the voltage on R55 feedback resistor, and adjusts the PWM value on OC1B +to match the expected current through the LED string. Occasionally +the ADC is switched to the battery voltage sensing, and the battery +voltage is read. If the battery is critically low, the system +is switched to the power-saving light pattern (see below). + +The step-up converter has four target values of current (2 mA, +6 mA, 12 mA, and 20 mA as of this writing, see pwmled.c). The blinking pattern +is adjusted separately from the target value in the firmware. + +The firmware recognizes short and long button presses. The short one +cycles through all blinking modes, the long one switches the system off and on. + +The status LED has two blinking modes: +- in the normal one, it is off by default, and uses a series of + short switch-on blinks to display the battery voltage + (the number of blinks is voltage above 7V in 0.5V steps). +- when an error occurs, the status LED stays on by default, and displays + the error condition as a series of short switch-off blinks: + - one blink is a "power low" condition + - three blinks is "step-up error" (a LED string disconnected, + for example). +- when the long (-enough) button press is detected, i.e. when powering on + or off, the LED is switched on to provide a visual feedback + of long-enough button press. + +The blinking modes and patterns are currently set up as follows: +1. power-saving minimal mode + - a single short blink at minimum current +2. blinking mode 1 + - 2 and 3 blinks at the second-lowest current +3. blinking mode 2 + - 2 and 3 blinks at the third-lowest current +4. blinking mode 3 + - 2 and 3 blinks at the highest current +5. steady light at the minimum current +6. steady light at the second-lowest current +7. steady light at the third-lowest current +8. steady light at the highest current + +The system starts up set to mode 3, and switches to mode 1 when +the power is critically low. Other modes can be chosen via short +button press. +