potentiometer that acts as a rotary switch

Started by Dimitree, June 17, 2014, 06:32:43 PM

Previous topic - Next topic

Dimitree

hello,
my aim is to use a standard potentiometer (let's say 10K linear) in order to trigger an electronic switch (let's say 4066 or 4053).
Not only ON-OFF, but more like a x positions rotary switch.
This is fairly simple using a uC with an ADC, you just measure the resistance and then decide how to trigger the electronic switch.

But, is it possible without an uC, using just logic chips (or maybe comparators or such) ?

R.G.

R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

earthtonesaudio

RG's suggestion is probably as simple and low-parts-count as you can get outside of a microcontroller. But is it possible with other devices? Absolutely. You could even use op-amps:
http://www.diystompboxes.com/smfforum/index.php?topic=89977.msg765149#msg765149

merlinb

+1 to RG's suggestion.

A further possiblility is a rotary encoder, which can be 'decoded' with a D-type flip flop and fed to a Johnson counter, or whatever.

MrStab

Quote from: R.G. on June 17, 2014, 06:57:53 PM
LM3914

that is a pretty damn cool idea! i need to come up with some excuse to play with that lol
Recovered guitar player.
Electronics manufacturer.

Dimitree

thanks for the many suggestions,
LM3914 in dot mode seems perfect, however now I will try to build a similar circuit using comparators, since LM3914 is quite pricey (I may need many) and I don't need 10 outputs

R.G.

Frankly, you need a uC. A US$0.50 to $1.00 uC will read your pot and set one of up to about 16 outputs reliably and cheaply with only the uC, the pot, and a 5V power supply.  If cost is an issue, the uC is going to eventually be cheaper for many units. If you can't program uCs, go find (or make!) a friend who can.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Dimitree

Thanks again, yes I can easily program microchip and atmel uCs, but I would prefer to not use an uC because I may need many units, and since my design is smd, I would need to program them in-circuit, quite boring.. But yes, hardware-wise would be easier/cheaper/smaller

slacker

Microchip have a programming service where you can buy PICs programmed with your own code. Depending on how many you need this can be easier and or cheaper than buying blank ones and programming them yourself.

Seljer

Aa 6 pin in-circuit programming header isn't that much of a hassle to add to your PCB. Programming a microcontroller with 1 or 2k of memory takes what, 10 seconds?

Dimitree

I tried to simulate something and come up with this:



in the simulation it works..
it gives exclusive output.. In some places I don't need exclusive outpus so I can remove the CD4070..
The 2 chips are pretty cheap and pretty small (in TSSOP package).. And since I only need 4 levels, I don't need precision in the choose of resistors and comparators.
any disadvantages?
do I need to buffer the pot voltage before it hits the comparators?

R.G.

Quote from: Dimitree on June 19, 2014, 03:33:59 PM
I tried to simulate something and come up with this:
That is very much like what's inside the LM3914, so it ought to be fine.

Quotein the simulation it works..
it gives exclusive output.. In some places I don't need exclusive outpus so I can remove the CD4070..
Give some thought to whether you want the comparator outputs to ever have a dead zone between them for any condition (in a switch this would be break-before-make) or to overlap so the next one goes on before the last one goes off, implementing make-before-break. Also worry a little bit about whether the output dithering back and forth if the input signal has some ripple or noise on it and wants to sit right on the middle between two states will be a problem. Also think about whether some minor hysteresis on each comparator would be useful. In general, no comparator should be left entirely without hysteresis, as many of them tend to break into bursts of oscillation right at the threshold. Not always, but generally when you're showing the prototype to the boss or a customer.

QuoteThe 2 chips are pretty cheap and pretty small (in TSSOP package).. And since I only need 4 levels, I don't need precision in the choose of resistors and comparators.
any disadvantages?
Other than have already been noted, no.
Quotedo I need to buffer the pot voltage before it hits the comparators?
What is the input impedance and bias current for the comparator inputs?

Probably with 1K resistors and a pot under 10K, no. However, do take a look at that.

Hmmm. Also, check out the common mode input range on your comparators. You're asking the comparators to function properly with an input at 0V. Some comparators can, some can't.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Dimitree

Quote. Also think about whether some minor hysteresis on each comparator would be useful. In general, no comparator should be left entirely without hysteresis,
And how do I add that? Adding a capacitor to ground on the comparator input perhaps?

Quote
Hmmm. Also, check out the common mode input range on your comparators. You're asking the comparators to function properly with an input at 0V. Some comparators can, some can't.
You mean 0V when the pot is fully on one side? If so, should I add resistors in series with the pot to limit the voltage range a bit?

Quote
. Also worry a little bit about whether the output dithering back and forth if the input signal has some ripple or noise on it and wants to sit right on the middle between two states will be a problem.
This only happens when the pot in near the limit between two states?

earthtonesaudio

Add hysteresis to a comparator with positive feedback. In your circuit, you could do this by:

* swap all comparator inputs: (+) becomes (-)
* put a large (10x or 100x the pot value to start, adjust to taste) resistor from each comparator's output to its (+) input
* note that the pot now operates in reverse compared to before

In your circuit as you rotate the pot from 0V to 5V you'll get the following output states:

0000 (0 to 5/6) volts
0001 (5/6 to 10/6) volts
0010 (10/6 to 15/6) volts
0100 (15/6 to 20/6) volts
1000 (20/6 to 25/6) volts
0000 (25/6 to 30/6) volts

Since you only want the middle 4 output states then you can put resistors on either side of your pot so it can't go to either 0 or 5V. Your pot should cover from just over 5/6 volts, to just under 25/6 volts, with enough voltage on each side to account for your hysteresis (if you choose to add it).

commathe

LM3914 pulls its outputs low rather than hi, correct?

merlinb

Quote from: Dimitree on June 19, 2014, 03:33:59 PM
I tried to simulate something and come up with this:
This won't work in real life until you add pull-up resistors to the comparator outputs.

Dimitree

ok I tried to add the suggestions:



I need to find better values for the resistors on the pot sides, since with those values it is not 100% linear..

btw, how does hysteresis YES/hysteresist NO translate in real life? I can't see any difference in the simulation

Seljer

In situation you're on the very edge between two separate output states:
-Without hysteresis you might get a jumpy output signal from whatever noise is present.
-With hysteresis when you transition from low->high, the voltage limit required to go from high->low is lowered slightly by the feedback so it doesn't accidentally retrigger until you go back down (and vice versa when it the output goes high->low)

So observe what happens as you move the pot up/down around one of the transition points.



And as merlinb noted, most comparators like the LM339 you listed have open-collector outputs so you need pull up resistors to get a proper voltage on the output.

merlinb

Quote from: Dimitree on June 20, 2014, 07:39:50 AM
how does hysteresis YES/hysteresist NO translate in real life? I can't see any difference in the simulation

With the pot half-way between two options, your outputs could flip rapidly back and forth between the two options. Possibly not an issue for you; you could just add some markings around the knob to show where it must be set to avoid any ambiguity.

You still need pull-up resistors from each comparator output to the supply voltage (100k say).

Dimitree

yes I will add pull-up resistors, thank you :)