Homebrewing a Board for the MCP3426 ADC (2)

circuit3426-g-ccoolleerr2Continued from previous page one …

I’ll contemplate exactly how I’ll do the marriage thing.  Meanwhile, I put one of the other proto boards into my second “homemade” tablet, and tried to read a battery voltage with the ADC.

As noted on the previous page, I used git to get the source for the python MCP342x library.  Then, I made sure that the I2C module was loaded:

lsmod |grep i2c-dev

I changed the directory to be the installation directory, and installed the library:

  • cd python-MCP342x
  • sudo python ./setup.py install

I changed the directory to be the examples directory:

  • cd ~/python-MCP342x/MCP342x/examples

In the examples directory, I edited the convert_and_read_many.py program file, changing the model number in the initialization to be MCP3426.  The program has a different model number designated by default, and if it’s not correct, it’ll not play.  Next, I had to find the place in the code where the resolution was set to 18 bits, and change it to 16 bits.  Apparently, the library was created while using one of the slightly more powerful ADC chips.

It was necessary to reduce the number of channels (four are specified in the original example code, but the MCP3426 does not have four channels).  I had to change the address from the 0x68 found in the example code, to 0x6a (my device, the address of which was found via the (i2cdetect -y 1) command line).  Once that was done,  I ran the example program:

  • sudo python convert_and_read_many.py

The result was:

firstADC-result3426-1Figure 2The first test of the MCP3426 new ADC in the second tablet.

Success!  The 1.3399375 volts is the NiMH battery voltage !

 

To be continued …

 

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 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. “Raspberry Pi” is a trademark of the Raspberry Pi Foundation, and they are not affiliated with this page or author.