LM393 IR Speed Sensor Using
How he quickly turned the direction in which a DC motor, has few laps etc information, we need some project.In this article I will talk to you therefore to LM393 speed infrared sensor.
The operating principle of the sensor:
Using the infrared sensor communication method, when obstacles between the transmitter and receiver output low, the data in the absence of high obstacles. So you can say that open and close the circuit, such as a button. This high availability of low substitution process is done by treatment with an interpreter and engine speed, speed is measured. Now I better learn by example project. We will measure one dc motor speed and the speed of the project.
Materials:
- Arduino
- Lm393 speed sensor
- Motor drive (l293d enough)
- Potentiometer
- Dc motor and the wheels
- Encoder disks
- Jumper cables
- Battery
Insert the disc encoder on the motor shaft as follows: position the sensor and encoder disk as shown in Fig.
Electronic Section:
Software Part:
The software interrupt (cut) will be eligible to use the feature. You will receive accurate results if you do the cutting process. Because arduino while running other events, will be automatically cut off when the news of related events occur. When the sensor detects automatically changed the situation here. You can download the bottom of the interrupt library.
Library: timerone-r11
/* Robimek - Robotik Systems www.robimek.com */ #include <TimerOne.h> unsigned int sayac=0; int in1 = 9; int in2 = 5; int ena = 10; void say() // sayma işlemi { sayac++; // sayacı bir arttır } void timerIsr() { Timer1.detachInterrupt(); //zamanlayıcıyı durdur Serial.print("Motor hızı: "); int devir = (sayac / 15); // buradaki 15 sayısı encoderdeki boşluk veya delik sayısıdır. Sizdeki kaç delik ise o sayıyı yazın. Serial.print(devir,DEC); Serial.println(" Saniyedeki Devir Sayısı"); sayac=0; // sayacı sıfırla Timer1.attachInterrupt( timerIsr ); //zamanlayıcıyı etkinleştir } void setup() { Serial.begin(9600); pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(ena, OUTPUT); digitalWrite(in1, HIGH); digitalWrite(in2, LOW); Timer1.initialize(1000000); // zamanlayıcıyı bir saniyeye ayarla attachInterrupt(0, say, RISING); // Sensör pini high olduğunda sayacı bir arttır. Timer1.attachInterrupt( timerIsr ); // timerIsr zamanlayıcıyı etkinleştir } void loop() { int pot_deger = analogRead(0); // Potansiyometreden veri okuma int motor_hizi = map(pot_deger, 0, 680, 255, 0); // hız değerini hesapla analogWrite(ena, motor_hizi); // hız değerini yazdır. }
The code “int devir = (sayac / 15); “Expression value 15 is the number of gaps or holes in the encoder. If you enter that number in the first few in the encoder.
this source: brainy-bits.com
Can you say me LR393 sensor which it sense the running speed of the vehicle.
my lm393 sensor is increasing the value by more than 1 unit on 1 gap. it is randon 3,4,6.
can u suggest how to fix it please?