64 #include "USB_Parser.h"
71 #define VOLTAGE_VUV_DEFAULT (2.50 * UV_PER_V/LTC6804_VOLTAGE_RESOLUTION)
72 #define VOLTAGE_VOV_DEFAULT (4.50 * UV_PER_V/LTC6804_VOLTAGE_RESOLUTION)
73 #define VOLTAGE_UVOV_CONVERSION (LTC6804_UVOV_RESOLUTION/LTC6804_VOLTAGE_RESOLUTION)
74 #define VOLTAGE_UVOV_ROUND_MASK (VOLTAGE_UVOV_CONVERSION - 1)
76 #define VOLTAGE_PROCESSING_DURING_DELAY 50 // Estimated number of microseconds that we can avoid waiting, due to processing done during ADC conversion
81 unsigned int16
voltage_cell[DC2100A_MAX_BOARDS][DC2100A_NUM_CELLS];
99 void voltage_error_adc_clear(int8 board_num);
142 int8 board_num, cell_num;
143 unsigned int16 voltage_temp[DC2100A_NUM_CELLS];
144 int16 vov_flags, vuv_flags;
145 BOOLEAN suspend_sent;
146 BOOLEAN results_clear;
163 suspend_sent = FALSE;
167 #if (LTC6804_CONVERSIONS_ALL_7KHZ_DELAY > VOLTAGE_PROCESSING_DURING_DELAY)
173 for (board_num = 0; board_num < System_Num_Boards; board_num++)
176 results_clear = FALSE;
184 for(cell_num = 0; cell_num < DC2100A_NUM_CELLS; cell_num++)
188 voltage_cell[board_num][cell_num] = voltage_temp[cell_num];
193 results_clear = TRUE;
199 if(results_clear == FALSE)
205 voltage_error_adc_clear(board_num);
209 if((System_Powered_Up() == TRUE) && (results_clear == FALSE))
223 if(vov_flags || vuv_flags)
227 if(suspend_sent == FALSE)
239 USB_Parser_Board_Vov_Vuv_Async(board_num);
251 BOOLEAN write_successful;
252 unsigned int16 vuv_value_temp, vov_value_temp;
257 vov_value = (vov_value / VOLTAGE_UVOV_CONVERSION) - (vov_value & VOLTAGE_UVOV_ROUND_MASK ? 1 : 0);
258 vuv_value = (vuv_value / VOLTAGE_UVOV_CONVERSION) + (vuv_value & VOLTAGE_UVOV_ROUND_MASK ? 1 : 0);
264 write_successful = TRUE;
265 for (board_num = 0; board_num < System_Num_Boards; board_num++)
268 if((vuv_value_temp != vuv_value) || (vov_value_temp != vov_value))
270 write_successful = FALSE;
278 return write_successful;
286 void voltage_error_adc_clear(int8 board_num)
288 int8 temp_data[ERROR_DATA_SIZE];
289 temp_data[0] = board_num;
294 Error_Data_Set(ERROR_CODE_LTC6804_ADC_CLEAR, temp_data, 5);
BOOLEAN LTC6804_UVOV_Flags_Get(int8 board_num, int16 *vuv_flags, int16 *vov_flags)
Gets the LTC6804 flags indicating under-voltage and over-voltage conditions are present.
BOOLEAN Voltage_Wakeup_Init(void)
Initializes the parts of the Voltage Module, that need to be initialized upon wakeup of the LTC6804...
BOOLEAN LTC6804_UVOV_Thresholds_Get(int8 board_num, unsigned int16 *vuv_value, unsigned int16 *vov_value)
Gets the LTC6804 under-voltage and over-voltage thresholds in LTC6804_UVOV_RESOLUTION units...
unsigned int16 voltage_ov_flags[DC2100A_MAX_BOARDS]
Bitmap indicating if a cell input on the LTC6804 is over-voltage (1) or not (0).
void LTC6804_UVOV_Thresholds_Set(int8 board_num, int16 vuv_value, int16 vov_value)
Sets the LTC6804 under-voltage and over-voltage thresholds in LTC6804_UVOV_RESOLUTION units...
void Balancer_Suspend(void)
Places Balancer Control Task in the BALANCER_CONTROL_SUSPEND state immediately as it's possible there...
#define LTC6804_BROADCAST
Code for application code to indicate an LTC6804 command is to be broadcast to all boards...
BOOLEAN Balancer_Is_Balancing(void)
Returns if any balancer is actively balancing.
#define LTC6804_ADC_CLEAR
ADC Value returned when results are cleared, but not retaken.
BOOLEAN LTC6804_Cell_ADC_Read(int8 board_num, LTC6804_CH_CELL_TYPE cell_select, unsigned int16 *adc_value_ptr)
Reads the LTC6804 Cell Voltage ADC conversion results.
unsigned int8 voltage_balancestamp
1 if balancers were on when these measurements were taken, otherwise 0
void LTC6804_Cell_ADC_Start(int8 board_num, LTC6804_CONVERSION_MODE_T mode, LTC6804_CH_CELL_TYPE cell_select, BOOLEAN discharge_permitted)
Starts the LTC6804 Cell Voltage ADC conversion at the specified conversion mode.
void LTC6804_Cell_ADC_Clear(int8 board_num)
Clears the LTC6804 Cell Voltage ADC registers.
#define LTC6804_SOC_RESOLUTION
uV per bit (SOC), sum-of-cells resolution.
API Header File for LTC6804-2 Multicell Battery Monitors.
Reference Application File for Monitoring Voltages from the LTC6804-2 Battery Monitor on the DC2100A ...
unsigned int16 voltage_uv_flags[DC2100A_MAX_BOARDS]
Bitmap indicating if a cell input on the LTC6804 is under-voltage (1) or not (0). ...
unsigned int32 voltage_timestamp
Timestamp taken when voltage measurements were started.
BOOLEAN Voltage_UVOV_Thresholds_Set(unsigned int16 vuv_value, unsigned int16 vov_value)
Sets the under-voltage and over-voltage thresholds in all DC2100A in the system.
void Voltage_Init(void)
Initializes the parts of the Voltage Module, that need to be initialized upon power-up of the PIC...
#define LTC6804_CONVERSIONS_ALL_7KHZ_DELAY
in us, delay between sampling and reading ADC in 7kHz conversion mode
void Voltage_Monitor_Task(void)
Executes the Voltage Monitor task.
#define LTC6804_VOLTAGE_RESOLUTION
uV per bit (CxV), cell voltage resolution.
unsigned int16 voltage_cell[DC2100A_MAX_BOARDS][DC2100A_NUM_CELLS]
Measured cell voltages for each board in LTC6804_VOLTAGE_RESOLUTION.
unsigned int16 voltage_vov_threshold
over-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
unsigned int16 voltage_sum[DC2100A_MAX_BOARDS]
Measured sum of the cell voltages for this board in LTC6804_SOC_RESOLUTION.
VOLTAGE_CELL_PRESENT_TYPE voltage_cell_present_flags[DC2100A_MAX_BOARDS]
Bitmap indicating if a cell input on the LTC6804 is unpopulated (0), such that UV conditions should b...
unsigned int16 voltage_vuv_threshold
under-voltage threshold in LTC6804_VOLTAGE_RESOLUTION.
Reference Application File for Controlling the LTC3300-1 Battery Balancers through the LTC6804-2 Batt...
unsigned int16 VOLTAGE_CELL_PRESENT_TYPE
Bitmap indicating if a cell input on the LTC6804 is populated or shorted.