Unable to get full resolution with digital potentiometer MCP4151

Hi everyone,

I’m trying to use the digital potentiometer MCP4151 (I tried both the models with 5 and 10 KOhms resistance) to replace a classical potentiometer, the goal being to be able to vary the voltage between (approximately) 0 and 5V.

I tried to use this example, which I think I adapted for my model of micro controller and my board (Arduino Mega).

It kind of work, but not totally the way I expected. First, the maximum voltage I get on the wiper output is around 3.9V, while I’m feeding it with the 5V from Arduino. Even if I send it 255 (well at least I think I do) it still never goes higher.

Secondly, I’m not sure the resistance is really changing in a linear fashion. When I increment the data byte sent to set the resistance value bit by bit, there are some steps at which the output voltage is not modified at all, and when it is it’s only by 0.01V. And after reaching a certain point it then increases faster and eventually reaches 3.92V when I send 255.

I know this is a very peculiar case and not many people is using this particuliar microcontoller, but I was wondering if by chance someone ever ran into a similar issue

How is it wired?

Also - terminology - the microcontroller is the arduino mega (well, the ATmega2560 on the arduino mega). The MCP4151 is a digital potentiometer, not a microcontroller.

Yup sorry for the terminology, the MCP looks like a microcontroller so...

I wired Vdd and Vss on 5V and GND of the Arduino, then :

CS is on Pin 53 (SS pin of the arduino mega)

SCK on Pin 52 (SCK pin of the arduino)

SDI/SDO on Pin 51 (MOSI pin of the arduino)

P0A is on 5V from Arduino as well, P0B on GND from Arduino

Finally, I read the wiper value with one of my analog pin

Okay sorry I'm too dumb and deserve death by fire, I just had a resistor and led wired on the wiper output, in parallel with the arduino's analog pin. I unplugged it and now it's working perfectly. I guess the arduino's 5V couldn't feed enough current to both or something...

francoisdtf:
Okay sorry I'm too dumb and deserve death by fire, I just had a resistor and led wired on the wiper output, in parallel with the arduino's analog pin. I unplugged it and now it's working perfectly. I guess the arduino's 5V couldn't feed enough current to both or something...

It's not the Arduino's 5v that was unable to supply it, you were putting a load in series with a large (high value) resistor. The LED will draw current and throw off the voltage divider. Since the full scale of that pot is at least 5k, while the resistor in series with the LED is probably under 1k; once the voltage on the output is high enough that the LED begins to conduct, that will dominate, and start to throw off the results.