Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

02 - Introduction To The NI LabVIEW Control Design and Simulation Module PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

Introduction to the NI LabVIEW Control

Design and Simulation Module


Andreas Stark
Systems Engineer

Agenda

Simulation Concepts
PID Concepts
Advanced Control Algorithms
Conclusion

Agenda

Simulation Concepts
PID Concepts
Advanced Control Algorithms
Conclusion

How to become a control expert?


Trial and Error

Time consuming
Risk

Simulation

No need of physical plant


Safe

What can you learn from simulation?


Gain insight into the system that otherwise would
be impossible or difficult due to real-world
limitations
Improve your design before beginning the
prototyping stage
Validate and tune your embedded LabVIEW
FPGA or LabVIEW Real-Time logic

What is simulation?
Use mathematical formulas to represent dynamics
of a system

Simulation Benefits
Faster, better control algorithm code
development
Understand how your control algorithm effects
the system
Evaluate impact of
Sampling rate
Sensor response time, noise, offset/gain error
Deadtime, backlash or resonance

Todays Example

NI 9505
Motor Drive Module

Ethernet

Maxon Amax
Brushed DC Motor

Demo DC Motor Control Simulation

Control System Diagram DC Motor


LabVIEW
Front Panel

Desired
Position

+-

Error

PID
Toolkit

NI 9505

Disturbance

PID
Compensator

Drive
Output

Motion
System

Measured
Position
Windows

Real-Time Hardware

FPGA Hardware
10

Encoder
Sensor

11

How to create plant models.


The old days

Write differential equations for system


Linearize the system
Convert to Laplace domain
Rearrange for transfer function or state-space model
Enter matrix equations

Today

Write differential equations for system


Type into a formula node in the LabVIEW diagram
Click RUN

Use System Identification

Use measurement data

12

Simulating a DC Motor the Old Way

Shaft
Angle

i
+

DO5

d
Tf B
dt

Ti J
B

d 2
dt 2

+
-

vR iR

L
vL L

vm

Vsup
id

di
dt

+
-

ve K e

Tm Kt i

Sum of Forces

d 2
d
0 Kt i J 2 B
dt
dt

Kirchoffs Voltage Law

di
d
vm Ri L K e
dt
dt

Rearrange to put highest order derivative terms on the left side of equation:

d 2 Kt
B d

dt 2
J
J dt

di
R
Ke d vm
i

dt
L
L dt
L

13

d
dt

The Traditional Way: Laplace Transforms


Laplace transform of motor force & voltage equations,
Vm R I L sI K e s

0 Kt I J s 2 B s

Rearranging the force equation,


Kt I

J s2 B s

Transfer function between motor terminal


voltage and shaft angle position,

Vm

K t / JL

BR K t K e
s 3 s 2 B / J R / L s

JL

14

Demo - DC Motor Simulation TF

15

Laplace Transform Approach


Benefits

Wide array of analytical techniques available (bode plots, root


locus, stability analysis, )

Challenges

Transformation is labor intensive


System must be linear otherwise a linear approximation must
be made
Transfer functions are solved for one input and one output
must redo algebra to solve for other variables.
Difficult to monitor other system states during simulation

Abstract. After transformation, the system model is less


human readable

16

Simulating a DC Motor the Modern Way

Shaft
Angle

i
+

DO5

d
Tf B
dt

Ti J
B

d 2
dt 2

+
-

vR iR

L
vL L

vm

Vsup
id

di
dt

+
-

ve K e

Tm Kt i

Sum of Forces

d 2
d
0 Kt i J 2 B
dt
dt

Kirchoffs Voltage Law

di
d
vm Ri L K e
dt
dt

Rearrange to put highest order derivative terms on the left side of equation:

d 2 Kt
B d

dt 2
J
J dt

di
R
Ke d vm
i

dt
L
L dt
L

17

d
dt

Demo - DC Motor Simulation - Textual

18

LabVIEW Simulation Module with Formula Node


Easier: If you can find the equations in a textbook, you
can simulate the system
More intuitive: You can analyze the differential
equations to gain insight into the system and discover
novel control techniques
More informative: You can instrument the system
with no physical limitations on time, accuracy or which
variables can be measured
More accurate: Both linear and non-linear behavior can
be accurately simulated
19

System Identification Definition


If prototype hardware exists, system identification can
be used as first step in model-based control design
process
Create a mathematical model of dynamic system using
measured stimulus and response data
Techniques similar to curve-fitting
Inputs
(stimulus signals)

Dynamic
System

Outputs
(response signals)

20

Demonstration System Identification

21

Comparing Simulated & Real World Results


Real-World

Simulated

22

Agenda
Simulation Concepts
PID Concepts
Basic PID Algorithms
Loop Rate
PID tuning

Advanced Control Algorithms


Conclusion

23

What is PID Control

Set Point (SP) Desired control point


Output (OP) Controller output
Process Variable (PV) Plant/process output
Error = SP - PV

error

OP

SP

PV

25

PID Parameters
Proportional

Drive to setpoint
Error 0, OP 0
Steady-state error

Integral
Eliminate steady-state error
OP proportional to error

Derivative

Increase response rate


OP proportional to change of error rate

26

Proportional-Integral-Derivative (PID)
Proportional

The further the system is from the set point, the larger the
actuator output to drive it to the set point

Integral

The longer the system has been off from the set point, the
larger the actuator output to drive it to the set point

Derivative

The faster the system is changing, the larger the actuator


output to drive it to the set point

27

Demo DC Motor Control

28

How to program PID

PID VIs

Simulation VI

Function Blocks

PID FPGA VIs

Textual Math Scripts

Ready to Run

Custom
30

Algorithm Compatibility Chart


PID VIs

Function
Blocks

Windows

Yes

No

Yes

Yes

Yes

Real Time

Yes

Yes

Yes

Yes

Yes

FPGA

No

No

Yes

No

No

PID and
Fuzzy Logic
Toolkit

LabVIEW RT

PID and
Fuzzy Logic
Toolkit

Control
Design and
Simulation

Mathscript
RT

Included
with Product

FPGA PID VI Simulation VI Textual Math


Scripts

31

PID and Fuzzy Logic Toolkit - Features


Saturation
Integral Antiwindup
Bumpless Transfers
Autotuning
Gain Scheduling
Filtering

32

PID Toolkit Features Explained


Output Range Limits

Protects the motor

Integrator Antiwindup

Better performance in the presence of control


saturation

Bumpless Manual Control

Avoid abrupt changes to motor, increase life

33

Demonstration Integral Antiwindup

34

How fast should the loop rate be


Perception that faster is
better
Too fast might be
challenge to implement
Tuning challenges
Use Frequency
Response to find out

35

Frequency Response
Gain Crossover Frequency

Frequency (Hz)

Input

System (Plant)

Output

36

What can you learn from the frequency response?


Loop Rate Requirements

How fast the control system need to be

Rule of thumb

The control loop should be at least ten times faster than the gain
crossover frequency of the system (minimum 2X faster)
Crossover frequency = 40 Hz
Suggested Loop rate = 400 Hz

CAUTION: Increasing the control algorithm gain increases the crossover frequency

37

Demo: Frequency Response Demo

38

Real World Control Challenges


Systems with a fast response
Use a fast control system and fast I/O modules
Ensure determinism and avoid jitter

FPGA-based control systems are ideal !

39

PID Tuning and Loop Rates


Increasing the P gain makes your system faster.

Result: You may need a faster control loop rate.

40

Conclusions
The performance and stability of the system
depends on the frequency response of the
system AND the control algorithm
Systems that change quickly or have complex
behavior require faster control loop rates
Increasing the gain of the control algorithm may
mean you need to run the control system faster

41

Other PID Tuning tools


Manual
Open Loop Ziegler-Nichols
Closed Loop Ziegler-Nichols

Automatic
Autotuning
Frequency Based (Analytical PID)
Time Based (Optimization)

44

Demo Analytical PID

45

Conclusions
P gain is the most important factor in PID tuning
I gain gets rid of steady-state error
D gain is rarely used and may cause problems if
feedback signal is noisy
If you increase the gain, you may have to
increase the loop rate

If you see a system tuned with a gain of less than 1,


running the control loops faster may improve
performance and reliability

46

Agenda

Simulation Concepts
PID concepts
Advanced PID Algorithms
Conclusion

47

Upgrade Your PID


Disturbances
Nonlinear
Time Variant
Known
Profiles

Feedforward
Gain Scheduling
Adaptive PID
Model Predictive
Control
48

Feed forward

49

Gain Scheduling

PID 3

PID 2
PID 1

50

Control Design Techniques


Adaptive Control

Self-Tuning
Parameter or Structure of the
Controller modifies with changes
on the plant

Set Point

+-

Controller
Configurator

Plant
Estimator

Controller

System
(Plant)

51

Adaptive PID - Example

52

Control Design Techniques


Modern Control

State-Space Feedback Controller Design


Ackermann / Pole Placement
Optimal or Linear Quadratic Regulator (LQR)
Stochastic Systems and Linear Quadratic Gaussian (LQG)

Set Point

+-

PID
Servo

System
(Plant)

+-

Estimator

Regulator
u=-k.x

States

53

Control Design Techniques


Optimal Control and Predictive Control

Parameter of the Controller are optimized for the specific operation.


Np

min J xT Qx u T Ru 2 xT Nudt
0

Constraints

Optimizer

Set Point

System
(Plant)

+-

PID Control

54

Model Predictive Control Vs PID

55

Agenda

Simulation Concepts
PID concepts
Advanced PID Algorithms
Conclusion

57

Easily Deploy to Hardware the NI Way

Many modelsOne approach

58

Questions?
To find
Code used on the demonstration
Technical documentation
Follow up whitepapers
Go to
www.ni.com\info
and enter the code

devdays2010ctrl

59

Additional Resources

60

Deadtime
The interval of time between initiation of an input change or
stimulus and the start of the resulting response

Deadtime

61

Dead time
Deadtime is a delay between when a process
variable changes, and when that change can be
observed.
Examples:

Temperature sensor is placed far away from a cold water


fluid inlet valve

Delay caused by the flow of fluid through pipes


Will not measure a change in temperature immediately if the
valve is opened or closed

Deadtime can also be caused by a System (Plant) or


Output Actuator that is slow to respond to the
Compensator command.

Valve that is slow to open or close

Thermocouple sensor: Response time depends on thermal


mass
I/O module: Filters that remove 50/60 Hz noise slow the
response

Every sensor and I/O module causes some delay in


the measurement

62

Backlash
Example: Motor spins but gate doesnt begin to
open for some time due to a sloppy mechanical
system.

63

Resonance or Vibration
Avoid exciting the system at the resonant
frequency

Gain can be reduced at the problem frequency using


a notch filter or low pass filter

Use a custom control algorithms such as a leadlag controller


Convolve algorithm
MFA algorithm
64

Linear systems vs non-linear systems


Linear system

Steady state response of the system is linearly


proportional to the stimulus
Gain

Offset

Y mX b
Steady State Response

Constant Stimulus

65

Linear system

Differential equation describing system response (y)


has constant multiplier coefficients

The function (y) or its derivatives (y, y) are not raised to


some power or embedded in another function (such as sin
y)

y 7y 0

First order linear, no stimulus

y 2 y 8 y sin 2 x

Second order linear

'

''

'

y x 1 y sin 4 x
''

Second order nonlinear

66

You might also like