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.
Dependents: backdrive backdrive_3
encoder.h
- Committer:
- takenowa
- Date:
- 2018-06-04
- Revision:
- 0:4b99060621fd
- Child:
- 2:4bb7c8730d91
File content as of revision 0:4b99060621fd:
#ifndef ENCODER_H #define ENCODER_H #include "mbed.h" #include "arm_math.h" enum CH{ DISTANCE, RPM, VELOCITY, ACCELERATION, OMEGA, DELTA_DISTANCE, }; enum TYPE_NUMBER{ NORMAL, DELTA, TYPE_NUMBER, }; enum BEFORE_NUMBER{ NOW, ONE_BEFORE, TWO_BEFORE, BEFORE_NUMBER, }; class Encoder { public: Encoder(PinName aPhase , PinName bPhase ); void calState(); float getState(int ch); void reset(); void init(float _ppr, float _radius,float _dt); private: void read(); float rpm, distance, omega, velocity, radius, delta_distance, ppr, dt, dt_square, circle, acceleration; float count[TYPE_NUMBER][BEFORE_NUMBER]; InterruptIn aPhase; DigitalIn bPhase; }; #endif