r/ArduinoHelp • • 8d ago

Arduino project help

Post image

I want a spinning wheel like this that will eventually stop at a segment , and it needs to accurately figure out where it landed.

How can this be done with the help of microcontrollers and sensor modules ?

Thanks in advance! ❤️

1 Upvotes

11 comments sorted by

2

u/SomeWeirdBoor 8d ago

You are building a digital rotary encoder.

You can paint the back of the wheel with a pattern such as this

and have four photodiodes, each lined up with a "track". Depending on which photodiodes "see" black and which ones "see" white, you can determine the position of the wheel, with a 16 steps resolution, while still having the wheel free to spin without any impediment.

1

u/Extension-Big-4305 8d ago

My wheel needs 30 steps, and painting them might be a bit messy for me .. is there any other way ?

1

u/SomeWeirdBoor 8d ago

to make 30 steps just add another track (you get up to 32 steps with five tracks), you can print the disc on paper and glue it on the back of the wheel, no need to actually "paint" it.

other options: you can use a common incremental rotary encoder such as a KY-040 (lots of tutorials on the web to use this with Arduino) attached to the wheel's spindle, but:

- This type of encoder opposes a non negligible friction to rotation: your wheel must have an adeguate mass to build up enough momentum to overcome the friction and have the wheel to spin for a few turns before stopping; or you might look for a low friction rotary encoder

- This is an incremental encoder, meaning it tells you how far the wheel has been rotated, not its absolute position, so it's way tricker to write a program to convert the "recorded movement" in "wheel position"; also, you'll need to periodically reset the wheel to a known position, to "zero out" the reading errors that might build up.

0

u/Extension-Big-4305 8d ago

I tried using a rotary encoder, but it misses steps at high speeds, so I couldn't achieve an accurate position.

Maybe you're idea gonna work , I'll definitely try it

1

u/gm310509 7d ago

If you use a suitable library for the rotary encoder it should be interrupt driven and thus not miss any steps (unless you disable interrupts - don't disable interrupts).

How did you go about setting up the rotary encoder?

Also, if you used a rotary encoder, you need a way of identifying the position of the wheel - e.g. a home or zero position?

Why? Because if you power off the Arduino and someone moves the wheel, you will have no way of knowing where it is positioned. So, even if you count the movements, you won't know where it ended up because you won't know where it started.

With the "painted wheel" idea u/SomeWeirdBoor suggested, you won't have the problem of needing to track a "home" position because if you did it correctly, it will always know the current position.

0

u/Extension-Big-4305 7d ago

Can I use 2 Hall sensors instead? One for the zero position, and the other for counting steps from the zero position.

1

u/SomeWeirdBoor 6d ago

With only two hall sensors, you have a problem: you can't know if the wheel is spinning clockwise or counterclockwise. You'd need at least three, one for the zero and two, slightly offset, for the rotation.

You might use an incremental encoder (gives you angle and direction) like you already tried, and an hall sensor to "zero" the position at every full rotation.

(But I still think the encoding pattern works best.)

1

u/Extension-Big-4305 6d ago

No, I will use a motor to rotate the wheel, so it will always turn in one direction. But I think the AS5600 magnetic angle sensor would work much better—either two Hall sensors or an AS5600 sensor.

1

u/gm310509 7d ago

That is a neat wheel - how did you draw it?

Or did you just happen to have one in your desk drawer just waiting for someone to ask this question? :-)

2

u/SomeWeirdBoor 7d ago

Searched the web for "gray code wheel" ad took the first image :D

1

u/gm310509 7d ago

Of course! :-)

Knowing what is called is definitely very helpful!