Shop OBEX P1 Docs P2 Docs Learn Events
Hall effect sensor? — Parallax Forums

Hall effect sensor?

bear_phillipsbear_phillips Posts: 14
edited 2006-05-20 14:34 in BASIC Stamp
I am trying to get a Hall effect sensor to work with my BS2. The datasheet for the sensor is at
http://www.datasheet4u.com/html/O/H/0/OH090U_ETC.pdf.html

I connected pin 1 to vdd, pin 2 to vss and pin 3 to Pin 0 of the BS2. My code is:
detect VAR Word
INPUT 0
DO
irdetect = IN0
DEBUG CR, "Hall detector=",DEC detect
PAUSE 400
LOOP

If I read the datasheet correctly the pin should go high when the sensor is near the south pole of a magnet, but that doesn't seem to be working.

Any thoughts I what I may be doing wrong? Do I have the wrong type of hall effect sensor? I just want to be able to detect when the magnet is near the sensor. Like to detect when a door opens.

thanks
chad

Comments

  • wb8aizwb8aiz Posts: 8
    edited 2006-05-19 00:50
    Hello Chad
    Are you using a pull up resister? Take a look at http://www.parallax.com/dl/docs/books/edu/wamv2_2.pdf
    Page 79 for some interfacing ideas.

    Good Luck
    Kevin
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-19 00:58
    You have:

    detect VAR Word
    INPUT 0
    DO
    irdetect = IN0
    DEBUG CR, "Hall detector=",DEC detect
    PAUSE 400
    LOOP

    ? ? ?
  • bear_phillipsbear_phillips Posts: 14
    edited 2006-05-19 15:34
    Yep, I had an error in the code I posted, but it is correct in the copy I used.

    Is there a way to test the sensor with a meter to make sure I didn't hurt it?

    thanks
    chad
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-05-19 16:34
    How do you have it hooked up?· As in the drawing attached?

    Post edit:· The fine-print says the bevel is the back.· So, pin1 is on the left with the totally flat side facing you.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
     
    INPUT 0
     
    DO
      IF (IN0 = 1) THEN DEBUG "HALL = 1", CR
      IF (IN0 = 0) THEN DEBUG "HALL = 0", CR
      PAUSE 50
    LOOP
    
    


    Post Edited (PJ Allen) : 5/19/2006 7:32:57 PM GMT
    446 x 265 - 9K
    358 x 268 - 9K
  • bear_phillipsbear_phillips Posts: 14
    edited 2006-05-20 14:34
    Thanks! That did the trick. Thanks for the help.

    chad
Sign In or Register to comment.