Help required for arduino based RPM sensor using hall effect and magnets

Hi all, I am trying to make a RPM sensor for my bot. I am using Arduino and this hall effect sensor that i got:

I have made a small bench setup to prove the concept. See attached snap. I am using 8 equidistant magnets around the perifery of the sprocket. Here is the arduino program:

const int ledPin = 13;
volatile int rpmcount;
int sensorState = 0;
unsigned int rpm;
unsigned long timeold;

void rpm_fun()
{
rpmcount++;
digitalWrite(ledPin, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
}

void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
attachInterrupt(0, rpm_fun, FALLING);
}

void loop(){

if(rpmcount>=5) {
rpm=(60000rpmcount)/(8(millis()-timeold)); //the 8 changes to 4 if 4 magnets are used.
timeold = millis();
//Serial.println(rpmcount,DEC);
rpmcount = 0;
Serial.println(rpm,DEC);
}
}

Here is the problem:
At slow speeds this setup works and i can read correct rpm value on the serial monitor. But at higher speeds, the hall effect sensor does not detect the magnet or the arduino doesnt get the interrupt. The magnets are very powerfull and work from even 15mm away. I have tried this with 4 and 1 magnet around the periphery but at higher speeds the magnet is not detected.

What can be causing this? Is the hall sensor not switching at high enough frequency? Am I messing something in the setup? I have tried changing the distance between the magnet and the sensor but no difference.

20111223_211539-1.jpg

Hi!

my tle4905l datasheet says, that it has a rise/fall time of 1usec...
so it could do easily 100kHz...

the AH180PL datasheet can be found here:
http://www.diodes.com/datasheets/AH180.pdf
it seems to use a lot less power than the tle4905...
and it is used for checking if a cover of a phone is closed or not... (rather slow processes)

it seems like the AH180 cant be fast...

EDIT:
u can test my theory by using less magnets...
e. g. when u use half the number of magnets, the detectable rotation speed should double...

Bye

Try to remove delay from interrupt subroutine, and transfer leds indicator to main loop