Arduino Forum

Using Arduino => General Electronics => Topic started by: Boopidoo on Jan 31, 2013, 03:27 pm

Title: Rotary potentiometer with steps/positions
Post by: Boopidoo on Jan 31, 2013, 03:27 pm
Ok, this is probably not the "correct" way of describing it so please bear with me. :)

I'm looking for a rotary potentiometer that has pre-defined "steps/positions". I'd like to use it to change pages on a LCD-screen, each position of the potentiometer would be one page. The "feel" would be a lot better if I could match each page with a defined position on the knob.

It would be good if it had the aprox same dimensions as this one since I have a  number of knobs for it.
Pot: http://www.ebay.com/itm/221132272705?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2648
Knob: http://www.ebay.com/itm/321038173376?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2648
Title: Re: Rotary potentiometer with steps/positions
Post by: dhenry on Jan 31, 2013, 03:50 pm
Alps has some but they tend to be quite expensive.

A cheaper solution would be to use a rotary switch to control a digital pot.
Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Jan 31, 2013, 03:53 pm
What you're after is a called "rotary encoder"

http://www.ebay.com/sch/i.html?_nkw=12mm+rotary+encoder

There's libraries, etc. for them on the Arduino web site.
Title: Re: Rotary potentiometer with steps/positions
Post by: Grumpy_Mike on Jan 31, 2013, 04:52 pm
Quote
What you're after is a called "rotary encoder"

Yes but you can get them with or without "dents" these dents are the click that you feel when you turn it. You can also get different number of dents per revolution.
Title: Re: Rotary potentiometer with steps/positions
Post by: Papa G on Jan 31, 2013, 06:39 pm

Quote
What you're after is a called "rotary encoder"

Yes but you can get them with or without "dents" these dents are the click that you feel when you turn it. You can also get different number of dents per revolution.

The technical name for which is "detents", although "dents" is sure to get you a laugh.

The term potentiometer is incorrect in this situation, as a potentiometer is a type of variable resistor. As noted by others, a rotary encoder is what you are looking for.

Title: Re: Rotary potentiometer with steps/positions
Post by: Grumpy_Mike on Jan 31, 2013, 06:51 pm
Quote
The technical name for which is "detents", although "dents" is sure to get you a laugh.

Yep dyslexia and an iPad are not friends  ;)
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Jan 31, 2013, 06:53 pm
Well there are/were pots that had mechanical detents, used a lot is older stereo systems to give it a higher tech feel I guess.

Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Jan 31, 2013, 06:56 pm

Quote
The technical name for which is "detents", although "dents" is sure to get you a laugh.

Yep dyslexia and an iPad are not friends  ;)


We might believe that excuse if you'd only typed it once...  :.

Title: Re: Rotary potentiometer with steps/positions
Post by: Papa G on Jan 31, 2013, 07:03 pm

Well there are/were pots that had mechanical detents, used a lot is older stereo systems to give it a higher tech feel I guess.

Lefty

Agreed, but one wouldn't normally use one of those to select pages on an LCD like OP wants.

A pot with detents sounds like a really bad idea if the pot gets dirty at one of the detents. Probably why they use encoders for that application nowadays.
Title: Re: Rotary potentiometer with steps/positions
Post by: Papa G on Jan 31, 2013, 07:05 pm

Quote
The technical name for which is "detents", although "dents" is sure to get you a laugh.

Yep dyslexia and an iPad are not friends  ;)


I can sympathize. I get some pretty funny autocorrects from my iDevices.  :)
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Jan 31, 2013, 07:12 pm
Actually I think a standard pot with or without detents could make a fine menu selection input device. Just wire the pot ends to ground and +5vdc and after reading a pot wiper value do a right shift of say 6 bits, so the resulting pot values would be 16 distinct values depending on pot position, that could be used to select 16 different menu items in the coding.

Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: Papa G on Jan 31, 2013, 07:21 pm

Actually I think a standard pot with or without detents could make a fine menu selection input device. Just wire the pot ends to ground and +5vdc and after reading a pot wiper value do a right shift of say 6 bits, so the resulting pot values would be 16 distinct values depending on pot position, that could be used to select 16 different menu items in the coding.

Lefty

That would certainly work. You would a have a constant position of the knob for each menu item which may or may not be desirable. It might make the software slightly more complicated for when you wanted to add/delete menu pages. Another way for sure.
Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Jan 31, 2013, 07:30 pm

Actually I think a standard pot with or without detents could make a fine menu selection input device. Just wire the pot ends to ground and +5vdc and after reading a pot wiper value do a right shift of say 6 bits, so the resulting pot values would be 16 distinct values depending on pot position, that could be used to select 16 different menu items in the coding.


Nope. It works if there's only one menu (with exactly 16 items in it!) but it falls apart for anything more.

eg. Suppose you select a value in a sub-menu ... the pot will be in the wrong position when you return to the main menu (and it was probably in the wrong position when you went into the sub menu, too...)

Rotary encoders don't have any of those problems.
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Jan 31, 2013, 07:36 pm


Actually I think a standard pot with or without detents could make a fine menu selection input device. Just wire the pot ends to ground and +5vdc and after reading a pot wiper value do a right shift of say 6 bits, so the resulting pot values would be 16 distinct values depending on pot position, that could be used to select 16 different menu items in the coding.


Nope. It works if there's only one menu (with exactly 16 items in it!) but it falls apart for anything more.

eg. Suppose you select a value in a sub-menu ... the pot will be in the wrong position when you return to the main menu (and it was probably in the wrong position when you went into the sub menu, too...)

Rotary encoders don't have any of those problems.



You just lack imagination. There is never a 'wrong' position to be in until you do something to tell the software to accept that selection. ;)

I feel it could be a simple reliable menu pointing device if the sketch is designed correctly knowing before hand the maximum items for the menus and submenus before deciding how many shifts to make on the analog input readings. It's just software. Most menu selection interfaces require a second input, usually a button press to say yes that is the selection I want.  ;)

Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Jan 31, 2013, 10:07 pm

You just lack imagination. There is never a 'wrong' position to be in


Yes there is.

Suppose you have a menu. The fourth option is 'color'

You select 'color' and a sub menu appears. You select 'red', it's the the first click from the left on the pot. The LED turns red as a result and you get sent back to the main menu.

The main menu is now out of sync. If 'color' is still selected then the pot is in the wrong position. If 'color' isn't selected then the menu isn't very intuitive to use (the currently selected item will depend on the color you selected in the submenu).

Now suppose you go back to the 'color' submenu. It should have 'red' highlighted (the current LED color). Problem is, 'color' is the fourth option in the main menu so the pot isn't in the right place to do that.

It doesn't work.
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Jan 31, 2013, 10:11 pm
Quote
It doesn't work.


I agree in your mind it doesn't work. In my mind I can make it work perfectly. You seem to thinking turning among the options offered is the same as selecting an option, there is always another user action required to select the displayed option.  Lets leave it at that.

Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: Docedison on Feb 01, 2013, 04:31 pm
It works perfectly... providing that you choose to save the previous state so re entry places you at the position you exited at. Positional feedback must be from the visual display and not the knob. You don't read the knob you use the knob to read... Regardless of what the knob really is, rotary encoder, pot or rotary switch. Using a rotary encoder is probably the best move as it doesn't have the 270  deg rotational limitation of a pot  or the mechanical stops that most rotary switches do.
{Edit RKJ}

Bob
Title: Re: Rotary potentiometer with steps/positions
Post by: Boopidoo on Feb 01, 2013, 05:27 pm
Thanks for the suggestions and ideas. For me I guess a normal pot would be ok since I only need to. Switch between 2-3 pages.

Now the next question. Can I use a digital (pwm) pin for this? This can be made to know what position the pot is right or do I need an analog pin?

What type of pin should I use for a rotary encoder?
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Feb 01, 2013, 05:33 pm

Thanks for the suggestions and ideas. For me I guess a normal pot would be ok since I only need to. Switch between 2-3 pages.

Now the next question. Can I use a digital (pwm) pin for this? This can be made to know what position the pot is right or do I need an analog pin?

What type of pin should I use for a rotary encoder?


A digital pin used in PWM service is an output pin, it could not be used to 'read' anything. Reading something is an inputting function for your arduino board. An analog pin must be used to read a pot because a pot is only capable of generating a variable DC output voltage to be wired to a analog input pin. A rotary encoder needs to use two digital input pins and depending if you want to use interrupts to service the encoder or not you may be limited to using digital pins 2 and/or 3.

Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: Boopidoo on Feb 01, 2013, 05:45 pm
Ah, of course, thanks!

I think I might need to buy a Mega since I'm running out of pins. :)
Title: Re: Rotary potentiometer with steps/positions
Post by: kf2qd on Feb 01, 2013, 06:03 pm
A rotary switch with resistors in series. As you turn the switch to the various poles the resistance changes and you use that resistance value to determine which page to turn to. Basically what you wold be making in a multi-tap voltage divider.
Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Feb 01, 2013, 07:42 pm

A rotary switch with resistors in series. As you turn the switch to the various poles the resistance changes and you use that resistance value to determine which page to turn to. Basically what you wold be making in a multi-tap voltage divider.


Why not use a rotary encoder? It's what they're for.
Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Feb 01, 2013, 07:44 pm

It works perfectly... providing that you choose to save the previous state so re entry places you at the position you exited at.


That's precisely what makes the pot fail. There's situations where you can't turn it any further left or right. A rotary encoder turns forever.

Rotary encoders usually have a push switch in the knob, too. You can use it as "select" without taking your hand off it to press a separate button.
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Feb 01, 2013, 08:39 pm


It works perfectly... providing that you choose to save the previous state so re entry places you at the position you exited at.


That's precisely what makes the pot fail. There's situations where you can't turn it any further left or right. A rotary encoder turns forever.

Why must it be able to turn more left or right, as long as it can be turned to all the defined selections?

Rotary encoders usually have a push switch in the knob, too. You can use it as "select" without taking your hand off it to press a separate button.

So do some pots have a push switch built in. Also an encoder might have 200 steps per rev, your sketch has to jump through some hoops to limit the menu choices to just the number defined say a dozen or less?
Opps I said I was done with this topic didn't I?  ;)

Lefty


Title: Re: Rotary potentiometer with steps/positions
Post by: fungus on Feb 01, 2013, 09:51 pm

That's precisely what makes the pot fail. There's situations where you can't turn it any further left or right. A rotary encoder turns forever.

Why must it be able to turn more left or right, as long as it can be turned to all the defined selections?


Because the value displayed won't always match the position of the pot.

The display/pot get out of sync when you go to submenus. You end up in situations where you might want to turn the pot left but it's already fully left so you can't.

Title: Re: Rotary potentiometer with steps/positions
Post by: Docedison on Feb 01, 2013, 10:30 pm
I Think Young Person that you need to do some reading so that you have a better idea of what you have, what you want to do and how you are going to do it.
Before you start to work, You must "Plan your Work" and then you Must "Work Your Plan".

Bob
Title: Re: Rotary potentiometer with steps/positions
Post by: dhenry on Feb 01, 2013, 11:56 pm
Quote
For me I guess a normal pot would be ok since I only need to.


Just so you know, there are digital pots that can be incremented / decremented via up/down buttons, making them far more usable here.
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Feb 02, 2013, 12:03 am


That's precisely what makes the pot fail. There's situations where you can't turn it any further left or right. A rotary encoder turns forever.

Why must it be able to turn more left or right, as long as it can be turned to all the defined selections?


Because the value displayed won't always match the position of the pot.

The display/pot get out of sync when you go to submenus. You end up in situations where you might want to turn the pot left but it's already fully left so you can't.

You still create problems that exist only in your mind.  ;)

If your sketch wants/needs to jump to a new sub menu, then the first choice it should display is that which corresponds to where the pot actually is at that specific time, simple. And again that doesn't select the displayed option as that takes an additonal user's action such as pushing the push button.

Lefty

Title: Re: Rotary potentiometer with steps/positions
Post by: lemming on Feb 02, 2013, 12:41 am
These rotary encoders also embody a select switch by pressing down on the knob. (appologies for being a Sparkfun tart yet again).

https://www.sparkfun.com/products/9117

However, having programmed a few of these menu systems using various rotary encoders (use a four line LCD for clarity of the scrolling menus in the users mind rather than the two line) I find that these type of units have fairly fine dentents (or 'dents'). It can make it easy to overshoot.

One of those clunky rotary switches (with resistors soldered between the tabs) will have a more positive feel and selection. A seperate pushbutton will be required for selection.

Regarding the pots....  I think you would have to account for hysterisis in your code as there is not the demarcation of clicks between the various states.
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Feb 02, 2013, 01:00 am

These rotary encoders also embody a select switch by pressing down on the knob. (appologies for being a Sparkfun tart yet again).

https://www.sparkfun.com/products/9117

However, having programmed a few of these menu systems using various rotary encoders (use a four line LCD for clarity of the scrolling menus in the users mind rather than the two line) I find that these type of units have fairly fine dentents (or 'dents'). It can make it easy to overshoot.

The cheap mechanical encoders suffer from pretty bad contact bounce and detent positioning that doesn't always seem to line up with the electrical signal transition positions. They can be made to work with lots of software fussing, but optical or magnetic encoders are a whole lot easier to live with.

One of those clunky rotary switches (with resistors soldered between the tabs) will have a more positive feel and selection. A seperate pushbutton will be required for selection.

Regarding the pots....  I think you would have to account for hysterisis in your code as there is not the demarcation of clicks between the various states.

By reading a 10 bit pot value and shifting the results right allows a much lower number of possible count possibilities, the problem of hysteresis or small count variations becomes a non problem. It's all about how many different  values do you need from the pot as a ratio of 1023 possibilities. If you need only two value possibilities you shift the analogRead() results 9 bits right and the pot can only be seen as returning a 1 or 0 value, with the actual change being done at the 50% pot travel position.
Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: Grumpy_Mike on Feb 02, 2013, 08:57 pm
Quote
and detent positioning that doesn't always seem to line up with the electrical signal transition positions.

Most I have used only pass through the transition electrically when passing through it mechanically. When the control is sitting at rest the output is always the same.
Title: Re: Rotary potentiometer with steps/positions
Post by: dc42 on Feb 03, 2013, 12:01 am
What inputs will you be providing on the submenus? When using a rotary encoder, I generally use the built-in push button to cycle between different parameters or submenus, and the rotary motion to adjust the selected parameter.
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Feb 03, 2013, 12:05 am

Quote
and detent positioning that doesn't always seem to line up with the electrical signal transition positions.

Most I have used only pass through the transition electrically when passing through it mechanically. When the control is sitting at rest the output is always the same.


I found that I could force encoder steps just by applying slight pressure against the encoder knob without having to go through a detent click. Not at all positions and not all the time, but it just didn't have the precision feel and operation of the optical encoder I have. Like I said it could be made usable but I found them to be rather flimsy in actual operation.
Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: retrolefty on Feb 03, 2013, 12:11 am

What inputs will you be providing on the submenus? When using a rotary encoder, I generally use the built-in push button to cycle between different parameters or submenus, and the rotary motion to adjust the selected parameter.


The same, either a switch with a built in momentary push switch or a separate momentary switch to select the displayed menu option.

Lefty
Title: Re: Rotary potentiometer with steps/positions
Post by: dc42 on Feb 03, 2013, 12:14 am

I found that I could force encoder steps just by applying slight pressure against the encoder knob without having to go through a detent click. Not at all positions and not all the time, but it just didn't have the precision feel and operation of the optical encoder I have. Like I said it could be made usable but I found them to be rather flimsy in actual operation.


I have one encoder in which one of the transitions occurs more or less at the same position as the detent. My rotary encoder driver software has a 1-state hyteresis to make it insensitive to this. Every encoder I have purchased since has the state transitions away from the detent. The problem encoder has 16 detents/rev, whereas now I go for 8 or 12.