PDA

View Full Version : Hall effect sensor?



bear_phillips
05-19-2006, 07:37 AM
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

wb8aiz
05-19-2006, 08:50 AM
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

PJ Allen
05-19-2006, 08:58 AM
You have:

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

? ? ?

bear_phillips
05-19-2006, 11:34 PM
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

PJ Allen
05-20-2006, 12:34 AM
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

bear_phillips
05-20-2006, 10:34 PM
Thanks! That did the trick. Thanks for the help.

chad