Interface to a standard tarco sensor. Measure the periode and the cal the speed
Tarco.h@7:752b8065ce2d, 2014-03-07 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Fri Mar 07 08:01:26 2014 +0000
- Revision:
- 7:752b8065ce2d
- Parent:
- 6:2ad5029f7b1a
- Child:
- 8:2e6b17f1da02
Fungerende version
Who changed what in which revision?
User | Revision | Line number | New 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 | 7:752b8065ce2d | 6 | #define PulsPrRotation 24 |
gert_lauritsen | 7:752b8065ce2d | 7 | /************************************************************************************* |
gert_lauritsen | 7:752b8065ce2d | 8 | * Tarco sensor on the SwitchAuto |
gert_lauritsen | 7:752b8065ce2d | 9 | * Have 2 mode to measure the rotation |
gert_lauritsen | 7:752b8065ce2d | 10 | * @param mode |
gert_lauritsen | 7:752b8065ce2d | 11 | * Mode 0 Prescale |
gert_lauritsen | 7:752b8065ce2d | 12 | * Mode 1 Runing mean |
gert_lauritsen | 7:752b8065ce2d | 13 | *************************************************************************************/ |
gert_lauritsen | 2:c50da089786a | 14 | class Tarco { |
gert_lauritsen | 2:c50da089786a | 15 | private: |
gert_lauritsen | 2:c50da089786a | 16 | InterruptIn _tarcosensor; |
gert_lauritsen | 5:451dd1189b0f | 17 | int AdvPeriode[TarcoRunMean]; //running mean for tarco |
gert_lauritsen | 4:35024179a736 | 18 | Timer t; //time for one rotation |
gert_lauritsen | 7:752b8065ce2d | 19 | |
gert_lauritsen | 4:35024179a736 | 20 | char tarcomode; |
gert_lauritsen | 5:451dd1189b0f | 21 | float lastfrekvens; |
gert_lauritsen | 6:2ad5029f7b1a | 22 | int lastperiode; |
gert_lauritsen | 7:752b8065ce2d | 23 | |
gert_lauritsen | 7:752b8065ce2d | 24 | void RunMeanMeasure(); //Measure the tarco from a one puls /rotation source |
gert_lauritsen | 7:752b8065ce2d | 25 | void Rotationtimer(); //measure tarco by dividing input frekvens with 24 |
gert_lauritsen | 7:752b8065ce2d | 26 | |
gert_lauritsen | 2:c50da089786a | 27 | public: |
gert_lauritsen | 7:752b8065ce2d | 28 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 29 | * Constructor |
gert_lauritsen | 7:752b8065ce2d | 30 | * @param flowsignal The pin which is connected to the flowsensor. |
gert_lauritsen | 7:752b8065ce2d | 31 | * |
gert_lauritsen | 7:752b8065ce2d | 32 | * change the mode of the tarco |
gert_lauritsen | 7:752b8065ce2d | 33 | * 0: Standard Prescale to one measure pr rotation |
gert_lauritsen | 7:752b8065ce2d | 34 | * 1: Running mean |
gert_lauritsen | 7:752b8065ce2d | 35 | ********************************************************************************/ |
gert_lauritsen | 4:35024179a736 | 36 | Tarco(PinName tarcosignal,char mode); |
gert_lauritsen | 4:35024179a736 | 37 | |
gert_lauritsen | 7:752b8065ce2d | 38 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 39 | * gives the tarco value in hz |
gert_lauritsen | 7:752b8065ce2d | 40 | ********************************************************************************/ |
gert_lauritsen | 3:6d3f2034e5f1 | 41 | |
gert_lauritsen | 2:c50da089786a | 42 | float Speed(); |
gert_lauritsen | 7:752b8065ce2d | 43 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 44 | * gives the tarco value in rotation pr min |
gert_lauritsen | 7:752b8065ce2d | 45 | ********************************************************************************/ |
gert_lauritsen | 3:6d3f2034e5f1 | 46 | |
gert_lauritsen | 2:c50da089786a | 47 | float RPM(); |
gert_lauritsen | 2:c50da089786a | 48 | }; |
gert_lauritsen | 2:c50da089786a | 49 | |
gert_lauritsen | 2:c50da089786a | 50 | #endif |