This Arduino program is designed to interface with a two-channel incremental encoder and display the rotational speed of a roller on an LCD screen.
Find a file
2024-06-19 16:51:43 +02:00
LICENSE Initial commit 2024-06-17 12:25:23 +02:00
README.md Atualizar README.md 2024-06-18 00:16:05 +02:00
tachometer_v1.ino Atualizar tachometer_v1.ino 2024-06-19 16:51:43 +02:00

Arduino nano tachometer

Program Functionalities

This Arduino program is designed to interface with a two-channel incremental encoder and display the rotational speed of a roller conveyor on an LCD screen. The main functionalities of the program include:

Initialization of LCD and Encoder Pins

  • The program initializes a 16x2 I2C LCD to display the calculated speed.
  • It sets up two digital pins as inputs with internal pull-up resistors to read signals from the encoder.

Interrupt Handling for Encoder Pulses

  • The program uses external interrupts on the encoder signal pins (CLK and DT) to accurately count pulses.
  • Two interrupt service routines (ISRs) are defined: ai0() and ai1(). These routines increment the pulse counter based on the state of the encoder signals, ensuring the counter increases only in one direction to prevent negative values.

Real-Time Calculation of RPM and Speed

  • The main loop of the program calculates the RPM (revolutions per minute) and the speed in meters per minute (m/min) every second.
  • RPM is calculated using the formula:
    RPM = (counter * 60) / pulses per revolution
  • The speed in m/min is calculated using the formula:
    Speed (m/min) = (RPM * π * roller diameter) / 1000
  • After each calculation, the counter is reset for the next measurement period.

Displaying Speed on the LCD

  • The calculated speed in m/min is displayed on the LCD screen.
  • The LCD is updated every second with the new speed value, ensuring the display shows real-time data.