34
University of Colorado Electrical, Computer, and Energy Engineering ECEE4638 Control Systems Lab Manual Author: Shalom D. Ruben Postdoctoral Scholar Co-Advisors: Prof. Jason R. Marden Prof. Lucy Y. Pao August 21, 2011

ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Embed Size (px)

Citation preview

Page 1: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

University of Colorado

Electrical, Computer, and Energy Engineering

ECEE4638 Control Systems LabManual

Author:Shalom D. RubenPostdoctoral Scholar

Co-Advisors:Prof. Jason R. MardenProf. Lucy Y. Pao

August 21, 2011

Page 2: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Contents

Preface ii

1 Preliminaries 11.1 Why Feedback Control? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Why The 3-disk Torsional System? . . . . . . . . . . . . . . . . . . . . . . . 2

2 Hardware 32.1 Plant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Actuation and Hardware Gain kh . . . . . . . . . . . . . . . . . . . . . . . . 92.3 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.4 Hardware Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

2.4.1 Simulation and Implementation Method I . . . . . . . . . . . . . . . 192.4.2 Simulation and Implementation Method II . . . . . . . . . . . . . . . 19

2.5 System Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.6 Disturbances and Nonlinearities . . . . . . . . . . . . . . . . . . . . . . . . . 20

3 Software 213.1 Main LabVIEW Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.2 Main FPGA Code (instructor access only) . . . . . . . . . . . . . . . . . . . 243.3 Encoder Count FPGA Code (instructor access only) . . . . . . . . . . . . . . 263.4 Stiffness Data Acquisition (for System Identification, instructor access only) 263.5 Free Response Data Acquisition (for System Identification) . . . . . . . . . . 28

A Safety Hardware Warnings! 29

i

Page 3: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Preface

Welcome to the Control Systems Lab course! This course was developed by Prof. ToddMurphey with the help of Prof. Lucy Pao who developed a similar lab during her tenure atNorthwestern University. This lab and this manual are constantly changing in the attemptto improve the course so suggestions are encouraged.

It is assumed that you have or are currently taking the theory course (ECEE 4138 Con-trol Systems Analysis). This lab course requires learning Mathworks’ Matlab (which youwill already be learning in the theory course) and National Instruments’ LabVIEW soft-ware. Although there will be some simulation in LabVIEW, in an attempt to aid in learningLabVIEW, for the most part it sufficient to simulate in Matlab so as to be consistent with thetools used in the theory course. LabVIEW, for the most part, will be used in implementingcontrol algorithm and collecting data in lab experiments.

This manual described both the hardware and software, in some detail, that will be usedthrough out this course. It is my hope that both the students and future instructors willneed only look to this manual for most of their hardware and software questions.

I’d like to acknowledge that the majority of the LabVIEW code described in this manualwas written or supervised by Prof. Todd Murphey [1]. Marian Chaffe edited the LabVIEWTutorial (Lab 0) and made many useful suggestions. Darren McSweeney, Application Engi-neer at the ITLL, speaks LabVIEW better than he speaks english and is a great help to thiscourse.

ii

Page 4: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Chapter 1

Preliminaries

1.1 Why Feedback Control?

Before answering the question at hand, let me present a few different control structures. TheFeedback (or Closed-Loop) control structure which we will primarily use in this course isshown in Figure 1.1.

CFB Pur e y

−y

Figure 1.1: Feedback Control Diagram

Another control structure is the Feedforward (or Open-Loop) structure shown in Figure1.2.

CFF Pur y

Figure 1.2: FeedForward Control Diagram

It is theoretically possible to have y = r by setting CFF = P−1. There are many advancedcontrol schemes that deal with the problems that can occur, for example P−1 may be unstabledue to non-minimum phase zeros of P (zeros in the right-plan complex plane), and you needto model P and any disturbances very well. Feedforward can respond faster since it predictsthe future and does not wait for a feedback signal. We will not cover any of these advancedtechniques.

The last structure that I will mention is the combined Feedback/Feedforward controlstructure shown in Figure 1.3.

1

Page 5: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

CFB

CFF

PuFB

uFF

ur

r

e y

y

Figure 1.3: Feedback/FeedForward Control Diagram

The combined Feedforward/Feedback combines the best of both world but will not be cov-ered in this course. An illustration of the benefit of the combined structure versus feedback-only on an atomic force microscope can be found in Figure 4. of this paper [2].

Now back to the question of the benefits of feedback:

1.) Can Stabilize a system while feedforward cannot change the dynamics of the plant

2.) Can improve robustness to un-modelled plant dynamics while feedforward depends onan excellent model

3.) Rejection of un-modelled disturbances

For interesting, yet not so rigorous, explanations of control theory, I point you to thisbook [3]

1.2 Why The 3-disk Torsional System?

More details to come, but the main points are as follows:

1. It is a non-trivial system

2. Although non-trivial, the system can be modeled as coupled second order systems

3. Able to show the difficulties of controlling a system with a non-collocated actuator andsensor (will see this in the Root Locus lab)

4. Visualize 3 distinct mode shapes (more relevant for a vibration course but interestingnon the less)

2

Page 6: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Chapter 2

Hardware

2.1 Plant

The experimental test bed used in this course, designed and built by Educational ControlProducts (ECP), is the Model 205 Torsional Disk System (TDS) shown in Figure 2.1.

Figure 2.1: Model 205 Torsional Disk System (TDS)

The following pages come from the ECP Model 205 TDS Manual and describe the possibleconfigurations of this model and other useful directions.

3

Page 7: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+,-%&.(/&-0'1$%123(4(5$&'#%136(73-%'80%123-!

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

()*)( 9:&0%'2.&0"#310#:(;:#3%(!

$%$%&! '()*+,!'()-.*/0*1,!

23(! /45,06! )317,! *,! 8*+9.(! $%$:&6! -1,)*)0)! 1;! 071! <=1>(4! $?@A! 1.! 03.((! <=1>(4! $?@5A! >*)B)!)9//1.0(>!CD!5!01.)*1,544D!;4(E*C4(!)35;0!73*-3!*)!)9)/(,>(>!F(.0*-544D!1,!5,0*:;.*-0*1,!C544!C(5.*,+)%!!23(! )35;0! *)! >.*F(,! CD! 5! C.9)34())! )(.F1! G101.! -1,,(-0(>! F*5! 5! .*+*>! C(40! <,(+4*+*C4(! 0(,)*4(!;4(E*C*4*0DA!5,>!/944(D!)D)0(G!7*03!5!"H&!)/((>!.(>9-0*1,!.50*1%!!I,!(,-1>(.!41-50(>!1,!03(!C5)(!1;!03(!)35;0!G(5)9.()!03(!5,+945.!>*)/45-(G(,06! &!1;!03(!;*.)0!>*)B6!J&%!!23(!)(-1,>!>*)B!*)!-1,,(-0(>!

01!*0)!(,-1>(.!CD!5!.*+*>!C(40!K!/944(D!7*03!5!&H&!)/((>!.50*1%!!I)!)317,!*,!8*+9.(!$%$:$5!03*)!>*)B!5,>!(,-1>(.!G5D!C(!G1F(>!;.1G!03(!9//(.!)35;0! 41-50*1,!01!03(!G*>>4(!41-50*1,!;1.!=1>(4!$?@%!!81.!=1>(4!$?@56!03(.(!*)!5,!(,-1>(.!50!(5-3!>*)B!41-50*1,!<8*+9.(!$%$:$CA!

8*+9.()! $%$:$5! L! C! 54)1! )317! 03(! F5.*(0D! 1;! /45,0! 0D/()! 0350! 5.(! )9//1.0(>! CD! (5-3! G1>(4%!=503(G50*-54!G1>(4*,+!5,>!/5.5G(0(.!*>(,0*;*-50*1,!1;!03()(!/45,0)!5.(!+*F(,!*,!M35/0(.)!@!5,>!#%!

!

mm

4 Movablemasseseach disk

m

Rigid belt drive

BrushlessServoMotor

B&!NO&PJ

B$!N O$PJ

m m

m m

Encoder #1< & A

Encoder #2< A$

Encoder #3< "A Third encoder /disk

for Model 205a only<J"A

<J$A

<J&A

m

Make cer tainupper disk ismountedbelow shaf tclamp

!Figure 2.2-1. Torsion Spring / Inertia Apparatus!

4

Page 8: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+,-%&.(/&-0'1$%123(4(5$&'#%136(73-%'80%123- !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

!!

5

Page 9: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+,-%&.(/&-0'1$%123(4(5$&'#%136(73-%'80%123- !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

!

6

Page 10: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+,-%&.(/&-0'1$%123(4(5$&'#%136(73-%'80%123- !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

$%$%$! &'()*+)*!,-().!&/)0+*12(.+/)3!()4!,(2(56.62!7(-163!83! 3'/9)! +)! :+*126! ;%$%$<$=! .'6! >-().! 5(?! @6! >-(A64! +)! (! B(2+6.?! /0! 0266! ()4! A-(5>64!A/)0+*12(.+/)3! 9+.'! C=! $=! ()4! "! DE/46-! $F;(G! 46*2663! /0! 02664/5! DHI:G%! ! :/2! C! ()4! $!HI:!>-().3=! .'6! ./23+/)(-! 3>2+)*! A/)3.().! JC! 5(?! @6! '(-B64! @?! A'/+A6! /0! 4+3J! -/A(.+/)%! ! &'()*+)*!A/)0+*12(.+/)3!/0.6)!26K1+263!265/B+)*!/2!26>-(A+)*!+)62.+(!4+3J3%! !8-.'/1*'!.'636!/>62(.+/)3!(26!3.2(+*'.0/29(24=! +.! +3! 26A/556)464! .'(.! .'6?! @6! >620/2564! @?! (! K1(-+0+64! .6A')+A+()%! ! L.! +3!+5>/2.().! ./!J66>!6(A'!>(+2!/0!'(-0<4+3J3! ./*6.'62! +)!5(.A'64!36.3! D366! +)3A2+@64! -6..623!/)!4+3J!64*63G%! !M?!(-+*)+)*! .'6!A/)A6).2+A!5(2J+)*3=! .'6!>2/>62! 26-(.+B6!(-+*)56).!/0! .'6! .9/!'(-B63!+3!(331264%! ! :/2! />62(.+)*! 3(06.?=! @6! 3126! ./! 0+25-?! .+*'.6)! D@1.! )/.! 6NA633+B6-?! 3/G! .'6! @/-.3! .'(.!0(3.6)!.'6!4+3J3!./!.'6!3'(0.!A-(5>3%!!!O'6!1362!5(?!A'()*6!+)62.+(!B(-163!@?!A'()*+)*!.'6!)15@62!/0!5(3363!()4P/2!.'6+2!-/A(.+/)!/)!(!*+B6)!4+3J%!!:+*126!$%$<"!*+B63!+)3.21A.+/)3!0/2!>'?3+A(--?!A'()*+)*!+)62.+(3%!

!

Hub Spl it Li ne

Secure masses by t ightening screw. Loosenand sli de to relocate.

Concentric rings @ r = 2.0 to 9.0 cm i n 1 cmintervals to assi st i n m ass c.g. m easurement.(M easure to edge of 5.00 cm dia mass)

All masses must be concentr ically located(w ithin ± 1 mm) prior to operation.

If only tw o masses are used, they must belocated along the hub split line.

500 ± 1 gr(i ncl bol t & nut)

Disk Mass

Flat side of squarenut must face upw ard

Disk Pl ate

Each disk may hav e four, two or zero massesonly. One or three masses w il l imbalance disk.

!Figure 2.2-3. Guidelines For Changing Or Adjusting Disk Masses

!

7

Page 11: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+,-%&.(/&-0'1$%123(4(5$&'#%136(73-%'80%123- !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

$%&! '(&)! (%*'+,! -&)./0! 1%21! 1%&! ,.(3(4! 5&+1(4! 26,! 7'++&0(! 2)&! 7)*7&)+0! 2+.86&,! 26,! (&9')&,! 26,!)*121&!/)&&+0!7).*)!1*!*7&)21.*6:!!!;*)!<*,&+!=#>!?=!,.(3!*6+0@!1%&!(&9*6,!,.(3!.(!6*A.62++0!+*921&,!21!1%&!'77&)!(%2/1!7*(.1.*6:! !B/!1%&! ,.(3! .(! A*-&,! 1*! 1%&! A.,,+&! 7*(.1.*64! 1%&! &69*,&)! C.++! 5&! *).&61&,! '7(.,&! ,*C6! 26,! 1%&!7*+2).10!*/!.1(!(.862+!C.++!5&!)&-&)(&,:!!D!6&821.-&!'6.10!82.6!.6!1%&!&69*,&)!/&&,5293!5)269%!?&:8:!!"#$4!%"#$4!*)!&"#$@!A'(1!5&!,*C6+*2,&,!-.2!1%&!8&6&)2+!/*)A!1*!7)*-.,&!(125+&!?6&821.-&!/&&,5293@!9+*(&,!+**7!9*61)*+:!!$%.(!A'(1!5&!,*6&!&-&)0!1.A&!2!9*61)*++&)!.6-*+-.68!&69*,&)!E=!?21!1%&!A.,F(%2/1!+*921.*6@!.(!.A7+&A&61&,:!!;*)!<*,&+!=#>2!6*!7*+2).10!9*))&91.*6!.(!6&9&((2)0:!!!=:=:G! $%&!H71.*62+!I.(1')5269&!I).-&!$%&!,).-&!.(!92+.5)21&,!21!1%&!/291*)0!1*!*'17'1!277)*J.A21&+0!K:=!LFAMN!2(!277+.&,!1*!1%&!.6&)1.2!

26,!A20'!5&!(7&9./.&,!-.2!1%&!&J&9'1.-&!7)*8)2A4!*)!277+.&,!&J1&)62++0!.6!1%&!92(&!1%&!'(&)!.(!('77+30.68!9*61)*+!%2),C2)&!.67'1(!?&:8:!1%&!

O!P%&6! 1%&! ,).-&! .(! ,).-&6! .6! )&(7*6(&! 1*! 1%&! A*1.*6! 21! 2! (7&9./.9! ,.(3! ! !

@! !A*,&(! ! 1%&!A*1.*6! .(! (&6(&,!-.2! 1%&!&69*,&)!21! 1%&!2,Q29&61!,.(3:! !$%&!72)1.9'+2)!,.(3!A'(1!5&! (7&9./.&,! .6! 1%&!Disturbance Configuration!,.2+*8!5*J:!!

.(!277+.&,!2(!2!1*)R'&!?A*1*)!9'))&61@!7)*7*)1.*62+!1*!26,!.6!1%&!*77*(.1&!,.)&91.*6!*/!1%&!)21&!2(!A&2(')&,!-.2!1%&!&69*,&)!21!1%&!(7&9./.&,!.6&)1.2!,.(3:@!B6(1)'91.*6(!/*)!7*(.1.*6.684!2,Q'(1.684!26,!(1*C.68!1%&!,).-&!2)&!8.-&6!.6!;.8')&!=:=F":!!!

8

Page 12: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

2.2 Actuation and Hardware Gain kh

Actuation of the system , from the command desired torque in the computer to actualtorque applied, is a combination of the parts shown in Figure 2.2. First a desired torque

Digital to

Analog

Converter

(DAC)

Amp Motor Pulley

Torque

Counts Volts Current Torque Torque

Figure 2.2: Amplifier, Motor, DAC, and Pulley

from the software is sent, in counts to the digital to analog converter (DAC) which outputsa proportional voltage (10 volts per 32767 counts for a 16 Bit DAC) to the current amplifierwhich then send current to the motor which applies a torque that is finally magnified by apulley before torque is applied to the system.

We neglect any dynamics by the amplifier, motor, and pulley and assume constant gainsas shown in Figure 2.3. To simplify the system identification, we combine these three gainsas shown in Figure 2.3 and call this the hardware gain kh. You will calculate this gainexperimentally in Lab 3.

kdac = 1032,767 ka km kp

Torque

Counts Volts Current Torque Torque

kh

Figure 2.3: Hardware Gain kh = kakmkp

The motor in this system is known as a Brushless DC motors which has 3 current inputs(3 phases or coils) to produce the torque (notice in Figure 2.2 that Current is bold faceto signify a vector). The algorithm that the amplifier implements, of converting a desiredtorque (or proportional voltage) to 3 currents, is known as Commutation. More detail aboutthe commutation and current feedback implemented by the amplifier can be found in thefollow pages which were taken for the ECP manual. The main point to keep in mind is thatdue to the low-resolution commutation, implemented by this amplifier, a source of torqueerror (actual torque versus desired torque/voltage command) of up to 13% occurs. Thiserror oscillates and therefore is known as Torque Ripple and the reduction of Torque Ripplecan be found in many research papers.

9

Page 13: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

)*3( 4'56",&66(70%0'(!0//5%#%.01(#18(90':5&(!01%'0,($%&! '()*! (+,(*-(.&! /0! (! 12! 3456%7&66! '/-/4! 8/-%&49)6&! :*/9*! (6! (! !"#$%&"&'( $%)&"'(*+&,-#.&./*! '/-/4;! /,&4! -%&! </*,&*-)/*(7! 12! 3456%! '/-/4! )6! -%&! &7)')*(-)/*! /0! 3/-%! 3456%!04)<-)/*!(66/<)(-&+!9&(4=!

>).54&! ?=@AB! 6%/96! (! <4/66! 6&<-)/*(7! ,)&9!/0! (! -CD)<(7!12!3456%7&66!'/-/4=! ! E*!</*-4(6-! -/! -%&!</*,&*-)/*(7!12!3456%!'/-/4F!-%&!D&4'(*&*-!'(.*&-6!(4&!0)G&+!-/!-%&!4/-/4=!!$%&!D%(6&!9)*+)*.6!8-CD)<(77C! @! D%(6&6;! (4&! +)6-4)35-&+! )*! 67/-6! /0! -%&! 6-(-/4=! ! $%)6! (44(*.&'&*-! (76/! D4/,)+&6! 0/4!.4&(-&4!%&(-!+)66)D(-)/*!8)HI;F!9%)<%!)*!-54*!7&(+6!-/!)'D4/,&+!7)0&!(*+!-CD)<(77C!.4&(-&4!,/75'&A-/AD/9&4!4(-)/6!0/4!3456%7&66!'/-/46!-%(*!0/4!3456%!'/-/46=!

N S

NS

Stator

Rotor

Air Gap

PermanentMagnet

Hall Sensors(3 places)

30o

30o

!Figure 4.3-1. Cross-section of a Typical DC Brushless Motor. (Four pole type shown)

E*!(*C!</*-)*5/567C!4/-(-)*.!'/-/4F!-/!D4/,)+&!</*-)*5/56!-/4J5&!-%&!<544&*-!'56-!3&!65<<&66),&7C!(7-&4&+!/4! 69)-<%&+!+&D&*+)*.!/*! -%&!(36/75-&!D/6)-)/*!/0! -%&!4/-/4=! !E*!(!12!3456%!'/-/4F! -%)6!69)-<%)*.! )6! )'D7&'&*-&+!'&<%(*)<(77C! 3C! -%&! </''5-(-/4=! ! E*! (! 12! 3456%7&66!'/-/4F! (! 4/-/4!D/6)-)/*)*.! 6&*6/4! )6! 56&+! (*+! -%&! </''5-(-)/*! D4/<&+54&! )6! +/*&! &7&<-4/*)<(77C=! ! K&! 9)77!</*6)+&4! -9/! +)00&4&*-! -CD&6! /0! </''5-(-)/*! D4/<&+54&6! 0/4! 12! D&4'(*&*-! '(.*&-! 3456%7&66!'/-/46L!4&<-(*.57(4!(*+!6)*56/)+(7=!

!

?=@=B!!I&<-(*.57(4!8M(77AN00&<-;!2/''5-(-)/*(>).54&!?=@AH!6%/96!(!6)'D7)0)&+!6<%&'(-)<!/0!-%&!+4),&!6C6-&'86;!56&+!)*!-%)6!'&<%(*)6'=!!$%)6!)6!(!-CD)<(7! +4),&! 6<%&'&! 0/4! (! ?AD/7&! @AD%(6&! 6-(4A9/5*+! 3456%7&66! '/-/4! 9)-%! M(77A&00&<-!84&<-(*.57(4;! </''5-(-)/*=! ! $%&! -%4&&! M(77A&00&<-! 6&*6/46! (4&! D/6)-)/*&+! /*! -%&! 6-(-/4=! ! $%&!6&*6&+!'(.*&-)<!0)&7+!69)-<%&6!3&-9&&*!-%&!(+O(<&*-!*/4-%P6/5-%!D/7&6!(6!-%&!4/-/4!4/-(-&6=!!$%)6!69)-<%)*.! 6&J5&*<&! )6! -%&*! 56&+! -/! +)4&<-! -%&! </''(*+&+!'/-/4! <544&*-! -/! )*+),)+5(7!9)*+)*.!D%(6&6!8>).54&!?=@A@;=!!Q!6)'D7&!&7&<-4/*)<!7/.)<!<)4<5)-!)6!56&+!0/4!-%&!.&*&4(-)/*!/0!-%&!69)-<%)*.!6-&D6!86)G!6-&D6!D&4!&7&<-4)<(7!<C<7&!/4!BH!6-&D6!D&4!'&<%(*)<(7!<C<7&!0/4!(!?AD/7&!'/-/4;=!!Q*(7/.!%).%!3(*+9)+-%!!#.!.#'0.&%1(!1/*( 0&'")#%1! 8RE;!<544&*-! 0&&+3(<:! 7//D6!(4&! -%&*!56&+!/*! -9/!/0!

10

Page 14: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

""!

#$%!#$&%%!'$()%)!#*!())+&%!(,-*)#!./)#(/#(/%*+)!&%)'*/)%!*0!#$%!(1#+(,!2./3./4!1+&&%/#!0*,,*2./4!(/5! 1*--(/3%3! 1+&&%/#! 1$(/4%)6! ! 7$%! #$.&3! '$()%! 3*%)! /*#! &%8+.&%! (! 1+&&%/#! 0%%39(1:! ,**'!9%1(+)%! ;()!'%&!<.&1$$*00=)! ,(2>! #$%!1+&&%/#! ./! #$%! #$.&3!'$()%! .)! #$%!/%4(#.?%!*0! #$%!)+-!*0!#$%!1+&&%/#!./!#$%!*#$%&!#2*!'$()%)6!

!Figure 4.3-2 Simplified Schematic of Hall-effect Commutated DC Brushless Motor

Drive System(!

@%!())+-%! #$(#A!3+%! #*! #$%! &%,(#.?%,5!$.4$!9(/32.3#$!*0! #$%!1+&&%/#! ,**')A!/%(&,5!./)#(/#(/%*+)!-(#1$./4!*0!#$%!1*--(/3%3!1+&&%/#!;#*&8+%>!(/3!#$%!(1#+(,!1+&&%/#!*11+&)6B!!@.#$!#$%!&%1#(/4+,(&!3&.?%!)1$%-%!)$*2/!./!C.4+&%!D6EFE9A!(#!(/5!'*).#.*/!*/,5!#2*!*0!#$%!#$&%%!'$()%)!(&%!*'%&(#.*/(,!)*!#$(#!#$%!1+&&%/#!./!#$%!#$.&3!'$()%!.)!G%&*6!!H*/).3%&!(!"I!%,%1#&.1(,!3%4&%%!./#%&?(,!I! ! ! !"I6!!7$%!#*&8+%!./'+#!0&*-!'$()%!J!.)!

! 7J!K!<#!LJ!)./ ! ;D6EFB>!

(/3!!

! LJ!K!FL7!2.#$!LM!K!I!

2$%&%! <#! K! NOP'O&O,! .)! #$%! #*&8+%! 1*/)#(/#! '%&! '$()%! ./! QF-6! ! N! .)! #$%! /+-9%&! *0! #+&/)! '%&!2./3./4A! &! .)! #$%! ./).3%!&(3.+)!*0! #$%!)#(#*&! ./!-%#%&)A!(/3!,! .)! #$%!(1#.?%!,%/4#$!*0!1*/3+1#*&)!./!-%#%&)6!!P'!.)!#$%!'%(:!(.&!4('!0,+R!3%/).#5!./!7%),()6!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!B@%!8+(,.05!#$%!?(,.3.#5!*0!#$.)!())+-'#.*/!,(#%&!2$%/!2%!3.)1+))!#$%!SL!1+&&%/#!,**')6!!!

11

Page 15: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

(Figure 4.3-3 Hall-effect Commutation Timing Diagram(

$%!&'%()*+!&%,-.-/+!.%'0)+1!.2+!34)5!(+6,-.7!8),.!9+!6+:;.-/+!3%'!&2;,+!$<!!$2-,!-,!.2+!*;,+!3%'!;!,-6),%-(;447!=%)6(!8%.%'!>,++!?-:)'+!@<ABA;CD!

! $$! E!F.!GH!,-6> IJ@KC! >@<ABJC!! E!F.!GH!>K<L,-6 IK<MM"*%, C!! 3%'!K! ! ! !"K!

$2+!.%.;4!.%'0)+!-,!:-/+6!97!.2+!;((-.-%6!%3!$$!;6(!$H!%/+'!.2+!-6.+'/;4!K! ! ! !"KD!

! $!E!$HI$$!E!F.>N<L,-6 IK<MM"*%, COGH! >@<ABAC!

P0);.-%6! @<ABA! ,2%=,! .2;.! .2+! +33+*.-/+! .%'0)+! *%6,.;6.1! F.>N<L,-6 IK<MM"*%, C1! *2;6:+,! ;,! ;!

3)6*.-%6!%3!'%.%'!;6:4+!&'%()*-6:!;!.%'0)+!'-&&4+!;,!8)*2!;,!NAQ!3%'!'+*.;6:)4;'!*%88).;.-%6<!!$2-,!.%'0)+!'-&&4+!*;6!9+!.'+;.+(!;,!;!(-,.)'9;6*+!=2-*21!-6!8%,.!&';*.-*;4!;&&4-*;.-%6,1!-,!'+()*+(!97!*4%,-6:!%).+'!/+4%*-.7!;6(!&%,-.-%6!4%%&,!;'%)6(!.2+!*)''+6.!4%%&<!(((

12

Page 16: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01!

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

(!

$%&%'!!()*+,-)./0!1-22+3/3)-*(4-5!/!2-3-5!6)37!,)*+,-)./008!6-+*.!,3/3-5!9-)0,!37:!/)5!;/<!=0+>!.:*,)3):,!/5:?!

!

! @A!B!@<!,)*!

! @(!B!@<!,)*C DE'FG! C$%&H$G!

! @I!B!@<!,)*C D'$FG!

!

J7:5:! @AK! @(K! /*.! @I! /5:! 37:! <:5! <7/,:! =0+>! .:*,)3):,! =-5! 37:! 2-3-5! <7/,:,! AK! (K! /*.! I!

5:,<:93)L:08!/*.!@<! ),! 37:!<:/M!L/0+:! )*!I:,0/%! ! N=!6:!/,,+2:!37/3! 37:!ON!9-*35-00:5,!/5-+*.!37:!

9+55:*3!0--<!2/)*3/)*!37:!<7/,:!9+55:*3,!)*!<7/,:!6)37!37:!/)5!;/<!=0+>!.:*,)3):,K!37:*!37:!9+55:*3!

)*!:/97!<7/,:!)*!3:52,!-=!37:!<:/M!9+55:*3!N<!/5:!;)L:*!P8!

!

! NA!B!N<!,)*!

! N(!B!N<!,)*C DE'FG! C$%&HQG!

! NI!B!N<!,)*C D'$FG!

!

45-2!:R+/3)-*!$%&H$!/*.!$%&HQK!37:!)*,3/*3/*:-+,!3-5R+:!P:)*;!<5-.+9:.!)*!:/97!<7/,:!),!

!

! IA!B!S3!N<!,)*' !

! I(!B!S3!N<!,)*'C DE'FG! C$%&H"G!

! IA!B!S3!N<!,)*'C D'$FG!

!

I7:!3-3/0!3-5R+:!),!37:!,+2!-=!37:!/P-L:!3-5R+:!9-2<-*:*3,K!67)97!),!;)L:*!P8!

!

! I! B!IADI(DII!

! ! B!S3!N<!C,)*' D,)*'C DE'FGD,)*'C D'$FGG!

! B!&T'!S3!N<! C$%&HUG!!

VR+/3)-*!$%&HU!,7-6,!37/3!W<:5=:93W!,)*+,-)./0!9-22+3/3)-*!-=!/!W<:5=:9308W!,)*+,-)./008!6-+*.!

2-3-5!<5-L).:,!=-5!/!5)<<0:!=5::!3-5R+:!9-*,3/*3%!!N*!<5/93)9:K!7-6:L:5K!/!,2/00!/2-+*3!-=!3-5R+:!

5)<<0:! 2/8! :>),3! .+:! 3-! )2<:5=:93)-*,! )*! 37:! 6)*.)*;,! /*.! 37:! 9+55:*3! 0--<! :0:2:*3,! /*.!

2),/0);*2:*3! -=! 37:! 5-3-5! <-,)3)-*! ,:*,-5%! ! X-3:! 37/3! =-5! 37),! 2:37-.! -=! 9-22+3/3)-*K! /! 7);7!

5:,-0+3)-*!/P,-0+3:!<-,)3)-*!,:*,-5!),!5:R+)5:.%!

!

!

$%&%&!!O5-<-53)-*/0!O0+,!N*3:;5/0!CONG!1+55:*3!Y--<!

V/97!<7/,:!-=!37:!2-3-5!6)*.)*;!9-)0!),!97/5/93:5)Z:.!P8!)3,!5:,),3/*9:!A!/*.!)3,!)*.+93/*9:!Y%!!N=!

6:! /,,+2:! 37/3! 37:! <:5H<7/,:! P/9M! :2=! -=! 2-3-5! ),! *:;0);)P0:! )*! 37:! 7);7! 3-5R+:! T! 0-6! ,<::.!

5:;)-*! -=! -<:5/3)-*K! 37:*! 37:! P0-9M! .)/;5/2! ,7-6*! )*!4);+5:! $%&H$! 5:<5:,:*3,! 37:! <:5H<7/,:!ON!

0--<!=-5!36-!-=!37:!375::!<7/,:,%!!CI7:5:!),!*-!*::.!=-5!ON!0--<!-*!37:!37)5.!<7/,:K!/,!37:!,+2!-=!

37:!3-3/0!9+55:*3!2+,3!P:!Z:5-!)*!/!,3/5!6)*.)*;!9)59+)3G%(

13

Page 17: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

!" ! #$

$%&'(

v

-

ic

1

T!%

Motor Admittance

ioPI Control Phase Winding

&

!Figure 4.3-4 Simplified Block Diagram of Analog PI Controller (applies to each motor winding phase)(

)*+&!+&!,!&-./01!/21-2!&3&4-5!6+4*!4*-!42,0&7-2!780.4+/0!

! !#'9&:#(9&:

!!;!!"<) &*'*!# <)

&=' +'!" ) &'*!# <)! 9>?@AB:!

*,C+0D!0,482,E!72-F8-0.3!

! ,!; *!#)* ! 9>?@A#:!

,01!1,5G+0D!2,4+/!

! !; *!"'+= !#)

*! 9>?@AB:!

H3!.*//&+0D! 4*-!,GG2/G2+,4-!C,E8-&! 7/2!!"! ,01!!#I!C-23!*+D*!J,016+14*&!7/2!.E/&-1!E//G!.822-04!94/2F8-:! 2-&G/0&-!5,3!J-!,.*+-C-1!9KLMM!NO:?! !P0!./5G,2+&/0!4/!4*-!,.*+-C,JE-!J,016+14*&!7/2!4*-!/84-2!C-E/.+43!,01</2!G/&+4+/0!E//G&I!4*-!J,016+14*!/7!4*-!.822-04!E//G!+&!D-0-2,EE3!,J/84!46/!/21-2&! /7! 5,D0+481-! D2-,4-2?! ! )*+&! 5-,0&! 4*,4! 4*-! .822-04! 94/2F8-:! 2-&G/0&-! +&! -&&-04+,EE3!+0&4,04,0-/8&!,01!4*-2-7/2-!+4&!130,5+.&!5,3!8&8,EE3!J-!+D0/2-1?! !Q/4-!,E&/!4*,4! 4*-!,11+4+/0!/7!4*-!+04-D2,4/2!*,&!5,1-!4*+&!.E/&-1!E//G!&3&4-5!,!43G-!/0-!&3&4-5?!!)*+&I!+0!4820I!2-&8E4&!+0!O-2/!&4-,13!&4,4-!-22/2!,01!,!80+43!RS!D,+0?!

(()*)( 34,%.-5#67.18(91:.'01/&1%!R+D+4,E!./042/E!+5GE-5-04,4+/0!+&!+04+5,4-E3!./8GE-1!6+4*!4*-!*,216,2-!,01!&/746,2-!4*,4!&8GG/24&!+4?!!Q/6*-2-!+&!4*+&!5/2-!,GG,2-04!4*,0!+0!4*-!,2.*+4-.482-!,01!4+5+0D!8&-1!4/!&8GG/24!4*-!C,2+/8&!1,4,!G2/.-&&+0D!2/84+0-&?!!T!6-EE!G2+/2+4+O-1!4+5-!58E4+A4,&U+0D!&.*-5-!+&!-&&-04+,E!4/!5,V+5+O+0D!4*-!G-27/25,0.-!,44,+0,JE-!72/5!4*-!G2/.-&&+0D!2-&/82.-&?!!!

)*-!G2+/2+43! &.*-5-!7/2!4*-!WSX!2-,EA4+5-!S/042/EE-2Y&!58E4+A4,&U+0D!-0C+2/05-04!+&! 4,J8E,4-1!+0!),JE-!>?>A$?!!)*-!*+D*-&4!G2+/2+43!4,&U!+&!4*-!42,Z-.4/23!8G1,4-!,01!&-2C/!E//G!.E/&82-!./5G84,4+/0!6*+.*! 4,U-&! GE,.-! ,4! 4*-! 5,V+585! 2,4-! /7! $?$@$![NO! 95+0+585! &,5GE+0D! G-2+/1! +&! M?MMMBB>!&-./01&:?!!P0!4*+&!.,&-I!4*-!8&-2!5,3!2-18.-!4*-!&,5GE+0D!2,4-!4*2/8D*!4*-!WV-.84+C-!X2/D2,5!C+,!.*,0D-&!4/!)&!+0!4*-!Setup Control Algorithm(1+,E/D!J/V?!!!

14

Page 18: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

2.3 Sensors

The sensor in this system, known as a Quadrature Encoder, is a digital encoder and thereforedoes not need a analog-to-digital converter (ADC). The encoder sends two channels of digital(High/Low) feedback to the controller. Using the A and B channel phasing, which are 90degrees phase shifted, to decode direction and detects the rising and falling edge of eachto generate 4x resolution. This added resolution can be seen in Figure 2.4 by analyzingone period of the A and B channel and noticing that it is possible to read four regions(High/High, Low/High, Low/Low, and High/Low).

Figure 2.4: Quadrature Encoder A and B channel outputs

Our encoders have 4000 Lines per revolution making the disk resolution 16000 encodercounts per revolution due to the 4x magnification and define this encoder gain as kenc. Formore details see the following pages which come from the ECP manual and the encoderFPGA code in the following chapter.

15

Page 19: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

$%&! '()*&+',(-! ./)00102! ')34!%)3! '%&! '%1(5!%12%&3'!.(1,(1'-!)05! 13! 3&(61+&5!)'!)!7)81797!()'&!,:!;""!<=>! !<&(&!'%&!.)()7&'&(3!:,(!)!0&?!'()*&+',(-!0&&5!0,'!@&!+)/+9/)'&5!&6&(-!'17&!'%13!')34!13!3&(61+&5! @-! '%&! (&)/A'17&! B,0'(,//&(>! ! C%&0&6&(! )! 0&?! '()*&+',(-! 13! (&D91(&5! E1>&>! '%&! +9((&0'!'()*&+',(-!13!0&)(!1'3!+,7./&'1,0F!'%13!')34!13!&8&+9'&5>!!$%&!/,?&(!.(1,(1'-!')343!)(&!3-3'&7!%,93&!4&&.102!(,9'10&3!10+/95102!3):&'-!+%&+43G!10'&(:)+&!)05!)981/1)(-!)0)/,2!,9'.9'>!!!

Table 4.4-1 The Multi-Tasking Priority Scheme of the Real-Time Controller!

3'.0'.%4( 5#67(8&69'.$%.01( :&';.9&(<'&=>&194(

H! I&(6,!J,,.!B/,39(&!K!B,77)05!L.5)'&! H>H!M<=!

N! $()*&+',(-!O/)00102! ;""!<=!

;! P)+42(,905!$)343!10+/95102!L3&(!Q0'&(:)+&G!R981/1)(-!SRB!L.5)'&G!J171'!+%&+43!&'+>!

!P)+42(,905!EQ0!'17&!@&'?&&0!,'%&(!')343F!

($%&!%12%&(!.(1,(1'-!')343!)/?)-3!.(&6)1/!,6&(!/,?&(!,0&3!10!,@')10102!'%&!+,7.9')'1,0)/!.,?&(!,:!'%&!SIO>! !$%13!79/'1A')34102!3+%&7&!13!(&)/1=&5!@-!!)!(&)/A'17&!+/,+4!?%1+%!2&0&()'&3!.(,+&33,(!10'&((9.'3>!!!!)*?( :&160'6!$%&(&!)(&!'?,!10+(&7&0')/!(,')(-!3%):'!&0+,5&(3!93&5!10!'%&!T,5&/!N#U>!!V)+%!%)3!)!(&3,/9'1,0!,:!W###!.9/3&3!.&(!(&6,/9'1,0>! !$%&3&!&0+,5&(3!7&)39(&!'%&!10+(&7&0')/!513./)+&7&0'!,:!'%&!7,',(!)05!'%&!/,)5!3%):'>!!$%&!&0+,5&(3!)(&!)0!,.'1+)/!'-.&!?%,3&!.(10+1./&!,:!,.&()'1,0!13!5&.1+'&5!10!X129(&!W>UAH>!!R!/,?!.,?&(! /12%'! 3,9(+&! 13! 93&5! ',! 2&0&()'&! '?,! Y#! 5&2(&&3! ,9'! ,:! .%)3&! 31093,15)/! 3120)/3! ,0! '%&!5&'&+',(3!)3!'%&!7,6102!./)'&!(,')'&3!?1'%!(&3.&+'!',!'%&!3')'1,0)(-!./)'&>!!$%&3&!3120)/3!)(&!'%&0!3D9)(&5!9.!)05!)7./1:1&5!10!,(5&(!',!2&0&()'&!D9)5()'&!/,21+!/&6&/!3120)/3!391')@/&!:,(!10.9'!',!'%&!.(,2()77)@/&!2)'&!)(()-!,0! '%&! (&)/A'17&!B,0'(,//&(>! !$%&!2)'&!)(()-!93&3!'%&!R!)05!P!+%)00&/!.%)3102! ',! 5&+,5&! 51(&+'1,0! )05! 5&'&+'3! '%&! (13102! )05! :)//102! &52&! ,:! &)+%! ',! 2&0&()'&! W8!(&3,/9'1,0! ! 3&&!X129(&!W>UAN>H! !$%&!.9/3&3!)(&!)++979/)'&5!+,0'109,93/-!?1'%10!NWA@1'!+,90'&(3!E%)(5?)(&! (&213'&(3F>! ! $%&! +,0'&0'3! ,:! '%&! +,90'&(3! )(&! (&)5! @-! '%&!SIO! ,0+&! &6&(-! 3&(6,! E,(!+,779')'1,0F! +-+/&! '17&! )05! &8'&05&5! ',! WZA@1'! ?,(5! /&02'%! :,(! %12%! .(&+131,0! 097&(1+)/!.(,+&33102>! !$%93!'%&!)++979/)'1,0!,:!&0+,5&(!.9/3&3!.(,615&3!)0!)029/)(!.,31'1,0!7&)39(&7&0'!E3120)/F!:,(!'%&!3&(6,!(,9'10&3>!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!HQ>&>!'%&!5134!&0+,5&(!(&3,/9'1,0!&::&+'16&/-!@&+,7&3!H[G###!+,90'3!.&(!(&6,/9'1,0>!

16

Page 20: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

!

Figure 4.5-1 The Operation Principle of Optical Incremental Encoders((

!

!

!

Figure 4.5-2. Optical Encoder Output((

!!!

17

Page 21: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

ecp !"#$%&'()*((+&#, -%./&(!01%'0,(2/$,&/&1%#%.01 !

© 1991-1999 Educational Control Products. All rights reserved.!!

"#!

)*3( 456.,.#'7(41#,08(95%$5%(:;7<%&/(9$%.01=!!$!%&%'()!*+',*-!+.*/,0(%!'1*!2-23*4!*5'+5'!672--(3%!,-!'7(!8*-'.*3!9*:!17,67!2.(!6*--(6'(0!'*!'1*!;<=>,'!?$8%!17,67!+7&%,6233&!.(%,0(!*-!'7(!.(23=',)(!8*-'.*33(.@!!A267!2-23*4!*5'+5'!72%!'7(!.2-4(!*B!CD=!;E!/*3'%!F=G#"<H!'*!CG#"<"!6*5-'%I!1,'7!.(%+(6'!'*!'7(!2-23*4!4.*5-0@!!J7(!*5'+5'%!*-! '7(%(! ?$8%! 2.(! 5+02'(0! >&! '7(! .(23=',)(! 8*-'.*33(.! 2%! 2! 3*1! +.,*.,'&! '2%K@! ! L*1(/(.M! B*.!/,.'5233&!233! '.2N(6'*.,(%! F(@4@! B*.! %,-(!%1((+!5+! '*!2++.*:@!#O!LPI! '7(!5+02'(! .2'(!,%!%5BB,6,(-'3&!B2%'! B*.! 2-! *%6,33*%6*+(! *.! *'7(.! 2-23*4! (Q5,+)(-'! '*! ,-%+(6'! '7(! /2.,*5%! ,-'(.-23! 8*-'.*33(.!%,4-23%@!!R((!'7(!%(6',*-!*-!'7(!A:(65',/(!S.*4.2)T%!Utility!)(-5!B*.!'7(!2/2,32>3(!%,4-23%!'*!*5'+5'!*-!'7(%(!?$8%@!!!((!(!(!

18

Page 22: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

2.4 Hardware Loop

Now combining a controller block along with all that was described in the previous sectionswe get the hardware loop in Figure 2.5.

C kdac kh P kencr e u v u y y

yP

Figure 2.5: Hardware Loop

The notation “hat” refers to the variable in the software such the variable y, angle,would be in radians but after it has entered the computer through the encoder it be-comes y in encoder counts. Also notice that the command u, torque, is the output ofthe amp/motor/pulley (kh) while u is the desired command from the controller in torquecounts before it inters the DAC. When implementing the algorithm, C needs to be codedin the computer. There are two recommended methods to simulating the system and thenimplementing and are described as follows:

2.4.1 Simulation and Implementation Method I

The “real” plant P (toque to radians) can be combined with the other gains, as shown inFigure 2.5, to form P (torque counts to encoder counts) giving the loop shown in Figure 2.6.

C Pr e u y

y

Figure 2.6: Simulation and Implementation Method I

It is now easy to design, simulate, and implement directly C.

2.4.2 Simulation and Implementation Method II

The second method is to design a controller C based on the “real” plant P as shown inFigure 2.7.

After design and simulation, the controller C, must be converted to C before coding intothe computer by:

C =C

kdackhkenc

19

Page 23: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

C Pr e u y

−y

Figure 2.7: Simulation and Implementation Method II

2.5 System Specifications

The following data was inlcuded in the ECP Model 205 Documentation listing the valuesfor the system parameters described in this chapter. The class will spend time verifying orestimating these parameters and it is important to note that many of these parameters willchange:

Parameter Value

Disk Inertia (each) 0.0019 kg-m2

Motor/Drive Inertia 0.005 kg-m2

Weights (each) 0.5 kgSpring Constant (each half) 2.7 Nm/rad

Pulley Magnification kp 3 Nm/NmDrive Motor Torque Constant km 0.086 Nm/A

Drive Motor Amplifier Current Gain ka 1.5 A/VEncoder Resolution kenc 4000 lines per Rev (or 16000 counts/rev)

DAC Resolution kdac 10 Volts per 32767 counts

Table 2.1: Values of system parameters described in the previous sections of this chapter

2.6 Disturbances and Nonlinearities

The hardware system can be modeled as an ideal system of coupled second order systemsbut we will find through out this course that we are making certain assumptions. Here area few disturbances/nonlinearities that will present themselves in the experiments:

1. Friction in the motor and pulleys

2. Amplifier nonlinearities

3. The commutation of the brushless motor has a Torque Ripple of up to 13%

4. vibration

5. sensor noise

6. actuator/amplifier saturation

20

Page 24: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Chapter 3

Software

The implementation of the controller is a combination of two sources of code and both arewritten in LabVIEW. The main control algorithm is written in a “Simulation Loop” onthe computer while the calculation of the encoder counts (from the A and B channels asdescribed in the previous chapter) and the output to the DAC is performed by the FieldProgrammable Gate Array (FPGA). In our case, think of the FPGA as a processor thatperforms simple tasks very fast. Note (especially instructor) that the control loop runningon the computer, running windows, is not a “real-time” task and will deteriorate the controldue to jitter as the sampling rate increases. At a rate of 100 Hz it is not necessary to runthis control algorithm on a real-time processor, but if fast rates are desired in the futurethan acquiring hardware (such as the SB-RIO) which has both an FPGA and a real-timeprocessor would be advised.

The following sections describe both the environment where the controller will be coded,running on windows, the FPGA code (although students have no access to this code sincecommunication between hardware and computer need not be altered unless hardware changes),and some programs used in system identification.

3.1 Main LabVIEW Interface

The main LabVIEW code where the controller is added is shown in Figure 3.1. Notice thatthere are 3 parts that make up this this code:

1. FPGA Initialization

2. Control Loop

3. Close FPGA

The following figures take a closer look at each of the three parts, starting with Figure 3.2.The important code segments are labeled with capital letters and their uses are described inthe following list.

21

Page 25: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Figure 3.1: Main LabVIEW Interface Code for the TDS

Figure 3.2: Part 1 of Main Interface Code

A.) The name of the FPGA

B.) Open the FPGA compiled file

22

Page 26: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

C.) Download onto the FPGA

D.) Start the FPGA

E.) Set the Encoders to zero

The second part, of which the controller is coded, is shown in Figure 3.3. The important

Figure 3.3: Part 2 of Main Interface Code

code segments are labeled with capital letters and their uses are described in the continuedlist.

F.) Define the sampling rate of 100 Hz (see Figure 3.1)

G.) The space where the control code will be place, in between the encoder outputs (Feed-back) and the voltage input (Controller command)

H.) You should always stop the simulation loop using the ABORT button

I.) The program stops if the angle between the 1st and 2nd disk or the 2nd and 3rd is toolarge (defined value shown is 650 counts)

Make notice of location G where the controller will be coded.Finally the FPGA is closed and a voltage of 0 is sent to the DAC, all of which are

implemented in the last part of the code (Figure 3.4) and the list continues.

J.) When the program is ABORTED, by the user, or KILLED, due to the relative anglerestriction, the voltage output is set to zero counts

K.) Close FPGA file

23

Page 27: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Figure 3.4: Part 3 of Main Interface Code

Figure 3.5: FPGA Interface

3.2 Main FPGA Code (instructor access only)

Here you will find a description of the code that is running on the FPGA. In Figure 3.5 youwill find the interface to the FPGA variables accessible in the main LabVIEW code runningthe controller described in the last section.

You will see that along with the 3 encoder feedback and the voltage output, an encoderreset option, a deflection limit setting, and killswitch indicator. The deflection limit settingssets the limit of the relative degree difference between disks 1 and 2 and disks 2 and 3,which should be under 40 for this system, so as not to damage the torsional springs andthe killswitch indicator is set to “true” and the voltage output is set to zero when the therelative angle is greater than the set value.

24

Page 28: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

The main code behind the interface in Figure 3.5 is shown in Figure 3.6.

Figure 3.6: FPGA Main Code

The code portions are labeled with capital letters and the descriptions are listed as:

A.) The A and B channel of each encoder are read in to the FPGA

B.) The encoder counts are calculated using the A and B channels (see following section forcode)

C.) The results of the encoder counts are stored into the variables

D.) Deflection Limit and Motor Voltage variables are read

E.) The motor voltage is multiplied a negative so that positive Motor Voltage producespositive torque (could swap wires to get the same affect) and then sent to the DAC

25

Page 29: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

3.3 Encoder Count FPGA Code (instructor access only)

Item B of Figure 3.6 is a function that calculates the encoder counts. The code for thisfunction is shown in Figure 3.7.

Figure 3.7: FPGA Encoder Code

The details are itemized here:

A.) This is the main logic section of the code where +1 or -1 are added to the previousencoder count value.

B.) This code is a bit mysterious but it is believed that it is intended to prevent count errorswhen the system is stopped and is oscillating at an edge of the A or B channel.

3.4 Stiffness Data Acquisition (for System Identifica-

tion, instructor access only)

The code shown in Figure 3.8 is used to produce a angle versus voltage (proportional totorque by kh) to compare to the stiffness of the torsional spring.

If the stiffness is known, then kh can be calculated using this plot. Notice also that thisloop is not a simulation loop but a standard while loop. Omitted from the code is the firstand third parts of the main LabVIEW interface code which are necessary to open the FPGAcode and close the FPGA coed. The code is labeled and described by the following list:

26

Page 30: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Figure 3.8: Code to collect stiffness data

A.) A vector of command voltage to the amplifier is defined between ±2000 counts (thisvalue makes sure that the command is less than 1 Volt command to the amplifier)

B.) The ith element of the array is sent to the DAC

C.) Wait 3 seconds so system is at steady-state

D.) Record encoder count

E.) Plot

F.) Save to array and save to file

27

Page 31: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

3.5 Free Response Data Acquisition (for System Iden-

tification)

The code shown in Figure 3.9 collects response data when a student rotates disk 1 or 3 (whiledisk 2 is clamped) for parameter identification.

Figure 3.9: Code to collect free response data

The following list describes the code:

A.) Scales the x-axis of the plot to match “time”

B.) Voltage to the motor is set to zero

C.) Set the length of record time in samples

D.) Set sampling rate (using “wait” function) to 100 Hz

E.) Save to array and save to file

28

Page 32: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Appendix A

Safety Hardware Warnings!

The following safety points come mainly from the ECP Model 205 manual found in thefollowing page.

1. Never turn on the amplifier without a lab member holding a finger on the amplifierOFF switch

2. Never turn on the amplifier while the middle disk is clamped

3. The peak rating of ±10 Volts to the amplifier should not be exceeded (need to have asaturation block in code)

4. RMS amplifier current command should not be more than ±3.5 Volts

5. At stand-still (motor stalled) the RMS amplifier current command should be limitedto ±1 Volt

6. Make sure that weights are securely fastened before powering amplifier

7. Keep clear of torsional system during experiments so clothing and or hair doesn’t getcaught

8. Always use the “ABORT” button rather than stopping the LabVIEW code so thatthe output voltage to the motor gets set to ZERO. If you STOP the code, than thelast commanded voltage will stay and the system will spin out-of-control! (hence alabmate’s finger on the amplifier OFF switch)

29

Page 33: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

1

This document provides the pertinent information of Model 205 (2 Disk Torsional) and Model 205a ( 3 Disk Torsional) apparatus when shipped as "plant only" without the ECP Controller.

The following points should be carefully read and understood prior to operating the mechanism:

1. It is the user's responsibility to provide the +/- 10 volts current Command Signal(s) to the motor amplifier. This signal should be brought into the Control Box through the inputs marked "DAC". Connect the return signal to the input marked "DAC/". For systems with Model 205-d option DAC1 is the Drive Motor input and DAC2 is the Disturbance Motor input.

2. It is the user's responsibility to adhere to the amplifier(s) current rating by limiting the current Command signal to +/- 10.0 volts peak. The peak rating should not be exceeded for more than 1 seconds in a period of 60 seconds. The RMS current command should not be more than +/- 3.5 volts. At stand- still (motor stalled) the RMS current command should be limited to +/- 1.0 volts

3. It is the users responsibility to provide the +5 volts power to the encoders and accept the standard A QUAD B signals from each encoder.

4. Make sure that the clamps on the disks are removed prior to motor actuation.5. Do not twist one end of the flexible shaft (torsion rod) more than 40 degrees with respect to

the other end.6. Please read the WARNING notes below and pay attention to the CAUTION note on the

mechanism.

FUSES:

There is a 3 A slow blow fuse inside the fuse holder at the back side of the amplifier box. In addition, another 3 A slow blow fuse is installed on the amplifier chassis.

WARNING #1: To replace either of the fuses you MUST positively DISCONNECT the power cord from the amplifier box. To avoid electric shock, the power cord must not be attached to the Amplifier Box whenever its cover is removed.

WARNING #2: DO NOT apply power to the amplifier box (i.e. supply power to motor) unless you have made sure that the weights are securely fastened. This check must be made every time the mechanism is to be activated. WARNING #3: When power is applied to the motor stay well clear of the mechanism at all time and make sure that loose clothing and hair are kept well clear of the mechanism.

ECP Model 205 With A51 “Plant Only-NI” Documentation

© 1993-2006 Educational Control Products. All Rights Reserved30

Page 34: ECEE4638 Control Systems Lab Manual - University of ...ecee.colorado.edu/shalom/ecee4638/ecee4638manual.pdf · University of Colorado Electrical, Computer, and Energy Engineering

Bibliography

[1] T.D. Murphey and J. Falcon. Programming from the ground up in controls laboratoriesusing graphical programming. In Proceedings of the IFAC Advances in Control Education(ACE), 2006.

[2] L.Y. Pao, J.A. Butterworth, and D.Y. Abramovitch. Combined feedforward/feedbackcontrol of atomic force microscopes. In American Control Conference, 2007. ACC ’07,pages 3509 –3515, july 2007.

[3] Iven Mareels Pedro Albertos. Feedback and Control for Everyone. SpringerBerlin Heidelberg, 2010. Note: From CU this book can be accessed athttp://www.springerlink.com/content/978-3-642-03445-9/contents/.

31