Pages: [1]   Go Down
Author Topic: Hall Effect Wheel Speed, next step  (Read 1080 times)
0 Members and 1 Guest are viewing this topic.
Newcastle, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please note: Currently trying to set up a hall effect sensor for the wheel speed of a car. Eventually we will have discs with teeth to produce a good signal but currently just using a lump of metal and mr arm to generate the signal. Using UNO R3

So what I have so far is a hall effect sensor that outputs an analogue signal and I have managed to read this and convert it to a 1 or 0 stored in a variable "hallval". The led part is just so I can see it working.

Code:
int hallPin = A0;
int ledPin = 13;
int val;
int hallval;


void setup()
{
 pinMode(hallPin, INPUT_PULLUP);
 pinMode(ledPin, OUTPUT);
 Serial.begin(9600);
}

void loop()
{
  val = analogRead(hallPin);
  if (val <= 75) digitalWrite(ledPin, HIGH);
  else if (val > 75) digitalWrite(ledPin, LOW);
  if (val <= 75) hallval = 1;
  else if (val > 75) hallval = 0;
  Serial.println(hallval);
  delay(1);
}

What I need to do, or think I need to do is now measure the time it takes to switch "hallval" from 1 to the next "1" in order to calculate the speed.

So I have two questions, given that this is the sensor I have right now and cannot buy new ones.. yet.

1) Is what I have done so far good enough / does anyone know an easier way to achieve what I require?

2) How can I measure the time from 1 to the next 1? are there any functions you can suggest the might help me.
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have to use interrupts, there are a number of ways. Make sure your hall sensor can switch fast enough too

http://www.societyofrobots.com/robotforum/index.php?topic=14973.0

German but you can use google translate and code is still the same
http://saduino.ch/mechatronic/index.php?article=umdrehungsgeschwindigkeit-von-stirling-motor-mit-hallsensor-messen

This code also depends on whether you have a latch sensor or not.
Logged

Germany
Offline Offline
Full Member
***
Karma: 1
Posts: 141
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

what I would do is: connect the signal of your hall effect sensor to one of the interrupts of the arduino. Make a interrupt routine that increments a variable every time the routine is called. In the main loop subtract the value of the variable 1 second before from the current value of the variable. Then you have the number of pulses per second. Now you can calculate RPM or the time for one revolution.

Elektrix
Logged

My blog about arduino and Linux themes:
http://heliosoph.mit-links.info/

Newcastle, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies, I will look into the interupt function and update on progress.
Logged

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

 Note that hall effect sensors come in different 'flavors'. Yours appears to be one that outputs a analog voltage relative to the magnetic field strength being sensed? Others come as simple digital switches that out either a logic high or low depending on if the magnetic field being sensed is above or below a specific value. A digital hall sensor would be better to use as a speed detector as you can easily interface it as a interrupt and use timers to keep track of the last change of signal to the next change of signal and then calculate the speed based on the delta time passed.

 Now what I do not understand is how a hall effect will work with just metal gear teeth? A hall effect senses the strength (and in some cases the polarity) of a external magnetic field. Unless the gear is magnetized I don't see where there is a magnetic field to be sensed in your application? There are speed sensors that are designed to just sense gear teeth, called variable reluctance sensors that work on a different principle as the magnetic field is generated internal inside the sensor and the rotating teeth effect the magnetic field and is sensed by the internal circuitry of the speed probe. Perhaps a link to the sensor you are using will verify if it's best suitable for your application?

Lefty
Logged

Newcastle, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry quick reply but this is the datasheet, we have used this on a previous car for some testing although we believe it is too slow for the higher speeds

http://sensing.honeywell.com/index.php?ci_id=50300
Logged

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

sorry quick reply but this is the datasheet, we have used this on a previous car for some testing although we believe it is too slow for the higher speeds

http://sensing.honeywell.com/index.php?ci_id=50300

Interesting sensor. It's not a pure simple hall effect sensor as it has an internal magnetic field generator that 'biases' the sensor such that rotating teeth will effect the field. It's also outputs a pure digital signal so you should not be reading it with a analog input pin using a analogRead() statement, but rather read it as a digital input signal using digitalRead() commands or better yet learn how to use the user interrupt functions on the arduino using digital pins 2 or 3 (on a Uno) board.

 As far as maximum speed capabilities you will have to work out the minimum time between teeth to see that you are not exceeding a maximum switching speed of the sensor. The key spec seems to be:

Quote
Fast operating speed – over 100 kHz

 This will of course be related to the number of teeth on the gear wheel and the maximum RPMs of the wheel. Less teeth would allow higher maximum RPM.

Lefty
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You might find some relevant content here -

http://rcarduino.blogspot.ae/2013/06/rc-arduino-traction-control-traction.html

Duane B

rcarduino.blogspot.com
Logged


Pages: [1]   Go Up
Jump to: