Read Endless Potentiometer

nazori

Member
Hello, I've been working on a Midi Controller project and after a lot of reserach I found that:

- I don't want regular analog potentiometers because I don't want a fixed value so I can change parameter and not mess up the current value.
- I don't want digital encoders because of their low resolution on affordable models.


So I came up with this

https://www.mouser.es/ProductDetail/Alpha-Taiwan/RV112FF-40B1-15F-0B20K-0068?qs=%2Fha2pyFadugIUR6z4peD5VgXgqxB99COJ4kSfZg41aSWLc55zFxVXs6XFyc2q3gYyB27TqoGq8Q=

This are the same or very similar as the ones that Maschine MK3 uses and I really like the feel. I found them contacting with this great guy.

https://www.youtube.com/watch?v=q2axuDSDThQ&list=LL8_Dy_2inRPRU5aztbPRgKA&index=6&t=0s



So my question is, How do I read properly this with the Teensy LC that I have. I want to have increments or decrements.
I connected the potentiometer correctly and I get the two values, one delayed from the other.

This is the behaviour of the potentiometer:

Capture2.PNG


This is what I got on the serial:

Capture.PNG


This is the code so far:


int val6, val5;

void setup()
{
Serial.begin(38400);

val6 = analogRead(6);
val5 = analogRead(5);
}


void loop()
{
delay(250);
if (abs(val6 - analogRead(6)) > 10) {

val6 = analogRead(6);
val5 = analogRead(5);


Serial.print("values: ");
Serial.print(val6);
Serial.print(" / ");
Serial.println(val5);
Serial.println("");

}

}


Sorry for the mess, and thanks.
 
Hello, you piqued my interest with this post. There's obviously a correct way of coding this, that's neat and no doubt, mathematical. I don't have the exact answer, but this is a form of absolute rotary encoder called a resolver, I think. And it's designed so that angle can be read. They are based on two coils 90deg apart to produce two analogue signals - a sine wave and a cos wave, and the idea is to take the arctan(sin output/cos output) to get the angle.

The potentiometer has two linear tracks that approximate this. So it can probably be treated the same way. Then once you have the 'angle', compare it to a previous value - in theory. There are ICs for this purpose it seems, but to read one turned by hand with a Teensy should be possible.
 
Last edited:
Having watched the video at 12:00, the Maschine MK3 seems to just have a normal (detent-less? - non-clicking) encoder. Arturia use these on their products like the Minilab. They rotate freely with some grease inside to give a bit of resistance. I would just use one of these.
 
edit. never hear about these endless pots, very intriguing, knobs on my NI keyboards feel great. i spend a good while finding the best rotary encoders for my synth build.. fwiw if you wanna order samples, the ALPS are worth the extra $ over the bourns imho, feel much sturdier and more like a pot. i am happy with those.
the resolution on encoders can be misleading because in most cases you will have to implement some kind acceleration on the software side anyways.

UHF - yeah these look like encoder but its atually the part nazori posted
 
Last edited:
Working on it

Thanks very much, UHF and MarkzP. I will try to do the conversion to angle and work from there. I will keep you updated.
 
Yeah I was having the same problem until I found about this. I really didn't like the enoders from arturia at least the MiniLab ones, the resolution was very low and you had to do several whole laps to get the parameter cover.

Sorry for my bad english, I will keep you update, this week I hope to advance a lot.
 
Angle reading DONE

I took your suggestions and i did this:

Code:
void loop()
{
  delay(250);
  if (abs((val6 + 500) - analogRead(6)) > 50) {

    //I substract 500 because the reading values where 1000 - 0
    val6 = analogRead(6) - 500;
    val5 = analogRead(5) - 500;

    //Get the Angle and I transform it to deegres because i'm not that good at radians
    angle = atan2f(val6, val5);
    deg = angle * 57296 / 1000;

    //Add 360 because every angle from 180 to 360 are calculated as the negative one
    if(deg < 0){
      deg = deg + 360;
      }
      
    Serial.print("sin:  ");
    Serial.print(val6);
    Serial.print(" / ");
    Serial.print("cos:  ");
    Serial.print(val5);
    Serial.print(" / ");
    Serial.print("Angle = ");
    Serial.println(deg);
    Serial.println("");
    
  }


And I got the angle correctly:

Capture.PNG


Now I'm going to see how I translate that into MIDI 0 - 127 and see how ableton behavies to that.

THANKS
 
Fascinating knob! Very clever.

Using arctan will not give the right angles in this case, it works for that resolver since it has sinus waves.

The solution for this knob is actually very simple: :)
Code:
if(v0 < 50%) 
  angle  = 360 - v1 *180
else
  angle  = v1 * 180
v0 and v1 are assumed to be between 0 and 1.0. v0 is the curve that starts in the middle in the datasheet.

If the unsharp turns at the top and bottom are annoying or the knobs are made with poor precision you would have to use a more intricate method. Perhaps trying to only use the value from v0 or v1 when the are away from the top or bottom. I would guess that to get best precision you would have to calibrate each knob to find the exact points where both pots are equal. That might be overkill in your case.
 
Looks interesting. Just an observation but do you really wish to use:
Code:
]analogRead(6);
Analog pins are more traditional referenced with as "Ax", as in
Code:
]analogRead(A6);
You may actually be targeting the wrong hardware pin.
 
Looks interesting. Just an observation but do you really wish to use:
Code:
]analogRead(6);
Analog pins are more traditional referenced with as "Ax", as in
Code:
]analogRead(A6);
You may actually be targeting the wrong hardware pin.
By convention in Arduino (and Teensyduino) A6 is understood when '6' is called for analogRead... handy in control loops where a incremented variable can be used directly in the read.
 
By convention in Arduino (and Teensyduino) A6 is understood when '6' is called for analogRead... handy in control loops where a incremented variable can be used directly in the read.
Well there you go; I did not realize that. Thanks for the lesson! Sorry for the derail.
 
Looking at the Teensy card where it shows 'A6' - it is on pin 20, so that can work as well

Code:
// A0-A9 are always digital 14-23, for Arduino compatibility
// ...
#define PIN_A6  (20)
 
necro-bump on this. :)

I'm heading down this same road with the RDC803101A and I'm curious...

How did you wire the RV112FF? I'm somewhat confused by the diagram on the datasheet.
 
Back
Top