diff --git a/README.md b/README.md index dac280b..0821713 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ -# tachometer +# 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 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: + \[ + \text{RPM} = \frac{\text{counter} \times 60}{\text{pulses per revolution}} + \] +- The speed in m/min is calculated using the formula: + \[ + \text{Speed (m/min)} = \frac{\text{RPM} \times \pi \times \text{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.