Detented Pot vs. Rotary Switch

Was planning to use a 10k, 10-detent pot between 5v and 0v, wiper to an analog input, to provide 10 selection options for my sketch. Don't need real-time response so plan to put it in setup() so the selection is read once on startup or after reset is pressed.

Read here somewhere that using a pot is a bad idea. Can someone explain why? It's a lot less parts and effort than separate resistors and a rotary switch. Not sure how to use a rotary encoder which I suppose is another option.

Rotary Encoder is straight forward to add, member jurs wrote some code in this thread to read one and show a count from 0 to F and 00 to FF.
http://forum.arduino.cc/index.php?topic=318170.0
I used inexpensive mechanical encoders

with the filter circuit shown on page 2 of the datasheet

You can see it on the lower left corner of this standalone programmer board

rickso234:
Read here somewhere that using a pot is a bad idea. Can someone explain why? It's a lot less parts and effort than separate resistors and a rotary switch. Not sure how to use a rotary encoder which I suppose is another option.

I can only think of one reason why it might be a "bad idea":

Basically, because you say it can stay in one position, and is only read on reset/power-up of the Arduino (in the setup) - over time if it is left in one spot, then later (after a long period) it is moved - it may or may not have issues with it's value (and/or when it is returned to the same spot).

Have you ever had a radio with a volume control (potentiometer) that you left in one spot for a long time, then at some much later point tried to change the volume? What you sometimes will get is a lot of static/noise as you rotate the control - and in some cases the noise where the control was originally will be extremely horrible (or it will "skip") - because when the wiper of the pot is left in one spot, then "broke free" - it can damage the resistive track - plus all the accumulated dirt and stuff on the rest of the track that was not under the wiper can cause noise.

This "noise" - in the context of a rotary detented pot - might be interpreted as different values from what you originally were looking for.

Now - if the control is going to be used more often (changed more than once in a long while) - and the control is in some kind of environment that isn't "harsh" (high humidity, dust, temp swings, etc) - it will likely be ok for the most part. Just make sure your code checks for a "range" around the detented values, and that the ranges don't overlap - that will allow for any potential drift (due to any number of factors).

Otherwise, another solution for your selection control should be used; in such a case - a switch with multiple resistors would work better, though it would need more parts and such. Or, go with an absolute encoder rotary control (you can't use a simple quadrature encoded control - as you won't know it's value on a reset/power-up - you could save the value in the EEPROM after reading it, then read it again on startup and modify it from that point with the control - but then you would need some way of displaying the value for feedback to the user).

If the settings only very rarely changes - and you have the spare pins to do so - then a DIP switch might be more appropriate.

As far as T&M equipment goes, all the old stuff used pots. All the new stuff, except the very cheapest, use encoders. There is a reason for that - encoders are way more reliable. Also, they are more fun. Users can keep turning them all they want for added equipment enjoyment. But if all you are building is a little bit of hobby kit I wouldn't put you off using a pot if either you want to keep it cheap and familiar and don't need that better reliability.

I wouldn't use a single-pole bazillion-throw rotary switch either, for the reason you mention (uses too many inputs).

Rotary encoders are more reliable but they don't remember their position. You would have to save the position in non-volatile memory and could only change it when the program is running.

For reading the position at start up I would stick to the pot. The main reliability problems with pots are a result of a dirty environment with dust getting inside or long term wear of the track, particularly in one area. I doubt if it will be a problem for you.

Russell.

russellz:
Rotary encoders are more reliable but they don't remember their position.

No, some types do remember. Binary encoded switches like this one do remember but quadrature encoders don't remember. With the binary encoded ones you would probably need 5 resistors to distinguish the 10 positions with an analog input, or use 4 digital input pins and no resistors (just internal pull-ups) if you can afford that.
rotaryswitch.JPG

You could wire one up like this:

rotaryswitch.png

Which should give these approximate readings:

position analogRead()
0........ 1023
1........ 695
2........ 511
3........ 775
4........ 319
5........ 737
6........ 606
7........ 799
8........ 179
9........ 716

Paul

PaulRB:
No, some types do remember.

The usual rotary encoders don't. Your example is a switch not a rotary encoder however it is a good solution for the OP.

Russell.

Thanks for all the input. The pot will not be left in one position for a long time, will not be used in a harsh environment, and I plan to use wide. non-overlapping measurement ranges for each detent position. Will read its value during setup() and will not be moving the pot while trying to read its value, just setting it before applying power or setting it before pressing "Reset".