Interface to a standard tarco sensor. Measure the periode and the cal the speed

Tarco.h

Committer:
gert_lauritsen
Date:
2014-03-07
Revision:
7:752b8065ce2d
Parent:
6:2ad5029f7b1a
Child:
8:2e6b17f1da02

File content as of revision 7:752b8065ce2d:

#ifndef _Tarco_H
#define _Tarco_H

#include "mbed.h"
#define TarcoRunMean 50
#define PulsPrRotation 24
/************************************************************************************* 
*  Tarco sensor on the SwitchAuto
*  Have 2 mode to measure the rotation
*  @param mode
*  Mode 0 Prescale
*  Mode 1 Runing mean
*************************************************************************************/
class Tarco {
private:
    InterruptIn _tarcosensor;
    int AdvPeriode[TarcoRunMean]; //running mean for tarco
    Timer t; //time for one rotation

    char tarcomode;
    float lastfrekvens;
    int lastperiode;
    
    void RunMeanMeasure(); //Measure the tarco from a one puls /rotation source
    void Rotationtimer();   //measure tarco by dividing input frekvens with 24
    
public:
    /********************************************************************************
    * Constructor
    * @param flowsignal   The pin which is connected to the flowsensor.
    *
    * change the mode of the tarco
    * 0: Standard Prescale to one measure pr rotation
    * 1: Running mean
     ********************************************************************************/
    Tarco(PinName tarcosignal,char mode);
    
    /********************************************************************************
    * gives the tarco value in hz
    ********************************************************************************/

    float Speed();
    /********************************************************************************
    * gives the tarco value in rotation pr min
    ********************************************************************************/

    float RPM();
};

#endif