Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: QEI_with_distance wheelchaircontrol wheelchaircontrolRos wheelchaircontrol ... more
Fork of QEI by
Diff: QEI.cpp
- Revision:
- 1:f57640259245
- Parent:
- 0:5c2ad81551aa
- Child:
- 2:2a173fdae3ca
--- a/QEI.cpp Thu Sep 02 16:48:55 2010 +0000
+++ b/QEI.cpp Wed Jul 25 22:51:54 2018 +0000
@@ -185,11 +185,6 @@
}
-int QEI::getRevolutions(void) {
-
- return revolutions_;
-
-}
// +-------------+
// | X2 Encoding |
@@ -275,13 +270,23 @@
pulses_ -= change;
}
-
}
-
prevState_ = currState_;
}
+float QEI::getRevolutions(){
+ if (encoding_ == X2_ENCODING)
+ return (float) ((float)pulses_ /(pulsesPerRev_));
+ else
+ return (float) (pulses_ / 4 * pulsesPerRev_);
+}
+
+float QEI::getDistance(float radius)
+{
+ return getRevolutions()*radius*3.1415926*2;
+}
+
void QEI::index(void) {
revolutions_++;
