Home Code Arduino and MCP3424 A/D converter example

Arduino and MCP3424 A/D converter example

by shedboy71
[lebox id="1"]

Arduino and MCP3424 A/D converter example, lets look at the device.

The MCP3424 is a four channel low-noise, high accuracy delta-sigma A/D converter with differential inputs and up to 18 bits of resolution. The on-board precision 2.048V reference voltage enables an input range of ±2.048V differentially. The device uses a two-wire I2C™ compatible serial interface and operates from a single power supply ranging from 2.7V to 5.5V.

The MCP3424 device performs conversions at rates of 3.75, 15, 60 or 240 samples per second depending on user controllable configuration bit settings using the two-wire I2C™ compatible serial interface. The I2C™ address is user configurable with two address selection pins. This device has an onboard programmable gain amplifier (PGA). User can select the PGA gain of x1, x2, x4, or x8 before the analog-to-digital conversion takes place. This allows the MCP3424 device to convert a smaller input signal with high resolution. The device has two conversion modes: (a) Continuous mode and (b) One-Shot mode.

In One-Shot mode, the device enters a low current standby mode automatically after one conversion. This reduces current consumption greatly during idle periods. The MCP3424 device can be used for various high accuracy analog-to-digital data conversion applications where ease of use, low power consumption and small footprint are major considerations.

Features
    • 18-bit resolution
    • 4-channel differential input operation
    • Differential input operation
    • On-board voltage reference with 15 ppm/°C drift
    • On-board PGA, gains of 1, 2, 4, 8
    • Programmable data rate options
      • 3.75 SPS (18 bits)
      • 15 SPS (16 bits)
      • 60 SPS (14 bits)
      • 240 SPS (12 bits)
    • INL 10 ppm of FSR max
    • Low current consumption, 135 µA at 3V
    • One-shot or continuous conversion options
    • Supports I2C™ serial interface with user configurable addresses
    • Extended temperature range: -40°C to +125°C

 

Parts List

Part Link
Arduino Uno UNO R3 CH340G/ATmega328P, compatible for Arduino UNO
MCP3424 module MCP3424 Digital I2C ADC-4 Channel Conversion Module
Connecting cable Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Code

You need to install the following library – https://github.com/bersch/MCP3424

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <MCP3424.h>

MCP3424 adc(PIN_FLOAT, PIN_FLOAT);

void setup() 
{
    Serial.begin(9600);
    Wire.begin();
    adc.generalCall(GC_RESET);
    adc.creg[CH1].bits = { GAINx1, SR18B, CONTINUOUS, CH1, 1 };
}

double value;
static char * errmsg[] = {"", "underflow", "overflow", "i2c", "in progress", "timeout"};

void loop() 
{
    ConvStatus err = adc.read(CH1, value);
    if (err == R_OK) 
      Serial.println(value, DEC); 
    else 
    {
      Serial.print("conversion error: ");
      Serial.println(errmsg[err]);
    }
    asm volatile ("nop");
}

[/codesyntax]

Output

Open the serial monitor – the low reading was ground and the higher reading was 3.3v

2.0479843616
2.0479843616
2.0479843616
0.0402031278
0.0402031278
0.0401875019
0.0401875019
0.0401875019
0.0401875019
0.0401875019
0.0401875019
0.0401718759
0.0401406240
1.9360313415
2.0479843616
2.0479843616

Share
[lebox id="2"]

You may also like

Leave a Comment