QITH FLAGS
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of TF_conops_BAE1_3 by
Diff: EPS.h
- Revision:
- 1:7185136654ce
- Parent:
- 0:246d1b5f11ae
--- a/EPS.h Tue Jun 30 05:55:48 2015 +0000 +++ b/EPS.h Mon Jul 06 07:34:00 2015 +0000 @@ -1,29 +1,47 @@ #include "mbed.h" - +#include "pin_config.h" +//.............Power switching.......... +#define TRXY_DR_EN PIN82 //torque rod driver enable +#define TRZ_DR_EN PIN88 +#define 3V3AENBL PIN33 +#define VBATT PIN20 +//......................HK..................... #define vstart 3.3 #define vstep 0.84667 #define cstart 0.0691 #define cstep 0.09133 -#define rsens 0.095 +#define tstart -40 +#define tstep 8.33 +#define rsens 0.025 #define Bnewvalue_start -100//in microTesla...max possible field is .0001 T #define Bnewvalue_step 13.333 #define AngularSpeed_start -10//max possible ang. velocity in space is 10 deg/sec #define AngularSpeed_step 1.3333 - -/***********************************************Configuring Peripherals*******************************************************************/ +//...............Battery Gauge................ +#define BG_ADDR (0x6C) //slave address of battery gauge +//I2C register addresses +#define REG_VCELL 0x02 +#define REG_SOC 0x04 +#define REG_MODE 0x06 +#define REG_VERSION 0x08 +#define REG_HIBRT 0x0A +#define REG_CONFIG 0x0C +#define REG_VALRT 0x14 +#define REG_CRATE 0x16 +#define REG_VRESET_ID 0x18 +#define REG_STATUS 0x1A +#define REG_TABLE 0x40 +#define REG_CMD 0xFE -DigitalOut SelectLinesA[] = {PIN43,PIN44,PIN45,PIN46}; //to mux1=>voltage mux , PTA 13-16 , CHNGE TO PIN43 LATER -DigitalOut SelectLinesB[] = {PIN56,PIN57,PIN58,PIN59}; //to mux2=>current mux(differential mux) , PTB 3,7,8,9 - //MSB is SelectLines[0],LSB is SelectLines[3] -AnalogIn CurrentInput(PIN53); // output from Current Mux PTB0 -AnalogIn VoltageInput(PIN54); // output from Voltage Multiplexer PTB1 -/**************************************************Variables******************************************************************************/ -typedef struct SensorData //soc value has to be included +typedef struct SensorData { - float Voltage[16]; - float Current[8]; - float PanelTemperature[4]; // not finalised + float SOC; //added recently + float Vbatt; //added recently + float Voltage[15]; + float Current[7]; + float Temperature[1]; // not finalised + //float PanelTemperature[4]; // not finalised ///there wer 4 values here? float BatteryTemperature; char fault_poll; //polled faults char fault_ir; //interrupted faults @@ -39,7 +57,8 @@ { char Voltage[8]; char Current[4]; - char PanelTemperature[2];//read by the 4 thermistors on solar panels + char Temperature[2]; ///size?????? + //char PanelTemperature[2];//read by the 4 thermistors on solar panels char BatteryTemperature; //to be populated char faultpoll; //polled faults char faultir; //interrupted faults @@ -61,9 +80,41 @@ char ErrorFlag[1]; //fault }ShortBeacy; - + +/******************************************************function headers************************************************************************/ void FCTN_EPS_INIT(); -void FCTN_EPS_MAIN(); + +void FCTN_EPS_BTEMP_INIT(); +void FCTN_EPS_BTEMP_MAIN(float*); + +unsigned short BG_readReg(char); +void BG_writeReg(char, unsigned short); +void BG_reset(); //not used in code +void BG_quickStart(); //not used in code +void BG_disableSleep(); +void BG_disableHibernate(); +void BG_socChangeAlertEnabled(bool); +float BG_compensation(); //not used in code +void BG_compensation(char); +void BG_tempCompensation(float); +bool BG_alerting(); +void BG_clearAlert(); +void BG_emptyAlertThreshold(char); +void BG_vAlertMinMaxThreshold(); +void BG_vResetThresholdSet(); +void BG_vResetAlertEnabled(bool); +char BG_alertFlags(); +void BG_clearAlertFlags(); +float BG_vcell(); +float BG_soc(); +void FCTN_EPS_BG_INIT(); +void FCTN_EPS_BG_MAIN(); + +int FCTN_EPS_POWERMODE(float); +void FCTN_EPS_CTRLPOWER(int) ; + +int FCTN_QUANTIZE(float ,float ,float ); +void FCTN_WRITE_BEASTRUCT(ShortBeacy* ,SensorDataQuantised ); +void FCTN_EPS_HK_MAIN(); + -int FCTN_QUANTIZE(float l_start,float l_step,float l_x); -void FCTN_WRITE_BEASTRUCT(ShortBeacy* x,SensorDataQuantised y);