encoder readSpeed() output 0 or 6.2500 only

Im working in making a small model to control DC motor using LM393 IR encoder. I'm using arduino as data acquisition and infrareed to get the rpm.
when i try to get rpm by rpm=readSpeed() it gives me zero or 6.2500 only why ?
here is the code
clear;
clc;
a = arduino('com3','uno','Libraries','rotaryEncoder');
Encoder=rotaryEncoder(a,'D2','D3',120);
PotPin = configurePin(a,'A0');
HBA1 = configurePin(a,'D10');
resetCount(Encoder);
while true
voltage= readVoltage(a,'A0');
writePWMVoltage(a,'D10',voltage);
rpm=readSpeed(Encoder);
pause(0.1);
disp('rpm = ');
disp(rpm);
end

Answers (0)

Products

Release

R2020b

Asked:

on 16 Nov 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!