Compact IR infrared rotary speed sensing module (HCMODU0240)

Modules for various types of sensors including accelerometers. gyro's, IR motion, etc
Post Reply
admin
Site Admin
Posts: 867
Joined: Sun Aug 05, 2012 4:02 pm

Compact IR infrared rotary speed sensing module (HCMODU0240)

Post by admin » Wed Jun 14, 2023 11:20 am

[IMAGE TBA]



A compact rotary speed sensing module. This module incorporates an WYC-H206 infra-red sensor to sense a split object passing its IR emitter and receiver. It can be used in applications such as endstop sensing in mechanical devices such as CNC machines or 3D printers, or when used with a rotary encoder wheel, can be used for rotary speed sensing of motors and wheels.

The module has a single 3 pin 0.1” pitch header consisting of VCC & GND for power and a single digital schmitt triggered TTL output pin which signifies the sensor's current state. An onboard LED is also included as a visual indicator of the sensor's current state.


Specification:

Product code: HCMODU0240
Supply voltage: 3.3 to 5V
Slot width: 6mm
Dimensions ex header (LxWxH): 26.6 x 14.8 x 18.7mm
Mounting holes diameter: 3mm


Pinout:

OUT….Digital out (low = sensor interrupted)
VCC….3.3/5V
GND….Ground



Example Arduino Sketch:

  1. /* FILE:    TMP102_Example.cpp
  2.    DATE:    14/06/23
  3.    VERSION: 1.0
  4.    AUTHOR:  Andrew Davies
  5.  
  6.    Library created by Hobby Components Ltd (HOBBYCOMPONENTS.COM)
  7.  
  8. You may copy, alter and reuse this code in any way you like, but please leave
  9. reference to HobbyComponents.com in your comments if you redistribute this code.
  10. This software may not be used directly for the purpose of selling products that
  11. directly compete with Hobby Components Ltd's own range of products.
  12.  
  13. THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
  14. EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  15. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
  16. HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
  17. INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
  18. REASON WHATSOEVER.
  19. */
  20.  
  21.  
  22. // Pin connected to the sensor's out pin. Must be an interrupt pin!
  23. #define SENSOR_PIN 2
  24.  
  25. // Init variables used for pulse timing
  26. unsigned long newTime = 0, oldTime, pulseTime = 0;
  27.  
  28.  
  29. void setup()
  30. {
  31.   Serial.begin(115200);
  32.   pinMode(SENSOR_PIN, INPUT);
  33.   attachInterrupt(digitalPinToInterrupt(SENSOR_PIN), isr, RISING);
  34. }
  35.  
  36.  
  37. void loop()
  38. {
  39.   Serial.println(getRPM());   // Print out the current RPM
  40.  
  41.   delay(100);                 // Wait a little so not to flood the serial port
  42. }
  43.  
  44.  
  45. // Function to calculate the current RPM
  46. unsigned long getRPM(void)
  47. {
  48.   // Only calculate RPM if the sensor has been triggered
  49.   if(newTime)
  50.   {
  51.     // Calculate the pulse time in microseconds
  52.     pulseTime = newTime - oldTime;
  53.  
  54.     // Check if we've had a recent update from the ISR and if not calculate
  55.     // the pulse time based on the current time
  56.     if(pulseTime < (micros() - newTime))
  57.     {
  58.       pulseTime = micros() - newTime;
  59.     }
  60.  
  61.     // Return the new RPM
  62.     return 60000000 / pulseTime;
  63.   }else
  64.     return 0; // The sensor has never been triggered so RPM = 0
  65. }
  66.  
  67.  
  68. // Interrupt service routine used to calculate the time
  69. // between each sensor trigger in microseconds
  70. void isr()
  71. {
  72.   oldTime = newTime;
  73.   newTime = micros();
  74. }


Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.

Post Reply

Return to “Sensors”