|
|
Subscribe / Log in / New account

Development

A bit of visual programming with MicroFlo

By Nathan Willis
December 5, 2013

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.

[MicroFlo]

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.

Comments (2 posted)

Brief items

Quotes of the week

"Please upgrade to Pro to use this feature." "We have discontinued the Pro version. The free version remains available." Yay, closed source.
Stephen Gadsby

At this point I'm willing to say I'm happy with how Python 3 has turned out and how the community has supported it. Python 3.3 was a great release and I think Python 3.4 will be as well. I see no reason to think that the language and community's forward momentum will not continue, leading to a day where Python 2 only exists for people stuck on RHEL. =)
Brett Cannon

Comments (5 posted)

Go 1.2 released

Version 1.2 of the Go language has been released. "This new release comes nearly seven months after the release of Go 1.1 in May, a much shorter period than the 14 months between 1.1 and 1.0. We anticipate a comparable interval between future major releases." See the release notes for details on the changes this time around, which include three-index slices, a preemptive goroutine scheduler, a test coverage analyzer, and more.

Comments (8 posted)

A Rust frontend for GCC

Philip Herron has announced the availability of a GCC frontend allowing it to compile programs in the Rust language. It is currently in an early stage but is able to compile a number of programs. "There is still a lot of work but i would really like to share it and see what people think. Personally i think rust will target GCC very well and be a good addition (if / when it works)."

Full Story (comments: 21)

Emacspeak 39.0 available

Version 39.0 of the Emacspeak audio desktop has been released. Codenamed "BigDog," the release includes several key enhancements, such as speech-enablement for Chrome, Firefox, and Ipython Notebook, improved Web search wizards and URL templates, and improved support for Emacs 24.3.

Comments (none posted)

Git 1.8.5 released

Git 1.8.5 is available. This release rolls out a number of feature additions, including updates to foreign interfaces, subsystems, and ports.

Full Story (comments: none)

EFL 1.8 released

Version 1.8 of the Enlightenment Foundation Libraries (EFL) has been released. Carsten Haitzler notes that "many major things have happened to EFL in the past year since EFL 1.7 first came out. The usual has been done in fixing bugs, optimizing speed and memory footprint, and much much more." The changes merge several of EFL's libraries into a single EFL package, as well as introducing new libraries for physics and D-Bus, among many other changes.

Full Story (comments: none)

Newsletters and articles

Development newsletters from the past week and change

Comments (none posted)

Paper: How and why has the LibreOffice project evolved?

Simon Phipps pointed to a paper by Jonas Gamalielsson and Bjorn Lundell on the evolution of the Apache OpenOffice and LibreOffice development communities. "From our results, it remains to be seen to what extent the LibreOffice and Apache OpenOffice projects may successfully evolve their projects and associated communities in a way that can be sustainable long-term. So far it seems that LibreOffice has been the more successful project in terms of growing associated communities. Our results suggest that the choice of Open Source license significantly impacts on conditions for attracting contributions to Open Source projects."

Comments (25 posted)

The hackable watch: a wearable MSP430 MCU

At his blog, Alessandro Pasotti has written a tutorial on developing for the Texas Instruments eZ430 Chronos programmable watch using Linux, including a look at the two active firmware development projects. The Chronos is a low-power watch with RF communications and a variety of sensors; as Pasotti shows it is quite hackable, even if it has not attracted as large of a community as other wearable computing products.

Comments (none posted)

Page editor: Nathan Willis
Next page: Announcements>>


Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds