QEI library with velocity implementation based on time difference between successive encoder counts.
Dependents: Bezier_Trajectory_Follower Dolphin 2_131TEST Jerby ... more
Diff: QEI.cpp
- Revision:
- 4:58a3c9c9e956
- Parent:
- 0:43b9eeecccc7
--- a/QEI.cpp Tue Aug 11 20:02:03 2015 +0000 +++ b/QEI.cpp Wed Sep 23 17:33:09 2015 +0000 @@ -297,8 +297,10 @@ float QEI::getVelocity() { - if(prevDirection_ != currDirection_ || prevTime_ == currTime_) - { + int ct = currTime_; + int pt = prevTime_; + + if(prevDirection_ != currDirection_ || pt == ct) { return 0; } double dt = (currTime_ - prevTime_)/1000000.;