acs beacon and hk integrated

Dependencies:   mbed-rtos mbed

Committer:
sakthipriya
Date:
Sat May 16 07:07:56 2015 +0000
Revision:
0:1a04c0beef21
acs beacon and hk integrated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sakthipriya 0:1a04c0beef21 1 #include "fault.h"
sakthipriya 0:1a04c0beef21 2 #include "HK.h"
sakthipriya 0:1a04c0beef21 3
sakthipriya 0:1a04c0beef21 4
sakthipriya 0:1a04c0beef21 5 DigitalIn fault0(FAULT0,PullUp);
sakthipriya 0:1a04c0beef21 6 DigitalIn fault1(FAULT1,PullUp);
sakthipriya 0:1a04c0beef21 7 DigitalIn fault2(FAULT2,PullUp);
sakthipriya 0:1a04c0beef21 8 DigitalIn fault3(FAULT3,PullUp);
sakthipriya 0:1a04c0beef21 9 DigitalIn fault4(FAULT4,PullUp);
sakthipriya 0:1a04c0beef21 10 //DigitalIn fault5(FAULT5,PullUp);
sakthipriya 0:1a04c0beef21 11 //DigitalIn fault6(FAULT6,PullUp);
sakthipriya 0:1a04c0beef21 12 //DigitalIn fault7(FAULT7,PullUp);
sakthipriya 0:1a04c0beef21 13 //DigitalIn fault8(FAULT8,PullUp);
sakthipriya 0:1a04c0beef21 14
sakthipriya 0:1a04c0beef21 15
sakthipriya 0:1a04c0beef21 16 InterruptIn fault_IR1(FAULT5);
sakthipriya 0:1a04c0beef21 17 InterruptIn fault_IR2(FAULT6);
sakthipriya 0:1a04c0beef21 18 InterruptIn fault_IR3(FAULT7);
sakthipriya 0:1a04c0beef21 19 InterruptIn fault_IR4(FAULT8);
sakthipriya 0:1a04c0beef21 20 InterruptIn fault_IR5(FAULT9);
sakthipriya 0:1a04c0beef21 21
sakthipriya 0:1a04c0beef21 22
sakthipriya 0:1a04c0beef21 23
sakthipriya 0:1a04c0beef21 24 DigitalOut clear1(FAULT_CLEAR1,0);
sakthipriya 0:1a04c0beef21 25 DigitalOut clear2(FAULT_CLEAR2,0);
sakthipriya 0:1a04c0beef21 26 DigitalOut clear3(FAULT_CLEAR3,0);
sakthipriya 0:1a04c0beef21 27 DigitalOut clear4(FAULT_CLEAR4,0);
sakthipriya 0:1a04c0beef21 28 DigitalOut clear5(FAULT_CLEAR5);
sakthipriya 0:1a04c0beef21 29 DigitalOut clear6(FAULT_CLEAR6);
sakthipriya 0:1a04c0beef21 30 DigitalOut clear7(FAULT_CLEAR7);
sakthipriya 0:1a04c0beef21 31 DigitalOut clear8(FAULT_CLEAR8);
sakthipriya 0:1a04c0beef21 32 DigitalOut clear9(FAULT_CLEAR9);
sakthipriya 0:1a04c0beef21 33
sakthipriya 0:1a04c0beef21 34
sakthipriya 0:1a04c0beef21 35 DigitalOut acs_active(ACS);
sakthipriya 0:1a04c0beef21 36
sakthipriya 0:1a04c0beef21 37
sakthipriya 0:1a04c0beef21 38 BusIn fault_poll(FAULT0,FAULT1,FAULT2,FAULT3,FAULT4);
sakthipriya 0:1a04c0beef21 39 BusIn fault_ir(FAULT5,FAULT6,FAULT7,FAULT8,FAULT9);
sakthipriya 0:1a04c0beef21 40
sakthipriya 0:1a04c0beef21 41 BusOut clear_poll(FAULT_CLEAR1,FAULT_CLEAR2,FAULT_CLEAR3,FAULT_CLEAR4);//to send fault data along with hk
sakthipriya 0:1a04c0beef21 42 BusOut clear_ir(FAULT_CLEAR5,FAULT_CLEAR6,FAULT_CLEAR7,FAULT_CLEAR8,FAULT_CLEAR9);
sakthipriya 0:1a04c0beef21 43
sakthipriya 0:1a04c0beef21 44
sakthipriya 0:1a04c0beef21 45 extern SensorDataQuantised SensorQuantised;
sakthipriya 0:1a04c0beef21 46 extern int beacon_sc; //to switch beacon between low and high power mode
sakthipriya 0:1a04c0beef21 47 extern int acs_pflag; //to activate/deactivate control algo
sakthipriya 0:1a04c0beef21 48 char out_poll;
sakthipriya 0:1a04c0beef21 49 char out_ir;
sakthipriya 0:1a04c0beef21 50
sakthipriya 0:1a04c0beef21 51 void FUNC_HK_FAULTS()
sakthipriya 0:1a04c0beef21 52 {
sakthipriya 0:1a04c0beef21 53
sakthipriya 0:1a04c0beef21 54 printf("Entered Fault management \n");
sakthipriya 0:1a04c0beef21 55 /*if(fault0==0)printf("CHARGER IS CHARGING THE BATTERY ");
sakthipriya 0:1a04c0beef21 56 if(fault0==1)printf("CHRGER GONE OFFLINE, BATTERY DRAINING");
sakthipriya 0:1a04c0beef21 57
sakthipriya 0:1a04c0beef21 58 if(fault1==0)
sakthipriya 0:1a04c0beef21 59 { clear1=1;printf("");}
sakthipriya 0:1a04c0beef21 60 else
sakthipriya 0:1a04c0beef21 61 { clear1=0;}
sakthipriya 0:1a04c0beef21 62
sakthipriya 0:1a04c0beef21 63 if(fault2==0)
sakthipriya 0:1a04c0beef21 64 { clear2=1;printf("");}
sakthipriya 0:1a04c0beef21 65 else
sakthipriya 0:1a04c0beef21 66 { clear2=0;}
sakthipriya 0:1a04c0beef21 67
sakthipriya 0:1a04c0beef21 68 if(fault3==0)
sakthipriya 0:1a04c0beef21 69 { clear3=1;printf("");}
sakthipriya 0:1a04c0beef21 70 else
sakthipriya 0:1a04c0beef21 71 { clear3=0;}
sakthipriya 0:1a04c0beef21 72
sakthipriya 0:1a04c0beef21 73 if(fault4==0)
sakthipriya 0:1a04c0beef21 74 { clear4=1;printf("");}
sakthipriya 0:1a04c0beef21 75 else
sakthipriya 0:1a04c0beef21 76 { clear4=0;}*/
sakthipriya 0:1a04c0beef21 77
sakthipriya 0:1a04c0beef21 78
sakthipriya 0:1a04c0beef21 79
sakthipriya 0:1a04c0beef21 80
sakthipriya 0:1a04c0beef21 81
sakthipriya 0:1a04c0beef21 82
sakthipriya 0:1a04c0beef21 83
sakthipriya 0:1a04c0beef21 84
sakthipriya 0:1a04c0beef21 85 //clear1 = !fault1;
sakthipriya 0:1a04c0beef21 86 //clear2 = !fault2;
sakthipriya 0:1a04c0beef21 87 //clear3 = !fault3;
sakthipriya 0:1a04c0beef21 88 //clear4 = !fault4;
sakthipriya 0:1a04c0beef21 89 //clear5 = !fault5;
sakthipriya 0:1a04c0beef21 90 //clear6 = !fault6;
sakthipriya 0:1a04c0beef21 91 //clear7 = !fault7;
sakthipriya 0:1a04c0beef21 92 //clear8 = !fault8;
sakthipriya 0:1a04c0beef21 93
sakthipriya 0:1a04c0beef21 94
sakthipriya 0:1a04c0beef21 95 // out_poll = clear_poll;
sakthipriya 0:1a04c0beef21 96 //out_ir = clear_ir;
sakthipriya 0:1a04c0beef21 97 SensorQuantised.faultpoll = fault_poll ;
sakthipriya 0:1a04c0beef21 98 SensorQuantised.faultir=fault_ir ;
sakthipriya 0:1a04c0beef21 99 printf(" %d , %d \n ",SensorQuantised.faultpoll, SensorQuantised.faultir ) ;
sakthipriya 0:1a04c0beef21 100
sakthipriya 0:1a04c0beef21 101 }
sakthipriya 0:1a04c0beef21 102
sakthipriya 0:1a04c0beef21 103
sakthipriya 0:1a04c0beef21 104
sakthipriya 0:1a04c0beef21 105 void Clear_IR1()
sakthipriya 0:1a04c0beef21 106 {clear5=!clear5;
sakthipriya 0:1a04c0beef21 107 }
sakthipriya 0:1a04c0beef21 108
sakthipriya 0:1a04c0beef21 109 void Clear_IR2()
sakthipriya 0:1a04c0beef21 110 {clear6=!clear6;
sakthipriya 0:1a04c0beef21 111 }
sakthipriya 0:1a04c0beef21 112
sakthipriya 0:1a04c0beef21 113 void Clear_IR3()
sakthipriya 0:1a04c0beef21 114 {clear7=!clear7;
sakthipriya 0:1a04c0beef21 115 }
sakthipriya 0:1a04c0beef21 116
sakthipriya 0:1a04c0beef21 117 void Clear_IR4()
sakthipriya 0:1a04c0beef21 118 {clear8=!clear8;
sakthipriya 0:1a04c0beef21 119 }
sakthipriya 0:1a04c0beef21 120
sakthipriya 0:1a04c0beef21 121 void Clear_IR5()
sakthipriya 0:1a04c0beef21 122 {clear9=!clear9;
sakthipriya 0:1a04c0beef21 123 }
sakthipriya 0:1a04c0beef21 124
sakthipriya 0:1a04c0beef21 125 void interrupt_fault()
sakthipriya 0:1a04c0beef21 126 {
sakthipriya 0:1a04c0beef21 127 fault_IR1.rise(&Clear_IR1);
sakthipriya 0:1a04c0beef21 128 fault_IR2.rise(&Clear_IR2);
sakthipriya 0:1a04c0beef21 129 fault_IR3.rise(&Clear_IR3);
sakthipriya 0:1a04c0beef21 130 fault_IR4.rise(&Clear_IR4);
sakthipriya 0:1a04c0beef21 131 fault_IR5.rise(&Clear_IR5);
sakthipriya 0:1a04c0beef21 132 fault_IR1.fall(&Clear_IR1);
sakthipriya 0:1a04c0beef21 133 fault_IR2.fall(&Clear_IR2);
sakthipriya 0:1a04c0beef21 134 fault_IR3.fall(&Clear_IR3);
sakthipriya 0:1a04c0beef21 135 fault_IR4.fall(&Clear_IR4);
sakthipriya 0:1a04c0beef21 136 fault_IR5.fall(&Clear_IR5);
sakthipriya 0:1a04c0beef21 137 }
sakthipriya 0:1a04c0beef21 138
sakthipriya 0:1a04c0beef21 139
sakthipriya 0:1a04c0beef21 140 void FUNC_HK_POWER(char flag) //flag corresponds to the power mode
sakthipriya 0:1a04c0beef21 141 {
sakthipriya 0:1a04c0beef21 142 printf("Entered Power Management \n");
sakthipriya 0:1a04c0beef21 143 printf("Entering mode %c \n", flag);
sakthipriya 0:1a04c0beef21 144 switch (flag)
sakthipriya 0:1a04c0beef21 145 {
sakthipriya 0:1a04c0beef21 146 case '0': beacon_sc = 6; //least power mode
sakthipriya 0:1a04c0beef21 147 acs_pflag = 0;
sakthipriya 0:1a04c0beef21 148 acs_active = 0; //switching off a component of acs
sakthipriya 0:1a04c0beef21 149 break;
sakthipriya 0:1a04c0beef21 150 case '1': beacon_sc = 3;
sakthipriya 0:1a04c0beef21 151 acs_pflag = 0;
sakthipriya 0:1a04c0beef21 152 acs_active = 0;
sakthipriya 0:1a04c0beef21 153 break;
sakthipriya 0:1a04c0beef21 154 case '2': beacon_sc = 3;
sakthipriya 0:1a04c0beef21 155 acs_pflag = 0;
sakthipriya 0:1a04c0beef21 156 acs_active = 0;
sakthipriya 0:1a04c0beef21 157 break;
sakthipriya 0:1a04c0beef21 158 case '3': beacon_sc = 3; //normal mode
sakthipriya 0:1a04c0beef21 159 acs_pflag = 1;
sakthipriya 0:1a04c0beef21 160 acs_active = 1;
sakthipriya 0:1a04c0beef21 161 break;
sakthipriya 0:1a04c0beef21 162 }
sakthipriya 0:1a04c0beef21 163 /* if (flag == '0')
sakthipriya 0:1a04c0beef21 164 beacon_sc = 30;
sakthipriya 0:1a04c0beef21 165 else
sakthipriya 0:1a04c0beef21 166 beacon_sc = 3;
sakthipriya 0:1a04c0beef21 167 if (flag == '3')
sakthipriya 0:1a04c0beef21 168 acs_pflag = 1;
sakthipriya 0:1a04c0beef21 169 else
sakthipriya 0:1a04c0beef21 170 acs_pflag = 0; */
sakthipriya 0:1a04c0beef21 171 }