Technical Data
SRF08addressesshouldhavebeensetupbeforerunningthiscommandandtheMD22shouldbeinitializedtothemodeandacceleration
required.Onemoreimportantfeature.TheSCANcommandalsosetsupa500mStimerontheUSBI2C.IfanotherSCANcommandisnot
receivedwithinthistime,acommandisautomaticallysenttotheMD22tostopthemotors.Thisistopreventyourrobotwanderingoutofcontrol
ifitventuresoutsideoftherangeoftheradiolink.
LEDs
TherearetwostatusLedsontheUSBI2C.AredLedindicatespowerisonandthegreenLedflashesbrieflywhenacommandisreceived.The
redLedcanbeturnedonandoffusingtheSETPINScommand.Seebelow.
I/OPins
IftheUSBI2CmoduleisnotbeingusedforI2C,itcanbeusedasgeneralpurposeI/OcontrollerwiththreeI/Olines.Input1isalwaysaninput
onlypinandhasa47kpullupresistor(not4.7kliketheothers).Theothertwocanbeinputoroutput.Theoutputsaresethigh/lowwiththe
SETPINScommand.Thepinisnotactivelydrivenhigh,itisreleasedandpulledhighbya4.7kresistor.Outputlowisactivelydrivenandcan
sinkamaximumof24mA.GETPINSwillreturnthestatusoftheI/Opins.TouseanI/Opinasaninput,itmustfirsthavea1(high)writtentoit.
Thiswillreleasethepinsothatthe4.7kresistorwillpullithigh,itcanthenbeusedasaninput.BothSETPINSandGETPINScommandswill
returnthestatusoftheI/OPins,however,onlySETPINScanchangethem.ThebitsinthedatabytewrittenbySETPINSandreturnedby
SETPINSandGETPINShavethefollowingformat:
7 6 5 4 3 2 1 0
x x x x I/O3 I/O2 Input1 RedLed
ThefollowingcommandwillturntheRedledoffandmaketheI/Olineshighsotheycanbeusedasinputs:
USBI2C_CMD SETPINSCommand Data1 Data2
0x5A 0x10 0x0E 0x00(unused)
AnalogueInputs
TheUSBI2CmodulecanalsoconverttheanaloguevaluesonpinsI/O2andI/O3.BeforedoingthistheI/Opinsshouldbesethigh,effectively
makingtheminputs.RememberthoughthatthisisprimarilyaUSBtoI2Cinterfaceandassuchhas4k7pullupresistors.Takethisintoaccount
whenconnectingyouranalogueinput.
Thefollowingcommandwillfetchtheanaloguevalues:
USBI2C_CMD GETADCommand Data1 Data2
0x5A 0x12 0x00(unused) 0x00(unused)
Withanaloguedatareturnedinthefollowingformat:
Byte1 Byte2 Byte3 Byte4
I/O2HighByte I/O2LowByte I/O3HighByte I/O3LowByte
Theanalogueinputsuse10bitconversion,soyouwillseevaluesfrom0to1024(0x0000to0x03FF)
NoteyoucannotmixI/OmodeandI2Cmode,I/OcommandsshouldnotbeusedwhenI2Cdevicesareconnected.
USBI2CTestSoftware
TohelpyoutestandgettheUSBI2Cupandrunningquickly,wehaveprovidedacoupleofsimpletestprograms.ThefirstisfortheUSBI2C
connectedtoanSRF08ultrasonicranger.
TheconnectorontheUSBI2CmodulemaybesoldereddirectlytotheSRF08asshown,oryoucanuseacableifpreferred.TheUSBI2C
modulecaneasilysupplythe25mApeakoftheSRF08.ThesoftwareautomaticallysearchesfortheSRF08anddisplaysitsI2Caddress,along
withrevisionnumber,rangeandlightsensorreading.Youcandownloadusb_i2c_srf08.exeandtheCsourcecodehere.
ThesecondisfortestingI/Omodes,andallowsyoutoset/clrtheI/O'saswellasreadthedigitalandanalogueinputs.