Revision 5:94ab0cebd88f, committed 2019-12-05
- Comitter:
- BoGBoG
- Date:
- Thu Dec 05 18:05:14 2019 +0000
- Parent:
- 4:dc96133b5129
- Commit message:
- a
Changed in this revision
QEI.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/QEI.cpp Sat Oct 27 10:09:39 2018 +0000 +++ b/QEI.cpp Thu Dec 05 18:05:14 2019 +0000 @@ -284,11 +284,11 @@ return (float)pulses_ / (4 * pulsesPerRev_); } -float QEI::getDistance(float diameter) +float QEI::getDistance(float distance) { oldDistance_ = newDistance_; - newDistance_ = getRevolutions()*diameter*3.1415926; - return newDistance_; + newDistance_ = getPulses(); + return newDistance_-oldDistance_; } void QEI::index(void) { @@ -297,8 +297,11 @@ } float QEI::getVelosity() { - getDistance(53.975); - velosity_ = ti.read()*(newDistance_-oldDistance_); + /* + getDistance(0.03); //radius wheel 0.03m + velosity_ = (newDistance_-oldDistance_)/ti.read();*/ + + velosity_ = (6.2831852*getDistance(0.03))/(pulsesPerRev_*ti.read()); ti.reset(); return velosity_; }