Using several Sharp Range finders?
haunteddansion
Posts: 68
I am working with the Sharp GP2Y0A02YK IR Sensor, is there a way to connect 3 of the sharp sensors in parallel or series so I have a wider cone of triggering space. I could put the three on a half circle so they fan out? I have attched the code I am using which works great with one·sensor, I would be great to have a wider fan of triggering zone though, without much more circuitry infrastructure
' {$STAMP BS1}
' PROGRAM: AD_CONV.BAS
SYMBOL· CS· =· 0
SYMBOL· AD· =· PIN1
SYMBOL· CLK· =· 2
SYMBOL· DATA· =· B0
SYMBOL· i· =· B2
setup:· LET PINS = 255··· 'Pins high (deselect ADC).
· LET DIRS = %11111101· 'S_out, CLK, CS outputs; AD input.
loop:· GOSUB conv··· 'Get the data.
· DEBUG DATA
· PIN6=1
· PAUSE 25··· 'Wait 2 seconds
· IF DATA > 23 THEN Trigger
· GOTO loop··· 'Do it forever.
conv:· LOW CLK····· 'Put clock line in starting state.
· LOW CS····· 'Select ADC.
· PULSOUT CLK, 1··· '10 us clock pulse.
· LET DATA = 0··· 'Clear data.
· FOR i = 1 TO 8··· 'Eight data bits.
· LET DATA = DATA * 2· 'Perform shift left.
· PULSOUT CLK, 1··· '10 us clock pulse.
· LET DATA = DATA + AD· 'Put bit in LSB of data.
· NEXT····· 'Do it again.
· HIGH CS····· 'Deselect ADC when done.
· RETURN
Trigger:
·· PIN6=0
·· PAUSE 500
·· PIN6=1
·· GOTO loop:
Post Edited (haunteddansion) : 5/14/2007 7:50:27 PM GMT
' {$STAMP BS1}
' PROGRAM: AD_CONV.BAS
SYMBOL· CS· =· 0
SYMBOL· AD· =· PIN1
SYMBOL· CLK· =· 2
SYMBOL· DATA· =· B0
SYMBOL· i· =· B2
setup:· LET PINS = 255··· 'Pins high (deselect ADC).
· LET DIRS = %11111101· 'S_out, CLK, CS outputs; AD input.
loop:· GOSUB conv··· 'Get the data.
· DEBUG DATA
· PIN6=1
· PAUSE 25··· 'Wait 2 seconds
· IF DATA > 23 THEN Trigger
· GOTO loop··· 'Do it forever.
conv:· LOW CLK····· 'Put clock line in starting state.
· LOW CS····· 'Select ADC.
· PULSOUT CLK, 1··· '10 us clock pulse.
· LET DATA = 0··· 'Clear data.
· FOR i = 1 TO 8··· 'Eight data bits.
· LET DATA = DATA * 2· 'Perform shift left.
· PULSOUT CLK, 1··· '10 us clock pulse.
· LET DATA = DATA + AD· 'Put bit in LSB of data.
· NEXT····· 'Do it again.
· HIGH CS····· 'Deselect ADC when done.
· RETURN
Trigger:
·· PIN6=0
·· PAUSE 500
·· PIN6=1
·· GOTO loop:
Post Edited (haunteddansion) : 5/14/2007 7:50:27 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
DO
LOW CLK 'Put clock line in starting state.
LOW CS 'Select ADC.
PULSOUT CLK, 1 '10 us clock pulse.
LET DATA = 0 'Clear data.
FOR i = 1 TO 8 'Eight data bits.
LET DATA = DATA * 2 'Perform shift left.
PULSOUT CLK, 1 '10 us clock pulse.
LET DATA = DATA + AD 'Put bit in LSB of data.
NEXT 'Do it again.
HIGH CS 'Deselect ADC when done.
DEBUG DATA
PIN6=1
PAUSE 25 'Wait 2 seconds
IF DATA > 23 THEN Trigger
LOOP 'Do it forever.
Should do the same as your code without as many jumps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen