ctacke.com

Embedded programming · Industrial integration

Introducing SMFlow: visual programming for microcontrollers and control systems

Why I built SMFlow, a visual, PLC-inspired IDE that compiles node-and-wire flows into plain C++ for microcontrollers, and what a real transfer-case controller looks like in it.

I recently released SMFlow, a visual IDE where you build microcontroller and control-system logic by wiring nodes together, and it compiles the flow down to plain C++ for whatever board you’re targeting. Here’s why I built it.

I’ve been a fan of visual software development for a long time. Some of my earliest programming experience was using Logo on the Commodore 64, and I still remember how mind-bending sprites were at the time. I think Scratch was groundbreaking for helping to teach programming and, in a way, even PLC ladder logic has an intuitive (if archaic) nature to it. Writing code requires learning a foreign language, and it’s not easy. If you’re doing microcontroller programming you have to learn several “languages”: reading schematics, reading data sheets, and then programming. And if you need to support multiple microcontrollers it only gets worse. It’s a large cognitive load. I’ve been thinking about it for a couple of decades, and recently set out to provide a new option.

If writing microcontroller and control-system code could become visual, it would be much more intuitive for a large block of developers. Why not take concepts like the scan period from PLCs and flow-chart-like design, and build an IDE that opens up microcontroller programming to a wider group? It can still be deterministic, and at the same time greatly reduce or even eliminate problems like C memory leaks. I know it’s a cliché at this point, but I really want to “democratize” developing apps for microcontrollers and industrial control.

That’s the need SMFlow is trying to fill (“SM” is short for state machine, since a large part of most microcontroller programming is managing state machines). It started out as an experiment for my own learning. I built a tool that could do the obvious, easy stuff like turning on GPIOs or relays and reading A2Ds, and I found it really nice to be able to swap hardware on my desktop, select the new hardware, and redeploy. No need to change toolchains and grab new libraries.

I then attacked a real-world, more complex problem: a transfer case control module (TCCM). I’d done a few TCCMs before, one in C and one in C#, but I wanted to see how SMFlow could adapt to the problem. As expected, the first attempts were rough, with overly complex, hard-to-follow flows because SMFlow didn’t yet have the features the problem needed. But as I worked through it, I added nodes to SMFlow to tackle the issues I found, and I ended up at a point where it’s now possible to create a clean, easy-to-follow flow that’s robust, reliable, and under 50 nodes in size. I call that a win.

The SMFlow editor showing a transfer-case controller in grouped sections: an encoder and a dash switch read through Range Map, Debounce and Select nodes, four indicator outputs driven through a Value Map, and serial telemetry, with Servo Deadband and Motor Guard subflow tabs beside the main task and the Range Map ladder in the properties pane.

The finished transfer-case controller: 37 nodes in one 100 ms task, with the servo deadband and motor guard built as reusable subflows. More on how it’s built.

Since I also come from a dev background, I have opinions on tool licensing, so I made SMFlow free for flows of up to 12 nodes, with no time limits and no nag screens. And once you buy the app, it’s perpetually licensed. All features, all upgrades, and it’s not locked to one PC. You bought it, you own it. It also generates plain old C++, so the output can be checked into source control, edited, compiled, and distributed without SMFlow. No distribution or runtime fees.

Whether you’re just starting your microcontroller or control-systems journey or you’re a seasoned expert, it has a lot to offer.

Try it at smflow.co, or watch the walkthroughs on YouTube.