Help CenterHelp Center
Read current rotational speed
rpm = readSpeed(encoder)
rpm = readSpeed([encoder1,encoder2])
example
rpm = readSpeed(encoder) returns the current rotational speed measured by the single quadrature encoder in revolutions per minute.
rpm
encoder
rpm = readSpeed([encoder1,encoder2]) also returns the current rotational speeds measured by the two quadrature encoders in revolutions per minute.
collapse all
Create an Arduino® object with the 'rotaryEncoder' library.
'rotaryEncoder'
a = arduino('COM4','Uno','Libraries','rotaryEncoder');
Connect to the encoder that is connected to your Arduino board.
encoder = rotaryEncoder(a,'D2','D3',180);
Read the current rotational speed.
rpm = 0
Create an Arduino object with the 'rotaryEncoder' library.
a = arduino('COM8','Mega2560','Libraries','rotaryEncoder');
Connect to the encoders that are connected to your Arduino board.
encoder1 = rotaryEncoder(a,'D2','D3',180); encoder2 = rotaryEncoder(a,'D18','D19',180);
rpm = 1×2 0 0
Quadrature encoder connection, specified as a single rotaryEncoder object or a vector of rotaryEncoder objects.
Note
Specify pulse per revolution while creating the rotaryEncoder object to use this function.
Current rotational speed measured by the quadrature encoder in revolutions per minute, returned as a double or vector of doubles.
The speed measurement interval of 20 ms is used to calculate the rotational speed.
Introduced in R2017a
rotaryEncoder | resetCount | readCount
rotaryEncoder
resetCount
readCount
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office