LTC具温度电压和电流测量功能的多节电池电量测量芯片_第1页
LTC具温度电压和电流测量功能的多节电池电量测量芯片_第2页
LTC具温度电压和电流测量功能的多节电池电量测量芯片_第3页
LTC具温度电压和电流测量功能的多节电池电量测量芯片_第4页
LTC具温度电压和电流测量功能的多节电池电量测量芯片_第5页
已阅读5页,还剩39页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、ltc2943 -具温度、电压和电流测量功能的多节电池电量测量芯片特点可测量累积的电池充电和放电电量3.6v至20v工作范围可适合多种电池应用14位adc负责测量电池电压、电流和温度1%电压、电流和充电准确度50mv检测电压范围高压侧检测适合任何电池化学组成和容量的通用测量fc/smbus接口可配置警报输出/充电完成输入静态电流小于120 n a小外形8引脚3mm x 3mm dfn圭寸装典型应用 描述ltc?2943?可测量便携式产品应用中的电池充电状态、电池电压、电池电流及其自身温度。其具有宽输入电压范围,因而可与高达 ? 20v?的多节电池配合使用。一个精准的库仑计量器负责对流经位于电池

2、正端子和负载或充电器之间的一个检测电阻器电流进行积分运算。电池电压、电流和温度利用一个内部?14位无?|2c/smbus?接口进行存延迟增量累加?(n。latency 男)adc?来测量。测量结果被存储于可通过内置 取的内部寄存器中。ltc2943?具有针对所有? 4?种测量物理量的可编程高门限和低门限。如果超过了某个编程门限,则该器件 将采用?smbus?警报协议或通过在内部状态寄存器中设定一个标记来传送;报信号。ltc2943?仅需采用单个低阻值检测电阻器以设定测量电流范围。应用电动工具电动自行车便携式医疗设备视频摄像机程序:include include include linduino

3、.hinclude tt_l2c.hninclude userinterface.hninclude hquikeval_eeprom.hninclude ”ltc2943.h”include / function declarationvoid print_title();/ print the title blockvoid print_prompt(); / print the promptvoid store_alert_settings(); / store the alert settings to theeepromint8_t restore_alert_settings();

4、 / read the alert settings from eeprom#define automatic_mode_display_delay 1000/! thedelay between readings in automatic mode#define scan_mode_display_delay 10000 /! the delay between readings in scan modeconst float resistor = .100;/!resistor value on demo board/ error stringconst char ack_error =

5、error: no acknowledge. check i2c address.n; /! error message/ global variablesstatic int8_t demo_board_connected; /! set to 1 if the board is connectedstatic uint8_t alert_code = 0;/! value stored or readfrom alert register. shared between loop() and restore_alert_settings()/! initialize linduino vo

6、id setup() (char demo_name = dc1812n; /! demo board name stored in quikeval eepromquikeval_l2c_init(); /! configure the eeprom i2c port for 100khzquikeval_l2c_connect(); /! connects to main i2c portserial.begin(115200); /! initialize the serial port to the pcprint_title();demo_board_connected = disc

7、over_demo_board(demo_name);if (demo_board_connected)(print_prompt();)else(demo_board_connected = true;serial.println(did not read id string, attempting to proceed anyway.anplease ensure i2c lines of linduino are connected to the ltc device);)/! repeats linduino loopvoid loop()int8_t ack = 0; indicat

8、or/! i2c acknowledgestatic uint8_t user_command;command/! the user inputstatic uint8_t mah_or_coulombs = 0;static uint8_t celcius_or_kelvin = 0;static uint16_t prescalar_mode = ltc2943_prescalar_m_4096;static uint16_t prescalarvalue = 4096;static uint16_t alcc_mode = ltc2943_alert_mode;if (demo_boar

9、d_connected) demo /! do nothing if the board is not connected(if (serial.available() serial is not /i do nothing if available(/! read user inputuser_command = readj nt(); commandif (user_command !=,m)serial.println(user_command);serial.println();ack = 0;/! prints theswitch (user_command) appropriate

10、 submenu(case 1:ack |= menu_1_automatic_mode(mah_or_coulombs, celcius_or_kelvin, prescalar_mode, prescalarvalue, alcc_mode); /! automatic modebreak;case 2:ack |= menu_2_scan_mode(mah_or_coulombs, celcius_or_kelvin, prescalar_mode, prescalarvalue, alcc_mode); /! scan modebreak;case 3:ack |= menu_3_ma

11、nual_mode(mah_or_coulombs, celcius_or_kelvin, prescalar_mode, prescalarvalue, alcc_mode); /! manual modebreak;case 4:ack |= menu_4_sleep_mode(mah_or_coulombs, prescalar_mode, prescalarvalue, alcc_mode); /! sleep modebreak;case 5:ack |= menu_5_shutdown_mode();/! shutdown modebreak;case 6:ack |= menu_

12、6_settings(&mah_or_coulombs, &celcius_or_kelvin, &prescalar_mode, &prescalarvalue, &alcc_mode); /! settings modebreak;)if (ack != 0)/! if ack is not recieved print an error.serial.println(ack_error);serial print(f(h *)print_prompt();/ function definitions /! print the title block void print_title()s

13、erial.println(f(hn *serial.print(f(h* dc1812a demonstration program*n”);serial.print(f(h*n”);serial.print(f(h* this program communicates with the ltc2943 multicell coulomb*n”);serial.print(f(h* counter found on the dc1812a demo board. *n);serial.print(f(h* set the baud rate to 115200 and select the

14、newline terminator.*nn);serial.print(f(h*n);serialprint(f(n * nh ./! print the prompt void print_prompt() (serial.print(f(n1 -automatic modenn);serial.print(f(2-scan modenn);serial.print(f(3-manual moden);serial.print(f(4-sleep moden);serial.print(f(5-shutdown moden);serial.print(f(,6-settingsn,);se

15、rial.print(f(henter a command:);/! automatic m8_t menu_1_automatic_mode(int8_t mah_or_coulombs, int8_t celcius_or_kelvin ,uint16_t prescalar_mode, uint16_t prescalarvalue, uint16_t alcc_mode)/! return returns the state of the acknowledge bit after the i2c address write. o=acknowledge, 1=no ac

16、knowledge.(int8_t ltc2943_mode;int8_t ack = 0;ltc2943_mode = ltc2943_automatic_mode|prescalar_mode|alcc_mode ; /! set the control register of the ltc2943 to automatic mode as well as set prescalar and al#/cc# pin values.serial.println();ack |= ltc2943_write(ltc2943_l2c_address, ltc2943_control_reg,

17、ltc2943_mode); /! writes the set mode to the ltc2943 control registerdo*serial.print(f(hnn);uint8_t status_code, hightemp_code, lowtemp_code;uint16_t charge_code, current_code, voltage_code, temperature_code;ack |= ltc2943_read_16_bits(ltc2943_l2c_address, ltc2943_accum_charge_msb_reg, &charge_code)

18、;/! read msb and lsb accumulated charge registers for 16 bit charge codeack|=ltc2943_read_16_bits(ltc2943_l2c_address,lt c2943_v o lt ag e_m s b_r e g, &voltage_code);/! read msb and lsbvoltage registers for 16 bit voltage codeack |= ltc2943_read_16_bits(ltc2943_l2c_address, ltc2943_current_msb_reg,

19、 ¤t_code); /! read msb and lsb currentregisters for 16 bit current codeack |= ltc2943_read_16_bits(ltc2943_l2c_address, ltc2943_temperature_i/isb_reg, &temperature_code); /! read msb and lsb temperature registers for 16 bit temperature codeack |= ltc2943_read(ltc2943_l2c_address, ltc2943_statu

20、s_reg, &status_code);/! read status register for 8bit status codefloat charge, current, voltage, temperature;if(mah_or_coulombs)(charge = ltc2943_code_to_coulombs(charge_code, resistor, prescalarvalue); /! convert charge code to coulombs if coulomb units are desired.serial.print(,coulombs:);serial.p

21、rint(charge, 4);serial.print(f( cnh);)else(charge = ltc2943_code_to_mah(charge_code, resistor, prescalarvalue); /! convert charge code to mah if mah units are desired.serial.print(hmah: ”);serial.print(charge, 4);serial.print(f( mahn”);)current = ltc2943_code_to_current(current_code, resistor);/! co

22、nvert current code to amperesvoltage = lt c2943_code_to_voltage(voltage_code);/! convert voltage code to voltsserialprint(f(hcurrent );serial.print(current, 4);serial.print(f(h an);serial.print(f(voltage );serial.print(voltage, 4);serial.print(f( vn);if(celcius_or_kelvin)temperature =ltc2943_code_to

23、_kelvin_temperature(temperature_code); /! convert temperature code to kelvinserial.print(f(temperature );serial.print(temperature, 4);serial.print(f( kn);)else(temperature =ltc2943_code_to_celcius_temperature(temperature_code); /! convert temperature code to celciusserial.print(f(htemperature );seri

24、al.print(temperature, 4);serial.print(f(n cnm);checkalerts(status_code);/! check status code for alerts. if an alert has been set, print out appropriate message in the serial prompt.serial.print(f(iti-main menunnm);serial.flush();delay(automatic_mode_display_delay);/! delay for 1s before next pollin

25、gwhile (serial.available() = false | (ack);/! if serial is not available and an nack has not been recieved, keep polling the registers.read_int(); / clears the serial.availablereturn(ack);/! scan mode int8_t menu_2_scan_mode(int8_t mah_or_coulombs , int8_t celcius_or_kelvin ,uint16_t prescalar_mode,

26、uint16_t prescalarvalue, uint16_t alcc_mode)/! return returns the state of the acknowledge bit after the i2c address write. o=acknowledge, 1=no acknowledgeint8_t ltc2943_mode;int8_t ack = 0;ltc2943_mode = ltc2943_scan_mode|prescalar_mode|alcc_mode ;/! set the control mode of the ltc2943 to scan mode

27、 as well as set prescalar and al#/cc# pin values.serial.println();ack |= ltc2943_write(ltc2943_l2c_address, ltc2943_control_reg, ltc2943_mode); /! writes the set mode to the ltc2943 control registerdouint8_t status_code;uint16_t charge_code, current_code, voltage_code, temperature_code;ack |= ltc294

28、3_read_16_bits(ltc2943_l2c_address, ltc2943_accum_charge_msb_reg, &charge_code); /! read msb and lsb accumulated charge registers for 16 bit charge codeack |= ltc2943_read_16_bits(ltc2943_l2c_address,lt c2943_v o lt ag e_m s b_r e g, &voltage_code);/! read msb andlsb voltage registers for 16 bit vol

29、tage codeack |= ltc2943_read_16_bits(ltc2943_l2c_address, ltc2943_current_msb_reg, ¤t_code); /! read msb and lsb current registers for 16 bit current codeack |= ltc2943_read_16_bits(ltc2943_l2c_address, ltc2943_temperature_i/isb_reg, &temperature_code); /! read msb and lsb temperature register

30、s for 16 bit temperature codeack |= ltc2943_read(ltc2943_l2c_address, ltc2943_status_reg, &status_code); /! read status registers for 8 bit status codefloat charge, current, voltage, temperature;if(mah_or_coulombs)(charge = ltc2943_code_to_coulombs(charge_code, resistor, prescalarvalue);/! convert c

31、harge code to coulombs if coulomb units are desired.serial.print(,coulombs:);serial.print(charge, 4); serial.print(f(m cn);charge = ltc2943_code_to_mah(charge_code, resistor, prescalarvalue); /! convert chargecode to mah if mah units are desired.serial.printcmah: ”);serial.print(charge, 4);serial.pr

32、int(f(m mahnh);current = ltc2943_code_to_current(current_code, resistor); /! convert current code to amperesvoltage = lt c2943_code_to_voltage(voltage_code);/! convert voltage code to voltsserial.print(f(current);serial.print(current, 4);serial.print(f(n an”);serial.print(f(voltage ”);serial.print(v

33、oltage, 4);serial.print(f(” vn);if(celcius_or_kelvin)(temperature = ltc2943_code_to_kelvin_temperature(temperature_code); /! convert temperature code to kelvin if kelvin units are desired.serial.print(f(temperature );serial.printemperature, 4);serial.print(f(h knh);temperature = ltc2943_code_to_celc

34、ius_temperature(temperature_code); /! convert temperature code to celcius if celcius units are desired.serial.print(f(,temperature );serial.print(temperature, 4);serial.print(f(n cn”);)checkalerts(status_code);/! check status code for alerts. if an alert has been set, print out appropriate message i

35、n the serial promptserial.print(f(m-main menunnm);serial.flush();delay(scan_mode_display_delay);)elsewhile (serial.available() = false | (ack); read_int(); / clears the serial.available return(ack);/! manual mode int8_t menu_3_manual_mode(int8_t mah_or_coulombs ,int8_t celcius_or_kelvin ,uint16_t pr

36、escalar_mode, uint16_t prescalarvalue, uint16_t alcc_mode) /! return returns the state of the acknowledge bit after the i2c address write. o=acknowledge3 1=no acknowledgeint8_t ltc2943_mode;int8_t ack = 0;ltc2943_mode = ltc2943_manual_mode|prescalar_mode|alcc_mode ;/! set the control mode of the ltc

37、2943 to manual mode as well as set prescalar and al#/cc# pin values.serial.println();ack |= ltc2943_write(ltc2943_l2c_address, ltc2943_control_reg, ltc2943_mode);/! writes the set mode to theltc2943 control registerint staledata = 0;/! stale data check variable. when set to 1 it indicates that stale

38、 data is being read from the voltage, current and temperature registers.do*serial.print(f(nnn);uint8_t status_code;uint16_t charge_code, current_code, voltage_code, temperature_code;ack |= ltc2943_read_16_bits(ltc2943_l2c_address, ltc2943_accum_charge_msb_reg, &charge_code); lsb /! read msb and accu

39、mulated charge registers for 16 bit charge codeack |= ltc2943_read_16_bits(ltc2943_l2c_address,lt c2943_v o lt ag e_m s b_r eg, &voltage_code);/! read msb andlsb voltage registers for 16 bit voltage codeack|=ltc2943_read_16_bits(ltc2943_l2c_address,ltc2943_current_msb_reg, ¤t_code); /! read ms

40、b and lsb current registers for 16 bit current codeack |= ltc2943_read_16_bits(ltc2943_l2c_address,ltc2943_temperature_msb_reg, &temperature_code); /! read msb and lsb temperature registers for 16 bit temperature codeack |= ltc2943_read(ltc2943_l2c_address, ltc2943_status_reg, &status_code);/! read

41、status registers for8 bit status codefloat charge, current, voltage, temperature; if(mah_or_coulombs)charge = ltc2943_code_to_coulombs(charge_code, resistor, prescalarvalue); /! convert charge codeto coulombs if coulomb units are desired.serial.print(ncoulombs: ”);serial.print(charge, 4);serial.prin

42、t(f( cn);)else(charge = ltc2943_code_to_mah(charge_code, resistor, prescalarvalue); /! convert charge code to mah if mah units are desired.serial.print(mah: );serial.print(charge, 4);serial.print(f(h mahnn);)current = ltc2943_code_to_current(current_code, resistor);/! convert current code to amperes

43、voltage = ltc2943_code_to_voltage(voltage_code);/! convert voltage code to voltsserial.print(f(hcurrent);serial.print(current, 4);serial.print(f(n a”);if(staledata) serial.prinfc* stale data *n);/! if stale data is inside the register after initial snapshot, print stale data message.serial.print(f(n

44、voltage ”);serial.print(voltage, 4);serial.print(f(h vh);if(staledata) serialprint(f(n * stale data *nn);/! if stale data is inside the register after initial snapshot, print stale data message.else serial.println(,h,);if(celcius_or_kelvin)temperature = ltc2943_code_to_kelvin_temperature(temperature

45、_code); /! convert temperature code to kelvin if kelvin units are desired.serial.print(f(ntemperature );serial.print(temperature5 4);serial.print(fc,kn);)else(temperature = ltc2943_code_to_celcius_temperature(temperature_code); /! convert temperature code to celcius if celcius units are desired.seri

46、al.print(f(ntemperature );serial.print(temperature, 4);serial.print(f( c);)if(staledata) serial.print(f(h * stale data *nh);else serial.println(,h,);checkalerts(status_code);/! check status code for alerts. if an alert has been set, print out appropriate message in the serial promptelse serial.print

47、ln(,h,);serial.print(f(,m-main menunn);staledata = 1;serial.flush();delay(automatic_mode_display_delay);)while (serial.available() = false | (ack); readjnt(); / clears the serial.available return(ack);)/! sleep modeint8_t menu_4_sleep_mode(int8_t mah_or_coulombs ,uint16_t prescalar_mode, uint16_t pr

48、escalarvalue, uint16_t alcc_mode)/! return returns the state of the acknowledge bit after the i2c address write. o=acknowledge, 1=no acknowledge(int8_t ltc2943_mode;int8_t ack = 0;ltc2943_mode = ltc2943_sleep_mode|prescalar_mode|alcc_mode ;/! set the control mode of the ltc2943 to sleep mode as well

49、 as set prescalar and al#/cc# pin values.serial.println();ack |= ltc2943_write(ltc2943_l2c_address, ltc2943_control_reg, ltc2943_mode); /! writes the set mode to the ltc2943 control registerdo*nn”);delay(100);serialprint(f(nuint8_t status_code;uintl 6_t charge_code;ack |= ltc2943_read_16_bits(ltc294

50、3_l2c_address, ltc2943_accum_charge_msb_reg, &charge_code); /! read msb and lsb accumulated charge registers for 16 bit charge codeack |= ltc2943_read(ltc2943_l2c_address, ltc2943_status_reg, &status_code);/! read status registers for 8bit status codefloat charge;if(mah_or_coulombs)(charge = ltc2943

51、_code_to_coulombs(charge_code, resistor, prescalarvalue); /! convert charge code tocoulombs if coulomb units are desired.serial.print(,coulombs: );serial.print(charge, 4);serial.print(f(h cnh);)else(charge = ltc2943_code_to_mah(charge_code, resistor, prescalarvalue); /! convert charge code to mah if

52、 mah units are desired.serial.print(hmah:);serial.print(charge, 4);serial.print(f(n mahnn);)serial.print(f(hcurrent);serial.print(f( adc sleep.an);serial.print(f(,voltage );serial.print(f( adc sleep.an);serial.print(f(htemperature );serialprint(f(n adc sleep.nm);serial.print(f(hm-main menunnh); chec

53、kalerts(status_code);serial.flush();delay(automatic_mode_display_delay);)while (serial.available() = false | (ack);readj nt (); / clears the serial.available return(ack);)/! shutdown modeint8_t menu_5_shutdown_mode()/! return returns the state of the acknowledge bit after the i2c address write. o=ac

54、knowledge, 1=no acknowledge(int8_t ack = 0;ack |= ltc2943_write(ltc2943_l2c_address, ltc2943_control_reg, ltc2943_shutdown_mode);/! sets the ltc2943 intoshutdown modeserial.print(ltc2943 has been shutdownnh); return(ack);/! settings menuint8_t menu_6_settings(uint8_t *mah_or_coulombs, uint8_t*celcius_or_kelvin, uint16_t *prescalar_mode, uint16_t *prescalarvalue, uint16_t*alcc_mode)/! return returns the state of the acknowledge bit after the i2c address write.0二acknowledge, 1=no acknowledge(int8_t ack = 0;int8_t user_command;doserial.print(fc,nnh);serial.p

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论