September 17, 2024

Biscotti firmware -- ADC and battery monitor

The code has some stuff (commented out) for temperature monitoring. It isn't clear what the idea here was, but this does not seem to be in any way functional. I don't read that the ATtiny13 has any kind of built in temperature sensor. The code was reading ADC4

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.59
These seem surprisingly low.
Feedback? Questions? Drop me a line!

Tom's Light Info / [email protected]