LTC6811
Embed:
(wiki syntax)
Show/hide line numbers
LTC6811.h
Go to the documentation of this file.
00001 /*! 00002 LTC6811-1: Multicell Battery Monitor 00003 00004 http://www.linear.com/product/LTC6811-1 00005 00006 http://www.linear.com/product/LTC6811-1#demoboards 00007 00008 REVISION HISTORY 00009 $Revision: 7139 $ 00010 $Date: 2017-06-01 13:55:14 -0700 (Thu, 01 Jun 2017) $ 00011 00012 Copyright (c) 2015, Linear Technology Corp.(LTC) 00013 All rights reserved. 00014 00015 Redistribution and use in source and binary forms, with or without 00016 modification, are permitted provided that the following conditions are met: 00017 00018 1. Redistributions of source code must retain the above copyright notice, this 00019 list of conditions and the following disclaimer. 00020 2. Redistributions in binary form must reproduce the above copyright notice, 00021 this list of conditions and the following disclaimer in the documentation 00022 and/or other materials provided with the distribution. 00023 00024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00025 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00028 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00031 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 00035 The views and conclusions contained in the software and documentation are those 00036 of the authors and should not be interpreted as representing official policies, 00037 either expressed or implied, of Linear Technology Corp. 00038 00039 The Linear Technology Linduino is not affiliated with the official Arduino team. 00040 However, the Linduino is only possible because of the Arduino team's commitment 00041 to the open-source community. Please, visit http://www.arduino.cc and 00042 http://store.arduino.cc , and consider a purchase that will help fund their 00043 ongoing work. 00044 00045 Copyright 2017 Linear Technology Corp. (LTC) 00046 ***********************************************************/ 00047 00048 /*! @file 00049 @ingroup LTC6811-1 00050 Header for LTC6811-1 Multicell Battery Monitor 00051 */ 00052 00053 #ifndef LTC6811_H 00054 #define LTC6811_H 00055 00056 #include "LTC681x.h" 00057 #include "mbed.h" 00058 #include "LT_SPI.h" 00059 #include "bms_hardware.h" 00060 00061 #define CELL 1 00062 #define AUX 2 00063 #define STAT 3 00064 00065 00066 void LTC6811_init_reg_limits(uint8_t total_ic, cell_asic ic[]); 00067 00068 00069 /*! Starts the Mux Decoder diagnostic self test 00070 00071 Running this command will start the Mux Decoder Diagnostic Self Test 00072 This test takes roughly 1mS to complete. The MUXFAIL bit will be updated, 00073 the bit will be set to 1 for a failure and 0 if the test has been passed. 00074 00075 */ 00076 void LTC6811_diagn (); 00077 00078 00079 //! Sends the poll adc command 00080 //! @returns 1 byte read back after a pladc command. If the byte is not 0xFF ADC conversion has completed 00081 uint8_t LTC6811_pladc(); 00082 00083 00084 //! This function will block operation until the ADC has finished it's conversion 00085 //! @returns the approximate time it took for the ADC function to complete. 00086 uint32_t LTC6811_pollAdc(); 00087 00088 /*! Starts cell voltage conversion 00089 */ 00090 void LTC6811_adcv (uint8_t MD, //!< ADC Conversion Mode 00091 uint8_t DCP, //!< Controls if Discharge is permitted during conversion 00092 uint8_t CH //!< Sets which Cell channels are converted 00093 ); 00094 00095 /*! Starts cell voltage and GPIO 1&2 conversion 00096 */ 00097 void LTC6811_adcvax ( 00098 uint8_t MD, //!< ADC Conversion Mode 00099 uint8_t DCP //!< Controls if Discharge is permitted during conversion 00100 ); 00101 00102 00103 /*! Starts cell voltage self test conversion 00104 */ 00105 void LTC6811_cvst ( 00106 uint8_t MD, //!< ADC Conversion Mode 00107 uint8_t ST //!< Self Test Mode 00108 ); 00109 00110 /*! Starts cell voltage and SOC conversion 00111 */ 00112 void LTC6811_adcvsc ( 00113 uint8_t MD, //!< ADC Conversion Mode 00114 uint8_t DCP //!< Controls if Discharge is permitted during conversion 00115 ); 00116 /*! Starts cell voltage overlap conversion 00117 */ 00118 void LTC6811_adol ( 00119 uint8_t MD, //!< ADC Conversion Mode 00120 uint8_t DCP //!< Discharge permitted during conversion 00121 ); 00122 00123 /*! Start an open wire Conversion 00124 */ 00125 void LTC6811_adow ( 00126 uint8_t MD, //!< ADC Conversion Mode 00127 uint8_t PUP //!< Controls if Discharge is permitted during conversion 00128 ); 00129 00130 00131 /*! Start a GPIO and Vref2 Conversion 00132 */ 00133 void LTC6811_adax ( 00134 uint8_t MD, //!< ADC Conversion Mode 00135 uint8_t CHG //!< Sets which GPIO channels are converted 00136 ); 00137 00138 /*! Start an GPIO Redundancy test 00139 */ 00140 void LTC6811_adaxd ( 00141 uint8_t MD, //!< ADC Conversion Mode 00142 uint8_t CHG //!< Sets which GPIO channels are converted 00143 ); 00144 00145 /*! Start an Auxiliary Register Self Test Conversion 00146 */ 00147 void LTC6811_axst ( 00148 uint8_t MD, //!< ADC Conversion Mode 00149 uint8_t ST //!< Sets if self test 1 or 2 is run 00150 ); 00151 00152 /*! Start a Status ADC Conversion 00153 */ 00154 void LTC6811_adstat ( 00155 uint8_t MD, //!< ADC Conversion Mode 00156 uint8_t CHST //!< Sets which Stat channels are converted 00157 ); 00158 00159 /*! Start a Status register redundancy test Conversion 00160 */ 00161 void LTC6811_adstatd ( 00162 uint8_t MD, //!< ADC Mode 00163 uint8_t CHST //!< Sets which Status channels are converted 00164 ); 00165 00166 00167 /*! Start a Status Register Self Test Conversion 00168 */ 00169 void LTC6811_statst ( 00170 uint8_t MD, //!< ADC Conversion Mode 00171 uint8_t ST //!< Sets if self test 1 or 2 is run 00172 ); 00173 00174 /*! Reads and parses the LTC6811 cell voltage registers. 00175 00176 @return int8_t, PEC Status. 00177 0: No PEC error detected 00178 -1: PEC error detected, retry read 00179 */ 00180 uint8_t LTC6811_rdcv (uint8_t reg, //!< controls which cell voltage register is read back. 00181 uint8_t total_ic, //!< the number of ICs in the daisy chain(-1 only) 00182 cell_asic ic[] //!< array of the parsed cell codes from lowest to highest. 00183 ); 00184 00185 00186 00187 /*! Reads and parses the LTC6811 auxiliary registers. 00188 @return int8_t, PEC Status 00189 0: No PEC error detected 00190 -1: PEC error detected, retry read 00191 */ 00192 int8_t LTC6811_rdaux (uint8_t reg, //!< controls which GPIO voltage register is read back 00193 uint8_t nIC, //!< the number of ICs in the daisy chain 00194 cell_asic ic[] //!< A two dimensional array of the parsed gpio voltage codes 00195 ); 00196 00197 /*! Reads and parses the LTC6811 stat registers. 00198 00199 @return int8_t, PEC Status 00200 0: No PEC error detected 00201 -1: PEC error detected, retry read 00202 */ 00203 int8_t LTC6811_rdstat (uint8_t reg, //Determines which Stat register is read back. 00204 uint8_t total_ic,//the number of ICs in the system 00205 cell_asic ic[] 00206 ); 00207 00208 /*! Clears the LTC6811 cell voltage registers 00209 */ 00210 void LTC6811_clrcell (); 00211 00212 /*! Clears the LTC6811 Auxiliary registers 00213 */ 00214 void LTC6811_clraux (); 00215 00216 /*! Clears the LTC6811 Stat registers 00217 */ 00218 void LTC6811_clrstat (); 00219 00220 /*! Clears the LTC6811 Sctrl registers 00221 */ 00222 void LTC6811_clrsctrl (); 00223 00224 /*! Write the LTC6811 configuration register 00225 */ 00226 void LTC6811_wrcfg (uint8_t nIC, //!< The number of ICs being written 00227 cell_asic ic[] //!< a two dimensional array of the configuration data that will be written 00228 ); 00229 00230 void LTC6811_wrcfgb (uint8_t nIC, //!< The number of ICs being written 00231 cell_asic ic[] //!< a two dimensional array of the configuration data that will be written 00232 ); 00233 /*! Reads configuration registers of a LTC6811 daisy chain 00234 @return int8_t, PEC Status. 00235 0: Data read back has matching PEC 00236 -1: Data read back has incorrect PEC 00237 */ 00238 int8_t LTC6811_rdcfg (uint8_t nIC, //!< number of ICs in the daisy chain 00239 cell_asic ic[] //!< a two dimensional array that the function stores the read configuration data 00240 ); 00241 00242 int8_t LTC6811_rdcfgb (uint8_t nIC, //!< number of ICs in the daisy chain 00243 cell_asic ic[] //!< a two dimensional array that the function stores the read configuration data 00244 ); 00245 /*! Write the LTC6811 PWM register 00246 */ 00247 void LTC6811_wrpwm (uint8_t nIC, //!< number of ICs in the daisy chain 00248 uint8_t pwmReg, 00249 cell_asic ic[] 00250 ); 00251 00252 /*! Reads pwm registers of a LTC6811 daisy chain 00253 00254 */ 00255 int8_t LTC6811_rdpwm (uint8_t nIC, //!< number of ICs in the daisy chain 00256 uint8_t pwmReg, 00257 cell_asic ic[] //!< a two dimensional array that the function stores the read pwm data 00258 ); 00259 00260 /*! Write the LTC6811 Sctrl register 00261 */ 00262 void LTC6811_wrsctrl (uint8_t nIC, //!< number of ICs in the daisy chain 00263 uint8_t sctrl_reg, 00264 cell_asic ic[] 00265 ); 00266 00267 00268 /*! Reads sctrl registers of a LTC6811 daisy chain 00269 @return int8_t, PEC Status. 00270 0: Data read back has matching PEC 00271 -1: Data read back has incorrect PEC 00272 */ 00273 int8_t LTC6811_rdsctrl (uint8_t nIC, //!< number of ICs in the daisy chain 00274 uint8_t sctrl_reg, 00275 cell_asic ic[] //!< a two dimensional array that the function stores the read pwm data 00276 ); 00277 00278 00279 /*! Start Sctrl data communication 00280 This command will start the sctrl pulse communication over the spins 00281 */ 00282 void LTC6811_stsctrl (); 00283 00284 00285 /*! Write the LTC6811 COMM register 00286 */ 00287 void LTC6811_wrcomm (uint8_t total_ic, //!< Number of ICs in the daisy chain 00288 cell_asic ic[] //!< A two dimensional array of the comm data that will be written 00289 ); 00290 00291 /*! Reads comm registers of a LTC6811 daisy chain 00292 @return int8_t, PEC Status. 00293 00294 0: Data read back has matching PEC 00295 00296 -1: Data read back has incorrect PEC 00297 00298 */ 00299 int8_t LTC6811_rdcomm (uint8_t total_ic, //!< number of ICs in the daisy chain 00300 cell_asic ic[] //!< Two dimensional array that the function stores the read comm data. 00301 ); 00302 00303 /*! issues a stcomm command and clocks data out of the COMM register */ 00304 void LTC6811_stcomm (); 00305 00306 00307 /*! @returns returns the register data pattern for a given ADC MD and Self test */ 00308 uint16_t LTC6811_st_lookup ( 00309 uint8_t MD, //!< ADC Conversion Mode 00310 uint8_t ST //!< Self test number 00311 ); 00312 00313 void LTC6811_set_discharge(int Cell, 00314 uint8_t total_ic, 00315 cell_asic ic[]); 00316 00317 /*! Helper function that runs the ADC Self Tests*/ 00318 int16_t LTC6811_run_cell_adc_st (uint8_t adc_reg, 00319 uint8_t total_ic, 00320 cell_asic ic[]); 00321 00322 /*! Helper function that runs the ADC Digital Redudancy commands and checks output for errors*/ 00323 int16_t LTC6811_run_adc_redundancy_st (uint8_t adc_mode, 00324 uint8_t adc_reg, 00325 uint8_t total_ic, 00326 cell_asic ic[]); 00327 00328 /*! Helper function that runs the datasheet open wire algorithm*/ 00329 void LTC6811_run_openwire (uint8_t total_ic, 00330 cell_asic ic[]); 00331 00332 void LTC6811_set_discharge(int Cell, 00333 uint8_t total_ic, 00334 cell_asic ic[]); 00335 00336 /*! Helper Function that runs the ADC Overlap test*/ 00337 uint16_t LTC6811_run_adc_overlap (uint8_t total_ic, 00338 cell_asic ic[]); 00339 00340 /*! Helper Function that counts overall PEC errors and register/IC PEC errors*/ 00341 void LTC6811_check_pec (uint8_t total_ic, 00342 uint8_t reg, 00343 cell_asic ic[]); 00344 00345 /*! Helper Function that resets the PEC error counters */ 00346 void LTC6811_reset_crc_count (uint8_t total_ic, 00347 cell_asic ic[]); 00348 00349 /*! Helper Function to initialize the CFGR data structures*/ 00350 void LTC6811_init_cfg (uint8_t total_ic, 00351 cell_asic ic[]); 00352 00353 /*! Helper function to set appropriate bits in CFGR register based on bit function*/ 00354 void LTC6811_set_cfgr (uint8_t nIC, 00355 cell_asic ic[], 00356 bool refon, 00357 bool adcopt, 00358 bool gpio[5], 00359 bool dcc[12]); 00360 00361 /*! Helper function to turn the refon bit HIGH or LOW*/ 00362 void LTC6811_set_cfgr_refon (uint8_t nIC, 00363 cell_asic ic[], 00364 bool refon); 00365 00366 /*! Helper function to turn the ADCOPT bit HIGH or LOW*/ 00367 void LTC6811_set_cfgr_adcopt (uint8_t nIC, 00368 cell_asic ic[], 00369 bool adcopt); 00370 00371 /*! Helper function to turn the GPIO bits HIGH or LOW*/ 00372 void LTC6811_set_cfgr_gpio (uint8_t nIC, 00373 cell_asic ic[], 00374 bool gpio[]); 00375 00376 /*! Helper function to turn the DCC bits HIGH or LOW*/ 00377 void LTC6811_set_cfgr_dis (uint8_t nIC, 00378 cell_asic ic[], 00379 bool dcc[]); 00380 /*! Helper function to set uv field in CFGRA register*/ 00381 void LTC6811_set_cfgr_uv (uint8_t nIC, 00382 cell_asic ic[], 00383 uint16_t uv); 00384 00385 /*! Helper function to set ov field in CFGRA register*/ 00386 void LTC6811_set_cfgr_ov (uint8_t nIC, 00387 cell_asic ic[], 00388 uint16_t ov); 00389 00390 void LTC6811_init_max_min(uint8_t total_ic, 00391 cell_asic ic[], 00392 cell_asic ic_max[], 00393 cell_asic ic_min[]); 00394 00395 void LTC6811_max_min(uint8_t total_ic, cell_asic ic_cells[], 00396 cell_asic ic_min[], 00397 cell_asic ic_max[], 00398 cell_asic ic_delta[]); 00399 #endif
Generated on Wed Jul 13 2022 11:08:21 by
