![]() |
DC2100A
1.2.0
Bi-Directional Cell Balancer Using the LTC3300-1 and the LTC6804-2
|
Reference Application File for Controlling the LTC3300-1 Battery Balancers through the LTC6804-2 Battery Monitor on the DC2100A PCB. More...
Go to the source code of this file.
Reference Application File for Controlling the LTC3300-1 Battery Balancers through the LTC6804-2 Battery Monitor on the DC2100A PCB.
Definition in file Balancer.h.
Functions | |
| void | Balancer_Init (void) |
| Initializes the parts of the Balancer Module, that need to be initialized upon power-up of the PIC. More... | |
| BOOLEAN | Balancer_Wakeup_Init (void) |
| Initializes the parts of the Balancer Module, that need to be initialized upon wakeup of the LTC3300-1. More... | |
| void | Balancer_Control_Task (void) |
| Executes the Balancer Control task. More... | |
| void | Balancer_Set (void) |
| Places Balancer Control Task in the BALANCER_CONTROL_SETUP state. More... | |
| void | Balancer_Set (int8 board_num, BALANCER_ACTIVE_STATE_TYPE *cell_state_ptr) |
| void | Balancer_Set (BALANCER_DELTA_Q_TYPE *charge_target_ptr) |
| Places Balancer Control Task in the BALANCER_CONTROL_SETUP state. More... | |
| void | Balancer_Start (void) |
| Places Balancer Control Task in the BALANCER_CONTROL_ON state. More... | |
| void | Balancer_Stop (void) |
| Places Balancer Control Task in the BALANCER_CONTROL_OFF state immediately, as it's possible there's a catastrophic reason why we need to suspend,and resets the Balancer Control Task. More... | |
| void | Balancer_Suspend (void) |
| Places Balancer Control Task in the BALANCER_CONTROL_SUSPEND state immediately as it's possible there's a catastrophic reason why we need to suspend. More... | |
| void | Balancer_GUI (void) |
| Places Balancer Control Task in the BALANCER_CONTROL_GUI state, stopping all control of balancers by Balancer Control Task, and allows full control of LTC3300 ICs through direct commands from GUI. More... | |
| BOOLEAN | Balancer_Is_Balancing (void) |
| Returns if any balancer is actively balancing. More... | |
| void | Balancer_Synchronous_Mode_Set (BOOLEAN synchronous_mode) |
| Sets Balancer Control Task for synchronous or asynchronous mode. More... | |
| BOOLEAN | Balancer_Synchronous_Mode_Get (void) |
| Returns if Balancer Control Task is configured for synchronous mode. More... | |
| void | Balancer_Max_and_Nextstop_Find (void) |
| Forces recalculation of the longest and shortest (yet non-zero) active balance times in the DC2100A system. More... | |
Macros | |
Balancer Control Module Constants | |
| #define | BALANCER_TASK_RATE 250 |
| in ms, the rate at which the balancer control task is executed. More... | |
Balancer Current Constants | |
Nominal balance currents for DC2100A models, which can be A, B, C, or D. Note that calibrated balance currents use a scaled version of nominal to reduce RAM usage. | |
| #define | BALANCER_AB_CURRENT_CHARGE_12CELL 2600 |
| in mA, nominal charge balance current for cells with 12 cell secondary connections on a DC2100A-A or DC2100A-B More... | |
| #define | BALANCER_AB_CURRENT_DISCHARGE_12CELL 2400 |
| in mA, nominal discharge balance current for cells with 12 cell secondary connections on a DC2100A-A or DC2100A-B More... | |
| #define | BALANCER_AB_CURRENT_CHARGE_6CELL 2200 |
| in mA, nominal charge balance current for cells with 6 cell secondary connections on a DC2100A-A or DC2100A-B More... | |
| #define | BALANCER_AB_CURRENT_DISCHARGE_6CELL 2400 |
| in mA, nominal discharge balance current for cells with 6 cell secondary connections on a DC2100A-A or DC2100A-B More... | |
| #define | BALANCER_CD_CURRENT_CHARGE_12CELL 4000 |
| in mA, nominal charge balance current for cells with 12 cell secondary connections on a DC2100A-C or DC2100A-D More... | |
| #define | BALANCER_CD_CURRENT_DISCHARGE_12CELL 4300 |
| in mA, nominal discharge balance current for cells with 12 cell secondary connections on a DC2100A-C or DC2100A-D More... | |
| #define | BALANCER_CD_CURRENT_CHARGE_6CELL 3400 |
| in mA, nominal charge balance current for cells with 6 cell secondary connections on a DC2100A-C or DC2100A-D More... | |
| #define | BALANCER_CD_CURRENT_DISCHARGE_6CELL 4000 |
| in mA, nominal discharge balance current for cells with 6 cell secondary connections on a DC2100A-C or DC2100A-D More... | |
| #define | BALANCER_CURRENT_SCALE_FACTOR (1L << BALANCER_CURRENT_SCALE_FACTOR_SHIFT) |
| scale that calibration values are divided by to get a % of the nominal current value. More... | |
| #define | BALANCER_CURRENT_SCALE_FACTOR_SHIFT 8 |
| number of bits to shift for equivalant of division by BALANCER_CURRENT_SCALE_FACTOR More... | |
| #define | BALANCER_CURRENT_SCALE_CALC(desired_current, base_current) ((BALANCER_CURRENT_SCALE_FACTOR*(desired_current - base_current) + base_current/2) / base_current) |
| calculation of calibration current values More... | |
Typedefs | |
Balancer Passive State Structure | |
| typedef int16 | BALANCER_PASSIVE_STATE_TYPE |
| Bitmap for LTC6804_NUM_CELLV_ADC passive balancers on one DC2100A, 1 = ON and 0 = Off, bit 0 = cell 0. More... | |
| typedef signed int32 | BALANCER_DELTA_Q_TYPE |
| Data Type for amount of charge to move from a cell in mAs. More... | |
Enumerations | |
Balancer Control States | |
The Balancer Control Task can operate in one of the following states. | |
| enum | BALANCER_CONTROL_STATE_TYPE { BALANCER_CONTROL_OFF, BALANCER_CONTROL_GUI, BALANCER_CONTROL_SETUP, BALANCER_CONTROL_ON, BALANCER_CONTROL_SUSPEND } |
Variables | |
Active Cell Balancer State Variables | |
| BALANCER_ACTIVE_STATE_TYPE | Balancer_Active_State [DC2100A_MAX_BOARDS][DC2100A_NUM_CELLS] |
| The state of each active cell balancer on each DC2100A in the system. More... | |
| BALANCER_ACTIVE_STATE_TYPE | Balancer_Active_Time_Max |
| The longest active balance time in the DC2100A system. More... | |
| BALANCER_ACTIVE_STATE_TYPE | Balancer_Active_Time_Next_Stop |
| The shortest, yet non-zero, active balance time in the DC2100A system. More... | |
| int8 | Balancer_Active_Board_Max |
| The board with the longest remaining balance time. More... | |
| int8 | Balancer_Active_Board_Next_Stop |
| The cell with the shortest, yet non-zero, remaining balance time. More... | |
Passive Cell Balancer States | |
| BALANCER_PASSIVE_STATE_TYPE | Balancer_Passive_State [DC2100A_MAX_BOARDS] |
| Bitmap for LTC6804_NUM_CELLV_ADC passive balancers on one DC2100A, 1 = ON and 0 = Off, bit 0 = cell 0. More... | |
Balancer Active State Structures | |
This C structure contains the active balance command to be executed by the Balancer task in the BALANCER_CONTROL_ON state. Note that CCS gives the error "Number of bits is out of range" with the structure defined, so definitions are used to define the BALANCER_ACTIVE_STATE_TYPE packed structure manually. //! typedef struct{
//! int16 time : 15; // time to balance with BALANCER_TASK_RATE resolution.
//! int16 command : 1; // 0 for charge, 1 for discharge
//! } BALANCER_ACTIVE_STATE_TYPE;
//! | |
| #define | BALANCER_ACTIVE_STATE_COMMAND_BITS 1 |
| Size of bit field used to indicate charge and discharge. More... | |
| #define | BALANCER_ACTIVE_STATE_COMMAND_SHIFT 15 |
| Position of bit field used to indicate charge and discharge. More... | |
| #define | BALANCER_ACTIVE_STATE_COMMAND_MASK MASK(BALANCER_ACTIVE_STATE_COMMAND_BITS, BALANCER_ACTIVE_STATE_COMMAND_SHIFT) |
| Mask for bit field used to indicate charge and discharge. More... | |
| #define | BALANCER_ACTIVE_STATE_TIME_BITS 15 |
| Size of bit field used to hold time to balance. More... | |
| #define | BALANCER_ACTIVE_STATE_TIME_SHIFT 0 |
| Position of bit field used to hold time to balance. More... | |
| #define | BALANCER_ACTIVE_STATE_TIME_MASK MASK(BALANCER_ACTIVE_STATE_TIME_BITS, BALANCER_ACTIVE_STATE_TIME_SHIFT) |
| Mask for bit field used to hold time to balance. More... | |
| #define | BALANCER_ACTIVE_STATE_CHARGE 0 |
| 0 for charge More... | |
| #define | BALANCER_ACTIVE_STATE_DISCHARGE 1 |
| 1 for discharge More... | |
| #define | BALANCER_ACTIVE_STATE_COMMAND_SET(command, time) ((command << BALANCER_ACTIVE_STATE_COMMAND_SHIFT) + (time << BALANCER_ACTIVE_STATE_TIME_SHIFT)) |
| Macro to set active balancer command. More... | |
| typedef int16 | BALANCER_ACTIVE_STATE_TYPE |
| Size of structure used for balancer active state. More... | |
| void Balancer_Control_Task | ( | void | ) |
Executes the Balancer Control task.
Definition at line 168 of file Balancer.c.
| void Balancer_GUI | ( | void | ) |
Places Balancer Control Task in the BALANCER_CONTROL_GUI state, stopping all control of balancers by Balancer Control Task, and allows full control of LTC3300 ICs through direct commands from GUI.
Definition at line 570 of file Balancer.c.
| void Balancer_Init | ( | void | ) |
Initializes the parts of the Balancer Module, that need to be initialized upon power-up of the PIC.
Definition at line 120 of file Balancer.c.
| BOOLEAN Balancer_Is_Balancing | ( | void | ) |
Returns if any balancer is actively balancing.
Definition at line 576 of file Balancer.c.
| void Balancer_Max_and_Nextstop_Find | ( | void | ) |
Forces recalculation of the longest and shortest (yet non-zero) active balance times in the DC2100A system.
Definition at line 604 of file Balancer.c.
| void Balancer_Set | ( | void | ) |
Places Balancer Control Task in the BALANCER_CONTROL_SETUP state.
Does not change the active cell balancer states.
Definition at line 303 of file Balancer.c.
| void Balancer_Set | ( | BALANCER_DELTA_Q_TYPE * | charge_target_ptr | ) |
Places Balancer Control Task in the BALANCER_CONTROL_SETUP state.
Definition at line 331 of file Balancer.c.
| void Balancer_Start | ( | void | ) |
Places Balancer Control Task in the BALANCER_CONTROL_ON state.
Note that balancing is not started until the next state execution, to ensure that the balance times are accurately controlled to the BALANCER_TASK_RATE resolution.
Definition at line 539 of file Balancer.c.
| void Balancer_Stop | ( | void | ) |
Places Balancer Control Task in the BALANCER_CONTROL_OFF state immediately, as it's possible there's a catastrophic reason why we need to suspend,and resets the Balancer Control Task.
Definition at line 547 of file Balancer.c.
| void Balancer_Suspend | ( | void | ) |
Places Balancer Control Task in the BALANCER_CONTROL_SUSPEND state immediately as it's possible there's a catastrophic reason why we need to suspend.
Definition at line 562 of file Balancer.c.
| BOOLEAN Balancer_Synchronous_Mode_Get | ( | void | ) |
Returns if Balancer Control Task is configured for synchronous mode.
Definition at line 598 of file Balancer.c.
| void Balancer_Synchronous_Mode_Set | ( | BOOLEAN | synchronous_mode | ) |
Sets Balancer Control Task for synchronous or asynchronous mode.
| synchronous_mode | TRUE for synchronous mode, FALSE for asynchronous mode. |
Definition at line 592 of file Balancer.c.
| BOOLEAN Balancer_Wakeup_Init | ( | void | ) |
Initializes the parts of the Balancer Module, that need to be initialized upon wakeup of the LTC3300-1.
Definition at line 143 of file Balancer.c.
| #define BALANCER_AB_CURRENT_CHARGE_12CELL 2600 |
in mA, nominal charge balance current for cells with 12 cell secondary connections on a DC2100A-A or DC2100A-B
Definition at line 117 of file Balancer.h.
| #define BALANCER_AB_CURRENT_CHARGE_6CELL 2200 |
in mA, nominal charge balance current for cells with 6 cell secondary connections on a DC2100A-A or DC2100A-B
Definition at line 119 of file Balancer.h.
| #define BALANCER_AB_CURRENT_DISCHARGE_12CELL 2400 |
in mA, nominal discharge balance current for cells with 12 cell secondary connections on a DC2100A-A or DC2100A-B
Definition at line 118 of file Balancer.h.
| #define BALANCER_AB_CURRENT_DISCHARGE_6CELL 2400 |
in mA, nominal discharge balance current for cells with 6 cell secondary connections on a DC2100A-A or DC2100A-B
Definition at line 120 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_CHARGE 0 |
0 for charge
Definition at line 98 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_COMMAND_BITS 1 |
Size of bit field used to indicate charge and discharge.
Definition at line 92 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_COMMAND_MASK MASK(BALANCER_ACTIVE_STATE_COMMAND_BITS, BALANCER_ACTIVE_STATE_COMMAND_SHIFT) |
Mask for bit field used to indicate charge and discharge.
Definition at line 94 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_COMMAND_SET | ( | command, | |
| time | |||
| ) | ((command << BALANCER_ACTIVE_STATE_COMMAND_SHIFT) + (time << BALANCER_ACTIVE_STATE_TIME_SHIFT)) |
Macro to set active balancer command.
Definition at line 100 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_COMMAND_SHIFT 15 |
Position of bit field used to indicate charge and discharge.
Definition at line 93 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_DISCHARGE 1 |
1 for discharge
Definition at line 99 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_TIME_BITS 15 |
Size of bit field used to hold time to balance.
Definition at line 95 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_TIME_MASK MASK(BALANCER_ACTIVE_STATE_TIME_BITS, BALANCER_ACTIVE_STATE_TIME_SHIFT) |
Mask for bit field used to hold time to balance.
Definition at line 97 of file Balancer.h.
| #define BALANCER_ACTIVE_STATE_TIME_SHIFT 0 |
Position of bit field used to hold time to balance.
Definition at line 96 of file Balancer.h.
| #define BALANCER_CD_CURRENT_CHARGE_12CELL 4000 |
in mA, nominal charge balance current for cells with 12 cell secondary connections on a DC2100A-C or DC2100A-D
Definition at line 121 of file Balancer.h.
| #define BALANCER_CD_CURRENT_CHARGE_6CELL 3400 |
in mA, nominal charge balance current for cells with 6 cell secondary connections on a DC2100A-C or DC2100A-D
Definition at line 123 of file Balancer.h.
| #define BALANCER_CD_CURRENT_DISCHARGE_12CELL 4300 |
in mA, nominal discharge balance current for cells with 12 cell secondary connections on a DC2100A-C or DC2100A-D
Definition at line 122 of file Balancer.h.
| #define BALANCER_CD_CURRENT_DISCHARGE_6CELL 4000 |
in mA, nominal discharge balance current for cells with 6 cell secondary connections on a DC2100A-C or DC2100A-D
Definition at line 124 of file Balancer.h.
| #define BALANCER_CURRENT_SCALE_CALC | ( | desired_current, | |
| base_current | |||
| ) | ((BALANCER_CURRENT_SCALE_FACTOR*(desired_current - base_current) + base_current/2) / base_current) |
calculation of calibration current values
Definition at line 127 of file Balancer.h.
| #define BALANCER_CURRENT_SCALE_FACTOR (1L << BALANCER_CURRENT_SCALE_FACTOR_SHIFT) |
scale that calibration values are divided by to get a % of the nominal current value.
Definition at line 125 of file Balancer.h.
| #define BALANCER_CURRENT_SCALE_FACTOR_SHIFT 8 |
number of bits to shift for equivalant of division by BALANCER_CURRENT_SCALE_FACTOR
Definition at line 126 of file Balancer.h.
| #define BALANCER_TASK_RATE 250 |
in ms, the rate at which the balancer control task is executed.
Definition at line 64 of file Balancer.h.
| typedef int16 BALANCER_ACTIVE_STATE_TYPE |
Size of structure used for balancer active state.
Definition at line 91 of file Balancer.h.
| typedef signed int32 BALANCER_DELTA_Q_TYPE |
Data Type for amount of charge to move from a cell in mAs.
Definition at line 110 of file Balancer.h.
| typedef int16 BALANCER_PASSIVE_STATE_TYPE |
Bitmap for LTC6804_NUM_CELLV_ADC passive balancers on one DC2100A, 1 = ON and 0 = Off, bit 0 = cell 0.
Definition at line 105 of file Balancer.h.
Definition at line 70 of file Balancer.h.
| int8 Balancer_Active_Board_Max |
The board with the longest remaining balance time.
Definition at line 92 of file Balancer.c.
| int8 Balancer_Active_Board_Next_Stop |
The cell with the shortest, yet non-zero, remaining balance time.
Definition at line 93 of file Balancer.c.
| BALANCER_ACTIVE_STATE_TYPE Balancer_Active_State[DC2100A_MAX_BOARDS][DC2100A_NUM_CELLS] |
The state of each active cell balancer on each DC2100A in the system.
Definition at line 89 of file Balancer.c.
| BALANCER_ACTIVE_STATE_TYPE Balancer_Active_Time_Max |
The longest active balance time in the DC2100A system.
Definition at line 90 of file Balancer.c.
| BALANCER_ACTIVE_STATE_TYPE Balancer_Active_Time_Next_Stop |
The shortest, yet non-zero, active balance time in the DC2100A system.
Definition at line 91 of file Balancer.c.
| BALANCER_PASSIVE_STATE_TYPE Balancer_Passive_State[DC2100A_MAX_BOARDS] |
Bitmap for LTC6804_NUM_CELLV_ADC passive balancers on one DC2100A, 1 = ON and 0 = Off, bit 0 = cell 0.
Definition at line 94 of file Balancer.c.