Interface to a standard tarco sensor. Measure the periode and the cal the speed
Tarco.h@12:9269bd188bfa, 2016-02-28 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Sun Feb 28 15:26:18 2016 +0000
- Revision:
- 12:9269bd188bfa
- Parent:
- 11:284b87a84cdd
- Child:
- 13:4b58c9730bc7
Fjernet callback, da vi ikke bruger den mere
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 | 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 | 12:9269bd188bfa | 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 | 12:9269bd188bfa | 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 | 11:284b87a84cdd | 27 | float advfrekvens; |
gert_lauritsen | 6:2ad5029f7b1a | 28 | int lastperiode; |
gert_lauritsen | 8:2e6b17f1da02 | 29 | void Hird(); |
gert_lauritsen | 7:752b8065ce2d | 30 | void RunMeanMeasure(); //Measure the tarco from a one puls /rotation source |
gert_lauritsen | 7:752b8065ce2d | 31 | void Rotationtimer(); //measure tarco by dividing input frekvens with 24 |
gert_lauritsen | 7:752b8065ce2d | 32 | |
gert_lauritsen | 2:c50da089786a | 33 | public: |
gert_lauritsen | 7:752b8065ce2d | 34 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 35 | * Constructor |
gert_lauritsen | 7:752b8065ce2d | 36 | * @param flowsignal The pin which is connected to the flowsensor. |
gert_lauritsen | 7:752b8065ce2d | 37 | * |
gert_lauritsen | 7:752b8065ce2d | 38 | * change the mode of the tarco |
gert_lauritsen | 7:752b8065ce2d | 39 | * 0: Standard Prescale to one measure pr rotation |
gert_lauritsen | 7:752b8065ce2d | 40 | * 1: Running mean |
gert_lauritsen | 7:752b8065ce2d | 41 | ********************************************************************************/ |
gert_lauritsen | 12:9269bd188bfa | 42 | Tarco(PinName tarcosignal,char mode); |
gert_lauritsen | 4:35024179a736 | 43 | |
gert_lauritsen | 7:752b8065ce2d | 44 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 45 | * gives the tarco value in hz |
gert_lauritsen | 7:752b8065ce2d | 46 | ********************************************************************************/ |
gert_lauritsen | 3:6d3f2034e5f1 | 47 | |
gert_lauritsen | 2:c50da089786a | 48 | float Speed(); |
gert_lauritsen | 7:752b8065ce2d | 49 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 50 | * gives the tarco value in rotation pr min |
gert_lauritsen | 7:752b8065ce2d | 51 | ********************************************************************************/ |
gert_lauritsen | 3:6d3f2034e5f1 | 52 | |
gert_lauritsen | 2:c50da089786a | 53 | float RPM(); |
gert_lauritsen | 11:284b87a84cdd | 54 | |
gert_lauritsen | 2:c50da089786a | 55 | }; |
gert_lauritsen | 2:c50da089786a | 56 | |
gert_lauritsen | 2:c50da089786a | 57 | #endif |