1、三 LI-ION1A LOADTotal Charge Error vsDifferential Sense VoltageOJ 1 10 100sense (mV)294a TAO It描述LTC?2943可测量便携式产品应用中的电池充电状态、电池电压、电池电流及其自身温度。其具有宽输入电压范围,因而可与高达20V的多节电池配合使用。一个精准的库仑计量器负责对流经位于电池正端子与负载或充电器之间的一个检测电阻器电流进行积分运算。电池电压、电流与温度利用一个内部 14位无延迟增量累加 (No Latency 男)ADC来测量。测量结果被存储于 可通过内置I2C / SMBus接口进行存取的内部
2、寄存器中。LTC2943具有针对所有4种测量物理量的可编程高门限与低门限。如果超过了某个编程门限 ,则该器件将采用SMBus警报协议或通过在内部状态寄存器中设定一个标记来传送警报信号。LTC2943仅需采用单个低阻值检测电阻器以设定测量电流范围。应用电动工具电动自行车便携式医疗设备视频摄像机程序:#inelude vArduino 、h#inelude vstdint 、h#inelude Linduino 、hLT_I2C 、h#include UserInterface 、hQuikEval_EEPROM、hLTC2943、h#include / Function Declarationv
3、oid print_title(); / Print the title blockvoid print_prompt(); / Print the Promptvoid store_alert_settings(); / Store the alert settings to the EEPROMint8_t restore_alert_settings(); / Read the alert settings from EEPROM/! The delay The delay between#define AUTOMATIC_MODE_DISPLAY_DELAY 1000 between
4、readings in automatic modeconst float resistor = 、 100; resistor value on demo board#define SCAN_MODE_DISPLAY_DELAY 10000 readings in scan modeCheck I2C Address 、 ; /! Error/ Error stringconst char ack_error = Error: No Acknowledge message/ Global variablesstatic int8_t demo_board_connected; Set to
5、1 if the board is connectedstatic uint8_t alert_code = 0; Value stored or read from ALERTregister 、 Shared between loop() and restore_alert_settings() Initialize Linduinovoid setup()char demo_name = DC1812 Demo Board Name stored in QuikEval EEPROMquikeval_I2C_init(); Configure the EEPROM I2C port fo
6、r 100kHzquikeval_I2C_connect(); Connects to main I2C portSerial 、 begin(115200); Initialize the serial port to the PCprint_title();demo_board_connected = discover_demo_board(demo_name); if (demo_board_connected)print_prompt();elsedemo_board_connected = true;Serial、 println(Did not read ID String, at
7、tempting to proceed anyway nPlease ensure I2C lines of Linduino are connected to the LTC device); Repeats Linduino loopvoid loop()int8_t ack = 0; I2C acknowledge indicatorstatic uint8_t user_command; The user input command static uint8_t mAh_or_Coulombs = 0;static uint8_t celcius_or_kelvin = 0;stati
8、c uint16_t prescalar_mode = LTC2943_PRESCALAR_M_4096;static uint16_t prescalarValue = 4096;static uint16_t alcc_mode = LTC2943_ALERT_MODE; Do nothing if the demo board is not Do nothing if serial is not available Read user input commandif (demo_board_connected) connectedif (Serial 、 available()user_
9、command = read_int(); if (user_command != m)Serial 、 println(user_command);Serial 、 println();ack = 0;switch (user_command) /! Prints the appropriate submenucase 1:ack |= menu_1_automatic_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); Automatic Modebreak;case 2:
10、ack |= menu_2_scan_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); Scan Modecase 3:ack |= menu_3_manual_mode(mAh_or_Coulombs, celcius_or_kelvin, prescalar_mode, prescalarValue, alcc_mode); Manual Modecase 4:ack |= menu_4_sleep_mode(mAh_or_Coulombs, prescalar_mode
11、, prescalarValue, alcc_mode); Sleep Modecase 5:ack |= menu_5_shutdown_mode(); Shutdown Modecase 6:ack |= menu_6_settings(&mAh_or_Coulombs, &celcius_or_kelvin, &prescalar_mode, &prescalarValue, &alcc_mode); Settings Mode If ack is not recieved printif (ack != 0) an error 、Serial 、 println(ack_error);
12、/ Function Definitions /! Print the title block void print_title()Serial 、*println(F(n*);*nSerial 、 print(F(* DC1812A Demonstration ProgramSerial 、print(F(* This program communicates with the LTC2943 Multicell Coulomb *n* Counter found on the DC1812A demo board 、* Set the baud rate to 115200 and sel
13、ect the newline terminator *nprint(F(*n Print the Prompt void print_prompt()n1-Automatic Moden2-Scan Moden3-Manual Moden4-Sleep Moden5-Shutdown Moden6-SettingsnEnter a command: Automatic Mode int8_t menu_1_automatic_mode(int8_t mAh_or_Coulombs, int8_t celcius_or_kelvin ,uint16_t prescalar_mode, uint
14、16_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 LTC2943_mode;LTC2943_mode = LTC2943_AUTOMATIC_MODE|prescalar_mode|alcc_mode ; Set the control register of the LTC2943 to automatic mode as w
15、ell as set prescalar and AL#/CC# pin values 、ack |= LTC2943_write(LTC2943_I2C_ADDRESS, LTC2943_CONTROL_REG, LTC2943_mode); Writes the set mode to the LTC2943 control registerprint(F(H*nndo uint8_t status_code, hightemp_code, lowtemp_code; uint16_t charge_code, current_code, voltage_code, temperature
16、_code;ack |= LTC2943_read_16_bits(LTC2943_I2C_ADDRESS,LTC2943_ACCUM_CHARGE_MSB_REG, &charge_code); Read MSB and LSB Accumulated Charge Registers for 16 bit charge codeLTC2943_VOLTAGE_MSB_REG, &voltage_code); Read MSB and LSB Voltage Registers for 16 bit voltage codeLTC2943_CURRENT_MSB_REG, ¤t_
17、code); Read MSB and LSB Current Registers for 16 bit current codeLTC2943_TEMPERATURE_MSB_REG, &temperature_code); Read MSB and LSB Temperature Registers for 16 bit temperature codeack |= LTC2943_read(LTC2943_I2C_ADDRESS, LTC2943_STATUS_REG, &status_code); Read Status Register for 8 bit status codefl
18、oat 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: Cncharge = LTC2943_code_to_mAh(charge_code, resistor, prescalarValue);Convert
19、charge code to mAh if mAh units are desired 、mAh:Serial 、 print(charge, 4); mAhncurrent = LTC2943_code_to_current(current_code, resistor);Convert current code to Amperesvoltage = LTC2943_code_to_voltage(voltage_code); Convert voltage code to VoltsCurrent Serial 、 print(current, 4); AnVoltage Serial
20、、 print(voltage, 4); Vnif(celcius_or_kelvin) temperature = LTC2943_code_to_kelvin_temperature(temperature_code); Convert temperature code to kelvinTemperature Serial 、 print(temperature, 4); Kntemperature = LTC2943_code_to_celcius_temperature(temperature_code); Convert temperature code to celciusche
21、ckAlerts(status_code); Check status code for Alerts 、 If an Alert has been set, print out appropriate message in the Serial Prompt 、m-Main MenunnSerial 、 flush();delay(AUTOMATIC_MODE_DISPLAY_DELAY); Delay for 1s before next pollingwhile (Serial 、 available() = false | (ack); if Serial isnot availabl
22、e 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,uint16_t prescalarValue, uint16_t alcc_mode) /! return Returns the sta
23、te of the acknowledge bit after the I2C address write 0=acknowledge, 1=no acknowledgeLTC2943_mode = LTC2943_SCAN_MODE|prescalar_mode|alcc_mode ; Set the control mode of the LTC2943 to scan mode as well as set prescalar and AL#/CC# pin values 、douint8_t status_code;uint16_t charge_code, current_code,
24、 voltage_code, temperature_code; Read MSB and LSBack |= LTC2943_read_16_bits(LTC2943_I2C_ADDRESS, LTC2943_ACCUM_CHARGE_MSB_REG, & Accumulated Charge Registers for 16 bit charge codeack |= LTC2943_read_16_bits(LTC2943_I2C_ADDRESS, LTC2943_VOLTAGE_MSB_REG, &Voltage Registers for 16 bit voltage codeack |= LTC2943_read_16_bits(LTC2943_I2C_ADDRESS, LTC2943_CURRENT_MSB_REG, &Current Registers for 16 bit current codeack |= LTC2943_read_16_bits(LTC2943_I2C_ADDRESS, LTC2943_TEMPERATURE_MSB_REG, & Read Status Registers for 8 bit status codefloat charge
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1