You are on page 1of 14

CHAPTER3

SYSTEM SI
MULATI
ONANDCONTROLDESI
GN

I
nt hischapter,thequadcoptermodel ,whi
chisformulatedusi
ngphysi
calsyst
em
parametersanddy namicsequat i
ons,wil
lbedesignedinSoli
dworks2018and
i
mpl ement edinMat l
abSimul i
nkenv i
ronmentbyusingSi mMechani
csLinkuti
l
itywhi
ch
l
inkMat labSi muli
nkwi t
hCADpr ogram.TheSimul i
nkmodelisusedforopenloop
testi
ng,verif
icat
ionandcontrollerdesi
gn.

3.
1Sol
idWor
ks

Soli
dWor ksiscomput erai dedengi neer i
ng( CAE)andcomput erai deddesi gn( CAD)
softwar
eappl icat ionwi thrunsofWi ndows.Thesof twarehasv eryadv ancedesi gni
ng
capabil
i
tiesint hef i
elddoaer ospaceandr obot i
cs.Itisoneoft hemostwi delyused
softwar
e by engi neersf rom v ari
ous f ield whi ch included,aer ospace,r oboti
cs,
mechanicalengi neer i
ng,civ ilengi neeringandsoon.Tobui l
dt hev i
rtualsimulati
on
envir
onmenti nMATLABandt heCADmodel forquadcopt erf orthecont roll
ingpurposes,
Soli
dworks2018wasusedf ordesi gningpr ocess.Whent hemodelwasf i
nali
zed,itwas
thenusedwi tht hecont r
olofquadcopt erbyi ntegrati
ngitwi thMATLAB/ Simuli
nk.When
theCADmodeloft hequadcopt erisi ntegratedi ntoMATLAB/ Simul i
nki tcreatesthe
completecont rolmodelf ort hequadcopt erandal lthedy nami csequat ionsar ederiv
ed
automatical
l
y .Al though,t hi
sav eryusef ultechni quetobui ldcont r
olsf oraquadcopt er
,
i
tsomet i
mesgi veser rorifthemodeli snotcor rectl
ydefinedi nSolidwor ks.Therewer e
acoupleofi nst anceswhent heCADmodelwasi ntegr
at edwi thMATLAB/ Simulinkit
wronglyderivedt hemot orsandpr opel l
ercont r
ols.Thiswasduet hedef i
niti
onwas
wronglydefined i nt heCAD model .Fur t
her mor e,thev irt
ualenv i
ronmentwasal so
i
ncludedwi t
ht heCADmodelr athert handesigningitseparatelyagai
ninMATLAB.To
startwith,aCADmodelwasdesi gnedi nSolidWorksfort hequadcopterUAVhaving
precise physicalparameter
s.Thi s al l
owed us t o extracti nf
ormati
on aboutthe
quadcopt erdynamicsandcont r
ol.Italsohelpedust ounderstandhowmuchpowerwas
requiredbythemot ortorot
atet hepr opell
er,whichgaveusani deaofthebat
ter
yneeds
tobeused.TheCADmodel lingdesi gningoft hequadcopt erwasdonei nSoli
dWorks.
Figure3-1showst hecompl etemodeloft hequadcopt er.Othercomponentscanbe
seeni nAppendi xB.
Fi
gur
e3-
1:CADmodelofquadcopt
erbui
lti
nSol
idWor
ksf
orv
irt
ualsi
mul
ati
onenv
ironment

3.
2MATLAB&Si
mul
ink

Thi
spar toftheproj
ecti
sbasedonsimul
ati
onthequadcopt
eri
nvi
rtual
envi
ronment.To
dothis,
MATLABSi muli
nkweresel
ect
edtodesi
gnthecontr
olf
ort
hequadcopterhavi
ng
avi
rtualsimulat
ionenvi
ronment
.

3.
2.1MATLAB

Mat l
ab (Matr
ixLabor atory)isamul ti
-paradigm numer i
calcomput i
ngenv ironmentand
fourth-
generat
ion pr ogr ammi ng language. A pr opri
etar
y pr ogrammi ng l anguage
dev el
opedbyMat hWor ks,MATLABal l
owsmat r
ixmanipulati
ons,pl ott
ingoff unctions
anddat a,impl
ement ationofal gori
thms,creationofuserinterfaces,andi nterfaci
ngwi th
programswr i
tt
en in ot herlanguages,i ncluding C,C++,Jav a,For tr
an and Py thon.
AlthoughMATLABi sint endedpr i
maril
yfornumer i
calcomput i
ng.Anaddi ti
onal package,
Simul i
nk,addsgraphicalmul tidomainsimul ationandmodel -
baseddesi gnf ordynami c
andembeddedsy stems.TheMATLABappl i
cat i
onisbuiltaroundt heMATLABscr i
pt i
ng
l
anguage.Commonusageoft heMATLABappl i
cati
oni nvolvesusi ngt heCommand
Windowasani
nter
act
ivemat
hemat
icalshel
lorexecut
ingt
extf
il
escont
aini
ngMATLAB
code.

3.
2.2SI
MULI
NK

Simulinki sdev el
opedbyMat hWor ks,isagr aphicalpr ogr
ammi ngenv i
ronmentf or
model li
ng,simul ati
ng and anal yzi
ng mul t
i-
domai n dy namic systems.I ts primar y
i
nterfacei sa gr aphi calbl ockdi agrammi ng tooland a cust omizablesetofbl ock
l
ibrari
es.”Itofferst i
ghti ntegrat i
onwi tht herestoft heMATLABenv ir
onmentandcan
eit
herdr i
v eMATLABorbescr iptedf r
om i t
.Simulinkiswi del
yusedi nautomat i
ccont rol
anddi gitalsi
gnalpr ocessi ngf ormul ti
-domai nsimul at
ionandModel -BasedDesi gn.
Mat hWor ksandot hert hir
d- partyhar dwar eandsof twareproductscanbeusedwi th
Simulink.Forexampl e,st ate-fl
ow ext endsSi muli
nkwi th adesign env i
ronmentf or
developing statemachi nesand f l
ow char t
s.Mat hWorkscl ai
mst hat,coupled wi th
anotheroft heirproduct s,Si mul i
nkcanaut omat i
callygenerateCsour cecodef orreal-
ti
mei mpl ement at
ionofsy st ems.Ast heef fi
ciencyandf lexi
bil
it
yoft hecodei mprov es,
thi
si sbecomi ngmor ewi del yadopt edf orproductionsy stems,inadditiont obeinga
toolforembeddedsy stem desi gnwor kbecauseofi tsfl
exibi
li
tyandcapaci tyforquick
i
terati
on.

3.
3Const
ruct
ionofSi
mul
ati
onModel

Thesi mulationmodeli sbui l


tinst ages,t hatis,atfirstsol id,sur face,orhy bridmodeli s
createdbyCADpr ogram( SolidWor ks).Anassembl yofel ement scanbeusedsol elyfor
si
mul ati
onst udiesbecausei nsuchcasest hereexistsani nteractionbet weeni ndivi
dual
parts,whichi nt ur nmakesi tpossi bl etoi ntroducet hecont rolsy stem andper f
orm
mot i
onanal ysis.Ther efore,eachcr eat edsi mulationmodeli sanassembl yofmany
i
ndiv i
dualpar tsorsub- assembl ies.Fori nstance,thesampl eCADmodelpr esentedi n
Fi
gur e 3-1 consi stsof :3 assembl iesand 62 par ts,butt heseassembl i
esi nclude
subsequentassembl i
esorpar ts,et c.Bui ldingofeachpar tofgeomet ricmodeli n
Soli
dWor ks, simi lartot heonesmostcur r
ent l
yusedf orthi ski ndofappl i
cat ions, begins
withdef i
ninga2Dgeomet rythatcr eatesasol idorasur faceaf tercompl etingoneof
numer ous oper at i
ons ( e.g.ext rusi
on orpocket ).Then,based on expansi on or
modi fi
cati
onoft heobt ainedel ementmadebyr emov ingoraddi ngmat erial,thecr eat i
on
ofpar t
siscont inued.Themaj orityofCADsy stemsof fernor mal i
zedel ement st hatcan
beusedt obui ldassembl ies.Thepr oductt hatist her esul toft hef inalassembl yof
component shasaper manentl i
nkt ot heindividualpar tfiles, whichmeanst hatchanges
madei noneoft hef i
lesar eaut omat i
callyascr i
bedt ot hel inkedf iles,respect ively
.The
producthav ei tsowngeomet ry.Geomet ricalmodel scanbeusednotonl yf ort he
constructi
onoft hesi mul at i
onmodel ,butinav erysi mpl ewayt heycanbeut i
li
zedt o
carryoutot hert y pesofanal ysis, suchasdy nami canal ysis.I nthiscase, thecal cul
at i
on
modelwhi cht akesi ntoaccountcont actconnect ionsandboundar ycondi tionsshoul d
bewor
kedout
.

Thenextst
ageofbui
l
dingthesi
mulat
ionmodelistheimplement
ati
onoft
heCAD
assembl
ymodeli
nMat l
ab/
Simuli
nkenvi
ronment(Fig.
3-2)
.

Fi
g.3-
2.I
mpl
ement
ati
onpr
ocessofCADmodeli
nMat
lab/
Simul
inkenv
ironment

Fort
hispur
poseCADsoft
wareandMatl
ab/Si
mul
i
nk,
theSi
mMechani
csLi
nkut
il
it
yhas
tobei
nstal
l
edandli
nkedt
otheCADprogr
am .

Conver
ti
ngt hemodel i
ntoSimMechanicsisveryusefulbecause;
 I
tsimpl i
fiest hebuil
dingupofdy namicsyst
em.
 I
tcani ntegr atewit
hot herphy
sicalmodeli
nglibr
ariesautomati
cal
ly
.
 Wedon’ thav eto der i
vetheequat i
onsf orelectr
onicssystem,equat
ionsof
motion,et c.
 I
tcreatest hecompl etemodelforusv er
yquickl
yandeasi l
yandwecanopt imi
ze
i
twher e
neededwhi chcanal sobedonev eryeasi
ly.

Thef i
rstst epofi mpl ement ati
onpr ocessi st ouset heSi mMechanicsLi nkexpor terto
createPhy sicalModel ingXMLf il
ethatincludesi nfor
mat i
onaboutthemassandi nerti
a
ofeachpar toft heassembl y,def i
nit
ionsofconst r
aintsbetweenpar ts,aswellasaset
ofSTL( stereolithographic)f i
lesforr epresenti
ngsur f
acegeometriesoft heassembl y
bodies.Thesecond st ep isi mpor toft her eceived fi
lesint
ot he Mat lab/Simul i
nk
program andgener at
ionofaSi mMechani csmodel .TheSi mMechani csmodel ,obtained
i
mmedi atelyaftert hei mplement ation,includesabl ockscheme( Fig.3-3)andal lows
onlyv i
sualizingmechani sm ormachi ne(Fig.3-4),withoutapossibili
tyofcarry i
ngout
simulati
on r esear ch.Onl yr arelyiti sopt imal,and does requir
e modi f
icat
ions l i
ke
remov i
ngunnecessar yconst r
aintsbet weenel ement soft hemodelorchangi ngt hei
r
types
Fi
g.3-
3.Asampl
eSi
mMechani
csbl
ockdi
agr
am

Fi
g.3-
4.Vi
sual
izat
ionofasampl
eSi
mMechani
csmodel

3.
3.1Mot
orCont
rolModel
ing:

Thequadcopt erachievedesiredmot i
onthroughcont roll
i
ngt herotors.Ther ot
oris
mainlyaBr ushlessDCmot or(BLDC)andapr opel
ler.Thequadcopt ermotorhasits
owncont r
olsy st
em throughtheelectr
oni
cspeedcont roll
er(ESC).Themot orrecei
ves
an inputand i s expect
ed to produce a cer
tain outputregardl
ess ofi t
s contr
ol
mechani
sm.

Fi
gur
e3-
5:BLCDMot
orModelf
or

3.
3.2Mot
orMi
xer
:

Thepurposeofmotormixerblocki
stodeter
minethemotorsinputandt
hust
herotati
on
speedforeachmotoraccor
dingtowhicht
herequi
redt
hrustandmomentsaregenerat
ed
achi
evi
ngthedesi
redatt
it
udeandalt
it
ude.

Fi
gur
e3-
6:Si
mul
inkModelofaMot
orMi
xer
3.
3.3OpenLoopSi
mul
ati
on:

Thissimul
ati
onmethodisusedtover
ifyt
hatthesyst
em buil
tinSi
mul
i
nki
swor
kingand
respondi
ngasexpect
ed.Gener
all
yiti
sthefi
rstst
epinveri
fi
cati
on.

Per
for
mingopenl
oopSi
mul
ati
onl
eadst
othef
oll
owi
ngobser
vat
ions:

 Changingthet
hrustofeachmot
orequal
l
yonl
ychangest
heal
ti
tudeoft
he
quadcopter
.

 Thus,hov
eri
ngcondit
ionresul
tswhenthetot
alt
hrusti
sequalt
othequadcopt
er
weight
.Hover
ingcondit
ioncanbeexpr
essedbyt
hef ol
l
owi
ngequati
on:

 Whenthetot
althrustisequaltothequadcopterweightandtworot
orsofthe
samedi
agonalr
otatefast
ertheothert
worotor
s; onl
ytheyawangl
echanges.

 Whenchangi
ngther
ollandpi
tchangl
es;thesyst
em osci
l
lat
esandget
sunst
abl
e
duet
ononli
near
it
yandabsenceofthecontr
oll
er.

Theseobser
vat
ionscompl
ywi
tht
hemat
hemat
icalmodelder
ivedandt
husf
ir
stst
epi
n
ver
ifi
cat
ioni
sachiev
ed.

3.
3.4Cont
rol
lerDesi
gn:

Thequadcopt erisunderact uatedsy stem whi chhasf ourcont roli nputsandsi xDOF.
Whilequadcopt ercanmov ei nverticalaxeswi thoutchangi ngirrelevantstates,itneeds
tochangeat t
it
udewhenmov inginxoryaxes.Thecont rolsystem consi stsoft womai n
l
oops;i nnerloop,whi ch correspondst o or
ientation cont r
ol,and out erloop whi ch
corr
espondst ot heposi ti
oncont r
ol.Themai ni nnerloopconsi st
soft wocascaded
l
oopsaswel l
;onel oopf ortrackingt heangul arr ateandanot herl oopf ortrackingthe
angle.Theinnerloopmustbeatl eastt entimesf ast erthantheout erloop.Speci fi
crol
l
andpi tchangles,whi char ecalcul atedaccor dingt odesi r
ed( x,y )coordinates,are
compar edtot heact ualanglesmeasur edbyi nerti
almeasur ementuni t(IMU)oft he
syst
em.I ntheout erl oop,theact ualposi ti
oni scompar edtot hedesi redposi ti
onand
thusiscalcul
ated. Thecont rolinputv ectorcomponent sasshowni nequat i
onser veas
i
nput stothecontrol system asshowni ntheFigure
Fi
gur
e3-
7:Si
mpl
if
iedCompr
ehensi
veSy
stem Cont
rol

3.
3.5Al
ti
tudeCont
rol
:

Theactualquadcopteral
tit
udeismeasuredusingbarometersensor
.Thi
smeasured
al
ti
tudeist
hencompar edtothedesi
redal
ti
tude.Theer
rorobtai
nedisf
edtot
heal
ti
tude
contr
oll
ert
ogenerateU1signal
.

Fi
gur
e3-
8:Al
ti
tudeCont
rol
ler

Fr
om equat
ion:

3.
3.6At
ti
tudeandHeadi
ngCont
rol
:

OnceU1i scalcul
atedbytheout
erloop,t
hei
nnerl
oopcommandsshoul
dnow be
cal
cul
ated.Si
ncethemovemental
ongxandyaxesi
scont
rol
l
edt
hroughrol
landpi
tch
angl
es.I
nreal
appl
i
cat
ions,
thi
sisdonev
iat
her
adi
ocont
rol
.

Fi
gur
e3-
9:At
ti
tudeandHeadi
ngCont
rol
ler

Fi
gur
e3-
10:
Simul
inkModelf
orTr
ansl
ati
ngPosi
ti
on(
x,y
)toPi
tchandRol
lAngl
es

3.
3.7Si
mpl
if
iedPI
DCont
rol
ler

Gener all
ythissimplif
iedschemeofcont r
oll
ergeneratessignalsdependingont heerror
bet weent heact ualand desired st
ate.I nthi
st hesis,PID contr
ollerissel ected to
stabil
izethequadcopt erbecauseiti
si ntui
ti
vetot uneandeasyt oimplementi ncode
withlitt
leprocessingpower .PI
Dcontroll
erhasthreet unabl
egains;proporti
onal gainKp,
i
nt egralgainKIandder i
vat
ivegai
nKD.I tcanber epresentedwiththef ol
l
owi ngt r
ansfer
function:
Thepr opor ti
onalt erm Kpi sdi rectl
ypr opor tionaltot heer ror,i
ncreasingi twil
lincrease
the r i
se t i
me,i .e.maki ng the sy stem r esponse f aster .The I ntegralterm KIi s
propor ti
onaltot hesum oft heer rorv al uesaccumul at
edov ert i
me;t hi
ser roroften
represent sadi st urbance( wind,model i
ng er ror
s,et c.).I ncr
easing KIwi l
ldecr ease
steadyst at
eerroroft hef eedbacksy stem,howev er,thist ermi nt
roducesapol eatt he
originoft heS-planewhi chmi ghtmaket hesy stem osci l
lateandev engounst abl
e.The
der i
vatieKDt
v ermi samul ti
pleoft her ateofchangeoft heerror.Itisusedt or educe
theov ershootandmaket hesy st
em r esponsesl ower .KD act sasadamperwhi ch
all
owst heuseofl argerKP v al ueandr esultsini mpr ovingst eadyst ateperformance
.SinceKD i sactingont heder ivat
iveoft heer ror,andnott heerrori t
self,i
tisal ways
usedi ncombi nationwi hKpandKI
t .

Fi
gur
e3-
11:
Simpl
if
iedPI
DCont
rol
ler

Therearev ari
ousmet hodst otunePI D contr
oll
eranddeter
minethebestv al
uesof
contr
olgains.I
nt hi
sthesi
s,thevaluesarefir
stdeter
minedf
orsimul
ati
onpurposesand
thenver
if
iedont heactualsy
stem.

3.
3.8Ov
eral
lSy
stem Cont
rolandr
esul
t:

Thefullautopil
otcont
roll
erisobtai
nedbycombini
ngall
previ
ouscont
rol
l
erst
ogetheri
n
asingl
edi agram (
subsystem).Thesecont
rol
l
erscancontai
nanyty
peofcont
rol
al
gorit
hms.
Fi
gur
e3-
11:
Quadcopt
erUAVSi
mul
inkModel
sSubsy
stems

Fi
gur
e3-
12:
Simul
ati
onr
esul
tinMat
labSi
mul
ink
X-
axi
s Y-
axi
s

Al
ti
tude Rol
l
ing

Pat
chi
ng Yawi
ng

You might also like