Question to generic pulse counter

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bastler11
Normal user
Posts: 110
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Question to generic pulse counter

#1 Post by bastler11 » 28 Feb 2024, 15:04

Hello, I tried to build a pulse counter for my anemometer. For this I build a test environment.
IMG_5656.JPG
IMG_5656.JPG (3.2 MiB) Viewed 2199 times


I use an esp8266 with normal 4M VCC firmware. I connected a 10kΩ resistance between ground and D5 and a reed contact between 3V and D5. The reed contact I fixed near the chuck of my lathe. The chuck has 2 magnets. In the chuck I clamped a tachometer. When the lathe is running with 10 turns per second the frequency is also shown with 10Hz.

Here is the setting
Screenshot-Feb.-28-2024_13.29.38.jpg
Screenshot-Feb.-28-2024_13.29.38.jpg (114.55 KiB) Viewed 2199 times
Sometimes there are some differences, although the late is running with the same speed. Than I changed the debounce time from 0 to 1ms. It looks better. I tried also to use a higher speed, but after 40Hz the value is fix there is no rising. I simulated this with 8 magnets on the chuck.

If my anemometer turns 3 times with 1m/s windspeed and I want to measure max. 15m/s the frequency from the two reed contacts is about 2x 45Hz = 90Hz. So the esp or the reed contacts are too slow? Has somebody an idea what I could do to measure also the whole range of speed wind?

I also tried to use the other options high, low and changes, but the result I do not understand. I my frequency is 10Hz with rising and value/4 and I switch to high -> 7-8Hz, to low -> 6-9Hz (both with value/2). If I use changes -> 5-10Hz (value/4). Does anyone understand this?

Thanks and best regards!

TD-er
Core team member
Posts: 9265
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Question to generic pulse counter

#2 Post by TD-er » 28 Feb 2024, 15:58

Better use an ESP32 for this and keep the wires from the sensor to the ESP as short as possible or try to twist the cables to reduce the effects of noise.
The ESP32 does act on the pulses in hardware, where the ESP8266 does it entirely in software.

A reed switch is a bad choice for these kinds of measurements as there are also some mechanical vibrations in the setup.
Debounce is only needed for "mechanical" switches as those actually "bounce" when pressed, but also can cause triggers due to vibrations like in your setup.
Debounce timings also can cause a valid pulse to be missed.
Also a reed switch is probably too slow as the magnet hardly has any time to pull on the metal of the switch.

A better option can be to use a Hall effect sensor.
That's not a mechanical switch and thus doesn't need any debounce.
It can respond a lot faster.

Another option is to use an optical sensor and count some reflective marking or interrupt some beam of light.

Rob73
Normal user
Posts: 58
Joined: 25 May 2022, 15:05

Re: Question to generic pulse counter

#3 Post by Rob73 » 02 Mar 2024, 04:38

Hall effect sensor A3144 may be what you want to look into. They sell them on ebay and amazon pretty cheap. I have a few anemometers that I built with those sensors. The hall effect sensors work great and I have used them with esp8266 and esp32 and they seem to work well with both. The only trouble I had with an anemometer project was some of the nodemcu boards do not like using interrupts while the wifi is on and I had to work around that. The best work around was to just use a different module that didnt have that limitation. I have used the wemos D1 Mini for lots of projects and they have worked good on my wind sensor projects.


Rob

bastler11
Normal user
Posts: 110
Joined: 11 Jan 2021, 21:58
Location: Luebeck

Re: Question to generic pulse counter

#4 Post by bastler11 » 08 Mar 2024, 22:05

First of all, thanks Rob73 and TD-er for your ideas. I´m late but I was a little bit busy the last days and the delivery for the Hall sensors needed also some days. Today they arrived. I exchanged in my test environment this: ESP8266 -> ESP32 and reed contact -> Hall sensor. The result is really so much better, no debounce and it worked up to 160Hz. Next step is to exchange the reed contact in my anemometer and than I must calibrate it to get the correct wind speed.

Rob73
Normal user
Posts: 58
Joined: 25 May 2022, 15:05

Re: Question to generic pulse counter

#5 Post by Rob73 » 13 Mar 2024, 04:06

bastler11, I send you a private message. Sorry it took so long, I didnt see the message.

Rob

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest