The ADC devices currently in all three of my “homemade” tablets are a little under powered, so I’m upgrading some of them to use 18 bit Microchip MCP3426 ADC chips. A reasonably hand solderable chip package-type is the SOIC. Most of the newest, fastest most glam chips are not even available with old-time DIP packages anymore. This is seriously bad news for oldish guys like myself.
In addition to the ADCs (purchased via Mouser), some Adafruit eight pin SOIC breakout boards were obtained as well. I managed to build three homebrew ADC boards: dual channel, configurable (except for addressing), differential input, 18 bit ADC boards with I2C control and communication facilities. I was able to keep the cost inside of a cheap budget (about $3 for each board, not counting my labor). After soldering the chips to the SOIC breakout boards, I piggybacked each board onto (slightly larger) PCB proto boards, so that the latter could hold the few other needed components (pullup resistors, capacitors, etc). Let’s describe some of the things I can now do with this setup.
On the list of applications for the ADC is the replacement of some of my homemade tablet’s internal ADC devices.
In another application, I am combining one ADC with a Hardkernel USBIO (hardkernel.com). The USBIO board is indeed a versatile one, as it allows me to test all of the newly built ADC boards before I actually install them. What is the Hardkernel USBIO? It’s a board that connects to a USB port. It has onboard GPIO, ADC, SPI, I2C, and UART capabilities, which can be controlled by the client (connected via the USB). The newly built ADCs can be tested by connecting them to the USBIO board, using one of my homemade tablets, or for that matter a standard PC computer.
Figure 3 shows the I2C and power connections between the USBIO board and the newly minted ADC board. The pullups (recommended by Microchip for the lowest two speeds) are 5 k-ohms, thus my 4.7 k-ohm supply turns out to be very handy once again. They recommend lower values for higher speeds (as low as 1 k-ohm). Although not shown, pin pairs 1,2 and 7,8 on the MCP3426 are the two differential inputs for the ADC. Also recommended by the manufacturer were two capacitors (both placed between VDD and VSS) of .1uF and 10 uF, respectively.
Powering the device by plugging the USBIO micro USB cable into my PC, I measured the VDD pin on the USBIO board at 3.39 VDC. The board has a 3.3 VDC regulator on it. With the MCP3426, it wouldn’t matter, as the ADC can take from 2.7 VDC to 5.0 VDC for power. The differential input must be less than or equal to 2.048 volts though. On the Odroid C1, it’d be critical to stay at 3.3 VDC or less for anything connected to it (or 1.8 VDC on the XU4)! So, I’m glad the USB board has a regulator that puts it in parity with the C1/C1+.
Software will be needed. To start:
I downloaded the python library for accessing the MCP3426. This is a very handy library, as the MCP3426 is quite versatile, and has many configuration options to handle. This python library is on python.org, at:
It was necessary to set up the USB (client) side. For testing, I’m using my AMD64 PC with linux. First I install libusb-1.0-0-dev:
- sudo apt-get install libusb-1.0-0-dev
Then, I install the pyusb library:
- git clone https://github.com/walac/pyusb
- cd pyusb
- sudo python ./setup.py install
(assuming that setuptools is installed)
Then, Hardkernel supplies a nice library to go with the USBIO board:
I connect the board to the PC with a micro USB cable.
- cd Odroid-USBIO/usbio/linux
- sudo usbio
- sudo python usb-io-demo.py
OK, we’ve looked at the easy parts. Now we need to look more closely at the MCP3426, to know how we’ll interface with it. It is I2C configurable at 100KHz, 400 KHz, and 3.2 MHz. It’s samples-per-second rate is configurable also, and can be selected to be 15, 60, or 240.
It can be configured for a “one-shot, then sleep” mode or a “continuous” mode. The I2C address for the MCP3426 is factory established at some value between 0x68 and 0x6F inclusive. The addressing of 3427 and 3428 devices is more versatile, due to the additional two pins that are used for setting the addresss. My first test device was at 0x6A. The 3426 has a programmable gain of 1x, 2x, 4x, or 8x. The purpose of the one-shot mode is to conserve power. The unit can draw smallish micro-amps of current when it’s sleeping, and then awaken on an I2C wake-up call. The device draws only 350 micro-amps with running full-out.
The MCP342x python library is geared to work with smbus. For that reason, we’ll likely need to transport some of its MCP342x goodness to the USBIO software, in order to make the “remote” I2C connection. But, for grins, I connected the USBIO board to a Devuan Linux AMD64 PC, and started one of the example programs. In the same directory as the usb-io-demo.py example program (listed above), several other example programs can be found. There is a program for an I2C enabled mims compass board, and another program for an I2C enabled temperature and barometric pressure board.
First I used the usb-io-demo.py program to prove that I could turn an LED (located on the USBIO board) “on” and then “off”. That worked fine. So far, so good. Then I used one of the I2C programs (temperature, I think). When running, the program exited with a “time out” message, as it was waiting for an I2C device. This made good sense, as I had not connected any of the newly minted ADC boards to the USBIO. I did so, and retried the “temperature” program. It started spitting out data (much garbled nonsense data of course) – since the target chip of the example program was not an MCP3426! Of course. But, by all indications, we had communication going on.
So, what could happen (I suppose) – is the marrying of the MCP3426 goodness of the MCP342x python library to the USBIO protocol in one (select any) of the I2C example programs. Sounds easy, huh?
Note: the author does not have a recent, applicable background in circuit building, or battery related issues, so this is presented as the work of a hobbyist, and is not meant for duplication by others. Readers should look elsewhere for design advice and info.
Note: The MCP3426 ADC chip is a product of Microchip Technology, at http://www.microchip.com, and is not affiliated with this author or site. The Odroid C1 is a product of Hardkernel, at http://www.hardkernel.com, and is not affiliated with this author or site. The 8-pin SOIC breakout boards were purchased from Adafruit. They are at http://www.adafruit.com, and have no affiliation with this author or site. All other trademarks usd here are acknowledged as belonging to their respective owners. Any trademark references put in this text do not imply any affiliation with the owner of the trademark.