A bit of visual programming with MicroFlo
One of the chief advertised benefits of the Arduino family of devices is its suitability for novice programmers—Arduino "sketches" (Arduino's term for programs) are easy to read and write, and the integrated development environment (IDE) is equally friendly to learn and use. But there is always more that can be done, as a recent "visual programming" project illustrates.
MicroFlo is an implementation of flow-based programming for microcontroller boards. Flow-based programming represents applications as graphs of modules that are joined by connecting together input and output streams on each module. It is a model that is conceptually easy to grasp for newcomers, in part because it lends itself so well toward visual diagrams, where the relationships between components are clear and hard to misinterpret.
MicroFlo is the creation of Jon Nordby, best known from the GEGL and MyPaint projects. The first public release was in September, followed by the latest update (version 0.2) in late November. Although the initial target platform is Arduino-compatible hardware, the long-term goals include a variety of other devices.
As the name suggests (to those who follow flow-based programming), MicroFlo is inspired by NoFlo, a flow-based development environment for JavaScript, and MicroFlo's visual interface is built with the NoFlo UI components (although the code to which they are connected is very different). The interface runs on Node.js, and allows users to construct Arduino programs by building a graph of components in the browser window. Behind the scenes, MicroFlo currently requires the Arduino IDE to be running as a back-end connection to the hardware device.
The notion of representing an Arduino sketch as a graph of nodes would not be particularly novel on its own, but MicroFlo goes further by enabling the user to change the graph in the interface and have those changes reflected almost live on the device itself. It is actually a "MicroFlo runtime" sketch that is uploaded to the Arduino itself; as the user constructs the graph in the web UI, the graph is sent to the device as parameters to the runtime. This means that programs are limited to those components supported by the MicroFlo runtime sketch (of which there are currently around 20), however, it also means that changes to the application's graph are reflected near instantaneously in the running code on the Arduino. In comparison, uploading a sketch through the Arduino IDE takes around fifteen seconds.
Blinken
To get started with MicroFlo, one needs a recent Arduino board and the Arduino IDE. Next come the prerequisites for MicroFlo itself: Node.js, the npm package manager, and the node-gyp package. The MicroFlo release packages include three pieces: the server component for Node.js (in the microflo folder), the NoFlo web UI (in the microflo-ui folder), and the library for the Arduino IDE (the microflo-arduino.zip file).
The server is installed with npm install, then started with:
node ./microflo.js runtime
The library needs to be loaded into the Arduino IDE (through the "Add library" menu item), then the "Standalone" sketch uploaded to the Arduino device. With the sketch running on the device and the server running on the PC, the user can open the index.html page from the UI folder and begin editing a graph. Pressing the "play" button relays the graph to the Arduino, where it begins executing immediately.
The modules available in the graph UI right now cover most of the basic Arduino functions: the various input/output pins (digital and analog), the built-in LED and serial port, and so on. There are also basic flow-control options, timers, and counters, and a module for reading a Dallas Semiconductor thermometer, presumably courtesy of Nordby's first release, which his blog announcement indicates he tested by controlling an old refrigerator.
The project's roadmap indicates that supporting the full set of Arduino tutorials is one of the goals, as is allowing users to build more complex programs by defining "sub-graphs"—functional units that can be combined together just like the basic modules.
That would truly be a useful addition; as it is MicroFlo makes it quite simple to tweak a graph and see its changes on the Arduino itself. However, many other visual programming environments work well when the full graphs fits neatly onto the screen, but start to break down rapidly once the graph becomes so large that horizontal and vertical scrolling are required to work on it (see the Blender node graph for one example).
Replace software here:
The other angle that Nordby highlights for MicroFlo's potential usefulness is the possibility of "IDE included" hardware devices. In a talk at the Piksel 2013 conference (of which a YouTube video is available), he noted that more and more electronic products in the home are built with software-driven microcontrollers, but that in almost every case there is no practical way to take advantage of the freedom to tinker with the software inside—even if it is free software.
By including a runtime in these devices that can be connected to a PC (and modified), it would be far simpler to reprogram household appliances. Furthermore, he said, the visual programming model makes the features of a device easier to discover and less difficult to understand. Essentially, when connecting modules is as simple as linking output pads to input pads on a graph, it becomes much more difficult to write something syntactically incorrect or dangerous.
Of course, to achieve that long-term goal, a project like MicroFlo will have to expand far beyond Arduino boards. Other device back-ends are on the project roadmap, starting with a more generic back-end for the AVR microcontrollers used by Arduino boards. Arduinos, after all, are designed for experimentation and prototyping—hence the use of pin headers rather than solder pads. Eventually, most "finished" projects (not to mention commercial products) move to a dedicated circuit, even if they continue to use a compatible microcontroller for their software.
The distant future aside, though, MicroFlo is already an
interesting take on visual programming for a platform geared toward
learning. Almost anyone can learn to program with an Arduino, but
visual learners may find more to like about an IDE where all the
connections and capabilities can be seen with the naked eye.
Posted Dec 8, 2013 16:17 UTC (Sun)
by erwaelde (subscriber, #34976)
[Link] (1 responses)
I tried the examples successfully. It seems that a system (approx 16k) is put onto the controller first, which is used to run "my program". This bit reminds me of Forth, which I use routinely (http://amforth.sf.net) --- except for the gui clicky part, of course. amForth puts some 8k onto the controller to run "my program".
Happy hacking!
Posted Dec 20, 2013 12:49 UTC (Fri)
by jonnor (guest, #76768)
[Link]
A bit of visual programming with MicroFlo
Erich
A bit of visual programming with MicroFlo
In the future there will be a need to configure which component(sets) are included in the image.
