Sample'{$STAMP'{$PBASICBS2}Program(Star_Pattern.BS2)
2.5}
'Program'Angle'failsofto'withouttoeachtraversea5-pointedstar.Straightsectionsareabout25\"long.
function,turnisthe144-degrees.Boe-BotwillUsejustitcontinuetotestthegoingencoders.Iftheleftone'Ideally,stopping.'Butit'situncalibrated,willcomeIfthetorightonefails,itwillcontinueinatostraightcircleinline
theturn.sorestthat'satthesomewhatpointunlikely!
anddirectioninwhichitstarted.'---------[Constants]----------------------------------------------------------RIGHTLEFTCONCON01'Constantsdefiningdirectionsubscripts.SenseRSenseLPINPIN1011'Righthand'Lefthandencoderencoderinput.input.
(MUSTbeSenseR+1.)MotorRMotorLPINPIN1213'Righthand'Lefthandmotormotoroutput.output.
(MUSTbeMotorR+1.)SenseMotor
CONCONSenseRMotorR
'Base'Baseaddressaddressforforencoders.motors.
'---------[Variables]----------------------------------------------------------PrevNewVAR'PreviousSideVARBit(2)VARBit(2)Bit'Current'Sideindexreadingsreadingsfromencoders.(LEFTfromorRIGHT).encoders.Counteri
VARVARWord(2)Byte
'Pulse'FOR/NEXTcountersindex
forencoders.'---------[Programbeginshere.]-----------------------------------------------PAUSEFOR'Timetoremovefingerfromresetbutton...Counter(LEFT)i3000
=1TO5
DO=0
'InitializeLEFTcounter.
PULSOUTWHILE(Counter(LEFT)PULSOUTMotorL,850<50)'PulseGOSUBMotorR,650'bytheservos'Update50pulsetogostraightLOOP
PAUSEUpdate20'20mspulsetheencoderedges(about25\").gap.
counts.PAUSECounter(RIGHT)500
'WaitDO'Initialize1/2secondRIGHTbeforecounter.
turn.PULSOUTWHILE(Counter(RIGHT)=0
GOSUBUpdateMotorR,650<20)'Pulse'UpdatetheRIGHTservototurna40%circle.LOOP
PAUSE20'20mspulsetheencodergap.
counts.NEXTPAUSE500'Wait1/2secondbeforenextside.
END
'---------[Subroutines]--------------------------------------------------------Update:
'Update'Justcallpulseitcountsoftenenoughfromthetoencoders.
catchalltheFORNew(Side)Side=RIGHT'changes.
IFPrev(Side)(New(Side)=INS.LOWBIT(SenseTOLEFT^Prev(Side))THEN+Side)'For'Readbothencoders...'Differentnewencodervalue.Counter(Side)=New(Side)=Counter(Side)+1''Yes:UpdatefromUpdatewithlastcounter.newvalue?value.NEXTENDIFRETURN
Boe-BotEncoderDigitalKit#28107support@parallax.comwww.parallax.com/moc.ci599en888-512-1024MenloDrive,(toll-free)Suite100•916-624-8333•Rocklin,CA95765•916-624-8003•USA
(fax)
o//:ptthDocumentrevision:2005Aug23
PartsList2ea.ReflectiveSensors2ea.ConnectingCable2ea.MountingPlates2Machineea.#4-40Screwx1/4\"Panhead2ea.#4-40HexNut2ea.10K1/4WResistorAssemblyToyouassembleawillneedtheasmallBot-BotPhillipsWheelscrewdriverEncoderKit,andbothpairtheintopwheelsofneedlenosetwoscrewsfromthepliers.Beginbyremoving(theBoe-Bot.onesnearestNext,theremovecreaseremainingthechassis)servoholdingmountingeachscrews:
servo.LoosentheRemoveRemoveLoosenLoosenPlugshown:
aconnectingcableintoeachsensor,asNext,threadtakeoneofthemountingthepinoblongthewireshole.fromoneoftheplates,cablesandthroughSecureintoscrewonthroughthetheInsertthesensor'salignmentsensormatingmountingplatehole.
thetootherthemountingsetofholesplateandwithawiththeyoutheback.oppositeRepeatfortheothersensor,abutnutmirrorswillofhaveeachtwoorientation.Whenfinishedother:
mountedsensorsthatareUsingstep,lensesmounttheservoeachscrewssensorremovedtotheinthefirsttightenarethenearscrewstotheyet.servoSeephoto:
shaft.chassisDonotsotheViewingadjustastheirthepositionsservosfromthechassisbottom,theircloselyaspossible.soEitherthattheircentershaftsbothalignintowardrespectivecutouts,orpushthembothJust(notawayfrom)thesensorconnector.alleightmakeservosurescrews.
they'rethesame.NowtightenTheundersensorwiresinsertedthefrontofmaytheprintednowbecircuitbroughtboardoutfromareassignedintotheasfollows:
prototypingarea.ThewiresandRed:Black:VddWhite:Vss
Signal(opencollector)
TheschematicencodersshouldbewiredaccordingtothewiresParallaxareforred,ontheablack,nextdifferentandpage.wiringyellowNote:Ifyourdiagram.
,contactVddfloor,aninchincrementeachedgeoftraveloftheslightlysquarewavemorewillthanmark1/22below:
(1.27cm),asshownintheillustrationLeftRd10KxDirectionofMotion
01SensorWhBkP11
23RightRd4SensorWhBkP10
About0.5\"5Vss01234567Ashowntypicalbelow:
implementationofthisschematicisEncoderOutput
VddVinVssBlackBytoSensorsWiresit'strackinghowpossiblechangesforaBASICintheStampencoders'outputs,P15theP14RedwhichencodersfartheBoe-Botthemselveshastraveled.programtotelldonottellNoticethatP13toSensorsWiresP12whenP11drivinganddirectionhowfar.theButwheelsiftheareturningthe—StamponlyP10WhiteP9toLeftWireSensordirectionthethiseachwheelwheelservos,isturningitknowsStampprogramisandwhichcanP8P7WhiteencoderadditionalinformationalongwiththeapplyP6P5toRightWireSensor
applications,outputs.P4trackitisInpossiblethemostsophisticatedP3P2butP1wheels,alsoofthetocoordinateBot-Bot'spositionnotonlytokeeptherotationsanddirection,P0
obtainanyusingdesiredtheencodersmotioncontour.
asfeedback,ofthetotwoOperation
Beneveraware,Thewheelperfect.though,returnsensorsemitinfraredlightandlookforFurtherdiametersUncertaintiesthatwheelencodersarecanleadtoinpositiontheeffectivecalibratedfromareflectivesurface.Theyare
itsspacinguncertaintiesmillimetersforoptimalsensingofsurfacesafewerrors.thougherrorsAndduringineffectivewheelerrors.eventurnssmallcanresultindirectioncausenothaveawayofaccumulatingpositionandquicklydirectionif\"sees\"thetheyaway.sensorsareblack,TheBoe-Bot'swheels,eventoreflectsufficientIRtoreferences.periodicallycorrectedusingexternal
Whenrunfloats,it'spartandlookingofawheel,respond.itpullsWhenitsoutputasensorlow.thepullupthroughresistorahole,pullsitsitoutputhigh.vinylonorahardwoodhard,Toflat,obtainsmooththebestfloor—surface,accuracy,neveronsuchalwayscarpet.asaBecauseThemodulatedthesensorsemitfromfollowingtheencoderssampletoprogramusesfeedbackrelativelyIR(atabout7.8KHz)anddetectonlypatternaware,insensitivetoambientlight.theyareBethereforeonmaystartingunlikelythefloor.toIttraverseastar-shapedreturnisuncalibratedsoisinterferealsothough,withemitthatsomefluorescentfixturestheirlightoperation.
atthisfrequencyandcouldcloseincludingitgets.point.MoreButtrycomplicateditanywayexactlytoseetoitshow/andmAsocanddirectioncoordinatedmotion,X-Yexamples,position.ancidownloadedthetheoryodometry,frombehindtheParallaxthem,calibrationmaytechniques,websitebe
at:
enoalternatingaBoe-Botwheelpatternturns,ofholethe-sensornowillseenowhosehole,frequencyetc.Itsoutputhole-hole-correspondswillbeasquarewave//www.parallax.com/detail.asp?product_id=28107
:rotation.IftheBoe-Botisrollingtothealongspeedthe
ofptth
分销商库存信息:
PARALLAX28107