Example Code

Simple Intruder Alarm Log VI with State Machine Architecture using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
A simple State Machine example that logs the Date/Time that an Intruder enters a building (simulated by pressing a Boolean Front Panel control). 


Description
This VI logs date and time of the intrusion event when the "Intruder?" button is pressed, and shows the logged data and time that corresponds to the intrusion number selected. Every step within the State Machine architecture is fully explained, a Flow Diagram image illustrating the operation of the State Machine is also embedded into the Block Diagram.


Requirements

  • LabVIEW Base Development System 2012 (or compatible)


Steps to Implement or Execute Code

  1. Download and unzip "Intruder 2012 NIVerified.zip"
  2. Open the project "Intruder 2012 NIVerified.lvproj"
  3. Open the VI "Intruder 2012 NIVerified.vi"
  4. Run the program

 

Additional Information or References

  • Adding More States to Case Structure

The Case structure can automatically create a CASE for every state added to the ENUM. To achieve this, right-click the case structure and select "Add Case for Every Value".

 

  • Using the ENUM constant in Code

Please make copies of the ENUM when using it in code, to achieve this hold down the CTRL key on your keyboard whilst clicking and dragging an existing instance of the ENUM.

 

  • VI Block Diagram

Capture.JPG

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 
Jamie S.

Applications Engineer
National Instruments

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.