Go Down

Topic: MCP41100 Not working right. Help (Read 901 times) previous topic - next topic

1Ghasthunter1

Hello.
I recently just got my mcp41100 hooked up and basically have it wipe from 0-5 volts up and down in a loop, which is read by an analog pin and graphed. Without any load on the pin PW0, the mcp41100 goes from 0-5 volts linear just fine. But when I add an LED to the load(no resistor, PW0 --> LED --> GND), the resistor readings peak at just about 2 volts. Can someone explain why this is? I have also included pictures of the serial readings below.
WITH LED:
https://drive.google.com/file/d/0B00Guxk1ME_fS3NNS2lFbmg3ODA/view?usp=sharing
NO LED:
https://drive.google.com/file/d/0B00Guxk1ME_fZ3dvRnpUUng3VUE/view?usp=sharing
(volts on the vertical axis of the grid)

Code(I added some things to the example program for serial reading):
Code: [Select]
/*
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);
   Serial.begin(9600);
   Serial.println("--- Start Serial Monitor SEND_RCVE ---");
}

void loop()
{
    float potread = 0;
    for (i = 0; i <= 255; i++)
    {
      digitalPotWrite(i);
      delay(10);
      potread = analogRead(5);
      potread = potread / 204;
      Serial.println(potread);
     
    }
    delay(500);
    for (i = 255; i >= 0; i--)
    {
      digitalPotWrite(i);
      delay(10);
      potread = analogRead(5);
      potread = potread / 204;
      Serial.println(potread);
    }
    potread = analogRead(5);
    potread = potread / 204;
    Serial.println(potread);
}

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

Smajdalf

And what did you except?
For wiper current the Datasheet says maximum +/-1 mA. Anyway try to connect any resistor --> LED --> GND. On the LED you will have its forward voltage drop in any case (unless it burns).
How to insert images: https://forum.arduino.cc/index.php?topic=519037.0

1Ghasthunter1

It is the same thing. I am pretty sure that the digipot sweeps from 0-100k ohms with i think is too much. If you look at the start of the programs there are a few values that set the highest, lowest, and wiper resistance. I don't know how to use those but those might be the answers.

Jiggy-Ninja

#3
Apr 23, 2017, 05:39 pm Last Edit: Apr 23, 2017, 05:39 pm by Jiggy-Ninja
I'm with Smajdalf. What did you expect to happen? What you got is exactly what I expected.

Please...


An LED can be very roughly approximated as a constant voltage load. This is why it is always said that you need some form of current limited for an LED, usually just a resistor for small indication LEDs. Directly attaching a constant voltage power supply (such as an output pin or large battery) to a constant voltage load is very dangerous. The mismatch in voltage will cause the device to either not operate at all (if the supply is too low) or draw excessive amounts of current (if the supply is too high).

What you're doing with the potentiometer and LED is that the LED is loading the potentiometer. The voltage divider formula is only valid is nothing is connected to the center of the resistors. As soon as you draw any current from the divider output (and an LED can use substantial current), the output voltage will drop. You need to use some extra math to calculate the actual output then (usually involving calculating the Thevenin equivalent circuit for the divider).
Hackaday: https://hackaday.io/MarkRD
Advanced C++ Techniques: https://forum.arduino.cc/index.php?topic=493075.0

1Ghasthunter1

ok, thanks. I will
Quote
Consider The Following[\QUOTE]
I will reply when I do the calculations and attempt to understand your message.

Go Up