Interface to a standard tarco sensor. Measure the periode and the cal the speed
Tarco.h@6:2ad5029f7b1a, 2013-11-20 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Wed Nov 20 13:29:29 2013 +0000
- Revision:
- 6:2ad5029f7b1a
- Parent:
- 5:451dd1189b0f
- Child:
- 7:752b8065ce2d
Fjerne den lange periode i tarco signallet
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gert_lauritsen | 2:c50da089786a | 1 | #include "mbed.h" |
gert_lauritsen | 2:c50da089786a | 2 | |
gert_lauritsen | 2:c50da089786a | 3 | #ifndef _Tarco_H |
gert_lauritsen | 2:c50da089786a | 4 | #define _Tarco_H |
gert_lauritsen | 5:451dd1189b0f | 5 | #define TarcoRunMean 50 |
gert_lauritsen | 2:c50da089786a | 6 | |
gert_lauritsen | 2:c50da089786a | 7 | class Tarco { |
gert_lauritsen | 2:c50da089786a | 8 | |
gert_lauritsen | 2:c50da089786a | 9 | private: |
gert_lauritsen | 2:c50da089786a | 10 | InterruptIn _tarcosensor; |
gert_lauritsen | 4:35024179a736 | 11 | void click(); //Measure the tarco from a one puls /rotation source |
gert_lauritsen | 4:35024179a736 | 12 | void fsk(); //measure tarco from a fsk source |
gert_lauritsen | 4:35024179a736 | 13 | int p1,p2; |
gert_lauritsen | 5:451dd1189b0f | 14 | int AdvPeriode[TarcoRunMean]; //running mean for tarco |
gert_lauritsen | 4:35024179a736 | 15 | Timer t; //time for one rotation |
gert_lauritsen | 4:35024179a736 | 16 | Timer fsktime; //time between fsk pulse |
gert_lauritsen | 4:35024179a736 | 17 | int pulsvariation, lastpuls, count; |
gert_lauritsen | 4:35024179a736 | 18 | char tarcomode; |
gert_lauritsen | 5:451dd1189b0f | 19 | float lastfrekvens; |
gert_lauritsen | 6:2ad5029f7b1a | 20 | int lastperiode; |
gert_lauritsen | 2:c50da089786a | 21 | public: |
gert_lauritsen | 2:c50da089786a | 22 | // ******************************************************************************** |
gert_lauritsen | 4:35024179a736 | 23 | // Constructor |
gert_lauritsen | 4:35024179a736 | 24 | // @param flowsignal The pin which is connected to the flowsensor. |
gert_lauritsen | 4:35024179a736 | 25 | // |
gert_lauritsen | 4:35024179a736 | 26 | // change the mode of the tarco |
gert_lauritsen | 4:35024179a736 | 27 | // 0: Standard One click/rotation |
gert_lauritsen | 4:35024179a736 | 28 | // 1: FSK modulated |
gert_lauritsen | 2:c50da089786a | 29 | // ******************************************************************************** |
gert_lauritsen | 4:35024179a736 | 30 | Tarco(PinName tarcosignal,char mode); |
gert_lauritsen | 4:35024179a736 | 31 | |
gert_lauritsen | 3:6d3f2034e5f1 | 32 | // ******************************************************************************** |
gert_lauritsen | 3:6d3f2034e5f1 | 33 | // gives the tarco value in hz |
gert_lauritsen | 3:6d3f2034e5f1 | 34 | // ******************************************************************************** |
gert_lauritsen | 3:6d3f2034e5f1 | 35 | |
gert_lauritsen | 2:c50da089786a | 36 | float Speed(); |
gert_lauritsen | 3:6d3f2034e5f1 | 37 | // ******************************************************************************** |
gert_lauritsen | 3:6d3f2034e5f1 | 38 | // gives the tarco value in rotation pr min |
gert_lauritsen | 3:6d3f2034e5f1 | 39 | // ******************************************************************************** |
gert_lauritsen | 3:6d3f2034e5f1 | 40 | |
gert_lauritsen | 2:c50da089786a | 41 | float RPM(); |
gert_lauritsen | 2:c50da089786a | 42 | }; |
gert_lauritsen | 2:c50da089786a | 43 | |
gert_lauritsen | 2:c50da089786a | 44 | #endif |