6
6
requests, patches, fan mail, hate mail, legal threats etc. to tido@4gh.eu
7
7
or join the discussion on the Budget Light Forum: http://budgetlightforum.cz.cc
10
This is the second alpha release of the BLF-VLD. It can be built in three
9
This is the third alpha release of the BLF-VLD. It can be built in three
11
10
configurations, namely simple, fixed and programmable modes. In simple mode,
12
11
the user can only use the standard modes configured at compile time. In fixed
13
12
and programmable mode, the user can switch from the main mode group to the
61
60
To enter programming mode, first choose the mode slot you wish to reassign and
62
61
stay in that mode for more than two seconds. Now change mode NUM_EXT_CLICKS
63
times in a row. The light will give two short blinks and enter the extended
62
times in a row. The light will give a short blink and enter the extended
64
63
mode group. Choose the mode you wish to assign and stay in it for more than
65
64
two seconds, then switch the light off. When switched on again, the light
66
will give two short blinks and you will have to lock in the new mode.
65
will give a short blink and you will have to lock in the new mode.
68
67
To acknowledge the programming, you will have to follow a timed sequence of
69
68
"taps". "Tapping" means turning the light on for only a short period of time.
72
71
driver has been compiled with the proghelper enabled, the light will signal
73
72
the appropriate moment to switch off by briefly rising or lowering the light
74
73
level, depending on the current light mode.
75
Setting up battery monitoring
76
=============================
78
Battery voltage monitoring is configured via the following #defines:
81
If defined, battery monitoring will be compiled into the driver.
84
Battery voltage is monitored via the analog-to-digital converter, which
85
returns a value in the range of 0 to 255. Low battery voltage handling
86
will be activated if the measured value is smaller than the one given here.
87
The actual threshold to use here depends on how the monitoring circuitry
88
is set up. See below for an explanation on how to calculate this value.
89
For most variants of the NANJG-101-AK, a threshold value of 130 will
93
PWM level to fall back to if a low battery situation is detected.
96
ADC channel to use, depending on which pin of the ATtiny13 is connected.
103
To make sure the ADC works correctly, the digital input for pin used for
104
measuring is explicitly disabled.
111
The ADC has to be clocked between 50kHz and 200kHz. The clock is generated
112
from the system clock and needs to be scaled down. For systems running at
113
4.8MHz or 9.6MHz a prescaler value of 64 is adequate, systems running at
114
1.2MHz will need a prescale factor of 32.
118
How to compute the low voltage threshold:
119
==========================================
121
Most driver PCBs sold by DX and KD contain the necessary circuitry to monitor
122
the battery's voltage (V_bat). This is done by using the ATtiny13's
123
analog-to-digital converter (ADC) and the internal 1.1V reference (V_ref).
124
To measure the battery's voltage, which is usually in the 3V-4V range, V_cc is
125
connected to the measuring pin via a voltage divider. This is necessary
126
because the ADC can only measure voltages smaller or equal to the reference.
128
As there usually is a diode in front of the µC to provide reverse polarity
129
protection, V_cc is 200mV to 600mV lower than V_bat. We will call this voltage
132
The voltage divider consists of two resistors in series, connecting V_cc to
133
ground. The voltage between the resistors is measured by the ADC and can be
134
expressed by the following formula:
136
V_adc = V_cc * (R2 / (R1 + R2))
138
The ADC is set to measure with 8 bit resolution in the range from 0V to V_ref.
139
The value returned by the ADC can be expressed by this formula:
141
val = 255 * (V_adc / V_ref);
143
By subsequently substituting V_adc and V_cc, we get the following formula:
145
val = ((V_bat - V_diode) * R2 * 255) / ((R1 + R2) * V_ref)
147
Now we can substitute the component values and the desired target voltage
148
to get the ADC value at which the battery alert should be triggered.
150
Example 1 (older NANJG-101-AK):
153
V_bat = 3V <= target voltage
157
val = ((3.0V - 0.6V) * 3kOhm * 255) / ((10kOhm + 3kOhm) * 1.1V) = 128
159
Example 2 (newer version):
166
val = ((3.0V - 0.2V) * 4.7kOhm * 255) / ((18kOhm + 4.7kOhm) * 1.1V) = 134