I am assuming there are two pulses per revolution because otherwise the maths does not work
And this approach would be better as all the calculations use the same value of millis()
Usually the two pulses per rotation is because the reed switch and the bar magnet are oriented in parallel. Then magnet rotates N-S for one closure and then S-N for the second closure. One revolution of the magnet.
Paul_KD7HB:
Usually the two pulses per rotation is because the reed switch and the bar magnet are oriented in parallel. Then magnet rotates N-S for one closure and then S-N for the second closure. One revolution of the magnet.
Paul
Hi Paul
So, if I'm understand you correctly, two pulses equals one passing of the magnet bar.
I'm guessing that even if I were to use a donut shaped magnet (which I am) the result would be the same? The magnetic field would be slightly different but the polarisation shift remains, right?
GypsumFantastic:
if(engrotation>=2) means it doesn't calculate rpm on the first rotation. I'm not sure why but that's what it does.
timetaken1 is the time in milliseconds it takes for one rotation.
(1000/timetaken1) is the revolutions per second
(1000/timetaken1)*60 is the revolutions per minute
Ok, that makes sense. Could it be that at startup the rotations isn't reliable when calculating the rpm? If that's the case, maybe it would be appropriate to start count even later?!
I am assuming there are two pulses per revolution because otherwise the maths does not work
And this approach would be better as all the calculations use the same value of millis()