Creating a digital potentiometer from basic parts

Hi,

In France I can not find a 20K digipot for less than $15 delivered, so I would like to know whether I could replicate the effect of a digipot with simple transistors and resitors. I need a simple 4 step digipot: 0 ohm, 5K ohm, 10K ohm and 20K ohm, controlled by the arduino pins. I just don't know where to get started...

thanks!

XBerg

Start from reading data sheets for ANALOG MULTIPLEXER/DEMULTIPLEXER, M74HC4051
or similar. If you connect one resistor (20k) to common input/output, and 4 resistor ( 0, 5, 10, 20 ) to other inputs/outputs you 'd create a digitally controllable voltage divider. Varying value of resistors can get logarithmic/linear scale.

perhaps you can salvage one from something like a printer

does it need to be digital - will analogue do ?

Magician,

I can't get my head around what you're recommending:
If you connect one resistor (20k) to common input/output, and 4 resistor ( 0, 5, 10, 20 ) to other inputs/outputs you 'd create a digitally controllable voltage divider

could you please be more specific?

Gadget999: salvaging a component from a printer? I would not recognize a digital pot if it were starring at me in the eye !!! So no - not a chance I open a printer for spares :slight_smile:

O'k. Switches are 1 multiplexer IC chip. There are two A, and B shown, but millions possible variation could be created depends on requirement: linearity, accuracy, speed, quantity of steps etc. (Google to read on topic, search pattern "DAC resistors network").
For you, probably A is sufficient.

Hi, ElCheapo solution:

Couple R,LED to digital output, run in 'analog out' mode. Point it at a Photoconductor like (http://arduino-direct.com/sunshop/index.php?l=product_detail&p=135).

Put filter cap across the photoconductor if the ripple is too much. Sketch to calibrate it.. What speed of response do you need??

Terryking: That's pure genius!!! Thank you so much. I don't need any response speed at all - this is to control an already slow motor to make it even slower - set once and forget. So your solution is super.

Magician - thanks for the sketch - now it's all clear. I'll go the Terryking route though as it saves quite a few pins.

Brilliant :slight_smile:

Look up vactrol, you can by them or make them your self. I fit's for audio there are some nice one's that were/are for audio compressors.

To control a slow motor, you need a digital switch ( transistor ) - not potentiometer.
Plus 1 PWM pin.

terryking228:
Couple R,LED to digital output, run in 'analog out' mode. Point it at a Photoconductor like (http://arduino-direct.com/sunshop/index.php?l=product_detail&p=135).

Put filter cap across the photoconductor if the ripple is too much. Sketch to calibrate it..

OK - I now had the chance to test this. I'm running into a bug: the PWM, too fast for the eye to see, keeps turning the LED on and off. The photoresistor on the other hand sees mostly "0", particularly at low brightness levels. Maybe 75%+ of values are 0. I use the analogWrite and analogRead functions.

int led=11;
int sensorPin = A0;
int pause=100;

int sensorValue = 0;         // the sensor value


void setup()
{
  pinMode(led, OUTPUT);
  Serial.begin(9600);
 
  
}

void loop()
{
     for (int brightness = 0; brightness < 130; brightness++) 
     {
      analogWrite(led, brightness);
      sensorValue = analogRead(sensorPin);
      Serial.println(sensorValue,DEC);
      delay(pause);
     }

for (int brightness = 130; brightness >= 0; brightness--) {
      analogWrite(led, brightness);
      sensorValue = analogRead(sensorPin);
      Serial.println(sensorValue,DEC);
      delay(pause);
     }
  
  
}

So I don't think this is quite usable quite so easily.Or I missed something...

Hi, Let's try to figure this out...

What kind of "Photo Conductor" or "Phototransistor" are you using?

How fast do you need the system to respond to changes?

You need to minimize the effect of the PWM on the LED on your output, probably by filtering it somehow..