Encoders Spin Us Right Round

Rotary encoders are great devices. Monitoring just a few pins you can easily and quickly read in rotation and direction of a user input (as well as many other applications). But as with anything, there are caveats. I recently had the chance to dive into some of the benefits and drawbacks of rotary encoders and how to work with them.

I often work with students on different levels of electronic projects. One student project needed a rotary encoder. These come in mechanical and optical variants. In a way, they are very simple devices. In another way, they have some complex nuances. The target board was an ST Nucleo. This particular board has a small ARM processor and can use mbed environment for development and programming. The board itself can take Arduino daughter boards and have additional pins for ST morpho boards (whatever those are).

The mbed system is the ARM’s answer to Arduino. A web-based IDE lets you write C++ code with tons of support libraries. The board looks like a USB drive, so you download the program to this ersatz drive, and the board is programmed. I posted an intro to mbed awhile back with a similar board, so if you want a refresher on that, you might like to read that first.

Reading the Encoder

The encoder we had was on a little PCB that you get when you buy one of those Chinese Arduino 37 sensor kits. (By the way, if you are looking for documentation on those kinds of boards, look here.; in particular, this was a KY-040 module.) The board has power and ground pins, along with three pins. One of the pins is a switch closure to ground when you depress the shaft of the encoder. The other two encode the direction and speed of the shaft rotation. There are three pull-up resistors, one for each output.

I expected to explain how the device worked, and then assist in writing some code with a good example of having to debounce, use pin change interrupts, and obviously throw in some other arcane lore. Turns out that was wholly unnecessary. Well… sort of.

Continue reading “Encoders Spin Us Right Round”

This Old Mouse Keeps Track Of Filament Usage

Keeping track of your 3D-printer filament use can be both eye-opening and depressing. Knowing exactly how much material goes into a project can help you make build-versus-buy decisions, but it can also prove gut-wrenching when you see how much you just spent on that failed print. Stock filament counters aren’t always very accurate, but you can roll your own filament counter from an old mouse.

[Bin Sun]’s build is based around an old ball-type PS/2 mouse, the kind with the nice optical encoders. Mice of this vintage are getting harder to come by these days, but chances are you’ve got one lying around in a junk bin or can scrounge one up from a thrift store. Stripped down to its guts and held in place by a 3D-printed bracket, the roller that used to sense ball rotation bears on the filament on its way to the extruder. An Arduino keeps track of the pulses and totalizes the amount of filament used; the counter handily subtracts from the totals when the filament is retracted.

Simple, useful, and cheap — the very definition of a hack. And even if you don’t have a 3D-printer to keep track of, harvesting encoders from old mice is a nice trick to file away for a rainy day. Or you might prefer to just build your own encoders for your next project.

Continue reading “This Old Mouse Keeps Track Of Filament Usage”

Victorian Mouse

If Babbage had started the computer revolution early, we might have seen a mouse like the one [Peter Balch] created. He started with the guts from a USB wheeled mouse and some gears from an old clock movement. In addition to the big wheels to capture X and Y movement, the mouse buttons look like the keys from an old typewriter.

mechanical-mouse-magicWe were afraid the project would require advanced wood or metal working capability, but the bottom of the mouse is made from paper mache. The top and sides are cut from tinplate. Of course, the paint job is everything.

The electronics part is pretty simple, just hacking a normal mouse (although it is getting harder to find USB mice with mechanical encoders). However, we wondered if it would have been as simple to use an optical wireless mouse. That would leave the wheels just for show, but honestly, most people aren’t going to know if the wheels are useful or just ornamental, anyway.

If you don’t feel like gutting a mouse, but you still want USB, you could use an Arduino or similar board that can simulate a mouse. We’ve seen quite a few of those in the past. Now all you need is a matching keyboard.

[HomoFaciens] Shows Off With DIY Paper Printer

[HomoFaciens] is always making us feel silly about our purchases. Did we really need to buy a nice set of stepper motors for that automation project? Couldn’t we have just used some epoxy and a threaded rod to make an encoder? Did we need to spend hours reading through the documentation for an industrial inkjet head? Couldn’t we just have asked ourselves, “What would [HomoFaciens] do?” and then made a jailhouse tattoo gun attached to a broken printer carriage and some other household tech trash?

In his continuing work for his Hackaday prize entry, which we have covered before, his latest is a ink (…drop? ) printer. We think the goal is a Gingery book for CNC.  He begins to combine all his previous work into a complete assembly. The video, viewable after the break, starts by explaining the function of a salvaged printer carriage. A motor attached to a belt moves the carriage back and forth; the original linear encoder from the printer is used for positional feedback.

The base of the printer is a homemade y-carriage with another salvaged printer motor and encoder driving a threaded rod. The positional feedback for this axis is provided by a optical mouse gliding on a sheet of graph paper.  The printer nozzle is a cup of ink with a solenoid actuated needle in it. When the needle moves in a hole at the bottom, it dispenses ink.

As always, [HomoFaciens] makes something that is the very definition of a hack. Commenters will have to go elsewhere to leave their favorite debasement.

Continue reading “[HomoFaciens] Shows Off With DIY Paper Printer”

Wheel Of Resistors Form Unique Rotary Encoder

Continuing his tradition of making bits of wire and scraps of wood work wonders, [HomoFaciens] is back with a unique and clever design for an electromechanical encoder.

There are lots of ways to build an encoder, and this is one we haven’t seen before. Not intended in any way to be a practical engineered solution, [HomoFaciens]’ build log and the video below document his approach. Using a rotating disc divided into segments by three, six or eight resistors, the encoder works by adding each resistor into a voltage divider as the disc is turned. An Arduino reads the output of the voltage divider and determines the direction of rotation by comparing the sequence of voltages. More resistors mean higher resolution but decreased maximum shaft speed due to the software debouncing of the wiped contacts. [HomoFaciens] has covered ground like this before with his tutorial on optical encoders, but this is a new twist – sort of a low-resolution continuous-rotation potentiometer. It’s a simple concept, a good review of voltage dividers, and a unique way to sense shaft rotation.

Is this all really basic stuff? Yep. Is it practical in any way? Probably not, although we’ll lay odds that these encoders find their way into a future [HomoFaciens] CNC build. Is it a well-executed, neat idea? Oh yeah.

Continue reading “Wheel Of Resistors Form Unique Rotary Encoder”

Mechaduino- Closed Loop Stepper Servos For Everyone

Is it something in the water, or have there been a lot of really cool servo projects lately? Mechaduino is a board that sits on a regular stepper motor and turns it into a servo with a closed loop control of 0.1degree.

Whenever we post something about using cheap brushless motors for precision control, someone comments that a stepper is just a brushless motor with a lot of poles, why not just control it like one. That’s exactly what the Mechaduino does. They also hint at doing something very clever with a magnetic encoder on the board which allows them, after a calibration routine, to get the accuracy they’ve promised.

T Continue reading “Mechaduino- Closed Loop Stepper Servos For Everyone”

Hackaday Prize Entry: Industrial Servo Control On The Cheap

[Oscar] wonders why hobby projects ignore all the powerful brushless motors available for far less than the equivalent stepper motors, especially with advanced techniques available to overcome their deficiencies.  He decided it must be because there is simply not a good, cheap, open source motor controller out there to drive them precisely. So, he made one.

Stepper motors are good for what they do, open-loop positioning along a grid, but as far as industrial motors go they’re really not the best technology available. Steppers win on the cost curve for being uncomplicated to manufacture and easy to control, but when it comes to higher-end automation it’s servo control all the way. The motors are more powerful and the closed-loop control can be more precise, but they require more control logic. [Oscar]’s board is designed to fill in this gap and take full advantage of this motor control technology.

The board can do some pretty impressive things for something with a price goal under $50 US dollars. It supports two motors at 24 volts with up to 150 amps peak current. It can take an encoder input for full closed loop control. It supports battery regeneration for braking. You can even augment a more modest power supply to allow for the occasional 1 KW peak movement with  the addition of a lithium battery. You can see the board showing off some of its features in the video after the break.

Continue reading “Hackaday Prize Entry: Industrial Servo Control On The Cheap”