Controlling 10-bit digital pot & read the voltage using analog input: Arduino Uno

I am using a 10-bit digital pot
MAX5494 Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX5494-MAX5499.pdf
According to the datasheet, the last 6 digits of the 24-bit register should be shifted so that 10-bit data is in register bits 9 to 18.
I have referred to the following thread
[SOLVED] MAX5494 10k Digipot and SPI - Resolution/taps issues - #12 by GTC
However, my script does not have the expected results. The POT changes the resistance for 8 steps and then stops modifying the resistance. Can someone help me with identifying the problem?
To debug, I printed every 8 bytes of the POT register and the voltage recorded with analog pin 0. The register values seem to change correctly for the first ramp up and ramp down, but the voltage that corresponds to changing resistance does not.

My code

#include <SPI.h>
 const uint8_t  CSpin = 10;
 
void setup() {
  // put your setup code here, to run once:
  SPI.begin();
  pinMode(CSpin, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
  //for (uint16_t i=0;   i<1024; i+100)
  uint16_t i=0;
  while( i<1009) ////new line
  {
    update_digipot(0x01, i);
    //delay(10000);
    //Serial.print(i);
    Serial.print("step: "); Serial.print(i); Serial.print("\t"); 
    Serial.print("Voltage: "); Serial.print(analogRead(0)*5.00/1023); Serial.println("V");
    i=i+100;//new line
  }
  ++i;
  update_digipot(0x01, i);
  //delay(10000);
  //Serial.print(i);
  Serial.print("step: "); Serial.print(i); Serial.print("\t"); 
  Serial.print("Voltage: "); Serial.print(analogRead(0)*5.00/1023); Serial.println("V");
    
  delay(30000);
  while( i>0) ////new line
  {
    update_digipot(0x01, i);
    //delay(10000);
    //Serial.print(i);
    Serial.print("step: "); Serial.print(i); Serial.print("\t"); 
    Serial.print("Voltage: "); Serial.print(analogRead(0)*5.00/1023); Serial.println("V");
    i=i-100;//new line
  }
}

void update_digipot(uint8_t reg, uint16_t value)
{
  union
  {
    uint16_t val;
    uint8_t bytes[2];
  } in;

  in.val  = value << 6; //as per datasheet
  //in.val  = value;//assuming 6 bit shift is not working
  digitalWrite(CSpin, LOW);
  //Write Wiper Register. 0x01; wiper 1 ; 0x02 wiper2
  SPI.transfer(reg);
  //send upper value byte
  SPI.transfer(in.bytes[1]);
  //send lower value byte
  SPI.transfer(in.bytes[0]);
  digitalWrite(CSpin, HIGH);
  
  delay(10000);
  Serial.print("Hello ");Serial.print("\t"); 
  Serial.print(reg);Serial.print("\t"); 
  Serial.print(in.bytes[1]); Serial.print("\t"); 
  Serial.print(in.bytes[0]);Serial.print("\t"); 
  
}

//Serial port output

ello 1 0 0 step: 0 Voltage: 2.56V
12:00:03.012 -> Hello 1 25 0 step: 100 Voltage: 2.38V
12:00:12.971 -> Hello 1 50 0 step: 200 Voltage: 2.26V
12:00:22.984 -> Hello 1 75 0 step: 300 Voltage: 2.24V
12:00:32.958 -> Hello 1 100 0 step: 400 Voltage: 2.21V
12:00:42.965 -> Hello 1 125 0 step: 500 Voltage: 2.27V
12:00:52.934 -> Hello 1 150 0 step: 600 Voltage: 2.18V
12:01:02.939 -> Hello 1 175 0 step: 700 Voltage: 2.19V
12:01:12.943 -> Hello 1 200 0 step: 800 Voltage: 2.19V
12:01:22.909 -> Hello 1 225 0 step: 900 Voltage: 2.18V
12:01:32.907 -> Hello 1 250 0 step: 1000 Voltage: 2.17V
12:01:42.887 -> Hello 1 19 64 step: 1101 Voltage: 2.17V
12:02:22.844 -> Hello 1 19 64 step: 1101 Voltage: 2.17V
12:02:32.862 -> Hello 1 250 64 step: 1001 Voltage: 2.17V
12:02:42.829 -> Hello 1 225 64 step: 901 Voltage: 2.16V
12:02:52.825 -> Hello 1 200 64 step: 801 Voltage: 2.16V
12:03:02.819 -> Hello 1 175 64 step: 701 Voltage: 2.17V
12:03:12.803 -> Hello 1 150 64 step: 601 Voltage: 2.17V
12:03:22.795 -> Hello 1 125 64 step: 501 Voltage: 2.17V
12:03:32.791 -> Hello 1 100 64 step: 401 Voltage: 2.16V
12:03:42.795 -> Hello 1 75 64 step: 301 Voltage: 2.16V
12:03:52.782 -> Hello 1 50 64 step: 201 Voltage: 2.17V
12:04:02.770 -> Hello 1 25 64 step: 101 Voltage: 2.17V
12:04:12.760 -> Hello 1 0 64 step: 1 Voltage: 2.16V
12:04:22.759 -> Hello 1 231 64 step: 65437 Voltage: 2.16V
12:04:32.733 -> Hello 1 206 64 step: 65337 Voltage: 2.17V
12:04:42.736 -> Hello 1 181 64 step: 65237 Voltage: 2.17V
12:04:52.718 -> Hello 1 156 64 step: 65137 Voltage: 2.17V
12:05:02.718 -> Hello 1 131 64 step: 65037 Voltage: 2.17V
12:05:12.692 -> Hello 1 106 64 step: 64937 Voltage: 2.17V
12:05:22.706 -> Hello 1 81 64 step: 64837 Voltage: 2.17V
12:05:32.680 -> Hello 1 56 64 step: 64737 Voltage: 2.17V
12:05:42.683 -> Hello 1 31 64 step: 64637 Voltage: 2.16V
12:05:52.647 -> Hello 1 6 64 step: 64537 Voltage: 2.17V
12:06:02.664 -> Hello 1 237 64 step: 64437 Voltage: 2.17V
12:06:12.630 -> Hello 1 212 64 step: 64337 Voltage: 2.16V
12:06:22.650 -> Hello 1 187 64 step: 64237 Voltage: 2.17V
12:06:32.645 -> Hello 1 162 64 step: 64137 Voltage: 2.17V
12:06:42.639 -> Hello 1 137 64 step: 64037 Voltage: 2.17V
12:06:52.622 -> Hello 1 112 64 step: 63937 Voltage: 2.17V
12:07:02.587 -> Hello 1 87 64 step: 63837 Voltage: 2.16V
12:07:12.597 -> Hello 1 62 64 step: 63737 Voltage: 2.17V
12:07:22.573 -> Hello 1 37 64 step: 63637 Voltage: 2.17V
12:07:32.557 -> Hello 1 12 64 step: 63537 Voltage: 2.17V
12:07:42.571 -> Hello 1 243 64 step: 63437 Voltage: 2.17V
12:07:52.538 -> Hello 1 218 64 step: 63337 Voltage: 2.17V
12:08:02.532 -> Hello 1 193 64 step: 63237 Voltage: 2.17V

It's the 7th character in line 327.

Edit - OP went back and edited their post. It had no code.

Can you post a schematic as you have it wired, not a frizzy picture showing all connections including power and ground. Also include links to technical information on all hardware devices.

I am using

  1. Arduino UNO R3
  2. Digital Potentiometer https://media.digikey.com/pdf/Data%20Sheets/MikroElektronika%20PDFs/MIKROE-2873_Web.pdf

Connections:
Arduino to Mikrow-2873 DIGI POT4
SPI bus pins [Pin 10 - CS, Pin 11- SDI, & Pin 13- SCK]
5V Pin- 5V
GND- GND
A0-Wiper1

With the information given so far It will not work. A schematic would save a lot of time and effort. What are H1, H2, L1, L2, W1, W2, A0 connected to? How is the VCC jumpered? All of this would have been shown on a schematic.

When you add information, please don't edit your original post. Just add it in a new message. Thanks.

This is sounding like some disappointingly ill-fated attempt to use an analog connection as a communication between two Arduinos! :thinking:

Hi,
PLEASE post a schematic of your project?
A hand drawn image will be fine.
Please include power supplies, component names, and pin labels.

An image of your project will also help.

Thanks.. Tom.... :smiley: :+1: :australia: :coffee:

Sorry, I was not able to figure out how to do a schematic with an Arduino board. I have only used Spice before for schematics.
I used Powerpoint to show the connections. I hope this schematic will help to clarify the question.

Don't you know that if you want a pig to go forwards you have to pull it's tail. :grin:
Maybe next time ask for a Frizzy picture. Maybe then you get a schematic diagram.

Didn't read the full thread, but the first thing I saw is that you only have connected the wiper of the digipot. Shouldn't you also connect H1 to 5volt and L1 to ground.
Leo..

I never got that lucky. You can place an ear of corn in front of the pig and it will follow?-)

I see on the Fritzing picture that the digipot is configured for a 3.3volt processor.
That could mean that connecting the board to a 5volt processor (Uno) could fry it.
Leo..

Hi,

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

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