Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Committer:
pspatel321
Date:
Fri Oct 24 22:09:04 2014 +0000
Revision:
13:fbd9b3f5a07c
Child:
17:c9ce210f6654
Fork showing Parth's changes to current monitor, IMD, and fanpump.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pspatel321 13:fbd9b3f5a07c 1 // copied idea from http://developer.mbed.org/forum/mbed/topic/466/?page=1#comment-2457
pspatel321 13:fbd9b3f5a07c 2
pspatel321 13:fbd9b3f5a07c 3 #ifndef _FILE_IMD_H
pspatel321 13:fbd9b3f5a07c 4 #define _FILE_IMD_H
pspatel321 13:fbd9b3f5a07c 5
pspatel321 13:fbd9b3f5a07c 6 #include "mbed.h"
pspatel321 13:fbd9b3f5a07c 7 #include "LPCDigitalIn.h"
pspatel321 13:fbd9b3f5a07c 8
pspatel321 13:fbd9b3f5a07c 9 const float ZERO_HZ_TIMEOUT = 0.1; // Time (sec) that must pass without an edge to call it 0 Hz, set to greater than the longest expected pulse width
pspatel321 13:fbd9b3f5a07c 10
pspatel321 13:fbd9b3f5a07c 11 enum EdgeT {
pspatel321 13:fbd9b3f5a07c 12 RISING=5,
pspatel321 13:fbd9b3f5a07c 13 FALLING=6,
pspatel321 13:fbd9b3f5a07c 14 BOTH=7,
pspatel321 13:fbd9b3f5a07c 15 };
pspatel321 13:fbd9b3f5a07c 16 class IMD{
pspatel321 13:fbd9b3f5a07c 17 public:
pspatel321 13:fbd9b3f5a07c 18 IMD();
pspatel321 13:fbd9b3f5a07c 19
pspatel321 13:fbd9b3f5a07c 20 // Get the IMD status
pspatel321 13:fbd9b3f5a07c 21 /*
pspatel321 13:fbd9b3f5a07c 22 Status State
pspatel321 13:fbd9b3f5a07c 23 0 IMD off
pspatel321 13:fbd9b3f5a07c 24 1 Normal
pspatel321 13:fbd9b3f5a07c 25 2 under voltage
pspatel321 13:fbd9b3f5a07c 26 3 Speed Start
pspatel321 13:fbd9b3f5a07c 27 4 IMD error
pspatel321 13:fbd9b3f5a07c 28 5 Ground error
pspatel321 13:fbd9b3f5a07c 29 */
pspatel321 13:fbd9b3f5a07c 30 char status();
pspatel321 13:fbd9b3f5a07c 31
pspatel321 13:fbd9b3f5a07c 32 // Gets the insulation resistance reading
pspatel321 13:fbd9b3f5a07c 33 // Returns 0 to 50,000,000 in normal/UV modes
pspatel321 13:fbd9b3f5a07c 34 // Returns 0 or 50,000,000 in speed start (good/bad only)
pspatel321 13:fbd9b3f5a07c 35 // -1 for invalid measurement (out of permissible range)
pspatel321 13:fbd9b3f5a07c 36 // and NaN for not applicable mode
pspatel321 13:fbd9b3f5a07c 37 float resistance();
pspatel321 13:fbd9b3f5a07c 38
pspatel321 13:fbd9b3f5a07c 39 // Interrupt function for the edge type detected
pspatel321 13:fbd9b3f5a07c 40 void edgeIRQ();
pspatel321 13:fbd9b3f5a07c 41 // Used to zero (reset) the data on timeout
pspatel321 13:fbd9b3f5a07c 42 void zeroIRQ();
pspatel321 13:fbd9b3f5a07c 43
pspatel321 13:fbd9b3f5a07c 44 private:
pspatel321 13:fbd9b3f5a07c 45 float frequency();
pspatel321 13:fbd9b3f5a07c 46 float duty();
pspatel321 13:fbd9b3f5a07c 47 uint32_t startTime;
pspatel321 13:fbd9b3f5a07c 48 uint32_t widthTicks;
pspatel321 13:fbd9b3f5a07c 49 uint32_t periodTicks;
pspatel321 13:fbd9b3f5a07c 50 bool first;
pspatel321 13:fbd9b3f5a07c 51 };
pspatel321 13:fbd9b3f5a07c 52
pspatel321 13:fbd9b3f5a07c 53 #endif