I have a circuit with 6 MCP4162-103/P digital 10k pots.
I started with one and expanded it to 6.
The object is a HW/SW training exercise.
I have a program that works repeatedly and flawlessly cycling the resistance of the pots one at a time.
It starts with them all off and one by one reduces the resistance so the voltage at the wiper will drive a led.
My plan for the next phase was to add analog input. I tested all the analog inputs using an SD Datalogger
example program I found that uses a potentiometer to vary the input voltage and saves it to a datalog.txt
file on the SD card. One of my objectives was to build (breadboard) a data acquisition system. So there’s
no problem with that. It works fine. The problem is when I tried to combine the analog input and the
six digital pot program to read the changing voltages on the wipers and display them on the serial port.
The serial output is no problem but somehow I just don’t get the “IF” statement usage right. When I take
the working six pot program and add IF statements based on the SSelectPin (the SPI CS for each of the
pots) the program doesn’t cycle any more. Only pot 4 cycles.
Here’s the wiring:
DigPot-1 CS = Arduino UNO dig-10-----------=>Analog Input A5
DigPot-2 CS = Arduino UNO dig-9-----------=>Analog Input A4
DigPot-3 CS = Arduino UNO dig-8-----------=>Analog Input A3
DigPot-4 CS = Arduino UNO dig-7-----------=>Analog Input A2
DigPot-5 CS = Arduino UNO dig-8-----------=>Analog Input A1
DigPot-6 CS = Arduino UNO dig-6-----------=>Analog Input A0
I wired it this way thinking I could take advantage of the relationship between the ascending CS and the descending
dig Output pin numbers using "Analog Input#= (SSelectPin-5) but realized that the designation for the analog inputs
start with an “A” (A0, A1 etc…) and I couldn’t figure out how to make it work so in desperation I made some IF
The attached files are:
SIX_DIGITAL_POTS_6.ino (perfectly functioning pot cycling , led illuminating program)
Data_Acquisition_14 (A completely nonfunctional program )
It got changed that many times because I was too embarassed to ask for help but now I would
rather byte the bullet if I can get it working. I still have add the thermocouple /LCD display (that works standalone)
and the I2C LCD (also works standalone) and the I2C 6-Digit-7-Segment LCD which works (cycles through a test
routine) but I haven’t learned to interpret the figure out the HT1621B datasheet pdf to program it .
All the display stuff will have to wait because if I can’t acquire the data there is nothing to display if you know what
I’m sure I did something really dumb in the IF statement department but I had to try anyway.
SIX_DIGITAL_POTS_FINAL_6.ino (5.17 KB)
Data_Acquisition_14.ino (14.9 KB)