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”

Lightweight OS For Any Platform

Linux has come a long way from its roots, where users had to compile the kernel and all of the other source code from scratch, often without any internet connection at all to help with documentation. It was the wild west of Linux, and while we can all rely on an easy-to-install Ubuntu distribution if we need it, there are still distributions out there that require some discovery of those old roots. Meet SkiffOS, a lightweight Linux distribution which compiles on almost any hardware but also opens up a whole world of opportunity in containerization.

The operating system is intended to be able to compile itself on any Linux-compatible board (with some input) and yet still be lightweight. It can run on Raspberry Pis, Nvidia Jetsons, and x86 machines to name a few, and focuses on hosting containerized applications independent of the hardware it is installed on. One of the goals of this OS is to separate the hardware support from the applications, while being able to support real-time tasks such as applications in robotics. It also makes upgrading the base OS easy without disrupting the programs running in the containers, and of course has all of the other benefits of containerization as well.

It does seem like containerization is the way of the future, and while it has obviously been put to great use in web hosting and other network applications, it’s interesting to see it expand into a real-time arena. Presumably an approach like this would have many other applications as well since it isn’t hardware-specific, and we’re excited to see the future developments as people adopt this type of operating system for their specific needs.

Thanks to [Christian] for the tip!

Free RTOS

Getting Started With FreeRTOS And ChibiOS

If operating systems weren’t so useful, we would not be running them on every single of our desktop systems. In the same vein, embedded operating systems provide similar functionality as these desktop OSes, while targeting a more specialized market. Some of these are adapted versions of desktop OSes (e.g. Yocto Linux), whereas others are built up from the ground up for embedded applications, like VxWorks and QNX. Few of those OSes can run on a microcontroller (MCU), however. When you need to run an OS on something like an 8-bit AVR or 32-bit Cortex-M MCU, you need something smaller.

Something like ChibiOS (‘Chibi’ meaning ‘small’ in Japanese), or FreeRTOS (here no points for originality). Perhaps more accurately, FreeRTOS could be summarized as a multi-threading framework targeting low-powered systems, whereas ChibiOS is more of a full-featured OS, including a hardware abstraction layer (HAL) and other niceties.

In this article we’ll take a more in-depth look at these two OSes, to see what benefits they bring. Continue reading “Getting Started With FreeRTOS And ChibiOS”

An Anti-Tamper Mesh Plugin For KiCad

Physical access to electronics generally means all bets are off when it comes to information security. But in special cases this is just unacceptable and a better solution must be found. Consider the encryption keys used by point of sale machines. To protect them, the devices incorporate anti-tamper mechanisms that will wipe the keys from memory if the device is opened. One such technique is to use a mesh of traces on a circuit board that are monitored for any changes in resistance or capacitance. [Sebastian Götte] has been researching in this area and wrote a KiCad plugin to automatically generate tamper-detection mesh.

The idea is pretty simple, place traces very close to one another and it makes it impossible to drill into the case of a device without upsetting the apple cart. There are other uses as well, such as embedding them in adhesives that destroy the traces when pried apart. For [Sebastian’s] experiments he’s sticking with PCBs because of the ease of manufacture. His plugin lays down a footprint that has four pads to begin and end two loops in the mesh. The plugin looks for an outline to fence in the area, then uses a space filling curve to generate the path. This proof of concept works, but it sounds like there are some quirks that can crash KiCad. Consider taking a look at the code if you have the expertise to help make it more stable.

We’ve seen these anti-tamper meshes in practice in the VeriFone payment terminal that [Tom Nardi] tore down a couple of years ago. The approach that [Sabastian] took with the plugin actually produces a more complex mesh than was in use there as it only really used vertical lines for the traces.

Ask Hackaday: What’s Your Favourite Build Tool? Can Make Ever Be Usurped?

What do you do whilst your code’s compiling? Pull up Hackaday? Check Elon Musk’s net worth? Research the price of a faster PC? Or do you wonder what’s taking so long, and decide to switch out your build system?

Clamber aboard for some musings on Makefiles, monopolies, and the magic of Ninja. I want to hear what you use to build your software. Should we still be using make in 2021? Jump into the fray in the comments.

Continue reading “Ask Hackaday: What’s Your Favourite Build Tool? Can Make Ever Be Usurped?”

3D Printing 90° Overhangs With Non-Planar Slicing

When slicing a model for 3D printing, the part is divided into a stack of flat, 2D layers. But there’s an alternative in the form of non-planar slicing, where the layers can follow 3D curves. [Rene K. Mueller] took this a step further and successfully used non-planar slicing to print 90° overhangs on a normal Cartesian FDM printer.

Non-planar layers have been around for a while, but were generally limited to creating smooth curves without layer lines. The idea of using the technique for overhangs had been floating around in [Rene]’s head for a while, and he was spurred to action after seeing the rotating tilted nozzle printer featured here on Hackaday. The idea is only to have the outer edge of each layer overhang, by making each layer slope downward toward the overhang. [Rene] programmed a conic slicer algorithm for this purpose, which splits the model into dome-shaped layers, like an onion.

He did a lot of testing and documented the results in detail. Conical slices were compared with tilted slices, which are also used for belt 3D printers. Both have some geometric limitations. Tilted slices can only print the overhang in one direction, but conical slices can do this in all directions, allowing it to create a mushroom-like shape without any support. The limitation is that it can only print inward or outward from a central point. More complex geometry must be segmented, and each sub-volume sliced separately. The slicing angle is also limited by the shape of the print head, to avoid it crashing into the print.

We think this technique has a lot of potential for widespread use, especially since it is compatible with most existing FDM printers. It is still a work in progress, but support has already been added for Slic3r and Prusa Slicer. We look forward to seeing how it develops and gets adopted.

Open Source CAM Software In The Browser

3D printers, desktop CNC mills/routers, and laser cutters have made a massive difference in the level of projects the average hacker can tackle. Of course, these machines would never have seen this level of adoption if you had to manually write G-code, so CAM software had a big part to play. Recently we found out about an open-source browser-based CAM pack created by [Stewert Allen] named Kiri:Moto, which can generate G-code for all your desktop CNC platforms.

To get it out of the way, Kiri:Moto does not run in the cloud. Everything happens client-side, in your browser. There are performance trade-offs with this approach, but it does have the inherent advantages of being cross-platform and not requiring any installation. You can click the link above and start generating tool paths within seconds, which is great for trying it out. In the machine setup section you can choose CNC mill, laser cutter, FDM printer, or SLA printer. The features for CNC should be perfect for 90% of your desktop CNC needs. The interface is intuitive, even if you don’t have any previous CAM experience. See the video after the break for a complete breakdown of the features, complete with timestamp for the different sections.

All the required features for laser cutting are present, and it supports a drag knife. If you want to build an assembly from layers of laser-cut parts, Kiri:Moto can automatically slice the 3D model and nest the 2D parts on the platform. The slicer for 3D printing is functional, but probably won’t be replacing our regular slicer soon. It places heavy emphasis on manually adding supports, and belt printers like the Ender CR30 are already supported.

Kiri:Moto is being actively improved, and it looks as though [Stewart] is very responsive to community inputs. The complete source code is available on GitHub, and you can run an instance on your local machine if you prefer to do so. Continue reading “Open Source CAM Software In The Browser”