Design Con 2015

Automatic code generation and Arduino

-January 07, 2013

Two complementary concepts—automatic code generation and the inexpensive, open-source, single-board microcontroller—have reinvigorated innovation in engineering practice and education.

Automatic code generation from system block diagrams has been around for decades and is an entrenched way of developing embedded control systems and performing hardware-in-the-loop testing at many aerospace and automotive companies; today, it is rapidly moving into other industries. The Arduino microcontroller debuted in 2005 and has quickly become a favorite of inventors and students.

Computer programming and implementation can seem so out of place in engineering problem solving that engineers often relegate the tasks to a specialist. “Engineer programmer” is an oxymoron.

I have said, however, that the human, the computer tools (software and hardware), and the problem should all be in perfect harmony throughout the problem-solving process. The combination of graphical programming using block diagrams, automatic code generation from the block diagrams, and implementation on an easily understandable yet powerful microcontroller comes close to that ideal.

Honeywell observed in 2005 that the typical software process injects 100 defects, due to both design and coding errors, per 1000 lines of source code using manual processes. The company has automated software manufacturing through automatic code generation and has demonstrated the achievement of six-sigma quality—that is, not more than 3.4 defects per million opportunities. Northrop-Grumman, for its part, has fine-tuned the process of going from the desktop directly to flight code on flight hardware. Rapid prototyping and hardware-in-the-loop testing are now the rule, rather than the exception.

What could possibly excite an engineer or engineering student more than solving a real-world problem? Seeing one’s solution implemented in hardware does precisely that.


The Arduino open-source, single-board microcontroller is a favorite of inventors and students.

While teaching model-based design and controls over the past 20 years, I have not seen a more exciting, effective, and accessible problem-solving combination than graphical block-diagram programming, as is done in the Matlab/Simulink environment, and automatic generation of C code for a microcontroller, as is done using the Arduino microcontroller with the Simulink Coder. Today, all manner of robots and self-balancing transporters are conceived, modeled, simulated, controlled, and virtually prototyped before construction, in a way that all engineers embrace.

Ours is an age of diminishing meaningful human interaction. A university engineering program’s value, then, lies in demonstrating the importance of such interaction through faculty-student mentoring and education in the context of real-world, human-centered, team-based problem solving.

Automatic code generation and the Arduino microcontroller should be a part of that strategy from the beginning of an engineering student’s career. Innovative concepts, expressed graphically for all to see and understand, automatically become real-time instructions for a computer, and then become real-world actions that make a difference.


Kevin C Craig, PhD, is the Robert C Greenheck chairman in engineering design and a professor of mechanical engineering at the College of Engineering at Marquette University. For more mechatronics news, visit mechatronicszone.com.

Loading comments...

Write a Comment

To comment please Log In

FEATURED RESOURCES