Pi-Based Spectrometer Puts The Complexity In The Software

Play around with optics long enough and sooner or later you’re probably going to want a spectrometer. Optical instruments are famously expensive, though, at least for high-quality units. But a useful spectrometer, like this DIY Raspberry Pi-based instrument, doesn’t necessarily have to break the bank.

This one comes to us by way of [Les Wright], whose homebrew laser builds we’ve been admiring for a while now. [Les] managed to keep the costs to a minimum here by keeping the optics super simple. The front end of the instrument is just a handheld diffraction-grating spectroscope, of the kind used in physics classrooms to demonstrate the spectral characteristics of different light sources. Turning it from a spectroscope to a spectrometer required a Raspberry Pi and a camera; mounted to a lens and positioned to see the spectrum created by the diffraction grating, the camera sends data to the Pi, where a Python program does the business of converting the spectrum to data. [Les]’s software is simple by complete, giving a graphical representation of the spectral data it sees. The video below shows the build process and what’s involved in calibrating the spectrometer, plus some of the more interesting spectra one can easily explore.

We appreciate the simplicity and the utility of this design, as well as its adaptability. Rather than using machined aluminum, the spectroscope holder and Pi cam bracket could easily be 3D-printer, and we could also see how the software could be adapted to use a PC and webcam.

Continue reading “Pi-Based Spectrometer Puts The Complexity In The Software”

Code Your Own Twitch Chat Controls For Robots — Or Just About Anything Else!

Twitch Plays Pokemon burst onto the then nascent livestreaming scene back in 2014, letting Twitch viewers take command of a Game Boy emulator running Pokemon Red via simple chat commands. Since then, the same concept has been applied to everything under the sun. Other video games, installing Linux, and even trading on the New York Stock Exchange have all been gameified through Twitch chat.

TwitchPlaysPokemon started a craze in crowdsourced control of video games, robots, and just about everything else.

You, thirsty reader, are wondering how you can get a slice of this delicious action. Fear not, for with a bit of ramshackle code, you can let Twitch chat take over pretty much anything in, on, or around your computer.

It’s Just IRC

The great thing about Twitch chat is that it runs on vanilla IRC (Internet Relay Chat). The protocol has been around forever, and libraries exist to make interfacing easy. Just like the original streamer behind Twitch Plays Pokemon, we’re going to use Python because it’s great for fun little experiments like these. With that said, any language will do fine — just apply the same techniques in the relevant syntax.

SimpleTwitchCommander, as I’ve named it on Github, assumes some familiarity with basic Python programming. The code will allow you to take commands from chat in two ways. Commands from chat can be tabulated, and only the one with the most votes executed, or every single command can be acted on directly. Actually getting this code to control your robot, video game, or pet viper is up to you. What we’re doing here is interfacing with Twitch chat and pulling out commands so you can make it do whatever you like. With that said, for this example, we’ve set up the code to parse commands for a simple wheeled robot. Let’s dive in.

Continue reading “Code Your Own Twitch Chat Controls For Robots — Or Just About Anything Else!”

Python Will Soon Support Switch Statements

Rejoice! Gone are the long chains of ifelse statements, because switch statements will soon be here — sort of. What the Python gods are actually giving us are match statements. match statements are awfully similar to switch statements, but have a few really cool and unique features, which I’ll attempt to illustrate below.

Continue reading “Python Will Soon Support Switch Statements”

Wires Vs Words — PCB Routing In Python

Preferring to spend hours typing code instead of graphically pushing traces around in a PCB layout tool, [James Bowman] over at ExCamera Labs has developed CuFlow, a method for routing PCBs in Python. Whether or not you’re on-board with the concept, you have to admit the results look pretty good.

GD3X Dazzler PCB routed using CuFlow

Key to this project is a concept [James] calls rivers — the Dazzler board shown above contains only eight of them. Connections get to their destination by taking one or more of these rivers which can be split, joined, and merged along the way as needed in a very Pythonic manner. River navigation is performed using Turtle graphics-like commands such as left(90) and the appropriately named shimmy(d)that aligns two displaced rivers. He also makes extensive use of pin / gate swapping to make the routing smoother, and there’s a nifty shuffler feature which arbitrarily reorders signals in a crossbar manner. Routing to complex packages, like the BGA shown, is made easier by embedding signal escapes for each part’s library definition.

We completely agree with [James]’s frustration with so many schematics these days being nothing more than a visual net lists, not representing the logical flow and function of the design at all. However, CuFlow further obfuscates the interconnections by burying them deep inside the wire connection details. Perhaps, if CuFlow were melded with something like the SKiDL Python schematic description language, the concept would gain more traction?

That said, we like the concept and routing methodologies he has implemented in CuFlow. Check it out yourself by visiting the GitHub repository, where he writes in more detail about his motivation and various techniques. You may remember [James] two of his embedded systems development tools that we covered back in 2018 — the SPI Driver and the I2C driver.

An Algorithm For Art: Thread Portraits

We’ve all been there — through the magic of the internet, you see someone else’s stunning project and you just have to replicate it. For [Jenny Ma], that project was computer-generated string art, as in the computer figures out the best nail order to replicate a given image, and you lay out the thread yourself.

So, how does it work? Although a few algorithms are out there already, [Jenny] wanted to make her own using Python. Essentially it crops the image into a circle and then lays out evenly-spaced software nails around the circumference. The algorithm starts from a random nail and then determines the best next nail to wrap around by drawing a line from that nail to every other nail and choosing the darkest one based on the darkness of the image underneath that little line. It repeats this one chord at a time, subtracting from the original image until every pixel has been replaced with a thread or lack thereof, and then it spits out an ordered list of nail numbers.

Once the software was ready, [Jenny] made a wood canvas that’s 80 cm (31.5″) in diameter and started laying out the nail hole locations. There wasn’t quite enough room for 300 nails, so instead of starting over, [Jenny] changed the algorithm to use 298 nails and re-ran it.

[Jenny] does a great job of discussing the many variables at play in this hardware representation of software-created art. The most obvious of course is that the more nails used, the higher the resolution would be, but she determined that 300 is the sweet spot — more than that, and the resolution doesn’t really improve. We have to wonder if 360 nails would make things any easier. Check out the build video after the break.

Want to cut out most of the manual labor altogether? Build yourself a string art machine.

Continue reading “An Algorithm For Art: Thread Portraits”

Custom Dummy Load With Data Logging

While it might seem counterintuitive on the surface, there are a number of cases where dumping a large amount of energy into a resistor simply to turn it into heat is necessary to the operation of a circuit. Most of these cases involve testing electronic equipment such as power supplies or radio transmitters and while a simple resistor bank can be used in some situations, this active dummy load is comprised of different internals has some extra features to boot.

The load bank built by [Debraj] is actually an electronic load, which opens it up for a wider set of use cases than a simple passive dummy load like a resistor bank. It’s specifically designed for DC and also includes voltage measurement, current control, and temperature measurement and speed control of the fans on the heat sinks. It also includes a Bluetooth module that allows it to communicate to a computer using python via a custom protocol and GUI.

While this one does use a case and some other parts from another product and was specifically built to use them, the PCB schematics and code are all available to build your own or expand on this design. It’s intended for DC applications, but there are other dummy loads available for things such radio antenna design, and it turns out that you can learn a lot from them too.

Continue reading “Custom Dummy Load With Data Logging”

Tetris On Split-Flap Go Brrr

It hardly seems possible, but engineer collective and split-flap display purveyors [Oat Foundry] were able to build a working implementation of Tetris on a 10 x 40 split-flap display in the span of a single day. Check it out in the video after the break.

This project is a bit understaffed in the details department, but we do know that [Oat Foundry] started with [Timur Bakibayev]’s open-source implementation of Tetris in Python and modified the draw function to work on a split-flap display. As you may have guessed, the biggest obstacle is the refresh rate and how it affects playability — particularly during those tense moments when a player rotates a piece before dropping it. Split-flaps flip quickly from on to off, but flipping back to on requires a full trip around through all the other characters.

We think this is nice work for a one-day build. Should they go further, we’d like to see the same things implemented as [Oat Foundry] does: a high score tracker and a preview of the next piece.

Don’t have a split-flap display? Yeah, us either, but we do have televisions. Turn on the tube and check out this Nano-scale Tetris.

Continue reading “Tetris On Split-Flap Go Brrr”