Last time, I discussed how to interface TI’s ADS1112 16-bit delta-sigma A/D converter with Arduino. Today I am going to introduce you to a set of easy-to-program A/D chips from Microchip. MCP3246/7/8 are a family of 16-bit Delta-Sigma A/D converters with an I2C interface. MCP3426 and MCP3427 both have two differential input channels, while MCP3429 has four differential input channels. The programming for all three devices are essentially the same, except for the number of available channels.

Compared to the ADS1112 library we discussed previously, you will find that the programming for MCP342X are strikingly similar — the layout of the configuration register is bit-wise identical compared to that of ADS1112 except for the default value of the A/D conversion resolution and the sample rate. ADS1112 defaults to 16 bit and 15 SPS, whereas MCP342X defaults to 14 bit and 240 SPS.

One key deference between ADS1112 and MCP342X is how the single-ended inputs are handled. In ADS1112, switching between single-ended and differential measurements changes the analog input pin reference. Under single-ended mode, AIN3 becomes the common input pin and AIN0 to AIN2 become the single-ended inputs. For MCP342X, single-ended operation is achieved by grounding the negative differential input of the channel. So ADS1112 has two differential channels and three single-ended channels and MCP342X has four differential and four single-ended channels. Due to this difference, the programming for MCP342X is actually easier as we do not need to distinguish single-ended and differential operations in code.

MCP3428 Reference Circuit (Courtesy  http://ww1.microchip.com/downloads/en/ DeviceDoc/22226a.pdf))
MCP3428 Reference Circuit (Courtesy http://ww1.microchip.com/downloads/en/ DeviceDoc/22226a.pdf))

The Arduino library can be downloaded at the end. As for the ADS1112 library, I only included 16-bit mode. For other resolution and sampling rate, you can change the S0 and S1 bits in the communication register in the selectChannel function. Since differential and single-ended input are handled essentially the same way (except for where the negative differential input is referenced), we do not need to distinguish these two modes in code and thus the mode parameter was dropped on purpose.

#include <MCP342X.h>
#include <Wire.h>

MCP342X mcp3428;

void setup()
{
  Wire.begin();
  Serial.begin(9600);

  mcp3428.init(MCP342X::L, MCP342X::L);
  mcp3428.selectChannel(MCP342X::CHANNEL_0, MCP342X::GAIN_1);
}

void loop()
{
    Serial.println(mcp3428.readADC(), 3);
    delay(100);
}

Here is a list of the available library functions and parameters:

init(byte A0, byte A1)
A0 and A1 are used in conjunction with the corresponding pin wiring to set the device I2C address. (MCP3426 does not have user selectable addresses)

selectChannel(byte channel, byte gain, byte mode)
channel: CHANNEL_0, CHANNEL_1, CHANNEL; in bi-polar mode, it is either CHANNEL_0 or CHANNEL_1 _2 or CHANNEL_3 (CHANNEL_2 and CHANNEL_3 only available for MCP3428)
gain: GAIN_1, GAIN_2, GAIN_4 or GAIN_8

readADC()
get the AD conversion result based on the parameters selected using selectChannel

MCP3428 on Breadboard
MCP3428 on Breadboard

Download: MCP342X Library

Be Sociable, Share!