Skip to main content

Replies sorted oldest to newest

So the first thing that came to mind was one of those decade-resistance boxes for prototype circuits:

Untitled

These are generally made up of multiple 1p10t rotary switches with 10 resistors (0,1,2,3,4...9) per decade.  So you could get a 1p10t rotary switch and solder in 10 resistors corresponding to the 10 resistances you need.  But these are 2-terminal widgets and not the 3-terminal potentiometer that you may (or may not?) need.

I figure what you're really after is the mechanical detents provided by the rotary switch.  So how about modifying a 1p10t rotary switch by extending its shaft on the bottom end.  Then couple this shaft with a collar to the shaft of "any" potentiometer.

rotary switch

It's just that while you may find a 10-detent potentiometer, I'd think these would be specialty items so spendy and with limited choices.

 

Attachments

Images (2)
  • Untitled
  • rotary switch

Stan, what's the purpose of the shaft extension?  I'd think just using the switch as it is would fill his requirement with the resistors.  Are you thinking about the transition between points?  If so, a shorting rotary switch has make before break contacts and would probably do the trick without the mechanical trickery.

Ceramic Rotary Switch 2 pole 11 positions (Make-Before-Break). NOS. Lot of 1, eBay: 264169120324

A little more expensive, but a lot easier to get working without mechanical issues.

Attachments

Images (1)
  • mceclip0
Last edited by gunrunnerjohn

A rotary switch with a pile of resistors is technically a 2-terminal "variable resistor" which is not the same as a 3-terminal "potentiometer".  Leo may only need the functionality of a "variable resistor" but sometimes words matter

Anyway, make-before-break or break-before-make may not work because there's a discontinuity in resistance when changing positions.  In one case the resistance briefly goes to infinity, in the other case two adjacent values are albeit briefly shorted so the resistance at the terminals momentarily drops.  Again, it depends on the application but one can imagine situations where even a brief jump in resistance can be a deal-breaker when you expect only incremental no-hiccup changes as you increase or decrease the value.

 

 

John identified the need to use a shorting relay.  This will avoid a momentary open condition.  It will create a momentary change in overall resistance as one resistor will be bridged while two contacts are shorted.  Whether this is significant depends on the values and how this is used.

I like Stan's approach of borrowing the detent function of the switch for a ganged potentiometer.  It is fairly common to gang combinations of switches and potentiometers to a common shaft.

I would use a wafer switch with two or more wafers.  Disassemble the switch to remove one or more wafers while leaving to detent in place.  This will leave a portion of the shaft exposed on the back of the switch.  It may be flat at this point as it fits a slot in the wafer.  Fabricate a small metal bracket for the pot and include it when you reassemble the switch.   You will need to couple the two shafts.  This will allow you to use any value you require and change to a different pot if needed.  Depending on the feel you want in the detent you may need to try a few switches.

 

 

I found this at Mouser. Digikey had them too but they don't stock them and they want you to order in batches of 1200. These are 79¢ apiece for a batch of ten.

It took a while to come up with one that just might work. The idea is to use one of these to feed into an analog pin of an Arduino that does an analog to digital conversion in the range 0-1023. With the detents, I should be able to have the feel of a rotary switch to yield 11 distinct value ranges.


I thought about a rotary switch with resistors wired in but this should be much easier. I remember that my Dad had a health-kit volt ohm meter that he put together once and it was like that; one big rotary switch.

Thanks for the ideas! -- Leo

Attachments

Images (2)
  • mceclip2
  • mceclip3
stan2004 posted:

So you really did want a 3-terminal potentiometer!  Just so I understand, you're using an A/D to detect 1 of 11 positions of the potentiometer as a selector switch to choose from 11 functions or programs or whatever in the Arduino ?

That's correct. I was thinking about the station stop block (the #132) and how I might want to work out a stop block controlled by an Arduino. I wanted to be able to vary the number of times a train might pass the station without stopping. Maybe 10 times seemed like a good number. I knew it could be done with a nice panel mount potentiometer. But continuously variable just doesn't cut it when you want a small count. I wasn't even sure if a pot with detents existed other than the ones with a center detent for stereo controls. If this idea works, I may use it for precise delay timing as well.

stan2004 posted:

A rotary switch with a pile of resistors is technically a 2-terminal "variable resistor" which is not the same as a 3-terminal "potentiometer".  Leo may only need the functionality of a "variable resistor" but sometimes words matter.  

Au contraire Stan.  There's no reason in the world you can't connect to both ends of the resistor string on the switch to make it the same as a three-terminal pot, just with steps.  Words do matter, but I'm not getting your point here.

Last edited by gunrunnerjohn
eddiem posted:

Just a note:

The Arduino map() function would let you change a pot that goes from 0 to 1023 to one that delivers values from 0 to 10....but with no detents

You probably already know that....

EddieM: Yep. I knew that. What I want is a way to make a 1 of 10 selection with the pot in a reliable manner. I think the stop points will give me the range of values that I can "map" to the proper selection. It's like having a rotary switch with only 3 wires and using one input pin of the Arduino. At least that's the idea.

They've arrived:

IMG_6463IMG_6466IMG_6468IMG_6472IMG_6473

They're a bit smaller than I expected but very workable. The detents count out to 10 stop positions within one turn; about 300 degrees. I mounted one through a piece of sketch board to see how they work. There's a tab that holds them in place so they don't spin on their own. Mechanically the feel is very much like that of a rotary switch which is what I wanted. Very smooth.

I don't seem to have any knobs that will fit the D-type shaft so I'll need to order some of those. And I need to test them out with an Arduino to find out if they will produce consistent values to get the 1 in 10 selection result. That comes next.

Attachments

Images (5)
  • IMG_6463
  • IMG_6466
  • IMG_6468
  • IMG_6472
  • IMG_6473

As I see it, the idea here is to use a single analog-to-digital input pin on the Arduino as a 1 of N (e.g., 1 of 10) selector of a mode, level, count, function, whatever.  The software must scan or sample the potentiometer value, say, ten times per second or faster to insure a somewhat responsive feel when a change is made.

So the typical way to perform this selector function with a rotary/knob input is with a 3-terminal quadrature rotary encoder switch which requires 2 digital input pins.

rotary encoder

Like the 3-terminal potentiometer method, a rotary encode also has 3-terminals.  As you rotate the shaft, the two internal switches turn on and off in a pattern that can be decoded (using software) to determine whether the switch is going CW or CCW.  The software must keep track of the absolute count (unlike the detent analog potentiometer method which will indicate its position in a single analog measurement).

In any case, these rotary encoders are low cost and are even available on tiny PCBs with square-pin headers to connect to Arduino modules using square-pin jumpers so no soldering.  These encoders typically have, say, 20 or 30 detents per revolution and are continuously rotating multiple revolutions can select from tens or even hundreds of modes, functions, levels, whatever.  

rotary encoder to arduino analog

So getting back to the topic at hand...and this being a discussion forum... I'm thinking someone out there in Arduino land might have tried to apply a 3-terminal rotary encoder plus 3 resistors (as shown above) to create a 4-level analog voltage to drive a single Arduino analog pin.  That is, as mentioned earlier, the Arduino must read the analog voltage, say, tens of times per second.  So now the selector software must only distinguish 1 of 4 analog levels, and then decide if the voltage change (if any) indicated a CW or CCW rotation and increment or decrement the selection accordingly. 

That is, now that the actual application is understood, while the detent potentiometer will surely do the trick, there is an argument that there is no value or use for the continuous resistance between detents. 

Attachments

Images (2)
  • rotary encoder to arduino analog
  • rotary encoder
Last edited by stan2004

Stan: I agree that there is no use for the continuous resistance from the potentiometers. I would settle for a rotary switch that produced 10 different values to distinguish it's position. I believe this was among the various solutions that were proposed earlier. Is there such a thing available off the shelf for under a dollar?

The rotary encoders are a bit more software intensive and I'm sure that you're right and someone has already tackled that problem. The phasing of the wave forms is a tricky bit of logic. But you do get the advantage of knowing the direction; CW, CCW. Also, they're kinda cool as controls go.

GRJ: Thanks for covering the part number break down.

To be clear, I think you have a completely workable/viable solution for the application at hand.

I am suggesting an alternative in the spirit of a forum discussion.  So if you search eBay for "detent potentiometer" you get a few hundred listings.  If you search for "rotary encoder" you get thousands of listings.  In either case there is software involved to convert an analog voltage to a discrete value - in your example it's a selector for 1 of 10 and the intermediate, non-detent, positions are irrelevant.  But that's just your application and clearly if this was used in some kind of analog circuit such as for audio volume control you might need the continuous resistance adjustment between detents.

But let's say this was a mfg production (as opposed to low-volume hobby) application.  For the scenario where you have 1 pin left on your microcontroller...and it happens to have analog (A/D converter) capability...an argument can be made that the design engineer might choose a rotary encoder with 3 resistors.  That is, the software is frequently sampling the analog value anyway.  It's now just a matter of the algorithm that converts a sequence of analog values into a discrete value.

rotary encoder 20mm

Perhaps there's a few more lines of software to be written with the rotary encoder + 3-resistor method.  So above is a eBay listing where in conjunction with 1 cent resistors the hardware is less than 50 cents.  The software is written once whilst the savings vs. a detent potentiometer is gained on each manufactured board or whatever is being produced. 

I completely acknowledge the incremental (vs. absolute encoding) nature of the rotary encoder method.  But if your next application needs, say, 20 detents, or 30 detents, or "N" detents then your inventory of 10-detent potentiometers remains on the shelf.  OTOH, you could use the same rotary encoder hardware and change 1 line of code which defines the number of positions.

Again, this is for discussion purposes only!

 

 

Attachments

Images (1)
  • rotary encoder 20mm
Last edited by stan2004

Stan: Understood. I'm all in for a discussion of alternatives.

For my application, where I want a small integral value between 1 and 10, it would be better to have a more certain form of feedback on what number that is exactly. The rotary position switch with numbers on it would be better, I think. A 7 segment display would be okay but then you have to drive it and that almost requires an MPU just to do the work.

The idea of using voltage differences as inputs to an Arduino analog input pin has been around for a while. I ran across this AVR tutorial on the subject. They demonstrate how it can be used with a 3x4 or 4x4 numeric keypad and other variations of switches and buttons to save on the number of total pins used. And here's another one that includes an Arduino library for a one wire keypad array.

3844-00

Attachments

Images (1)
  • 3844-00
Last edited by Consolidated Leo

Incremental rotary encoders tell you movement and direction.  They do not tell you absolute position.  For example when you turn your computer on it doesn't know where your mouse is initially positioned.  For position a starting point must be assumed or derived from another source like a reset button, limit switch or and index mark.

What you would use for this application is an absolute encoder.  For ten positions you would need 4 bits.  This can be done with a four pole rotary switch.  Some switches do this directly: numeric thumbwheel switches provide a 4 bit BCD output (binary coded decimal).  You would need 4 digital inputs to read these.

Back to the potentiometer:

This page has sample code.  https://wiki.dfrobot.com/Rotar...ule_V1__SKU_SEN0156_

The conversion from analog input reading to a finite position is very simple.  The analog input is sampled.  Then the reading is compared in turn to a list of threshold values until it finds the value that exceeds the reading.  In the example, a value up to 630 represents 1, up to 680 is 2, up to 750 is 3, etc.  These thresholds must account for tolerances in the resistances and A/D readings.

int adc_key_val[12] ={630,680,750,810,845,860,890,905,920,940,950,980};

// Convert ADC value to key number
int get_key(unsigned int input)
{
    int k;
    for (k = 0; k < NUM_KEYS; k++)
    {
      if (input < adc_key_val[k])
     {
          return k;
        }
   }
       if (k >= NUM_KEYS)k = -1;
       return k;
}

Consolidated Leo posted:

...

One question I have about the fancy rotary switch with the LEDs from DFRobot. If you make a selection, does the corresponding LED stay lit to give feedback? I didn't see anything about that.

df

Per the schematic provided in the link, one LED is always ON.  One assumes they did the math but in my opinion the stability is somewhat questionable.  So you have a 1024 count a/d converter.

int adc_key_val[12] ={630,680,750,810,845,860,890,905,920,940,950,980};

Between 680 and 750 the 3rd position has a zone of 70 counts to 'work with', but the 8th position has a zone of only 15 counts, and the 11th position only 10 counts!  10 counts is only 1% of the total range.  Sure they can use better than 1% resistors in the ladder....but this assumes that the LEDs are exactly matched to much better than 1% in terms of current vs. voltage.  I find this hard to believe but that's just my opinion.

To wit, if you read the product page a user challenges the stability as he could not get it to work even after messing with the table entries.  Someone from DFRobot also says this version will be revised to one that is "not based on analog signal" which is curious.

gunrunnerjohn posted:
stan2004 posted:

A rotary switch with a pile of resistors is technically a 2-terminal "variable resistor" which is not the same as a 3-terminal "potentiometer".  Leo may only need the functionality of a "variable resistor" but sometimes words matter.  

Au contraire Stan.  There's no reason in the world you can't connect to both ends of the resistor string on the switch to make it the same as a three-terminal pot, just with steps.  Words do matter, but I'm not getting your point here.

The point is to put the horse before the cart - determine "what" we are trying to do before specifying "how" to do it.  In this case, if the "what" includes a built-in feedback method such as LEDs like DFRobot, then a equal valued resistor string or detent potentiometer is not directly applicable since the LEDs sit between the string of resistors and the switch throws.  The LEDs upset the simple ratiometric division of the string of resistors.  Hence I was suggesting the generalized case of tapping into a pile of resistors of "random" configuration and values (note the range of resistor values in the DFRobot encoder) meaning it might have other components or interconnections.  Semantic gymnastics to say the least.

 

Attachments

Images (1)
  • df

Add Reply

Post
×
×
×
×
Link copied to your clipboard.
×
×