Advanced RealTime Programming - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

Advanced RealTime Programming

Description:

Methods of scheduling multiple threads. Round Robin. Preemption. Sleep mode. ni.com. ni.com ... PID Loop Example. ni.com. ni.com. LabVIEW Real-Time Constraints ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 33
Provided by: johnli
Category:

less

Transcript and Presenter's Notes

Title: Advanced RealTime Programming


1
Advanced Real-Time Programming
  • John Limroth
  • LabVIEW Real-Time Systems Engineer

2
Presentation Overview
  • Embedded versus real-time needs
  • Real-time case study 16 Channel PID
  • Software timing versus hardware timing
  • Synchronizing analog input and output across
    multiple DAQ boards
  • Real-time optimization rules of thumb

3
Embedded Versus Real-Time
  • Do you need real-time or embedded
    characteristics?
  • What is your real-time need?
  • NOTE This presentation focuses on maximizing
    determinism in LabVIEW Real-Time applications.

4
Real-Time Software Principles
  • Benefits of multithreading
  • Thread Priorities
  • Time-critical priority (highest)
  • Methods of scheduling multiple threads
  • Round Robin
  • Preemption
  • Sleep mode

5
Real-Time Software Principles (cont.)
  • Benefits of multithreading
  • Thread Priorities
  • Time-critical priority (highest)
  • Methods of scheduling multiple threads
  • Round Robin
  • Preemption
  • Sleep mode

6
Real-Time Software Principles (cont.)
  • Benefits of multithreading
  • Thread Priorities
  • Time-critical priority (highest)
  • Methods of scheduling multiple threads
  • Round Robin
  • Preemption
  • Sleep mode

7
Assigning Priority to a VI
8
Real-Time Case Study
  • System Multi-loop PID controller
  • LabVIEW Real-Time 6i
  • NI-DAQ 6.9.1
  • PXI-8170 controller
  • PXI E-series data acquisition (DAQ) boards
  • Objective
  • Achieve nanosecond determinism

9
Single PID Loop Application
10
Software Timing
  • Software determines timing of all operations

AI
AO
AI
(t)
HW events
Code Execution Time
Sleep Time (Wait Until)
?T (ms multiple)
11
Software Timing
  • Software determines timing of all operations

AI
AO
AI
(t)
HW events
Code Execution Time
Sleep Time (Wait Until)
?T (ms multiple)
Software Jitter
Note Not drawn to scale!
12
Software Timed PID Loop
  • Max loop rate 1 kHz
  • Timing limited to 1 ms intervals
  • 1 kHz, 500 Hz, 333 Hz, 250 Hz, etc.
  • AI/AO timing is subject to software jitter
  • Note These characteristics are sufficient for
    most real-time control applications!

13
Anchoring Software to Hardware
  • AI Single Scan.vi provides
  • Hardware timing of software
  • Sleeping pathway built into NI-DAQ
  • Increased overall performance of application
  • NOTE Counter/timer functions used with E-Series
    MIO devices also have a sleeping pathway

14
Hardware Timed Loop
15
Hardware Timing
  • Hardware timing masks software jitter from the
    system under control

AI
AI
AO
(t)
HW events
Code Execution Time
Sleep Time (AI SingleScan)
DAQ Hardware ?T
16
Hardware Timing
  • Hardware timing masks software jitter from the
    system under control

AI
AI
AO
(t)
HW events
Code Execution Time
Sleep Time (AI SingleScan)
DAQ Hardware ?T
Software Jitter
17
Hardware Timing
  • Hardware timing masks software jitter from the
    system under control
  • Te Tj ? ?T

AI
AI
AO
(t)
HW events
Te
TJ
Code Execution Time, Te
Sleep Time (AI SingleScan)
DT
DAQ Hardware ?T
Software Jitter, Tj
18
Hardware Timed PID Loop
  • AI has nanosecond determinism
  • AO timing is subject to software jitter

19
16 Ch. PID Loop Application
  • 2 PXI-6040E boards for analog input
  • 2 PXI-6713 boards for analog output

20
16 Ch. Hardware Timed Loop
21
16 Ch. Hardware Timing
AI
AI
AO
AI
AI
AO
(t)
HW events
Code Execution Time
Sleep Time (AI SingleScan)
DAQ Hardware ?T
22
16 Ch. Hardware Timing
AI
AI
AO
AO
AI
AI
(t)
HW events
Code Execution Time
Sleep Time (AI SingleScan)
DAQ Hardware ?T
Software Jitter
23
16 Channel PID Loop
  • Timing of AI scans on the two boards is
    independent
  • AO timing is subject to software jitter

24
Synchronized Hardware Timing
  • Use RTSI line or PFI pin to synchronize AI and
    AO
  • One AI board serves as master
  • Clock for all other AI and AO is driven by the
    master
  • Example
  • \LabVIEW\Examples\DAQ\Solution
    \Control.llb\Real-Time PID Control.vi

25
Synchronized Hardware Timing
26
Synchronized Hardware Timing
  • Hardware timing masks software jitter from the
    system under control

AI/AO
AI/AO
(t)
HW events
Code Execution Time
Sleep Time (AI SingleScan)
DAQ Hardware ?T
27
Synchronized Hardware Timing
  • Hardware timing masks software jitter from the
    system under control

AI/AO
AI/AO
(t)
HW events
Code Execution Time
Sleep Time (AI SingleScan)
DAQ Hardware ?T
Software Jitter
28
Synchronized Hardware Timing
  • All AI board scans and AO board updates driven by
    one clock
  • AI and AO timing have nanosecond determinism

29
Shared Resources
  • Shared resources cause priority inversions which
    result in software jitter
  • Common shared resources
  • Memory Manager
  • Global variables
  • Non-reentrant sub-VIs
  • Synchronization code (Queues, Semaphores,
    Occurrences, etc)
  • TCP/IP, UDP, VI Server, (networking protocols)
  • File I/O

30
Shared Resources(cont.)
  • Shared resources cause priority inversions which
    result in software jitter
  • Common shared resources
  • Memory Manager
  • Global variables
  • Non-reentrant sub-VIs
  • Synchronization code (Queues, Semaphores,
    Occurrences, etc)
  • TCP/IP, UDP, VI Server, (networking protocols)
  • File I/O

31
Shared Resources Example
  • Top-level VI

32
Shared Resources Example
  • Time Critical VI

33
10 Ch. PID Loop Example
34
LabVIEW Real-Time Constraints
  • ALL NI-DAQ calls MUST be done within the
    real-time loop!
  • Single time-critical loop in the entire
    application

35
Results Summary
  • Two solutions found
  • Synchronized hardware timing
  • Removal of all shared resources (e.g. no memory
    management!)
  • Result robust, high performance control system
    with nanosecond determinism
Write a Comment
User Comments (0)
About PowerShow.com