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.
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_;
}