Go Down

Topic: digital rheostat pot - not closing entirely? (Read 4647 times) previous topic - next topic

LasseMunk

Dear Forum

I have a digital rheostat 10 kOhm potentiometer, that I want ultimately to control the volume of a radio, but for now, just want to fade an LED.

I have it fading in/out, except I cannot make the LED turn of entirely.

I've been reading about the differences between rheostat and potentiometers - and many people mention different things, so I'm kind of confused. Also - i thought I ordered a digital potentiometer, but by accident bought a rheostat. soo.. is it even possible?

I have attached a schematic of the setup, and the code:

link to digi pot datasheet:

http://ww1.microchip.com/downloads/en/DeviceDoc/22060b.pdf


CODE:

#include <SPI.h>
int ss = 10; // slave select pins

void setup() {

// set SS pin directions
// Others are handled automatically

pinMode(ss, OUTPUT);

//Initialize SPI
SPI.begin();

Serial.begin(9600);
 
}
// function to set LED to specific level
// reg is the register, register is the index - this is only one pot,
// so the reg is == 00000000
// level is the leve

void setLed(int reg, int level) {
 
  digitalWrite(ss, LOW);  // set SS to low for communicating to that chip
  SPI.transfer(reg);      // send register / index
  SPI.transfer(level);
  digitalWrite(ss, HIGH); // Finish writing to that chip
}

void loop() {
 
for(int i = 0; i<255; i++) {

   setLed(0, i);
   delay(20);
   
   Serial.println(i);
}

delay(500);

   for(int i = 255; i >= 0; i--) {
   
    setLed(0, i);
    delay(20);
   
    Serial.println(i);
   }
delay(500);
}

Grumpy_Mike

Quote
but by accident bought a rheostat

No that looks like a pot to me.
The way you have wired it up you will never get the LED to go off fully. Wire it up like a pot. POA to +5V, POB to ground and P0W to your LED and resistor. Then it will turn off. However, it will turn off before the full range of the pot is reached because the voltage on the LED will drop below the LED's threshold voltage.

LasseMunk

thank you so much for your answer!

but the thing is - there is no P0A - how to wire it then? (you can see the the options in the schematics image or in the datasheet i linked to :) )

LasseMunk

its the one on the right in the datasheet labeled "MCP41X2 Single Rheostat" i have

Grumpy_Mike


its the one on the right in the datasheet labeled "MCP41X2 Single Rheostat" i have

Well no you have a MCP4132, the x means it is a missing number.
In which case you should wire P0B to ground and P0W to the anode of the LED. Then wire a resistor of at least 250R from the LED anode / P0W to +5V.

LasseMunk

ah yes - sorry typo.. just copy pasted the name / number without thinking :)

That sounds cool! - thanks a bunch. Will this work with turning volume up/down? the initial idea was to control the volume of a transistor radio, by replacing the analog potentiometer with the digital one.


Grumpy_Mike

Quote
Will this work with turning volume up/down?

Basically yes but there are two problems:-
1) It is a linear pot, not a log one. You normally use log pots for volume control because the ear's response is log ( or close to log ). By using a linear pot you will perceive all the volume change at one end.
2) Because you have to have a pull up resistor the maximum output will only be half the input. That is if you make the pull up resistor the same value as the rheostat value.

soeren



its the one on the right in the datasheet labeled "MCP41X2 Single Rheostat" i have

Well no you have a MCP4132, the x means it is a missing number.
In which case you should wire P0B to ground and P0W to the anode of the LED. Then wire a resistor of at least 250R from the LED anode / P0W to +5V.


Are you sure about this way to hook it up? It seems weird to me to hook up the POW to both +5v and the LED, and it doesn't turn all the way down when doing so.

Grumpy_Mike




its the one on the right in the datasheet labeled "MCP41X2 Single Rheostat" i have

Well no you have a MCP4132, the x means it is a missing number.
In which case you should wire P0B to ground and P0W to the anode of the LED. Then wire a resistor of at least 250R from the LED anode / P0W to +5V.


Are you sure about this way to hook it up? It seems weird to me to hook up the POW to both +5v and the LED, and it doesn't turn all the way down when doing so.

It would indeed be weired if that is what I said but I did not. Read again. The P0W and the led both go to a resistor, the other end of which is connected to 5V

Go Up