United Kingdom
Offline
Newbie
Karma: 1
Posts: 21
|
 |
« on: January 30, 2011, 09:24:55 am » |
Recently I purchased the following Hall switch sensor from farnell (UK component shop): http://uk.farnell.com/allegro-microsystems/a1101eua-t/hall-effect-switch-sip-3-1101/dp/1198078I have been experimenting with the sensor and have found it to not behave in any way you'd expect it to. Below I have uploaded 4 videos showing my experiments. The arduino is set up to turn the LED on when the signal coming from the "hall switch" is low, in other words, the output that should occur when a magnetic field greater than the sensors threshold is present. /* * Hall switch test * Turns on and off an LED connected to pin 13 when passing a magnet by the hall switch connected to pin 2 */ int ledpin = 13; //Pin for LED int hallpin = 8; //Pin for Hall switch int val = 0; //Integer for reading Hall status void setup(){ pinMode(ledpin, OUTPUT); //Declare LED pin as output pinMode(hallpin, INPUT); //Declare Hall pin as input } void loop(){ val = digitalRead(hallpin); //Read Hall pin status if (val == HIGH){ //If there is no magnet infront of Hall switch... digitalWrite(ledpin, LOW); //Turn LED off } else{ //Otherwise... digitalWrite(ledpin, HIGH); //Turn LED on } } Experiment 1http://youtu.be/D3E9Gl55wl8The sensor appears to be unaffected by the magnet, but will switch to low output when a hand is brought into close proximity Experiment 2http://youtu.be/IC5K88AgcaEThe same result is seen when the sensor is covered with an opaque bag (although some light can enter through the bottom) Experiment 3http://youtu.be/EMTKCNDFil8The sensor also switches to low output when hot air is blown onto it Experiment 4http://youtu.be/TiJkIAZWlicPerhaps the strangest result... The sensor seems to switch low when I place my hand infront of my desk lamp I am posting this to seek clarification on what sensor I have received, as I am now certain it is not a hall switch. Is it some sort of capacitive sensor? Or some sort of magic hand sensor?
|
|
|
|
|
Logged
|
|
|
|
|
Texas
Offline
Jr. Member
Karma: 1
Posts: 97
Eso es lo que es
|
 |
« Reply #1 on: January 30, 2011, 10:17:57 am » |
Post a circuit diagram so I can see how you've got it wired. I had a similar problem with my hall switch before and realized it was wired incorrectly.
Also, have you made sure you have the south pole of the magnet facing the switch, and not the north?
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Newbie
Karma: 1
Posts: 21
|
 |
« Reply #2 on: January 30, 2011, 10:48:35 am » |
Here is the best representation I could come up with on "Fritzing" Imagine that the 3 pin component is the Hall switch  And with regards to the magnet polarity question, I have tried positioning the magnet in every orientation possible.
|
|
|
|
« Last Edit: January 30, 2011, 10:54:45 am by davidbrowne »
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #3 on: January 30, 2011, 12:41:25 pm » |
Ok I think you have two problems:
1. Remove that resistor and wire your +5vdc breadboard voltage directly to the Vcc pin of the hall sensor. Why did you think you needed a series resistor? Perhaps you meant to wire the resistor as a pull-up by wiring it between the sensor signal and Vcc pins. But you have it in series with +5vdc?
2. The signal output from the sensor is a open drain type output, meaning that there is a pull-up resistor required. The easist way to implement it is to just enable the internal pull-up for your input pin. Or you could wire the removed resistor above and wire it correctly between signal and Vcc pins.
So in your setup function you have a:
pinMode(hallpin, INPUT); //Declare Hall pin as input Add this after that command: digitalWrite(hallpin, HIGH) // turn on internal pull-up
Try those two changes and get back to us if it's working or not.
Lefty
|
|
|
|
« Last Edit: January 30, 2011, 12:48:06 pm by retrolefty »
|
Logged
|
|
|
|
|
United Kingdom
Offline
Newbie
Karma: 1
Posts: 21
|
 |
« Reply #4 on: January 30, 2011, 01:17:53 pm » |
I realise now that I had the resistor in the wrong place; I was following a similar digital input problem that came with my starter-kit and is also here: http://www.arduino.cc/en/Tutorial/Pushbutton Here they describe a pull-up resistor being placed between the Vsource and Vin of the button. 1) If I use the "digitalWrite(hallpin, HIGH);" line in the code, the LED is permanently on, with or without the pull-up resistor in the correct location 2) With the pull-up resistor in the correct location (and I used a higher resistance of 10kohms this time as suggested here): http://www.arduino.cc/playground/Main/ReadingRPMI can now trigger the hall switch with a magnet. However, I can also trigger it by moving my hand into close proximity. 5th experimentReferring to my 4th video, where when I squeeze my desklamp the LED turns on. If I then ground myself through my laptop in my other hand, the LED does not turn on. I can actually do this with my friend holding the lamp, me holding my friends hand, and then touching the laptop.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #5 on: January 30, 2011, 01:23:30 pm » |
I also don't see a series resistor wired to your led going to pin 13? You should either remove the led and just watch the on-board pin 13 led, or wire in a series with a resistor of say 200-500 ohms. You are in danger of destroying your output pin 13 as it is screaming in pain every time you turn it on.
Lefty
|
|
|
|
« Last Edit: January 30, 2011, 01:26:32 pm by retrolefty »
|
Logged
|
|
|
|
|
United Kingdom
Offline
Newbie
Karma: 1
Posts: 21
|
 |
« Reply #6 on: January 30, 2011, 01:34:08 pm » |
I did not realise. I have now added a resistor between the Vsource and the LED.
I have 3 magnets. If I leave the weakest of the 3 magnets near the sensor the LED remains on. If I use any of the stronger magnets the LED remains off. If I touch my laptop, the LED turns off. I should note, that the arduino is being powered by my laptop currently. Whatever is happening, the problem is unfortunately still not solved.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #7 on: January 30, 2011, 01:46:30 pm » |
I can't explain all the wavy hands and proximity stuff you are seeing. I have used that same sensor and it just worked as expected. Perhaps you should add a bypass filter capacitor of .1ufd (or larger) between the hall effects Vcc pin and ground pin. I don't see anything wrong with your sketch. Edit: You might try using a diffenet output pin for the led and change your code to match as maybe you damaged the pin 13. Lefty
|
|
|
|
« Last Edit: January 30, 2011, 01:48:50 pm by retrolefty »
|
Logged
|
|
|
|
|
United Kingdom
Offline
Newbie
Karma: 1
Posts: 21
|
 |
« Reply #8 on: January 30, 2011, 01:54:41 pm » |
Thankyou for your help anyway. With regards to your edit I already thought to try a different LED output pin, and the same results occur.
I guess I'll wait and see if Jd.steinberger has anything to suggest if he had a similar problem.
If there is no resolve, I still have reason to suspect I may of been sent an incorrect sensor model and I may return it. If you still have yours available could you let me know what markings it had on it?
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15316
Measurement changes behavior
|
 |
« Reply #9 on: January 30, 2011, 02:11:07 pm » |
If you still have yours available could you let me know what markings it had on it? I bought my Allegro hall effect sensors about a year ago from an E-bay seller. I bought both 5 each of their analog sensor and switch sensor. Part number and device markings are: Allegro analog hall sensor part # A1323LUA-T Device marking = 23L Allegro digital switch sensor part # A3213EWA Device marking = 13E Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Texas
Offline
Jr. Member
Karma: 1
Posts: 97
Eso es lo que es
|
 |
« Reply #10 on: January 30, 2011, 03:18:45 pm » |
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1294620858/15Check out the 6th post down by pwillard. I don't have time to read all the posts right now or check your datasheet, maybe you've already tried this.
|
|
|
|
|
Logged
|
|
|
|
|
Central MN, USA
Online
Faraday Member
Karma: 35
Posts: 5921
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
|
 |
« Reply #11 on: January 30, 2011, 11:42:48 pm » |
2. The signal output from the sensor is a open drain type output, meaning that there is a pull-up resistor required. The easist way to implement it is to just enable the internal pull-up for your input pin. Or you could wire the removed resistor above and wire it correctly between signal and Vcc pins.
Lefty, thanks for pointing this out. I just made a PCB without the knowledge of the output is open-drain. Glad that ATMEGA has internal pull-ups. I'm going to use the internal pull-up for sure.
|
|
|
|
|
Logged
|
|
|
|
|
United Kingdom
Offline
Newbie
Karma: 1
Posts: 21
|
 |
« Reply #12 on: February 01, 2011, 10:06:06 am » |
In case any one stumbles upon this thread looking for a solution themselves, the problem was that the sensor required a resistor to be placed between the Vin and Vcc ports. With this in place, the sensor is functional.
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25501
Solder is electric glue
|
 |
« Reply #13 on: February 01, 2011, 06:27:19 pm » |
Glad you got it working, in over 30 years I have never known Farnell to send a wrong part. was that the sensor required a resistor to be placed between the Vin and Vcc ports. With this in place, the sensor is functional. That resistor is called a pull up resistor, it was mentioned several times. Note that enabling the internal pull up resistors would have been a solution as well. This is done by doing a digitalWrite HIGH to the input pin you are using.
|
|
|
|
|
Logged
|
|
|
|
|
Cumming, Ga
Offline
Edison Member
Karma: 12
Posts: 1389
Ultimate DIY: Arduino
|
 |
« Reply #14 on: February 01, 2011, 09:28:57 pm » |
Just to be a little helpful here, I have attached the drawing for future reference.
|
|
|
|
|
Logged
|
|
|
|
|
|