Вы находитесь на странице: 1из 6

02/08/2016

11:TheKUKARobotProgrammingLanguage|Dr.Stienecker'sSite

Dr.Stienecker'sSite
Dr.StieneckersSite

11:TheKUKARobotProgrammingLanguage
DownloadtheNotes(hps://adamwsonu.les.wordpress.com/2010/04/discussion11notes.pdf)
TOPIC 1:
L20S3.mp3)

Movement

(AUDIO)

(hp://www2.onu.edu/~astienecker.1/TECH332/TECH332

TheKUKArobotcanmovefrompointAtopointBinthreemainways.
1.PTPPointtoPointMotionalongthequickestpathtoanendpoint.Thismotionrequiresthe
programmertoteachonepoint.
2. LIN Linear Motion at a dened velocity and acceleration along a straight line. This motion
requires the programmer to teach one point. The robot uses the point dened in the previous
move as the start point and the point dened in the current command as the end point and
interpolatesastraightlineinbetweenthetwopoints.
3.CIRCCircularMotionatadenedvelocityandaccerlationalongacircularpathoraportionof
acircularpath.Thismotionrequirestheprogrammertoteachtwopoints,themidpointandthe
end point. Using the start point of the robot (dened as the end point in the previous motion
command)therobotinterpolatesacircularpaththroughthemidpointandtotheendpoint.
TOPIC2:InputsandOutputs
InputsandOutputs(I/O)arethesameconceptasinPLCs.
INPUTSAninputissomething(digitaloranalog)comingfromanothersystemandisreadinand
usedtomakedecisions.Inputscannotbechangedbytherobotisrepresentthestateofsomething
externaltotherobotsuchaswhetherasensorisonoro.Intherobotsourinputsaredenedfrom
33through40.Theseinputscanbesettoanynumberbuttheexternalinputsthatarenumbered0
through7arereectedintheprogramminglanguageas33through40.Thereforetorefertophysical
input 0 in the program the syntax is $IN[33]. Physical input 4 would be $IN[37]. (AUDIO)
(hp://www2.onu.edu/~astienecker.1/TECH332/TECH332L20S4.mp3)
OUTPUTSOutputscanbechangedbytherobotbutcanalsobemonitored.Thenumberingisthe
sameastheinputs.Physicaloutput0isoutput33intheprogram.Thesytaxis$OUT[33]foroutput
33.Thesyntaxtochangethestateoftheoutputis$OUT[33]=TRUEtocausephysicaloutput0toturn
onand$OUT[33]=FALSEtocausephysicaloutput0toturno.(AUDIO)(hp://www2.onu.edu/~a
stienecker.1/TECH332/TECH332L20S5.mp3)
PULSEDOUTPUTSAnoutputcanbeturnedonforashort(ordened)periodoftimeeasierthan
justturningtheoutputon,waitingforatime,andthenturningtheoutputo.Aninputcannotbe
pulsed because it cannot be altered by the robot. The syntax to accomplish this is
https://drstienecker.com/tech332/11thekukarobotprogramminglanguage/
1/6
PULSE($OUT[33],TRUE,0.5)ormoregenericallyPULSE($OUT[#],state,time)wherestatecanbeTRUE

02/08/2016

11:TheKUKARobotProgrammingLanguage|Dr.Stienecker'sSite

PULSE($OUT[33],TRUE,0.5)ormoregenericallyPULSE($OUT[#],state,time)wherestatecanbeTRUE
or FALSE and time is the time to pulse the output in seconds. The above example would turn on
physical output 0 for 0.5 seconds. This time can range from 0.012 seconds to 2^31 seconds in
increments of 0.1 seconds. (AUDIO) (hp://www2.onu.edu/~astienecker.1/TECH332/TECH332
L20S6.mp3)
TOPIC3:ExecutionControl
Thefollowingaredierentwaystocontroltheexecutionofyourprogram.
1.IfstatementsAnifstatementschecksaconditionandexecutescodeiftheconditionistrueand
may execute code (if wrien) if the condition is false. The syntax is as follows. (AUDIO)
(hp://www2.onu.edu/~astienecker.1/TECH332/TECH332L20S8.mp3)
IFconditional==TRUETHEN
WhatevercodeyouwanttoexecutewhentheconditionalisTRUE
ELSE
WhatevercodeyouwanttoexecutewhentheconditionalisFALSE
ENDIF
Forexample,ifyouhadaswitchconnectedtophysicalinput0thefollowingcodemightbeused.
IF$IN[33]==TRUETHEN
thecodewrienherewouldexecutewhentheswitchwason.
ELSE
thecodewrienherewouldexecutewhentheswitchwaso.
ENDIF
The ELSE statement is optional and if not used should not be entered in. In other words if in the
exampleabovenothingshouldhappeniftheswitchwasothefollowingcodecouldbeused.
IF$IN[33]==TRUETHEN
thecodewrienherewouldexecutewhentheswitchwason.
ENDIF
For those of you who are familiar with programming, there is no ELSEIF option. However, you
cannesttheIFstatementswithineachother.
2. Switch statements A switch statement (in other languages it is called a case statement) is
commonlyusedwhenavariablecanhavemanyvaluesinsteadofjustonando.Forexample,ifa
variablehadthenamecounter_variableanditcouldaainvaluesof10,20,30,40,or50thefollowing
code could be used to execute dierent code base on the value of the variable. (AUDIO)
(hp://www2.onu.edu/~astienecker.1/TECH332/TECH332L20S9.mp3)
SWITCHcounter_variable
https://drstienecker.com/tech332/11thekukarobotprogramminglanguage/
CASE10

2/6

02/08/2016

11:TheKUKARobotProgrammingLanguage|Dr.Stienecker'sSite

CASE10
codethatshouldexecutewhencounter_variableequals10.
CASE20
codethatshouldexecutewhencounter_variableequals20.
CASE30
codethatshouldexecutewhencounter_variableequals30.
DEFAULT
codethatshouldexecutewhencounter_variabledoesntequalanyoftheabovecases.
ENDSWITCH
3.ForloopsTheForloopisacommandthatallowstheprogrammertoexecuteapieceofcodea
certain number of times while incrementing through a variable. For example if a programmer
wanted to execute a set of code 50 times while incrementing a variable in steps of 2 the following
code could be used. (AUDIO) (hp://www2.onu.edu/~astienecker.1/TECH332/TECH332
L20S10.mp3)
FORCounter_Variable=1to100STEP2
codetoexecuteeverytimethroughtheloop
ENDFOR
TheSTEPisoptionalandwithoutthecommanditdefaultsto1.
4.WhileloopsInsteadofexecutingasetofcodeasetnumberoftimes,aWhileloopcanbeusedto
executeapieceofcodewhileaconditionremainstrueorfalse.Forexampleifarobotshouldmove
back and forth while an input remains on the following code could be used. (AUDIO)
(hp://www2.onu.edu/~astienecker.1/TECH332/TECH332L20S11.mp3)
WHILE$IN[35]==TRUE
codetoexecutewhiletheinputremainson
ENDWHILE
5.RepeatsloopsAWhileloopdoessomethingwhileaconditionremainstrueorfalse,butarepeat
loopdoessomethinguntilaconditionsbecomestrueorfalse.Forexample,arobotcouldbeaskedto
move back and forth until a condition is met. (AUDIO) (hp://www2.onu.edu/~a
stienecker.1/TECH332/TECH332L20S12.mp3)
REPEAT
codetobeexecuteduntilinput40turnso.
UNTIL$IN[40]==FALSE

https://drstienecker.com/tech332/11thekukarobotprogramminglanguage/
3/6
6.EndlessloopsManytimes,itisthedesireoftheprogrammerthattherobotdoesthesametask

02/08/2016

11:TheKUKARobotProgrammingLanguage|Dr.Stienecker'sSite

6.EndlessloopsManytimes,itisthedesireoftheprogrammerthattherobotdoesthesametask
overandoveragainendlessly.InordertoaccomplishthatweusetheLOOPcommand.Thiscauses
codebetweenLOOPandENDLOOPtoexecutewithoutend.
LOOP
codetoexecuteendlessly
ENDLOOP
TOPIC4:Variables
Inabasicprogram(MODULPROGRAM)thereisaINIlineprewrieninanewprogram.Above
thisINIlineistheareainwhichvariablesaredeclaredorgivennameanddenition.Thefollowing
are allowable variable types. (AUDIO) (hp://www2.onu.edu/~astienecker.1/TECH332/TECH332
L20S14.mp3)
1.Integer(numberswithoutadecimalpointsuchas1,233,143,4365)Syntax:INTvariable_name
2.Real(numberswithadecimalpointsuchas1.2,33.45,3.14)Syntax:REALvariable_name
3.E6POS (variable representing a point in space and robot orientation) Syntax: E6POS
variable_name
The E6POS variable consists of 6 variables representing the point in cartesian space and the
orientationofthearmatthatpoint.BecauseofthistheprogrammercanreferenceanE6POSvariable
inseveralways.
variable_name.xwouldrefertothexvalueofthepointinspace
variable_name.ywouldrefertotheyvalueofthepointinspace
variable_name.zwouldrefertothezvalueofthepointinspace
variable_name.awouldrefertotherotationaroundthezaxisinspace
variable_name.bwouldrefertotherotationaroundtheyaxisinspace
variable_name.cwouldrefertotherotationaroundthexaxisinspace
OftentimesaprogrammerwillwanttosavethecurrentpositionoftherobottoanE6POSvariable.
Thisisdonewiththe$POS_ACTcommandasfollows.
Ifpoint_in_spaceisthevariablenametheprogrammerwouldtypepoint_in_space=$POS_ACT
andthecurrentpositionoftherobotwouldbesavedtothevariableinrealtime.
Additionally, when using variables, many operators are required and can be grouped into three
categories.(AUDIO)(hp://www2.onu.edu/~astienecker.1/TECH332/TECH332L20S15.mp3)
1.RelationalOperators
Checktoseeifequalto:==
Checktoseeifnotequalto:<>
Checktoseeiflessthan:<
Checktoseeiflessthanorequalto:<=
Checktoseeifgreaterthan:>
Checktoseeifgreaterthanorequalto:>=
2.LogicOperators
NOT
AND
https://drstienecker.com/tech332/11thekukarobotprogramminglanguage/
OR

4/6

02/08/2016

11:TheKUKARobotProgrammingLanguage|Dr.Stienecker'sSite

OR
EXOR(exclusiveor)
3.ArithmeticOperators
Multiplication*
Additiona+
Subraction
Division/
TOPIC5:OtherTopics(includewaitandwaitforhere)
TimersTimersarealsoavailabletotheprogrammerforusessuchastimingtheamountoftimethat
occurs between two inputs coming on. There are 16 timers (116) and there are three commands
availableforeachtimer.Shownherearethecommandsfortimer1.Ifanyothertimerisusedjust
replace the 1 with the timer number. (AUDIO) (hp://www2.onu.edu/~a
stienecker.1/TECH332/TECH332L20S17.mp3)
$TIMER_STOP[1]=FALSEThiscommandstartsthetimertiming.Justlikethebuononyour
stopwatchthatstartstiming.
$TIMER_STOP[1]=TRUE This command stops the timer timing. Just like the buon on your
stopwatchthatstopstiming.
$TIMER[1]Thisistheplacewherethetimeisstoredinmilliseconds.Aprogrammercansetthis
valuetozerobytyping$TIMER[1]=0oruseconditionalstatementsbasedonthevalue.Thevalue
canalsobeusedinamathematicalequationsuchasDistance=Rate*Timetodetermineeither
distanceorratewhicheverisnotknown.Wewillusethisinthelabtodeterminethespeedofthe
conveyorbeltbysolvingforRate=Distance/Timeusingtwosensorsplacedalongtheconveyora
knowndistanceapart.
VelocityCommandThelinearvelocityoftherobotcanbesetbyusingthe$VEL.CPvariable.We
willalsousethisinthelabtosettherobottomoveatthesamespeedastheconveyor.Anexample
would be if we wanted the robot to move at 0.5m/s we would type $VEL.CP=0.5. Note that this
variableisalwaysinunitsofm/s.
Wait Commands There are three dierent commands that the programmer can use to cause the
program to freeze. (AUDIO) (hp://www2.onu.edu/~astienecker.1/TECH332/TECH332
L20S13.mp3)
WAIT FOR This command causes the program to stop until a condition is met. An example
wouldbeWAITFOR$IN[35].Thiswouldcausetheprogramtostopuntil$IN[35]wastrue.
WAITSECThiscommandcausestheprogramtostopforacertainamountoftime.Anexample
wouldbeWAITSEC3.2.Thiswouldcausetheprogramtofreezefor3.2seconds.
HALTTheHALTcommandcausestherobotprogramtostopuntilrestartedbyanoperator.
You should now be prepared to begin the assessment game (hp://www2.onu.edu/~a
stienecker.1/TECH332/KRL Game.swf). BE SURE TO HAVE YOUR CAPS LOCK ON AS IT WILL
MARK LOWERCASE ANSWERS INCORRECT. If you hit a score of 1200 you are guaranteed an
80%,afterthatyouarecompetingwithyourpeers.Thehighestscoregets100%.Todetermineother
grades(ifyourscoreisgreaterthan1200)Iwilltake80+(yourscore1200)x(20/((thehighestscore)
1200)).Ifyourscoreislessthan1200yourgradewillbe(80/1200)x(yourscore).
Tosubmit,takeascreencaptureofyourresultsandemailittomeinaworddocument.

https://drstienecker.com/tech332/11thekukarobotprogramminglanguage/

5/6

02/08/2016

11:TheKUKARobotProgrammingLanguage|Dr.Stienecker'sSite

2Responsesto11:TheKUKARobotProgrammingLanguage
dewaniSays:
July24,2010at3:17pm|Reply
Thisguidedmetocompletemyworkwithease
adamwsonuSays:
July24,2010at4:00pm|Reply
Gladthematerialhelped.Pleasesharetheapplicationforwhichyouusedit.

CreateafreewebsiteorblogatWordPress.com.
Entries(RSS)andComments(RSS).

https://drstienecker.com/tech332/11thekukarobotprogramminglanguage/

6/6

Вам также может понравиться