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

Tarco.h

Committer:
gert_lauritsen
Date:
2013-11-19
Revision:
5:451dd1189b0f
Parent:
4:35024179a736
Child:
6:2ad5029f7b1a

File content as of revision 5:451dd1189b0f:

#include "mbed.h"

#ifndef _Tarco_H
#define _Tarco_H
#define TarcoRunMean 50

class Tarco {

private:
    InterruptIn _tarcosensor;
    void click(); //Measure the tarco from a one puls /rotation source
    void fsk();   //measure tarco from a fsk source
    int p1,p2;
    int AdvPeriode[TarcoRunMean]; //running mean for tarco
    Timer t; //time for one rotation
    Timer fsktime; //time between fsk pulse
    int pulsvariation, lastpuls, count;
    char tarcomode;
    float lastfrekvens;
public:
    // ********************************************************************************
    // Constructor
    // @param flowsignal   The pin which is connected to the flowsensor.
    //
    // change the mode of the tarco
    // 0: Standard One click/rotation
    // 1: FSK modulated 
    // ********************************************************************************
    Tarco(PinName tarcosignal,char mode);
    
    // ********************************************************************************
    // gives the tarco value in hz
    // ********************************************************************************

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

    float RPM();
};

#endif