|
Overflow?
Clock tick period? If this is shorter than you expected, you will get silly results if you try to time between two consecutive pulses.
If the rising edge isn't high / sharp enough, it could be triggering early or late?
But of course, sticking a scope probe on the pulse may change the results ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I check the overflow condition by short circuiting with an early return if old_tick_us is greater than tick_us if that makes sense. In that case I just don't use that reading.
I've verified I'm getting the ticks because I've tried #1.
I've even tried taking a sample only every ten revolutions (20 ticks) and counting the duration between that and the initial tick and I don't get better results - can't remember what they were and I'm getting a friend's help to test since I don't currently have a power supply that can run a fan - one is on order.
Edit:
OriginalGriff wrote: If the rising edge isn't high / sharp enough, it could be triggering early or late?
I missed this somehow when I first read your post. Interesting. The only thing that makes me doubt it is the RPM readings I'm getting are so bloody low - single digits when they should be four digits. It makes me think there's a deeper issue.
To err is human. Fortune favors the monsters.
|
|
|
|
|
Not knowing what hardware you are using, just a thought that maybe irrelevant - but have you got any components (capacitors/inductors that in conjunction with resistors or internal resistance of other components) that may have accidentally created a filter that is tuned to roughly the frequency you would be expecting and either attenuating the signal or passing it to ground?
Maybe an idea to use an optical isolator to separate the output signal totally from the inductive load of the fan motor???
|
|
|
|
|
I do share a ground with the fan but they are on a different power supply than the MCU that is taking the reading.
There aren't any components in the circuit other than a level shifter, which I know can handle these frequencies because I routinely use them with I2C devices.
Edit: I should add, I am getting all the ticks because method #1 in my original post works.
To err is human. Fortune favors the monsters.
|
|
|
|
|
Can't you just output the duration between pulses, in order to discriminate between a measure error or computation error?
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
The only reason I haven't done that yet - admittedly part of it is laziness - is it complicates the code and I'm not sure what readings I should be expecting as I have no practical concept of a microsecond vs a spinning fan.
To err is human. Fortune favors the monsters.
|
|
|
|
|
You should get about 18 msec for 1700 rpm (about 6 sec for 5 rpm).
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
If method 1 works and method 2 does not, then there is either an error in the time recorded or an error in the maths.
You should be getting about 17000 microseconds between pulses. How many did you get?
(60s/1700 rpm = 0.035 s per rotation = 17000 microseconds per 1/2 rotation)
|
|
|
|
|
#Worldle #335 2/6 (100%)
π©π©π©π©π¨β¬οΈ
π©π©π©π©π©π
https://worldle.teuteuf.fr
one of two possibles.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Wordle 552 4/6
β¬β¬π¨π©β¬
β¬π¨β¬π©π¨
β¬β¬π¨π©π©
π©π©π©π©π©
With apologies for getting yesterday's title wrong!
|
|
|
|
|
Wordle 552 5/6
π©β¬β¬β¬β¬
π©β¬π¨β¬β¬
π©π¨π¨β¬β¬
π©β¬π¨π¨π¨
π©π©π©π©π©
|
|
|
|
|
Wordle 552 4/6
β¬π¨π¨β¬β¬
β¬π¨π©π¨β¬
π©π¨π©β¬π©
π©π©π©π©π©
|
|
|
|
|
Wordle 552 3/6
π©π¨π¨β¬β¬
π©β¬π¨π¨π¨
π©π©π©π©π©
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 552 3/6*
β¬π¨β¬π¨π¨
β¬π¨π©π©β¬
π©π©π©π©π©
Happiness will never come to those who fail to appreciate what they already have. -Anon
|
|
|
|
|
Wordle 552 4/6
🟩β¬β¬β¬🟨
🟩β¬🟨β¬β¬
🟩β¬🟨🟨β¬
🟩🟩🟩🟩🟩
|
|
|
|
|
β¬π¨π¨β¬β¬
β¬π¨π©β¬β¬
π©β¬π©π¨β¬
π©π©π©π©π©
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming βWow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 552 5/6
π¨β¬β¬β¬β¬
π©β¬β¬β¬β¬
β¬β¬π¨β¬β¬
π©π¨β¬π¨β¬
π©π©π©π©π©
|
|
|
|
|
Wordle 552 3/6
π©β¬π¨β¬β¬
π©β¬π©π¨β¬
π©π©π©π©π©
Get me coffee and no one gets hurt!
|
|
|
|
|
Wordle 552 3/6*
β¬π¨β¬π¨β¬
β¬π¨π©π©β¬
π©π©π©π©π©
|
|
|
|
|
Wordle 552 6/6
β¬π©β¬β¬β¬
β¬π©β¬β¬β¬
β¬π©β¬π¨π©
π¨π©β¬π©π©
β¬π©π©π©π©
π©π©π©π©π©
doh
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
The first French fries weren't cooked in France. They were cooked in Greece.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
I believe that the first freedom fries were cooked in the USA. Maybe all.
|
|
|
|
|
LOL. Good one
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Wordle 551 5/6
β¬β¬β¬π¨β¬
β¬π¨β¬π©π©
β¬β¬π¨π©π©
π©π©β¬π©π©
π©π©π©π©π©
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Sorry. I got yesterday's title wrong and put 531.
|
|
|
|