Quadrature encoder interface library with distance function
Dependents: QEI_with_distance wheelchaircontrol wheelchaircontrolRos wheelchaircontrol ... more
Fork of QEI by
Revision 2:2a173fdae3ca, committed 2018-08-03
- Comitter:
- jvfausto
- Date:
- Fri Aug 03 20:28:47 2018 +0000
- Parent:
- 1:f57640259245
- Child:
- 3:0035b165ecc4
- Commit message:
- Added distance measurement
Changed in this revision
QEI.cpp | Show annotated file Show diff for this revision Revisions of this file |
QEI.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/QEI.cpp Wed Jul 25 22:51:54 2018 +0000 +++ b/QEI.cpp Fri Aug 03 20:28:47 2018 +0000 @@ -277,14 +277,16 @@ float QEI::getRevolutions(){ if (encoding_ == X2_ENCODING) - return (float) ((float)pulses_ /(pulsesPerRev_)); + { + return (float)pulses_ / pulsesPerRev_; + } else - return (float) (pulses_ / 4 * pulsesPerRev_); + return (float)pulses_ / (4 * pulsesPerRev_); } -float QEI::getDistance(float radius) +float QEI::getDistance(float diameter) { - return getRevolutions()*radius*3.1415926*2; + return getRevolutions()*diameter*3.1415926; } void QEI::index(void) {
--- a/QEI.h Wed Jul 25 22:51:54 2018 +0000 +++ b/QEI.h Fri Aug 03 20:28:47 2018 +0000 @@ -210,7 +210,7 @@ float getRevolutions(void); - float QEI::getDistance(float radius); + float getDistance(float diameter); private: