From 7256fe1c07cf5ecbe485c3cdac238b88dfc2cd1d Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Thu, 7 Mar 2019 17:08:42 +0200 Subject: Add system fans + read the tacho of the new small drawer fans --- Software/Embedded_SW/Embedded/DataDef.h | 26 +++++ Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c | 105 ++++++++++++++++----- .../Embedded/Modules/Control/MillisecTask.c | 12 ++- .../Embedded/Modules/Control/MillisecTask.h | 1 + 4 files changed, 118 insertions(+), 26 deletions(-) (limited to 'Software/Embedded_SW') diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index cf137a00a..4601e971b 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -243,6 +243,32 @@ typedef enum CART3 = 3, }CARTREGE; */ + +typedef struct +{ + bool DRAWER_BIG; //bit 0 + bool DRAWER_SMALL0;//bit 1 + bool DRAWER_SMALL1;//bit 2 + bool DRAWER_SMALL2;//bit 3 + bool DRAWER_SMALL3;//bit 4 + bool SYSTEM_FAN0; //bit 5 + bool SYSTEM_FAN1; //bit 6 + bool SYSTEM_FAN2; //bit 7 +}FANS_STATUS; + +enum +{ + DRAWER_B, + DRAWER_S0, + DRAWER_S1, + DRAWER_S2, + DRAWER_S3, + SYSTEM_0, + SYSTEM_1, + SYSTEM_2, + MAX_FANS, +}FANS_ID; + //--------------------- #define MaxFlashWords 128 //1K #define MaxFlashBytes MaxFlashWords*4 //4K Byte diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index 8efa3998f..454e82c28 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -9,6 +9,7 @@ #include "FPGA_Rename.h" #include "FPGA_COMM.h" +#include #include "driverlib/sysctl.h" //for SysCtlDelay #include @@ -191,20 +192,29 @@ uint32_t Calculate_Tacho_Fan_Speed(uint32_t OSC_IN, uint8_t PPR, uint16_t Presca } +uint32_t Fans_Speed_RPM[MAX_FANS]; + -uint32_t Read_Fans_Tacho() +FANS_STATUS Read_Fans_Tacho() { - uint32_t Status = 0; - uint32_t Drawer_Fan_Speed_RPM = 0; + FANS_STATUS Fans_Status; + #ifndef EVALUATION_BOARD // The big Fan in the drawer - Drawer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); - - if( Drawer_Fan_Speed_RPM < 1000 ) // need to work around 3000 RPM - Status|= 0x01;// not working / Low Speed + Fans_Speed_RPM[DRAWER_B] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); + Fans_Speed_RPM[DRAWER_S0] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg1); + Fans_Speed_RPM[DRAWER_S1] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg2); + Fans_Speed_RPM[DRAWER_S2] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg3); + Fans_Speed_RPM[DRAWER_S3] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg4); + Fans_Speed_RPM[SYSTEM_0] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg5); + Fans_Speed_RPM[SYSTEM_1] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg6); + Fans_Speed_RPM[SYSTEM_2] = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg7); + + if( Fans_Speed_RPM[DRAWER_B] < 1000 ) // need to work around 3000 RPM + Fans_Status.DRAWER_BIG = ERROR;// not working / Low Speed else - Status&= ~0x01;//working (Speed ~0x400) + Fans_Status.DRAWER_BIG = OK;//working (Speed ~0x400) // The 4 small Fans in the drawer // F1_gpi_FANS @@ -212,7 +222,10 @@ uint32_t Read_Fans_Tacho() // “1” Fan working if (F1_gpi_FANS == 0x0F ) { - Status&= ~(0x0F<<1);//working + Fans_Status.DRAWER_SMALL0 = OK;//working + Fans_Status.DRAWER_SMALL1 = OK;//working + Fans_Status.DRAWER_SMALL2 = OK;//working + Fans_Status.DRAWER_SMALL3 = OK;//working } else { @@ -221,28 +234,72 @@ uint32_t Read_Fans_Tacho() bool F1_FAN3_TACH = (F1_gpi_FANS & 0x04)>>0x02; bool F1_FAN4_TACH = (F1_gpi_FANS & 0x08)>>0x03; - if( F1_FAN1_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<1);// not working + if(( Fans_Speed_RPM[DRAWER_S0] < 3000 ) && ( F1_FAN1_TACH == 0)) // need to work around 5000 RPM + { + Fans_Status.DRAWER_SMALL0 = ERROR;/// not working / Low Speed + } else - Status&= ~(0x01<<1);//working + { + Fans_Status.DRAWER_SMALL0 = OK;//working (Speed ~0x400) + } - if( F1_FAN2_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<2);// not working + if(( Fans_Speed_RPM[DRAWER_S1] < 3000 ) && ( F1_FAN2_TACH == 0)) // Small Fan in the drawer // need to work around 5000 RPM + { + Fans_Status.DRAWER_SMALL1 = ERROR;// not working / Low Speed + } else - Status&= ~(0x01<<2);//working - - if( F1_FAN3_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<3);// not working + { + Fans_Status.DRAWER_SMALL1 = OK;//working (Speed ~0x400) + } + if(( Fans_Speed_RPM[DRAWER_S2] < 3000 ) && ( F1_FAN3_TACH == 0)) // Small Fan in the drawer // need to work around 5000 RPM + { + Fans_Status.DRAWER_SMALL2 = ERROR;// not working / Low Speed + } else - Status&= ~(0x01<<3);//working - - if( F1_FAN4_TACH == 0) // Small Fan in the drawer - Status|= (0x01<<4);// not working + { + Fans_Status.DRAWER_SMALL2 = OK;//working (Speed ~0x400) + } + if(( Fans_Speed_RPM[DRAWER_S3] < 3000 ) && ( F1_FAN4_TACH == 0)) // Small Fan in the drawer // need to work around 3050 RPM + { + Fans_Status.DRAWER_SMALL3 = ERROR;// not working / Low Speed + } else - Status&= ~(0x01<<4);//working + { + Fans_Status.DRAWER_SMALL3 = OK;//working (Speed ~0x400) < 1000 ) // need to work around 5000 RPM + } + + } + + if( Fans_Speed_RPM[SYSTEM_0] < 1000 ) // need to work around 3050 RPM + { + Fans_Status.SYSTEM_FAN0 = ERROR;// not working / Low Speed } + else + { + Fans_Status.SYSTEM_FAN0 = OK;//working (Speed ~0x400) + } + + if( Fans_Speed_RPM[SYSTEM_1] < 1000 ) // need to work around 3050 RPM + { + Fans_Status.SYSTEM_FAN1 = ERROR;// not working / Low Speed + } + else + { + Fans_Status.SYSTEM_FAN1 = OK;//working (Speed ~0x400) + } + + if( Fans_Speed_RPM[SYSTEM_2] < 1000 ) // need to work around 3050 RPM + { + Fans_Status.SYSTEM_FAN2 = ERROR;// not working / Low Speed + } + else + { + Fans_Status.SYSTEM_FAN2 = OK;//working (Speed ~0x400) + } + #endif - return Status; + + return Fans_Status; } //------------------------- WHS ---------------------- diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index db6624fd4..8e4a36e62 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -84,6 +84,8 @@ typedef struct MillisecMessage{ uint32_t Dancer_Data[NUM_OF_DANCERS] = {0}; float Speed_Data = 0; uint32_t DrawerFansStatus = 0; +uint32_t SystemFansStatus = 0; + bool watchdogCriticalAlarm = false; @@ -445,7 +447,7 @@ uint32_t MillisecLoop(uint32_t tick) } uint32_t MillisecLowLoop(uint32_t tick) { - uint8_t Motor_i,Disp_i,Heater_i; + uint8_t Motor_i,Disp_i,Heater_i,temp; TEMPERATURE_SENSOR_ID_ENUM Sensor_i; //static int temp=0; @@ -497,7 +499,9 @@ uint32_t MillisecLowLoop(uint32_t tick) //Read_MidTank_Pressure_Sensor(Disp_i); } FPGA_GetAllDispensersValveBusyOCD(); - DrawerFansStatus = Read_Fans_Tacho(); + temp = Read_Fans_Tacho(); + DrawerFansStatus = temp & 0x1F; + SystemFansStatus = temp & 0xE0; KeepAliveOneSecondCall(); for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) { @@ -617,6 +621,10 @@ uint32_t getDrawerFansStatus(void) { return DrawerFansStatus; } +uint32_t getSystemFansStatus(void) +{ + return SystemFansStatus; +} #ifdef HUNDRED_MICROSECONDS_DANCER_READ uint32_t DancerData[NUM_OF_DANCERS]; uint32_t Control_Read_Dancer_Position(HardwareDancerType DancerId, uint32_t Parameter1, uint32_t Parameter2) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index 61c7df7ee..7e2af1079 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -31,6 +31,7 @@ uint32_t getADCData(int DeviceId); */ float getSensorSpeedData(void); uint32_t getDrawerFansStatus(void); +uint32_t getSystemFansStatus(void); void MillisecInit(void); void MillisecStop(void); -- cgit v1.3.1