ADS1118 commissioning guidelines and analytical register

ADS1118 basic functions

TI's ADS1118 the ADC 16, and a built-1MHz oscillator reference voltage source, the conversion rate of 8 to 860 times per second, adjustable, range ± 0.256V to ± 6.144V adjustable, the menu may be ended or differential input, the internal integrated temperature sensor .

ADS1118 register

ADS1118 register is very simple, only two 16bit registers. Wherein a read-only register, the stored value after ADC conversion; the other is a configuration register, the configuration acquisition channel, positive and negative range, acquisition mode, acquisition rate, acquisition source (voltage or temperature) and the like.

ADS1118 conversion register

ADS1118 shift register length is 16 bits, complement coded form, each to save the result of the AD conversion.

ADS1118 configuration register

Place first name Read type The initial value description
15 SS Read and write 0h A single conversion is started only for the single conversion mode, write 1 represents the start conversion when there is no conversion write 0 does not work, write 1 has no effect when you are converting, this bit is always read as 0
14~12 MUX Read and write 0h Selected voltage input channel: 000 = Ain0 + Ain1- (differential); 001 = Ain0 + Ain3- (differential); 010 = Ain1 + Ain3- (differential); 011 = Ain2 + Ain3- (differential); 100 = Ain0 + (single side); 101 = Ain1 + (single-ended); 110 = Ain2 + (single-ended); 111 = Ain3 + (single-ended) a negative single-ended input to GND reference
11~9 PGA Read and write 2h Range selection: 000 = ± 6.144V; 001 = ± 4.096V; 010 = ± 2.048V; 011 = ± 1.024V; 100 = ± 0.512V; 101 = 110 = 111 = ± 0.256V;
8 MODE Read and write 1h Select conversion mode, continuous conversion mode = 0, 1 = single conversion mode (after completion of CPA becomes the power down state)
7~5 DR Read and write 4h Conversion rate: 8 = 000; 16 = 001; 32 = 010; 31 = 011; = 100 128; 101 = 250; = 110 475; 111 = 860 (times per second)
4 TS_MODE Read and write 0h Collect voltage = 0; 1 = collecting internal temperature sensor
3 PULLUP_EN Read and write 1h Controlling whether to enable the DOUT / DRDY pin internal weak pull-: 0 = no pull-up, pull-1 = (recommended)
2~1 NOP Read and write 1h Determine the parameter settings are valid: 01 = settings to take effect, ignore the other settings are all the ADS1118
0 Retention Read-only 1h Reserved bit, write 0 or write has no effect and read forever 1

ADS1118 read and write timing analysis

There are two read-write mode ADS1118: 32-Bit and 16-Bit Mode mode, two modes are MSB first. 32-Bit Mode for CS (Chip Select) pin is always lower case, 16-Bit mode is used when the chip select pin is controlled by the microcontroller IO.

32-Bit Mode

The 32-Bit Mode CS pin can remain low, save an IO port. 32-Bit mode can be divided into two, one is the setting register (16bit) written twice, the second one is written (after 16bit) After a write 0.
Two kinds of 32-Bit Mode Timing
The read only data format, the first 16 bits of the value stored in the shift register of the previous conversion to the 16-bit register just written. After each 32-Bit communication is completed, DOUT / DRDY pin is brought low again next time when the representative AD acquisition has been completed, data can be read.

16-Bit mode

16-Bit Mode requires communication between each of the two CS (Chip Select) pin to be pulled again. Each communication may be written into the configuration register values ​​read 16bit and 16bit value into the shift register.
Here Insert Picture Description

ADS1118 data format

Voltage acquisition data format

ADS1118 using complement data format, when acquiring the voltage, the read data can be directly assigned 16bit C language short (signed 16bit integer) according to the type and range of the voltage value obtained by multiplying the scale factor. Range and scale factor table below.

Range Scaling factor
±6.144V 187.5μV
±4.096V 125μV
±2.048V 62.5μV
±1.024V 31.25mV
±0.512V 15.625mV
±0.256V 7.8125mV

Temperature acquisition data format

16 ADS1118 temperature data obtained in the communication only 14 active high (the lower two bits is always 0), is a 14-bit signed integer. During processing the data may be in accordance with the first unsigned right shift (>>) 2, and then determines whether a position 14 (represented by a negative temperature), if it is 1 then 16-bit data of ( the most significant bit) by writing a 1, and removed position 14 1, can be converted to 16-bit signed integer (short) operation for the next step. Refer to the C language program as follows:

val = ((unsigned short)val) >> 2;//温度数据高十四位有效
if(val & 0x2000){//温度数据第十四位表明是否为负数
	unsigned short temp = ((unsigned short)val) ^ 0x2000;//第十四位清零
	temp = temp-1;//转换为反码
	temp = (~temp)&0x1FFF; //低十三位按位取反得原码
	val = -temp; //重新取负转换为十六位的补码格式
}

Test code

And comprising ADS1118.c ADS1118.h, encapsulate four single-ended channel acquisition function and the function of temperature acquisition, analog full-duplex SPI, STM32 HAL style library, transplant friends have to rename ADS1118_ReadWrite.

Released three original articles · won praise 1 · views 1546

Guess you like

Origin blog.csdn.net/humphreyandkate/article/details/104731073