Bare-Metal STM32: Please Mind The Interrupt Event

Interruptions aren’t just a staple of our daily lives. They’re also crucial for making computer systems work as well as they do, as they allow for a system to immediately respond to an event. While on desktop computers these interrupts are less prominent than back when we still had to manually set the IRQ for a new piece of hardware using toggle switches on an ISA card, IRQs along with DMA (direct memory access) transfers are still what makes a system appear zippy to a user if used properly.

On microcontroller systems like the STM32, interrupts are even more important, as this is what allows an MCU to respond in hard real-time to an (external) event. Especially in something like an industrial process or in a modern car, there are many events that simply cannot be processed whenever the processor gets around to polling a register. Beyond this, interrupts along with interrupt handlers provide for a convenient way to respond to both external and internal events.

In this article we will take a look at what it takes to set up interrupt handlers on GPIO inputs, using a practical example involving a rotary incremental encoder.

Continue reading “Bare-Metal STM32: Please Mind The Interrupt Event”

How Fast Is The Universe Expanding? The Riddle Of Two Values For The Hubble Constant

In the last decades, our understanding of the Universe has made tremendous progress. Not long ago, “precision astronomy” was thought to be an oxymoron. Nowadays, satellite experiments and powerful telescopes on earth were able to measure the properties of our Universe with astonishing precision. For example, we know the age of the Universe with an uncertainty of merely 0.3%, and even though we still do not know the origin of Dark Matter or Dark Energy we have determined their abundance with a precision of better than 1%.

There is, however, one value that astronomers have difficulty in pinning down: how fast our universe is expanding. Or, more precisely, astronomers have used multiple methods of estimating the Hubble constant, and the different methods are converging quite tightly on two different values! This clearly can’t be true, but nobody has yet figured out how to reconcile the results, and further observations have only improved the precision, deepening the conflict. It’s likely that we’ll need either new astronomy or new physics to solve this puzzle.

The Discovery of the Expanding Universe

In the 1920s Edwin Hubble used the newly built telescope at Mount Wilson Observatory to study fuzzy objects known as nebulae. Back then, astronomers were arguing whether these nebulae are clouds of stars within our Milky Way or if they are whole different galaxies. Hubble discovered stars within these nebulae whose brightness slowly fades in and out. These were known as Cepheids and previously studied by Henrietta Levitt who showed that there was a tight relationship between the star’s intrinsic brightness and the period of its variation. This means Cepheids could be used as so-called standard candles which refers to objects whose absolute brightness is known. Since there is a simple relationship between how the brightness of an object decreases with distance, Hubble was able to calculate the distance of the Cepheids by comparing their apparent and intrinsic brightness. He showed that the Cepheid stars were not located within our galaxy and that nebulae are actually distant galaxies.

Hubble also measured the velocity at which these distant galaxies are moving away from us by observing the redshifts of spectral lines caused by the Doppler effect. He found that the further away the galaxy is located, the faster it is moving away from us described by a simple linear relationship.

\bf v = H_0 d

The parameter H0 is what is known as the Hubble constant. Later the Belgian priest and physicist Georges Lemaître realized that the velocity-distance relationship measured by Hubble was evidence for the expansion of the Universe. Since the expansion of space itself causes other galaxies to move away from us we are not in any privileged location but the same effect would be measured from any other place in the Universe. An effect that is sometimes illustrated by drawing points on a balloon, when it is inflated the points move away from each other at a speed that depends on their distance. It is also better not to think of the cosmological redshift as being caused by a real velocity as the parameter v in the above equation can easily exceed the speed of light. Continue reading “How Fast Is The Universe Expanding? The Riddle Of Two Values For The Hubble Constant”

How The LIGO Observatory Detects Gravitational Waves

Gravity is one of the more obvious forces in the universe, generally regarded as easily noticeable by the way apples fall from trees. However, the underlying mechanisms behind gravity are inordinately complex, and the subject of much study to this day.

A major component of this study is around the concept of gravitational waves. First posited by Henri Poincaré in 1905, and later a major component of Einstein’s general theory of relativity, they’re a phenomena hunted for by generations of physicists ever since. For the team at the Laser Interferometer Gravitational-wave Observatory, or LIGO, finding direct evidence of gravitational waves is all in a day’s work.

Continue reading “How The LIGO Observatory Detects Gravitational Waves”

Hey Google, Is My Heart Still Beating?

University of Washington researchers studying the potential medical use of smart speakers such as Amazon’s Echo and Google’s Nest have recently released a paper detailing their experiments with non-contact acoustic heartbeat detection. Thanks to their sensitive microphone arrays, normally used to help localize voice commands from the user, the team proposes these affordable and increasingly popular smart home gadgets could lead a double life as unobtrusive life sign monitors. The paper goes so far as to say that even with multiple people in the room, their technique can be used to monitor the heart and respiratory rate of a specific target individual.

Those are some bold claims, but they aren’t without precedent. Previous studies performed at UW in 2019 demonstrated how smart speaker technology could be used to detect cardiac arrest and monitor infant breathing. This latest paper could be seen as the culmination of those earlier experiments: a single piece of software that could not just monitor the vitals of nearby patients, but actually detect a medical emergency. The lifesaving potential of such a program, especially for the very young and elderly, would be incredible.

So when will you be able to install a heart monitor skill on the cheap Echo Dot you picked up on Prime Day? Well, as is often the case with this kind of research, putting the technique to work in the real-world isn’t nearly as easy as in the laboratory. While the concept is promising and is more than worthy of further research, it may be some time before our lowly smart speakers are capable of Star Trek style life-sign detection.

Continue reading “Hey Google, Is My Heart Still Beating?”

How Laser Headlights Work

When we think about the onward march of automotive technology, headlights aren’t usually the first thing that come to mind. Engines, fuel efficiency, and the switch to electric power are all more front of mind. However, that doesn’t mean there aren’t thousands of engineers around the world working to improve the state of the art in automotive lighting day in, day out.

Sealed beam headlights gave way to more modern designs once regulations loosened up, while bulbs moved from simple halogens to xenon HIDs and, more recently, LEDs. Now, a new technology is on the scene, with lasers!

Continue reading “How Laser Headlights Work”

New Part Day: Onion Tau LiDAR Camera

The Onion Tau LiDAR Camera is a small, time-of-flight (ToF) based depth-sensing camera that looks and works a little like a USB webcam, but with  a really big difference: frames from the Tau include 160 x 60 “pixels” of depth information as well as greyscale. This data is easily accessed via a Python API, and example scripts make it easy to get up and running quickly. The goal is to be an affordable and easy to use option for projects that could benefit from depth sensing.

When the Tau was announced on Crowd Supply, I immediately placed a pre-order for about $180. Since then, the folks at Onion were kind enough to send me a pre-production unit, and I’ve been playing around with the device to get an idea of how it acts, and to build an idea of what kind of projects it would be a good fit for. Here is what I’ve learned so far.

Continue reading “New Part Day: Onion Tau LiDAR Camera”

Science Officer…Scan For Elephants!

If you watch many espionage or terrorism movies set in the present day, there’s usually a scene where some government employee enhances a satellite image to show a clear picture of the main villain’s face. Do modern spy satellites have that kind of resolution? We don’t know, and if we did we couldn’t tell you anyway. But we do know that even with unclassified resolution, scientists are using satellite imagery and machine learning to count things like elephant populations.

When you think about it, it is a hard problem to count wildlife populations in their habitat. First, if you go in person you disturb the target animals. Even a drone is probably going to upset timid wildlife. Then there is the problem with trying to cover a large area and figuring out if the elephant you see today is the same one as one you saw yesterday. If you guess wrong you will either undercount or overcount.

The Oxford scientists counting elephants used the Worldview-3 satellite. It collects up to 680,000 square kilometers every day. You aren’t disturbing any of the observed creatures, and since each shot covers a huge swath of territory, your problem of double counting all but vanishes.

Continue reading “Science Officer…Scan For Elephants!”