will this code be able to measure the speed of the motor correctly. I used it and the rpm output was actually higher than that it should be , like 6th times higher. The motor i am using is CH-N20-3.
You need to know the gear ratio and the PPR of the encoder.
Seems most encoders for the motor are 12PPR
Do you know the gear ratio?
I think it may be 20. so the PPR in your code should be 20*12 = 240 not 44
No, I don't know the specification of the motor. I tried to search in online but the datasheet was not matching for the motor name.By the way how do I know the gear ratio from the datasheet, like it has number of column showing rated rpm for gear ratio in the datasheets or is it fix for a motor. Thanks for the help.
from chat gpt i got the ppr as 44 , as it is a quadrature encoder. One of my friend said that the rated rpm was 300 or something under 300 but the serial monitor showed 1600 something. I think gear ratio might be the issue as I have totally ignored it . Also tell me do we have to multiply the ppr by 4 for a quadrature encoder? Thanks a lot for your help.
Chat is never right.
No, do not multiply by 4 but you must know the PPR (sometimes called CPR) of the encoder. I think for your motor it is 12
Knowing the rated RPM does not help
So how do you know the motor is rotating 6 time slower?
sorry for the inconvenience and my lack of clarity . It was 6 times higher than the rated rpm. Rated rpm(300 or something I am not clear) was 1/6th of the rpm shown in serial monitor. Thanks a lot for your help.