Erratic and inconsistent results - Arduino board and rotary dial

I've used the code in the following tutorial many times in order to get the values from an old rotary dial:

Using it again tonight, I'm finding I'm getting very erratic numbers when dialing. The wiring/breadboard is definitely correct and the dial works fine - I've tested it all with another rotary dial (completely identical and has worked in the past with this setup) yet I still get inconsistent results.

Basically... Are there any reasons why an Arduino board may act in this way?

Any help greatly appreciated.

Are there any reasons why an Arduino board may act in this way?

Maybe it's just that time of month.

No code. No schematics. No proof that the wiring is correct/tight. No help, I'm afraid.

Wow.

Did you click the link? The link has the code, the link has the schematic.
It's a simple schematic - the wiring is definitely correct.
The code is the same that I've used before and has worked. And did I mention it's all available via the link? Forget the code, the code works.

THAT, is the mystery.

Forget the code, the code works.

So, you don't have a problem. I must have misunderstood. Sorry to have bothered you.

Ugh.

Mystery = problem.

Exactly the same setup that has worked countless times before.

Question: Is there any reason why an Arduino board may be giving inaccurate analogue readings in this situation...

LCenquire:
Ugh.

Mystery = problem.

Exactly the same setup that has worked countless times before.

Question: Is there any reason why an Arduino board may be giving inaccurate analogue readings in this situation...

Sounds like a bounce problem. To quote the article you cite - "Try playing about with the debounce constant and the 'how long do we wait before assuming dial has finished rotating' constant." . I would also add some hardware debounce.

stowite:
Sounds like a bounce problem. To quote the article you cite - "Try playing about with the debounce constant and the 'how long do we wait before assuming dial has finished rotating' constant." . I would also add some hardware debounce.

I did think that at first, but then I tested the whole setup with a different (but identical) rotary dial (a dial that's worked perfectly fine with this code before) and found that I was still getting the inconsistent values. So it's not that the code needs altering. Thanks though!

LCenquire:
So it's not that the code needs altering.

Sorry but that does not follow! The article is quite clear about what it thinks might need adjustment and that requires a code modification.

I've edited my last reply, but I'll add it here as well -

I know the code is fine as I've tested it with a different, but identical rotary dial that has worked perfectly with this setup before, and yet it now gives inconsistent readings.

LCenquire:
I've edited my last reply, but I'll add it here as well -

I know the code is fine as I've tested it with a different, but identical rotary dial that has worked perfectly with this setup before, and yet it now gives inconsistent readings.

Sorry but no two phones, even of the same type, will be identical! Stick an oscilloscope on the two phone outputs and I will guarantee that the two phone have significantly different bounce characteristics.

I don't understand why you persist in saying the code is fine when it works for one switch and not for another. While ever you persist with that silly assertion there is no point in anyone trying to help you.

stowite:
Sorry but no two phones, even of the same type, will be identical! Stick an oscilloscope on the two phone outputs and I will guarantee that the two phone have significantly different bounce characteristics.

I don't understand why you persist in saying the code is fine when it works for one switch and not for another. While ever you persist with that silly assertion there is no point in anyone trying to help you.

Right, okay, granted I can see your point there that there will be a difference.

BUT, it's not a 'silly assertion', you've misunderstood, I didn't[/][/b] say that the code has worked for one dial, but now isn't working for another "now please help, but the code is definitely working".
What I am saying, is that I have used this code before with a rotary dial and it all worked fine. I've got a new rotary dial and suddenly this whole setup isn't working. Logical solution: the rotary dial is different/faulty. BUT, I then took the original rotary dial and tested it with this setup (the same setup that worked previously) and I'm still getting the erratic readings.

Hi,
Can you post a picture of your project, so we can see how it is wired to the protoboard.
Have you just tried shorting the two wires together that go to the dial, and see if you get reliable readings.

Also check your protoboard, see if the red and blue or red and black strips down the length of the board continuous and do not have a break.
See the attached pictures.

Tom.... :slight_smile:

Protoboards.jpg

Protoboards1.jpg

Hi,
I read further down the instructables, some feedback, that increasing debounce to 20mS can help.

Tom... :slight_smile:

LCenquire:
It's a simple schematic - the wiring is definitely correct.
The code is the same that I've used before and has worked. And did I mention it's all available via the link? Forget the code, the code works.

THAT, is the mystery.

Did you update the Arduino-IDE between "used before and has worked" and "getting very erratic numbers"?

In that case, perhaps you better use the old version of the Arduino-IDE with your code, which "has worked".

An alpha particle strike on any portion of your memory can easily "flip a bit" causing random effects.
I suggest some grounded tin foil.

as in a hat?

Thanks for your replies!

Can you post a picture of your project, so we can see how it is wired to the protoboard.
Have you just tried shorting the two wires together that go to the dial, and see if you get reliable readings.

Tried shorting the wires to no avail!

I realise that your help is dependent on my providing a decent image, but... Yeah, this was taken in a rush before leaving the house. Can see the setup though.

Also check your protoboard, see if the red and blue or red and black strips down the length of the board continuous and do not have a break.

All fine! Nothing wrong with the breadboard.

I read further down the instructables, some feedback, that increasing debounce to 20mS can help.

Still erratic readings, just hit-and-miss as to a value is given at all when the debounce is changed from 10ms.

Did you update the Arduino-IDE between "used before and has worked" and "getting very erratic numbers"?

This setup has worked many times before and after IDE changes.

I did attempt to work this whole thing out again last night, and for a brief moment the values that were returned were correct... Then after leaving everything for 5 minutes and coming back to it, it was back to returning erratic and inconsistent numbers.

Though it does tend to be that 1s come through fine, and most often 2s, but then the higher numbers are returned as lower numbers, if that helps anyone figure something out...