RPM counter for fast and slow movment

Dependents:   Motorteststand

counter.h

Committer:
HMFK03LST1
Date:
2017-03-28
Revision:
2:a1fd290abd1a
Parent:
0:62ab475dd6f4

File content as of revision 2:a1fd290abd1a:

#include "mbed.h"

class Counter {
public:
    /** Create an Counter with period read for low counts
     * 
     * @param pin is the MC pin for the Interrupt Input 
     */
    
    Counter(PinName pin, int count_per_round);
 
    /** Stores Counts per Second for last counting interval
     */
    float rps;
    int no_count;


private:

    void increment();
    
    void do_calc();
    
    InterruptIn _interrupt;
    Ticker      _base;
    Timer       _time;
    
    volatile int _count;
    volatile int _count_per_round;
    float _period;
    
};