aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Embedded_SW/Embedded/Modules
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-10-17 15:23:13 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-10-17 15:23:13 +0300
commite01a3adffe474b22879c4959187c280c49f89bb1 (patch)
tree0b88eb7c46c07bdf3f1ff882521ddbe2731e9fac /Software/Embedded_SW/Embedded/Modules
parent567e496569795e676df189d1a39b1aa5d01b4ea1 (diff)
parent8d8035d7c7382e9aa74f4a42aa1cd9080a4c2095 (diff)
downloadTango-e01a3adffe474b22879c4959187c280c49f89bb1.tar.gz
Tango-e01a3adffe474b22879c4959187c280c49f89bb1.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
-rw-r--r--Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c4
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c68
-rw-r--r--Software/Embedded_SW/Embedded/Modules/General/process.c25
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h14
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c5
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c35
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c2
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h1
-rw-r--r--Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c111
10 files changed, 158 insertions, 111 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
index c46e49672..15ebfc632 100644
--- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
+++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c
@@ -116,10 +116,10 @@ AlarmHandlingItem AlarmItem[MAX_SYSTEM_ALARMS]={
{100,LimitSwitchAlarm,LimitSwitchAlarmLow_6,false,true,DEBUG_LOG_CATEGORY__Warning,5,0,0,false,EVENT_TYPE__Dispenser6LowLevel,NULL,"Dispenser6LowLevel"},
{100,LimitSwitchAlarm,LimitSwitchAlarmLow_7,false,true,DEBUG_LOG_CATEGORY__Warning,6,0,0,false,EVENT_TYPE__Dispenser7LowLevel,NULL,"Dispenser7LowLevel"},
{100,LimitSwitchAlarm,LimitSwitchAlarmLow_8,false,true,DEBUG_LOG_CATEGORY__Warning,7,0,0,false,EVENT_TYPE__Dispenser8LowLevel,NULL,"Dispenser8LowLevel"},*/
-{100,TemperatureAlarm,TEMP_SENSE_ANALOG_MIXCHIP_TEMP,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"GeneralInternalOverTemperature"},
+{100,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP3,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"GeneralInternalOverTemperature"},
//{100,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP1,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"GeneralInternalOverTemperature"},
//{100,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP2,80,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"GeneralInternalOverTemperature"},
-{100,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP3,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead6OverTemperature,NULL,"DyeingHead6OverTemperature"},
+{100,TemperatureAlarm,TEMP_SENSE_ANALOG_MIXCHIP_TEMP,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead6OverTemperature,NULL,"DyeingHead6OverTemperature"},
{100,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP1,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead1OverTemperature,NULL,"DyeingHead1OverTemperature"},
{100,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP2,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead2OverTemperature,NULL,"DyeingHead2OverTemperature"},
{100,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP3,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead3OverTemperature,NULL,"DyeingHead3OverTemperature"},
diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
index 9ce05b485..fa168067f 100644
--- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
+++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c
@@ -494,13 +494,13 @@ uint32_t MillisecLoop(uint32_t tick)
{
Read_MidTank_Pressure_Sensor(Disp_i);
}
- for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++)
+/* for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++)
{
if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_SCREW)
continue; //
if (isMotorConfigured(Motor_i))
MotorGetStatusFromFPGA(Motor_i);
- }
+ }*/
}
//ROM_IntMasterEnable();
diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
index 1ec32a4ae..44681fb29 100644
--- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
+++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c
@@ -55,9 +55,8 @@ uint32_t Diagnostics_TenMiliControlTrigger(uint32_t IfIndex, uint32_t ReadValue)
DiagnosticsMonitors DiagnosticsMonitor = DIAGNOSTICS_MONITORS__INIT;
-DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM];
-#define DIAGNOSTICS_LIMIT 10
-#define DIAGNOSTICS_DANCER_LIMIT 100
+#define DIAGNOSTICS_LIMIT 5
+#define DIAGNOSTICS_DANCER_LIMIT 50
int DiagnosticsIndex = 0;
int DiagnosticCollectionLimit = 3; //number of data samples to collect before sending to the host
//int DiagnosticLimit = eHundredMillisecond; //frequency of data collection
@@ -96,6 +95,8 @@ DoubleArray DiagnosticsDispenserPressure[MAX_SYSTEM_DISPENSERS];
HeaterState **heatersstates;
HeaterState HeaterInfo[HEATER_TYPE__MixerHeater+1];
+DigitalInterfaceState **digitalinterfacestates;
+DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM];
/*double dispenser1motorfrequency[DIAGNOSTICS_LIMIT];
double dispenser2motorfrequency[DIAGNOSTICS_LIMIT];
double dispenser3motorfrequency[DIAGNOSTICS_LIMIT];
@@ -153,6 +154,14 @@ void DiagnosticsInit(void)
heater_state__init(&HeaterInfo[i]);
heatersstates[i] = &HeaterInfo[i];
}
+ digitalinterfacestates = (DigitalInterfaceState**)malloc(sizeof(DigitalInterfaceState *)*MAX_HEATERS_NUM);
+ for (i = 0;i<MAX_HEATERS_NUM;i++ )
+ {
+ digital_interface_state__init(&DigitalOutputState[i]);
+ DigitalOutputState[i].has_interfaceio = true;
+ DigitalOutputState[i].has_value = true;
+ digitalinterfacestates[i] = &DigitalOutputState[i];
+ }
return;
}
@@ -160,6 +169,8 @@ uint8_t HeaterCounterIndex[MAX_HEATERS_NUM]= {0,0,0,0,0,0,0,0,0,0};
double HeaterTemperature[MAX_HEATERS_NUM][DIAGNOSTICS_LIMIT];
uint8_t DancerCounterIndex[NUM_OF_DANCERS]= {0,0,0};
double DancerValue[NUM_OF_DANCERS][DIAGNOSTICS_DANCER_LIMIT];
+int8_t DancerErrorCounterIndex[NUM_OF_DANCERS]= {0,0,0};
+double DancerErrorValue[NUM_OF_DANCERS][DIAGNOSTICS_DANCER_LIMIT];
uint8_t MotorCounterIndex[MAX_THREAD_MOTORS_NUM]= {0,0,0};
double MotorValue[MAX_THREAD_MOTORS_NUM][DIAGNOSTICS_LIMIT];
uint8_t SpeedCounterIndex= 0;
@@ -181,12 +192,6 @@ void DiagnosticLoadMotor(int MotorId, int frequency)
void DiagnosticsLoadDigitalValues(void)
{
int i;
- for (i = 0;i<MAX_HEATERS_NUM;i++ )
- {
- digital_interface_state__init(&DigitalOutputState[i]);
- DigitalOutputState[i].has_interfaceio = true;
- DigitalOutputState[i].has_value = true;
- }
DigitalOutputState[0].interfaceio = INTERFACE_IOS__GPO_DRYER_SSR3_CTRL;
DigitalOutputState[0].value = GetHeaterState(0);
@@ -250,6 +255,19 @@ void DiagnosticLoadDancer(int DancerId, uint16_t value)
if (DancerCounterIndex[DancerId]>=DIAGNOSTICS_DANCER_LIMIT )
DancerCounterIndex[DancerId] = 0;
}
+void DiagnosticLoadDancerError(int DancerId, double value)
+{
+ if (DancerId >= MAX_HEATERS_NUM)
+ {
+ LOG_ERROR(DancerId,"wrong Dancer Id");
+ return;
+ }
+ DancerErrorValue[DancerId][DancerErrorCounterIndex[DancerId]] = value;
+ DancerErrorCounterIndex[DancerId]++;
+ if (DancerErrorCounterIndex[DancerId]>=DIAGNOSTICS_DANCER_LIMIT )
+ DancerErrorCounterIndex[DancerId] = 0;
+
+}
void DiagnosticTenMsecCollection(void)
{
if (DiagnosticsActive == false)
@@ -259,6 +277,11 @@ void DiagnosticTenMsecCollection(void)
DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0,0));
DiagnosticLoadDancer(POOLER_DANCER,Control_Read_Dancer_Position(POOLER_DANCER, 0,0));
DiagnosticLoadDancer(FEEDER_DANCER,Control_Read_Dancer_Position(FEEDER_DANCER, 0,0));
+
+ DiagnosticLoadDancerError(WINDER_DANCER,ThreadGetMotorCalculatedError(WINDER_DANCER));
+ DiagnosticLoadDancerError(POOLER_DANCER,ThreadGetMotorCalculatedError(POOLER_DANCER));
+ DiagnosticLoadDancerError(FEEDER_DANCER,ThreadGetMotorCalculatedError(FEEDER_DANCER));
+
//DiagnosticLoadSpeedSensor(getSensorSpeedData());
}
@@ -400,6 +423,12 @@ void SendDiagnostics(void)
DiagnosticsMonitor.dancer1angle = DancerValue[0];
DiagnosticsMonitor.dancer2angle = DancerValue[1];
DiagnosticsMonitor.dancer3angle = DancerValue[2];
+ DiagnosticsMonitor.n_windertension = DancerErrorCounterIndex[0];
+ DiagnosticsMonitor.n_pullertension = DancerErrorCounterIndex[1];
+ DiagnosticsMonitor.n_feedertension = DancerErrorCounterIndex[2];
+ DiagnosticsMonitor.windertension = DancerErrorValue[0];
+ DiagnosticsMonitor.pullertension = DancerErrorValue[1];
+ DiagnosticsMonitor.feedertension = DancerErrorValue[2];
DiagnosticsMonitor.n_threadspeed = SpeedCounterIndex;
DiagnosticsMonitor.threadspeed = SpeedValue;
@@ -500,20 +529,6 @@ void SendDiagnostics(void)
DiagnosticsMonitor.dispenser8pressure = dispenserspressure[7];
response.monitors = &DiagnosticsMonitor;
- //DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM];
- response.n_digitalinterfacestates = 0;
- /*
- response.n_digitalinterfacestates = MAX_HEATERS_NUM;
- response.digitalinterfacestates = (DigitalInterfaceState**)malloc(sizeof(DigitalInterfaceState)*MAX_HEATERS_NUM);
- if (response.digitalinterfacestates)
- {
- DiagnosticsLoadDigitalValues();
- for (i=0;i<MAX_HEATERS_NUM;i++)
- {
- response.digitalinterfacestates[i] = &DigitalOutputState[i];
- }
- }
- */
//response.digitalpins = DigitalPinArray;
response.n_componentsstates = 0;
/* if (blowervolatgedisplay == true)
@@ -531,6 +546,10 @@ void SendDiagnostics(void)
}
}
*/
+ DiagnosticsLoadDigitalValues();
+ response.n_digitalinterfacestates = MAX_HEATERS_NUM;
+ response.digitalinterfacestates = digitalinterfacestates;
+
for (i=HEATER_TYPE__DryerAirHeater;i<=HEATER_TYPE__MixerHeater;i++)
{
LoadHeaterState((HeaterType)i,&HeaterInfo[i]);
@@ -560,12 +579,11 @@ void SendDiagnostics(void)
else
{
LOG_ERROR(Task_self(),"malloc failed");
+ DiagnosticsStop();
}
free(diagnosticsresponseContainer.data.data);
}
DiagnosticsReset();
- if (response.digitalinterfacestates)
- free(response.digitalinterfacestates);
}
uint32_t DiagnosticsControlId = 0xff;
uint32_t Diagnostics10MSControlId = 0xff;
diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c
index 8fc9434cb..b56162bea 100644
--- a/Software/Embedded_SW/Embedded/Modules/General/process.c
+++ b/Software/Embedded_SW/Embedded/Modules/General/process.c
@@ -33,6 +33,18 @@ ProcessParameters* ProcessParametersKeep;
uint32_t HandleProcessParameters(ProcessParameters* ProcessParams)
{
uint32_t status = 0;
+ if (ProcessParams->dryerzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->dryerzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->dryerzone3temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->mixertemp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->headzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->headzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->headzone3temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->headzone4temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->headzone5temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (ProcessParams->headzone6temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
+ if (status != 0)
+ return status;
if (ProcessParams)
{
ProcessParametersKeep = ProcessParams;
@@ -127,7 +139,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams)
headairflow = ProcessParams->headairflow;
dryerairflow = ProcessParams->dryerairflow;
- return OK;//status;
+ return status;//status;
}
void ProcessRequestFunc(MessageContainer* requestContainer)
@@ -148,17 +160,6 @@ void ProcessRequestFunc(MessageContainer* requestContainer)
REPORT_MSG (ProcessParams->dryerzone1temp,"Process Params Dryer");
- if (ProcessParams->dryerzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->dryerzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->dryerzone3temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->mixertemp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->headzone1temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->headzone2temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->headzone3temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->headzone4temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->headzone5temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
- if (ProcessParams->headzone6temp > MAX_ALLOWED_TEMPERATURE) status = ERROR_CODE__INVALID_PARAMETER;
-
if (status == 0)
status = HandleProcessParameters(ProcessParams);
if (status)
diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h
index 3b357ce11..d19e4e5dd 100644
--- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h
+++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h
@@ -24,7 +24,7 @@ typedef struct HeaterPIDControlConfigstruc
int id; //HardwarePidControlType
char name[20];
int32_t outputproportionalpowerlimit;
- int32_t outputproportionalband;
+ float outputproportionalband;
int32_t integraltime;
int32_t derivativetime;
int32_t sensorcorrectionadjustment;
@@ -50,20 +50,8 @@ typedef struct HeaterCommandstruc
uint32_t targettemperatue;
}HeaterCommand;
-typedef struct
-{
- bool m_isEnabled;
- float m_SetParam;
- float m_mesuredParam;
- float m_preError;
- float m_integral;
- float m_calculatedError;
- bool m_isReady;
- PID_Config_Params m_params;
-}HeaterControlConfig_t;
extern HeaterPIDControlConfig HeaterControl[MAX_HEATERS_NUM];
-extern HeaterControlConfig_t HeaterPIDConfig[MAX_HEATERS_NUM];
extern HeaterCommand HeaterCmd[MAX_HEATERS_NUM];
extern uint32_t Heater_timerBase;
diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c
index ebdb126ac..e862107ff 100644
--- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c
+++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c
@@ -46,7 +46,6 @@ typedef enum {
/******************** GLOBAL PARAMETERS ********************************************/
HeaterPIDControlConfig HeaterControl[MAX_HEATERS_NUM] = {0,0,0,0,0,0,0,0,0,0,0,0};
-HeaterControlConfig_t HeaterPIDConfig[MAX_HEATERS_NUM] = {0,0,0,0,0,0,0,0,0,0,0,0};
bool AcHeaterConfigured[MAX_AC_HEATERS] = {0,0,0};
int NumberOFSlicesInUse = 0;
@@ -348,7 +347,7 @@ uint32_t HeaterRecalculateSharedHeatersParams(uint32_t deviceId, uint32_t new_ou
}
// all numbers are rounded down. better to have carefully calculated numbers
- HeaterControl[deviceId].outputproportionalpowerlimit = new_outputproportionalpowerlimit/100;
+ HeaterControl[deviceId].outputproportionalpowerlimit = new_outputproportionalpowerlimit;///100;
Heater1000Slices = HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain].outputproportionalpowerlimit * NumberOFSlicesInUse / 100;
Heater200aSlices = HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].outputproportionalpowerlimit * NumberOFSlicesInUse / 100;
@@ -391,7 +390,7 @@ uint32_t HeaterRecalculateHeaterParams(uint32_t deviceId, uint32_t new_outputpro
HeaterControl[deviceId].outputproportionalpowerlimit = new_outputproportionalpowerlimit;
//mark the time slices for heaters operation as empty / Heater1000 / Heater 200
- DCTimeSliceAllocation[deviceId] = (HeaterControl[deviceId].outputproportionalpowerlimit/100 * NumberOFSlicesInUse) / 100;
+ DCTimeSliceAllocation[deviceId] = (HeaterControl[deviceId].outputproportionalpowerlimit/*/100*/ * NumberOFSlicesInUse) / 100;
diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c
index 2acd8c56f..3caf91de4 100644
--- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c
@@ -41,6 +41,18 @@ typedef struct HeatersControlMessage{
uint32_t tick;
uint8_t messageData[20];
}HeatersControlMessageStruc;
+typedef struct
+{
+ bool m_isEnabled;
+ float m_SetParam;
+ float m_mesuredParam;
+ float m_preError;
+ float m_integral;
+ float m_calculatedError;
+ bool m_isReady;
+ PID_Config_Params m_params;
+}HeaterControlConfig_t;
+HeaterControlConfig_t HeaterPIDConfig[MAX_HEATERS_NUM] = {0,0,0,0,0,0,0,0,0,0,0,0};
/******************** GLOBAL PARAMETERS ********************************************/
HeaterCommand HeaterCmd[MAX_HEATERS_NUM];
@@ -124,8 +136,7 @@ void HeatersControlStart(void)
}
void LoadHeaterState(HeaterType HeaterType,HeaterState *HeaterState)
{
- HardwarePidControlType HeaterTypeToControlId[HEATER_TYPE__HeaterZone6] = {HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1,HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2,HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3,HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4,HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5,HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6};
- int HeaterId = HeaterTypeToControlId[HeaterType];
+ int HeaterId = HeaterType;
HeaterState->has_heatertype = true;
HeaterState->heatertype = HeaterType;
@@ -462,7 +473,6 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue)
uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue)
{
int index=MAX_HEATERS_NUM;
- double temperror = 0.0, correction = 0.0;
/*char str[100];
uint8_t len = 0;*/
if (IfIndex>>8 != IfTypeHeaters)
@@ -511,11 +521,20 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue)
if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0))
{
HeaterPIDConfig[index].m_mesuredParam = readValue;
+ if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band
+ {
+ HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 100);
+ //REPORT_MSG (readValue,"AC HEATER Over temperature");
+ }
+ else if (readValue > ((HeaterCmd[index].targettemperatue * (100+HeaterControl[index].outputproportionalband))/100))
+ {
+ HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 0);
+ //REPORT_MSG (readValue,"AC HEATER Under temperature");
+ }
//check only for the proportional band limits
HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam,
&HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral);
- //correction = HeaterPIDConfig[index].m_calculatedError;
- HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, (int)(HeaterPIDConfig[index].m_calculatedError));
+ //HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, (int)(HeaterPIDConfig[index].m_calculatedError/100));
}
@@ -588,14 +607,14 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue)
}
if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0))
{
- /*if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band
+ if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band
{
HeaterRecalculateHeaterParams(index, 100);
}
else if (readValue > ((HeaterCmd[index].targettemperatue * (100+HeaterControl[index].outputproportionalband))/100))
{
HeaterRecalculateHeaterParams(index, 0);
- }*/
+ }
//check only for the proportional band limits
HeaterPIDConfig[index].m_mesuredParam = readValue;
@@ -611,7 +630,7 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue)
// Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]);
//#warning PID is now only proportional (above)
- HeaterRecalculateHeaterParams(index, (int)(HeaterPIDConfig[index].m_calculatedError));
+ //HeaterRecalculateHeaterParams(index, (int)(HeaterPIDConfig[index].m_calculatedError/100));
}
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
index ccc9623a3..c7dd4f7ae 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c
@@ -107,7 +107,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue)
uint32_t status=OK;
uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep;
- MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency);
+ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses);
//REPORT_MSG(numOfSteps, "Winder_PrepareStage2");
REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2");
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
index 2961bd105..c5e3edc85 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h
@@ -27,6 +27,7 @@ uint32_t InternalWindingConfigMessage(JobSpool* request);
uint32_t ThreadConfigBreakSensor(void *request);
uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId);
+double ThreadGetMotorCalculatedError(int DancerId);
uint32_t ThreadPrepareState(void *JobDetails);
uint32_t ThreadPreSegmentState(void *JobDetails);
uint32_t ThreadSegmentState(void *JobDetails, int SegmentId);
diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
index 05c6c9003..54309a187 100644
--- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
+++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c
@@ -70,10 +70,12 @@ double TotalProcessedLength = 0.0;
double LengthCalculationMultiplier;
uint32_t PoolerPreviousPosition = 0, PoolerCurrentPosition = 0;
-double PoolerCurrentProcessedLength = 0.0;
double PoolerTotalProcessedLength = 0.0;
double PoolerLengthCalculationMultiplier;
+double TempPoolerTotalProcessedLength = 0.0;
+double TempTotalProcessedLength = 0.0;
+
bool PrepareState = false;
int CurrentSegmentId = 0;
typedef void (* ProcessedLengthFunc)(void);
@@ -132,22 +134,21 @@ void ThreadUpdateProcessLength (double length, void *Funcptr)
{
CurrentRequestedLength = length*100;//Centimetres
CurrentProcessedLength = 0;
- PoolerCurrentProcessedLength = 0;
ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr;
initialpos = 0xFFFF;
Poolerinitialpos = 0xFFFF;
}
-
+char Lenstr[150];
uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
uint32_t positionDiff = 0;
double length = 0.0;
- char str[150];
+
int index = MAX_THREAD_MOTORS_NUM;
- if (ThreadControlActive == false)
- return OK;
- if (PrepareState == true)
- return OK;
+ // if (ThreadControlActive == false)
+ // return OK;
+ // if (PrepareState == true)
+ // return OK;
if (IfIndex>>8 != IfTypeThread)
{
LOG_ERROR (IfIndex, "Wrong Interface type");
@@ -184,14 +185,15 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
static int pooler_counter = 0;
pooler_counter++;
TotalProcessedLength+= (length/100);
+ TempTotalProcessedLength = TotalProcessedLength;
if (pooler_counter%10 == 0)
{
if (PrepareState == true)
{
//later - add temperatures
- TemperatureListString(str);
+ TemperatureListString(Lenstr);
- SendJobProgress(0.0,0,false, str);
+ SendJobProgress(0.0,0,false, Lenstr);
}
else
{
@@ -201,9 +203,9 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
}
if (CurrentProcessedLength>=CurrentRequestedLength )
{
- usnprintf(str, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
- SendJobProgress(0.0,0,false, str);
- Report(str,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
+ usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ SendJobProgress(0.0,0,false, Lenstr);
+ Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
// segment/intersegment/distance to spool finished
if (ProcessedLengthFuncPtr)
ProcessedLengthFuncPtr();
@@ -247,7 +249,8 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue)
PoolerPreviousPosition = PoolerCurrentPosition;
length = (double)(positionDiff)*PoolerLengthCalculationMultiplier;
- PoolerCurrentProcessedLength+=length;
+ PoolerTotalProcessedLength+= (length/100);
+ TempPoolerTotalProcessedLength = PoolerTotalProcessedLength;
return OK;
}
@@ -310,14 +313,16 @@ uint32_t ThreadControlSpeedReadFunction(uint32_t IfIndex, uint32_t ReadValue)
}
return OK;
}
-double calculatedError[200];
//double eNormalizedError[100];
-int MotorId[200];
-int readValue[200];
//int TranslatedreadValue[100];
-int AveragereadValue[200];
-int calculatedspeed[200];
+/*double calculatedError[1000];
+int MotorId[1000];
+int readValue[1000];
+int AveragereadValue[1000];
+int calculatedspeed[1000];
+int timestamp[1000];*/
int controlIndex = 0;
+bool keepdata = true;
/*int32_t KeepReadValue = 0;
void testDancersControl()
{
@@ -343,6 +348,8 @@ void testDancersControl()
ThreadControlActive = false;
}*/
bool dancerinvalid = false;
+int MotorFailedSample[MAX_THREAD_MOTORS_NUM] = {0,0,0,0,0};
+char Message[60];
uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
{
//#define MAX_CONTROL_SAMPLES 6
@@ -375,11 +382,13 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
DancerId = ThreadMotorIdToDancerId[index];
if (ReadValue < 10)
{
+ MotorFailedSample[index]++;
REPORT_MSG(ReadValue, "Dancer value read too small.");
return OK;
}
if (ReadValue == 0x3FFF)
{
+ MotorFailedSample[index]++;
if (dancerinvalid == false)
{
dancerinvalid = true;
@@ -429,10 +438,11 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
//Stop Execution if the dancer moves too much
if ((abs(avreageSampleValue)> DancerStopActivityLimit[index])&&(JobCounter > eOneSecond))
{
+ keepdata = false;
usnprintf(Message, 60, "Dancer %d limit %d value %d Zero %d",DancerId,DancerStopActivityLimit[index],avreageSampleValue,DancersCfg[DancerId].zeropoint);
//JobAbortedByUser = true;
ThreadControlActive = false;
- JobEndReason = JOB_WINDER_DANCER_FAIL+index;
+ JobEndReason = JOB_WINDER_DANCER_FAIL+DancerId;
SendJobProgress(0.0,0,false, Message);
//EndState(CurrentJob,Message );
SegmentReady(Module_Thread,ModuleFail);
@@ -454,35 +464,25 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue)
//KeepNormalizedError = NormalizedError;
}
calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index];
- /*if (index == FEEDER_MOTOR)
- {
- if (KeepReadValue != TranslatedReadValue)
- {
- eNormalizedError[controlIndex] = NormalizedError;
- calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError;
- readValue[controlIndex] = ReadValue;
- TranslatedreadValue[controlIndex] = TranslatedReadValue;
- AveragereadValue[controlIndex] = avreageSampleValue;
- calculatedspeed[controlIndex] = calculated_speed;
- controlIndex++;
- if (controlIndex >= 99) controlIndex = 0;
- KeepReadValue = TranslatedReadValue;
- }
- }*/
if (abs(calculated_speed-CurrentControlledSpeed[index])>2)
{
- calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError;
- //double eNormalizedError[100];
- MotorId[controlIndex] = index;
- readValue[controlIndex] = ReadValue;
- //int TranslatedreadValue[100];
- AveragereadValue[controlIndex] = avreageSampleValue;
- calculatedspeed[controlIndex] = calculated_speed;
- if (controlIndex++>=199)
- controlIndex = 0;
+ /*if (keepdata == true)
+ {
+ calculatedError[controlIndex] = MotorControlConfig[index].m_calculatedError;
+ MotorId[controlIndex] = index;
+ readValue[controlIndex] = ReadValue;
+ AveragereadValue[controlIndex] = avreageSampleValue;
+ calculatedspeed[controlIndex] = calculated_speed;
+ timestamp[controlIndex] = HibernateRTCSSGet();
+ if (controlIndex++>=999)
+ controlIndex = 0;
+ }*/
CurrentControlledSpeed[index] = calculated_speed;
MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed);
}
+ else
+ MotorFailedSample[index]++;
+
}
return OK;
@@ -493,6 +493,21 @@ uint32_t ThreadGetMotorSpeed(threadMotorsEnum MotorId)
{
return CurrentControlledSpeed[MotorId];
}
+//********************************************************************************************************************
+double ThreadGetMotorCalculatedError(int DancerId)
+{
+ switch (DancerId)
+ {
+ case FEEDER_DANCER:
+ return (double)MotorControlConfig[FEEDER_MOTOR].m_calculatedError;
+ case POOLER_DANCER:
+ return (double)MotorControlConfig[POOLER_MOTOR].m_calculatedError;
+ case WINDER_DANCER:
+ return (double)MotorControlConfig[WINDER_MOTOR].m_calculatedError;
+
+ }
+ return 0;
+}
//********************************************************************************************************************
uint32_t ThreadInitialTestStub(HardwareMotor * request)
@@ -564,7 +579,7 @@ uint32_t ThreadEmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue)
PoolerSpeedControlId = 0xFF;
}
//SetMotHome(ThreadMotorIdToMotorId[Motor_i]);
- LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
+ PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep);
PoolerSpeedControlId = AddControlCallback(PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i);
}
if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled
@@ -715,11 +730,17 @@ uint32_t ThreadDistanceToSpoolState(void )
return OK;
}
+char Endstr[150];
//********************************************************************************************************************
uint32_t ThreadEndState(void *JobDetails)
{
int Motor_i;
ThreadControlActive = false;
+
+ usnprintf(Endstr, 100, "Total _processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength);
+ SendJobProgress(0.0,0,false, Endstr);
+ Report(Endstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0);
+
ThreadUpdateProcessLength (0.0,(void *)NULL);
SetOriginMotorSpeed(0);