You are on page 1of 76

LabVIEW for Real-Time Control in

Measurement and Automation


National Instruments LabVIEW RT
and the RT Series Hardware
Agenda
Definitions
PID Control
Fuzzy Logic Control
Control Issues
Real-Time Control
Control Overview
Analyze
Determine needs
Output
Data to process
Open-Loop Control
System determines output needs
No Feeback
Control Overview
Acquire
Data from process
Analyze
Determine needs
Output
Data to process
Closed-Loop Control
Data acquired to determine current state
Control system determines output needs
Feedback provided
Control Overview
Acquire
Thermometer
Analyze
Temperature
Controller
Output
Heater / AC
turned on, off
Temperature Example
Data acquired from thermometer
Controller determines temperature status (too high? Low?)
Heater or AC turned on / off
Control Terminology
Terms:
Process variable
Setpoint
Controller output
Plant
Examples:
Temperature
Desired temperature
Heater voltage
Furnace
Acquire
Single-point acquisition
Allows fast control loops
Acquire
Data from process
Analysis
Analyze acquired points
Use full range of LabVIEW functions
Mean, RMS, FFT,
Single-point versions of multiple-point functions
Analyze
Determine needs
Analysis Functionality
Array-Based Analysis
1. Acquire all points
of data stream
2. Filter and analyze
3. Make decision
4. Generate report
Point-by-Point Analysis
1. Acquire one point
of data stream
2. Filter and analyze
3. Make decision
4. Generate report
Demo: Single-point analysis
1- PointByPoint.vi
Software only
Analysis
Analyze acquired points
Determine proper output signal
Simple Control
PID
Fuzzy Logic
Analyze
Determine needs
How do you implement Control?
Evaluate Error
Proportionally
Evaluate History
Integrate error over time
Evaluate dynamics
Rate of change of error- derivative
Analyze
Determine needs
PID Control
Analyze
Determine needs
PID Parameters
Proportional gain K
c
Integral gain K
c
/T
i
T
i
is the integral time constant or reset time
Derivative gain K
c
*T
d
T
d
is the derivative time constant or rate time
Analyze
Determine needs
PID Gains P
Proportional gain K
c
The Sledgehammer
Immediate controller
response to setpoint change
PV may not settle exactly on
SP
Demo: P only
2- Simple PID.vi
DAQ, Simple Circuit
+
-
+
-
Excitation
Analog In
1 MOhm
.153uF
.153uF
1 MOhm
1 MOhm
PID Gains PI
Integral gain K
c
/ T
i
Fine tuning
Integrates error over time
Overcomes offset from
Proportional
May cause overshoot,
oscillation, and instability
problems
Demo: PI
2- Simple PID.vi
DAQ, Simple Circuit
+
-
+
-
Excitation
Analog In
PID Gains PID
Derivative gain K
c
* T
d
Whoa
Puts the reigns on PI control
Prevents overshoot and
oscillation
Adds stability
Demo: PID
2- Simple PID.vi
DAQ, Simple Circuit
+
-
+
-
Excitation
Analog In
PID Considerations
Tuning
Integrator Windup
Varying Behaviors
Manual / Auto switch
Hold Value
Loop Speed
Analyze
Determine needs
PID Toolkit
Autotuning
Integrator Anti-windup
Gain scheduling
Switch
Hold mode
Tuning
Integrator Windup
Varying Behaviors
Manual / Auto switch
Hold Value
Loop Speed
Analyze
Determine needs
Demo: PID Toolkit
3- Toolkit PID
DAQ, Simple Circuit
+
-
+
-
Excitation
Analog In
Fuzzy Logic Dataflow
Fuzzy Logic Control for LabVIEW
Why is fuzzy logic important?
Easy to implement an intuitive control strategy
Better control of non-linear systems
PID control is linear
Fuzzy control is non-linear
Analyze
Determine needs
Fuzzy Logic: Rule-Based Control
Example
If temperature is high, then heater voltage output should be
low.
Membership sets
What is meant by high?
Analyze
Determine needs
Fuzzy Sets
Boolean (or two-valued) sets:
Members belong to a set non-members do not
Traditional Boolean values (on/off, 1/0)
Fuzzy Sets:
Partial membership to set allowed
Values along continuum of 0 to 1
Analyze
Determine needs
Boolean Set
High Body Temperature
Temperature
M
e
m
b
e
r
s
h
i
p
Analyze
Determine needs
Fuzzy Set
High Body Temperature
Temperature
M
e
m
b
e
r
s
h
i
p
Analyze
Determine needs
Fuzzy Logic Control
Demo: Fuzzy Logic
4- Fuzzy.vi
Simple Circuit
+
-
+
-
Excitation
Analog In
Fuzzy Logic and PID Combined
IF AND THEN
IF AND THEN
IF AND THEN
Rule base

Fuzzificatio n Fuzzy Inference Defuzzification


Process Fuzzy Controller
Set Point Values
Measur ed Values
PID
Command Variable
P
I
D
Fuzzy Logic Design Software
Analyze
Determine needs
Demo: Fuzzy Logic Design
5- Fuzzy.vi
Simple Circuit
+
-
+
-
Excitation
Analog In
Control Concerns
Autotuning
Integrator Anti-windup
Gain scheduling
Switch
Hold mode
Tuning
Integrator Windup
Varying Behaviors
Manual / Auto switch
Hold Value
Loop Speed Real-Time
Real-Time Definitions
Real-time means same time
Real-time does NOT mean real fast
Hard real-time - deadlines can not be missed
Flight control
Engine testing
Soft real-time - missed deadline acceptable
Temperature logging
Banking
More soft real-time applications than hard
Output
Data to process
Real-Time Applications
Real-Time OS
General-Purpose OS
Type Example
Event Response Control temperature and
provide safe shutdown in
an emergency
Control Monitor temperature,
compare to desired
temperature, initiate
appropriate heating
or cooling
Data Acquisition Monitor temperature
Operating Systems
General-purpose OS
High-priority tasks can be preempted by lower-priority tasks
Many extraneous programs run in the background
Screen savers, disk utilities, virus software, etc.
Must service interrupts from peripheral devices
Mouse, keyboard, etc.
No determinism guaranteed
Real-Time OS
Scheduling system ensures that high-priority tasks execute first
Difficult software integration
Can be very expensive
Typical Real-Time Applications
Hardware Real-Time OS General OS
Milliseconds Microseconds
Mechanical Test Telecom Test
Motion Control
Hydraulic Control
Business/POS
Medical Network Control H/W Loop
Simulation
Dynamic Signal Analysis Industrial Automation
Engine Test
Internet
1000 100 10 1 100 50 10 1
Windows LabVIEW-RT LabVIEW-FPGA
LabVIEW Development System
Rapid development with graphical programming
Built-in functionality for measurement and control applications
Tight software and hardware integration
LabVIEW Real-Time System
Develop on
Host Computer
Download
Processor
I/O modules
Execute on
RT Target
Target
PXI - Compact PCI for Control
Compact and modular form
Ethernet connectivity
Excellent networking protocols
DataSocket
VI Server
TCP/IP
RT Series PXI Embedded Controllers
Up to 40 kHz PID loop rate
I/O integration
Headless operation
Hard drive or CompactFlash
Watchdog timer
Processor
PXI Backplane
Memory
DAQ Boards
SCXI Modules
Demo: PXI-RT
6- Audio.vi
PXI Sound Demo
LabVIEW RT
Low cost RT controller
Easy to configure
Easy to program
Reliable
Full access to hard drive, cards, and some peripherals
High loop speeds
~50 microseconds
132 Mb/s, 33 MHz, 32-bit Computer Bus
PXI Trigger Bus
P
e
r
i
p
h
e
r
a
l
10 MHz
CLK
Star Trigger
R
e
a
l
-
T
i
m
e

O
S
Local Bus
PXI Timing and Triggering
P
e
r
i
p
h
e
r
a
l
P
e
r
i
p
h
e
r
a
l
S
t
a
r

T
r
i
g
g
e
r
C
o
n
t
r
o
l
l
e
r
S
y
s
t
e
m
C
o
n
t
r
o
l
l
e
r
RT PXI Modular Components
I/O connectivity
Data acquisition
Signal conditioning
Dynamic signal acquisition
Motion control
Image acquisition
Third party connectivity with NI-VISA
Communication protocols
Ethernet
Serial
GPIB
CAN
Chassis expansion through MXI-3
LabVIEW Real-Time Module
Delivers reliable, deterministic performance
Creates embedded, stand-alone applications
Features built-in tools for control
RT Series DAQ Board
I/O options
16-bit multifunction
12-bit multifunction
High-speed digital
DAQ Daughter Board
Local PCI Bus Memory
Processor
Processor Board
Features
Shared memory
User-defined LEDs
RT DAQ for Safety Shutdown
Windows Computer
R
T

S
e
r
i
e
s
D
A
Q
E

S
e
r
i
e
s
D
A
Q
D
S
A
B
o
a
r
d
Turbo Charger Unit Under Test
Safety
Shutdown
Signal Conditioning
Signal Monitor
Oil Pressure
Oil Temperature
Air Pressure
Turbo Speed
Vibration
LV-FPGA
More information - 2003
Distributed I/O with FieldPoint
Rugged, reliable I/O
Built-in isolation and signal
conditioning
Communication interfaces for
Ethernet, serial, Foundation
Fieldbus, and wireless networks
Distributed monitoring, control,
and datalogging applications
FieldPoint for Industrial Control
Embedded processor
Watchdog timers
Sensor and device diagnostics
Isolation
Programmable power-up output
Hot swappable modules
Demo: FP-RT
7- PID- Cycle Time.vi
FP - Temperature
RT Targets
RT Series DAQ RT PXI RT FieldPoint
Performance
(PID loop rate)
1 kHz 40 kHz (max) < 1kHz
Small Size Good Better Best
I/O Variety Good Best Better
I/O Count Low High High
Rugged Better Best
Distributed Better Best
Remote System Explorer
Configures system
Installs or upgrades software
Creates utility disks
Lists installed software or hardware
Develop
Host Computer
Download
RT Target
Host Computer
Execute
Default
Communication
Front Panel
displays on Host
Code executes
on RT Engine
RT Target
Host Computer
Demo: Default Communication
7- PID-Cycle Time.vi
FP - Temperature
Default Communication
No additional programming
Quick for debugging
Insufficient for some cases
Uses more network bandwidth than necessary
Unable to save data for further analysis
Need LabVIEW Real-Time development system on host
LabVIEW Web Server
FP-2000 Runs Web Server
Clients view VI Front Panel in Internet Explorer
Clients need run-time installed (free)
Clients can request control of VI
Deploy
Custom
Communication
RT Target
Host Computer
Demo: DataSocket Communication
8-
FP - Temperature
Round Robin Scheduling
Shop Manager
(Scheduler)
Mechanic
(CPU)
Normal
Normal
Normal
Preemptive Scheduling
Mechanic
(CPU)
Time
Critical
Normal
Normal
Normal
Shop Manager
(Scheduler)
LabVIEW Real-Time Scheduler
Combination of Round Robin and Preemptive
Normal priority shares the CPU
Time-critical priority releases CPU when finished or sleeping
Assign priority to each VI
Timing for Real-Time Applications
Real-Time Terminology
Determinismhow consistently a system is able to perform
operations within a fixed time
Jitteramount of time the actual loop cycle time varies from the
desired cycle time
Sleepperiod of time when the thread programmatically relinquishes
control of the processor
Objectives
Maximize performance
Maximize determinism
Minimize jitter
Jitter Diagram
L
o
o
p

I
t
e
r
a
t
i
o
n
Loop Time
Desired Loop Time
1
2
3
4
5
Jitter
Software
Wait until next millisecond multiple VI
Millisecond loop rates (microsecond jitter)
Hardware
Sample or update clock of I/O board
Microsecond loop rates (nanosecond jitter)
Timing Strategies
HW Clock
AI Scan
Software Timing Diagram
L
o
o
p

I
t
e
r
a
t
i
o
n
Time
PID
AO
1
s
jitter
AI
SW Sleep
2
3
4
5
Desired Loop
Time (ms)
AI sampled
AO written
AI Hardware Timing Diagram
PID
AO
1
AI
HW Sleep
2
3
4
5
L
o
o
p

I
t
e
r
a
t
i
o
n
Time
ns
jitter
Desired Loop
Time ( s)
AI sampled
AO written
Synchronized I/O Timing Diagram
PID
AO
1
AI
HW Sleep
2
3
4
5
L
o
o
p

I
t
e
r
a
t
i
o
n
Time
ns
jitter
Desired Loop
Time ( s)
AI sampled
AO written
Demo: Jitter
9- Jitter Test.vi
NI-Scope
PXI - Scope
Networked Real-Time Application
FieldPoint
Development
Machine
GPIB
Web Viewers
PC-Based
Instrument
Serial
PXI
PLC
Internet
Conclusion
More Information:
2002 National Instruments Catalog
www.ni.com
zone.ni.com
www.daqman.com
Steve.summers@ni.com
Steve.aposhian@ni.com

You might also like