Interfacing MCP4151 with Arduino Uno

I am using SPI to interface an MCP4151 with my Arduino Uno. Nothing I’ve researched seems to work, I am thinking it’s either something glaringly obvious or a hardware issue.

I am using the standard SPI pins for the arduino (SCK pin 13, MOSI pin 11, SS pin 10). I am measuring the resistance between pins 5 and 6 and getting 850 ohms on both of the MCP ICs I have.

#include <SPI.h>

byte address = 0x00;

void setup() {

  pinMode(10, OUTPUT);
  
  SPI.begin ();
  
}

void loop() {

  digitalWrite(10, LOW);        
 
  SPI.transfer(address);
  SPI.transfer(200);

  digitalWrite(10, HIGH);  
  
}

Any suggestions would be greatly appreciated.

Thanks, Jon

koalathejon:
I am using SPI to interface an MCP4151 with my Arduino Uno. Nothing I’ve researched seems to work, I am thinking it’s either something glaringly obvious or a hardware issue…

sounds like it could be hardware…

did you try using the increment/decrement command to see if the wiper resistance changes?

something like this in code:
(compiled, NOT tested!)

#include <SPI.h>

byte wiper_addr = 0x00;
byte increment_cmd = 0x04;
byte decrement_cmd = 0x08;
byte CS_pin = 10;
void setup() {

  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
  pinMode(CS_pin, OUTPUT);
  digitalWrite(CS_pin, HIGH);

}

void loop() {
  int16_t cnt = 0;

  while (cnt < 256) { //assumption: 8-bit digital pot
    digitalWrite(CS_pin, LOW);
    SPI.transfer(wiper_addr | increment_cmd); //increment pot
    digitalWrite(CS_pin, HIGH);
    delay(1000); //arbitrary delay
    ++cnt;
  }
   
  delay(2000); //arbitrary delay

  while (cnt > 0) { //assumption: 8-bit digital pot
    digitalWrite(CS_pin, LOW);
    SPI.transfer(wiper_addr | decrement_cmd); //decrement pot
    digitalWrite(CS_pin, HIGH);
    delay(1000); //arbitrary delay
    --cnt;
  }

}

/*
int digitalPotWrite(int value)
{
digitalWrite(CS_pin, LOW);
SPI.transfer(wiper_addr);
SPI.transfer(value);
digitalWrite(CS_pin, HIGH);
}
*/

hope that helps

Thanks for the quick reply!

The resistance is now reading ~4.88k which I assume means the wiper is in the middle position? But the wiper isn't moving as per the code.

I checked on both MCP's and both Arduino Uno's I have.

Jon