Author Topic: Potentiometer value with ADC  (Read 2134 times)

0 Members and 1 Guest are viewing this topic.

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Potentiometer value with ADC
« on: August 08, 2019, 09:05:46 pm »
I keep flip-flopping on whether the pot value matters, or not, for the rate of change when used with an ADC.

Part of this project involves making a digital clock, and I want to use a pot to set the time. Since one turn is one turn and 0-255 is 0-255, it seems to me that what ever value I use will not effect how fast the number changes. I keep trying to convince myself that using a larger pot will make the numbers change slower, however. For hours, 0-12, I do not expect a problem. For minutes, 0-59, on the other hand, it seems that it might be difficult to settle on the right number if it is changing at the same rate. Or maybe that the hours would be too slow. I am getting nowhere fast listening to myself. I have almost convinced myself, now, that the only way I am going to accomplish this is to go with a multi-turn pot. Could someone please set me straight?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13217
Re: Potentiometer value with ADC
« Reply #1 on: August 08, 2019, 11:19:13 pm »
If you wire the pot as a true potentiometer, the value has no effect on the unloaded output voltage provided the supply can provide enough current for the track resistance and the current at that supply voltage is within the pot's ratings.  However, when loaded, if the pot track resistance is greater than twice the maximum input resistance that the ADC is specified to work with, accuracy will be degraded.  Also if there is a large capacitance at the pot wiper, and you use a high resistance pot the voltage at the wiper may lag behind the physical pot movement by enough to be disconcerting or to make it difficult to adjust.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Potentiometer value with ADC
« Reply #2 on: August 08, 2019, 11:35:27 pm »
I have almost convinced myself, now, that the only way I am going to accomplish this is to go with a multi-turn pot.

Clock with multi-turn pots to me sounds like tool of torture. Why don't you use rotary encoder(s) instead?
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7681
  • Country: ca
Re: Potentiometer value with ADC
« Reply #3 on: August 09, 2019, 12:00:16 am »
You can scale the A/D so the pot goes from 1-12 or 0-59. Just dial in the value you want.
Or, less than half counts down, over 1/2 rotation counts up, with a dead zone in the middle.
Ideally a rotary encoder with built-in pushbutton switch would be the easiest UI.
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Potentiometer value with ADC
« Reply #4 on: August 09, 2019, 12:28:45 am »
Hmmm, I never bothered to look up what a rotary encoder was until just now. If I understand right, I could get away with a single one and just change the code depending on which number needs to change. It also sounds like I can easily adjust it to get the resolution I want. It would also mean that I could avoid buying new micros that have an ADC. I think I need to look into that a bit more.

Research time it looks like. Thanks all so far.
 

Offline StillTrying

  • Super Contributor
  • ***
  • Posts: 2850
  • Country: se
  • Country: Broken Britain
Re: Potentiometer value with ADC
« Reply #5 on: August 09, 2019, 12:30:07 am »
What's wrong with just an up button and a down button.
.  That took much longer than I thought it would.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Potentiometer value with ADC
« Reply #6 on: August 09, 2019, 12:34:04 am »
Hmmm, I never bothered to look up what a rotary encoder was until just now. If I understand right, I could get away with a single one and just change the code depending on which number needs to change. It also sounds like I can easily adjust it to get the resolution I want. It would also mean that I could avoid buying new micros that have an ADC. I think I need to look into that a bit more.

Research time it looks like. Thanks all so far.

You can do that with a pot too, you just need a button or switch to select which value you are changing. The advantage of an encoder is it offers continuous rotation so it's easy to scale to whatever granularity you want. A disadvantage is that most provide a relative rather than absolute value like a pot and also the software tends to be more complex. Not so much an issue anymore since there are ready to use libraries for either one.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Potentiometer value with ADC
« Reply #7 on: August 09, 2019, 12:40:35 am »
A disadvantage is that most provide a relative rather than absolute value like a pot

For a clock which is running relative value adjustment is advantage. Imagine you discovered that your clock is 5 seconds late - with encoder you just "add 5 clicks". With "absolute position" pot it will be many trial and error attempts while you "hit" the right number at right time.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Potentiometer value with ADC
« Reply #8 on: August 09, 2019, 12:44:03 am »
I should have been more clear. It can be either an advantage or a disadvantage depending on what you are trying to do. Either way it's something to keep in mind.
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Potentiometer value with ADC
« Reply #9 on: August 09, 2019, 07:14:26 pm »
What's wrong with just an up button and a down button.

That was my first thought. Actually my first thought was an up / down button for each digit. One of the reasons the clock in my bedroom is 3 1/2 hrs fast is because it is a pita to set it with the buttons though, so I quickly changed my mind on them.

I did find out that to get an encoder that would work like I was thinking would cost more than the whole project, or close to it. I am still stuck with ~ 3 turns for the minutes, but if I get one with a switch I can just switch to going 2 or 3 numbers at a time, if I have to go a ways.

For a clock which is running relative value adjustment is advantage. Imagine you discovered that your clock is 5 seconds late - with encoder you just "add 5 clicks". With "absolute position" pot it will be many trial and error attempts while you "hit" the right number at right time.

That was another thing I thought of. It does not matter where the knob is turned to when you go to make an adjustment.

... the software tends to be more complex. Not so much an issue anymore since there are ready to use libraries for either one.

I am primarily a software guy, so that makes it easier for me. It should not take more than a couple conditional statements, so I do not see any need for libraires, though.

I think I will start off with the encoder. I might change my mind later, but at least now I can go ahead and order parts. Thanks again.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Potentiometer value with ADC
« Reply #10 on: August 09, 2019, 08:15:12 pm »
I did find out that to get an encoder that would work like I was thinking would cost more than the whole project, or close to it.

Why you say so? On *Bay you can get five rotary encoders with end switch for 2.3$ delivered. If you make your clock using something like Arduino then encoder is all your additional costs.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Potentiometer value with ADC
« Reply #11 on: August 09, 2019, 08:29:58 pm »
The inexpensive encoders are simple to use in principal, but in practice they tend to be glitchy so the software has to account for this in order to provide a nice responsive debounced output. Go ahead and try on your own first if you want, just remember there are libraries out there that do the hard work if you have trouble.

If you don't want to set it at all another option is using a GPS module which can be had for around $5 these days and parse the time from the NMEA strings it spits out. You could also use a ESP8266 and pull the time from a NTP server.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Potentiometer value with ADC
« Reply #12 on: August 09, 2019, 09:12:41 pm »
The inexpensive encoders are simple to use in principal, but in practice they tend to be glitchy so the software has to account for this in order to provide a nice responsive debounced output.

Those inexpensive "bouncy" encoders can be easily tamed with debounce capacitor. It will limit maximum rotation speed, but will work even with generic encoder state polling code.
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Potentiometer value with ADC
« Reply #13 on: August 10, 2019, 01:54:31 am »
I did find out that to get an encoder that would work like I was thinking would cost more than the whole project, or close to it.

Why you say so? On *Bay you can get five rotary encoders with end switch for 2.3$ delivered. If you make your clock using something like Arduino then encoder is all your additional costs.

I was talking about >100 ppr, you are not going to get that for $.50.  24 ppr should work as I have it figured out. I do not need 5 a month from now, but can add 1 to my Mouser order for ~$1.50 and get it next week.

Those inexpensive "bouncy" encoders can be easily tamed with debounce capacitor. It will limit maximum rotation speed, but will work even with generic encoder state polling code.

Until I set something up, I have no idea how fast the numbers will change. I think it is safe to say, now that I have thought about it more, that in a worst case scenario that 30 is the maximum numbers that will need to be traversed. There is absolutely no reason to play wheel of fortune with the knob.

The inexpensive encoders are simple to use in principal, but in practice they tend to be glitchy so the software has to account for this in order to provide a nice responsive debounced output. Go ahead and try on your own first if you want, just remember there are libraries out there that do the hard work if you have trouble.

If you don't want to set it at all another option is using a GPS module which can be had for around $5 these days and parse the time from the NMEA strings it spits out. You could also use a ESP8266 and pull the time from a NTP server.

Years ago when I worked at a car dealership we used to laugh that you could tell mechanics from body men by what they drove, and for the most part it was true. The mechanic's ride was polished and shiny, but ran like shit.  The body man's ride was multi colored and looked like it was about to fall apart, but purred like a kitten. To put that more in this perspective, a hardware guy looks for libraries to make his software work. I do not learn anything by adding a library.

I really hope you where not serious about the GPS module.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Potentiometer value with ADC
« Reply #14 on: August 10, 2019, 04:58:41 am »
Why would you hope I'm not serious about the GPS module? I'm absolutely serious, you're building a clock right? A GPS module is great for a clock, it's an absurdly cheap device that spits out a ridiculously accurate timing signal and there are libraries to parse that down to whatever you need. The potential accuracy achievable will put anything short of a fullblown atomic clock to shame. GPS receivers have many uses outside of navigating, they even use them to synchronize the flashing of buoy beacons without requiring any sort of connection between the buoys.

Why do you need 100ppr? Or even 20ppr? Even an encoder with something crazy low like 5ppr would work fine for setting a clock. I'd even go so far as to say that the lowest ppr you can find is probably going to be better because if you have a really high resolution encoder you will either have to scale it in software and throw away a lot of that resolution, or you are going to have to make very small and precise movements to set the time. The beauty of an encoder is you can twirl it multiple revolutions, or a fraction of a revolution, it doesn't matter, it produces a relative output.
 

Offline ogden

  • Super Contributor
  • ***
  • Posts: 3731
  • Country: lv
Re: Potentiometer value with ADC
« Reply #15 on: August 10, 2019, 09:11:44 am »
I was talking about >100 ppr, you are not going to get that for $.50.  24 ppr should work as I have it figured out.

Clock will be fine with any encoder (that still works). High resolution > 100ppr encoders are for precision applications like CNC controllers. Using such for clock dial would be gigantic overkill.
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Potentiometer value with ADC
« Reply #16 on: August 11, 2019, 01:35:28 am »
Why would you hope I'm not serious about the GPS module? I'm absolutely serious, you're building a clock right? A GPS module is great for a clock, it's an absurdly cheap device that spits out a ridiculously accurate timing signal and there are libraries to parse that down to whatever you need. The potential accuracy achievable will put anything short of a fullblown atomic clock to shame. GPS receivers have many uses outside of navigating, they even use them to synchronize the flashing of buoy beacons without requiring any sort of connection between the buoys.

Why do you need 100ppr? Or even 20ppr? Even an encoder with something crazy low like 5ppr would work fine for setting a clock. I'd even go so far as to say that the lowest ppr you can find is probably going to be better because if you have a really high resolution encoder you will either have to scale it in software and throw away a lot of that resolution, or you are going to have to make very small and precise movements to set the time. The beauty of an encoder is you can twirl it multiple revolutions, or a fraction of a revolution, it doesn't matter, it produces a relative output.

OK, I did not think about GPS keeping time, but I guess it needs to. I am used to it giving crap directions down roads that do not exist or even into lakes. A RTC will be plenty good enough for this project, but I will keep the GPS deal in mind for future reference.

My thinking on the ppr bit is that each pulse will increase, or decrease, the number. If I have to spin the knob 10 X, it is not much better than using a button. I also do not want to overshoot the number, another problem with buttons. I am thinking of it in terms of what I expect to happen when I turn the knob, which I do not know until I build something. Unless I am mistaken, @ 5 ppr it would take over 2 complete turns to set hours from 0 - 12, or even one complete turn when considering +/- ability. A person cannot comfortably turn a knob one whole revolution in one action, it is probably closer to 1/2 a turn. That means 2 turns to turn the knob once. Until I have something to breadboard, it is all academic, and I have no idea how it will work in real life. It is, however, always easier to scale down than up.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Potentiometer value with ADC
« Reply #17 on: August 11, 2019, 04:32:44 am »
You're confusing GPS receivers with GPS navigation units. A navigation unit contains a GPS receiver but the receiver itself just spits out strings of data, this data includes raw coordinates as well as an extremely precise time signal because the way GPS works relies on very precise timing. The GPS satellites each have their own onboard atomic clock and everything has to be perfectly synchronized because your position is calculated from the time the signals from the various satellites take to travel from the satellite to the receiver module. It is the most accurate timing source available to the typical civilian.

My example of 5 ppr was a bit extreme in order to make a point. Pick up a cheap encoder from China and play with it, the sort you can get for a few dollars are the same type typically used for things like volume controls on stereo systems.
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Potentiometer value with ADC
« Reply #18 on: August 12, 2019, 01:41:42 am »
The ones I ordered are < $2, so cheap enough and will be here Tuesday. I got one with detents and one without. As long as they are slight, I think it might be better to give a more positive feel of being on the number without having to concentrate on the number. If they are too tight, I can just use the free wheeling one. I am hoping that for minutes it will not be too much travel because I overlooked switching from hours > minutes > seconds. The push button would be better used for that.

Thanks for clearing up the GPS bit. I knew they used time for positioning since they can be used for things like speedometers, just never thought of them as being used for actual clocks.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Potentiometer value with ADC
« Reply #19 on: August 12, 2019, 03:37:28 am »
GPS was designed for positioning, hence the name. In recent years though the receivers have dropped in price to the point where they cost only a few dollars each making them economical for purposes that have nothing to do with navigation. They even make receivers specifically optimized for timing, these have a 1pps output that occurs precisely at the top of the second.
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10385
  • Country: nz
Re: Potentiometer value with ADC
« Reply #20 on: August 12, 2019, 04:06:33 am »
Also consider it's cheap to get rotary encoders with a push button momentary switch built inside them.
Lot of products use them.
So you rotate L or R to the digit you want then push to change to the next digit that is to be changed. Perhaps the active digit flashes etc..

You can also get them with LEDs in but those usually have a price premium.
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9964
  • Country: us
Re: Potentiometer value with ADC
« Reply #21 on: August 12, 2019, 04:32:27 pm »
Also consider it's cheap to get rotary encoders with a push button momentary switch built inside them.
Lot of products use them.
So you rotate L or R to the digit you want then push to change to the next digit that is to be changed. Perhaps the active digit flashes etc..

You can also get them with LEDs in but those usually have a price premium.

I had a similar idea.  Rotate the encoder until the proper digit(s) flash, push the button, rotate the encoder until is displays the proper number and push the button again to lock in the value.  Now you are back to the starting state:  Rotate the encoder until the proper digit(s) flash...

Just make sure that the encoder is a 'detent' type with mechanical steps.
 

Offline admiralkTopic starter

  • Regular Contributor
  • *
  • Posts: 178
  • Country: us
Re: Potentiometer value with ADC
« Reply #22 on: August 13, 2019, 02:01:30 am »
That was basically my plan. Start at hours, first push goes to minutes, next one goes to seconds, then back to the beginning. I was thinking to just blank out unused numbers instead of blinking the ones open for editing. Ultimately there with be 5 "clocks", but the others will be timers.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf