Linux Fu: Debugging Bash Scripts

A recent post about debugging constructs surprised me. There were quite a few comments about how you didn’t need a debugger, as long as you had printf. For that matter, we’ve all debugged systems where you had nothing but an LED to flash or otherwise turn on to communicate with the user. However, it is hard to deny that a debugger can help with complex code.

To say you only need printf would be like saying you only need machine language. Technically accurate — you can do anything in machine language. But it sure makes things easier to have an assembler or some language to help you work out your problem. If you write a simple bash script, you can use the equivalent to printf — maybe that’s the echo command, although there is usually a printf command on a typical system, if you want to use it. However, there are other things you can do with bash including a pretty cool debugger if you know how to find it.

I assume you already know how to use echo and printf, but let’s dig into how to use trace execution line by line without the need for echo statements on every other line. Along the way, you’ll learn how to get started with the bash debugger.

Continue reading “Linux Fu: Debugging Bash Scripts”

A Tree Of LEDs That Blows Out Like A Candle

The beautiful workmanship in [Andrew]’s LED tree is gorgeous all on its own, but of course there’s more going on than meets the eye. ThisĀ  LED tree can be blown out like a candle and it even playfully challenges a user to blow out all the lights at once in a single breath.

Some of you may remember the fascinating example of an LED you can blow out like a candle which had the trick of using the LED itself as a sensor. Like any diode, the voltage drop across the LED changes very slightly based on temperature. By minimizing thermal mass with surface-mount LEDs and whisker-thin wires, it was possible to detect when the LED was being blown on.

The LED tree shown here uses the same basic principle, but with a few important changes. The electronics have been redesigned and improved, and the Arduino used in the original proof of concept is ditched for stacked custom PCBs. Each board has a diameter under 100 mm in order to take advantage of the fab house’s lower cost for small boards. [Andrew] says that while the boards required a lot of time-consuming hand soldering and assembly, the payoff was that five boards rang in at barely five dollars (plus shipping) and that’s hard to beat.

Watch the tree in action in the brief video embedded below.

Continue reading “A Tree Of LEDs That Blows Out Like A Candle”

The Story Of The Quickening: Mercurial Metal

Of all known metals, mercury is probably one of the most famous, if only for its lustrous, liquid form at room temperature. Over the centuries, it has been commonly used in a wide variety of applications, including industrial chemical processes, in cosmetics, for telescope mirrors, thermometers, fluorescent lamps, dental fillings, bearings, batteries, switches and most recently in atomic clocks.

Though hardly free from the controversy often surrounding a toxic heavy metal, it’s hard to argue the myriad ways in which mercury has played a positive role in humanity’s technological progress and scientific discoveries. This article will focus both on its historical, current, and possible future uses, as well as the darker side of this fascinating metal.

Continue reading “The Story Of The Quickening: Mercurial Metal”

Rescue An Expensive Servo With Some Reverse Engineering

[Andrew] had a servo damaged by someone connecting the power supply to the wrong pins (whoops) which fried the microcontroller and a logic level shifter. With a bit of reverse engineering, he successfully restored basic servo functionality by writing some new code. The new code implements only basic features, but that’s enough to save the device from the junk bin.

FAULHABER 2232DBHHO ring any bells? Google came up empty.

Why bother reverse engineering a servo? Well, if dollars are reasons then there are many for saving a HerkuleX DRS-0602 from the junk heap; they cost around 320 USD before shipping. Another reason to try is that the microcontroller turned out to be an AVR XMega, which gave [Andrew] confidence in writing some new code.

If you want to understand more about how these servos work, [Andrew] provides good photos of the insides and identifies the major components and their connections and functions. There are some mysteries (such as details of the motor and embedded encoder, which are FAULHABER 2232DBHHO) but [Andrew] figured out enough to write some basic code to allow the servo to work as a standard servo with a UART interface.

Sometimes curiosity drives reverse engineering and repair efforts, sometimes it’s cost, and sometimes it’s both. A $320 servo is certainly worth trying to save, and so are huge observatory telescopes with obsolete servo amps.

Cloned Gate Remote Does It (Slightly) Better

Ever make something just to see if you could? Yeah, we thought so. [serverframework] wanted to see if he could clone the remote that opens his neighborhood gate, inspired by the long distance ding-dong-ditch efforts of [Samy Kamkar].

This clone uses an ATtiny85 and an RF module to emulate and send the frequency that the gate is waiting for. To accomplish that, [serverframework] had to figure out both the operating frequency and the timing used by the remote. The crystal inside seemed to indicate 295 MHz, and a quick check of the device’s FCC registration confirmed it. Then he used an SDR dongle to watch the data coming across when he pressed the button, and ran it through Audacity to figure out the timing.

Unfortunately, the 295 MHz crystal is a rare beast, so [serverframework] had to transplant the original to the donor RF module. Then it was just a matter of programming the ATtiny85 to send the frequency with the right timing. It actually does a better job since the original has no timing crystal, and the ‘tiny is clocked with a standard 16 kHz oscillator. The code is available within [serverframework]’s excellent write-up, and you can see a tiny demo after the break.

There’s more than one way to clone a gate remote. This one leverages MQTT to turn friends’ phones into remotes.

Continue reading “Cloned Gate Remote Does It (Slightly) Better”

Globe Lamp Tracks The ISS For You

Assuming you don’t work at a major space agency, you probably don’t really need to know the exact location of the International Space Station at all times. If you’d like to know just because it’s cool, this lamp is for you.

The lamp is driven by a Wemos D1, which pulls in data on the space station’s current location from Open Notify. A stepper motor and servo motor serve to control a pan-tilt assembly, aiming a 405nm laser at the inside of a 3D printed globe to indicate the station’s position above Earth. As a nice touch, there’s also a ring of NeoPixel LEDs that are controlled to glow on the sunny side of the planet, too.

This is a fun project that makes it easy to know when to bust out your ham gear to chat to the team overhead, and would also make a great conversation starter. It’s not the first hardware ISS monitor we’ve seen, either! Video after the break.

Continue reading “Globe Lamp Tracks The ISS For You”

AI Knows If The Pitch Is On Target Before You Do

Pitching a baseball is about accuracy and speed. A swift ball on target is the goal, allowing the pitcher to strike out the batter. [Nick Bild] created an AI system that can determine a ball’s trajectory in mid-flight, based on a camera feed.

The system uses an NVIDIA Jetson AGX Xavier, fitted with a USB camera running at 100FPS. A Nerf tennis ball launcher is used to fire a ball towards the batter. Once triggered, the AI uses the camera to capture two successive images of the ball in flight. These images are fed into a convolutional neural network (CNN), and the software determines whether the ball is heading for the strike zone, or moving off-target. It uses this information to light a green or red LED respectively to alert the batter.

While such a system is unlikely to appear in professional baseball anytime soon, it shows the sheer capability of neural network systems to quickly and effectively analyse data in ways simply impossible for mere humans. [Nick]’s future goals involve running the system on faster hardware, and expanding it to determine effects like spin and more accurate positioning within the strike zone.

We’ve seen CNNs do everything from naming tomatoes to finding parking spaces. Video after the break.

Continue reading “AI Knows If The Pitch Is On Target Before You Do”