Page 1 of 1

How to calculate rpm (50 - 120 rpm) fast refresh rate.

Posted: 05 Oct 2021, 20:15
by borre
Hello
This is my second project with esp easy.
I have a old spinning bike with a display which shows the rpm of cranks/peddels.
The display hardware is broken (corrosion of sweat)
The sensor on the wheel looks like it stil works.
So I like to use this to calculate the rpm.
When I put gnd and D7 to sensor, I get 3 pulses every turn.

now I use the Generic - Pulse Counter to count the pulses.
but how to convert this to rpm.
I have set the interval of the pulse counter to 1 second.
and use these rules to display them on my oled

Code: Select all

on teller#Time do
	oledframedcmd, 1, "Time: [teller#Time]"
endon

on teller#Count do
	oledframedcmd, 2, "rmp: [teller#Count]"
endon
the formula with "count" value gives a good value, but it is in steps of 10 rmp's
and some time it goes up or down, I think because sometimes you have for example 2,5 count in a second, which counts as 2.
how can I get beter and more accurate rpm.
I need a quite fast update speed on my display

also esp easy gives me a warning of a daily write limit, I think because the interval of 1 second?

The rpm is between 50 till 120 rpm, not so fast of a fan or motor.
Image

I also try to create a button of D7 and
calulate the miliseconds between the pulses to calculate the rpm.
But this works not very accurate.
use these rules:

Code: Select all

on Button#State do
	oledframedcmd, 1, "State:[Button#State]"
	oledframedcmd, 3, "time: %uptime_ms% "
	if [Button#State] = 0
		let,2,60000/((%uptime_ms%-[VAR#1])*3)
		let,1,%uptime_ms% 
	endif
	oledframedcmd, 2, [VAR#2]
endon

Re: How to calculate rpm (50 - 120 rpm) fast refresh rate.

Posted: 05 Oct 2021, 20:55
by TD-er
The flash write limit is probably because you were testing a lot.
You can power cycle the node to clear the warning (and it will prohibit writes too, not just a warning), or give the command

Code: Select all

resetflashwritecounter
about getting a more stable RPM and still get a decent update rate, you can try to store the last 3 values in a variable and average over them.

Re: How to calculate rpm (50 - 120 rpm) fast refresh rate.

Posted: 07 Oct 2021, 22:04
by borre
TD-er wrote: 05 Oct 2021, 20:55
about getting a more stable RPM and still get a decent update rate, you can try to store the last 3 values in a variable and average over them.
ah I try to average it over 3 pules and that goes beter.
but if I am over 50/60 rpm the reading gets terrible.
Could it be that a esp is to slow to do the reading and calculation?

my code is like this now:

Code: Select all

On System#Boot do
  GPIO,13,2
  Monitor,GPIO,13
  let,1,%uptime_ms%
  let,2,0
  let,3,0
endon

On gpio#13=1 do
	let,3,[VAR#3]+1
	if [VAR#3]>2
		# 3 pules are 1 round.
		let,4,60000/(%uptime_ms%-[VAR#1])
		oledframedcmd, 3, "rpm: [VAR#4]"
		let,1,%uptime_ms%
                let,2,0
                let,3,0
	endif
endon

Re: How to calculate rpm (50 - 120 rpm) fast refresh rate.

Posted: 08 Oct 2021, 20:28
by TD-er
Better use the pulsecounter for this, as rules parsing does take quite some time.
The pulsecounter can be set to send an event once a second, which is doable for rules parsing.

Also to tune it, place the most frequently occuring event at the start of the 1st rules file.

Re: How to calculate rpm (50 - 120 rpm) fast refresh rate.

Posted: 09 Oct 2021, 09:16
by borre
TD-er wrote: 08 Oct 2021, 20:28 Better use the pulsecounter for this, as rules parsing does take quite some time.
The pulsecounter can be set to send an event once a second, which is doable for rules parsing.

Also to tune it, place the most frequently occuring event at the start of the 1st rules file.
ah plusecounter works much faster indeed.
I have now this settings:
Image
I needed to set the "mode type" to PULSE low, this works great now.

using these rules:

Code: Select all

on teller#Time do
    let,4,round((60000/([teller#Time]*3))*0.9)
    oledframedcmd, 1, [VAR#4]
endon
one question left, i have a SSD1306 oled display.
use the settings below.
I expected that if I set 1 line per frame that I get a realy big large font
but the font size is like 1/3 of the screen height, how can I enlarge this?
Image
Image

Re: How to calculate rpm (50 - 120 rpm) fast refresh rate.

Posted: 09 Oct 2021, 10:22
by TD-er
I don't think larger fonts are included for that display.