Is there a way to use a potentiometer instead of an encoder? MIDI and MCU

I am trying to use an analog potentiometer instead of an Encoder. With the following example the potentiometer just uses a tiny part of its movement, about 10 percent starting around 70% of it and only in one direction. I am guessing as DT or CLK.
I tried using a ADC for the speed and mapping for the dead zones but can't figure out as I'm a noob and found this post which I can't understand it all because of the amount of things it has use pot instead of encoder

The reason for a pot instead of the encoder is because of the 270º and smooth movement as I'd like it to have a fixed beginning and end to the movement rather than 360º

#include <Control_Surface.h>

USBMIDI_Interface midi;

CCRotaryEncoder enc {
  {A0, A1},
  MCU::V_POT_1,
  1,};

//EXAMPLE WITH POTENTIOMETER
CCPotentiometer potentiometer {
  A2, MCU::V_POT_1};

void setup() {
  RelativeCCSender::setMode(relativeCCmode::MACKIE_CONTROL_RELATIVE);
  Control_Surface.begin();
}

void loop() {
  Control_Surface.loop();
}

How is your pot wired?

left 3.3v, wiper center and right GND.
It does work for anything analog and even if I invert it just does the same to the other side

not clear what your application is? control surface suggests aircraft

can't imagine tracking speed over a partial rotation

encoders are often used to track the speed of a DC motor or measure full or fractional rotations for precise positioning. they are apparently also used with stepper motors for verifying their position

not sure if your application uses a DC, stepper or RC servo. and RC servo uses a pot to measure the limited range of a servo arm

you could use a pot to likewise measure the position of a stepper motor if its travel is limited to the range of the pot.

It's actually a Midi controller. Trying to mimic what another controller does where they seem to use pots for what other companies use encoders

Be aware that most pots you buy today are made from plastic with a conductive/resistive coating. They wear rapidly compared to the old fashioned pots.

The thing I don't know where to start as converting Pots to encoders doesn't seem straight forward

does the encoder return +/- or an absolute value?

You have a pot. One end connected to 3.3 volts and the other end ground. Regardless of degrees of rotation your wiper with respect to ground will output 0 to 3.3 volts or 3.3 volts to ground. With a 3.3 volt uC and a 10 bit uC that will be 0 to 1023 bits or 1023 bits to 0.

I would think about using a map function.

Read your raw analog input bits and map them to whatever you want.

Ron

1 Like

it does return +/- values

I managed mapping the pot but as V_POT in that occasion should be used with an encoder that has +/-, the value I get back is only in one direction rather than values between 0 to 3.3v. the value I get back is 3.3V whenever I move de pot either left or right . If I invert the pot I get 0 no matter what side I move the pot

check this example

https://tttapa.github.io/Control-Surface-doc/Doxygen/d3/d26/CCPotentiometer-Map_8ino-example.html

1 Like

post the code

This is what happens with the coded I posted right at first

where do you read the pot?

int potValue = analogRead (PinPot);

The example just maps a potentiometer for the right dead zones. using an ADC improves how fast it goes the potentiometer only moves either right or left with max value 3.3v or 0v

What sort of pot do you have? There are two types of pot.
See this link for details

It sounds to me that you have log pots instead of the Lin you need.

linear. 10k pot as it's for sound. It works well when I need to use it for any analog situation

Sounds that way. :slight_smile:

This is where a schematic is important and I have an idea MIDI is involved so how about you describe your project in some detail?

Ron

so if you run this code with your existing wiring

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(analogRead(A2));
  delay(100);
}

you see values between 0 and 1023 on the screen as you move the wiper? (terminal at 115200 bauds)