diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-04-16 00:38:18 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-04-16 00:38:18 +0300 |
| commit | a43abd7769c1dd19b2bfe4f9d09d8226da396516 (patch) | |
| tree | a692defe22a6eb75f1ee0d2caf539300d8dceb9c /Software/Embedded_SW/Embedded/Modules/Control | |
| parent | b54e81b157edff62414a8a8e3fb9e82964f0c5d1 (diff) | |
| parent | 9d9aa53284fd93fc8590d2ff85741c7f4a95947b (diff) | |
| download | Tango-a43abd7769c1dd19b2bfe4f9d09d8226da396516.tar.gz Tango-a43abd7769c1dd19b2bfe4f9d09d8226da396516.zip | |
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control')
4 files changed, 137 insertions, 8 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 738f59686..193769265 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -445,6 +445,37 @@ 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,temp; @@ -454,9 +485,10 @@ uint32_t MillisecLowLoop(uint32_t tick) //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; @@ -471,19 +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"); } } } @@ -516,6 +556,10 @@ uint32_t MillisecLowLoop(uint32_t tick) Read_Heaters_Current(Heater_i); } Gas_PPM = Calculate_Gas_Power_Consumption(); + for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) + { + TemperatureCalc[Sensor_i] = MillisecCalculateTemperatures ( Sensor_i); + } } if (OneMinute_Tick) { diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index 064302685..be82d9e98 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -33,6 +33,8 @@ 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); |
