3.1 Firmware Topology
The firmware is designed around three key .c files and their associated .h files.
The file MultiChemCharger_Main.c includes the following key routines in the main loop:
- Update_System_State routine – An overarching routine that evaluates the solar input voltage to determine whether the system should be running in Solar Charge mode, Sleep mode or LED Driver mode. External control input can override the default behavior as needed; however, charging constraints for input/output voltage must still be met, specifically that the solar voltage (Vsolar) must be greater than the battery voltage (Vbat).
- MPPT Tracking State Machine – Directs the process to achieve higher output power from the panel.
- Battery Charger State Machine –
Chemistry-specific state machines that properly charge multiple chemistry options
enabled through
#defineconfiguration statements. - Charger Protection Routines – Track the voltage, current, temperature and other parameters to ensure safe battery operation.
- LED Drive State Machine – Configures topology for Boost mode and controls soft-start and output current transitions up and down.
- ADC State Machine – Captures all analog signals.
- User Interface State Routine – Handles buttons, GUI and other interactions with the system.
- Serial Interface State Machine – Provides an I2C/SMBus client command and control interface.
The MultiChemCharger_Hardware.c file includes all hardware-specific routines as needed for each particular hardware platform. This includes the locations of the physical interfaces, methods to properly initialize, enable and increment/decrement power and safely shut down the power supply. Routines for implementing the storage of key parameters and calibration constants are also included. Each hardware implementation will have the option of using Flash, EEPROM or other methods for parameter storage.
The LED_Driver.c file includes routines to configure the hardware for LED mode, enable/disable LED output and set the requested brightness level. Both non-sync and synchronous LED driver modes are also provided depending on the efficiency of each mode when driving high output current.
The MultiChemCharger_Serial.c file includes the I2C/SMBus Client routines that allow the GUI to interface with the board. The Windows-based computer is the Host and the board is the Client. A state machine provides the interface to the I2C hardware registers and needs to be called regularly in the main loop to maintain sync with the Host.
All parameters found in these four .c files are implemented as #define
statements to allow for easy changes to system-wide parameters. Each of the associated
.h files includes the parameters along with one-line descriptions of their use.
