Only read pot value when it is turned quickly?

Is it possible for the arduino to not update variables controlled by a pot unless that pot is turned quickly? If the pot is turned slowly then the value of the variable would stay at its previous value.

How would I approach something like this?

You could use millis to look at how long it has been since the pot value changed by at least some amount.

Can't give you much more detail without getting some details from you.

tjm56: Is it possible for the arduino to not update variables controlled by a pot unless that pot is turned quickly? If the pot is turned slowly then the value of the variable would stay at its previous value.

How would I approach something like this?

I don't have a clue how you would approach this.

If were me,i would first decide what "quickly" meant. Then write an Arduino program to test with and design a circuit to monitor the pot turning.

If you can get an analog reading fast enough to satisfy "quickly", then, using milliseconds or microseconds, time the reading to get numerical values for "quickly". If within you parameters, then you have a valid method of determining the movement as quickly or slowly.

Paul

…If you get a big-difference in a short-time, the pot is moving fast. If you get small differences (or no differences) the pot is moving slowly (or not moving at all).

You’re obviously going to need a timer, made with millis() (like the Blink Without Delay Example), or depending on how fast/slow this thing is going to work, maybe you can use delay(). And, you’re going to have to figure out what “fast” and “slow” mean.

And of course, some if-statements so you can do different things under different conditions…

Take an initial reading and save this as your “old” or “previous” reading. Then another “current” reading again (after some time) and subtract. Either there will be no difference, a small difference, or a large difference.

If there is a large difference (after a short delay) the pot is moving quickly and you can “update your variables”.

If there is a small difference the pot is moving slowly. In this case update the “old” or “previous” reading to match the new reading. That way, after a small-slow movement you have a new starting point, the small differences won’t add-up, and any big difference means the pot is moving quickly.

Depending on what you're actually trying to do, it might be better to work with an encoder instead of a pot. With an encoder it is trivial to figure out how fast it is moving.

Yes, it's possible, but pots have a limited range of movement, so what happens when you bottom out on either end? If you're trying to compensate by allowing 'slow turn to reset the range' sort of thing, you're better off with a rotary encoder.

If you explained what your end goal was, folks here can help you figure it out instead of patching up your idea of what a possible solution could be.

Here is something like what I want to do:

https://www.youtube.com/watch?v=0m1ibTlUMj8

I am currently using rotary encoders but am having a major issue with them: constantly getting stuck counting upward so I was hoping this could be a simpler alternative

tjm56: I am currently using rotary encoders but am having a major issue with them: constantly getting stuck counting upward so I was hoping this could be a simpler alternative

That's kind of like buying a different brand of car because you have a flat tire.

aarg: That's kind of like buying a different brand of car because you have a flat tire.

just looking for the simplest solution!

Fixing your rotary encoder problem is likely the simplest solution.

If you use a ten turn pot you could do this. Look for a change in voltage greater than a certain mount.

.

INTP: Fixing your rotary encoder problem is likely the simplest solution.

how would you suggest I do that - are interrupts necessary? An issue with that would be that I am using four rotary encoders yet there are only two interrupt pins.

Yep..... just use the encoder. And use interrupts.

Set a current-time and previous-time variable for time value storage. Set previous-time to zero for initialisation, and set current-time to zero for initialisation.

When a pulse is detected by interrupt...measure the current time, and compare it to the previous time. Is (current-time MINUS previous-time) > 1 second ? If yes...... do something... like increment a counter ...and store the current-time to previous-time....repeat loop. If no....... then do nothing ....and store current-time to previous-time..... repeat loop.

tjm56:
how would you suggest I do that - are interrupts necessary? An issue with that would be that I am using four rotary encoders yet there are only two interrupt pins.

Maybe a MEGA 2560 could sort that.

When you take the road with interrupts, you can often cut down and avoid glitchy things that could happen when monitoring states of pins without interrupt.

But … then again, it doesn’t mean that you can’t use non-interrupt methods. As long as the solution works reliably for your purposes, then it’s ok.

You can use any pin as an interrupt with a pin change interrupt. Keep all 8 of the encoder pins on one port and you can handle the whole thing with one ISR.

Hi TJM,

This is sounding like it's getting waaay too complicated... what are you actually trying to do? are you really just looking for a simple hysteresis function?

That's EASY!

Pat.