資料介紹
Table of Contents
AD7280A IIO Lithium Ion Battery Monitoring System Linux Driver
Supported Devices
Reference Circuits
Evaluation Boards
Description
This is a Linux industrial I/O (IIO) subsystem driver, targeting multi channel serial interface ADCs. The industrial I/O subsystem provides a unified framework for drivers for many different types of converters and sensors using a number of different physical interfaces (i2c, spi, etc). See IIO for more information.
The AD7280A contains all the functions required for general-purpose monitoring of stacked lithium ion batteries as used in hybrid electric vehicles, battery backup applications, and power tools. The part has multiplexed cell voltage and auxiliary ADC measurement channels for up to six cells of battery management. This driver supports the daisy-chain interface allowing up to eight parts to be stacked without the need for individual device isolation.
The driver automatically detects then number of devices present and creates the iio device files accordingly.
Source Code
Status
Files
Function | File |
---|---|
driver | drivers/staging/iio/adc/ad7280a.c |
include | drivers/staging/iio/adc/ad7280a.h |
Example platform device initialization
For compile time configuration, it’s common Linux practice to keep board- and application-specific configuration out of the main driver file, instead putting it into the board support file.
For devices on custom boards, as typical of embedded and SoC-(system-on-chip) based hardware, Linux uses platform_data to point to board-specific structures describing devices and how they are connected to the SoC. This can include available ports, chip variants, preferred modes, default initialization, additional pin roles, and so on. This shrinks the board-support packages (BSPs) and minimizes board and application specific #ifdefs in drivers.
Some device parameter may vary between applications and use cases. The platform_data for the device's “struct device” holds this information.
#define AD7280A_ACQ_TIME_400ns 0 #define AD7280A_ACQ_TIME_800ns 1 #define AD7280A_ACQ_TIME_1200ns 2 #define AD7280A_ACQ_TIME_1600ns 3 ? #define AD7280A_CONV_AVG_DIS 0 #define AD7280A_CONV_AVG_2 1 #define AD7280A_CONV_AVG_4 2 #define AD7280A_CONV_AVG_8 3 ? #define AD7280A_ALERT_REMOVE_VIN5 (1 << 2) #define AD7280A_ALERT_REMOVE_VIN4_VIN5 (2 << 2) #define AD7280A_ALERT_REMOVE_AUX5 (1 << 0) #define AD7280A_ALERT_REMOVE_AUX4_AUX5 (2 << 0) ? struct ad7280_platform_data { unsigned acquisition_time; unsigned conversion_averaging; unsigned chain_last_alert_ignore; bool thermistor_term_en; }
In case platform_data is not present or set to NULL, the driver will use following defaults:
static const struct ad7280_platform_data ad7280_default_pdata = { .acquisition_time = AD7280A_ACQ_TIME_400ns, .conversion_averaging = AD7280A_CONV_AVG_DIS, .thermistor_term_en = true, };
Declaring SPI slave devices
Unlike PCI or USB devices, SPI devices are not enumerated at the hardware level. Instead, the software must know which devices are connected on each SPI bus segment, and what slave selects these devices are using. For this reason, the kernel code must instantiate SPI devices explicitly. The most common method is to declare the SPI devices by bus number.
This method is appropriate when the SPI bus is a system bus, as in many embedded systems, wherein each SPI bus has a number which is known in advance. It is thus possible to pre-declare the SPI devices that inhabit this bus. This is done with an array of struct spi_board_info, which is registered by calling spi_register_board_info().
For more information see: Documentation/spi/spi-summary
Depending on the converter IC used, you may need to set the modalias accordingly, matching your part name. It may also required to adjust max_speed_hz. Please consult the datasheet, for maximum spi clock supported by the device in question.
static struct spi_board_info board_spi_board_info[] __initdata = { #if defined(CONFIG_AD7280A) || / defined(CONFIG_AD7280A_MODULE) { .modalias = "ad7280a", .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = GPIO_PF10 + MAX_CTRL_CS, /* CS, change it for your board */ .mode = SPI_MODE_1, .irq = IRQ_PF6 }, #endif };
static int __init board_init(void) { [--snip--] ? spi_register_board_info(board_spi_board_info, ARRAY_SIZE(board_spi_board_info)); ? [--snip--] ? return 0; } arch_initcall(board_init);
Adding Linux driver support
Configure kernel with “make menuconfig” (alternatively use “make xconfig” or “make qconfig”)
The AD7280A Driver depends on CONFIG_SPI
Linux Kernel Configuration Device Drivers ---> [*] Staging drivers ---> <*> Industrial I/O support ---> --- Industrial I/O support -*- Enable ring buffer support within IIO -*- Industrial I/O lock free software ring -*- Enable triggered sampling support *** Analog to digital converters *** [--snip--] <*> Analog Devices AD7280A Lithium Ion Battery Monitoring System [--snip--]
Hardware configuration
Driver testing
Each and every IIO device, typically a hardware chip, has a device folder under /sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under every of these directory folders reside a set of files, depending on the characteristics and features of the hardware device in question. These files are consistently generalized and documented in the IIO ABI documentation. In order to determine which IIO deviceX corresponds to which hardware device, the user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case the sequence in which the iio device drivers are loaded/registered is constant, the numbering is constant and may be known in advance.
This specifies any shell prompt running on the target
root:/> cd /sys/bus/iio/devices/ root:/sys/bus/iio/devices> ls device0 device0:event0 root:/sys/bus/iio/devices> cd device0 root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> ls -l drwxr-xr-x 3 root root 0 Mar 14 11:16 device0:event0 -rw-r--r-- 1 root root 4096 Mar 14 11:16 in-in_scale -r--r--r-- 1 root root 4096 Mar 14 11:16 in0-in12_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in0-in1_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in0-in1_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in0-in1_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in1-in2_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in1-in2_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in1-in2_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in10-in11_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in10-in11_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in10-in11_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in11-in12_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in11-in12_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in11-in12_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in2-in3_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in2-in3_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in2-in3_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in3-in4_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in3-in4_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in3-in4_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in4-in5_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in4-in5_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in4-in5_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in5-in6_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in5-in6_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in5-in6_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in6-in7_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in6-in7_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in6-in7_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in7-in8_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in7-in8_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in7-in8_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in8-in9_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in8-in9_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in8-in9_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 in9-in10_balance_switch_en -rw-r--r-- 1 root root 4096 Mar 14 11:16 in9-in10_balance_timer -r--r--r-- 1 root root 4096 Mar 14 11:16 in9-in10_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 name drwxr-xr-x 2 root root 0 Mar 14 11:16 power lrwxrwxrwx 1 root root 0 Mar 14 11:16 subsystem -> ../../../../../bus/iio -r--r--r-- 1 root root 4096 Mar 14 11:16 temp0_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp10_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp11_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp1_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp2_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp3_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp4_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp5_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp6_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp7_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp8_raw -r--r--r-- 1 root root 4096 Mar 14 11:16 temp9_raw -rw-r--r-- 1 root root 4096 Mar 14 11:16 temp_scale -rw-r--r-- 1 root root 4096 Mar 14 11:16 uevent root:/sys/devices/platform/bfin-spi.0/spi0.18/device0>
Show device name
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat name ad7280a
Show cell channel scale
Description:
scale to be applied to inX-inY_raw in order to obtain the measured voltage in millivolts.
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in-in_scale 0.976000
Show channel 0-1 measurement
Description:
Raw unscaled voltage measurement on cell channel in0-in1_raw
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in0-in1_raw 2254
U = in0-in1_raw * in-in_scale + offset = 2254 * 0.976000 + 1000 = 3199.904 mV
Show voltage across all cells measurement
Description:
Raw unscaled voltage measurement on all cell channel in0-inX_raw
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in0-in12_raw 27048
U = in0-in1_raw * in-in_scale + (cell_num * offset) = 27048 * 0.976000 + (12 * 1000) = 38398.848 mV
Show auxiliary/temperature channel scale
Description:
scale to be applied to tempX_raw in order to obtain the measured voltage in millivolts.
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat temp_scale 1.220000
Show auxiliary/temperature channel measurement
Description:
Shows high accuracy band gap temperature sensor temperature in milli degrees Celsius.
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat temp0_raw 2096
U = temp0_raw * temp_scale = 2096 * 1.220000 = 2557.12 mV
Enable cell balance output switch on channel 4-5
The AD7280A has cell balancing interface outputs designed to control external FET transistors to allow discharging of individual cells.
Description:
Writing 1 enables the cell balance output switch corresponding
to input Y. Writing 0 disables it. If the inY-inZ_balance_timer
is set to a none zero value, the corresponding switch will
enable for the programmed amount of time, before it
automatically disables.
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> echo 1 > in4-in5_balance_switch_en root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in4-in5_balance_switch_en 1 root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> echo 0 > in4-in5_balance_switch_en root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in4-in5_balance_switch_en 0 root:/sys/devices/platform/bfin-spi.0/spi0.18/device0>
Enable cell balance timer on channel 4-5
Description:
The inY-inZ_balance_timer file allows the user to program
individual times for each cell balance output. The AD7280A
allows the user to set the timer to a value from 0 minutes to
36.9 minutes. The resolution of the timer is 71.5 sec.
The value written is the on-time in milliseconds. When the
timer value is set 0, the timer is disabled. The cell balance
outputs are controlled only by inY-inZ_balance_switch_en.
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> echo 150000 > in4-in5_balance_timer root:/sys/devices/platform/bfin-spi.0/spi0.18/device0> cat in4-in5_balance_timer 143000 root:/sys/devices/platform/bfin-spi.0/spi0.18/device0>
Enabling cell and auxiliary/temperature channel threshold events
This specifies any shell prompt running on the target
root:/> cd /sys/bus/iio/devices/ root:/sys/bus/iio/devices> ls device0 device0:event0 root:/sys/bus/iio/devices> cd device0:event0 root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> ls -l -r--r--r-- 1 root root 4096 Mar 14 13:37 dev -rw-r--r-- 1 root root 4096 Mar 14 13:37 in-in_thresh_high_value -rw-r--r-- 1 root root 4096 Mar 14 13:37 in-in_thresh_low_value drwxr-xr-x 2 root root 0 Mar 14 13:37 power lrwxrwxrwx 1 root root 0 Mar 14 13:37 subsystem -> ../../../../../../bus/iio -rw-r--r-- 1 root root 4096 Mar 14 13:37 temp_thresh_high_value -rw-r--r-- 1 root root 4096 Mar 14 13:37 temp_thresh_low_value -rw-r--r-- 1 root root 4096 Mar 14 13:37 uevent root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0>
The AD7280A includes a dynamic alert function that can detect whether the cell voltages or auxiliary ADC inputs exceed an upper or lower limit defined by the user.
Description:
Specifies the value of threshold (_high|_low) that the device is comparing against.
This specifies any shell prompt running on the target
root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> echo 2300 > in-in_thresh_low_value root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> cat in-in_thresh_low_value 2285 root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> echo 4000 > in-in_thresh_high_value root:/sys/devices/platform/bfin-spi.0/spi0.18/device0/device0:event0> cat in-in_thresh_high_value 3994
More Information
- IIO mailing list: linux [dash] iio [at] vger [dot] kernel [dot] org
- CN0235 全隔離式鋰離子電池監控和保護系統
- AD5449 IIO DAC Linux驅動程序
- AD5380 IIO多通道Linux驅動程序DAC
- AD7291 IIO ADC Linux驅動程序
- AD5421 IIO DAC Linux驅動程序
- AD5360 IIO多通道Linux驅動程序DAC
- AD7303 IIO DAC Linux驅動程序
- AD5446 IIO DAC Linux驅動程序
- UG-252:AD7280A鋰離子電池監測系統評估板
- IIO單通道串行ADC Linux驅動程序
- AD9834 IIO直接數字合成Linux驅動程序
- AD9832 IIO直接數字合成Linux驅動程序
- AD7998 IIO ADC Linux驅動程序
- AD7887 IIO ADC Linux驅動程序
- AD5677R NanDAC+IIO Linux驅動程序
- 通信電源系統的守護者:鋰離子電池 164次閱讀
- 鋰離子電池的工作原理、特點及應用 2144次閱讀
- 典型鋰離子電池充電器電路圖分享 5406次閱讀
- 鋰離子電池的工作原理和結構 1923次閱讀
- 鋰離子電池的容量是多少?如何計算鋰離子電池容量? 1w次閱讀
- 詳解鋰離子電池膨脹原因 1147次閱讀
- 使用鋰離子電池設計應用時的注意事項 2321次閱讀
- 固態鋰離子電池的詳細資料解析 8650次閱讀
- 簡析鋰離子電池 4366次閱讀
- 鋰離子電池的組成及工作原理,鋰離子電池的安全隱患 1.5w次閱讀
- 解析鋰離子電池隔膜的生產過程 3.5w次閱讀
- 鋰離子電池作業原理及結構分析 5659次閱讀
- 基于高電壓鋰離子電池組的充電方法 9608次閱讀
- 全隔離式鋰離子電池監控和保護系統 2432次閱讀
- 鋰離子電池基礎知識大匯總 1w次閱讀
下載排行
本周
- 1電子電路原理第七版PDF電子教材免費下載
- 0.00 MB | 1491次下載 | 免費
- 2單片機典型實例介紹
- 18.19 MB | 95次下載 | 1 積分
- 3S7-200PLC編程實例詳細資料
- 1.17 MB | 27次下載 | 1 積分
- 4筆記本電腦主板的元件識別和講解說明
- 4.28 MB | 18次下載 | 4 積分
- 5開關電源原理及各功能電路詳解
- 0.38 MB | 11次下載 | 免費
- 6100W短波放大電路圖
- 0.05 MB | 4次下載 | 3 積分
- 7基于單片機和 SG3525的程控開關電源設計
- 0.23 MB | 4次下載 | 免費
- 8基于AT89C2051/4051單片機編程器的實驗
- 0.11 MB | 4次下載 | 免費
本月
- 1OrCAD10.5下載OrCAD10.5中文版軟件
- 0.00 MB | 234313次下載 | 免費
- 2PADS 9.0 2009最新版 -下載
- 0.00 MB | 66304次下載 | 免費
- 3protel99下載protel99軟件下載(中文版)
- 0.00 MB | 51209次下載 | 免費
- 4LabView 8.0 專業版下載 (3CD完整版)
- 0.00 MB | 51043次下載 | 免費
- 5555集成電路應用800例(新編版)
- 0.00 MB | 33562次下載 | 免費
- 6接口電路圖大全
- 未知 | 30320次下載 | 免費
- 7Multisim 10下載Multisim 10 中文版
- 0.00 MB | 28588次下載 | 免費
- 8開關電源設計實例指南
- 未知 | 21539次下載 | 免費
總榜
- 1matlab軟件下載入口
- 未知 | 935053次下載 | 免費
- 2protel99se軟件下載(可英文版轉中文版)
- 78.1 MB | 537793次下載 | 免費
- 3MATLAB 7.1 下載 (含軟件介紹)
- 未知 | 420026次下載 | 免費
- 4OrCAD10.5下載OrCAD10.5中文版軟件
- 0.00 MB | 234313次下載 | 免費
- 5Altium DXP2002下載入口
- 未知 | 233046次下載 | 免費
- 6電路仿真軟件multisim 10.0免費下載
- 340992 | 191183次下載 | 免費
- 7十天學會AVR單片機與C語言視頻教程 下載
- 158M | 183277次下載 | 免費
- 8proe5.0野火版下載(中文版免費下載)
- 未知 | 138039次下載 | 免費
評論
查看更多