Linux, Now In Real Time

Although Linux runs almost every supercomputer, most of the web, the majority of smart phones, and a few writers’ ancient Macbooks, there’s one major weak point in the Linux world that will almost always have developers reaching for a different operating system. Linux is not a real-time operating system (RTOS), meaning that it can’t respond to requests in the real world within a set timeframe. This means that applications needing computer control in industry, medicine, robotics, and other real-world situations generally need a purpose-built RTOS. At least, that was true until recently when an update to the Linux kernel added real-time capabilities.

The feature, called PREEMPT_RT, forces the Linux kernel to respond to certain request within a set limit of time. This means that a system with this support built into the kernel can “preempt” any current task, stopping everything else a computer is doing in order to execute that task right away. There are some existing solutions to getting a functional equivalent system working with Linux now, but they can be clunky or inelegant, requiring the user to install patches or other software to get it to work. With the support built directly into the kernel this will become much less of a pain point for anyone who needs this functionality going forward.

This feature has been in the works for around two decades now, so with this entering general use now we would expect to start seeing it show up in various projects as well as in commercial offerings soon, especially since other RTOS solutions can be pricey. Don’t recompile the kernel in your desktop for this feature just yet, though; real-time function can cause some unintended consequences with normal use you’ll need to account for. There’s some more discussion on this in the /r/Linux subreddit and there are some other real-time operating systems available for computers not typically capable of running Linux to take a look at as well.

Tiny Microcontroller Uses Real-Time Operating System

Most of the computers we interact with on a day-to-day basis use an operating system designed for flexibility. While these are great tools for getting work done or scrolling your favorite sites, they have a weakness when it comes to interacting quickly with a real-world environment. For these kinds of low-latency, high-reliability systems you may want to turn to something like freeRTOS which is optimized for this kind of application and which [Parikshit Pagare] has used to build his home automation system.

This build is based around an ESP32 for which freeRTOS, designed specifically for embedded systems, is uniquely suited. There are several channels built in capable of monitoring temperature, functioning as a smoke alarm, and sensing whether someone is at the front door. All of these are reported to a small OLED screen but are also updated on an Android app as well, which happens nearly instantaneously thanks to the real-time operating system. There are a number of user-controllable switches as well that are capable of turning lights or fans on and off.

For a home automation system, it’s one of the most low-cost and fully-featured we’ve seen and if you’re still having trouble coming across a Raspberry Pi as they sort out supply issues, something like this might make an excellent substitute at a fraction of the price. If you’re looking to expand even beyond this build, one of the gold standards for ESP32-based automation design is this build from [Marcus] which not only demonstrates how to build a system like this but goes into great detail on the ESPHome environment.

Continue reading “Tiny Microcontroller Uses Real-Time Operating System”

Write Once, Run Everywhere: Cross-Platform Programming Done Right

One of the goals of programming languages back in the 1950s was to create a way to write assembly language concepts in an abstract, high-level manner. This would allow the same code to be used across the wildly different system architectures of that era and subsequent decades, requiring only a translator unit (compiler) that would transform the source code into the machine instructions for the target architecture.

Other languages, like BASIC, would use a runtime that provided an even more abstract view of the underlying hardware, yet at the cost of a lot of performance. Although the era of 8-bit home computers is long behind us, the topic of cross-platform development is still highly relevant today, whether one talks about desktop, embedded or server development. Or all of them at the same time.

Let’s take a look at the cross-platform landscape today, shall we?

Continue reading “Write Once, Run Everywhere: Cross-Platform Programming Done Right”

Hackaday Links Column Banner

Hackaday Links: April 12, 2015

Everyone loves Top Gear, or as it’s more commonly known, The Short, The Slow, And The Ugly. Yeah, terrible shame [Clarkson] the BBC ruined it for the rest of us. Good News! A show featuring the Dacia Sandero drones will be filling the Top Gear timeslot. And on that bombshell…

More Arduino Drama! A few weeks ago, Arduino SRL (the new one) forked the Arduino IDE from Arduino LLC’s repo. The changes? The version number went up from 1.6.3 to 1.7. It’s been forked again, this time by [Mastro Gippo]. The changes? The version number went up to 2.0. We’re going to hold off until 2.1; major releases always have some bugs that take a few weeks to patch. Luckily the speed of the development cycle here means that patch should be out soon.

Need an ESP8266 connected to an Arduino. Arachnio has your back. Basically, it’s an Arduino Micro with an ESP8266 WiFi module. It also includes a Real Time Clock, a crypto module, and a solar battery charger. It’s available on Kickstarter, and we could think of a few sensor base station builds this would be useful for.

[Ben Heck] gave The Hacakday Prize a shoutout in this week’s episode. He says one of his life goals is to go to space. We’re giving that away to the project that makes the biggest difference for the world. We’re not sure how a [Bill Paxton] pinball machine fits into that category, but we also have a Best Product category for an opportunity to spend some time in a hackerspace… kind of like [Ben]’s 9 to 5 gig…

[Jim Tremblay] wrote a real time operating system for a bunch of different microcontrollers. There are a lot of examples for everything from an Arduino Mega to STM32 Discovery boards. Thanks [Alain] for the tip.

45s – the grammophone records that play at 45 RPM – are seven inches in diameter. Here’s one that’s 1.5 inches in diameter. Does it work? No one knows, because the creator can’t find a turntable to play it on.

Are we betting on the number of people who don’t get the joke in the second paragraph of this post? Decide in the comments.