diff options
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control')
4 files changed, 158 insertions, 12 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index a580dce02..193769265 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; +uint8_t Gas_PPM = 0; bool watchdogCriticalAlarm = false; @@ -443,18 +445,50 @@ uint32_t MillisecLoop(uint32_t tick) #endif return OK; } +int TemperatureSum[MAX_TEMPERATURE_SENSOR_ID]; +int TemperatureMin[MAX_TEMPERATURE_SENSOR_ID]; +int TemperatureMax[MAX_TEMPERATURE_SENSOR_ID]; +int TemperatureCount[MAX_TEMPERATURE_SENSOR_ID]; +int TemperatureCalc[MAX_TEMPERATURE_SENSOR_ID]; +void MillisecUpdateTemperatures (TEMPERATURE_SENSOR_ID_ENUM SensorId,int temperature) +{ + //if(TemperatureCount[SensorId]++>=10) + // TemperatureCount[SensorId] = 0; + TemperatureCount[SensorId]++; + if (TemperatureMax[SensorId]<temperature) TemperatureMax[SensorId]=temperature; + if (TemperatureMin[SensorId]>temperature) TemperatureMin[SensorId]=temperature; + TemperatureSum[SensorId]+=temperature; +} +int MillisecCalculateTemperatures (TEMPERATURE_SENSOR_ID_ENUM SensorId) +{ + int calc = 0; + TemperatureSum[SensorId]-=TemperatureMax[SensorId]; + TemperatureSum[SensorId]-=TemperatureMin[SensorId]; + calc = TemperatureSum[SensorId] / (TemperatureCount[SensorId]-2); + + TemperatureSum[SensorId] = 0; + TemperatureCount[SensorId] = 0; + TemperatureMin[SensorId] = 30000; + TemperatureMax[SensorId] = -30000; + return calc; +} +int MillisecGetTemperatures (TEMPERATURE_SENSOR_ID_ENUM SensorId) +{ + return TemperatureCalc[SensorId]; +} 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; //call all modules Millisec functions //test dancers and speed encoders //check all callback units (state machine waiting for completion of a change) - bool Ten_msTick, Hundred_msTick, Onesecond_Tick,O900Millisecond_Tick,OneMinute_Tick; + bool Ten_msTick, Hundred_msTick , m90msecTick, Onesecond_Tick,O900Millisecond_Tick,OneMinute_Tick; Ten_msTick = (tick%eTenMillisecond == 0) ?true:false; Hundred_msTick = (tick%eHundredMillisecond == 0) ?true:false; + m90msecTick = (tick%eHundredMillisecond == 90) ?true:false; O900Millisecond_Tick = (tick%eOneSecond == 900) ?true:false; Onesecond_Tick = (tick%eOneSecond == 0) ?true:false; OneMinute_Tick = (tick%eOneMinute == 0) ?true:false; @@ -469,18 +503,27 @@ uint32_t MillisecLowLoop(uint32_t tick) if(Machine_Idle_Mode == true) Machine_Idle_Breathing_Led(); } + if (m90msecTick) + { + for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) + { + MillisecReadFromTempSensor(Sensor_i, NULL); + } + } if (Hundred_msTick) { Speed_Data = Calculate_Speed_Sensor_Velocity(); + Read_Buttons_Reg(); for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { - MillisecReadFromTempSensor(Sensor_i, NULL); + MillisecUpdateTemperatures (Sensor_i,TemperatureSensorRead(Sensor_i)); } if (GeneralHwReady == true) { if (watchdogCriticalAlarm == false) { Control_WD(ENABLE,5); //activate heaters/dispenser watchdog, 0.5 seconds + //LOG_ERROR (1111, "Control_WD"); } } } @@ -497,7 +540,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++) { @@ -506,9 +551,14 @@ uint32_t MillisecLowLoop(uint32_t tick) if (isMotorConfigured(Motor_i)) MotorGetStatusFromFPGA(Motor_i); } - for (Heater_i = 0;Heater_i < NUM_OF_HEATERS;Heater_i++) + for (Heater_i = 0;Heater_i < NUM_OF_CURRENT_HEATERS;Heater_i++) + { + Read_Heaters_Current(Heater_i); + } + Gas_PPM = Calculate_Gas_Power_Consumption(); + for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { - Read_Head_MixChip_Heaters_Current(Heater_i); + TemperatureCalc[Sensor_i] = MillisecCalculateTemperatures ( Sensor_i); } } if (OneMinute_Tick) @@ -617,6 +667,15 @@ uint32_t getDrawerFansStatus(void) { return DrawerFansStatus; } +uint8_t getGasReading(void) +{ + return Gas_PPM; +} + +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..be82d9e98 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -31,6 +31,10 @@ uint32_t getADCData(int DeviceId); */ float getSensorSpeedData(void); uint32_t getDrawerFansStatus(void); +uint32_t getSystemFansStatus(void); +uint8_t getGasReading(void); +int MillisecGetTemperatures (TEMPERATURE_SENSOR_ID_ENUM SensorId); + void MillisecInit(void); void MillisecStop(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 52b52d93b..b316fd73f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -69,7 +69,7 @@ typedef struct uint32_t StartTick; DataReadCBFunction ControlDataReadPtr; ControlCBFunction ControlCallbackPtr; - uint16_t ControlTiming; + uint32_t ControlTiming; }ControlDeviceStruc; typedef enum @@ -166,11 +166,51 @@ uint32_t ControlActivityLed( uint32_t Parameter1) ACTIVITY_RED_LED_OFF; // Heaters indication - all the Heaters OFF if(power.color == fastBILNK) Pannel_Leds(POWER_ON_OFF,MODE_OFF); - + else if((power.color == BLINK) && (counter % Blink_Freq == 0) ) { Pannel_Leds(POWER_ON_OFF,MODE_OFF); } + /////////////////////////////////////////////////////////// + if(jog.color == fastBILNK) + Pannel_Leds(THREAD_JOGGING,MODE_OFF); + else + if((jog.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(THREAD_JOGGING,MODE_OFF); + } + /////////////////////////////////////////////////////////// + if(load.color == fastBILNK) + Pannel_Leds(THREAD_LOAD,MODE_OFF); + else + if((load.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(THREAD_LOAD,MODE_OFF); + } + /////////////////////////////////////////////////////////// + if(cart1.color == fastBILNK) + Pannel_Leds(CART_1,MODE_OFF); + else + if((cart1.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(CART_1,MODE_OFF); + } + /////////////////////////////////////////////////////////// + if(cart2.color == fastBILNK) + Pannel_Leds(CART_2,MODE_OFF); + else + if((cart2.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(CART_2,MODE_OFF); + } + /////////////////////////////////////////////////////////// + if(cart3.color == fastBILNK) + Pannel_Leds(CART_3,MODE_OFF); + else + if((cart3.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(CART_3,MODE_OFF); + } flag = false; } else @@ -181,11 +221,53 @@ uint32_t ControlActivityLed( uint32_t Parameter1) if(power.color == fastBILNK) Pannel_Leds(POWER_ON_OFF,MODE_ON); - + else if((power.color == BLINK) && (counter % Blink_Freq == 0) ) { Pannel_Leds(POWER_ON_OFF,MODE_ON); } + /////////////////////////////////////////////////////////// + if(jog.color == fastBILNK) + Pannel_Leds(THREAD_JOGGING,MODE_ON); + else + if((jog.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(THREAD_JOGGING,MODE_ON); + } + /////////////////////////////////////////////////////////// + if(load.color == fastBILNK) + Pannel_Leds(THREAD_LOAD,MODE_ON); + else + if((load.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(THREAD_LOAD,MODE_ON); + } + /////////////////////////////////////////////////////////// + if(cart1.color == fastBILNK) + Pannel_Leds(CART_1,MODE_ON); + else + if((cart1.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(CART_1,MODE_ON); + } + /////////////////////////////////////////////////////////// + if(cart2.color == fastBILNK) + Pannel_Leds(CART_2,MODE_ON); + else + if((cart2.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(CART_2,MODE_ON); + } + /////////////////////////////////////////////////////////// + if(cart3.color == fastBILNK) + Pannel_Leds(CART_3,MODE_ON); + else + if((cart3.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(CART_3,MODE_ON); + } + + flag = true; } @@ -224,7 +306,7 @@ void ControlStart(void) * both these callbacks can be removed. if a new call is arriving, it invalidates the previous one (no dual control or data) * ***************************************************************************************************************************************************/ -uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ) +uint32_t AddControlCallback( ControlCBFunction Callback, uint32_t CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ) { assert(Callback); assert(DriverfPtr); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 8d7e219ac..380040e34 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -19,7 +19,8 @@ typedef enum { eTenMillisecond = 10, eHundredMillisecond = 100, eOneSecond = 1000, - eOneMinute = 60000 + eOneMinute = 60000, + eOneHour = 3600000 }CTRL_TIMING_ENUM; typedef enum { @@ -37,7 +38,7 @@ typedef enum void ControlInit(void); void ControlStop(void); void ControlStart(void); -uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); +uint32_t AddControlCallback( ControlCBFunction Callback, uint32_t CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); int RemoveControlCallback(uint32_t deviceId, ControlCBFunction Callback ); //The safe remove command can be used ONLY when called from the control callback itself int SafeRemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback); |
