How to measure speed of three air fans?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

How to measure speed of three air fans?

#1 Post by themanfrommoon » 24 Aug 2017, 12:02

Hi,

I would like to measure the speed of three air fans (under 2000 rpm).
I already installed three infrared obstacle devices, connected them to a nodemcu and use ESP Mega dev 11.
I want the output in actual or average rpm, one value per minute.
But what needs to be choosen in the software?

I tried "Pulse Counter", but then I have no idea what to choose and to set in the settings.
I cannot find any documentation.

What is the meaning of:
Counter type:
Delta
Delta / Total / Time
Total
Delta / Total
Mode Type:
LOW
CHANGE
RISING
FALLING

Please help me.

Thanks and best regards,
Chris

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: How to measure speed of three air fans?

#2 Post by LisaM » 24 Aug 2017, 14:17

To little information to help:
- Which air fans?
- What connections do they have?
- etc...

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#3 Post by themanfrommoon » 24 Aug 2017, 14:49

Hi Lisa,

the fans doesn't matter, because they only rotate, no matter which type, which connection or anything else. The only interesting thing is the Speed, because of it's maximum frequency. The fans are from the heat pump of my house, and I want to log WHEN they are running at WHICH SPEED with the volkszähler https://www.volkszaehler.org/ application.
The speed is under 2000 rpm which means a maximum frequency of about 33,3 Hz. I think this frequency is low enough to be no high frequency problem.

As I wrote before I use IR obstacle avoidance sensors and reflex marks to recognize if the fan is rotating.
Just google it: https://www.google.de/search?q=ir+obsta ... nce+sensor
Image
source: https://img.banggood.com/thumb/view/upl ... %20(1).JPG

My question is not the Hardware. This works fine.

My question is the Software:
What is the meaning of:
Counter type:
Delta
Delta / Total / Time
Total
Delta / Total
Mode Type:
LOW
CHANGE
RISING
FALLING

Please help me.

Thanks and best regards,
Chris

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: How to measure speed of three air fans?

#4 Post by LisaM » 24 Aug 2017, 17:36

https://github.com/letscontrolit/ESPEas ... _Pulse.ino = RTBFC
Quite simple: The change detection will detect both rising and falling edges. Low is just that: pulse has low value.
Delta / Total / Time:

Code: Select all

String options[4] = { F("Delta"), F("Delta/Total/Time"), F("Total"), F("Delta/Total") };

        UserVar[event->BaseVarIndex] = Plugin_003_pulseCounter[event->TaskIndex];
        UserVar[event->BaseVarIndex+1] = Plugin_003_pulseTotalCounter[event->TaskIndex];
        UserVar[event->BaseVarIndex+2] = Plugin_003_pulseTime[event->TaskIndex];

switch (Settings.TaskDevicePluginConfig[event->TaskIndex][1])
        {
          case 0:
          {
            event->sensorType = SENSOR_TYPE_SINGLE;
            UserVar[event->BaseVarIndex] = Plugin_003_pulseCounter[event->TaskIndex];
            break;
          }
          case 1:
          {
            event->sensorType = SENSOR_TYPE_TRIPLE;
            UserVar[event->BaseVarIndex] = Plugin_003_pulseCounter[event->TaskIndex];
            UserVar[event->BaseVarIndex+1] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            UserVar[event->BaseVarIndex+2] = Plugin_003_pulseTime[event->TaskIndex];
            break;
          }
          case 2:
          {
            event->sensorType = SENSOR_TYPE_SINGLE;
            UserVar[event->BaseVarIndex] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            break;
          }
          case 3:
          {
            event->sensorType = SENSOR_TYPE_DUAL;
            UserVar[event->BaseVarIndex] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            UserVar[event->BaseVarIndex+1] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            break;
          }
        Plugin_003_pulseCounter[event->TaskIndex] = 0;

Meaning for the code noobs:
Delta = Number of pulses since last read
Total = Total number of pulses counted since first reading
Time = Total time passed since start of measuring

By the way, it also has a bug:

Code: Select all

          case 3:
          {
            event->sensorType = SENSOR_TYPE_DUAL;
            UserVar[event->BaseVarIndex] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            UserVar[event->BaseVarIndex+1] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            break;
          }
Is incorrect, (Delta/Total), it should be:

Code: Select all

          case 3:
          {
            event->sensorType = SENSOR_TYPE_DUAL;
            UserVar[event->BaseVarIndex] = Plugin_003_pulseCounter[event->TaskIndex];
            UserVar[event->BaseVarIndex+1] = Plugin_003_pulseTotalCounter[event->TaskIndex];
            break;
          }
I'm to lazy to fix it, please report it as a bug including the solution mentioned above!

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#5 Post by themanfrommoon » 24 Aug 2017, 18:01

Hmmmm, okay.

And how to get a value for rpm?
This means pulses per minute?

Thanks and best regards,
Chris

LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: How to measure speed of three air fans?

#6 Post by LisaM » 24 Aug 2017, 18:19

themanfrommoon wrote: 24 Aug 2017, 18:01 Hmmmm, okay.

And how to get a value for rpm?
This means pulses per minute?

Thanks and best regards,
Chris
Duh, pulse delta/time delta = rpm...

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#7 Post by themanfrommoon » 24 Aug 2017, 18:58

I know that pulse delta / time delta (seconds) x 60 equals to rpm. Thats not the problem.

The question is how to setup this in ESPEasy / Mega?

Actually it shows some values (but this is not RPM):
PulseCounter1.PNG
PulseCounter1.PNG (6.58 KiB) Viewed 16754 times

What needs to be choosen and written in all of these fields?

PulseCounter2.PNG
PulseCounter2.PNG (20.33 KiB) Viewed 16754 times


Thanks a lot for your help and best regards,
Chris

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to measure speed of three air fans?

#8 Post by grovkillen » 24 Aug 2017, 19:01

Debounce 1mSec is not recommended. Try something between 100mSec and 500mSec (I generally work my way down from 500mSec until I find a good value).

The time is whatever you set as delay. You need to make that 60 if you want it to be rpMINUTES.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:


Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: How to measure speed of three air fans?

#10 Post by Shardan » 24 Aug 2017, 19:55

A debounce of 500msec (half a second) might be a bit much for a fast rotating fan.

A given maximum of 2000 rpm says 33,333 rotations per sec or 30msec/rotation.
So the debounce value has to remain under the value of 30msec.

This should work anyways.
The debounce was originally created to suppress the bouncing of mechanical contacts.
This sensor has an electronic output like a powermeter S0 so low debounce values
should work. I'd test values between 5 and 20 ms here.
Regards
Shardan

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#11 Post by themanfrommoon » 26 Aug 2017, 22:00

I built a testing device
PulseCounter5.jpg
PulseCounter5.jpg (85.7 KiB) Viewed 17558 times
It has one small fan with a black/white mark on it.
I installed two of the IR obstacle avoidance sensors.
I connected everything together.
I measured the frequenzy with my multimeter.
It has around 65Hz which is a speed of around 3900rpm and is has a period time of around 0,015 seconds or 15 milliseconds.
PulseCounter6.jpg
PulseCounter6.jpg (81.46 KiB) Viewed 17558 times
ESPEasy Mega is counting the pulses.
It gives "Count", "Total" and "Time".
I think I found out the follwing:
"Count" sums up the pulses until the time of "Delay" is reached and then resets the counter to zero and restarts counting.
"Total" sums up the pulses from starting counting to........ I guess sometime the variable is full. Maybe then it is reset to Zero or it will cause an error, no idea.
"Time" is the time in milliseconds between two pulses. But how accurate will this be? I guess only rounded to complete milliseconds, which will be very low accuracy for revolutions per Minute. For example 15 milliseconds period time equals to 4000rpm, 16 milliseconds period time equals to 3750 rpm. This is not very accurate.

But how should it be possible to get a rpm value?

The only thing is the measured period time.
So I tried following formula:
1 / 15milliseconds period time * 60 seconds/min * 1000 milliseconds/second equals to 4000 rpm. This should work.
For ESPEasy the formula could be simplified to
60000/%value%

I tried this, but it doesn't work.
It seems that the formula does not work:
PulseCounter3.PNG
PulseCounter3.PNG (19.69 KiB) Viewed 17558 times
PulseCounter4.PNG
PulseCounter4.PNG (6.4 KiB) Viewed 17558 times


So finally the question is still not answered:

How to get a rpm value?

Any idea?

Thanks a lot and best regards,
Chris

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: How to measure speed of three air fans?

#12 Post by Shardan » 26 Aug 2017, 22:09

besides accuracy your formula is wrong.

Code: Select all

60000 / %value%
should work.

Put spaces as written in the example. I've just today noticed that 60/%value% might not work, but 60 / %value% should work.

Regards
Shardan
Regards
Shardan

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#13 Post by themanfrommoon » 26 Aug 2017, 22:18

Hi Shardan,

thanks for your reply.

I also tested as you recommend:

Code: Select all

60000 / %value%
The result is: no Change. The screen looks still like (Time: 15) but there should be a value of 4000 (rpm) according to the formula)
Image
It seems that the formula does not work.

Any idea why it does not work?

Best regards,
Chris

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: How to measure speed of three air fans?

#14 Post by Shardan » 27 Aug 2017, 00:30

Not really...
I have same fault on some sensor values i tested with.

Maybe try

(60 / %Value%) * 1000

i don't know where the limit of these values is, 60000 might simply be too long for the internal value.

Another way might be to use a dummy device and feed it via a rule.
Create a dummy device with the Simulate data type = SENSOR_TYPE LONG
In the task 4 for example.

Create a rule like this:

Code: Select all

on Fan Speed 1#Time do
   TaskValueSet 4,1,60000/[Fan Speed 1#Time]
endon
I'd suggest to change the name of the device itself to Fan_Speed_1 as spaces might lead to failing rules.
(Change the name in the rule accordingly! No spaces in the formula here!)
Regards
Shardan

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#15 Post by themanfrommoon » 28 Aug 2017, 10:30

I tried a very easy formula like
%Value% + 10

But this does not work. It does not change the value. It still shows a time of 15. If I stop the fan, then the time value changes. So the testdevice works, but the formula of the counter task does not work.

The result is simply: No formula works within the counter task.
(I removed all tasks and setup only the first task as a counter task on pin GPIO-13 (D7)) for testing.

Then I followed your idea to use a dummy device.

The setup of the sensor task is defined as follows:
PulseCounter5.PNG
PulseCounter5.PNG (18.53 KiB) Viewed 17505 times
The dummy device is as follows:
PulseCounter6.PNG
PulseCounter6.PNG (13.17 KiB) Viewed 17505 times
The rule is like this:
PulseCounter7.PNG
PulseCounter7.PNG (9.99 KiB) Viewed 17505 times
The result is this:
PulseCounter8.PNG
PulseCounter8.PNG (27.9 KiB) Viewed 17505 times
or
PulseCounter9.PNG
PulseCounter9.PNG (28.12 KiB) Viewed 17505 times
This basically works :-)

....but the accuracy is very poor as expected :-(
The accuracy is a step of 250rpm at about 4000rpms due to the fact that the time between two pulses can only be measured down to full milliseconds.

The reason is, that the speed is calculated by the time between two pulses.
The time between two pulses is "only" measured in full milliseconds.
This means with a time between two pulses of 16 milliseconds this equals to 60000/16= 3750rpm
With a time between two pulses of 15 milliseconds this equals to 60000/15= 4000rpm
(....the values in above shown screenshots looks wrong, but the reason is, that there is a delay between the Fan1 pulse counter and the DummyFan1 calculated speed value)
I calculated the following table:
PulseCounter10.PNG
PulseCounter10.PNG (9.05 KiB) Viewed 17505 times
The result of this test is clear:
The counter task like it is today (ESP mega dev 11) cannot be used to measure fan speed rpms :-(

Any other idea to measure speed of three air fans?

It would be great to count the pulses for 60 seconds, then use this value as output and reset it to Zero to start the procedure again.
One speed value every 60 seconds (or adjustable period) would be sufficient.
Any idea how to do this?

Thanks and best regards,
Chris

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#16 Post by themanfrommoon » 28 Aug 2017, 11:16


LisaM
Normal user
Posts: 513
Joined: 11 Apr 2017, 18:29

Re: How to measure speed of three air fans?

#17 Post by LisaM » 28 Aug 2017, 13:55

themanfrommoon wrote: 28 Aug 2017, 10:30 Any other idea to measure speed of three air fans?
Pics of the fans please,particularly the connections (wires) from the fan...
If they are 3-wire (or more) fans they might rpm fans: http://pcbheaven.com/wikipages/How_PC_Fans_Work/ :(
3rd wire contains pulses which can be counted...

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#18 Post by themanfrommoon » 28 Aug 2017, 15:09

....I didn't expect that this topic is so hard to understand... okay, let's try to explain it again, hoping for a solution:

@LisaM:
Please read my post #3:
viewtopic.php?p=18570#p18570
It is no question of the hardware!
It is only a question of the software. The hardware works without any issue :-)
But especially for you: Here are the two sorts of fans I am interested in measuring the speed:
Two pieces of this fan:
Fan1.jpg
Fan1.jpg (299.85 KiB) Viewed 17484 times
And one piece of this fan:
Fan2.jpg
Fan2.jpg (283.03 KiB) Viewed 17484 times
I will attach some reflex marks as I did on the testing device.

The electric wires are not possible to reach.
I'm not interested in finding another solution on the electric side.
I'm not interested in finding another solution to measure the speed.
The fans are only accessible on the mechanic side.

The speed will be measured like this:
Image

This is the pulse that is coming out of the testing device on my old Hameg Scope:
PulseCounter11.jpg
PulseCounter11.jpg (97.94 KiB) Viewed 17484 times
And this is the pulse which directly comes out of the tachometer output of the PC fan from the testing device, just for reference:
PulseCounter12.jpg
PulseCounter12.jpg (109.78 KiB) Viewed 17484 times
You see, that the pulse of the test device is much better, clearer and sharper than the pulse of the PC fan.
The hardware is perfect :-)
THIS WORKS PERFECTLY :-)

The PROBLEM is the SOFTWARE :-)

I'm not able to get a value out of ESPEasy Mega dev 11 which generates a "pulses per minute" value which is the same like "revolutions per minute".

I supply a pulse between 3Hz and 70Hz and I want ESPEasy to show a value of pulses per minute every 60 seconds. That's all.

I hope now the problem is clear?

Thanks and best regards,
Chris

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to measure speed of three air fans?

#19 Post by grovkillen » 28 Aug 2017, 17:54

Sorry if I come across as ignorant but have you tried the "Delta" as "counter type" and the delay set to "60"?

Since you're able to test the rpm with external tachometer you can test and see if the pulses from the ESP Easy matches those numbers. Use debounce time to manipulate the values. If you get stable readings with higher debounce time you can use formula to multiply that value to match the true value. (For example of the ESP Easy miss every four pulse you multiply the value with the formula %value% * 4 / 3.)
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

themanfrommoon
Normal user
Posts: 48
Joined: 23 May 2017, 21:38
Location: Malente / Germany

Re: How to measure speed of three air fans?

#20 Post by themanfrommoon » 28 Aug 2017, 22:57

I'm not sure if I understand you right.

The ESP Easy does not miss any count.
You can see on the scope, that the signal is very good, clean and sharp without any chatter / bouncing.
I set the debounce time to 10ms, so it should be able to measure speeds up to 6000 rpm (60s/min / 10ms * 1000ms/s = 6000/min)

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to measure speed of three air fans?

#21 Post by grovkillen » 28 Aug 2017, 22:59

So what is the the problem?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

quasar66
New user
Posts: 6
Joined: 18 Aug 2017, 22:20

Re: How to measure speed of three air fans?

#22 Post by quasar66 » 29 Aug 2017, 10:56

What i did for something similar (with 6 ir sensors)

Code here

https://github.com/yahat/ESPEasySlaves_ ... igitalPins

modified esp easy slave code to read sensors

Code: Select all

void loop() {
  Now=millis();
  if(Now - LastRead >= Interval){
    LastRead = Now;
    Found=0;
    for(j=ReadMin;j<=ReadMax;j++){
      Read = digitalRead(j);
      if(Read == 0){
        Found =  j;
        break;
      }
    }
    if(Found!=0 && Found != Position){
      Position=Found;
      Reported = Found - ReadMin+1;
      //Serial.println(Reported);
    }
  }
}
then modified analog read to send the values i needed

Code: Select all

        case CMD_ANALOG_READ:
          if(port<4 || port>5){
            clearSendBuffer();
            int valueRead = analogRead(port);
            sendBuffer[0] = valueRead & 0xff;
            sendBuffer[1] = valueRead >> 8;
          }else{
            clearSendBuffer();
            int valueRead = map(Reported,0,6,0,1020);
            sendBuffer[0] = valueRead & 0xff;
            sendBuffer[1] = valueRead >> 8;
          }
          break
This way
- "slave" reads the values as fast as I want it to, and stores last value
- "master" with espeasy read a fake analog reading for the value every x seconds then does something with it.

Hope it helps

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: How to measure speed of three air fans?

#23 Post by Shardan » 29 Aug 2017, 13:11

Generator signals:
These signals are weak as they come directly from the sensor, leaving all processing to the circuits outside the fan.
The IR-Sensor has a small IC on the board, usually a comparator like LM293 or similiar that formats the pulses.
So equaling those two measurements is not really fair :)

The formula behaving is somewhat strange. I tested a formula with small values before writing my above post
and it worked for me. I suspect there might be some "leftovers" of older configs or former firmware somewhere in the flash.

Anyways.
If i remember right there is a setting in the counter plugin for "Delta" counting.

This accumulates the counted pulses, send the result to a controllet like domoticz or FHEM and resets the counter.

If you set the "Delay" to 60 seconds it would give the (more or less) exact RPM count back as grovekillen suggested above.
Limitations: Using of rules or interrupt driven sensors besides the counter might extend the "Delay" time so you might have to
play a bit with that setting to calibrate.

Please beware: Do not stick to the values in the ESP task list with these settings. As they update only on a webpage refresh
showing the actual countar at that moment you will see the value somewhere in the mid of counting, this making the values look strange.

Regards
Shardan
Regards
Shardan

BertB
Normal user
Posts: 1049
Joined: 25 Apr 2015, 14:39

Re: How to measure speed of three air fans?

#24 Post by BertB » 29 Aug 2017, 20:13

Shardan wrote: 29 Aug 2017, 13:11
Anyways.
If i remember right there is a setting in the counter plugin for "Delta" counting.

This accumulates the counted pulses, send the result to a controllet like domoticz or FHEM and resets the counter.

If you set the "Delay" to 60 seconds it would give the (more or less) exact RPM count back as grovekillen suggested above.
Limitations: Using of rules or interrupt driven sensors besides the counter might extend the "Delay" time so you might have to
play a bit with that setting to calibrate.

Please beware: Do not stick to the values in the ESP task list with these settings. As they update only on a webpage refresh
showing the actual countar at that moment you will see the value somewhere in the mid of counting, this making the values look strange.

Regards
Shardan
I have the same experience. It works just fine, but you need to send the output to something like Domoticz.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: How to measure speed of three air fans?

#25 Post by Shardan » 29 Aug 2017, 20:42

Well, what happens?
There is a register inside the ESP counting the pulses.
Everytime the "Delay" time runs out the counted valuer is transferred to the controller, domoticz or whatever.

If you refresh the website you will most likely hit the register somewhere in the mid of the counting period and see the value at that point of time.

I'm not sure if it is possible to use a rule and trigger it at the point the delay runs out to send it to a dummy.

Regards
Shardan
Regards
Shardan

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 92 guests