Creating A Bode Analyzer From A Microcontroller

Electrical engineers will recognize the Bode plot as a plot of the frequency response of a system. It displays the frequency on the x-axis and the phase (in degrees) or magnitude (in dB) on the y-axis, making it helpful for understanding a circuit or transfer function in frequency domain analysis.

[Debraj] was able to use a STM32F407 Discovery board to build a Bode analyzer for electronic circuits. The input to the analyzer is a series of sine wave signals with linearly increasing frequency, or chirps, preferably twenty frequencies/decade to keep the frequency range reasonable.

The signals from a DAC are applied to a target filter and the outputs (frequencies obtained) are read back through an ADC. Some calculations on the result reveal how much of the signal is attenuated and its phase, resulting in a Bode plot. The filtering is done through digital signal processing from a microcontroller.

While the signals initially ran through a physical RC-filter, testing the Bode plotter with different circuits made running the signals through a digital filter easier, since it eliminates the need to solder resistors and capacitors onto protoboards. Plotting is done using Python’s matplotlib, with the magnitude and phase of the output determined analytically.

It’s a cool project that highlights some of the capabilities of microcontrollers as a substitute for a pricier vector network analyzer.

Continue reading “Creating A Bode Analyzer From A Microcontroller”

An Algorithm For De-Biasing AI Systems

A fundamental truth about AI systems is that training the system with biased data creates biased results. This can be especially dangerous when the systems are being used to predict crime or select sentences for criminals, since they can hinge on unrelated traits such as race or gender to make determinations.

A group of researchers from the Massachusetts Institute of Technology (MIT) CSAIL is working on a solution to “de-bias” data by resampling it to be more balanced. The paper published by PhD students [Alexander Amini] and [Ava Soleimany] describes an algorithm that can learn a specific task – such as facial recognition – as well as the structure of the training data, which allows it to identify and minimize any hidden biases.

Testing showed that the algorithm minimized “categorical bias” by over 60% compared against other widely cited facial detection models, all while maintaining the same precision of detection. This figure was maintained when the team evaluated a facial-image dataset from the Algorithmic Justice League, a spin-off group from the MIT Media Lab.

The team says that their algorithm would be particularly relevant for large datasets that can’t easily be vetted by a human, and can potentially rectify algorithms used in security, law enforcement, and other domains beyond facial detection.

A DIY Retrocomputer Programmed In Pure Rust

Can you generate VGA and handle a PS/2 keyboard with a Cortex-M4 in Rust? That’s precisely what [theJPster] wanted to find out with Monotron, a 1980s style home computer programmed in pure Rust.

In order to run embedded Rust without a working operating system, some tools are necessary: an LLVM back-end for generating machine code, a target file for specifying memory sizes and other configs, and a pre-compiled libcore as a substitute for a compiler when running an operating system. Rust takes the place of C running on top of the board support package (BSP) and hardware abstraction layer (HAL), and peripheral access crates (PACs) that specify the hardware and allow the code to be portable across different chips.

The implementation generates a 800 x 600 VGA video signal at 60 Hz, displays text on a 48 character by 36 line display, displays color graphics using color lookup (stored in flash memory), and runs applications that take less than 24 KiB for all data. Monotron also generates 8-bit audio with PWM and sports a synthesizer that uses a three-channel wavetable allowing it to make sounds with square waves, sine waves, sawtooth waves, and create white noise.

So far, the Monotron has been able to work with an Atari joystick, a PS/2 keyboard, and has outputs to VGA, MIDI, SD card, and audio. Next up for the Monotron: writing a programming language (tentatively named Monotronian), adding support for Sega Megadrive pads, displaying sprites, and many more exciting developments.

Continue reading “A DIY Retrocomputer Programmed In Pure Rust”

How A Secret Gaming Scene Emerged In Communist East Germany

During the late 1980s, a gaming scene emerged in East Germany just before the fall of communism. Teenagers gathered in buildings like the “House of Young Talents” (HdjT), originally Palais Podewils, to watch and play Commodore 64 games. There were 20 similar clubs in Berlin alone, sometimes with more than 70 people crowded into a single room. Above all, the computers they were in possession of were all made in the West.

At a point in time when loyalties were frequently questioned, the club of self-proclaimed “freaks” soon attracted the attention of the Stasi, GDR (East Germany) intelligence agents who kept close tabs on the group. As one Stasi agent warned:

Given that there are also members within the interest groups or computer clubs with a verifiably negative attitude toward the socialist state and social order, there is a potential danger that the interest groups or computer clubs will go in a negative direction.

Domestically produced computers – the KC 85 from VEB Mikroelektronik Wilhelm Pieck Mühlhausen and the KC 87 from VEB Robotron – did not have the quality of C128 and C64s from Commodore. Surprisingly, even while microelectronics remained on the list of embargoed products imported to East Germany, C64s managed to make their way into the state. The GDR customs officials didn’t have any problem with Western imported hardware – what they were worried about was the software.

By the end of the 80s, modern data traffic over telephone lines had arrived in East Germany, causing fear that software would soon be disseminated without the need of a physical medium. For the gamers of GDR, however, many didn’t even have access to a phone line. They just wanted to go to computer clubs to swap software. Since computer games from the West were only available in government-run Intershop stores and not in normal shops, teenagers had to rely on the computer clubs to access these games. Games like Frogger and Rambo would be copied to cheaper cassette tapes – it wouldn’t even be violating the saw law since software was not protected by copyright within the country.

A few politically charged games – “Raid Over Moscow” and “Kremlin” – were forbidden to ensure that the HdjT wouldn’t be shut down. Towards the end of the GDR, the Stasi desperately tried to gain control of games “relating to the increasing activities of the political opponent”, but by this point the political situation was already heading towards the fall of the Wall. [Stefan Paubel], founder of the HdjT reflected that he was disappointed the Stasi didn’t try harder to report on the computer clubs.

They had everything critical in the reports: Swapping software, a complete list of all the games glorifying war and computers from the West.

It appeared that microelectronics were sacred to the GDR, since officials were trying to get more young people to engage with computers. The regime’s concern for their reputation led them to prioritize other forms of surveillance than technology. For a while after the fall of the Berlin Wall, the computer club continued to exist. It wasn’t until August 1990, two months before reunification, that the remaining members decided to dissolve the club.

[Thanks to Frank for the tip!]

Finding USB Bugs The Hard Way

Sometimes debugging just doesn’t go the way you want it to. When USB problems arise, you can usually use a protocol analyzer to find the issue causing trouble. For [Paul Stoffregen], it was only the first step in a long process to find the culprit.

Procotol Analyzer

The complaint that came up was from a customer whose 2 port USB hub wasn’t working on their Teensy 3.6. The hub had been tested on Linux, Mac, and Windows, so it made sense to test what was different about the Teensy. Furthermore, all other USB hubs worked on the Teensy. As it turns out, these weren’t the most helpful assumptions to make when finding the bug.

Any protocol analyzer can be used, for instance the Beagle480. The way it works is by passing through USB communication, making a copy of the communication coming in and out, and sending it to the PC.

 

Normally, the analyzer has a small buffer memory and must sustain fast data flow. Unfortunately, this can occasionally cause software lockup. From what could be gathered from the verbose printing, USB descriptors were found for the hub. As it turns out, the faulty hub was a Multi-TT type hub, while most others are single TT (transaction translator).

Fixing Software Lockup

Since it was necessary to get the rest of the descriptor data, fixing the software lockup was the next step. Writing in a panic function – a breakpoint of sorts – into the code allowed the USB host’s power to terminate, and stepping through the program revealed that while the 2 port hub was initially being read, some issue arose afterwards.

As it turns out, the issue relied on USB split transactions, used only between USB hosts and hubs. Communication happens by tokens, which begins with a SPLIT-START token.

 

As it turns out, the issue was that the tokens weren’t being sent in the correct order. The other hubs seemed to be handle this nevertheless. By applying a fix to the C++ code of the bad hub, which had previously not been implementing the data structure for accessing register properly, the hub was able to work again.The hub appeared to be rejecting bad token, which was causing the issue in the first place.

All in all, while I’m sure this had to be a head scratching experience, at least it gives us some insight into the low-level design of USB communication.

Turn Your Old-school CRT Into A YouTube Media Player

Ever wish you could enjoy modern conveniences like YouTube in a retro world of CRTs and late 20th century graphics?

[Johannes Spreitzer] happened to find an old VIENNASTAR CRT (cathode-ray tube television) made by the Austrian brand Kapsh at a flea market. The CRT dates back to 1977 and uses just RF input, making it useless as a modern television set since most TV stations nowadays broadcast primarily in digital.

However, HDMI-to-RF transmitters do exist, making it possible to convert HDMI signals to RF or coaxial cable output to replace an antenna signal. What [Spreitzer] did next was to plug in a Chromcast and essentially convert the CRT into an old-school monitor. You can see some of the trippy graphics in the video below – the video samples shown fit the retro aesthetic, but I’m sure there’s video combinations that would seem pretty out of place.

HDMI-to-RF adapters are pretty easy to pick up at a hardware store, and they allow you to project videos onto specific channels on a CRT. Needless to say, they don’t work the other way around, although since there are still televisions that only pick up RF broadcasts, coaxial to HDMI adapters do exist.

Continue reading “Turn Your Old-school CRT Into A YouTube Media Player”