The ATtiny13 has a 4 input 10 bit ADC. The Convoy has a voltage divider connected to pin 7 (which is ADC channel 1, or PB2). The voltage divider divides the battery voltage by 5, and there is also a diode drop before this divider, but I measure only 0.2 volts. Perhaps it is low because very little current is drawn.
Software can choose either a 1.1 volt reference or Vcc for a reference. Readings are scaled relative to the reference chosen. The biscotti software chooses the 1.1 volt reference -- which only makes sense if it wants to measure the battery voltage.
Software selects a prescale value of 6, but this does not scale the value, it is a divider on the system clock to generate the clock for the ADC. A value of 6 divides the system clock by 64.
Even though this is a 10 bit ADC, the software only reads the upper 8 bits from the ADCH register. It declares low battery when the value is less than ADC_LOW (ADC_30 = 133). A comment denotes another value as ADC_CRIT (ADC_27 = 120). The comment talks about shutting the light down, but the code never does based on this value. The shutdown is based on the ADC_LOW value and time spent while reducing light output.
If we figure
Vlow = (133/255) * 1.1 * 5 = 2.86 Vcrit = (120/255) * 1.1 * 5 = 2.59These seem surprisingly low.
Tom's Light Info / [email protected]