Close

Theory of Operation

A project log for BALT - Digital Barometric Altimeter

LCD Baro altimeter with climb, descent, vertical speed, & temperature.

brian-cornellBrian Cornell 02/05/2021 at 04:000 Comments

The design is based on Microchip's 8-bit, midrange, PIC16LF18326 MCU that controls all aspects of operation. The user interface consists of Display Visions 8-character transflective LCD display with integrated controller & character generator and two NO SPST tactile buttons. Altitude sensing uses TE Connectivity's MS5607-02BA03 barometric pressure & temperature sensor that incorporates a 24-bit Sigma-Delta ADC. The MCU uses SPI (400kHz) to communicate with the LCD and sensor.

The MCU boots when a battery is installed in the unit. The HFINTOSC is set to 16MHz for a 4MHz instruction clock. PIC peripheral & pin configuration is completed and all unused peripherals are disabled. The charge pump is started and after a delay the LCD and sensor are powered-up. The LCD is configured and the MCU status bits checked for stack over/under-flow and watchdog reset. If any of these conditions are true the LCD displays an error and the user must press the UP button to clear & reset. 

Otherwise, the sensor's calibration constants are retrieved and the CRC-4 checksum is calculated & compared to the retrieved value. A discrepancy will display an error and require the user to reset the unit with an UP button press. At the completion of a normal boot sequence the version & build number are displayed (MMmmBB) and the user must press the UP button to enter the RUN loop.

The RUN loop is a foreground infinite loop that controls display & sensor updates, user navigation (e.g. what is displayed, setup, backlight, etc.) and setup. The loop flow is:

The MS5607-02BA03 performs all pressure & temperature acqusition & conversion and presents a 24-bit value via SPI to the MCU. A set of second-order corrections are applied using the calibration constants and temperature compensation.

TI's LM2766 charge pump is used to double the battery voltage and On Semi's NCP508 LDO provides a stable 3.3V Vdd. Interestingly, TI's LDOs for these applications (at least the ones I reviewed) require a significant amount of ESR in the output bulk capacitance for stability which is why I selected the 508 (plus I had prior good experience with them). The enable pins of both are connected to the MCU thru a voltage divider that keeps the enable voltage to safe limits since the MCU's Vdd is higher. Schottky bypass diodes maintain Vdd at approximately battery voltage when the unit is in deep sleep (the MCU will operate down to ~ 1.9V and battery end-of-life voltage is ~ 2V).

10uF of bulk capacitance is used at the battery and at the LDO output to source the transient currents required when the MCU, sensor, and LCD power-up; without it is possible that Vdd would droop below the MCU's brown-out voltage causing a reset. Likewise, the bulk capacitance at the charge pump's input averages the current demand from the battery since pulse currents of more than a few milliamps dramatically shortens battery life.

The firmware maintains an interrupt driven system timer that provides chrono-time services when not in sleep. Timing is used to control display updates, deep sleep, and button debounce / interpretation (e.g. short press, long press, repeat). The ISR also services button presses using the IOC (Interrupt On Change) MCU feature. The unit is awakened from deep sleep using IOC. Last, the ISR manages backlight on/off & timing without intervention from the foreground RUN loop.

To conserve power, sample & display updates are performed approximately every four seconds. In between updates the MCU is placed in sleep and the WDT (Watch Dog Timer) wakes it (if the user is navigating or in setup the MCU does not sleep). The off timer (e.g. deep sleep) will expire when there is no navigation (e.g. button presses) and the MCU will place the unit in deep sleep: the LCD & sensor are powered off and then the charge pump & LDO disabled. Vdd drops to battery voltage, WDT is disabled, and the MCU goes to sleep. A button press wakes the MCU which first enables the charge pump & LDO and then powers-up the LCD & sensor. The resistor on the LCD/Sensor power pin protects the MCU's pin driver since it can only source ~ 50mA (the voltage drop during operation is immaterial since peak currents don't exceed 2mA).

Discussions