Convert a blend pot (stacked pot) into a 360 continuous rotation potentiometer.

Hello dear friends.

Please bear with me as im not a native english speaker and it gets kind of hard for me to express my thoughts effectively.

Im trying to build myself a custom midi controller for my mixing tasks. Given controller would ideally have 16 pots but im starting with just 2 or 3 as a proof of concept and then will scale accordingly. And decided that i want to have rotary encoders instad of single turn pots.

After looking for suitable rotary encoders, i discovered that most cheap ones output 24 ppm at the most which is definitely not enough resolution for providing an expressive control over my music software.

So i came up with the idea of hacking a stacked potentiometer (normally called pan pot, at least here where i live, basically two wafers connected to a single shaft) into a continuous rotation potentiometer so it can act as a rotary encoder.

What i did is open up the thing and remove the lower wafer and then remove the end stop of the case so that both wipers could do a 360 continuous turn. As you would expect, when the wipers end their normal rotation, the signal is lost as the conection between the outer ring and the middle pin is lost and the analog input starts to float.

So what i did is to realign one of the wipers about 90 degrees out of phase from the other one so that there is always a valid signal on at least one of the two analog inputs.

That seemed to work. and when plotting the analog ins what i got is two sine-ish, saw-ish similar looking waves which ran out of phase from each other and when each one reached the top or bottom there would be a gap for a few ms and then signal would come up from the other end (i hope i am making sense), When one input reached the the top or bottom the other was in the middle area rising or decreasing depending on the direction in which i moved the pot. So i thought i could code something that would help me discriminate one of the two signals when it reached the top or bottom and then dettect the direction of the remaining signal as to determine if a change to a higher value was required.

What i came up with is this scheme:

#include <MIDI.h>
int v1 = 0;
int v2 = 0;
int d1 = 0;
int d2 = 0;
int t = 0;
byte cc = 10;

MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  digitalWrite(A0, HIGH);
  digitalWrite(A1, HIGH);
  MIDI.begin();
  Serial.begin(115200);
}



void loop() {
  if((analogRead(A0) > 10) or (analogRead(A0) < 1020)) {
    if (analogRead(A0) > (v1 + 3) ) {
      if (analogRead(A0) > (v1 + 20) ) {
        d1 = -1;
      } else {
        d1 = 1;
      }
      v1 = analogRead(A0);
    } else if (analogRead(A0) < (v1 - 3)) {
      if (analogRead(A0) < (v1 - 20)) {
        d1 = 1;
      } else {
        d1 = -1;
      }
      v1 = analogRead(A0);
    } else {
      d1 = 0; 
    }  
  }  else {
      d1 = 0; 
    }  
  
  if((analogRead(A1) > 10) or (analogRead(A1) < 1020)) {
    if (analogRead(A1) > (v2 + 3) ) {
      if (analogRead(A1) > (v2 + 120) ) {
        d2 = -1;
      } else {
        d2 = 1;
      }
      v2 = analogRead(A1);
    } else if (analogRead(A1) < (v2 - 3)) {
      if (analogRead(A1) < (v2 - 120)) {
        d2 = 1;
      } else {
        d2 = -1;
      }
      v2 = analogRead(A1);
    } else {
      d2 = 0; 
    }  
  }  else {
      d2 = 0; 
    }  


  if ((d1+d2) > 0) {
    t++;
    MIDI.sendControlChange(cc, 65, 1);
  } else if ((d1+d2) < 0) {
    t--;
    MIDI.sendControlChange(cc, 63, 1);
  }

  /*
  Serial.print(1024);
  Serial.print(' ');
  Serial.print(0);
  Serial.print(' ');
  Serial.print(t);
  Serial.print(' ');
  Serial.print(analogRead(A1));
  Serial.print(' ');
  Serial.println(analogRead(A0));*/
}

And it seems to work. But the thing that botters me is that even after engaging the internal pull up resistor as to avoid floating inputs i steel get some minor jitter whenever one of the wipers leaves the resistive track. If after moving the pot i accidentaly leave the wiper in the wrong place the signal can move erratically thus sending undesired midi messages.

I would love to know if you my friends could help me solve this problem, as i've spent a lot of time trying to come up with a solution to no avail. Im really no electronics expert and have been experimenting with arduino for about 3 months. This is the first big project im trying to complete and it would mean a lot to me if you could point me in the right direction to eliminate the jitter.

Any help is appreciated.

Kind regards.

O5

Sketch out a circuit of how you have connected everything.

"a picture is worth a thousand words"

i steel get some minor jitter whenever one of the wipers leaves the resistive track.

Yes this is not surprising, there could be ways round this but first let me consider why you rejected the rotary pot idea.

The shaft encoder is not absolute, that is it will not remember where it was on power up so you have to have some sort of electronic indicator to show you where you are, you cannot use just the knob position alone. Given that the knob can be used in a multi turn mode to get the resolution you want. Alternative you can get an absolute encoder that has better resolution than you need with a "hall effect rotary encoder", google those words.

Back to your problem, you could use a boolean variable to determine what pot you look at and only look at that pot while it is in a specific range.

When you read outside that range, even though the readings are valid, you would switch to looking at the other pot. Again when a reading is outside that range you switch back to the first pot.

That way you are only looking at one pot at a time, the pot that is producing a valid reading. Enabling the pull up resistors will distort the linearity of the control and with this method you have no need to do this as when the input is floating you will not be looking at it.

Why not just put parallel resistance across the pots and leave the wafer alignment alone?

Grumpy_Mike:
Yes this is not surprising, there could be ways round this but first let me consider why you rejected the rotary pot idea.

Thank you very much for such a quick response.

The main reason im using pots instead of encoders is because as i said in my original post, encoders only putout 24 pulses each turn, which feels to steppy which is not expressive enough. Most midi plugins have parameters with ranges of 0 to 127 so id need about 5 turns of a cheap encoder to go from end to end. It feels unnatural as you could imagine. I now what im doing is hackish, but it actually feels more natural, i just want to get rid of the jitter.

Grumpy_Mike:
The shaft encoder is not absolute, that is it will not remember where it was on power up so you have to have some sort of electronic indicator to show you where you are, you cannot use just the knob position alone. Given that the knob can be used in a multi turn mode to get the resolution you want. Alternative you can get an absolute encoder that has better resolution than you need with a "hall effect rotary encoder", google those words.

I dont really need it to remember the position, i just need to know the direction of turn. My music software only needs a midi cc mesage with a value of 65 to know were going up or one with a value of 63 to know we're going down. Thats it. no need for absolute positions. Thats why im doing this with pots, cause they are cheap, as opposed to hi resolution rotary encoders which would rack up the price of the project to the hundreds. Which i cant spend right now.

Grumpy_Mike:
Back to your problem, you could use a boolean variable to determine what pot you look at and only look at that pot while it is in a specific range.

When you read outside that range, even though the readings are valid, you would switch to looking at the other pot. Again when a reading is outside that range you switch back to the first pot.

That way you are only looking at one pot at a time, the pot that is producing a valid reading. Enabling the pull up resistors will distort the linearity of the control and with this method you have no need to do this as when the input is floating you will not be looking at it.

If you look at the code it does that by restricting each pot to the range of 10 - 1020.
But i still get that jitter.

What im going to try is to code some inertia tracker as to avoid it to sending a message to go in the opposite direction (produced by jitter) if the innertia in one given direction is high. But im not really a good coder. I just hack stuff lol.

Im curious though. How would i go about using pull up resistors on each pot directly as opposed to using the internal pull up resistors in the uno?

Thanks in advance.

123Splat:
Why not just put parallel resistance across the pots and leave the wafer alignment alone?

How would i go about that?

If you look at the code it does that by restricting each pot to the range of 10 - 1020.

No it doesn't. You always look at both pots. You must not look at two pots in the same iteration of the loop. You need to do what I said, what you are doing is not what I said.

How would i do that? can you give me a general advice?

A typical pot has a +/- 270degree range - so if connected 90 degrees apart, there could still be some ambiguity at the overlap.

If you moved them 180 degrees apart there wouldn't be this problem, and Grumpy_Mike's solution ( post #2) would work well.

regards

Allan

I reopened and checked. And they are on oposite sides so absolutely no chance of overlap there whatsoever.

Octaviu5:
How would i do that? can you give me a general advice?

First do a rough plot of position angle against reading for each pot. Find out the valid range for each pot. See how they overlap and where the gaps are. Then work out the range you are going to use for each pot, make this as even as possible and identify the point greater and less than readings where you will switch from this pot to the other. Then re read reply #2.
Your code will look like
Take a reading from the current pot - use it for your measurement.
Is this reading outside the range you want to use? If yes change the variable that indicates the current pot.

Note that the use it bit will have different calculations in in depending on what pot is being used.

I have read your original post several times, and I cannot see why you are not using 10-turn pots.

Paul

I dont use 10 turn pots cause they reach an end. And AFAIK there is no way to remove it.

Octaviu5:
I dont use 10 turn pots cause they reach an end. And AFAIK there is no way to remove it.

Quite right! I was thinking of picking a single turn of 360 degrees out of the 10 possible and using that. Making the mechanical stops have been done, but is rather a lot of metal work. More for government work!

My limited Google research shows robotics has a problem similar to yours and they have no immediate solution, either. Looks like yours may be the best fit.

I have some concern, though, relating to the sliding contact wearing the material when it passes over the open end points. I am used to carbon material embedded in some type of phenolic material. I see some pots are using a conductive plastic material for the resistor. Are yours made this way? They would probably wear better.

Paul

You can get continuous rotation pots you know, all be it they are a bit expensive.

Paul_KD7HB:
Quite right! I was thinking of picking a single turn of 360 degrees out of the 10 possible and using that. Making the mechanical stops have been done, but is rather a lot of metal work. More for government work!

My limited Google research shows robotics has a problem similar to yours and they have no immediate solution, either. Looks like yours may be the best fit.

I have some concern, though, relating to the sliding contact wearing the material when it passes over the open end points. I am used to carbon material embedded in some type of phenolic material. I see some pots are using a conductive plastic material for the resistor. Are yours made this way? They would probably wear better.

Paul

Eventually they will fail, but they are so cheap. like 50c each i dont care.

Grumpy_Mike:
You can get continuous rotation pots you know, all be it they are a bit expensive.

http://uk.rs-online.com/web/p/potentiometers/8427150/

At that price, if i get 26, which is s what i intend. they would amount to over 500 quid. I live in the 3rd world. i cant afford it.