simple QEI library. no return speed, only return angle.

Dependents:   WRS_mechanamu_test

QEI.h

Committer:
sgrsn
Date:
2018-11-14
Revision:
1:6fa863d09d45
Parent:
0:bffc97496048

File content as of revision 1:6fa863d09d45:

#ifndef QEI_H
#define QEI_H

#include "mbed.h"

class QEI {

public:
    
    QEI(PinName A, PinName B, int ppr, Timer *t);
    
    float getAngle();
    float getSpeed();
    float getDisAngle();
    void reset();

private:

    void encode(void);

    InterruptIn channelA;
    InterruptIn channelB;
    Timer *timer;
    
    float angle;
    int currState;
    int prevState;
    int position;
    int last_position;
    float _ppr;
    float time;
};

#endif