a
Dependents: wheelchaircontrol wheelchaircontrol2 wheelchaircontrol3 wheelchaircontrol4 ... more
Diff: QEI.h
- Revision:
- 4:17d461de6a8f
- Parent:
- 2:2a173fdae3ca
diff -r 0035b165ecc4 -r 17d461de6a8f QEI.h --- a/QEI.h Fri Aug 31 17:09:18 2018 +0000 +++ b/QEI.h Fri Apr 19 23:03:41 2019 +0000 @@ -206,10 +206,16 @@ * * @return Number of revolutions which have occured on the index channel. */ - + float getRevolutions(void); - float getRevolutions(void); - + /** + * Takes the difference of distance divided by the difference of time + */ + float getVelocity(); + + /** + * Calculates the distance travelled using the diameter of the wheel and how many revolutions have happened + */ float getDistance(float diameter); private: @@ -236,13 +242,18 @@ InterruptIn channelB_; InterruptIn index_; - float pulsesPerRev_; - int prevState_; - int currState_; - - volatile int pulses_; - volatile int revolutions_; + float pulsesPerRev_; // variable that keeps the pulses in each revolution + float oldDistance_; // variable that keeps distance initial for velocity calculation + float newDistance_; // variable that keeps distance final for velocity calculation + float velocity_; // variable with the current velocity + int prevState_; // variable to use in direction logic + int currState_; // variable to use in direction logic + + Timer ti; // pointer to timer library to keep track of time + + volatile int pulses_; // keeps track of how many pulses have happened from initializing position + volatile int revolutions_; // keeps track of how many revolutions have happened from initializing position }; -#endif /* QEI_H */ +#endif /* QEI_H */ \ No newline at end of file