3-Stage SLA Battery Charger Source Code With STM32103C8
Budget: $10 – $30 USD
NOTE: Only the firmware (Source Code), is needed from the developer. The schematic is for the developer’s reference.
This project is to write a C program that will facilitate 20A Lead Acid Battery Charger using Step-Up DC-DC converter. STM32F103C8, the BluePill, will be used as the controlling MCU.
FEATURES:
1. BluePill pins are used according to the Schematic diagram.
2. The PWM Duty Cycle will start and rise slowly (Soft Start)
3. 3-Stage Charging Algorithm modes namely: Bulk Stage, Absorption Stage and Float Stage.
4. PA6 is the TIM1_BRK pin, it is tied to PA4. TIM1_BRK pin is set in rising edge. In case for any reasons, the battery rises to 32V or POWER (current*battery), rises to >= 600Watts, the pin PA4 will go HIGH and timer1 will break and the PWM will stop immediately. Then if it comes down to 28V and POWER < 600Watts, the pin PA4 will automatically go LOW and the PWM will resume automatically.
5. Serial Monitor displays the Battery, current, power and the PWM Value
6. PWM frequency will be within 20-25 KHz. Any frequency configuration between 20KHz to 25Khz is accepted. The PWM frequency is fixed.
7. I expect non-blocking delays in the program.
8. Current control with INA138 configured for x50 Gain. The Shunt resistance is 0.0006Ω
// INA138 reference current calculation
#define current_scale 0.026862027 // (3.3V/4095)/50/0.0006 Ohms)//*50 Gain
Float current = ADC*current_scale; // For gain 50 we get 3V at Imax of 100A
DEVELOPMENT PLATFORM
Device initialization: STM32CubeMX
Toolchain: Keil uVision5
HAL_Library.
Some pictures are uploaded for reference.
This project is to write a C program that will facilitate 20A Lead Acid Battery Charger using Step-Up DC-DC converter. STM32F103C8, the BluePill, will be used as the controlling MCU.
FEATURES:
1. BluePill pins are used according to the Schematic diagram.
2. The PWM Duty Cycle will start and rise slowly (Soft Start)
3. 3-Stage Charging Algorithm modes namely: Bulk Stage, Absorption Stage and Float Stage.
4. PA6 is the TIM1_BRK pin, it is tied to PA4. TIM1_BRK pin is set in rising edge. In case for any reasons, the battery rises to 32V or POWER (current*battery), rises to >= 600Watts, the pin PA4 will go HIGH and timer1 will break and the PWM will stop immediately. Then if it comes down to 28V and POWER < 600Watts, the pin PA4 will automatically go LOW and the PWM will resume automatically.
5. Serial Monitor displays the Battery, current, power and the PWM Value
6. PWM frequency will be within 20-25 KHz. Any frequency configuration between 20KHz to 25Khz is accepted. The PWM frequency is fixed.
7. I expect non-blocking delays in the program.
8. Current control with INA138 configured for x50 Gain. The Shunt resistance is 0.0006Ω
// INA138 reference current calculation
#define current_scale 0.026862027 // (3.3V/4095)/50/0.0006 Ohms)//*50 Gain
Float current = ADC*current_scale; // For gain 50 we get 3V at Imax of 100A
DEVELOPMENT PLATFORM
Device initialization: STM32CubeMX
Toolchain: Keil uVision5
HAL_Library.
Some pictures are uploaded for reference.
Related categories:
C Programming
Electronics
Microcontroller
Electrical Engineering
C++ Programming