How can I interface hall effect sensor with ATMEGA128 ?

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, the first sentence I read in the datasheet is "This device should not be used for new design applications..." (in 2005).
Else, it has an open collector output and can be tied (with a pull up resistor, say 1..10k) to any logical pin of an avr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Carefully.

No need for a pullup resistor as there's one in the processor you can turn on.

Why use an obsolete sensor? 'Cause he wants to make something and has one on hand, obviously.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or for a museum? 10K wonot harm (and if he forgets to pull up?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

any examples or links ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If I type "Hall Effect Sensor" in to Google then amongst the many links is this near the top:

https://www.google.co.uk/#q=hall...

I'm sure Google probably works similarly wherever you are located and will give you local shopping results too.

Personally I have a favoured supplier for components (Farnell UK) so if I was looking for one I'd probably localise my search to their site and get something like:

http://uk.farnell.com/jsp/search...|0&Ntk=gensearch&Ntt=hall+effect+sensor&Ntx=mode+matchallpartial&suppressRedirect=true&originalQueryURL=%2Fjsp%2Fsearch%2Fbrowse.jsp%3FN%3D2031%2B204543%2B731%26Ntk%3Dgensearch%26Ntt%3Dhall%2Beffect%2Bsensor%26Ntx%3Dmode%2Bmatchallpartial%26No%3D0%26getResults%3Dtrue%26appliedparametrics%3Dtrue%26locale%3Den_UK%26divisionLocale%3Den_UK%26catalogId%3D%26skipManufacturer%3Dfalse%26skipParametricAttributeId%3D%26prevNValues%3D2031%2B204543%2B731

So just 106 to choose from then. A site like Farnell (or Aroow or Digikey or whatever) will not list deprecated parts and will even indicate if a "current" product is nearing EOL.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

how about the code links ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do not need a sensor to test **your** software : a push button connected to the ground acts like an open collector ....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
how about the code links ?

But these things are effectively a 0/1 output. You just wire them to a GPIO and read the PIN don't you? If they have a varying voltage output then wire them to an ADC. Again is Google broken for you or something? If I type "AVR Hall Effect Sensor example code" into Google it hits (amongst others) this:

https://www.sparkfun.com/product...

If I follow their link to "Bildr Tutorial" it hits this:

http://bildr.org/2011/04/various...

That was three clicks away from here - please try searching as many many of the threads you start could be answered in seconds either by searching for previous threads here or using Google.

BTW if I type "hall effect sensor" in the Freaks search it hits 168 previous threads. Surely one of those could help you? Part of the reason for a message board like this is to build a body of knowledge so that the same questions don't need to be asked/answered repeatedly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok thanks for helping..

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But these things are effectively a 0/1 output. You just wire them to a GPIO and read the PIN don't you?

How can I calculate the pulse ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bianchi77 wrote:
But these things are effectively a 0/1 output. You just wire them to a GPIO and read the PIN don't you?

How can I calculate the pulse ?

Have you heard of a "timer"?

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

How can I calculate the pulse ?

To be honest I'm a little astonished that no one in any of those 168 threads I referred to was actually measuring pulses. Have you really read all 168? Did none of them have any useful advice?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:
bianchi77 wrote:
But these things are effectively a 0/1 output. You just wire them to a GPIO and read the PIN don't you?

How can I calculate the pulse ?

Have you heard of a "timer"?

Yes, I've heard about timer, how to use it as a counter of hall effect sensor pulse ?

thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Quote:

How can I calculate the pulse ?

To be honest I'm a little astonished that no one in any of those 168 threads I referred to was actually measuring pulses. Have you really read all 168? Did none of them have any useful advice?

I've tried to use the search with "hall effect sensor" but they're not clear on how to use it with code on ATMEGA128...

I don't understand on how to compare the pulse or count the pulse from hall effect sensor on my GPIO,

....if you have ideas ?
thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you want to do with your sensor:
* detect the presence of a magnet (like a push button, but with excellent insulation and no bounces)
* detect the time it takes to a wheel (say) to turn 2*pi -and you glue a magnet in it-
* make a compass (you should use two analogic Hall effects sensors, and compensate them for offsets, which is very complicated IIRC)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there any simple ways to implement it ?
I saw from arduino

it's pretty straight forward
http://garagelab.com/profiles/blogs/tutorial-how-to-use-the-hall-effect-sensor-with-arduino?xg_source=activity

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is a pulse output, then it is no different from any other pulse. As far as determining pulse frequency or pulse width, the fact that it is a Hall device is not important. Hint: look up "input capture" in your spec sheet.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

From the tutorial you linked, the magnetic sensor is used a a non-bouncing switch: its states are tested, not a pulse duration.

statePin=digitalRead(hallPin);
converts to

// let us suppose your sensor is connected to PORTA.5

#define hallPortDir DDRA
#define hallPortData PORTA
#define hallPin (1<< 5)

hallPortDir = ~hallPin & hallPortDir;
statePin= hallPortData & hallPin ;
(then it can be tested for open -statePin != 0) or closed -statePin == 0-)

You should really tell what you want to do (mimicking/cloning the tutorial you linked to is logically incompatible with
pulse duration measurement)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
How can I calculate the pulse ?
Stop timer.
Clear timer.
Wait for beginning of pulse.
Start timer.
Wait for end of pulse.
Read timer value.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dbrion0606 wrote:
From the tutorial you linked, the magnetic sensor is used a a non-bouncing switch: its states are tested, not a pulse duration.

statePin=digitalRead(hallPin);
converts to

// let us suppose your sensor is connected to PORTA.5

#define hallPortDir DDRA
#define hallPortData PORTA
#define hallPin (1<< 5)

hallPortDir = ~hallPin & hallPortDir;
statePin= hallPortData & hallPin ;
(then it can be tested for open -statePin != 0) or closed -statePin == 0-)

You should really tell what you want to do (mimicking/cloning the tutorial you linked to is logically incompatible with
pulse duration measurement)


So for example I put timer for 30 seconds, then count how many pulse from hall effect ?

What's the pseudo code for it ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hall effect does not generate pulses (a magnetic field is converted into a voltage: ask wikipedia). With the sensors you show (and each and every link you gave), it generates logic levels.... (but could generate analog values, in order to know where the North is -useful for explorers and for some religions-)