'Polaroid SONAR programs for the Parallax Stamp II 'Copywrite Dennis Clark 9/2000, more or less. SPKR con 1 'Polaroid SONAR one-step program PWR con 13 XLOG con 14 MFLOG con 15 'Polaroid SUN 660 (6500 board) SONAR INIT con 15 ECHO660 con 14 BINH660 con 13 time var word feet var word inches var word start: freqout SPKR,200,2000 pause 2000 goto onestep 'comment this line out to use the 660 routine below 'Polaroid 660 routine output PWR output INIT input ECHO660 low INIT 'turn init off high PWR 'turn power off trdng: low PWR 'turn on power pause 5 'wait a little high INIT pulsout 0,600 'wait 1.2ms (dummy line) rctime ECHO660,0,time 'Now,wait for ping pulse time = time*2 inches = time/148+11 '1.78ms per foot round trip 'with a little fudge for Stamp latency debug dec time,"uS ",dec inches," in",cr low INIT 'turn init off high PWR 'turn power off pause 1000 'let us catch our breath goto trdng 'do it again onestep: 'Polaroid One-Step routine input XLOG input MFLOG high PWR 'turn power off srdng: low PWR 'turn power on pulsin XLOG,0,time 'wait for XLOG (pulse started) rctime MFLOG,1,time 'wait for MFLOG (ping returned) time = time*2 'actually 2us per count inches = time/148 '1.78ms per foot transit time inches=inches+2 'occasional hack needed. high PWR 'turn power off debug dec time,"uS ",dec inches," in",cr pause 1000 'seems to take a while to recharge... goto srdng end