JKI Blog

#3 Best Practice for using the JKI State Machine: Keep the Original Size (i.e. don’t grow the structures)

Feb 11, 2015 1:24:12 PM Published by Jim Kring Leave a comment

In my last post on JKI State Machine Best Practices, I explained the #2 Best Practice: Don’t add code and logic inside the Event Structure.  In this post, I'll tell you which best practice came in third place.

The #3 Best Practice: Keep the Original Size (i.e. don’t grow the structures)


Here's what we mean:

The size of the JKI State Machine was carefully designed to fit on one “reasonably sized” VI Block Diagram.  The LabVIEW Style Block Diagram Checklist tells us:

“Avoid creating extremely large block diagrams. [...] The size of the block diagram window can affect how readable LabVIEW code is to others. Make the block diagram window no larger than the screen size.”

Of course, as monitors have grown in size (I’m looking at you, Thunderbolt Display!) block diagrams have gotten larger.


Still, you’ll want to exercise caution and avoid growing the size of the JKI State Machine, since limiting its size encourages the use of SubVIs and modularizing your code (and that's a good thing), as we'll discuss below.  There are a couple ways to achieve this...

First and foremost, keep the JKI State Machine size from growing by doing the following: 

  • Avoid using CTRL-drag to insert space into a LabVIEW diagram.
  • Leave the “Auto Grow” setting turned OFF for all the structures inside the JKI State Machine (it’s While Loop, Case Structure, and Event Structure)


Second, as your application logic and code naturally grow in size complexity, you can modularizing your code (i.e. don’t try to do everything in the block diagram of one frame) by doing the following:

  • Move code into subVIs (we'll have a blog post in the future on how your JKI State Machine application architecture evolves over time, so stay tuned for that)
  • Create add’l state frames of your state machine and organize them into related sections (as shown below -- we'll talk more about that in a future blog article, too).


Keep in mind, once you grow the size of your JKI State Machine, it’s nearly impossible to shrink its size again (but, there are a couple of cool LabVIEW idea exchange posts about how this might be possible in the future).

We'd like to hear about your best practices for using the JKI State Machine. Please post comments and suggestions, below.  And, if you have ideas for making the JKI State Machine better, please post them to the JKI State Machine GitHub Issue Tracker.

And a note from our sponsor: At JKI we use the JKI State Machine every day to help our our clients get their innovative high-tech products and technology to market fast. If you need help taking your system software to the next level or reach an important milestone, contact us to learn more about our services.

Tags: best practices, JKI State Machine, LabVIEW, LabVIEW tip, JKI State Machine, state machine

Subscribe to Email Updates

Recent Posts

Posts by Topic

see all