Page 2 of 2

Re: Tacho!

Posted: Sun Aug 04, 2024 10:12 am
by chipfryer27
Hi Jorgen

My curiosity is in how you obtain the pulse.

You detect the pulse and start a counter, stopping it once a revolution has occurred. Therefore you are attempting to count in mS the revolution by measuring the length of pulse. Hopefully my understanding is correct so far?

Assume you are rotating at sixty RPM (one revolution per second).
This would be 1000mS which gives 60,000mS / 1000mS = 60 RPM

Using an extreme example, and I appreciate this may not be how you are doing it but serves to illustrate.

Lets say you were using an optical sensor, triggering on "dark" patch stopping on "light" patch. If the dark patch were covering 90 degrees of the target (or one quarter of the circumference) then you would not read 1000mS you would read 250mS which would give 60,000mS/250mS = 240 RPM

Similarly if the "dark" patch covered 359 degrees leaving a small slit of "light" patch you would then read 997.22mS which gives you 60.17 RPM (60,000 / ((1000/360) x 359)).

So you can see that how you obtain the pulse can affect the accuracy of your readings.

If you were only using one sensor i.e. only detecting one event so to speak then you may be better to read your counter on an edge.

Using any of the above optical examples, triggering on "dark", which could be an interrupt set for either high or low (but not both).

Start counter
Take reading
First dark edge is detected.
Take reading (this first reading will most likely not be after a full 360 degrees of travel)
Pass reading on to whatever (subtract previous reading from this to give time for one revolution in mS)
Light edge is detected (do nothing)
Dark edge is again detected (after 360 degrees of travel)
Take reading
Pass reading on to whatever (subtract previous reading from this to give time for one revolution in mS)
Light edge is detected (do nothing)
Dark edge is again detected (after 360 degrees of travel)
Take reading
Pass reading on to whatever
and so on.

Many different technologies to capture RPM, many use magnets (Hall effect, not reed closure), others use optics either reflective or beam-break and some using in-built encoders that provide a chain of pulses for you to decode.

Hopefully the above helps in some way and once we know how you actually detect the revolution I'm sure we can assist further.

Regards

Re: Tacho!

Posted: Sun Aug 04, 2024 6:22 pm
by jgu1
Well well, now I understand chipfreyer :D
Of course. so I can't measure revolutions the way I do where I start a timer and measure on time of the spot, of course see the ligth ;) I understand your nice explanation, logical, yes I have to start timer and wait until one revolution (next time photosensor detect) and stop timer.

But anyway, the other way I do is I use the Timerinterrupt for one second, when this is started I count puls one the other interruptpin, so I get xpulses and when timerinterrupt is one sec I use the value for calculation rpm/min. This example work but in step of 60 because I multiply with 60.

Many many thank“s for your help and explanation :D I will try to change my program.

Jorgen

Re: Tacho!

Posted: Sun Aug 04, 2024 8:30 pm
by chipfryer27
Hi Jorgen

That is of course another option.

Start a one second timer and count how many leading edges occur in that second, then multiply by sixty to give RPM.

Regards