aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c47
1 files changed, 45 insertions, 2 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
index d34ac9ff9..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,13 +503,20 @@ 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)
{
@@ -517,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)
{