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-07-22
- Revision:
- 2:4bb7c8730d91
- Parent:
- 0:4b99060621fd
- Child:
- 3:6dce9d79da13
File content as of revision 2:4bb7c8730d91:
#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{
CURRENT,
ONE_BEFORE,
TWO_BEFORE,
BEFORE_NUMBER,
};
class Encoder
{
public:
Encoder(PinName a_phase , PinName b_phase );
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];/* = {
{[NORMAL][NOW], [NORMAL][ONE_BEFORE], [NORMAL][TWO_BEFORE]},
{[DELTA][NOW], [DELTA][ONE_BEFORE], [DELTA][TWO_BEFORE]}
}
*/
InterruptIn aPhase;
DigitalIn bPhase;
};
#endif