Linux Fu: Preprocessing Beyond Code

If you glanced at the title and thought, “I don’t care — I don’t write C code,” then hang on a minute. While it is true that C has a preprocessor and you can notoriously do strange and — depending on your point of view — horrible or wonderful things with it, there are actually other options and you don’t have to use any of them with a C program. You can actually use the C preprocessor with almost any kind of text file. And it’s not the only preprocessor you can abuse this way. For example, the m4 preprocessor is wildly complex, vastly underused, and can handle C source code or anything else you care to send to it.

Definitions

I’ll define a preprocessor as a program that transforms its input file into an output file, reacting to commands that are probably embedded in the file itself. Most often, that output is then sent to some other program to do the “real” work. That covers cpp, the C preprocessor. It also covers things like sed. Honestly, you can easily create custom preprocessors using C, awk, Python, Perl, or any other programming language. There are many other standard programs that you could think of as preprocessors, for example, tr. However, one of the most powerful is made to preprocess complex input files called m4. For some reason — maybe because of its complexity — you don’t see much m4 in the wild.

Continue reading “Linux Fu: Preprocessing Beyond Code”

Modern Control Of A Logic Analyzer

When you think of a logic analyzer today, you might think of a little USB probe that can measure a few signals and decoding for various serial buses. But actual logic analyzers were high-speed multichannel hardware with sophisticated ways to clock and trigger. [Tom] picked up an HP1670G on the surplus market and was impressed that it could sample 136 channels at 500 MHz. The circa-2000 machine has a front panel, but if you really wanted to use it, you wanted to use an X terminal. [Tom] shows us how that works with modern Linux software.

Continue reading “Modern Control Of A Logic Analyzer”

Beyond The Basics: Exploring More Exotic Scope Trigger Modes

Last time, we looked at some powerful trigger modes found on many modern scopes, including the Rigol DHO900 series we used as an example. Those triggers were mostly digital or, at least, threshold-based. This time, we’ll look at some more advanced analog triggers as well as a powerful digital trigger that can catch setup and hold violations. You can find the Raspberry Pi code to create the test waveforms online.

In addition to software, you’ll need to add some simple components to generate the analog waveform. In particular, pin 21 of the Pi connects to  2uF capacitor through a 10K resistor. The other side of the capacitor connects to ground. In addition, pin 22 connects directly to the capacitor, bypassing the 10K resistor. This allows us to discharge the capacitor quickly. The exact values are not especially important.

Runt Triggers

A runt pulse is one that doesn’t have the same voltage magnitude as surrounding pulses. Sometimes, this is due to a bus contention, for example. Imagine if you have some square waves that go from 0 to 5V. But, every so often, one pulse doesn’t make it to 5V. Instead, it stops at 3V.

Continue reading “Beyond The Basics: Exploring More Exotic Scope Trigger Modes”

Temperature Measurement By Wire

There’s an old joke about how to tell how tall a building is using a barometer. The funniest answer is to find the building owner and offer them a nice barometer in exchange for the information. We wonder if [DiodeGoneWild] has heard that one since his recent video details how to measure temperatures using an ohmmeter.

The idea is that wire changes its resistance based on temperature. So if you know the resistance of a lot of wire — maybe a coil — at room temperature and you can measure the resistance at temperature, it is entirely feasible to calculate the amount of temperature that would cause this rise in resistance.

Of course, there are many ways to measure resistance, too. It’s probably possible to measure parameters like operating current and estimate temperature for at least some circuits. The wire’s material also plays a part, and the online calculator lets you choose copper, aluminum, iron, or tungsten. You also need a lot of wire, a very accurate resistance measurement, or, preferably, both.

There are many ways to accurately measure resistance, of course. Then again, you can also get resistors specifically for the job.

Continue reading “Temperature Measurement By Wire”

A RISC-V Security Key

The TKey is a RISC-V-based security key that plugs into a USB port. The device has a number of features, including a device-specific serial number, RAM scrambling, and a monitor that kills the CPU in the event of access to protected memory. There is also an FPGA that, on the end-user version, is locked down. This prevents you from changing the core features and the unique ID number for the device.

As part of the start-up code, the device calculates a hash of the application and merges it with the device ID and, potentially, a user-defined secret. If this number matches a previous calculation, it is reasonably certain that nothing has changed between the times of the calculations.

Continue reading “A RISC-V Security Key”

Restoring The DC Bias

If you have a signal that passes through a capacitor or transformer, you will lose the DC portion of the signal. What do you do? If you need it, you can restore the DC bias using various techniques, as [Sam Ben-Yaakov] shows in a recent video.

These types of circuits were common in analog TVs, and, in fact, [Sam] shows the schematic of a TV to explain the need for the DC level. In that case, a vacuum tube diode does the work, but a solid state one will do the same job.

Continue reading “Restoring The DC Bias”

Open Source Scanner Scans The Slides

What do you get when you join a slide projector and a digital camera? Filmolimo, an open source slide scanner. The scanner uses an M5Stack Fire, an ESP32 development board. Thanks to the ESP32, you can control the device via WiFi.

All the project files, including KiCAD design files, are on GitHub. Of course, you will probably have to adapt things to your specific camera and slide projector. The PCB is double-sided and looks easy to put together. The board is mostly opto-isolation and interface between the controller and the equipment. The software allows you to change things like the time between slides, for example.

This is one of those projects you probably only need for a bit. Unless, of course, you regularly scan slides. You can farm it out to a service provider, but what fun is that? If you have a few hundred thousand slides, you might need to go for speed. If you just have a few, you can get by with a simple adapter.