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

Committer:
gert_lauritsen
Date:
Thu Sep 11 07:43:31 2014 +0000
Revision:
8:2e6b17f1da02
Parent:
7:752b8065ce2d
Child:
11:284b87a84cdd
callback tilf?jet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gert_lauritsen 2:c50da089786a 1 #ifndef _Tarco_H
gert_lauritsen 2:c50da089786a 2 #define _Tarco_H
gert_lauritsen 7:752b8065ce2d 3
gert_lauritsen 7:752b8065ce2d 4 #include "mbed.h"
gert_lauritsen 5:451dd1189b0f 5 #define TarcoRunMean 50
gert_lauritsen 8:2e6b17f1da02 6 #define PulsPrRotation 23
gert_lauritsen 8:2e6b17f1da02 7 #define HirthMode 2
gert_lauritsen 8:2e6b17f1da02 8 #define SwitchAuto 1
gert_lauritsen 8:2e6b17f1da02 9 #define RunMeanSwitchAuto 0
gert_lauritsen 8:2e6b17f1da02 10 typedef void (*callback_type)(int);
gert_lauritsen 7:752b8065ce2d 11 /*************************************************************************************
gert_lauritsen 7:752b8065ce2d 12 * Tarco sensor on the SwitchAuto
gert_lauritsen 7:752b8065ce2d 13 * Have 2 mode to measure the rotation
gert_lauritsen 7:752b8065ce2d 14 * @param mode
gert_lauritsen 7:752b8065ce2d 15 * Mode 0 Prescale
gert_lauritsen 7:752b8065ce2d 16 * Mode 1 Runing mean
gert_lauritsen 7:752b8065ce2d 17 *************************************************************************************/
gert_lauritsen 2:c50da089786a 18 class Tarco {
gert_lauritsen 2:c50da089786a 19 private:
gert_lauritsen 2:c50da089786a 20 InterruptIn _tarcosensor;
gert_lauritsen 8:2e6b17f1da02 21 callback_type callback;
gert_lauritsen 5:451dd1189b0f 22 int AdvPeriode[TarcoRunMean]; //running mean for tarco
gert_lauritsen 4:35024179a736 23 Timer t; //time for one rotation
gert_lauritsen 7:752b8065ce2d 24
gert_lauritsen 4:35024179a736 25 char tarcomode;
gert_lauritsen 5:451dd1189b0f 26 float lastfrekvens;
gert_lauritsen 6:2ad5029f7b1a 27 int lastperiode;
gert_lauritsen 8:2e6b17f1da02 28 void Hird();
gert_lauritsen 7:752b8065ce2d 29 void RunMeanMeasure(); //Measure the tarco from a one puls /rotation source
gert_lauritsen 7:752b8065ce2d 30 void Rotationtimer(); //measure tarco by dividing input frekvens with 24
gert_lauritsen 7:752b8065ce2d 31
gert_lauritsen 2:c50da089786a 32 public:
gert_lauritsen 7:752b8065ce2d 33 /********************************************************************************
gert_lauritsen 7:752b8065ce2d 34 * Constructor
gert_lauritsen 7:752b8065ce2d 35 * @param flowsignal The pin which is connected to the flowsensor.
gert_lauritsen 7:752b8065ce2d 36 *
gert_lauritsen 7:752b8065ce2d 37 * change the mode of the tarco
gert_lauritsen 7:752b8065ce2d 38 * 0: Standard Prescale to one measure pr rotation
gert_lauritsen 7:752b8065ce2d 39 * 1: Running mean
gert_lauritsen 7:752b8065ce2d 40 ********************************************************************************/
gert_lauritsen 8:2e6b17f1da02 41 Tarco(PinName tarcosignal,char mode,callback_type _callback);
gert_lauritsen 4:35024179a736 42
gert_lauritsen 7:752b8065ce2d 43 /********************************************************************************
gert_lauritsen 7:752b8065ce2d 44 * gives the tarco value in hz
gert_lauritsen 7:752b8065ce2d 45 ********************************************************************************/
gert_lauritsen 3:6d3f2034e5f1 46
gert_lauritsen 2:c50da089786a 47 float Speed();
gert_lauritsen 7:752b8065ce2d 48 /********************************************************************************
gert_lauritsen 7:752b8065ce2d 49 * gives the tarco value in rotation pr min
gert_lauritsen 7:752b8065ce2d 50 ********************************************************************************/
gert_lauritsen 3:6d3f2034e5f1 51
gert_lauritsen 2:c50da089786a 52 float RPM();
gert_lauritsen 2:c50da089786a 53 };
gert_lauritsen 2:c50da089786a 54
gert_lauritsen 2:c50da089786a 55 #endif