Iar Visual State Promo 6262ddc1b333d

Building State Machines on Linux

April 28, 2022
IAR Systems’ Visual State, which works on Linux and Windows, simplifies the task of creating state-machine models.

What you’ll learn

  • How to turn graphical state-machine models into C, C++, C#, or Java code.
  • Why using a tool like Visual State is better than building a state machine in source code.

Artificial intelligence and machine learning tends to garner the limelight these days, but programming techniques like state machines remain an extremely useful tool. They often provide a model or requirements.

Turning that into an application becomes an easier task when using a product like IAR Systems’ Visual State, which now runs on Windows and Linux. The new cross-platform hosting gives Linux-based programmers the ability to turn state-machine diagrams into code, thereby reducing coding errors due to translation.

With Visual State’s graphical interface, state-machine models can be created using a familiar drag-and-drop approach (see figure). These models can be turned into C, C++, C#, or Java source code. In the past, Linux-based developers could do this in Windows and move the source code to their development system, but that tends to be annoying at best.

State machines are very useful for event-driven applications like many embedded applications. Transitions can be initiated by changes detected in the environment via sensors. 

Though it’s possible to build a state machine in C source code, it’s often a collection of switch or conditional statements. This is what Visual State would generate, but the state transitions tend to get hidden in the text clutter, whereas a graphical presentation preserves them while hiding the details. The graphical version is easier to present and understand. 

Safety standards like ISO 26262 and IEC 61508 are process-oriented. Using a tool like Visual State allows for movement of an idea, in the form of the state-machine model, to code, eliminating the human factor in the translation.

Tools like Visual State become more important as the size and complexity of a system grows. It’s easy to hand-code a state machine with a dozen states and a few status and control functions. However, dealing with hundreds of states can be daunting and error-prone, especially if changes are being made to the model that then need to be reflected in the source code and program testing.

About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!