Hello,
I've been lurking around here for abit, but I never had an account...

My issue is this:
I am working on a harddrive clock (essentially the same as this one:
link), however I am not using a standard hall sensor.
The hall sensor I am using is salvaged from a defunct blackberry curve 8330, which uses hall sensors for trackball input. I have confirmed that the following datasheet is correct: (
link). This sheet shows that the hall sensor is capable of measuring microsecond durations at a minimum (I think). I am supplying the sensor with GND and 5V and am simply interfacing with pin5 via analog input (is this the best way?). There are no capacitors, etc on the output line.
...this is the sensor by the way, it's pretty small!The issue I am experiencing is that with the simplest code I can write I am not getting delay times (per rotation) of under 30 ms, which is incorrect (5400 rpm == 5.5 ms per rotation).
double hall = 0, hallpre = 0;
const int baseline = 1023;
const int sensitivity = 20;
boolean state = false;
unsigned long timerotat, timerotatprev, triggertime;
void setup()
{
Serial.begin(9600);
Serial.println("Welcome to Paul's HDD Clock debug output!");
delay(100);
}
void loop()
{
timerotat=millis(); // save the current time while magnet is NOT on sensor
hall = analogRead(A1);
while((hall < (baseline-sensitivity)) ) //& ((millis()-triggertime)>1)) //<- use with a filter value to stop flickering stopped on sensor
{
if (!state)
{
digitalWrite(13,1);
state=true;
timerotatprev=timerotat; //the magnet crossed the sensor, output the current value - previous for rotation time after spun-up
}
hall = analogRead(A1);
};
state=false;
digitalWrite(13,0);
}
Here is typical output once the drive is spun up at 5400 rpm.
passed in: 34ms
passed in: 34ms
passed in: 33ms
passed in: 33ms
passed in: 34ms
passed in: 34ms
passed in: 33ms
passed in: 34ms
passed in: 33ms
passed in: 34ms
passed in: 33ms
passed in: 34ms
Any help would be awesome!