25 lines
1.5 KiB
Markdown
25 lines
1.5 KiB
Markdown
# 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.
|