All Projects → DavidAntliff → esp32-freqcount

DavidAntliff / esp32-freqcount

Licence: MIT license
ESP32 Frequency Counter using Pulse Counter and Remote Control modules

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to esp32-freqcount

ESP32-LCD-I2S
Espressif ESP32 driving a controller-less monochrome lcd with parallel I2S bus
Stars: ✭ 54 (+12.5%)
Mutual labels:  esp32, esp-idf
esp-idf-hal
embedded-hal implementation for Rust on ESP32 and ESP-IDF
Stars: ✭ 42 (-12.5%)
Mutual labels:  esp32, esp-idf
esp32-ds18b20
ESP32-compatible C library for Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer.
Stars: ✭ 61 (+27.08%)
Mutual labels:  esp32, esp-idf
esp32-e-paper-weatherdisplay
An ESP32 and 4.2" ePaper Display reads Dark Sky weather API and displays the weather using ESP-IDF
Stars: ✭ 110 (+129.17%)
Mutual labels:  esp32, esp-idf
MQTT VPN
IP over MQTT for ESP controllers and Linux
Stars: ✭ 95 (+97.92%)
Mutual labels:  esp32, esp-idf
wireless-esp8266-dap
ESP8266 Wireless Debugger. Based on CMSIS-DAP v2.0.0. Optional 40MHz SPI acceleration, etc. ESP8266 无线调试器
Stars: ✭ 154 (+220.83%)
Mutual labels:  esp32, esp-idf
lis3dh-esp-idf
LIS3DH driver for ESP-IDF (ESP32)
Stars: ✭ 27 (-43.75%)
Mutual labels:  esp32, esp-idf
ESP32-USB-Soft-Host
An Arduino wrapper to @sdima1357's usb_soft_host esp-idf example
Stars: ✭ 119 (+147.92%)
Mutual labels:  esp32, esp-idf
Arduino Esp32
Arduino core for the ESP32
Stars: ✭ 7,741 (+16027.08%)
Mutual labels:  esp32, esp-idf
esp-idf-w25q64
SPI Flash Memory W25Q64 Access Library for esp-idf
Stars: ✭ 12 (-75%)
Mutual labels:  esp32, esp-idf
gfx demo
GFX Demo for Arduino and the ESP-IDF
Stars: ✭ 63 (+31.25%)
Mutual labels:  esp32, esp-idf
opcua-esp32
Embedded OPC UA Server on ESP32 based on open62541 stack
Stars: ✭ 82 (+70.83%)
Mutual labels:  esp32, esp-idf
esp32-epaper-display
Server and software to use an ESP32 as a connected display
Stars: ✭ 73 (+52.08%)
Mutual labels:  esp32, esp-idf
esp32-xbee
ESP32 XBee UART Interface
Stars: ✭ 48 (+0%)
Mutual labels:  esp32, esp-idf
esp-idf-parallel-tft
8bit parallel TFT & 4-line resistance touch screen Driver for esp-idf using i2s paralell mode
Stars: ✭ 45 (-6.25%)
Mutual labels:  esp32, esp-idf
esp-idf-vscode-boilerplate
Boilerplate for developing ESP-IDF applications using VS Code
Stars: ✭ 26 (-45.83%)
Mutual labels:  esp32, esp-idf
esp-idf-json
Example of JSON Serialize and Deserialize in ESP-IDF
Stars: ✭ 29 (-39.58%)
Mutual labels:  esp32, esp-idf
esp32-ota
ESP32 OTA based on ThingsBoard Open-source IoT Platform
Stars: ✭ 45 (-6.25%)
Mutual labels:  esp32, esp-idf
Homekit
Homekit for ESP32 with Arduino framework
Stars: ✭ 80 (+66.67%)
Mutual labels:  esp32, esp-idf
hman-stomper
Stomp Box based on ESP32
Stars: ✭ 26 (-45.83%)
Mutual labels:  esp32

esp32-freqcount

license

Introduction

This ESP32 component facilitates accurately measuring the frequency of square pulses on a GPIO using Pulse Counter, RMT and Interrupt.

The RMT generates a pulse of precise length, which is mapped to a GPIO. This is the sampling window signal.

The Pulse Counter (PCNT) control input is wired to this same GPIO. PCNT is configured to inhibit counting when the control input is low, and count when it is high.

Both rising and falling edges of the incoming signal of interest are counted during the sampling window.

The RMT TX Complete interrupt is used to fetch the counter value at the end of each control frame.

The sampling window duration and counter value are used to calculate the average frequency of the signal in Hertz.

Dependencies

It is written and tested for the ESP-IDF environment, using the xtensa-esp32-elf toolchain (gcc version 5.2.0).

Example

An example application that uses this component is available: esp32-freqcount-example

Features

  • Measurement of average frequency of input signal in Hertz.

Documentation

Automatically generated API documentation is available here.

Configuration

In order to accurately measure a frequency signal of interest, it is important to consider the expected frequency range of the signal. The general rule is: the slower the expected frequency, the longer the sampling window needs to be to get an accurate measurement.

For example, a ~10 Hz input signal measured over 10 seconds will only be accurate to +/- 0.05 Hz. However a ~10,000 Hz signal measured over a 0.1 second window will be accurate to +/- 5 Hz.

In addition, the onboard peripheral that generates the sampling window (RMT) is constrained by the system clock and a programmable divider. The duration of the window is specified by an array of "items" that are processed in order. Each item describes the number of RMT periods (after the divider) to hold the window signal high or low. Describing RMT operation is outside of the scope of this document, however it is sufficient to know that:

  • RMT programming consists of a block of instructions, called "items",
  • Each block contains 64 items,
  • There are up to 8 blocks of items,
  • Each item can encode up to 2 * 32767 = 65534 periods of the window

Therefore, for a APB clock of 80 MHz and an RMT divider of 160, the RMT period will be 1 / (80 MHz / 160) = 1 / 500,000 seconds. A fully-employed item will therefore represent 65534 / 500,000 = 0.1311 seconds of window. So it follows that a 10 second sampling window will need 10.0 / 0.1311 = ~76 items. Since each block contains 64 items, this will require two blocks.

The user specifies the maximum number of blocks that this component is allowed to use. If the sampling window requirements exceed this maximum, an assertion will fire.

In addition to the sampling window, there is also a filter that can be configured to reduce glitches on the counter input. The length of this filter must be carefully specified otherwise it can mask genuine edges. The filter length is specified as the number of periods at APB clock rate (80 MHz) that changes in the PCNT input signal will be ignored. For example, a value of 1023 will limit square-wave inputs to a maxmum frequency of 80 MHz / 1023 / 2 (because there are two edges per cycle!) = 39,100 Hz.

Source Code

The source is available from GitHub.

License

The code in this project is licensed under the MIT license - see LICENSE for details.

Links

Acknowledgements

Thank you to Chris Morgan for converting the original demo application into this reusable IDF component.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].