go away spammer

Author Topic: Problems with IR sharp gp2d02  (Read 3876 times)

0 Members and 1 Guest are viewing this topic.

Offline massiTopic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
Problems with IR sharp gp2d02
« on: June 07, 2007, 08:34:36 AM »
Problems with ir sharp gp2d02
Hi i have an ir sharp sensor a gp2d02 (digital output; range: 4 -80 cm) i tried  all the ways to make it work but in vain
in fact; i'm using a pic 16f84 ( using mplab) i'm following exactly what is written on the datasheet in terms of temporisations but it is not working.
it is for a robotics application: i need a led to switch on when the obstacle is at a distance lesser than 40cm.
help me please it's urgent
here is my source code

;*********************************************************************
;                              gpd202                               *
;*********************************************************************
;CK_GP2: clock
;Vout_GP2 : output of gp2
;cgp2 : byte where the datas are kept

GP2D02
    movlw D'7'
    movwf cT
    bcf CK_GP2
    call PDelay     ; 80ms

    bsf CK_GP2
    call tempo
    bcf CK_GP2

    btfsc Vout_GP2
    bcf cGp2,0
    btfss Vout_GP2
    bsf cGp2,0
    call tempo
    bsf CK_GP2
    call tempo

turn
    rlf cGp2,f
    bcf CK_GP2
    btfsc Vout_GP2
    bcf cGp2,0
    btfss Vout_GP2
    bsf cGp2,0

    call tempo
    bsf CK_GP2
    call tempo
    decfsz cT,f
    goto turn   

    call tempofin    ;1.6ms
    return

;*********************************************************************
;                      PROG.                          *
;*********************************************************************


start
    call tempo
    call GP2D02             
    bcf STATUS,C
    movf cGp2,w
    sublw D'110'
    btfsc STATUS,C
   goto notgood          ; positive result  ==> cGp2 < 110 then none critical distance
   goto good             ; negative result cgp2 > 110 then dangerous distance
notgood
    bcf myled
    call temporisation               ; just to have time to see if it detected something or not
   goto start
good
    bsf myled
    call temporisation              ; just to have time to see if it detected something or not
   goto start
    END    

thx               

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Problems with IR sharp gp2d02
« Reply #1 on: June 08, 2007, 01:11:49 PM »
always do a google search first:
rangefinder basic source code

on the first page there is source code:
http://www.hobbyrobotics.org/index.php?title=GP2D12

also, to help us debug software, you must:
  • Tell us what microcontroller you are using.
  • Tell us what programming language you are using.
  • Tell us what compiler you are using.
  • Comment your code!!!
  • Define 'not working' - is smoke rising? is it not printf'ing? is it compiling? voltages arent correct?

Its kind of like me saying 'why is my robot not working?' and then posting uncommented code - we need more info! Let us know what you have tried so far. ;D

 


Get Your Ad Here

data_list