Info Measure Speed Motor with Sensor

Hi, I purchased a speed measurement sensor "Infrared optical optocoupler module" like the one in the image. I need it to measure the actual speed of a stepper motor. I'm wondering how to get the angular velocity using such a device. I have seen projects where they measure an approximation of the number of slits. Still, it is not specified exactly when the sensor acquires the passage of the infrared through the slit: that is if the pulse is recorded exactly when it passes the edge of the slit or if when it is in the centre of the fissure. so, how would you create a code to extrapolate the angular speed of the motor as faithfully as possible with this module?
image

Why do you think this matters when measuring angular velocity? The important thing is that every time the signal is triggered at the same position. Also, if you are using a stepper motor you should know its speed because you set it. If you want a precise angular position there are magnetic sensors where a small magnet is added to the axis of the motor and the sensor measures the rotation of its magnetic field.

That would be SO EASY for you to test, I wonder why you are even asking.

because I need to know the maximum speed it can reach. I only have this sensor I can't buy another one. the point is how to understand using it how to calculate the speed as accurately as possible using this sensor.

You know that a flat surface reflects light and the openings are not infinitely thin, so the pulse indicating an opening will never be a sharp, square edged square wave. The way to time the openings is to use interrupts on the pin connected to the IR sensor and set it to interrupt on either a rising or a falling edge of the pulse. No need to concern yourself with the length of the pulse, only the time between interrupts.
You do that by counting the interrupts for any time interval you want, perhaps a second, and divide the interrupt count by the number of sensor openings and you now know the number of rotations in that second.

Thanks :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.