Overview of the Flat Sequence Structure
The Flat Sequence Structure in LabVIEW is a dataflow-based programming construct that enforces sequential execution of code.

It consists of one or more frames, each executing in order from left to right. Unlike the Stacked Sequence Structure, all frames are visible simultaneously, making debugging and maintenance easier.
Key Characteristics
- Forced Execution Order: Ensures that code executes in a strict sequence, independent of dataflow.
- Improved Readability: Avoids the hidden code issues associated with the Stacked Sequence Structure.
- No Hidden Code: Since all frames are visible, maintaining the code is easier.
- No Looping Capability: Executes once per run unless placed inside a loop.
Common Design Patterns Using Flat Sequence Structures
1. Initialisation, Execution, and Cleanup (IEC) Pattern
This pattern is commonly used in applications requiring setup, execution, and cleanup in a strict sequence.
Structure:
- Initialisation: Sets up hardware, variables, or UI elements.
- Execution: Runs the main processing logic.
- Cleanup: Closes references, releases resources, or resets settings.
Example: DAQ Data Acquisition
- Initialise DAQ hardware.
- Acquire and process data.
- Close the DAQ session.
This approach ensures that resources are properly released, even if an error occurs during execution.
2. Time-Controlled Execution (TCE) Pattern
This pattern is useful when precise timing between operations is required.
Structure:
- Pre-Timing Setup: Prepares necessary conditions.
- Timed Execution: Uses a delay (e.g., Wait (ms) or Tick Count).
- Post-Timing Actions: Executes tasks that follow the timed delay.
Example: LED Blink with Precise Timing
- Turn LED on.
- Wait for 500 milliseconds.
- Turn LED off.
This ensures an accurate LED on-off cycle without relying on a loop structure.
3. Error Handling Pattern
The Flat Sequence Structure can be used to propagate and handle errors systematically.
Structure:
- Main Operation: Executes the primary function (e.g., file operations, data acquisition).
- Error Check: Verifies if an error occurred.
- Error Handling: Logs or displays the error and performs necessary recovery actions.
Example: File Read with Error Handling
- Open a file.
- Read data.
- Check for errors and close the file.
This ensures that even if an error occurs, the file reference is properly closed.
4. Hardware Synchronisation Pattern
Used when multiple hardware devices must operate in a strict sequence.
Structure:
- Initialise Hardware
- Start Device 1
- Start Device 2
- Wait for Synchronisation
- Read Data
- Shutdown
Example: Synchronising a Motor and a Camera
- Start the motor.
- Start camera recording.
- Wait two seconds to synchronise.
- Read camera data and motor speed.
- Stop the motor and camera.
This approach ensures that the devices operate in a coordinated manner.
Best Practices
- Avoid Overuse: Use Flat Sequence Structures only when strict sequencing is necessary.
- Use Wires for Data Dependency: If natural dataflow enforces order, a sequence structure may not be needed.
- Error Wires Can Replace Some Sequences: Many functions execute sequentially when connected by error wires.
- Keep It Readable: Too many frames can make the Block Diagram cluttered.
When to Avoid Flat Sequences
- If Natural Dataflow Is Sufficient: When existing wire dependencies enforce order.
- If Complexity Increases: Large sequences can become difficult to maintain. Consider using a state machineinstead.
- If Future Modifications Are Likely: Flat Sequences can be rigid, making it hard to insert new steps without restructuring.
Alternative Approaches
- State Machine Pattern: A more flexible approach when execution order needs to change dynamically.
- Event Structure: Better suited for event-driven applications.
- Queued Message Handler (QMH): Ideal for managing multiple tasks dynamically.
Conclusion
Flat Sequence Structures are useful for enforcing strict execution order, particularly in hardware synchronisation, timing-sensitive operations, and initialisation/cleanup patterns. However, excessive use can make code rigid and harder to modify. The key to effective LabVIEW programming is knowing when a Flat Sequence Structure is necessary and when a more flexible approach would be better.