analog.h File Reference


Detailed Description

Headerfile for analog.c.

Application note:
AVR453: Smart Battery Reference Design
Documentation:
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Original author: Rob G. Fries - Apt Inc.
Revision
URL
Date

Definition in file analog.h.

Go to the source code of this file.

Defines

#define ACCUM_CONV_TIME   ACCUM_CONV_TIME_1000
#define ACCUM_CONV_TIME_1000   ((1<<CADAS1) | (1<<CADAS0))
#define ACCUM_CONV_TIME_125   ((0<<CADAS1) | (0<<CADAS0))
#define ACCUM_CONV_TIME_250   ((0<<CADAS1) | (1<<CADAS0))
#define ACCUM_CONV_TIME_500   ((1<<CADAS1) | (0<<CADAS0))
#define ACTIVE_CURRENT_THRESHOLD   9
#define ADC0_READINGS   10
#define REG_CONV_TIME   REG_CONV_TIME_1000
#define REG_CONV_TIME_1000   ((1<<CADSI1) | (0<<CADSI0))
#define REG_CONV_TIME_2000   ((1<<CADSI1) | (1<<CADSI0))
#define REG_CONV_TIME_250   ((0<<CADSI1) | (0<<CADSI0))
#define REG_CONV_TIME_500   ((0<<CADSI1) | (1<<CADSI0))
#define REGULAR_CURRENT_SCALE_VALUE   4
#define VPTAT_READINGS   10

Enumerations

enum  CC_MODE { CC_DISABLED = 0, CC_ACCUMULATE, CC_REGULAR }

Functions

unsigned int AbsoluteSOC (void)
void ADCinit (void)
unsigned int AtRateOK (void)
unsigned int AtRateTTE (void)
unsigned int AtRateTTF (void)
unsigned int AvgTimeToFull (void)
void CalculateADCresults (void)
signed int CCarray_Average (void)
void CCinit (void)
void CCmode (unsigned char mode)
signed int Current1Sec (void)
void DisableCellBalancing (void)
void EnableCellBalancing (void)
void FullChargeReached (void)
unsigned int FullChgCap (void)
void FullDischargeReached (void)
unsigned int GetTemperature (void)
unsigned int GetVoltage (void)
unsigned char ReadCCOffsetCalibration (void)
unsigned int ReadCell (char)
unsigned int ReadTemperature (unsigned char channel)
unsigned char ReadVrefCalibration (void)
unsigned char RelativeSOC (void)
unsigned int RemainingCap (void)
void SetMaxTopAcc (long value)
void StartAdc (unsigned char select)
unsigned int TimeToEmpty (unsigned char avgd)

Variables

unsigned char BGCCRCal
unsigned int cell_current [4]
unsigned char CellToBalance
unsigned char FastRCCal
volatile signed int LatestCCI
signed long RunningAcc
unsigned int SlowRCCal
unsigned char ThermistorSelect


Define Documentation

#define ACCUM_CONV_TIME   ACCUM_CONV_TIME_1000

Definition at line 105 of file analog.h.

Referenced by CCmode().

#define ACCUM_CONV_TIME_1000   ((1<<CADAS1) | (1<<CADAS0))

Definition at line 103 of file analog.h.

#define ACCUM_CONV_TIME_125   ((0<<CADAS1) | (0<<CADAS0))

Definition at line 100 of file analog.h.

#define ACCUM_CONV_TIME_250   ((0<<CADAS1) | (1<<CADAS0))

Definition at line 101 of file analog.h.

#define ACCUM_CONV_TIME_500   ((1<<CADAS1) | (0<<CADAS0))

Definition at line 102 of file analog.h.

#define ACTIVE_CURRENT_THRESHOLD   9

Definition at line 125 of file analog.h.

Referenced by CCmode().

#define ADC0_READINGS   10

Definition at line 130 of file analog.h.

Referenced by ADC_INT().

#define REG_CONV_TIME   REG_CONV_TIME_1000

Definition at line 113 of file analog.h.

Referenced by CCmode().

#define REG_CONV_TIME_1000   ((1<<CADSI1) | (0<<CADSI0))

Definition at line 110 of file analog.h.

#define REG_CONV_TIME_2000   ((1<<CADSI1) | (1<<CADSI0))

Definition at line 111 of file analog.h.

#define REG_CONV_TIME_250   ((0<<CADSI1) | (0<<CADSI0))

Definition at line 108 of file analog.h.

#define REG_CONV_TIME_500   ((0<<CADSI1) | (1<<CADSI0))

Definition at line 109 of file analog.h.

#define REGULAR_CURRENT_SCALE_VALUE   4

Definition at line 119 of file analog.h.

#define VPTAT_READINGS   10

Definition at line 129 of file analog.h.

Referenced by ADC_INT().


Enumeration Type Documentation

enum CC_MODE

Enumerator:
CC_DISABLED 
CC_ACCUMULATE 
CC_REGULAR 

Definition at line 32 of file analog.h.


Function Documentation

unsigned int AbsoluteSOC ( void   ) 

Definition at line 333 of file analog.c.

References GetCharge(), and PACK_DESIGNCAPTYP.

void ADCinit ( void   ) 

Definition at line 1088 of file analog.c.

References ReadFactoryCalibration().

unsigned int AtRateOK ( void   ) 

Definition at line 280 of file analog.c.

References CAPACITY_MODE, Current1Sec(), GetCharge_mAmins(), GetVoltage(), hibyte, PACK_MINV, SMBV_AtRate, SMBV_BattMode, SMBvar_int, and SMBvariables.

unsigned int AtRateTTE ( void   ) 

Definition at line 252 of file analog.c.

References CAPACITY_MODE, GetCharge_mAmins(), hibyte, PACK_MINV, SMBV_AtRate, SMBV_BattMode, SMBvar_int, and SMBvariables.

unsigned int AtRateTTF ( void   ) 

Definition at line 226 of file analog.c.

References CAPACITY_MODE, GetCharge_mAmins(), hibyte, PACK_DESIGNCAPTYP, SMBV_AtRate, SMBV_BattMode, SMBvar_int, and SMBvariables.

unsigned int AvgTimeToFull ( void   ) 

Definition at line 410 of file analog.c.

References CAPACITY_MODE, Current1Sec(), GetChgUntilFull_mAmins(), GetVoltage(), hibyte, PACK_MINV, SMBV_BattMode, and SMBvariables.

void CalculateADCresults ( void   ) 

Todo:
Code could be added HERE to do something with the cell_current[] array, for the purpose of determining cell impedances.

Definition at line 1176 of file analog.c.

References ADCbuffer, ADCgain, CELL_TOOLITTLEV, CELL_TOOMUCHV, CellV, DoShutdown(), OnChipTemp, PACKSTACK, SHUTDOWN_REASON_OVERVOLTAGE, SHUTDOWN_REASON_UNDERVOLTAGE, Thermistor, ThermistorSelect, VPA4, and VTgain.

signed int CCarray_Average ( void   ) 

Definition at line 841 of file analog.c.

References CCarray, CCvalidsamples, and ctr.

void CCinit ( void   ) 

Definition at line 785 of file analog.c.

References CC_DISABLED, and CCmode().

void CCmode ( unsigned char  mode  ) 

Todo:
See ANALOG.H to choose your interval for CC_ACCUMULATE

Todo:
See ANALOG.H to choose your interval for CC_REGULAR

Definition at line 742 of file analog.c.

References ACCUM_CONV_TIME, ACTIVE_CURRENT_THRESHOLD, CC_ACCUMULATE, CC_delay_acc, CC_delay_inst, CC_DISABLED, CC_REGULAR, CCarray_Init(), REG_CONV_TIME, and Timer32KHz.

signed int Current1Sec ( void   ) 

Todo:
NOTE: This could produce a bad result within the first 1Sec of operation.

Definition at line 826 of file analog.c.

References CCarray, and CCindex.

void DisableCellBalancing ( void   ) 

Definition at line 1261 of file analog.c.

void EnableCellBalancing ( void   ) 

Definition at line 1267 of file analog.c.

References CellToBalance.

void FullChargeReached ( void   ) 

Definition at line 131 of file analog.c.

References FULLY_CHARGED, FULLY_DISCHARGED, lobyte, MaxBottomAcc, MaxTopAcc, RunningAcc, SMBV_BattStatus, and SMBvariables.

unsigned int FullChgCap ( void   ) 

Todo:
This implementation does not take into account C/5 vs 1C capacity delta.

Definition at line 357 of file analog.c.

References CAPACITY_MODE, GetMaxChg(), hibyte, PACK_NOMINALV, SMBV_BattMode, and SMBvariables.

void FullDischargeReached ( void   ) 

Definition at line 144 of file analog.c.

References FULLY_CHARGED, FULLY_DISCHARGED, lobyte, MaxBottomAcc, MaxTopAcc, RunningAcc, SMBV_BattStatus, and SMBvariables.

unsigned int GetTemperature ( void   ) 

Definition at line 318 of file analog.c.

References ReadTemperature().

unsigned int GetVoltage ( void   ) 

Definition at line 160 of file analog.c.

References PACKSTACK, and ReadCell().

unsigned char ReadCCOffsetCalibration ( void   ) 

Definition at line 566 of file analog.c.

References EESTORAGE_CC_valid, EESTORAGE_CCIoffset, and EESTORAGE_CCoffset.

unsigned int ReadCell ( char   ) 

Definition at line 1252 of file analog.c.

References CellV.

unsigned int ReadTemperature ( unsigned char  channel  ) 

Todo:
Insert calculations here to convert voltage reading(s) to temperature(s).

Definition at line 1229 of file analog.c.

References OnChipTemp, and Thermistor.

unsigned char ReadVrefCalibration ( void   ) 

Definition at line 543 of file analog.c.

References BGCCRCal, EESTORAGE_BGCCR, and EESTORAGE_BGCRR.

unsigned char RelativeSOC ( void   ) 

Definition at line 325 of file analog.c.

References MaxTopAcc, and RunningAcc.

unsigned int RemainingCap ( void   ) 

Todo:
This implementation does not take into account C/5 vs 1C capacity delta.

Definition at line 341 of file analog.c.

References CAPACITY_MODE, GetCharge(), GetVoltage(), hibyte, SMBV_BattMode, and SMBvariables.

void SetMaxTopAcc ( long  value  ) 

Definition at line 126 of file analog.c.

References MaxTopAcc.

void StartAdc ( unsigned char  select  ) 

Todo:
NOTE: If not using ADC0-3 exclusively as analog inputs, you MUST modify the following code.

Definition at line 1103 of file analog.c.

unsigned int TimeToEmpty ( unsigned char  avgd  ) 

Definition at line 372 of file analog.c.

References CAPACITY_MODE, CCarray_Average(), Current1Sec(), GetCharge_mAmins(), GetVoltage(), hibyte, PACK_MINV, SMBV_BattMode, and SMBvariables.


Variable Documentation

unsigned char BGCCRCal

Referenced by CalibrateVREF(), ReadFactoryCalibration(), and ReadVrefCalibration().

unsigned int cell_current[4]

Referenced by ADC_INT().

unsigned char CellToBalance

Referenced by BalanceCheck(), and EnableCellBalancing().

unsigned char FastRCCal

Referenced by ReadFactoryCalibration().

volatile signed int LatestCCI

Referenced by ADC_INT(), and CC_Instantaneous_ISR().

signed long RunningAcc

Referenced by CC_Accumulator_ISR(), CC_Instantaneous_ISR(), FullChargeReached(), FullDischargeReached(), GetCharge(), GetCharge_mAmins(), GetChgUntilFull_mAmins(), RelativeSOC(), and WakeUp_ISR().

unsigned int SlowRCCal

Referenced by ReadFactoryCalibration().

unsigned char ThermistorSelect

Referenced by CalculateADCresults(), and main().


Generated on Mon Nov 12 15:59:58 2007 for AVR453 Smart Battery Reference Design by  doxygen 1.5.3