Example Code

A First LabVIEW Example – Random Strip Chart

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

Description

Random Strip Chart is often considered as the “Hello World” example for LabVIEW.  It displays random data on a strip chart.  A strip chart shows running data continuously scrolling from left to right across the chart with old data on the left and new data on the right.  

How to Use

Front Panel

On the Front Panel, place a Stop Button from the Boolean controls, a Waveform Chart from the Graph controls, and a Dial from the Numeric Controls.

To rename the Dial control, double click on the Dial text and enter “Loop time (ms)”. To change its upper limit, double click on the default 10 and change it to 1000.

Block Diagram

Move to the block diagram by selecting the menu option Window > Show Block Diagram or pressing Ctrl+E.

Place a While Loop from the Structures palette on the block diagram. Move the controls for the Waveform Chart, Loop time (ms), and Stop inside the loop as in the picture below.

Inside the loop, place a Random Number (0-1) VI from the Numeric palette and a Wait (ms) VI from the Timing palette. Wire the Random Number (0-1) VI to the Waveform Chart control. Wire the Loop time (ms) to the Wait (ms) VI. Wire the Stop button to the Condition Terminal of the While Loop.

Running the VI

Return to the front panel by selecting the menu option Window > Show Front Panel or pressing Ctrl+E. Click on the Run arrow to start. Random numbers are placed on the chart. Vary the loop time by changing the Loop time (ms) control. Click on the Stop button to stop.


Front Panel

mceclip0.png

Block Diagram 

mceclip1.png

Additional Information

Customizing Graphs and Charts

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

Contributors