Beruflich Dokumente
Kultur Dokumente
تحت إشراف-:
م/مهران العبسي
DIY: Measuring Wheel/Surveyor’s Wheel Using Arduino &
Rotary Encoder:-
Components
Working
Rotary encoder
Arduino
Arduino is the brain of the whole project which counts the rotation.
Arduino converts the rotation into distance using calibration and
displays the information on LCD.
LCD
In this project, we are using 16×2 LCD (16 Columns and 2 Rows).
The LCD has 16 pins, some pins are power pins, and 6 pins are
connected to Arduino and two pins are used for backlight. A preset
is also connected to 3rd pin of LCD which is used for contrast
control of the LCD.
Circuit
In the circuit Arduino, LCD and Rotary Encoder are the main
components. Rotary encoder has three pins. One pin is connected
to GND and two pins are connected to D2 and D3 pins of Arduino.
LCD is connected to Arduino through pins D0 to D5. Vin pin of
Arduino is powered by a 9-volt battery through a switch.
Calibration
In this DIY project, the rotary encoder measures the number of the
rotation but we have to convert the rotation into travelled distance.
Travelled distance depends on the diameter of the wheel.
In our case
N = 30
R = 5.5
By solving
Code
In the line 5 and 6 two integers are declared by names pin1 and
Pin2, that are interrupt pins of Arduino. Three Integers are declared
in lines 8, 9 and 10, where Pos is the current position of Rotary
encoder. Other two integers are “State” and “LastState”.
In the void setup section, pin1 and pin2 are declared by INPUT.
In the line 2 LCD is begun and in the line 16 “SURVEYOR’S
WHEEL” is displayed on the LCD.
#include <LiquidCrystal.h>
int pin1 = 2;
int pin2 = 3;
int Pos = 0;
int State;
int LastState;
const float R = 1;
void setup() {
lcd.begin(16, 2);
lcd.print("SURVEYOR'S WHEEL");
LastState = digitalRead(pin1);
Serial.begin(9600);
void loop() {
State = digitalRead(pin1);
if (State != LastState){
if (digitalRead(pin2) != State) {
Pos --;
else {
Pos ++;
distance = (2*pi*R*Pos)/N;
if (digitalRead(unitselector)==1){
lcd.setCursor(0, 1);
lcd.print( distance);
lcd.setCursor(7, 1);
lcd.print("cm ");
Serial.print(distance);
Serial.println(" Cm");
if (digitalRead(unitselector)==0){
lcd.setCursor(0, 1);
lcd.print(inch );
lcd.setCursor(7, 1);
lcd.print("inch ");
Serial.print(inch);
Serial.println(" inch");
LastState = State;
}
Measured values and uncertainty: -
Tru
N 𝑥𝑖 e Random Systemic Precision Accuracy
accuracy
1 10
𝑠𝑥 = √( ∑ (𝑥𝑖 − 𝑥 ′ )2
𝑁 − 1 𝑥=1
1 10
𝑠𝑥 = √( ∑ (𝑥𝑖 − 𝑥 ′ )2
9 𝑥=1
𝑠𝑥 = 0.6061 𝑐𝑚
𝑡9,95% = 2.262 cm
𝑠𝑥 ′ = 0.1917 𝑐𝑚
𝑢(𝑥𝑖 ,𝑟𝑒𝑝) = ±2.262 ∗ 0.6061𝑐𝑚
𝑢(𝑥 ′ ,𝑟𝑒𝑝) = ±2.262 ∗ 0.6061𝑐𝑚