Advertisement
microrobotics

ADS1110 High Precision A/D Converter, 16-Bit, I2C, Low Power

Apr 3rd, 2023
1,309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Here is an example code for the ADS1110 High Precision A/D Converter, 16-Bit, I2C, Low Power:
  3.  
  4. This code reads the voltage on a single-ended AIN0 input of the ADS1110 High Precision A/D Converter, 16-Bit, I2C, Low Power and prints the conversion result on the Serial Monitor of the Arduino IDE. The ADS1110 is configured for 16-bit resolution and 64 samples per second (SPS) using the configuration register. The conversion result is read from the conversion register and converted to a voltage using the formula (raw_value / 32767.0) * 2.048.
  5.  
  6. To use this code, connect the AIN0 input of the ADS1110 to a voltage source within the specified range of the ADS1110. Connect the SDA and SCL pins of the ADS1110 to the corresponding pins of the Arduino board (usually A4 and A5 for most Arduino boards). The ADS1110 should be powered with a 2.7-5.5V DC power source.
  7.  
  8. Note that this code only reads the voltage on a single-ended AIN0 input of the ADS1110. You can modify the code to read the voltage on other input channels or to use differential inputs. Also, note that the conversion speed and accuracy of the ADS1110 can be affected by various factors, such as the power supply voltage, the input voltage range, and the noise level of the system.
  9. */
  10.  
  11. #include <Wire.h>
  12.  
  13. #define ADS1110_ADDR 0x48
  14.  
  15. void setup() {
  16.   Serial.begin(9600);
  17.   Wire.begin();
  18. }
  19.  
  20. void loop() {
  21.   // Start conversion
  22.   Wire.beginTransmission(ADS1110_ADDR);
  23.   Wire.write(0x01); // Address pointer to configuration register
  24.   Wire.write(0x84); // Single-ended AIN0, 16-bit resolution, 64 SPS
  25.   Wire.endTransmission();
  26.  
  27.   // Wait for conversion to complete
  28.   delay(20); // 1/SPS + 1 ms margin
  29.  
  30.   // Read conversion result
  31.   Wire.beginTransmission(ADS1110_ADDR);
  32.   Wire.write(0x00); // Address pointer to conversion register
  33.   Wire.endTransmission();
  34.   Wire.requestFrom(ADS1110_ADDR, 2);
  35.   int16_t raw_value = (Wire.read() << 8) | Wire.read();
  36.   float voltage = (raw_value / 32767.0) * 2.048;
  37.  
  38.   // Print result
  39.   Serial.print("Raw value: ");
  40.   Serial.print(raw_value);
  41.   Serial.print(", Voltage: ");
  42.   Serial.println(voltage);
  43.  
  44.   // Wait for 1 second before taking the next reading
  45.   delay(1000);
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement