0% found this document useful (0 votes)
265 views

Servo Control - MATLAB & Simulink Example PDF

K Support Package for Arduino(r) hardware to control a standard servo motor. Can be run on any of the borad listed in the "Supported get Hardware" parameter in the configuration parameters of the model.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
265 views

Servo Control - MATLAB & Simulink Example PDF

K Support Package for Arduino(r) hardware to control a standard servo motor. Can be run on any of the borad listed in the "Supported get Hardware" parameter in the configuration parameters of the model.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

kSupportPackageforArduinoHardwaretocontrolastandardservomotor.

a2560_servocontrol_sweep

rArduinoMega2560andcanberunonanyoftheboradlistedinthe"Supported
getHardware"parameterintheconfigurationparametersofthemodelas

ardwareenablesyoutocreateandrunSimulinkmodelsonArduinoboard.The
ksforconfiguringandaccessingArduinosensors,actuatorsandcommunication

ateSimulinkmodelthatcontrolsastandardservomotor.Inastandardservo
yset,usuallybetween0and180degrees.Servomotorsareusedinmany
tionsandproducts.

tedwithArduinoHardwareexample.

lowinghardware:

ortedArduinoHardware

boardisnotArduinoMega2560hardware.

forthesupportedArduinoboard.

RunonTargetHardware>Options....

pageopensup,settheTargethardwareparametertoyourrequiredArduino

eArduinoBoard

otheArduinoboard.Servomotorshavethreewires:power,ground,andsignal.

tothe5Vpin.

ck)tothegroundpin.

ge)todigitalpin4.RefertoPinMappingonArduinoBlocksinthedocumentation

viaanInternalSource
servomotorshaftusinganinternalsource.Theshaftanglewillvarybetween0

ck.Theblocksetsthenewangleoftheservomotorshaftevery0.01second.

RunonTargetHardware>Options.

pageopensup,settheTargethardwareparametertosupportedArduino
mputer.Donotchangeanyothersettings.

oyToHardwarebuttononthetoolbar.

Arduinoboard,observethemotorshaftpositionsweepingbetween0and180

ionviaaPotentiometer

servomotorshaftmanually,usingapotentiometer.Connecttheouter
pinsonyourArduinoboard.Connectthemiddleterminaltoanaloginputpin0.As
ncechanges.Asaresult,thevoltageattheanaloginputpinchangesaswell.Your
ortionaltothisvoltage.

SimulinkModel.

pt.ThisopenstheSimulinkLibraryBrowser.
SimulinkSupportPackageforArduinoHardware>Common.

model.DoubleclicktheblockandsetthePinnumberto0,andtheSampletimeto

intothemodel.DoubleclicktheblockandsetthePinnumberto4.
ndardServoWriteblocks.

y,dragtheGainblockintothemodelanddropitonthelineconnectingtheAnalog
ck.DoubleclicktheGainblockandsetitsvalueto0.1760(maximumservomotor
loginputdigitalresolutioni.e.180/1023).

RunonTargetHardware>PrepareToRun....

pageopensup,settheTargethardwareparametertosupportedArduino

ployToHardwarebuttononthetoolbar.Themodelwillnowbedeployedtothe

duinoboard,observethemotorshaftsweepingbetween0and180degrees.

sdescribedabove,youcanusetheServoControlmodel.

ionviaaPhotocell

etsthepositionoftheservomotoraccordingtolightintensitydetectedbya
shouldbepositionedat0degrees,whileinabrightroomitshouldbepositioned

thepotentiometeryouusedinTask4.Connectoneendofthephotocelltothe5V
oneendoftheresistortotheGNDpinontheboard.Connecttheotherendsofthe
hentotheanaloginputpin0ontheboard.

CONTENTS

Close

dinTask4.

inoblocklibrary.Forexample:

motorshaftpositiondependingontheexternalcontrolsignalorsignals.

readthemotorshaftpositionandcompareitwiththedesiredposition.

mulinkSupportPackageforArduinoHardwaretocontrolastandardservomotor.

outosettheservomotorshaftposition,usuallyintherangefrom0to180degrees.

tageappliedtoanArduinoanaloginputpin.Varietyofsensorscanbeattachedto

You might also like