Home‎ > ‎Arduino Projects‎ > ‎

Project#11 Infrared speed sensor module

Mini Motor Speed Sensor -A from Amazon
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/mini.jpg

Mini Motor Speed Sensor -B from Amazon
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/IR%20Speed%20.jpg 

  1.  Motor speed sensor or work piece counting
  2.   Using infrared detection, strong anti-jamming capability
  3.   Schmidt trigger, high sensitivity, stable performance
  4.   5V Working voltage, black line output low level and white lines output high level
  5.    74HC14 Hex inverting high performance Schmitt trigger chip
  6.    Photo interrupter: MOCH25A; slotted width : 1 cm

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/IR%20Speed%20Sch%20.jpg

LED-D2 indicates the presence of voltage applied; the LED-D1 monitors operation of the phototransistor.

Optocoupler, U1 - MOCH25A, where the wheel encoder disc is placed. One side was an infrared led, and the other was a phototransistor. If no object block, the phototransistor would conduct; when something blocked the light falling on the transistor it wouldn’t conduct.

Chip U2 - 74HC14 Hex inverting.  When there is no object between the photo interrupter will be logical “0”, U2 generates a logical "1" and the LED-D1 is off. During the rotation, the object will block light output from optocoupler will be a logical "1" and U2 is logical  “0”, simultaneously, the LED-D1  is on .

Wheel Encoder Disc (Encoder resolution: 20 holes / disc):

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/encoder%20dsic.jpg

Code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
int encoder_pin = 2;  // The pin the encoder is connected           
unsigned int rpm;     // rpm reading
volatile byte pulses;  // number of pulses
unsigned long timeold; 
// The number of pulses per revolution
// depends on your index disc!!
unsigned int pulsesperturn = 20;

 void counter()
 {
    //Update count
      pulses++;    
 }

void setup()
 {
   Serial.begin(9600);
     //Use statusPin to flash along with interrupts
   pinMode(encoder_pin, INPUT);
   
   //Interrupt 0 is digital pin 2, so that is where the IR detector is connected
   //Triggers on FALLING (change from HIGH to LOW)
   attachInterrupt(0, counter, FALLING);
   // Initialize
   pulses = 0;
   rpm = 0;
   timeold = 0;

 }

 void loop()
 {
   if (millis() - timeold >= 1000){  /*Uptade every one second, this will be equal to reading frecuency (Hz).*/
 
  //Don't process interrupts during calculations
   detachInterrupt(0);
   //Note that this would be 60*1000/(millis() - timeold)*pulses if the interrupt
   //happened once per revolution
   rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses;
   timeold = millis();
   pulses = 0;
   
   //Write it out to serial port
   Serial.print("RPM = ");
   Serial.println(rpm,DEC);
   //Restart the interrupt processing
   attachInterrupt(0, counter, FALLING);
   }
  }

Output result  as below; it's close to the spec of motor's RPM value =240 @6V
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/output2.jpg

NOTE: Consider Bad Pulses described here
Add 100nF (104) metallized polyester Capacitor to the encoder,
Code:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// https://www.youtube.com/watch?v=9848QETGd_k

// Using HC-020K Photoelectric encoder on the Dual Axis Reducer Motor 
// with 100nF capacitor on the encoder
#include <TimerOne.h>  // library: https://code.google.com/archive/p/arduino-timerone/downloads
int encoder_pin = 2; 
unsigned int counter=0;

void setup() {
  Serial.begin(9600);
  pinMode(encoder_pin, INPUT);
  Timer1.initialize(1000000);  // set for 1 sec
  attachInterrupt(0,do_count,RISING);
  Timer1.attachInterrupt(timerIsr);
}

void loop() {
  // put your main code here, to run repeatedly:

}

void do_count() {
  counter++;
}

void timerIsr() {
  Timer1.detachInterrupt();
  Serial.print("Motor Speed: ");
  int rotation = (counter/20)*60;
  Serial.print(rotation, DEC);
  Serial.println(" RPM");
  counter=0;
  Timer1.attachInterrupt(timerIsr);
}
Result:
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/rpm.jpg

LM393 Comparator IR Speed Sensor Module
(FC-03)
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/FC-03.jpg
from Amazon

Working Voltage : DC 3.3-5V
Main Chip : LM393
Slotted Width : 5mm
ITR9608 photoelectric switch (not sure, I guessed)

Pins Connection:
VCC: positive power supply 3.3-5V;
GND: Ground;
DO:  Output frequency pulses;
AO:  analog output, real-time output voltage signal. (not useful)

http://aitendo3.sakura.ne.jp/aitendo_data/product_img/sensor/infrared/PIR393-5V/ir_sensor_sch.jpg

The LED (left) indicates the presence of voltage applied. When there is no object between the photo interrupter, the LED (right) is ON; otherwise is OFF. If slot unobstructed, DO output low; otherwise, DO output high.

 Using the same code above, output as below:

Note: I use 3.3V as VCC to get below result; if 5V is used, only get half RPM readings.

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/output.jpg

HC-020K Double Speed Measuring Module with Photoelectric Encoders

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/HC-020kjpg.jpg
from DX.com or Amazon
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/HC-020k2.jpg

  • Module Working Voltage: 4.5-5.5V
  • Launch Tube Pressure Drop: Vf=1.6V
  • Launch Tube Current: If<20mA
  • Signal output: ONE line; TT power level;
  • Slotted Width : 6mm
  • Chip: LM393

Slotted LM393 Beam Infrared Light Counter Photoelectric Sensor Module

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/61nwYSL-auL._SL1100_.jpg
from Amazon

Chip: LM393
Power : DC5V;
Slotted Width : 10mm

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/lm393.jpg

FC-33 Electric Motor Speed Sensor Module

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/sku_193010_1.jpg
from DX.com

Working voltage: 3.3~5V
Chip: LM393

Slotted Width : 10mm

https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/FC-33.jpg
https://sites.google.com/site/myscratchbooks/home/projects/project-11-infrared-speed-sensing-module/FC-33a.jpg