GP2D12.docx
- 文档编号:7804207
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:10
- 大小:126.38KB
GP2D12.docx
《GP2D12.docx》由会员分享,可在线阅读,更多相关《GP2D12.docx(10页珍藏版)》请在冰豆网上搜索。
GP2D12
夏普公司推出的红外测距传感器GP2D12外形很小,可测量范围为10-80厘米,其接口是标准的三线接口(Vcc/GND/Output)。
我们可以做一个转接电路,让它能与RCX相连,其硬件和编程可以参考:
。
应用:
可以在灭火比赛中应用,也可以应用在机器人走迷宫等等。
例子:
1.沿墙壁走的机器人
2.沿墙壁走的机器人的行走状态
Thisarticle,completewithtextandimages,waswrittenbyPhilippeHurbain.
Introduction
IlongthoughtthatadistancesensorwouldbeaniceadditiontoMindstormsrobots,butultrasoniconeswerebulkyandpowerhungry(I'vesincefoundtheSRF04UltrasonicRangeFinderthatcanperhapsbeused),andsimpleinfraredmethodsliketheoneIusedinmyradarcardetectobstaclesbutdon'tgivetruedistancemeasurement. ThesolutioncamefromAndreasPeter(thanksAndreasforshowingmethesedevices!
)whointerfacedaSharpGP2D05toRCX.
Thesesmallandratherinexpensiveinfrareddevicesareabletomeasuredistancebetween10and80cmwithreasonableprecisionandgoodimmunitytovariationsofobstaclesreflectivityandambientlight. Formoreinformations,seetheGP2D12datasheetandtheAcronamearticle:
DemystifyingtheSharpIRDetectors.
Andreas'ssensorinterfacehasafewdrawbacksthough. TheSharpGP2D05heusedhasadigitalserialoutputnotwellsuitedtoRCXanaloginput,thusrequiringarathercomplexdesign,bigandpowerhungry.
SoIdecidedtotrytoconnecttheanalogoutputGP2D12sensorusingthesimplestdesignpossible--anduseonlypowercomingfromsensorinput. ThiswasarealchallengesincetheGP2D12used35mAunder5V,whileRCXsensorinputiscurrent-limitedtoabout14mA!
Lookatvoltageversuscurrentofsensorinputpowersupply:
Themainconcepttoachievethisgoalwasquicklyimagined:
storeenergyinacapacitorwhiletheGP2D12isnotpowered,thenreleaseitduringmeasure. Ofcoursethereisapenaltywiththistechnique:
conversiontimeislonger. TheGP2D12requires50mspermeasure,whilemycircuitneeds300ms...thereisnofreelunch!
ThefirstdesignsIimaginedwererathercomplex,withtimersandasample-and-holdamplifier,thenIslowlycametothisstreamlinedcircuit:
UsingtheCircuit
Chargingphase
During250ms,sensorisconfiguredasalightsensor(powered),C1chargesthroughD1uptoSENSOR+voltage. LowdropregulatorU1generatesa+5Vregulatedsupply. Q1isblockedbyD2(D2maintainsbasetoavoltagehigherorequaltoitsemittervoltage),soGP2D12isnotpowered. Q3isnon-conductingtoo,preventingcurrentflowthroughD3/R5/Q2. SotheonlysignificantcurrentdivertedfromC1chargingisthroughR1(lessthan2mA),andattheendofthisphaseC1isfullycharged.
Measurementphase
Duringthefollowing50ms,sensorisconfiguredasatouchsensor(passive). SENSOR+isnowonlypulledupto+5Vthrough10Kohm(insideRCX),insufficienttoblockQ1. Q1andQ3arethenconducting,andGP2D12ispowered. Q2,mountedasanemitterfollower,buffersGP2D12outputanditsvalueisavailabletoRCXthroughD3andR5.
Samplecodetoreadsensor:
SetSensor(SENSOR_1,SENSOR_LIGHT);
Wait(25);
SetSensor(SENSOR_1,SENSOR_TOUCH);
Wait(5);
SetSensorMode(SENSOR_1,SENSOR_MODE_RAW);
distance=SENSOR_1;
//EnableC1chargeassoonaspossible
SetSensor(SENSOR_1,SENSOR_LIGHT);
ComponentSelection
∙D1preventsdestroyingthesensorincaseofreverseconnection. Ididn'tusethefull-bridgerectifierusedinLegosensorthatenablessensorstoworkwhenconnectedbackwards(numberofneededdiodesjumpsfrom3to8!
). Iconsideredthatsomeoneabletobuildthissensorisalsoabletoconnectitintherightway... Forthosewhowantit,hereisthediagramwithfullbridgerectifier. Iused1AmpShottkydiode1N5819forD1,whichisinexpensiveandreadilyavailable. It'slowforwarddropvoltageislessthan0.1Vforthecurrentthatflowsthroughit,thisenablesittochargeC1tothehighestvoltagepossible.
∙C1storesenergythatwillbeusedduringmeasurementphase. Itmustprovide+5Vattheendofthisstage. AssumingtypicalvaluesfortheGP2D12(I=35mA,conversiontime=50ms)andaninitial+7.5VacrossC1,itsvalueisC=I*dT/dV=35*50/(7.5-5)=700µF. Smallmarginwith1000µF...
∙U1isalowdropout5VregulatorinTO92case. IusedaTelcom/MicrochipTC55RP5000butotherregulatorswillprobablywork,suchasSTMicroelectronicsL4931-50. Standardregulatorssuchas78L05willNOTworkbecausetheyrequiremorethan+7Vatinputtogeta+5Voutput. TakecarewithsomelowdropregulatorssuchasLM2931thatrequiremorethan25mAwhenpoweredat1V. WithRCXcurrentlimitation,thishogeatsallenergy.(Iwascaughtwiththisone...)
∙Q1switchespoweronandoffforGP2D12. At35mAcurrent,IoriginallyusedaplainvanillaBC548. Mysensorbegantoworkwithit,butexhibitedstrangebehavior. LookingtoGP2D12powersupplyIthendiscovered2Vdips!
IthenlookedattheGP2D12consumptionanddiscoveredthatitwaspulsed(220mApulses1/8thoftime,superimposedtoa8mAconstantcurrent. Seeoscilloscopecaptureshere). Atsuchacurrent,BC548hasalowgain,andsinceIcouldn'tlowerbaseresistorR1(maincurrentdrainduringcapacitorcharge)IusedahighperformanceZetextransistor,ZTX718thatoffershighgainathighcurrent(othersimilardevicescanwork!
).
∙C2stabilizesU1andhelpsabsorbpeaksofcurrent. AlowESRversionwouldbebetter(see"grass"on5VoutputwhenGP2D12works).
MainComponentDatasheets(PDFFormat)
GP2D12PDFdatasheet
GP2D12
(olddocumentation,900k)
BC548
1N5819
TC55RP5000
BC558
ZTX718
OscilloscopeScreenCaptures
Seethemhere.
BuildingtheSensorInterfaceModule:
PhotoGallery
Theinterfacemoduleisbuildona1"squareproto-board
Topview
Topview,withcomponentsidentification
Bottomview. AnotchincircuitiscutforbigC1. Asinglelayercircuitboardwouldbeveryeasytodraw.
Everythingfitsin3hollowed4x2bricks
Prettytight!
Completemodule. GP2D12fixationswerecuttomatchLegobrickwidth.
Readytowork!
ThePrototype
Amuchmoreuglycircuit...
...mountedonatestvehicle
ARealApplication:
WallFollower
Seeithere!
Testprograms
HerearesomeNQCtestprograms(theyrequireRCX2.0firmwarethatyoucangethere).
GP2D12-3-a.nqc
Download"GP2D12-3-a.nqc"here
//ReadGP2D12Sensoroutputanddisplays
//rawvalueonRCXdisplay(requiresRCX2firmware)
intvalue;
taskmain()
{
SetUserDisplay(value,0);//Display"value"onLCD
SetSensor(SENSOR_1,SENSOR_LIGHT);//Activemode:
startschargingsensor
Wait(100);//Waitforfullchargeonstartup
until(false)
{
SetSensor(SENSOR_1,SENSOR_TOUCH);//Passivemode:
startsmeasure
Wait(5);//WaitforGP2D12conversiontime(50ms)
SetSensorMode(SENSOR_1,SENSOR_MODE_RAW);
value=SENSOR_1;//readsanddisplayvalue
SetSensor(SENSOR_1,SENSOR_LIGHT);//Rechargesensor
Wait(25);//for250ms
}
}
GP2D12-3-b.nqc
Download"GP2D12-3-b.nqc"here
//ReadGP2D12Sensoroutputanddisplaysdistance(incm)
//onRCXdisplay(requiresRCX2firmware)
intvalue,temp;
taskmain()
{
SetUserDisplay(value,1);//Display"value"onLCD
SetSensor(SENSOR_1,SENSOR_LIGHT);//Activemode:
startschargingsensor
Wait(100);//Waitforfullchargeonstartup
until(false)
{
SetSensor(SENSOR_1,SENSOR_TOUCH);//Passivemode:
startsmeasure
Wait(5);//WaitforGP2D12conversiontime(50ms)
SetSensorMode(SENSOR_1,SENSOR_MODE_RAW);
temp=SENSOR_1;//readssensorvalue
SetSensor(SENSOR_1,SENSOR_LIGHT);//Rechargesensor
Wait(25);//for250ms
temp=10000/((21*temp+6*temp/10)/100-72)-20;//linearizeandconvertinmm
value=temp;//displaysdistanceincm(format:
xx.x)
}
}
Distancevs. SensorReading
Linearizedcurve:
1000/(distance-2)vs. SensorReading+BestFitLine
RevisionHistory
∙4/26/01-Created.
∙5/08/01-Addedfullsizeimagesofcircuitboadconstruction.
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- GP2D12
![提示](https://static.bdocx.com/images/bang_tan.gif)