The MCP3208 12-bit analog-to-digitial converter is the basis of my battery load test analyzer and online monitoring system which I call pid3A . As I have mentioned before, I implemented a bit-banged SPI driver for the mcp3208 in the perl programming language. I use the analog-to-digital converters (adc’s) to sample the voltages of each cell in the battery plant at regular intervals to make graphs of the discharge curves.

pid3A is in it’s 2nd prototype and can accurately measure up to 24 cell voltages at a time with it’s three 8-channel mcp3208’s. Occasionally, I will burn up a single channel on one of the adc’s, rendering the whole chip useless for my application.
I have written a lot of diagnostic software for pid3A to make sure the adc’s are functioning properly before I begin an IEEE450 load test. To test all 24 channels, I made a test plug that puts 2.5VDC on each channel, takes 5 samples, and give the the binary output code and actual voltage of each sample. It then gives me a color-coded go/no-go visual indication. If there are any bad channels, I just change out the adc chip and re-run the diagnostic test.

Here is a sample of the output:

You can see that the adc output codes and voltages are very steady. The voltage is a function of the digital output code of the adc. Above, most of the output codes are 2049. Knowing this, and the reference voltage of 4.998VDC, you can calculate the actual voltage using this equation:

This is absolutely necessary for troubleshooting quickly, but sometimes I need to know what is going on at a microscopic level. My multi-channel logic analyzer is the perfect tool to look at the underlying SPI protocol.

I know this just looks like a mess of wires, but I have my logic analyzer hooked up to the data-in, data-out, chip select, and clock lines of one of my mcp3208 chips. Here is a close up of a frame from my diagnostic script:

This shows the driver clocking in 19 pulses. The first few bits on the MOSI line tell the adc to use single (as opposed to differential) mode, and sample channel 001. The rest of the MOSI bits are ‘don’t care’ bits, so my driver just set them all high. The MISO line is the mcp3208 clocking out the actual binary output code. In this case it is 2045, which in binary is 011111111101. The slave select line goes low to initiate a sample, and goes high when finished. PulseView shows me precisely what is happening, and lets me easily analyze the SPI protocol for proper function per the datasheet below:
