Author Topic: Detecting Presence of Expression pedal  (Read 613 times)

potul

Detecting Presence of Expression pedal
« on: June 17, 2019, 12:36:25 PM »
Hi

I'm currently building a project based on Arduino, that will use 2 expression pedals as voltage dividers using 3 wires each (vcc, gnd and signal).

I would like the Arduino to know when the pedal is connected. Any creative idea how to achieve this without using an additional I/O?


Blackaddr

Re: Detecting Presence of Expression pedal
« Reply #1 on: June 17, 2019, 05:01:23 PM »
Don't use the expression pedal as a 3-wire setup, use it as a two-wire setup where you connect to the wiper but don't connect anything to the "top" of the pot where you are normally connecting 3.3V.

Inside your enclosure you will have a pullup resistor to VCC, then connect your ARDUINO ADC input to this resistor and the TIP on your jack. Check to make sure the expression pedal is wired up to have the TIP as WIPER. If it uses the RING on the plug as WIPER replace TIP in the diagram below with RING.

The diagram below shows your enclosure wiring on the left to a TIP/SLEEVE mono jack, and the the right represents the wiring of the expressional pedal pot to the TRS plug. Assume the expression pedal is 10K for convenience. You select 1/10th of this for the pullup. If the pedal was actually 100K, you would use a 10K pullup, etc.

          VCC
           |                           TOP (10K ohm)
          1K                            |
           |                            |
ADC IN -------------TIP      TIP------WIPER
                         X              |
GND    -------------SLV      SLV-------BOT (0 ohm)


This is how you detect the pedal. When it is not plugged in, the ADC IN will be pulled by the 1K resistor to VCC. Now consider what happens when the expression pedal is plugged in. You are creating a voltage divider using the pull resistor and the lower half of the pot. If the wiper is all the way to zero 0 ohms, you will read ZERO at the ADC IN. If the WIper is all the way up, you will have a voltage divider of 1K and 10K, resulting in ADC IN reading (VCC * 10 / 11). Roughly 90% of VCC. Anywhere in between the wiper will result in a reading from close to zero up to around 90% of VCC.

In other words, if the ADC reading is above 90% of max, you know nothing is plugged in. If it's less than 90%, you know it is plugged in.

Hopefully that gets the idea across. In reality you would set the threshold a little higher to ensure accurate detection when the pedal is at max resistance. I.e., if the divider comes out to 90%, set the detector threshold at 95%.

You will also have to calibrate your pedal, but you need to do this anyway with the normal 3-wire hookup as well. Move the the pedal to heel down, record the ADC reading. This is MIN. Move the pedal to toe down. This is MAX. Typically you will convert the ADC reading from ADC values into some range like 0 to 99, or 0 to 127 for MIDI etc. You also want to saturate. Ie. once you are within a few percent of of MIN or MAX, just jump to that value as this compensates for temperature drift. This ensures the full range is reachable at the expense of a little bit of pedal responsiveness at the extremes. Note the MAX calibration value is different (less than) the value used for detection discussed above.
« Last Edit: June 17, 2019, 05:04:42 PM by Blackaddr »
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com

potul

Re: Detecting Presence of Expression pedal
« Reply #2 on: June 18, 2019, 06:28:10 AM »
Thanks for the explanation

I will check if my expression pedal will work with this... I assume yes as it's a passive one, so I assume it's only a pot connected to the TRS plug.

On the other hand, this will not give a linear response, so I will need to compensate by software somehow (is it going to be similar to anti-log?)

Regarding calibration, I'm aware of it... I don't have it coded yet but I'm planning on it.

Blackaddr

Re: Detecting Presence of Expression pedal
« Reply #3 on: June 18, 2019, 09:03:58 AM »
Thanks for the explanation

I will check if my expression pedal will work with this... I assume yes as it's a passive one, so I assume it's only a pot connected to the TRS plug.

On the other hand, this will not give a linear response, so I will need to compensate by software somehow (is it going to be similar to anti-log?)

Regarding calibration, I'm aware of it... I don't have it coded yet but I'm planning on it.

If it's an expression pedal, it will already have a linear pot. If it's specifically a volume pedal it will have a log response. You can check by measuring the resistance at the half-way pedal point vs toe-down. If it's linear, it will be roughly half the resistance, if it's log, it will be much lower or much higher than half the max resistance.

If you have a volume pedal, I suggest buying a proper expression pedal. The M-Audio EX-P is very good and very cheap if modded (see second article below). Log response is really not good for this application.

I wrote a couple articles about using expression pedals with digital effects a couple years ago that you might find some useful info within.

Expression Pedals Way More Than Just a Wah

Expression Pedals: Repair and Mods
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com

potul

Re: Detecting Presence of Expression pedal
« Reply #4 on: June 18, 2019, 09:36:25 AM »
Thanks for the links, I will check.

In fact, the M-Audio EX-P is the one I have at the moment.

I was referring to the fact that with your configuration, even if the expression pedal is linear, the reading at the ADC will not be. Because of the fixed 1k resistor on one side of the divider, and the 10k varying resistor at the other side.  Vout = Vin * R/(1+R)

With a VCC of 3.3v

Volume pedal at 0 -> ADC=0
Volume pedal at 5 -> ADC=2.75
Volume pedal at 10 -> ADC=3


Blackaddr

Re: Detecting Presence of Expression pedal
« Reply #5 on: June 18, 2019, 01:00:51 PM »
It's actually linear because the pot is linear, your midpoint calculation of 2.75 V seems off? Here's how I calculated it.

For a 10K pot, and a 1K pullup, at the pedal midpoint the pot will be at 5K.

3.3V* [ 5K * (10K + 1K)] = 3.3 * (5/11) = 1.5V

So when the pedal is at 0 (heel down), your ADC see's 0V. When the pedal is at midpoint, ADC sees 1.5V. When the pedal is toe down, pedal sees 3.0V.
« Last Edit: June 18, 2019, 03:05:41 PM by Blackaddr »
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com

potul

Re: Detecting Presence of Expression pedal
« Reply #6 on: June 19, 2019, 04:55:55 AM »
Shouldn't it be like this?

3.3V* [5k / (5K + 1K)] = 3.3 * 5/6 = 2.75V

Blackaddr

Re: Detecting Presence of Expression pedal
« Reply #7 on: June 19, 2019, 09:00:11 AM »
Shouldn't it be like this?

3.3V* [5k / (5K + 1K)] = 3.3 * 5/6 = 2.75V

whoops! You're 100% right. I know I've done something like this before long ago and it worked and it was linear. Let's try modifying the schematic a bit. How does this look now?

Put a weak pullup (Rweak) to VCC on the ADC input. Something much larger (10x would be 100K) than the pot should be good. When nothing is plugged in, it's pulled to 3.3V.

Connect the 1K resistor between VCC and the RING. The Pot now looks like an 11K pot instead of 10K, but the upper 1K is unreachable by the wiper. This will give the voltage divider equation I was trying to get in the previous post so the same detection/calibration stuff still applies. The idea is to linearly move from 0V to 90% of VCC and leave the upper voltages unused for detection purposes.

You'll of course need to scale all these values based on the actual resistance of your expression pot.

Code: [Select]
          VCC---1K---RING      RING-----TOP (10K)
           |                              |
         Rweak                            |
           |                              |
ADC IN ---------------TIP      TIP-------WIPER
                           X              |
GND    -------------SLV        SLV-------BOT (0 ohm)
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com

pruttelherrie

Re: Detecting Presence of Expression pedal
« Reply #8 on: June 19, 2019, 05:04:09 PM »
If you use a switched jack you can leave the Rweak out and have ADC/TIP connect to VCC when nothing is plugged in, have it break when plugging in the pedal.
Completely linear response and the rest of your story (calibration/detection/etc) functions as described.

Blackaddr

Re: Detecting Presence of Expression pedal
« Reply #9 on: June 20, 2019, 08:51:44 AM »
Note the Teensy has built in weak PULLUPs you can enable. Probably somewhere between 40K and 100K. Depending on how large your POT resistance is, Rweak could be free assuming it still works when configured as an ADC input.
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com

potul

Re: Detecting Presence of Expression pedal
« Reply #10 on: June 21, 2019, 01:46:07 AM »
Great!

Thanks both, this solution of the 1k resistor in series with the pot TOP and  the switched jack looks like what I had in my head and was not able to materialize.

I will give it a try

Regards

Mat