System Management code
Dependencies: CANBuffer mbed SystemManagement mbed-rtos
System Management code for Penn Electric Racing
Functions:
Controls Fans and Pumps via instruction from CAN Messages, ramps them up over time to prevent damage
Turns on/off DC-DC converter via instruction from CAN Messages
SysMngmt.h@7:5f6e31faa08e, 2014-10-10 (annotated)
- Committer:
- martydd3
- Date:
- Fri Oct 10 20:59:36 2014 +0000
- Revision:
- 7:5f6e31faa08e
- Parent:
- 0:e516fcccccda
PollSwitch code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
martydd3 | 0:e516fcccccda | 1 | #ifndef _SYSMNGMT_ |
martydd3 | 0:e516fcccccda | 2 | #define _SYSMNGMT_ |
martydd3 | 0:e516fcccccda | 3 | #include "mbed.h" |
martydd3 | 0:e516fcccccda | 4 | |
martydd3 | 0:e516fcccccda | 5 | #define MSEC_HRS 2.77778e-7 |
martydd3 | 0:e516fcccccda | 6 | #define DC_DC_ISENSE_OFFSET_V 0.5 |
martydd3 | 0:e516fcccccda | 7 | #define DC_DC_ISENSE_INCREMENT 0.133 |
martydd3 | 0:e516fcccccda | 8 | |
martydd3 | 0:e516fcccccda | 9 | #define BAT_ISENSE_OFFSET_V 1.65 |
martydd3 | 0:e516fcccccda | 10 | #define BAT_ISENSE_INCREMENT 0.5297 |
martydd3 | 0:e516fcccccda | 11 | |
martydd3 | 0:e516fcccccda | 12 | Serial pc(USBTX,USBRX); |
martydd3 | 0:e516fcccccda | 13 | CAN CAN_SysM(p30,p29); |
martydd3 | 0:e516fcccccda | 14 | |
martydd3 | 0:e516fcccccda | 15 | //Temperature Input |
martydd3 | 0:e516fcccccda | 16 | AnalogIn Coolant1(p17); //Brass ones |
martydd3 | 0:e516fcccccda | 17 | AnalogIn Coolant2(p16); //Brass ones |
martydd3 | 0:e516fcccccda | 18 | AnalogIn DC_DC(p18); //Murata |
martydd3 | 0:e516fcccccda | 19 | AnalogIn ChargerFET(p15);//Murata |
martydd3 | 0:e516fcccccda | 20 | AnalogIn BatISense(p19); |
martydd3 | 0:e516fcccccda | 21 | AnalogIn DCSense(p20); |
martydd3 | 0:e516fcccccda | 22 | |
martydd3 | 0:e516fcccccda | 23 | typedef union convert{ |
martydd3 | 0:e516fcccccda | 24 | float FLOAT; |
martydd3 | 0:e516fcccccda | 25 | char C_FLOAT[4]; |
martydd3 | 0:e516fcccccda | 26 | }ftc; |
martydd3 | 0:e516fcccccda | 27 | |
martydd3 | 0:e516fcccccda | 28 | // Call function at reccuring interval |
martydd3 | 0:e516fcccccda | 29 | Ticker ReadIMD, PollSDSwitch, ReadTemperature, ReadBatteryState; |
martydd3 | 0:e516fcccccda | 30 | |
martydd3 | 0:e516fcccccda | 31 | double BATmA_Hr; |
martydd3 | 0:e516fcccccda | 32 | float DCA_msec,BATA_msec; |
martydd3 | 0:e516fcccccda | 33 | float Bat_I_Ratio,DC_I_Ratio; |
martydd3 | 0:e516fcccccda | 34 | CANMessage RxBuffer[10]={}; |
martydd3 | 0:e516fcccccda | 35 | |
martydd3 | 0:e516fcccccda | 36 | /* |
martydd3 | 0:e516fcccccda | 37 | PwmOut Pump(p26); |
martydd3 | 0:e516fcccccda | 38 | PwmOut Fan1(p25); |
martydd3 | 0:e516fcccccda | 39 | PwmOut Fan2(p24); |
martydd3 | 0:e516fcccccda | 40 | PwmOut Fan3(p23); |
martydd3 | 0:e516fcccccda | 41 | */ |
martydd3 | 0:e516fcccccda | 42 | #endif /* _SYSMNGMT_ */ |