Decimus has one of the ADC inputs dedicated to monitoring the battery voltage. The batteries used in this micromouse are Lithium Polymer cells and it is particularly important that they are not allowed to discharge too far. Since the full battery voltage is about 7.4 Volts, this gets divided by four in a simple resistive divider before being sampled by the ADC.
Sampling is performed at every cycle. As soon as the battery voltage drops below the minimum safe level, the mouse will be placed in a warning state. Everything will be shut down except for a message on the LCD and a warning LED flash. The minimum safe value is chosen so that at least 5 minutes of warning state is possible. Should the battery voltage fall further to the absolute minimum safe level, the mouse will go into a complete power down to prevent excessive discharge of the battery.
During normal operation, the battery voltage can be displayed on the LCD as a reminder. The ADC is set to return 10 bit values and a full-scale reading of 1024 corresponds to the ADC reference voltage of 5 Volts. Taking into account the divide by four voltage divider, FSD at the ADC input would correspond to a battery voltage of 20 Volts with a possible resolution of 20mV or so. In practice, the ADC is not that accurate and there is little point in trying to resolve the battery voltage to better than 100mV. Thus, to indicate the battery voltage to the nearest 100 mV , the raw ADC value can be simply divided by 5. The result is a value, nominally in hundreds of millivolts so that an actual battery voltage of 7.2 Volts might be stored as the value 72. Easy for the operator to interpret and easy to display.