Interface to a standard tarco sensor. Measure the periode and the cal the speed
Tarco.h@14:07d968decc76, 2016-04-15 (annotated)
- Committer:
- gert_lauritsen
- Date:
- Fri Apr 15 12:44:00 2016 +0000
- Revision:
- 14:07d968decc76
- Parent:
- 13:4b58c9730bc7
Funger som "gammel" motor styring. Kan k?rer gennem alle stadier. Der er kommet en eventlog, s? man kan se hvad der er sket.
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 | 14:07d968decc76 | 6 | #define PulsPrRotation 24 |
gert_lauritsen | 14:07d968decc76 | 7 | #define PulsTimeOut 200 //200ms |
gert_lauritsen | 7:752b8065ce2d | 8 | /************************************************************************************* |
gert_lauritsen | 7:752b8065ce2d | 9 | * Tarco sensor on the SwitchAuto |
gert_lauritsen | 7:752b8065ce2d | 10 | * Have 2 mode to measure the rotation |
gert_lauritsen | 7:752b8065ce2d | 11 | * @param mode |
gert_lauritsen | 7:752b8065ce2d | 12 | * Mode 0 Prescale |
gert_lauritsen | 7:752b8065ce2d | 13 | * Mode 1 Runing mean |
gert_lauritsen | 7:752b8065ce2d | 14 | *************************************************************************************/ |
gert_lauritsen | 2:c50da089786a | 15 | class Tarco { |
gert_lauritsen | 2:c50da089786a | 16 | private: |
gert_lauritsen | 2:c50da089786a | 17 | InterruptIn _tarcosensor; |
gert_lauritsen | 14:07d968decc76 | 18 | int AdvPeriode; //running mean for tarco |
gert_lauritsen | 4:35024179a736 | 19 | Timer t; //time for one rotation |
gert_lauritsen | 14:07d968decc76 | 20 | Ticker TimeOut; |
gert_lauritsen | 14:07d968decc76 | 21 | bool GettingPuls; |
gert_lauritsen | 5:451dd1189b0f | 22 | float lastfrekvens; |
gert_lauritsen | 7:752b8065ce2d | 23 | void Rotationtimer(); //measure tarco by dividing input frekvens with 24 |
gert_lauritsen | 13:4b58c9730bc7 | 24 | void TarcoTimeout(); |
gert_lauritsen | 2:c50da089786a | 25 | public: |
gert_lauritsen | 7:752b8065ce2d | 26 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 27 | * Constructor |
gert_lauritsen | 7:752b8065ce2d | 28 | * @param flowsignal The pin which is connected to the flowsensor. |
gert_lauritsen | 7:752b8065ce2d | 29 | * |
gert_lauritsen | 7:752b8065ce2d | 30 | * change the mode of the tarco |
gert_lauritsen | 7:752b8065ce2d | 31 | * 0: Standard Prescale to one measure pr rotation |
gert_lauritsen | 7:752b8065ce2d | 32 | * 1: Running mean |
gert_lauritsen | 7:752b8065ce2d | 33 | ********************************************************************************/ |
gert_lauritsen | 14:07d968decc76 | 34 | Tarco(PinName tarcosignal); |
gert_lauritsen | 4:35024179a736 | 35 | |
gert_lauritsen | 7:752b8065ce2d | 36 | /******************************************************************************** |
gert_lauritsen | 7:752b8065ce2d | 37 | * gives the tarco value in rotation pr min |
gert_lauritsen | 7:752b8065ce2d | 38 | ********************************************************************************/ |
gert_lauritsen | 3:6d3f2034e5f1 | 39 | |
gert_lauritsen | 2:c50da089786a | 40 | float RPM(); |
gert_lauritsen | 11:284b87a84cdd | 41 | |
gert_lauritsen | 2:c50da089786a | 42 | }; |
gert_lauritsen | 2:c50da089786a | 43 | |
gert_lauritsen | 2:c50da089786a | 44 | #endif |