Category Archives: DIY

How To Use a Photo Tachometer

If you’re into anything even vaguely mechanical on the broad hacking spectrum, you’ve come into contact with things that spin. Sometimes, it’s important to know precisely how fast they are spinning! When you’ve got the need to know angular speed, you need a device to measure it. That device is a tachometer. And the most useful tachometer is the non-contact photo-tachometer.

The basic principle of operation of a photo-tachometer is quite simple. The device contains a light source – typically a laser, which can create a focused, coherent beam of light. This beam of light is capable of bouncing off of reflective objects.

To use the photo tachometer, you start by creating a reflective mark on the rotating surface you wish to measure. You must also ensure the rest of the rotating surface is comparatively non-reflective. An easy way to do this would be to create a white spot with a paint marker on an otherwise black or dull-metal shaft. Then, aim the beam of light from the photo-tachometer at the mark on the spinning shaft. Each time the reflective spot passes the beam of the photo-tachometer, some light is reflected back towards the device, where it is picked up by a light sensor. By counting the number of times the light sensor is triggered in a given time, it’s possible to determine the rotational speed of the machinery under test.

For example, let’s say we have a motor spinning at 1200 revolutions per minute. We aim the photo-tachometer’s beam at the white spot we’ve marked on the motor’s shaft. Let’s assume the photo-tachometer counts the number of pulses it sees in a unit time of one second to make its measurements. In one second, the white spot will pass the beam twenty times, triggering our light sensor as it goes by. The microcontroller in the photo-tachometer then does some simple maths – twenty pulses in one second, multiplied by 60 seconds – and we get a rotational speed of 1200 revolutions per minute on the display.

It is easy to imagine that if our shaft is rotating much more slowly, on the order of 10 RPM, our photo-tachometer will only see one pulse every six seconds. If we up this to 12 RPM, it’s still only one pulse every five seconds. Our tach is going to suffer trying to measure such low rotational speeds and it’s going to take a long time for it to notice any changes. Is there anything we can do to help in this situation?

Why yes, there is! We can place additional reflective spots on our rotating shaft. Let’s put ten spots on our rotating motor shaft. Now at 10 RPM, we’re getting a pulse of light every 0.6 seconds, and at 12 RPM, every 0.5 seconds. Our tach is now able to much more quickly respond to changes in speed at the low range – and we just need to remember to divide the display speed by ten to account for our additional markers.

There are other tricks you can use to improve performance, too. Many photo-tachs come with a supply of retro-reflective tape in the box. This is a special tape filled with lots of microscopic glass spheres that allow the tape to reflect light at any angle. Using this instead of white paint on a rotating machine allows us to measure with the photo-tachometer at an angle other than perpendicular to the marking. I used this myself to make a measurement of my car’s engine speed. It was impossible to point the tachometer straight at the crankshaft – but with the retro-reflective tape, I was able to point the laser at the crank pulley from above at an odd angle and still get a good reading.

The real power of photo-tachometers is they make it easy to get accurate rotational speed measurements without having to make any major modifications to the machinery beyond a spot of paint or tape. It’s a great non-contact method of measurement, and a usable photo-tach can be had for under $20 on eBay. I’ve wrapped up a review of the DT2234C+ tachometer on YouTube for your consideration. It’s the kind of thing that you’ll find incredibly useful having stashed away in the back of your toolbox. You’ll never know when you need it!

Filed under: Engineering, Hackaday Columns

from Blog – Hackaday

The Custom Clicky Shortcut Keypad

You’re not cool unless you have a mechanical keyboard. Case in point: if you were to somehow acquire an identical keyboard to the one I used to type this, it would set you back at least seven hundred dollars. Yes, it’s mechanical (Topre), and yes, I’m cooler than you. Of course, you can’t be as cool as me, but you can build your own mechanical keyboard. [Robin] is, I presume, a pretty cool dude so he built his own keyboard. It’s the amazing shortcut keyboard, and it can be programmed graphically.

The idea for this keyboard came when [Robin] was studying as an engineer. We assume this is code for wearing out the Escape key on AutoCAD, but many other software packages have the same problem. The solution to [Robin]’s problem was a shortcut keypad, a 3 by 4 matrix of Cherry switches that could be programmed for any task.

The design of this keyboard started out as an Adafruit Trellis matrix keypad. This was combined with some software written in Processing that assigned macros to each button. This was a sufficient solution, but the switches in the Adafruit trellis look squishy. These are not the right switches for someone who craves a soft snap under every fingertip. It’s not the keyboard of someone who desires the subtle thickness of laser etched PBT keycaps. The Adafruit keypad doesn’t have the graceful lines of a fully sculpted set of keycaps. Oh my god, it’s doubleshot.

[Robin]’s completed keyboard has gone through a few revisions, but in the end, he settled on PCB-mounted switches and a very clever 3D printed standoff system to hold an Arduino Pro Micro in place. The enclosure, too, is 3D printed, and the end result is a completely custom keyboard that’s perfect for mashing key combos.

You can check out a video of this keyboard in action below.

Filed under: Arduino Hacks, peripherals hacks

from Blog – Hackaday

Are You Down With MPPT? (Yeah, You Know Me.)

Solar cells have gotten cheaper and cheaper, and are becoming an economically viable source of renewable energy in many parts of the world. Capturing the optimal amount of energy from a solar panel is a tricky business, however. First there are a raft of physical prerequisites to operating efficiently: the panel needs to be kept clean so the sun can reach the cells, the panel needs to point at the sun, and it’s best if they’re kept from getting too hot.

Along with these physical demands, solar panels are electrically finicky as well. In particular, the amount of power they produce is strongly dependent on the electrical load that they’re presented, and this optimal load varies depending on how much illumination the panel receives. Maximum power-point trackers (MPPT) ideally keep the panel electrically in the zone even as little fluffy clouds roam the skies or the sun sinks in the west. Using MPPT can pull 20-30% more power out of a given cell, and the techniques are eminently hacker-friendly. If you’ve never played around with solar panels before, you should. Read on to see how!

Power Points

Let’s start at the ends. The specs for any cell will include an open-circuit voltage and a short-circuit current that it produces under a given illumination. If you don’t have the spec sheet, you can measure these yourself. Connecting a voltmeter to the cell and putting it in the sun measures the former, and swapping out an ammeter and measuring the current measures the latter. So far, so good. But neither of these configurations produces any power, and power delivered over time is what charges up your batteries.

solarcellPower equals voltage times current, P=IV. The open-circuit power is zero because no current is flowing, and the short-circuit power is zero because there’s no voltage difference across the terminals (ideally). Somewhere between these extremes of infinite resistance and zero resistance lies the maximum power point.

Finding it by yourself is as easy as attaching a variable load resistor to the solar panel and noting down the voltage across and current through the resistor at various resistances. Write I with V down as you vary the load resistance and pick the highest value. Done! (Yellow is the current vs. voltage curve, and green is the power.)

If you’re doing this by hand, the first thing to mention is the power handling capacity of the resistor that you’re using to measure the current. A big twenty-watt panel is going to literally burn through a standard 1/4 watt resistor faster than you can say “what’s that smell?”. [Julian Ilett], in his lengthy YouTube video series on creating an Arduino-powered MPPT battery charger, uses a large array of miniature bulbs (LAMB) that he can screw into their sockets to vary the load. We’ve also seen various controllable dummy-load projects ranging from small to very large. That’s ideal, but it’s a project in itself.


For a quick lash-up that will work for small-to-medium cells, you could do worse than a potentiometer manually controlling the current through a heatsinked power MOSFET. This circuit doesn’t offer precise control of the current, but you don’t need it either, and heck, it only requires two parts and is good for a few watts. It won’t work below the gate threshold of the FET, which was around 3.5 V, so it’s only good for bigger panels or bright sun.

Stay in the Zone

Once you have a good idea about how your panel runs under various loads, you can start designing a system to optimize this for you, and switch out the dummy load for something useful like a battery. An MPPT automates the above current and voltage measurements and includes a voltage converter to keep the solar panel running at its maximum power rating. If we’re interested in charging batteries at a lower voltage than the cell’s maximum power voltage, this converter can be as simple as a buck converter: a fast switch, a large inductor, and a freewheeling diode (or second switch).

buck_circuit_diagramWe usually think of a buck converter as taking an unknown input voltage and stepping it down to a fixed lower output voltage by varying a PWM duty cycle. Here, the PWM is set to maintain the desired voltage on the input from the solar panel so that it’s operating at peak power. Whatever charge passes from the panel into the inductor eventually makes its way downstream to the battery, minus switching and resistive losses in the inductor.

TI has an app note (PDF) that describes possible control strategies in overview. These can be as simple as operating the panel at 80% of it’s open-circuit voltage, or as complicated as sweeping the full range and picking the maximum directly. Just be aware that any adaptive strategy has to take into account that external lighting conditions can be changing continuously as the controller is trying to find the peak.

In particular, if you choose what TI calls a “perturb and observe” strategy — varying the panel voltage a little bit and observing whether more or less power results — changes in the light hitting the panel can make a perturbation look like it improves the panel’s efficiency when really it was just a cloud fading away. Indeed, in [Julian]’s video on automating the power controller you can see it falling into this trap, and we suspect it’s because his algorithm reacts too frequently. A slower feedback loop would be better in our opinion: you don’t mind losing a tiny bit of total power by failing to account for every crow that flies over the panel, but still you do want to drop the buck ratio when it becomes cloudy over a few minutes. There’s tons of room here for experimentation.

With Great Power…

Nature controls the inputs, and your MPPT controls the solar panel’s working voltage to maximize power. The downstream voltage and current are left to fluctuate. If you’re doing something forgiving like charging a lead-acid battery, you can pretty much just dump straight into the battery, taking care to shut off the solar panel when the battery is fully charged. Other than possible overcharge, which you could guard against by reading the battery voltage, a car battery will soak up whatever current you hand it.

img_9195If you’re charging up a battery with more sensitive chemistry, you may need further voltage or current limiting. We’re currently experimenting around with cheap eBay 5 V lithium-ion chargers and old laptop batteries. [Rusdy] has more real-world data on his e-bike charging setup, but there he’s using a step-up converter to charge higher-voltage battery packs.

A panel-to-battery MPPT and charge controller that makes charging lithium-ion batteries simple and efficient is obviously a great thing to have. We’ve had a number of MPPT charger projects on and they’ve even done well in the Hackaday Prize. There are many open designs out there for you to draw inspiration from, or just copy.

An MPPT is a great intermediate project in power electronics — you’ll learn something about current measurement and get to build your own boost or buck converters. There’s lots of room for data logging and optimization of control algorithms in firmware if that’s your thing. You can start with a small panel and parts from your junk box, or modify eBay parts. And in the end, you get your batteries charged “for free”. How cool is that?

Are you working on an MPPT project right now? If so, let us know!

Filed under: Engineering, green hacks, Hackaday Columns, how-to

from Blog – Hackaday

Neural Network Composes Music; Says “I’ll be Bach”

[carykh] took a dive into neural networks, training a computer to replicate Baroque music. The results are as interesting as the process he used. Instead of feeding Shakespeare (for example) to a neural network and marveling at how Shakespeare-y the text output looks, the process converts Bach’s music into a text format and feeds that to the neural network. There is one character for each key on the piano, making for an 88 character alphabet used during the training. The neural net then runs wild and the results are turned back to audio to see (or hear as it were) how much the output sounds like Bach.

The video embedded below starts with a bit of a skit but hang in there because once you hit the 90 second mark things get interesting. Those lacking patience can just skip to the demo; hear original Bach followed by early results (4:14) and compare to the results of a full day of training (11:36) on Bach with some Mozart mixed in for variety. For a system completely ignorant of any bigger-picture concepts such as melody, the results are not only recognizable as music but can even be pleasant to listen to.

MIDI describes music in terms of discrete events, and individual note starts and stops are separate events. Part of the reformatting process involved representing each note as a single ASCII character, thereby structuring the music more like text and less like keyboard events.

The core of things is this character-based Recurring Neural Network which is itself the work of Andrej Karpathy. In his words, “it takes one text file as input and trains a Recurrent Neural Network that learns to predict the next character in a sequence. The RNN can then be used to generate text character by character that will look like the original training data.” How did [carykh] actually use this for music? With the following process:

  1. Gather source material (lots and lots of MIDI files of Bach pieces for piano or harpsichord.)
  2. Convert those MIDI files to CSV format with a tool.
  3. Tokenize and reformat that CSV data with a custom Processing script: one ASCII character now equals one piano key.
  4. Feed the RNN with the resulting text.
  5. Take the ouput of the RNN and convert it back to MIDI with the reverse of the process.

[carykh] shares an important question that was raised during this whole process: what was he actually after? How did he define what he actually wanted? It’s a bit fuzzy: on one hand he wants the output of the RNN to replicate the input as closely as possible, but he also doesn’t actually want complete replication; he just wants the output to take on enough of the same patterns without actually copying the source material. The processing of the neural network never actually “ends”; [carykh] simply pulls the plug at some point to see what the results are like.

Neural Networks are a process rather than an end result and have varied applications, from processing handwritten equations to helping a legged robot squirm its way to a walking gait.

Thanks to [Keith Olson] for the tip!

Filed under: digital audio hacks, musical hacks

from Blog – Hackaday

Can You Bull’s-Eye A Womprat With A Bean Bag?

As it turns out, a simple game of cornhole — aka, bean bag toss — can have some pretty high stakes. If you lose a round playing on this Death Star trench run cornhole table, the Rebel Alliance may pay the price.

Designed and built by [Hyperdynelabs], the table is set up to play a number of audio clips from the movie with accompanying light effects. Details on how it was made are scant, but there are at least three strips of RGBW LEDs — two that run the length of the board and one inside the exhaust port — an Arduino(presumably), and some sort of wireless connectivity to receive commands.

But it’s not just the electronic effects that make this one great. The physical build itself really nails the Death Star trench run look. This is thanks to artful use of greebles — it’s the same technique which can turn a Nissan into a Z-Wing.

When you make a shot worthy of Luke Skywalker, you’re treated to an impressive lightshow and the sound of the Death Star exploding. For a particularly bad turn, you can have the table charge up and make a show of firing back, or taunt the player if their shot goes wide.

The lights and magic are reminiscent of an arcade machine, which suits the hit-or-miss style of play for this particular board. If cornhole is new to you, or you want to start preparing for a proper BBQ bonanza, check out our feature on some summer DIY projects.

Filed under: misc hacks

from Blog – Hackaday

PiSound, The Audio Card For The Raspberry Pi

Kids today are being loud with their ‘drum machines’ and ‘EDM’. Throw some Raspberry Pis at them, and there’s a need for a low-latency sound card with MIDI and all the other accouterments of the modern, Skrillex-haired rocker. That’s where PiSound comes in.

Of course, the Pi already comes with audio out, but that’s not enough if you want to do some real audio processing. You need audio in as well, and while you’re messing around with that, adding some high-quality opamps, ADCs, DACs, and some MIDI would be a good idea. This is what the PiSound is all about.

[Pranciskus], the guy who has been working on the PiSound for a while now, developed this multitool for audio on a tiny Linux system. One of the killer features on the PiSound is ‘The Button’, a simple tact switch that runs a script if the button is pressed, another script if the button is held down, and two more if the button is pressed two or three times. This is actually a pretty nifty UI, and we wouldn’t mind seeing this on a few more Pi accessories.

If you’d like to see some example projects using the PiSound, there example MIDI controllers, networked audio players, and some goofing around with LV2 plugins over here.

Filed under: Raspberry Pi

from Blog – Hackaday

A Wordsearch Twist on the Word Clock

We love seeing new takes on existing ideas, and [Danny] certainly took the word clock concept in an unusual direction with his Wordsearch Clock. Instead of lighting up words to spell out the time, [Danny] decided to embrace the fact that the apparent jumble of letters on the clock face resembles a word search puzzle.

In a word search puzzle, words can be found spelled forward or backward with letters lined up horizontally, diagonally, or vertically. All that matters is that the correct letters are in a line and sequentially adjacent to one another. [Danny]’s clock lights up the correct letters and words one after the other, just as if it were solving a word search puzzle for words that just happen to tell the correct time. You can see it in action in the video, embedded below.

[Danny] went the extra mile in the planning phase. After using a word search puzzle generator tool to assist in designing the layout, he wrote a Processing sketch to simulate the clock’s operation. Visually simulating the clock allowed him to make tweaks to the layout, identify edge cases to address, and gain insight into the whole process. If you’re interested in making your own, there is a GitHub repository for the project.

Word Clocks are a great place to see innovation; you can go small like this micro word clock, you can push the concept for all it’s worth by adding heaps of weather data, or just go the extra mile on presentation like this walnut-finish clock.

Filed under: clock hacks

from Blog – Hackaday