EmbeddedRelated.com
Memfault Beyond the Launch

Simple C++ State Machine Engine

Massimiliano Pagani March 14, 2024

When implementing state machines in your project it is an advantage to rely on a tried and tested state machine engine. This component is reused for every kind of application and helps the developer focus on the domain part of the software. In this article, the design process that turns a custom C++ code into a finite-state machine engine is fully described with motivations and tradeoffs for each iteration.


Getting Started with the Microchip PIC® Microcontroller

Luther Stanton March 11, 2024

This first post of a five part series looks at the available hardware options for getting started with Microchip 8-bit PIC® Microcontroller, explores the MPLAB® X Integrated Development Environment and walks through setting up a project to expose the configured clock to an external pin and implement a single output GPIO to light an LED.


Unraveling the Enigma: Object Detection in the World of Pixels

Charu Pande February 8, 2024

Exploring the realm of embedded systems co-design for object recognition, this blog navigates the convergence of hardware and software in revolutionizing industries. Delving into real-time image analysis and environmental sensing, the discussion highlights advanced object detection and image segmentation techniques. With insights into Convolutional Neural Networks (CNNs) decoding pixel data and autonomously extracting features, the blog emphasizes their pivotal role in modern computer vision. Practical examples, including digit classification using TensorFlow and Keras on the MNIST dataset, underscore the power of CNNs. Through industry insights and visualization aids, the blog unveils a tapestry of innovation, charting a course towards seamless interaction between intelligent embedded systems and the world.


There's a State in This Machine!

Massimiliano Pagani February 5, 20243 comments

An introduction to state machines and their implementation. Working from an intuitive definition of the state machine concept, we will start with a straightforward implementation then we evolve it into a more robust and engineered solution.


How Embedded Linux is used in Spacecrafts !

George Emad February 1, 20246 comments

This article dives into the application of Linux in spacecraft, examining the challenges it poses and proposing potential solutions. Real-life examples will be discussed, while also addressing the drawbacks of employing Linux in safety-critical missions.


++i and i++ : what’s the difference?

Colin Walls January 25, 20242 comments

Although the ++ and -- operators are well known, there are facets of their operation and implementation that are less familiar to many developers.


Remember Y2K?

Colin Walls December 21, 20231 comment

There was fear that the turn of the century at the end of 1999 would cause problems with many embedded systems. There is evidence that the same issue may occur in 2038.


More than just a pretty face - a good UI is essential

Colin Walls November 30, 20231 comment

A user interface can make or break a device - determining its success in the marketplace. With careful design, the UI can make the product compelling and result in a high level of satisfaction from new and experienced users.


Lightweight C++ Error-Codes Handling

Massimiliano Pagani November 16, 20232 comments

The traditional C++ approach to error handling tends to distinguish the happy path from the unhappy path. This makes handling errors hard (or at least boring) to write and hard to read. In this post, I present a technique based on chaining operations that merges the happy and the unhappy paths. Thanks to C++ template and inlining the proposed technique is lightweight and can be used proficiently for embedded software.


Embedded Systems Roadmaps

Nathan Jones November 9, 2023

What skills should every embedded systems engineer have? What should you study next to improve yourself as an embedded systems engineer? In this article I'll share with you a few lists from well-respected sources that seek to answer these questions, with the hope of helping provide you a path to mastery. Whether you've only just finished your first Arduino project or you've been building embedded systems for decades, I believe there's something in here for everyone to help improve themselves as embedded systems engineers.


Analyzing the Linker Map file with a little help from the ELF and the DWARF

Govind Mukundan December 27, 201522 comments

When you're writing firmware, there always comes a time when you need to check the resources consumed by your efforts - perhaps because you're running out of RAM or Flash or you want to optimize something. The map file generated by your linker is a useful tool to aid in the resource analysis. I wanted to filter and sort the data generated in an interactive way so I wrote a C# WinForms application that reads the data from the map and presents it in a list view (using the awesome


Understanding and Preventing Overflow (I Had Too Much to Add Last Night)

Jason Sachs December 4, 2013

Happy Thanksgiving! Maybe the memory of eating too much turkey is fresh in your mind. If so, this would be a good time to talk about overflow.

In the world of floating-point arithmetic, overflow is possible but not particularly common. You can get it when numbers become too large; IEEE double-precision floating-point numbers support a range of just under 21024, and if you go beyond that you have problems:

for k in [10, 100, 1000, 1020, 1023, 1023.9, 1023.9999, 1024]: try: ...

Chebyshev Approximation and How It Can Help You Save Money, Win Friends, and Influence People

Jason Sachs September 30, 201220 comments

Well... maybe that's a stretch. I don't think I can recommend anything to help you win friends. Not my forte.

But I am going to try to convince you why you should know about Chebyshev approximation, which is a technique for figuring out how you can come as close as possible to computing the result of a mathematical function, with a minimal amount of design effort and CPU power. Let's explore two use cases:

  • Amy has a low-power 8-bit microcontroller and needs to compute \( \sqrt{x} \)...

Zebras Hate You For No Reason: Why Amdahl's Law is Misleading in a World of Cats (And Maybe in Ours Too)

Jason Sachs February 27, 20171 comment

I’ve been wasting far too much of my free time lately on this stupid addicting game called the Kittens Game. It starts so innocently. You are a kitten in a catnip forest. Gather catnip.

And you click on Gather catnip and off you go. Soon you’re hunting unicorns and building Huts and studying Mathematics and Theology and so on. AND IT’S JUST A TEXT GAME! HTML and Javascript, that’s it, no pictures. It’s an example of an


Using the Beaglebone PRU to achieve realtime at low cost

Fabien Le Mentec April 25, 20148 comments
Introduction

I work as an engineer in a synchrotron facility. A few weeks ago, I helped the people in charge of the power supply developments to integrate a realtime control algorithm on a prototype platform: a BeagleBone Black (BBB) running Linux. I had already worked with this board in the past, and I found it very interesting given its excellent resources versus price ratio (around 40 euros). This time, I was impressed by its realtime capabilities. I thought it would be a good idea to...


Coroutines in one page of C

Yossi Kreinin August 20, 201316 comments

A coroutine is a function that you can jump back into after returning from it - and it remembers where it was in the code, and all the variables. This is very useful at times.

One use is generating a sequence of values. Here's how you can generate all the x,y pairs in a 2D range in Python:

def iterate(max_x, max_y): for x in range(max_x): for y in range(max_y): yield x,y for x,y in iterate(2,2): print x,y

This prints:

0 0 0 1 1 0 1 1

The yield keyword is like...


Important Programming Concepts (Even on Embedded Systems) Part I: Idempotence

Jason Sachs August 26, 20146 comments

There are literally hundreds, if not thousands, of subtle concepts that contribute to high quality software design. Many of them are well-known, and can be found in books or the Internet. I’m going to highlight a few of the ones I think are important and often overlooked.

But first let’s start with a short diversion. I’m going to make a bold statement: unless you’re a novice, there’s at least one thing in computer programming about which you’ve picked up...


Using the C language to program the am335x PRU

Fabien Le Mentec June 7, 201481 comments
Introduction

Some weeks ago, I published an article on how we used the PRU to implement a power supply control loop having hard realtime constraints:

//www.embeddedrelated.com/showarticle/586.php

Writing this kind of logic in assembly language is not easy. First the assembly language itself may be difficult to learn depending on your background. Then, fixed and floating point arithmetics require lot of code. While macros help to handle the complexity, they still are error prone as you...


C++ on microcontrollers 1 - introduction, and an output pin class

Wouter van Ooijen October 9, 20117 comments

 

This blog series is about the use of C++ for modern microcontrollers. My plan is to show the gradual development of a basic I/O library. I will introduce the object-oriented C++ features that are used step by step, to provide a gentle yet practical introduction into C++ for C programmers.  Reader input is very much appreciated, you might even steer me in the direction you find most interesting.

I am lazy. I am also a programmer. Luckily, being a lazy...


Memfault Beyond the Launch