Need help with SPI device MCP4131 10k Digital Pot

I could really use some help!

Let me outline what I have been doing first.

I have an Xbox 360 wireless controller and I am replacing the mechanical Pot with digital ones, run by Arduino Micro(Leonardo Chip seems to be the same). The mechanical ones are 10k, and the digital ones I bought are also 10k Pots.

The Analog Pots run off of 1.6v(Buttons are 1.8v, and everything else is 3.3 i think).

The Digital Pots are SPI, here is DATASHEET:http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General%20IC/22060b.pdf

So noticing that the MISO and MOSI are all on one pin, but use a 4.7k Resistor briged between MISO, and MOSI on the arduino, and that works awesome.

Clock on the Clock PIN for the micro.

Using SS(pin 10) for one POT and Pin 9 for the other.

A and B, one to Voltage, in this case 1.6v(the main power for the IC is 5v from the Arduino)

Wiper is out to Game Controller.

Here is my code, you’ll notice I dumbed down the code a bit, as i thought i made it too complicated, and that was my problem, but it wasn’t. Any here it is:

FIRST PAGE:

#include <SPI.h>



int value_A  = 0;
int value_B  = 0;
int const POT_A = 10;
int const POT_B =  9;
int xReading = 0;
int yReading = 0;

int readWiper1;
int readWiper2;

void setup() {
   // start serial port
  Serial.begin(115200);
  pinMode(POT_A, OUTPUT);
  pinMode(POT_B, OUTPUT);
  initSPI();  //intialize the SPI
  disable_POT_A();
  disable_POT_B();
  
  

} 

void loop() { 
  
  outPutY();
  outPutX();
  
  readWipers();

}
void outPutX()
{
  xReading  = analogRead(A0);
  int xAxis = map(xReading, 0, 335, 0, 128);
  value_A = xAxis;
  setTap_A();  
}

void outPutY()
{
  yReading = analogRead(A1);
  int yAxis = map(yReading, 0, 335, 0, 128);
  value_B = yAxis;
  setTap_B();    //just like A
}

void readWipers()
{
  readWiper1 = analogRead(A4);
  readWiper2 = analogRead(A5);
   Serial.println(readWiper1);
   Serial.println(readWiper2);
  delay(1);
}

SECOND PAGE:

void initSPI()
{
        SPI.begin();
	SPI.setBitOrder(MSBFIRST);
	SPI.setDataMode(SPI_MODE0);
	SPI.setClockDivider(SPI_CLOCK_DIV128);
}

void enable_POT_A()
{
  // take the SS pin low to select the chip:
	digitalWrite(POT_A, LOW);
}

void enable_POT_B()
{
  // take the SS pin low to select the chip:
	digitalWrite(POT_B, LOW);
}

void disable_POT_A()
{
  //take the SS pin HIGH to deselect the Chip
  digitalWrite(POT_A, HIGH);
}

void disable_POT_B()
{
  //take the SS pin HIGH to deselect the Chip
  digitalWrite(POT_B, HIGH);
}

void setTap_A()
{
  disable_POT_B();
  enable_POT_A();
  SPI.transfer(0);
  SPI.transfer(value_A);
  //  send in the address and value via SPI:
	//byte h = 0x03 & (value_A >> 8);
	//byte l = 0x00FF & value_A;

  //h = h | 0x02; //make sure the error checking bit is high	

	//byte ret1 = 0x02 & SPI.transfer(h); //we only want the error bit
	//byte ret2 = SPI.transfer(l);

 disable_POT_A();
  
}

void setTap_B()
{
  disable_POT_A();
  enable_POT_B();
  SPI.transfer(0);
  SPI.transfer(value_B);
  //  send in the address and value via SPI:
	//byte h = 0x03 & (value_B >> 8);
	//byte l = 0x00FF & value_B;

  //h = h | 0x02; //make sure the error checking bit is high	

	//byte ret1 = 0x02 & SPI.transfer(h); //we only want the error bit
	//byte ret2 = SPI.transfer(l);

 disable_POT_B();
  
}

The output works great on the Y axis, absolutely perfect!

But I get nothing on the X axis.

I think it is just how I am address things, as I don’t have much SPI experience( I usually use i2c, but still new to that as well).

So youll see at the end of the code I made some analog input so I could read the wiper out instead of sending it to the game controller.

If I have both plugged in, one wiper moves while the other freezes, unless I unplug the other, then it reads fine…hope that make sense,…

Thanks in advance, I hope someone can help:O)

~Bobby

Ive been trying to look over the datasheet, am I just not addressing them correctly? I thought that whatever line was LOW is the SS that is written to, while keeping the other HIGH.

Ok, so I hooked it all up to a Leonardo(Should be the same Pin for Pin right?), well I don't think it is, because the same code is NOT working the same. So i think this is my problem, is it possible that the Pin assignments are not the same...The Pin maps I find online say that they are...could anyone be more accurate about this?

~Bobby

Ok Noob alert! Once things were 'actually' hooked up right for the Micro it worked just fine, so it was my wiring! Not that I found the problem, but at least I know it was operator error!

~B