41
1 ni.com

Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

  • Upload
    wilson

  • View
    45

  • Download
    1

Embed Size (px)

DESCRIPTION

Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects. Meghan Kerry Embedded Software Product Manager Certified LabVIEW Developer (CLD). Agenda. Keys to quality in a software architecture Software architecture overview I/O safe states Watchdog timers Message communication - PowerPoint PPT Presentation

Citation preview

Page 1: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

1ni.com

Page 2: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

ni.com

Decisions Behind the Design: LabVIEW for CompactRIO

Sample ProjectsMeghan Kerry

Embedded Software Product ManagerCertified LabVIEW Developer (CLD)

Page 3: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

3ni.com

Agenda

• Keys to quality in a software architecture• Software architecture overview• I/O safe states• Watchdog timers• Message communication• Error handling • System monitoring

Page 4: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

4ni.com

Keys to Quality in a Software Architecture

• Define software architecture and identify architecture components

• Create an architectural diagram• Consider key components such as data communication, error handling, etc.

• Learn the foundational design patterns• Create new design patterns as required by your application (requires experience)

Page 5: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

5ni.com

Data Communication Diagram

• Documents foundational components:• Processes (loops)• Data communication paths• Type of data transfer

Page 6: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

6ni.com

Data Communication Types

Tag Latest value data

Messages/Commands Intermittent data, low latency

Stream Continuous acquisition, high throughput

Page 7: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

7ni.com

Typical CompactRIO System Diagram

Page 8: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

8ni.com

LabVIEW for CompactRIO Sample Projects• Pre-built architectures for embedded control and monitoring applications

• Designed to ensure quality and scalability of a system

Page 9: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

9ni.com

Basic FPGA Diagram

Performs deterministic and/or high speed control

Page 10: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

10

ni.com

State Machine for Hardware I/O and Control

Page 11: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

11

ni.com

Failure Conditions that Initiate Safe States

• Examples (from Fail Safe Reference Design):

• RT Safe – indicates the RT system is ready

• Emergency Safe – tied to an emergency shut-off switch

• Watchdog Safe – monitors the Real-Time system

• Control Inputs Valid – monitors the inputs to the control algorithm

• Based on system requirements

Page 12: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

12

ni.com

Basic FPGA Diagram

Detects software failures

Recovers from software failures

Page 13: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

13

ni.com

Watchdogs

• A watchdog timer is a hardware counter that interfaces with the embedded software application to detect and recover from software failures

• A user can then:• Reboot real-time target automatically• Perform user-defined recovery actions

• Two types of watchdogs with NI Real-Time hardware:

• LabVIEW Real-Time Watchdog • Real-Time <-> FPGA Watchdog (FPGA Fail Safe Design)

Page 14: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

14

ni.com

LabVIEW Real-Time Only Watchdog

• Uses hardware timer built into CompactRIO hardware

• “Reset = True” reboots system if the watchdog process is starved

Page 15: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

15

ni.com

LabVIEW Real-Time Watchdog

• Enable occurrence in expiration actions• Configure appropriate watchdog timeout and Watchdog Whack loop period

Page 16: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

16

ni.com

Real-Time <-> FPGA WatchdogReset timer

Put control loop into a safe state, and reset system

Page 17: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

17

ni.com

Real-Time <-> FPGA Watchdog

• Pet the watchdog at a user-defined watchdog pet rate

• This resets the counter implemented in the FPGA VI

See Fail-Safe Control Reference Design whitepaper

Page 18: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

18

ni.com

Basic FPGA Diagram - Summary

Detects software failures

Recovers from software failures

Performs deterministic and/or high speed control

Page 19: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

19

ni.com

Basic Real-Time Processor Diagram

Periodically communicates

tags

Communicates messages with

clientSends messages to other processes or

targets

Page 20: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

20

ni.com

Constructing a Message

Examples

DataVariant allows data-type to vary. Different messages may require different data

CommandString constant allows user to specify message

Command Data

Update Control Configuration

Cluster containing configuration data

Update FPGA State Enum

Update PID Setpoints Array of numerics

Send Error to UI Error cluster

Exit -

Page 21: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

21

ni.com

Queued Message Handler API

Page 22: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

22

ni.com

Queued Message Handler Framework

Message handling loop

Watchdog Loop

Monitoring Loop

Command ParserQueued Message Handler Setup

Page 23: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

23

ni.com

Queued Message Handler Framework

Watchdog Loop

Monitoring Loop

Command ParserOne or more messages handled per case

Communicate messages between processes or targets

Page 24: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

24

ni.com

Basic Real-Time Processor Diagram

Handles all error messages from

FPGA and RT target

Page 25: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

25

ni.com

Error Messages

• Specific Error Handling• Code called in specific

locations to respond with an action to specific error codes

• Possible actions are retry, ignore, correct

• Central Error Handling• High-level code that checks

for errors in an entire system• Responds to classes of errors

rather than specific codes• Uses the classification to

determine which actions to take

QueueCentral Handler

Page 26: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

26

ni.com

Central Error Handling Framework

UI message handling loop

Watchdog Loop

Monitoring Loop

Command Receiver Loop

Specific Handler

Specific Handler

Specific Handler

Page 27: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

27

ni.com

Central Error Handling Framework

Watchdog Loop

Monitoring Loop

Command Receiver Loop

Specific Handler

Specific Handler

Specific Handler

Page 28: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

28

ni.com

Central Error Handling Framework

Get next error based on priority

Return classification of error

Handle classified errors (update FPGA state and/or reboot system)

Log and send all errors to UI

Page 29: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

30

ni.com

Basic Real-Time Processor Diagram

Communicates messages with

client

Page 30: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

31

ni.com

Sending Commands Across the Network

• Network Streams are great for commands because are they are lossless

• Tips:• Use Flush with zero timeout to minimize latency• Add code to handle UI disconnections (see Sample

Project)

Page 31: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

33

ni.com

System Monitoring

Disk Space RAM CPU Bandwidth

EFF

EC

T

Lost Data Crash Starvation

Embedded processors have limited….

Page 32: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

34

ni.com

System Monitoring

Current value data can be sent to UI with Shared Variables

Monitor CPU usage per coreExecute loop

periodically

Page 33: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

35

ni.com

Network Published Shared Variables

• When to use the Static API:• Small number of variables (less than a dozen)

• When to use the Programmatic API:• Iterate through a large number of variables• Dynamically change the IP address of the cRIO from the

client (client side only)

Page 34: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

36

ni.com

Basic Real-Time Processor Diagram

Periodically communicates

tags

Communicates messages with

clientSends messages to other processes or

targets

Page 35: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

37

ni.com

Basic HMI Diagram

Generates UI Events using the Event Structure

Processes UI Events and communicates messages with real-time system

Periodically updates UI

Page 36: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

38

ni.com

Common Variant Architectures

• Other LabVIEW for CompactRIO Sample Projects• LabVIEW FPGA Control • LabVIEW FPGA Control with Real-Time Sequencer Engine • LabVIEW Real-Time Control (RIO Scan Interface) • LabVIEW FPGA Waveform Acquisition and Logging• LabVIEW Data Logging and Supervisory Control

Page 37: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

39

ni.com

FPGA Control with Sequencer Sample Project

Page 38: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

40

ni.com

Real-Time Control Sample Project

Page 39: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

41

ni.com

FPGA Waveform Acquisition and Logging

Page 40: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

42

ni.com

Demo – LabVIEW FPGA Control Sample Project

Page 41: Decisions Behind the Design: LabVIEW for CompactRIO Sample Projects

43

ni.com

LabVIEW for CompactRIO Sample Projects• Available in LabVIEW 2012 and later• Find more best practices at ni.com/compactriodevguide