[Mitxela] wanted to build a different kind of mouse, one that worked like an Etch-a-Sketch toy with one X knob and one Y knob. Armed with some rotary encoders and a microcontroller, that shouldn’t be hard. But when you use a pin-limited ATtiny85, you are going to need some tricks.
The encoders put out a two-bit Gray code and close a button when you depress them. Plus you need some pins for the V-USB stack to handle the USB interface. [Mitxela] decided to convert the encoders to output analog voltages using a simple resistor DAC. That would only require two analog inputs, and another anlaog input could read both switches.
One problem: there still wasn’t quite enough I/O. Of course, with AVRs you can always repurpose the reset pin as an analog pin, but you lose the ability to program the device at low voltage. And naturally, there’s a workaround for this too, allowing you to keep the reset pin and still read its analog value. You just have to make sure that value doesn’t go below about 2.5V so the device stays out of reset. Once that was in place, the rest went easy, as you can see in the video below.
A LASER-cut enclosure and knobs finishes the project off nicely. Honestly, we might have been tempted to just get a bigger CPU, but we have to admit this works. If it were a commercial project, we might be a bit worried about reducing noise immunity on the reset pin, but for a hacker project it works and it is a clever use of pins.
We love crazy ideas about saving pins. Once you have an Etch-a-Sketch mouse on your desk, you might as well build a clock to go with it.
If you have two quadrature encoders (same thing as 2-bit Gray code), and two pushbuttons, that’s exactly the same inputs as a two-button mouse — you know, the old-fashioned kind with a rubber-coated steel ball. So gut one of those, and you get a preprogrammed MCU that does exactly what you need.
Look at the process, not the end result. If you just wanted an etch-a-sketch mouse, that’d be fine, but (i’m guessing) he wanted to learn how to make this work, and pulling a chip from an old mouse and soldering a couple of encoders to it doesn’t teach you all that much.
Yea – the mice of today just don’t have the balls
Ick, stick them 2 pots at the hinges of a pantograph type arm. ..
…. Then you gotta do some polar coordinate math, but it’s easier to use.
Reducing noise immunity? That’s some devious product design….
Well, I mean if I let RESET drop to near the threshold I am probably more prone to spurious resets due to noise.
mitxela’s projects are always good value, and as he says, edifying.
I sort-of had one years ago when some s**t stole my mouse ball. I had to stick my finger in the “mouse hole” and drive the x and y manually.
Wire the gray code Switches to some steering diodes so it pulses on different pins for each direction of rotation. Then wire that to the diodes in a good old ball mouse.
Why not use 2 potmeters if you convert to an analog value? Or am I missing something?
The pots are going to limit you to one rotation, or, at best, a maximum number of rotations. The grey-code encoder lets you know position AND direction of movement. That way, you can infinitely move the mouse.
He converts it to analog for pin-saving purposes.
Depends on the software. What if position was relative to speed not angle (:
He is using analog to read the digital which is different than reading a pot. A pot would go, say, 0-5V continuously. His scheme is 00=0V 01=2V 10=3V 11=4V (or something like that, I didn’t go back to look up the actual voltages).
Nice project.
I’ve build a usb volume knob using one ATtiny and one opamp some time ago. For the encoder I’ve grabbed one old hard drive motor, put all inside in a wood block and voilà.
Here are some photos: https://m.imgur.com/gallery/whDBj
are there any optical panel mount encoders on the market like this homebrew one?
http://www.m.radiokot.ru/forum/download/file.php?id=181267&sid=dda0ffd036faa3014336306db2d61a10