Main.AvrLightController History
Hide minor edits - Show changes to output
Changed lines 75-77 from:
!! Code
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive captured my notes and design decisions during development.
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive captured my notes and design decisions during development.
to:
!! Firmware
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. It is released under GPL v2 or later. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive captured my notes and design decisions during development.
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. It is released under GPL v2 or later. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive captured my notes and design decisions during development.
Changed line 139 from:
* [[http://nightbiken.de| NightBiken.de]] provides detailed information on Halogen Lights and tips for building huge LiPo battery packs. See the LUXILUS and LUXILUS TTR pages.
to:
* [[http://nightbiken.de| NightBiken.de]] provides detailed information (in German) on Halogen Lights and tips for building huge LiPo battery packs. See the LUXILUS and LUXILUS TTR pages.
Changed lines 139-140 from:
* [[http://nightbiken.de| NightBiken.de]] detailed information on Halogen Lights and tips for building a big battery packs. See the LUXILUS and LUXILUS TTR pages.
* [[http://www.mmuennich.de/ | Martin Muennich]] built a similar lightcontroler with an ATmega8 microcontroller, which he also sells in case you are interested in just buying one.
* [[http://www.mmuennich.de/ | Martin Muennich]] built a similar light
to:
* [[http://nightbiken.de| NightBiken.de]] provides detailed information on Halogen Lights and tips for building huge LiPo battery packs. See the LUXILUS and LUXILUS TTR pages.
* [[http://www.mmuennich.de/ | Martin Muennich]] built a similar light controller with an ATmega8 microcontroller, which he also sells in case you are interested in just buying one.
* [[http://www.mmuennich.de/ | Martin Muennich]] built a similar light controller with an ATmega8 microcontroller, which he also sells in case you are interested in just buying one.
Changed line 139 from:
* [[http://nightbiken.de]| NightBiken.de]] detailed information on Halogen Lights and tips for building a big battery packs. See the LUXILUS and LUXILUS TTR pages.
to:
* [[http://nightbiken.de| NightBiken.de]] detailed information on Halogen Lights and tips for building a big battery packs. See the LUXILUS and LUXILUS TTR pages.
Changed lines 122-123 from:
%center%'''Connectors: Charger, Halogen Light, and Remote Control. Power Switch between Light and Remote'''
to:
%center%'''Connectors from left to right: Charge, Halogen Light, and Remote Control. The Power Switch is placed between the Light and Remote Control connectors.'''
Changed line 103 from:
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box.
to:
As I wear the light on top of my bike helmet, the battery and the AVR Light Controller are stored in the backpack. In this setup, the remote control (button and LED) are clipped conveniently on the strap of the backpack, instead of dangling around near the light as it is common with commercial Lupine lights. The battery and light controller are packaged together into one box.
Changed line 94 from:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6V halogen light. The 3 cell configuration provides the voltage level for the BRIGHT mode almost until the battery is depleted (~7.5V).
to:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6V halogen light. The 3 cell configuration provides the voltage level for the '''bright''' mode almost until the battery is depleted (~7.5V).
Changed lines 97-98 from:
* The voltage level for dimmed and bright are set by VOLTAGE_BRIGHT and VOLTAGE_DIMMED respectively. Note that the VOLTAGE_BRIGHT is set higher to compensate for the voltage over the MOSFET. Also VOLTAGE_STEP_UP and VOLTAGE_STEP_DOWN determines the transition speed between differnt voltage levels. If you use a 12 volt battery, you should double both values.
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW, which in turn depend on NR_LIPO_CELLS. Just set the NR_LIPO_CELLS according to your battery. I've used the following setting for a single LiPo cell: Shut off below 2.5 V, emergency mode below 3.0 V - only the DIMMED mode can be used, battery low warning below 3.375 V.
to:
* The voltage levels for '''dimmed''' and '''bright''' mode are set by VOLTAGE_BRIGHT and VOLTAGE_DIMMED respectively. Note that the VOLTAGE_BRIGHT is set higher to compensate for the voltage drop on the MOSFET.
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW, which are a function of the number of LiPo cells, NR_LIPO_CELLS. Just set the NR_LIPO_CELLS according to your battery. I've used the following setting for a single LiPo cell: battery low warning below 3.375V, emergency mode below 3.0V in which only the '''dimmed''' mode can be used, automatic shut-off below 2.5V.
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW, which are a function of the number of LiPo cells, NR_LIPO_CELLS. Just set the NR_LIPO_CELLS according to your battery. I've used the following setting for a single LiPo cell: battery low warning below 3.375V, emergency mode below 3.0V in which only the '''dimmed''' mode can be used, automatic shut-off below 2.5V.
Changed lines 95-96 from:
If you want to use a different battery or a different light you need to check the following three settings:
* The voltage divider for battery measurement. The ATtiny can only measure up to 2.56 volts. If you need to adjust the divider you also have to adapt the conversion from measured voltage at the voltage divider to the battery voltage in measure_battery()
* The voltage divider for battery measurement.
to:
If you want to use a different battery or a different light you need to check the following three items:
* The voltage divider for battery measurement, i.e., resistors R1 and R2. The ATtiny can only measure up to 2.56 volts. If you change the divider, you also have to adapt the conversion factor from measured voltage to the battery voltage in measure_battery().
* The voltage divider for battery measurement, i.e., resistors R1 and R2. The ATtiny can only measure up to 2.56 volts. If you change the divider, you also have to adapt the conversion factor from measured voltage to the battery voltage in measure_battery().
Changed line 94 from:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6 Volt halogen light. The 3 cell configuration provides the voltage level for the BRIGHT mode almost until it's end.
to:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6V halogen light. The 3 cell configuration provides the voltage level for the BRIGHT mode almost until the battery is depleted (~7.5V).
Changed line 80 from:
Measuring the drain voltage was a bit tricky as the ADC conversion time is close to the PWM period. Fortunately, the ADC contains a sample-and-hold unit that samples precisely after 1.5 ADC clock cycles. With this, it is possible to setup the ADC and trigger the ADC such that it measures the voltage exactly in the middle of the ON part of the PWM.
to:
Measuring the drain voltage was a bit tricky as the ADC conversion time is close to the PWM period. Fortunately, the ADC contains a sample-and-hold unit that samples precisely after 1.5 ADC clock cycles. With this, it is possible to setup the ADC and trigger the ADC such that it measures the voltage exactly in the middle of the ON part of the PWM as depicted in the figure below.
Deleted lines 81-82:
%center% http://electronics.ringwald.ch/img/ADC-conversion.png
Added lines 83-85:
%center% http://electronics.ringwald.ch/img/ADC-conversion.png
\\
Changed line 82 from:
%center% '''Time diagram for correct measuring of V'_D_''''
to:
%center%'''Time diagram for correct measuring of V'_D_' '''
Changed line 82 from:
%center%'''Time diagram for correct measuring of V'_D_''''
to:
%center% '''Time diagram for correct measuring of V'_D_''''
Changed line 80 from:
%center% http://electronics.ringwald.ch/files/ADC-conversion.png
to:
%center% http://electronics.ringwald.ch/img/ADC-conversion.png
Changed lines 75-76 from:
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive documents all design decisions and captured my personal notes during
development.
development.
to:
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive captured my notes and design decisions during development.
Changed line 78 from:
Measuring the drain voltage was a bit tricky as the duration for an ADC is close to the PWM period. However, the ADC contains a sample-and-hold unit that samples precisely after 1.5 ADC clock cycles. With this, it is possible to setup the ADC and trigger the ADC such that it measures the voltage exactly in the middle of the ON part of the PWM.
to:
Measuring the drain voltage was a bit tricky as the ADC conversion time is close to the PWM period. Fortunately, the ADC contains a sample-and-hold unit that samples precisely after 1.5 ADC clock cycles. With this, it is possible to setup the ADC and trigger the ADC such that it measures the voltage exactly in the middle of the ON part of the PWM.
Added line 80:
%center% http://electronics.ringwald.ch/files/ADC-conversion.png
Changed lines 82-83 from:
to:
%center%'''Time diagram for correct measuring of V'_D_''''
\\
\\
\\
\\
Changed line 75 from:
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The summary.txt file in the archive documents all design decision and captured my personal notes during
to:
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit-banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The ''summary.txt'' file in the archive documents all design decisions and captured my personal notes during
Changed line 7 from:
In my case, I did already had a Sigma Mirage 6V/20 Watt bike light, but its lead-acid battery is crap, especially in winter when it's cold.
to:
In my case, I did already had a Sigma Mirage 6V/20W bike light, but its lead-acid battery is crap, especially in winter when it's cold.
Changed line 51 from:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Because the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volt a voltage divider consisting of R1 and R2 is used to reduce the battery voltage to 1/8.
to:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Because the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55V, a voltage divider consisting of R1 and R2 is used to reduce the battery voltage to 1/8.
Changed line 54 from:
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as it drops when the the light is turned on, and raises when it is turned off.
to:
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as it drops when the light is turned on, and raises when it is turned off by the PWM.
Changed line 57 from:
The 7805 together with C1 and C2 provide the 5 volt VCC for the ATtiny45 and is the reason why the power switch S1 is needed as it has an idle current of up to 5 mA. This is clearly something to change in a later design. I just did not have a better voltage regulator lying around at the time.
to:
The 7805 together with C1 and C2 provide the 5V VCC for the ATtiny45. As its idle current is up to 5 mA, the power switch S1 is needed. This is clearly something to change in a later design.
Changed line 63 from:
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET. R8 acts as pull-down to keep the light off if the ATtiny does not work.
to:
The N-channel MOSFET Q1 is used to implement the PWM, i.e., to switch the light on and off. R7 limits the current to the MOSFET. R8 acts as pull-down resistor to keep the light off when the ATtiny does not work.
Changed line 66 from:
R6 is used to measure the drain voltage of the MOSFET. If the halogen light is broken or gets disconnected the drain voltage goes to GND. With a working light, it toggles between V'_bat' and the small voltage resulting from the resistance of the MOSFET (for a 6V/20 Watt light, it is about 0.4 V for the IRF540).
to:
R6 is used to measure the drain voltage (V'_D_') of the MOSFET. If the halogen light is broken or gets disconnected, the drain voltage goes to GND. With a working light, V'_D_' toggles between V'_bat_' and the small voltage resulting from the resistance of the MOSFET (for a 6V/20W light, it is about 0.4V for the IRF540).
Changed line 26 from:
I've got the basic idea of using PWM for controlling the light light voltage by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his designs. Later versions of his initial design already include a Microchip PIC microcontroller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
to:
I've got the basic idea of using PWM for controlling the light voltage by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his designs. Later versions of his initial design already include a Microchip PIC microcontroller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
Changed lines 34-35 from:
* Soft transition between power levels.
* A remote control with a single button and an LED that can be attached for example to thefront of a bike pack.
* A remote control with a single button and an LED that can be attached for example to the
to:
* Smooth transition between power levels.
* A remote control with a single button and an LED that can be attached for example to the strap of a bike pack.
* A remote control with a single button and an LED that can be attached for example to the strap of a bike pack.
Changed line 23 from:
In this project, a microcontroller continuously measures the battery voltage level and calculate the duty cycle to achieve a desired output power.
to:
In this project, a microcontroller continuously measures the battery voltage level and calculates the duty cycle to achieve a desired output power.
Changed lines 19-20 from:
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in: \\
to:
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in: \\\
Added lines 20-22:
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in: \\
%center% duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
%center% duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
Changed lines 24-26 from:
%center% duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
to:
In this project, a microcontroller continuously measures the battery voltage level and calculate the duty cycle to achieve a desired output power.
Changed line 27 from:
to:
I've got the basic idea of using PWM for controlling the light light voltage by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his designs. Later versions of his initial design already include a Microchip PIC microcontroller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
Changed lines 30-34 from:
\\
\\
to:
Changed line 23 from:
duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
to:
%center% duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
Added lines 22-23:
duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
Deleted line 24:
Added line 26:
In this project, a microcontroller continuously measures the battery voltage level and calculate the duty cycle to achieve a desired output power.
Deleted line 27:
Added line 29:
I've got the basic idea of using PWM for controlling the light light voltage by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his designs. Later versions of his initial design already include a Microchip PIC microcontroller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
Deleted line 30:
Changed lines 32-34 from:
to:
Changed line 18 from:
This project is about building a power controller based on a small microcontroller, here the ATtiny45 was used. The desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (LiPo battery in this case). The duty cycle of the PWM determines the amount of power sent to a load (i.e., the halogen light).
to:
This project is about building a power controller based on a small microcontroller, here the ATtiny45 was used. The desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-Width Modulation (PWM)]] of a power source (LiPo battery in this case). The duty cycle of the PWM determines the amount of power sent to a load (i.e., the halogen light).
Changed line 57 from:
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as the it drops the moment the light is turned on, and raises when it is turned off.
to:
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as it drops when the the light is turned on, and raises when it is turned off.
Changed line 54 from:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
to:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Because the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volt a voltage divider consisting of R1 and R2 is used to reduce the battery voltage to 1/8.
Changed lines 39-40 from:
* The button on the remote allows to turn the light on. It further allows to toggle between BRIGHT and DIMMED power mode. Holding the button for a second turns the light off. * The control LED warns about low battery or when the light is not connected. Also, holding the input button when the light is off triggers the LED to show the battery voltage level.
to:
* The button on the remote allows to turn the light on. It further allows to toggle between BRIGHT and DIMMED power mode. Holding the button for a second turns the light off.
* The control LED warns about low battery or when the light is not connected. Also, holding the input button when the light is off triggers the LED to show the battery voltage level.
* The control LED warns about low battery or when the light is not connected. Also, holding the input button when the light is off triggers the LED to show the battery voltage level.
Changed line 29 from:
I've got the basic idea of a PWM Voltage Regulator by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
to:
I've got the basic idea of using PWM for controlling the light light voltage by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his designs. Later versions of his initial design already include a Microchip PIC microcontroller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
Changed line 26 from:
to:
In this project, a microcontroller continuously measures the battery voltage level and calculate the duty cycle to achieve a desired output power.
Changed line 18 from:
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. A desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (halogen light in this case). PWM controls the amount of power sent to a load by modulating the halogen light's duty cycle.
to:
This project is about building a power controller based on a small microcontroller, here the ATtiny45 was used. The desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (LiPo battery in this case). The duty cycle of the PWM determines the amount of power sent to a load (i.e., the halogen light).
Changed line 12 from:
Lithium-Polymer batteries provide enough power, but cannot be used directly with halogen lights. A two-cell LiPo battery (nominal 7.4V) provides about 8.5V when fully charged, and it is not allowed to be discharged below 5V. The halogen lights are usually designed for 6V or 12V. Their light power is controlled by the provided voltage level. While 8.5V voltage level can break the 6V halogen light, the light power at 5V is not good. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
to:
Lithium-Polymer batteries provide enough power, but cannot be used directly with halogen lights. A two-cell LiPo battery (nominal 7.4V) provides about 8.5V when fully charged, and it is not allowed to be discharged below 5V. Halogen lights are commonly designed for 6V or 12V and their light power is controlled by the provided voltage level. While an 8.5V voltage level can overheat and destroy a 6V halogen light, the emitted light at 5V is very low. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
Changed lines 18-22 from:
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used.
A desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (halogen light in this case). PWM controls the amount of power sent to a load by modulating the halogen light's duty cycle.
The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
A desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (halogen light in this case). PWM controls the amount of power sent to a load by modulating the halogen light's duty cycle
The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power
to:
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. A desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (halogen light in this case). PWM controls the amount of power sent to a load by modulating the halogen light's duty cycle.
Changed line 26 from:
to:
The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
Changed lines 29-30 from:
to:
I've got the basic idea of a PWM Voltage Regulator by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
\\
\\
\\
\\
Changed lines 18-22 from:
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
to:
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used.
A desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (halogen light in this case). PWM controls the amount of power sent to a load by modulating the halogen light's duty cycle.
The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
A desired output power can be achieved using [[http://en.wikipedia.org/wiki/Pulse-width_modulation|Pulse-width modulation (PWM)]] of a power source (halogen light in this case). PWM controls the amount of power sent to a load by modulating the halogen light's duty cycle.
The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
Changed line 25 from:
to:
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in:
Added line 27:
duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
Deleted line 28:
Changed line 30 from:
to:
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
Added line 34:
Changed line 12 from:
Lithium-Polymer batteries provide enough power, but cannot be used directly with halogen lights. A two-cell LiPo battery (nominal 7.4V) provides about 8.5V when fully charged, and it is not allowed to be discharged below 5V. The halogen lights are usually designed for 6V or 12V. Their light power is controlled by the provided voltage level. While 8.5V can break the 6V halogen light, the light power at 5 volt is not good. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
to:
Lithium-Polymer batteries provide enough power, but cannot be used directly with halogen lights. A two-cell LiPo battery (nominal 7.4V) provides about 8.5V when fully charged, and it is not allowed to be discharged below 5V. The halogen lights are usually designed for 6V or 12V. Their light power is controlled by the provided voltage level. While 8.5V voltage level can break the 6V halogen light, the light power at 5V is not good. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
Changed line 26 from:
duty cycle = V_eff'^2^' / V_bat'^2^'
to:
duty cycle = V'_eff_''^2^' / V'_bat_''^2^'
Changed line 12 from:
Lithium-Polymer batteries provide enough power, but should not be used with halogen lights. The light power of halogen lights is controlled by the provided voltage level. A 7.2 LiPo battery provides about 8.5 volts when fully charged and will go down to about 5 volts. While 8.5 volts can break the light, the light output at 5 volt is not good. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
to:
Lithium-Polymer batteries provide enough power, but cannot be used directly with halogen lights. A two-cell LiPo battery (nominal 7.4V) provides about 8.5V when fully charged, and it is not allowed to be discharged below 5V. The halogen lights are usually designed for 6V or 12V. Their light power is controlled by the provided voltage level. While 8.5V can break the 6V halogen light, the light power at 5 volt is not good. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
Changed lines 120-121 from:
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
to:
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 watt-hours'''
Changed lines 128-130 from:
* Lightbulb Voltage Regulator site of Willi Hunt
* Nightbike.de detailed information on Halogen Lights and tips for building the Halo
*...
*
to:
* [[http://www.cs.indiana.edu/~willie/lvr.html |Lightbulb Voltage Regulator]] site of Willi Hunt.
* [[http://nightbiken.de]| NightBiken.de]] detailed information on Halogen Lights and tips for building a big battery packs. See the LUXILUS and LUXILUS TTR pages.
* [[http://www.mmuennich.de/ | Martin Muennich]] built a similar light controler with an ATmega8 microcontroller, which he also sells in case you are interested in just buying one.
* [[http://nightbiken.de]| NightBiken.de]] detailed information on Halogen Lights and tips for building a big battery packs. See the LUXILUS and LUXILUS TTR pages.
* [[http://www.mmuennich.de/ | Martin Muennich]] built a similar light controler with an ATmega8 microcontroller, which he also sells in case you are interested in just buying one.
Added lines 125-130:
!! Links
* Lightbulb Voltage Regulator site of Willi Hunt
* Nightbike.de detailed information on Halogen Lights and tips for building the Halo
* ...
Changed line 93 from:
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box. Let's see the pictures...
to:
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box.
Added line 96:
Let's show the pictures...
Deleted lines 97-99:
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
Deleted lines 98-100:
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
Changed lines 100-102 from:
%center%'''Close-up of Remote Control'''
%center%http://electronics.ringwald.ch/img/avr-light-3.jpg
%center%
to:
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
Changed lines 104-106 from:
%center%'''Connectors: Charger, Halogen Light, and Remote Control. Power Switch between Light and Remote'''
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
%center% http://electronics.ringwald.ch/img/avr-light-
to:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
Changed lines 108-110 from:
%center%'''AVR Light Controller circuit'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
%center% http://electronics.ringwald.ch/img/avr-light-
to:
%center%'''Close-up of Remote Control'''
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
Changed lines 112-114 from:
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
%center% http://electronics.ringwald.ch/img/avr-light-
to:
%center%'''Connectors: Charger, Halogen Light, and Remote Control. Power Switch between Light and Remote'''
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
Added lines 116-123:
%center%'''AVR Light Controller circuit'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
\\
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
\\
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
\\
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
\\
Changed lines 93-95 from:
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box.
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
%center% http://electronics
to:
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box. Let's see the pictures...
Deleted lines 94-96:
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
Deleted lines 95-97:
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
Changed lines 97-99 from:
%center%'''Connectors: Charger, Halogen Light, and Remote Control. Power Switch between Light and Remote'''
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
%center% http:
to:
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
Changed lines 101-103 from:
%center%'''AVR Light Controller circuit'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
%center% http://electronics.ringwald.ch/img/avr-light-
to:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
Changed lines 105-107 from:
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
%center%http://electronics.ringwald.ch/img/avr-light-6.jpg
%center%
to:
%center%'''Close-up of Remote Control'''
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
Added lines 109-120:
%center%'''Connectors: Charger, Halogen Light, and Remote Control. Power Switch between Light and Remote'''
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
\\
%center%'''AVR Light Controller circuit'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
\\
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
\\
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
\\
%center%'''AVR Light Controller circuit'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
\\
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
\\
Changed lines 101-102 from:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
to:
%center%'''Close-up of Remote Control'''
Changed lines 105-106 from:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
to:
%center%'''Connectors: Charger, Halogen Light, and Remote Control. Power Switch between Light and Remote'''
Changed lines 109-110 from:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
to:
%center%'''AVR Light Controller circuit'''
Changed lines 113-114 from:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
to:
%center%'''11.1 V, 3270 mAh LiPo Battery => 36 Wh'''
Changed lines 117-122 from:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
to:
%center%'''Let there be light!'''
Changed line 95 from:
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg"Schematic for AVR Light Control V1.0"
to:
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
Changed lines 97-122 from:
to:
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-2.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-3.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-4.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-5.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-6.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg
\\
%center%'''Assembled AVR Light Controller with Sigma Mirage X'''
Changed line 95 from:
%center% http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0"
to:
%center% http://electronics.ringwald.ch/img/avr-light-1.jpg"Schematic for AVR Light Control V1.0"
Changed lines 84-85 from:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6 Volt halogen light. The 3 cell configuration provides the voltage level for the BRIGHT mode almost until it's end. If you want to use a different battery or a different light you need to check the following three settings:
to:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6 Volt halogen light. The 3 cell configuration provides the voltage level for the BRIGHT mode almost until it's end.
If you want to use a different battery or a different light you need to check the following three settings:
If you want to use a different battery or a different light you need to check the following three settings:
Changed lines 92-94 from:
!! Hardware Images
!! Building Tips
!! Building Tips
to:
!! Implementation
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box.
%center% http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0"
\\
%center%'''Schematic for AVR Light Control V1.0'''
As I wear the light on the head of my bike helmet, the battery and the AVR Light Controller goes into the backpack. In this setup the control button and LED and be put conveniently on the strap of the backpack instead of dangling around near the light as it is common with commercial Lupine lights. Also, as battery and light controller are in the same place, I've put them together into one box.
%center% http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0"
\\
%center%'''Schematic for AVR Light Control V1.0'''
Deleted lines 12-16:
!! Approach
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
Changed lines 15-18 from:
to:
!! Approach
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
Changed line 21 from:
to:
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
Added lines 23-25:
\\
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in:
\\
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in:
\\
Changed lines 27-29 from:
to:
\\
\\
\\
Deleted lines 35-38:
!! Schematic
The schematic for the AVR Light Controller is depicted below.
Changed lines 38-41 from:
to:
!! Schematic
The schematic for the AVR Light Controller is depicted below.
Deleted line 42:
Added line 44:
%center%[[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0" ]]
Changed line 46 from:
to:
%center%'''Schematic for AVR Light Control V1.0'''
Changed line 49 from:
to:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
Changed line 52 from:
to:
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as the it drops the moment the light is turned on, and raises when it is turned off.
Changed line 55 from:
to:
The 7805 together with C1 and C2 provide the 5 volt VCC for the ATtiny45 and is the reason why the power switch S1 is needed as it has an idle current of up to 5 mA. This is clearly something to change in a later design. I just did not have a better voltage regulator lying around at the time.
Changed line 58 from:
to:
R5, S2, and the LED make up the 'remote control'.
Changed line 61 from:
to:
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET. R8 acts as pull-down to keep the light off if the ATtiny does not work.
Added lines 64-66:
R6 is used to measure the drain voltage of the MOSFET. If the halogen light is broken or gets disconnected the drain voltage goes to GND. With a working light, it toggles between V'_bat' and the small voltage resulting from the resistance of the MOSFET (for a 6V/20 Watt light, it is about 0.4 V for the IRF540).
\\
\\
\\
\\
Changed lines 68-70 from:
to:
\\
\\
\\
Changed lines 78-79 from:
to:
\\
\\
\\
Changed lines 88-90 from:
to:
\\
\\
\\
Deleted line 1:
Added lines 4-6:
!! Motivation
\\
Deleted line 8:
Added lines 11-13:
!! Problem
\\
Added line 2:
!! Motivation
Deleted lines 4-6:
\\
\\
Added line 7:
!! Problem
Deleted lines 9-11:
\\
\\
Changed line 1 from:
! AVR Light Controller for LiPo/LiIo-Powered Halogen Bike Lights
to:
! AVR Light Controller for LiPo/LiIon-Powered Halogen Bike Lights
Deleted line 3:
Changed lines 5-6 from:
to:
\\
\\
\\
Changed lines 9-10 from:
to:
\\
\\
\\
Changed lines 12-13 from:
to:
\\
\\
\\
Changed line 75 from:
The constants in the code are for a 2 cell LiPo battery (nominal 7.4 V) and a 6 Volt halogen light. If you want to use a different battery or a different light you need to check the following three settings:
to:
The constants in the code are for a 3 cell LiPo battery (nominal 11.1 V) and a 6 Volt halogen light. The 3 cell configuration provides the voltage level for the BRIGHT mode almost until it's end. If you want to use a different battery or a different light you need to check the following three settings:
Changed lines 78-80 from:
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW. If you use a battery with higher voltage adapt it accordingly. I've used the following setting for a single LiPo cell: Shut off below 2.5 V, emergency mode below 3.0 V - only the DIMMED mode can be used, battery low warning below 3.375 V.
to:
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW, which in turn depend on NR_LIPO_CELLS. Just set the NR_LIPO_CELLS according to your battery. I've used the following setting for a single LiPo cell: Shut off below 2.5 V, emergency mode below 3.0 V - only the DIMMED mode can be used, battery low warning below 3.375 V.
Changed line 30 from:
* Soft transition between power levels
to:
* Soft transition between power levels.
Changed lines 2-4 from:
to:
\\
\\
\\
Changed lines 73-74 from:
!! General Configuration
to:
!! Configuration
Changed lines 64-65 from:
to:
The [[http://electronics.ringwald.ch/files/AVR-Light-v1.0.zip| firmware for the AVR Light Controller]] was developed with the standard AVR-GCC and AVR-LIBC. During development, a bit banging software UART was used to output debug messages over PB1, which is used for the LED in the final design. I hope the documentation of the source code is reasonable to understand its workings. In doubt, just ask. The summary.txt file in the archive documents all design decision and captured my personal notes during
development.
\\
\\
Measuring the drain voltage was a bit tricky as the duration for an ADC is close to the PWM period. However, the ADC contains a sample-and-hold unit that samples precisely after 1.5 ADC clock cycles. With this, it is possible to setup the ADC and trigger the ADC such that it measures the voltage exactly in the middle of the ON part of the PWM.
development.
\\
\\
Measuring the drain voltage was a bit tricky as the duration for an ADC is close to the PWM period. However, the ADC contains a sample-and-hold unit that samples precisely after 1.5 ADC clock cycles. With this, it is possible to setup the ADC and trigger the ADC such that it measures the voltage exactly in the middle of the ON part of the PWM.
Changed lines 73-81 from:
!!! Configuration
3 changes:
* voltage divider for battery measurement
* voltage level for dimmed and bright
* voltage level for battery
to:
The constants in the code are for a 2 cell LiPo battery (nominal 7.4 V) and a 6 Volt halogen light. If you want to use a different battery or a different light you need to check the following three settings:
* The voltage divider for battery measurement. The ATtiny can only measure up to 2.56 volts. If you need to adjust the divider you also have to adapt the conversion from measured voltage at the voltage divider to the battery voltage in measure_battery()
* The voltage level for dimmed and bright are set by VOLTAGE_BRIGHT and VOLTAGE_DIMMED respectively. Note that the VOLTAGE_BRIGHT is set higher to compensate for the voltage over the MOSFET. Also VOLTAGE_STEP_UP and VOLTAGE_STEP_DOWN determines the transition speed between differnt voltage levels. If you use a 12 volt battery, you should double both values.
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW. If you use a battery with higher voltage adapt it accordingly. I've used the following setting for a single LiPo cell: Shut off below 2.5 V, emergency mode below 3.0 V - only the DIMMED mode can be used, battery low warning below 3.375 V.
* The voltage divider for battery measurement. The ATtiny can only measure up to 2.56 volts. If you need to adjust the divider you also have to adapt the conversion from measured voltage at the voltage divider to the battery voltage in measure_battery()
* The voltage level for dimmed and bright are set by VOLTAGE_BRIGHT and VOLTAGE_DIMMED respectively. Note that the VOLTAGE_BRIGHT is set higher to compensate for the voltage over the MOSFET. Also VOLTAGE_STEP_UP and VOLTAGE_STEP_DOWN determines the transition speed between differnt voltage levels. If you use a 12 volt battery, you should double both values.
* The voltage level for battery warnings are defined by VOLTAGE_FULL, VOLTAGE_WARN, and VOLTAGE_LOW. If you use a battery with higher voltage adapt it accordingly. I've used the following setting for a single LiPo cell: Shut off below 2.5 V, emergency mode below 3.0 V - only the DIMMED mode can be used, battery low warning below 3.375 V.
Changed line 54 from:
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET.
to:
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET. R8 acts as pull-down to keep the light off if the ATtiny does not work.
Changed lines 77-81 from:
!! hardware images
!! building tips
... coming soon.
... coming soon.
to:
!! Hardware Images
!! Building Tips
!! Building Tips
Changed line 37 from:
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0" ]]
to:
%center%[[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0" ]]
Changed line 39 from:
%center% '''Schematic for AVR Light Control V1.0'''
to:
%center%'''Schematic for AVR Light Control V1.0'''
Changed line 39 from:
'''Schematic for AVR Light Control V1.0'''
to:
%center% '''Schematic for AVR Light Control V1.0'''
Changed lines 35-36 from:
to:
\\
\\
\\
Deleted lines 38-39:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
Changed line 41 from:
to:
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
Changed line 44 from:
to:
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as the it drops the moment the light is turned on, and raises when it is turned off.
Changed line 47 from:
to:
The 7805 together with C1 and C2 provide the 5 volt VCC for the ATtiny45 and is the reason why the power switch S1 is needed as it has an idle current of up to 5 mA. This is clearly something to change in a later design. I just did not have a better voltage regulator lying around at the time.
Changed line 50 from:
to:
R5, S2, and the LED make up the 'remote control'.
Changed line 53 from:
to:
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET.
Added lines 56-58:
R6 is used to measure the drain voltage of the MOSFET. If the halogen light is broken or gets disconnected the drain voltage goes to GND. With a working light, it toggles between V'_bat' and the small voltage resulting from the resistance of the MOSFET (for a 6V/20 Watt light, it is about 0.4 V for the IRF540).
\\
\\
\\
\\
Changed lines 34-39 from:
The schematic for the AVR Light Controller is depicted below. On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
to:
The schematic for the AVR Light Controller is depicted below.
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0" ]]
'''Schematic for AVR Light Control V1.0'''
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0" ]]
'''Schematic for AVR Light Control V1.0'''
On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
Changed lines 48-59 from:
By turning
When
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics
'''Schematic for AVR Light Control V1.0'''
Explain schematic here in detail
to:
R5, S2, and the LED make up the 'remote control'.
\\
\\
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET.
\\
\\
R6 is used to measure the drain voltage of the MOSFET. If the halogen light is broken or gets disconnected the drain voltage goes to GND. With a working light, it toggles between V'_bat' and the small voltage resulting from the resistance of the MOSFET (for a 6V/20 Watt light, it is about 0.4 V for the IRF540).
\\
\\
The ATiny45 only requires power supply as it runs from its internal 8 MHz oscillator.
\\
\\
The N-channel MOSFET Q1 is used to switch the light on and off. R7 limits the current to the MOSFET.
\\
\\
R6 is used to measure the drain voltage of the MOSFET. If the halogen light is broken or gets disconnected the drain voltage goes to GND. With a working light, it toggles between V'_bat' and the small voltage resulting from the resistance of the MOSFET (for a 6V/20 Watt light, it is about 0.4 V for the IRF540).
\\
\\
The ATiny45 only requires power supply as it runs from its internal 8 MHz oscillator.
Changed line 22 from:
to:
\\
Changed lines 25-31 from:
to:
!! Features
Beside controlling the output power, the use of a microcontroller allows for other goodies:
* Soft transition between power levels
* A remote control with a single button and an LED that can be attached for example to the front of a bike pack.
* The button on the remote allows to turn the light on. It further allows to toggle between BRIGHT and DIMMED power mode. Holding the button for a second turns the light off. * The control LED warns about low battery or when the light is not connected. Also, holding the input button when the light is off triggers the LED to show the battery voltage level.
Beside controlling the output power, the use of a microcontroller allows for other goodies:
* Soft transition between power levels
* A remote control with a single button and an LED that can be attached for example to the front of a bike pack.
* The button on the remote allows to turn the light on. It further allows to toggle between BRIGHT and DIMMED power mode. Holding the button for a second turns the light off. * The control LED warns about low battery or when the light is not connected. Also, holding the input button when the light is off triggers the LED to show the battery voltage level.
Added lines 34-49:
The schematic for the AVR Light Controller is depicted below. On the left side is the LiPo battery with a fuse and a switch to power off the circuit. Then R1/R2 are used as a voltage divider as the Analog-to-Digital-Convertor (ADC) of the ATtiny45 can only measure voltage levels up to 2.55 volts. At R3, about 1/8 of the battery voltage is available.
\\
\\
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as the it drops the moment the light is turned on, and raises when it is turned off.
\\
\\
The 7805 together with C1 and C2 provide the 5 volt VCC for the ATtiny45 and is the reason why the power switch S1 is needed as it has an idle current of up to 5 mA. This is clearly something to change in a later design. I just did not have a better voltage regulator lying around at the time.
\\
\\
By turning the light on/off
When the light is running at
\\
\\
R3 and C3 create a low-pass filter. Without this filter, the battery voltage is quite noisy as the it drops the moment the light is turned on, and raises when it is turned off.
\\
\\
The 7805 together with C1 and C2 provide the 5 volt VCC for the ATtiny45 and is the reason why the power switch S1 is needed as it has an idle current of up to 5 mA. This is clearly something to change in a later design. I just did not have a better voltage regulator lying around at the time.
\\
\\
By turning the light on/off
When the light is running at
Deleted line 16:
Added lines 18-20:
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [[http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
\\
\\
\\
\\
Changed lines 16-18 from:
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available] but not the source code for the firmware.
to:
\\
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
\\
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993]] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available]] but not the source code for the firmware.
\\
Changed lines 13-18 from:
!! Approach/Concept
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used.
Explain general PWMapproach together with effective Power (RMS)
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used.
Explain general PWM
to:
!! Approach
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available] but not the source code for the firmware.
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in:
duty cycle = V_eff'^2^' / V_bat'^2^'
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used. The basic approach is to use the microcontroller to continuously measure the battery voltage level and calculate the duty cycle to achieve a desired output power.
I've got the basic idea of a Pulse Width Modulated Voltage Regulator by a [http://www.cs.indiana.edu/~willie/lvr/doc |posting of Willie Hunt in 1993] who later commercialized his design. A later version already includes a PIC microchip controller. Schematics are [[http://www.cs.indiana.edu/~willie/lvr.html |available] but not the source code for the firmware.
The resulting effective power of the halogen light is calculated by integrating the applied power over time. With on/off modulation, this results in:
duty cycle = V_eff'^2^' / V_bat'^2^'
Changed lines 5-6 from:
Although super-bright LEDs will Let's start with the current schematic.
to:
Although super-bright LEDs are superior to halogen lights, as they are more energy-efficient and require smaller batteries, halogen lights are cheaper and easier to build.
In my case, I did already had a Sigma Mirage 6V/20 Watt bike light, but its lead-acid battery is crap, especially in winter when it's cold.
In my case, I did already had a Sigma Mirage 6V/20 Watt bike light, but its lead-acid battery is crap, especially in winter when it's cold.
Added lines 10-12:
Lithium-Polymer batteries provide enough power, but should not be used with halogen lights. The light power of halogen lights is controlled by the provided voltage level. A 7.2 LiPo battery provides about 8.5 volts when fully charged and will go down to about 5 volts. While 8.5 volts can break the light, the light output at 5 volt is not good. Therefore, a power controller is required that keeps the voltage supply constant for the halogen light.
Added lines 15-16:
This project is about building such a controller based on a small microcontroller, here the ATtiny45 was used.
Changed lines 1-2 from:
! AVR Light Controller for Halogen Bike Lights
to:
! AVR Light Controller for LiPo/LiIo-Powered Halogen Bike Lights
Changed lines 5-6 from:
Let's start with the current schematic.
to:
Although super-bright LEDs will Let's start with the current schematic.
Changed lines 1-4 from:
!!! AVR Light Controller for Halogen Bike Lights
! Motivation
! Motivation
to:
! AVR Light Controller for Halogen Bike Lights
!! Motivation
!! Motivation
Changed lines 7-10 from:
! Problem
! Approach/Concept
! Approach/Concept
to:
!! Problem
!! Approach/Concept
!! Approach/Concept
Changed line 13 from:
! Schematic
to:
!! Schematic
Changed lines 20-21 from:
! Code
to:
!! Code
Changed lines 24-25 from:
! General Configuration
to:
!! General Configuration
Changed lines 28-29 from:
! Configuration for 12 Volt Halogen Lights
to:
!!! Configuration for 12 Volt Halogen Lights
Changed lines 35-38 from:
! hardware images
! building tips
! building tips
to:
!! hardware images
!! building tips
!! building tips
Changed line 15 from:
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" ]]
to:
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-thumb.png"Schematic for AVR Light Control V1.0" ]]
Changed lines 14-18 from:
[[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | Schematic as PDF]]
to:
%center% [[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" ]]
'''Schematic for AVR Light Control V1.0'''
Changed lines 15-16 from:
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" '''Schematic for AVR Light Control V1.0''']]
to:
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" '''Schematic for AVR Light Control V1.0'''
Changed lines 15-16 from:
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" '''Schematic for AVR Light Control V1.0'''
to:
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" '''Schematic for AVR Light Control V1.0''']]
[[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | Schematic as PDF]]
[[http://electronics.ringwald.ch/files/AVR-Light-schematic.pdf | Schematic as PDF]]
Changed lines 15-16 from:
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png "Schematic for AVR Light Control V1.0" | '''Schematic for AVR Light Control V1.0'''
to:
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png"Schematic for AVR Light Control V1.0" '''Schematic for AVR Light Control V1.0'''
Added lines 3-37:
! Motivation
Let's start with the current schematic.
! Problem
! Approach/Concept
Explain general PWM approach together with effective Power (RMS)
! Schematic
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png "Schematic for AVR Light Control V1.0" | '''Schematic for AVR Light Control V1.0'''
Explain schematic here in detail
! Code
Link to code. Explain code functions.
! General Configuration
Explain user changes to the code
! Configuration for 12 Volt Halogen Lights
3 changes:
* voltage divider for battery measurement
* voltage level for dimmed and bright
* voltage level for battery warnings
! hardware images
! building tips
Let's start with the current schematic.
! Problem
! Approach/Concept
Explain general PWM approach together with effective Power (RMS)
! Schematic
%center%http://electronics.ringwald.ch/img/AVR-Light-640x480.png "Schematic for AVR Light Control V1.0" | '''Schematic for AVR Light Control V1.0'''
Explain schematic here in detail
! Code
Link to code. Explain code functions.
! General Configuration
Explain user changes to the code
! Configuration for 12 Volt Halogen Lights
3 changes:
* voltage divider for battery measurement
* voltage level for dimmed and bright
* voltage level for battery warnings
! hardware images
! building tips
Added lines 1-3:
!!! AVR Light Controller for Halogen Bike Lights
... coming soon.
... coming soon.