Archive for the 'C/C++' Category

Creating Time-Consistent Loops for Embedded Systems

In an embedded system there are typically four main ways to architect the code: Simple loop, foreground-background, cyclic executive, and RTOS. In this article I will look at how to create a simple main loop with a time-consistent execution period, similar to what a cyclic executive does.

Continue reading ‘Creating Time-Consistent Loops for Embedded Systems’

Ardunio Programming: C++ and Embedded Systems

Ideally we would use assembly language to wring the last drop of performance from small microcontrollers, and at one time that really was the only way to do it. But assembly language programming is tedious and error-prone, and if I never have to wrestle with another assembly language program that would be fine with me.

With the advent of C, things got a lot easier in the embedded systems world. As its creators stated, C is essentially a close relative of an assembler, rather like a macro assembler (there’s a good Google/Wikipedia topic, if you don’t know what a macro assembler is). A C program can be compiled into very tight and efficient code, with an almost one-to-one correspondence to the underlying assembly language that the compiler generates.

But times change, and things are extended, improved, and expanded, and thus C++ arose from C. Over time C++ has become one of the dominant languages in programming, but there are challenges when attempting to use it with a microcontroller. Continue reading ‘Ardunio Programming: C++ and Embedded Systems’

Fear of the Unknown

Humans are strange creatures. In general we like things to be nice and predictable; the same tomorrow as today, and the same as yesterday. I don’t have any hard data to reference, but I suspect that, overall, the human race is rather conservative. We don’t like new things that challenge our current beliefs and knowledge. This is ironic, considering that we now live in a time where change is about the only reliable constant, and new things are appearing at an astounding pace. Continue reading ‘Fear of the Unknown’

Wrestling with Visual Studio

A few months ago I had a relatively large C++ source code set for a suite of applications dropped into my lap. Well, that’s OK, I don’t mind C++, but what I did mind was that it was all written using Visual Studio.

It’s been a long time since I had to work with Windows code, and now that I’ve waded through line after line of code and  wrestled with Visual Studio along the way, I’ve recalled now why I don’t like working with Windows.

Continue reading ‘Wrestling with Visual Studio’

Visual Debuggers

A visual debugger is a like an addictive mental drug. It’s fascinating to look at, very helpful at times, and it can become a crutch. Just as with alcohol or other drugs, a little bit can be fun and help get you to where you want to be, but too much can derail you. Allow me to explain.

I do most of my development on Linux (OK, I actually do ALL of my development on Linux or something similar like Solaris or BSD–I don’t do Windows) in C, C++, or Python. When the need arises to be able to peer into the code and see what, exactly, is causing an annoying fault I use gdb or DDD (a GUI front-end for gdb) for C and C++. For Python I use tools like winpdb or Eclipse with the Python IDE plug-in.

Continue reading ‘Visual Debuggers’

C++, CUDA, Python, and Really Big Cameras

I can’t believe this blog is still here. Amazing. I figured WordPress would close it down by now.

A lot has happened since the last entry. My book was released by O’Reilly (and it’s been doing OK), I came down with a severe case of food poisoning (and ended up in the ICU), and some months later had triple-bypass open-heart surgery (and another stay at the Hotel ICU). Fun times.

Here’s a link to the book, if you’re interested (shameless self-promotion):

http://shop.oreilly.com/product/9780596809577.do

and of course it’s also available on Amazon.

Continue reading ‘C++, CUDA, Python, and Really Big Cameras’

INI Files

So-called “INI” files are ubiquitous. You can find them on Unix systems, Windows platforms, and even in the flash memory of embedded systems. I even once wrote my own INI parser for some software on a embedded diskless VME control system running WindRiver’s VxWorks. It allowed us to upload new configuration and control parameters on-the-fly in a human-readable format. Very handy.

Continue reading ‘INI Files’