Pages: [1] 2   Go Down
Author Topic: Magnetic Sensor  (Read 3975 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Everybody,

Im pretty new to the arduino, and I was looking for any insight into using a hall sensor to simply detect a magnet with the arduino.  I would also like to visualize any output with an LCD, 7 segment display, or LED.  Any help with coding and circuitry would be greatly appreciated!
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6893
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Welcome! A hall sensor is not hard to use. Take a look at this one:

http://www.sparkfun.com/products/9312

You should try to break down your project into pieces such as understanding the hall sensor, understanding an LCD, and then putting them together.

sample code:
void setup()
{
  Serial.begin(19200);
  pinMode(2,INPUT);
  digitalWrite(2,HIGH);
}

void loop()
{
  Serial.println(digitalRead(2));
  delay(200);
}
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! Ill definitely get started
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How would I connect the arduino with the sensor?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31452
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Take the output of the sensor and connect it to one of the pins. Make sure the sensor's ground is connected to the arduino's ground as well.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12451
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


check - http://www.arduino.cc/playground/Code/HallEffect
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6893
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Observe the type of sensor that you use. One type of sensors only switch from High to Low when magnet's polarity is swapped and you may want the other type, where it goes from High to Low when the magnet is removed. But it doesn't responds to the opposite magnetic pole.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been using an allegro 1302eua hall effect sensor as part of a rover we're building in our school.  It's not the latching sort, so it returns a voltage proportionate to the magnetic strength it's detecting.  Baseline output is 1/2 supply (2500mV on a 5V supply) and a N pole increases the voltage and a S pole decreases it.

I borrowed a pretty rubbish magnet from the physics department and the sensor picked it up from a good 70mm away.

The supplier I used in the UK sells them for about £1.35 plus postage.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 509
Posts: 31452
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just for reference there are many types of hall sensors:-

1) Liner sensors - give an output proportional to the field, used in current detectors and such.

2) Switch - outputs zero or one.
    a) In the presence of a specific magnetic field direction- non latching unipolar.
    b) In the presence of any magnetic field - non latching bipolar.
    c) Reflecting the last field seen - latching.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6893
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In addition, if you got the old non-ic sensor, just to Hall probe, you need to flow current through the sensor and monitor voltage across it. The voltage could get negative and gets very big if you move your magnet too fast. This type of sensor is not very fit for arduinos. The ones we talk about are mostly 3-pin TO-92(?! right?) ones.
Logged


Lancashire, UK
Offline Offline
Edison Member
*
Karma: 8
Posts: 1992
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Personally I'm a fan of old fashioned reed switches, cheap and simple.......
Logged


Central MN, USA
Offline Offline
Tesla Member
***
Karma: 64
Posts: 6893
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Personally I'm a fan of old fashioned reed switches, cheap and simple.......

Definitely vote for Reed switches, no power is needed to drive the sensor and it can pass a moderate amount of current to power a device. On the other hand, Hall sensors can be made more sensitive with internal gains and much smaller packages.
Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16517
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

However, some reed switches tend to have some amount of contact bounce you have to deal with.
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 8
Posts: 1992
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

A capacitor and resistor takes care of the contact bounce smiley-wink
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks everybody for the help! But I havent gotten anything to work yet...Im still confused as to how exactly I need to set everything up...I have a breadboard, resistors, wiring my arduino and my sensor...am I missing something? If anyone had a diagram for a simple magnetic sensor, it would help greatly!
Logged

Pages: [1] 2   Go Up
Jump to: