SPI for MAX5401, Need Help

I'm trying to use the MAX 5401 as a gain potentiometer for a simple inverting op amp configuration. However, to test if the MAX 5401 is working, I attempted to wire it in series with an led and power source and was going to use a multimeter to read its resistance. I cannot get the digital potentiometer to work correctly and have little knowledge of SPI. I used the code below and it's not working correctly. Can someone please help me.

/*
this program taken from arduino Example .
modified by By Mohannad Rawashdeh
http://www.genotronex.com
https://www.instructables.com/

This code used to control the digital potentiometer
MCP41100 connected to arduino Board
CS >>> D10
SCLK >> D13
DI >>> D11
PA0 TO VCC
PBO TO GND
PW0 TO led with resistor 100ohm .
*/
#include <SPI.h>
byte address = 0x11;
int CS= 10;
int i=0;

void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();
// adjust high and low resistance of potentiometer
// adjust Highest Resistance .
digitalPotWrite(0x00);
delay(1000);

  // adjust  wiper in the  Mid point  .

digitalPotWrite(0x80);
delay(1000);

// adjust Lowest Resistance .
digitalPotWrite(0xFF);
delay(1000);
}

void loop()
{
for (i = 0; i <= 255; i++)
{
digitalPotWrite(i);
delay(10);
}
delay(500);
for (i = 255; i >= 0; i--)
{
digitalPotWrite(i);
delay(10);
}
}

int digitalPotWrite(int value)
{
digitalWrite(CS, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}

I guess the commands for controlling the digital potentiometers are different - MCP41100 and MAX5401.

If I have read the datasheet correct, then you only to send the desired pot value (0-255) to the MAX5401.

so in the int digitalPotWrite(int value) routine, simply comment out SPI.transfer(address);

ie

int digitalPotWrite(int value){
digitalWrite(CS, LOW);
//SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}

Hope that helps....

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.