Bare-Metal STM32: Using The I2C Bus In Master-Transceiver Mode

As one of the most popular buses today for on- and inter-board communication within systems, there’s a good chance you’ll end up using it with an embedded system. I2C offers a variety of speeds while requiring only two wires (clock and data), which makes it significantly easier to handle than alternatives, such as SPI. Within the STM32 family of MCUs, you will find at least one I2C peripheral on each device.

As a shared, half-duplex medium, I2C uses a rather straightforward call-and-response design, where one device controls the clock, and other devices simply wait and listen until their fixed address is sent on the I2C bus. While configuring an STM32 I2C peripheral entails a few steps, it is quite painless to use afterwards, as we will see in this article. Continue reading “Bare-Metal STM32: Using The I2C Bus In Master-Transceiver Mode”

Data Alignment Across Architectures: The Good, The Bad And The Ugly

Even though a computer’s memory map looks pretty smooth and very much byte-addressable at first glance, the same memory on a hardware level is a lot more bumpy. An essential term a developer may come across in this context is data alignment, which refers to how the hardware accesses the system’s random access memory (RAM). This and others are properties of the RAM and memory bus implementation of the system, with a variety of implications for software developers.

For a 32-bit memory bus, the optimal access type for some data would be a four bytes, aligned exactly on a four-byte border within memory. What happens when unaligned access is attempted – such as reading said four-byte value aligned halfway into a word – is implementation defined. Some hardware platforms have hardware support for unaligned access, others throw an exception that the operating system (OS) can catch and fallback to an unaligned routine in software. Other platforms will generally throw a bus error (SIGBUS in POSIX) if you attempt unaligned access.

Yet even if unaligned memory access is allowed, what is the true performance impact? Continue reading “Data Alignment Across Architectures: The Good, The Bad And The Ugly”

Training Doppler Radar With Smart Watch IMUs Data For Activity Recognition

When it comes to interpreting sensor data automatically, it helps to have a large data set to assist in validating it, as well as training when it concerns machine learning (ML). Creating this data set with carefully tagged and categorized information is a long and tedious process, which is where the idea of cross-domain translations come into play, as in the case of using millimeter wave (mmWave) radar sensors to recognize activity of e.g. building occupants with the IMU2Doppler project at Smash Lab of Carnegie Mellon University.

The most commonly used sensor type when it comes to classifying especially human motion are inertial measurement units (IMU) such as accelerometers and gyroscopes, which are found in everything from smartphones to smart watches and fitness bands. For these devices it’s common to classify measurement patterns as matches a particular activity, such as walking, jogging, or brushing one’s teeth. This makes them both well-defined and very accessible.

As for why a mmWave-based Doppler radar would be preferred for monitoring e.g. building occupants is the privacy aspect compared to using cameras, and the inconvenience of equipping people with a body-worn IMU. Using Doppler radar it would theoretically be possible for people to track activities within their own home, as well as in a medical setting to ensure patients are safe, or at a gym to track one’s performance, or usage of equipment. All without the use of cameras or personal sensors. In the past, we’ve seen a similar approach that used targeted laser beams.

As promising as this sounds, at this point in time the number of activities that are recognized with reasonable accuracy (~70%) is limited to ten types. Depending on the intended application this may already be sufficient, though as the published paper notes, there is still a lot of room for growth.

Continue reading “Training Doppler Radar With Smart Watch IMUs Data For Activity Recognition”

Testing 7 Wago-like Wire Connectors For Science And Fire

At the intersection of saving a few bucks and expensive home insurance claims due to a house fire, we find clones of certified and tested electrical connectors, even when many would argue that so-called wire nuts are fire hazards no matter how many certification labels are on them. When it comes to no-fuss wire connectors, Wago clamp connectors are an attractive target to save some money on due to their perceived high cost. But how expensive are they really?

This was the thought behind a recent video by [GreatScott!] (also embedded after the break) when he hopped onto everyone’s favorite e-commerce website and searched for ‘clamp lever terminal’. The resulting selection of seven connectors come in a wide variety of shapes, colors and configurations, though all are supposedly rated for mains (250 VAC) voltage and safe enough to put into a permanent installation.

While running the connectors through their paces with high-current, fire and mechanical strength tests, the conclusion was that all are good enough for hobbyists use and some brief connections while testing, but that only the ones with independent certification marks (like VDE) filled him with enough confidence to consider using in house wiring. One of these being the connectors by the German brand ViD, which would seem to be a slightly cheaper alternative to the Wago connectors, with similar guarantees of safety.

At the end of the day it is the certification that matters, after all, since long-term reliability is of primary concern with house wiring, not whether a few Euros were saved on material costs.

Continue reading “Testing 7 Wago-like Wire Connectors For Science And Fire”

Noor III Solar Tower of the Ouarzazate Power Station, at dusk. (Credit: Marc Lacoste)

The Future Of Energy Storage On Both Sides Of The Meter

That energy storage is a hot topic is hardly a surprise to anyone these days. Even so, energy storage can take a lot of different forms, some of which are more relevant to the utility provider (like grid-level storage), while others are relevant to business and home owners (e.g. whole-house storage), and yet other technologies live in this tense zone between utility and personal interest, such as (electric) vehicle-to-grid.

For utilities a lot of noise is being made about shiny new technologies, such as hydrogen-based storage, while home- and business owners are pondering on the benefits of relying solely on the utility’s generosity with feed-in tariffs, versus charging a big battery from the solar panels on the roof and using the produced power themselves. Ultimately the questions here are which technologies will indeed live up to their promises, and which a home owner may want to invest in.

Continue reading “The Future Of Energy Storage On Both Sides Of The Meter”

Bath County Pumped Storage Station (Credit: CHA)

Grid-Level Energy Storage And The Challenge Of Storing Energy Efficiently

Although every electrical grid begins with the production of electricity, there are times when storing this power in some form instead of using it immediately is highly convenient. Today’s battery-powered gadgets are an obvious example of such time-shifting, but energy storage plays a major role on the grid itself, too, whether in electrochemical, mechanical or in some other form.

Utility-level energy storage is essential for not only stabilizing the grid, but also to time-shift excess energy and provide a way to deal with sudden spikes in demand (peak-shaving) plus demand drops by absorbing the excess energy. The health of the grid can essentially be regarded as a function of its alternating current (AC) frequency, with strong deviations potentially leading to a collapse of the grid.

Naturally, such energy storage is not free, and the benefits of adding it to the grid have to be considered against the expense, as well as potential alternatives. With the rapid increase of highly volatile electrical generators on the grid in the form of non-dispatchable variable renewable energy, e.g. wind turbines and PV solar, there has been a push to store more excess power rather than curtailing it, in addition to using energy storage for general grid health.

Continue reading “Grid-Level Energy Storage And The Challenge Of Storing Energy Efficiently”

A Power Button For Raspberry Pi, Courtesy Of Device Tree Overlays

As a standard feature of the Linux kernel, device tree overlays (DTOs) allow for easy enabling and configuration of features and drivers, such as those contained within the standard firmware of a Raspberry Pi system. Using these DTOs it’s trivial to set up features like as a soft power-off button, triggering an external power supply and enable drivers for everything from an external real-time clock (RTC) to various displays, sensors and audio devices, all without modifying the operating system or using custom scripts.

It’s also possible to add your own DTOs to create a custom overlay that combines multiple DTO commands into a single one, or create a custom device tree binary (DTB) for the target hardware. Essentially this DTB is loaded by the Linux kernel on boot to let it know which devices are connected and their configuration settings, very similar to what the BIOS component with x86-based architectures handles automatically.

Ultimately, the DTB concept and the use of overlays allow for easy configuration of such optional devices and GPIO pin settings, especially when made configurable through a simple text file as on the Raspberry Pi SBC platform.

Continue reading “A Power Button For Raspberry Pi, Courtesy Of Device Tree Overlays”