pull-up/down and analog inputs

Status
Not open for further replies.

oddson

Well-known member
A noob question (my 2nd! here!)

The documentation says pull-ups should not be used with analog pins. http://www.pjrc.com/teensy/adc.html

I'm doing an MIDI expression pedal application where one of the available TRS connectors might be unused -- and therefore the pin can drift away from ground -- and generate garbage MIDI messages.

Should I use an external pull-down? If so what value (10K - 50K Ohm seems to be the standard range of expression-pedal pots - so I'm thinking it would have to be fairly large to not affect the output).

I tried it with a huge value (10M) and it worked but took forever to stabilize...

Anyone have any advice before I try to remember how to use Ohm's law or resort to trial and error? :eek:
 
Something in the 1M region seems to work OK... but if anyone can tell me if there's a better approach I'd appreciate it.
 
I'd strongly consider a switching jack over a pullup on an analog pin, especially if the other end isn't really low impedance
 
I'd strongly consider a switching jack over a pullup on an analog pin, especially if the other end isn't really low impedance
Yes, I agree. What this means is that when no jack plug is inserted, there is a pulldown to ground; inserting the jack plug into the socket disconnects the pulldown. 5 to 10k would be good, because the ADC prefers to see a source impedence less than 10k.
 
It's common (no pun intended) to just short them to ground, though a series resistor can reduce switching transients. I've seen some amazingly clever things done with just a humble switching jack. Depending on how much you need to accomplish - it can ground out the input, or it can be tied to a weak pullup, and used to drive a transistor base or other digital input. But the Jurassic Park Question still should be considered - stick with the simplest thing that will work.

You don't always need a true switching jack to do this either. One I've been curious about but haven't yet analyzed - Graphtech's piezo preamp for guitars senses the ring on TRS jack, and uses it as an output if it's not connected to ground. It's not just driving a series resistor into ground - it actually switches some stuff based on it, but it's primarily an output. I'm using grounding of an unused pin to determine if anything is plugged in to the connector carrying i2c to a project of mine.
 
Last edited:
Thanks guys!

I had originally put in a paragraph in about why I wasn't just using a switching jack... basically because I have really cheapo jacks in my junk box and I wanted to see what others thought of a pull-down approach when dealing with a low-res application like a MIDI pedal.

The 1M Ohm pull-down seems to work well enough in that it does not limit output range and does bring the pin to ground fast enough (in human scale).

In the back of my mind is the possibility of a future semi-commercial product so keeping cost low is something I want to be aware of as I play -- and because these little crappy jacks fit on 0.1" pitch perf-board so damn nicely (they take up about 0.5" each).

But I'll take heed of the advice and look into the ADC impedance issue a little more as I go...

I'm using grounding of an unused pin to determine if anything is plugged in to the connector carrying i2c to a project of mine.
I haven't worked out how this would work... but I'm interested in this approach...
I would have free pins in my application. I'm going to think about this for a bit...


Thanks again and expect to see other semi-daft questions from me! :)
 
Hmm... the stability I saw last night seems to have vanished. I may have to reconsider switching.

EDIT: Yeah... I don't think this approach will work with the impedances involved... thanks!
 
Last edited:
Sorry - I meant an unused (but non switching) pin on the connector, not the micro. You could use the ring for it if you weren't already using it for signal. Of course, if you have need of that info, you could just bring the 'plugged in' signal, however you derive it, to a pin on the micro if say... you wanted to not sample the ADC or power down some portion of the circuit. I can't really say how you could detect using a non-switching jack with signal on tip and rig without knowing whats on it.
 
Sorry - I meant an unused (but non switching) pin on the connector, not the micro. You could use the ring for it if you weren't already using it for signal...
Thanks for clarifying... I couldn't see how that would possibly work. I do need all three as it's a voltage divider arrangement. I'm right now black-boxing my expression pedal as there's a polarity switch and a separate adjustment pot... (I'll get a skrewdriver and see if I get it right afterwards!). It's an M-Audio EX-P pedal (they're dirt cheap too!). I'm going to take the opportunity to learn all I can from this and then decide if switched sockets are essential. And in the process be a lot more knowledgeable about using a voltage divider as an input. :)
 
Last edited:
I figured it was a simple divider.
http://joflaherty.org/MidiExprPedal/Midi%20Pedal%20schematic.png

A couple options - you treat the input pin as a capacitive sensor at startup, see if it's hooked up, then read it as an analog input after that. If you try driving the input pin - make sure you limit the current, a 470 Ohm series resistor should suffice. Alternatively you could drive the top of the divider with an unused output pin rather than tying it directly to Vref. Then you could pull it down and see if your divider leg moves. The last option is probably the simplest if you have an extra pin.

Finally, if your micro isn't doing anything besides watching the pedal, then there's no point in handling the unplugged case, because it will never be used that way. (This appears to be the case in the schematic I posted.)
 
Nice!

The reason to handle the unplugged case is I'd like it to have up to three pedals and still work when one or two are not connected.

I'm not averse to switching to switched sockets if that's what's called for.

I still have a ways to go to understand all the issues.
Your help has been invaluable... thanks SO much!
 
Last edited:
Colour me stupid -- because I was truncating and not rounding any pull-down of any significance was pulling the max voltage away from V+ just enough to not get to 127 when I integer divide by 8. Adding 4 before the divide gives enough leeway that I can pull-down with 100K and still get to 127 to the top and 0 at the bottom... which is what I was aiming for in the first place knowing the 8-bit resolution of MIDI could stand to loose a bit off the top.

Solved!

Still; learned a bunch so it was worth it. Thank you both one last time!
 
Status
Not open for further replies.
Back
Top