diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-10-15 17:03:53 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-10-15 17:03:53 +0300 |
| commit | fd4f2d63b097dc9e189c9d30682bd6d5cc584d48 (patch) | |
| tree | 8b911df6ec6f7c29ac85aa1dd8e331ed86f1e6bf /Software/Embedded_SW/Embedded/Modules | |
| parent | 6a3361f3a9e08b63b39589add64f5802932022f3 (diff) | |
| parent | 1b2dfd51ae086f40bba2934e550d9d4b8cca9cce (diff) | |
| download | Tango-fd4f2d63b097dc9e189c9d30682bd6d5cc584d48.tar.gz Tango-fd4f2d63b097dc9e189c9d30682bd6d5cc584d48.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
19 files changed, 555 insertions, 146 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index ca6c4d51f..990465fb1 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -29,12 +29,15 @@ #include "drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h" #include <Drivers/I2C_Communication/WHS_Card/D_EMC2302_Fan/WHS_Fan.h> #include "drivers/I2C_Communication/Head_Card/ADC/Head_ADC.h" +#include <Drivers/I2C_Communication/RFID_NFC/I2C_IFS_Mux.h> #include "Common/SWUpdate/FileSystem.h" #include "drivers/Flash_ram/MCU_E2Prom.h" #include "modules/thread/thread_ex.h" #include "modules/heaters/heaters_ex.h" #include "modules/ids/ids_ex.h" +#include "modules/waste/waste_ex.h" +#include "modules/General/process.h" #include <PMR/Diagnostics/Event.pb-c.h> #include <PMR/Diagnostics/EventType.pb-c.h> #include <PMR/Diagnostics/StartEventsNotificationRequest.pb-c.h> @@ -970,9 +973,9 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) } } } - if (Configured[Module_Waste]) + if ((IFS_Availability[1] == IFS_RECOGNIZED_INIT_PASSED)&&(IFS_Availability[2] == IFS_RECOGNIZED_INIT_PASSED)) //ifs installed -check cartridges { - FoundReason = Waste_Prepare(); + FoundReason = Waste_CheckState(); } if ((AlarmState[Alarm_i].Status == true)&&(FoundReason == JOB_OK)) { @@ -1005,7 +1008,10 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) { JobEndReason = getEndReason(AlarmId); if (JobEndReason!=FoundReason) + { ReportWithPackageFilter(AlarmFilter,"end reason mismatch!!!", __FILE__,AlarmId,JobEndReason, RpMessage, FoundReason, 0); + JobEndReason=FoundReason; + } //AbortJob(AlarmReasonStr); //PrepareReady(Module_Alarms,ModuleFail); ReportWithPackageFilter(AlarmFilter,AlarmReasonStr, __FILE__,__LINE__,AlarmId, RpMessage, DEBUG_LOG_CATEGORY__Error, 0); @@ -1324,7 +1330,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) case ALARM_SOURCE_TYPE__MotorAlarm: if (CheckMotorAlarms) { - if (FPGA_WD_Occurred == true) + if ((FPGA_WD_Occurred == true)||(MachineReadyForHeating == false)) { Status = false; } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 4cd91443b..091df1a3f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -578,6 +578,13 @@ uint32_t Diagnostics_Dryer_MovetoEncoderPosition_Callback(uint32_t MotorId, uint { MessageContainer responseContainer; MotorHomingResponse response = MOTOR_HOMING_RESPONSE__INIT; + ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_MovetoEncoderPosition_Callback time",__FILE__,__LINE__,msec_millisecondCounter,RpMessage,0,0); + if (HomingControlId[MotorId] != 0xff) + { + ReportWithPackageFilter(DiagnosticsFilter,"MotorHomingProgressReport stopped",__FILE__,__LINE__,MotorId,RpMessage,HomingCounter[MotorId],0); + RemoveControlCallback(HomingControlId[MotorId],MotorHomingProgressReport); + HomingControlId[MotorId] = 0xff; + } ReportWithPackageFilter(DiagnosticsFilter,"Store angle of arm drier - ended",__FILE__,__LINE__,(int)(Calculate_Arm_Angle(Drier_Center_read,ReadValue)*360),RpMessage,D_numberOfCycles,0); //ReportWithPackageFilter(DiagnosticsFilter,"Diagnostics_Dryer_MovetoEncoderPosition_Callback",__FILE__,__LINE__,0,RpMessage,CallbackCounter,0); @@ -624,6 +631,7 @@ uint32_t Diagnostics_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue ReportWithPackageFilter(DiagnosticsFilter,"Loading drier - halted",__FILE__,__LINE__,D_numberOfCycles,RpMessage,LoadArmRounds,0); ReportWithPackageFilter(DiagnosticsFilter,"Store angle of arm drier - halted",__FILE__,__LINE__,(int)(Calculate_Arm_Angle(Drier_Center_read,ReadValue)*360),RpMessage,D_numberOfCycles,0); MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, 200); + Diagnostics_Dryer_MovetoEncoderPosition_Callback(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,0); } return OK; } @@ -631,7 +639,6 @@ uint32_t Diagnostics_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue uint32_t Diagnostics_Dryer_Loading(void) { //float Calc_angle; -#warning assuming loading starts from 0 if (dryerbufferlength) LoadArmRounds = (int)dryerbufferlength; MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&D_DrierPrevLocation); diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 6f5b5fe23..774fd105b 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -243,7 +243,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->has_startheatingoninitsequence = true; EmbeddedParameters->startheatingoninitsequence = true; //set to true shlomo 14/5/2019 - EmbeddedParameters->n_generalparameters = 8; + EmbeddedParameters->n_generalparameters = 9; EmbeddedParameters->generalparameters = malloc (sizeof(double)*10); if (EmbeddedParameters->generalparameters) { @@ -255,6 +255,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->generalparameters[5] = 1000.0; //Dispenser initial pressure speed EmbeddedParameters->generalparameters[6] = Diagnostic_Extended_Mode; //Diagnostic Mode SetDiagnosticMode EmbeddedParameters->generalparameters[7] = AutoHoming_JobEnd_PowerOn_off; // + EmbeddedParameters->generalparameters[8] = false; // } EmbeddedParameters->has_currentalarmlowlimit = true; @@ -394,6 +395,11 @@ uint32_t EmbeddedParametersInit(void) else if (EmbeddedParameters->generalparameters[7]< 3.5) IDS_Dispenser_SetAutoHoming_Config(AutoHoming_JobEnd_PowerOn_off); else Report("SetAutoHoming_Config error", __FILE__,__LINE__,(int)(EmbeddedParameters->generalparameters[7]*100), RpMessage, 0, 0); } + if (EmbeddedParameters->n_generalparameters >= 9) + { + if (EmbeddedParameters->generalparameters[9]< 0.5) setPowerOffDisableCleaning(false); + else setPowerOffDisableCleaning(true); + } PowerIdleSetParameters(EmbeddedParameters->switchtoidletimeinseconds,EmbeddedParameters->idledriertemperature,EmbeddedParameters->idleheadtemperature,EmbeddedParameters->idlemixertemperature); return Fresult; @@ -837,10 +843,11 @@ void FlashInitAndLoad(void) uint32_t Bytes = 0; ConfigurationParameters *Params = NULL; - ProcessParameters* ProcessParams = NULL; - UploadProcessParametersRequest* request = NULL; + //ProcessParameters* ProcessParams = NULL; + //UploadProcessParametersRequest* request = NULL; + + //char ProcessParamsPath[50] = "0://SysInfo//ProcessP.cfg"; - char ProcessParamsPath[50] = "0://SysInfo//ProcessP.cfg"; #ifdef WATCHDOG ROM_WatchdogResetDisable(WATCHDOG0_BASE); uint32_t timeout = 0xFFFFFFFFU; diff --git a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c index 9297d3bb8..4b3f555f4 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c +++ b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c @@ -20,6 +20,11 @@ #include "PMR/MachineStatus/MachineState.pb-c.h" #include "PMR/MachineStatus/IDSPackLevel.pb-c.h" +#include "PMR/IFS/CartridgeStatus.pb-c.h" +#include "PMR/IFS/InkFillingStatus.pb-c.h" +#include "PMR/IFS/StartInkFillingStatusRequest.pb-c.h" +#include "PMR/IFS/StartInkFillingStatusResponse.pb-c.h" + #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "Drivers/Heater/TemperatureSensor.h" #include "drivers/Motors/Motor.h" @@ -27,8 +32,11 @@ #include "StateMachines/Initialization/InitSequence.h" #include "Modules/General/MachineStatus.h" +#include "Modules/AlarmHandling/AlarmHandling.h" #include "Modules/Control/MillisecTask.h" +#include "modules/waste/waste_ex.h" #include "modules/ids/ids_ex.h" +#include "modules/ifs/ifs.h" MachineState StoredMachineStatus = MACHINE_STATE__PowerUp; bool SetMAchineStateProblem = false; @@ -78,6 +86,7 @@ int MachineUpdateResponseFunc(void) int1valid = false; if((internaltemp2<=MINIMUM_HEATER_READ*100)||(MAXIMUM_HEATER_READ*100<=internaltemp2)) int2valid = false; + MachineStatus.has_overalltemperature = true; if ((int2valid == true)&&(int1valid == true)) { usetemp = (max(internaltemp1,internaltemp2))/100; @@ -89,17 +98,20 @@ int MachineUpdateResponseFunc(void) } else { - AlarmHandlingSetAlarm(EVENT_TYPE__TEMPERATURE_MEASUREMENT_ERROR, true); + //AlarmHandlingSetAlarm(EVENT_TYPE__TEMPERATURE_MEASUREMENT_ERROR, true); temp_measure_alarm = true; if ((int2valid == false)&&(int1valid == true)) usetemp = internaltemp1/100; else if ((int2valid == false)&&(int1valid == false)) + { + MachineStatus.has_overalltemperature = FALSE; usetemp = 0; + } else if ((int1valid == false)&&(int2valid == true)) usetemp = internaltemp2/100; } + MachineStatus.overalltemperature = usetemp; - MachineStatus.has_overalltemperature = true; if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) @@ -135,7 +147,6 @@ int MachineUpdateResponseFunc(void) return ERROR; - responseContainer = /*MachineUpdate*/createContainer(MESSAGE_TYPE__StartMachineStatusUpdateResponse, MachineUpdateToken, false, &response, &start_machine_status_update_response__pack, &start_machine_status_update_response__get_packed_size); responseContainer.has_continuous = true; responseContainer.continuous = true; @@ -204,4 +215,104 @@ uint32_t StopMachineUpdateFunc(MessageContainer* requestContainer) return OK; } +/*struct _Cartridge +{ + ProtobufCMessage base; + protobuf_c_boolean has_slot; + CartridgeSlot slot; + CartridgeTagContent *tag; + protobuf_c_boolean has_index; + int32_t index; +}; + typedef enum _CartridgeSlot { + CARTRIDGE_SLOT__Ink = 0, + CARTRIDGE_SLOT__WasteMiddle = 1, + CARTRIDGE_SLOT__WasteLower = 2 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CARTRIDGE_SLOT) +} CartridgeSlot; + * */ + +char WasteEmptyingToken[36+1] = {0}; +uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State) +{ + if (WasteEmptyingToken[0] == 0) + return ERROR; + uint32_t status = NOT_SUPPORTED,i; + MessageContainer responseContainer; + CartridgeStatus CartridgeStatus = CARTRIDGE_STATUS__INIT; + Cartridge CartData = CARTRIDGE__INIT; + StartInkFillingStatusResponse response = START_INK_FILLING_STATUS_RESPONSE__INIT; + response.status->n_cartridgesstatuses = MAX_CARTRIDGES; + response.status->cartridgesstatuses[0] = &CartridgeStatus; + CartridgeStatus.has_state = true; + CartridgeStatus.state = State; + CartridgeStatus.cartridge = &CartData; + CartData.has_slot = true; + CartData.slot = Slot; + + + + + /* +struct _CartridgeStatus +{ + ProtobufCMessage base; + Cartridge *cartridge; + protobuf_c_boolean has_state; + CartridgeState state; + protobuf_c_boolean has_progresspercentage; + double progresspercentage; + char *message; +}; + size_t n_cartridgesstatuses; + CartridgeStatus **cartridgesstatuses; +typedef enum _CartridgeState { + CARTRIDGE_STATE__None = 0, + CARTRIDGE_STATE__Absent = 1, + CARTRIDGE_STATE__Exists = 2, + CARTRIDGE_STATE__Inserted = 3, + CARTRIDGE_STATE__Filling = 4, + CARTRIDGE_STATE__FillingCompleted = 5, + CARTRIDGE_STATE__Emptying = 6, + CARTRIDGE_STATE__EmptyingCompleted = 7, + CARTRIDGE_STATE__Empty = 8, + CARTRIDGE_STATE__Full = 9, + CARTRIDGE_STATE__Error = 10 + PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(CARTRIDGE_STATE) +} CartridgeState; + */ + + responseContainer = createContainer(MESSAGE_TYPE__StartInkFillingStatusResponse, WasteEmptyingToken, false, &response, &start_ink_filling_status_response__pack, &start_ink_filling_status_response__get_packed_size); + responseContainer.has_continuous = true; + responseContainer.continuous = true; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + //USBCDCD_sendData(container_buffer, container_size,10); + + SendChars((char*)container_buffer, container_size); + //MessageContainer responseContainer; + + return status; +} + +uint32_t StartInkFillingStatusRequestFunc(MessageContainer* requestContainer) +{ + uint32_t status = NOT_SUPPORTED; + //MessageContainer responseContainer; + +// MachineUpdateInitParams InitParams; + + Report("StartInkFillingStatusRequestFunc",__FILE__,__LINE__,(int)0,RpWarning,(int)0,0); + StartInkFillingStatusRequest* request = start_ink_filling_status_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + ustrncpy (WasteEmptyingToken, requestContainer->token,36); + + CartridgeStateUpdate(CARTRIDGE_SLOT__Ink,CARTRIDGE_STATE__None); + CartridgeStateUpdate(CARTRIDGE_SLOT__WasteMiddle,CARTRIDGE_STATE__None); + CartridgeStateUpdate(CARTRIDGE_SLOT__WasteLower,CARTRIDGE_STATE__None); + start_ink_filling_status_request__free_unpacked(request,NULL); + return status; +// case MESSAGE_TYPE__StartWasteEmptyingRequest: + +} diff --git a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h index 489a8f638..b421785cc 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h +++ b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.h @@ -9,11 +9,16 @@ #define MODULES_GENERAL_MACHINESTATUS_H_ #include <PMR/Common/MessageContainer.pb-c.h> #include "PMR/MachineStatus/MachineState.pb-c.h" +#include "PMR/IFS/CartridgeState.pb-c.h" +#include "PMR/Diagnostics/CartridgeSlot.pb-c.h" uint32_t MachineUpdateInitFunc(MessageContainer* requestContainer); uint32_t StopMachineUpdateFunc(MessageContainer* requestContainer); void SetMachineStatus (MachineState State); int MachineUpdateResponseFunc(void); +uint32_t StartInkFillingStatusRequestFunc(MessageContainer* requestContainer); + +uint32_t CartridgeStateUpdate(CartridgeSlot Slot,CartridgeState State); diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index e5595a965..4538d0336 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -42,6 +42,7 @@ double pressurebuildup = 0; double dryerzone1temp = 0; int32_t tableindex = 0; double headBlowersFlow[2] = {1.0,1.0}; +double ArcCleaningMotorSpeed = 0.0; double dryerbufferMeters = 0; double dryerbufferCentimeters = 0; @@ -149,6 +150,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData) dryerbufferCentimeters = dryerbufferlength*76+90; + mininkuptake = ProcessParams->mininkuptake; feedertension = ProcessParams->feedertension; pullertension = ProcessParams->pullertension; @@ -157,6 +159,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData) dryerairflow = ProcessParams->dryerairflow; pressurebuildup = ProcessParams->pressurebuildup; dryerzone1temp = ProcessParams->dryerzone1temp; + ArcCleaningMotorSpeed = ProcessParams->archeadcleaningmotorspeed; if (MachineReadyForHeating == false) { diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.h b/Software/Embedded_SW/Embedded/Modules/General/process.h index f7f16d11e..4a1583aa8 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.h +++ b/Software/Embedded_SW/Embedded/Modules/General/process.h @@ -20,6 +20,7 @@ extern double dryerairflow; extern double pressurebuildup; extern double dryerzone1temp; extern double headBlowersFlow[2]; +extern double ArcCleaningMotorSpeed; extern int32_t tableindex; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h index 6d50eb926..e85694c48 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h @@ -47,6 +47,7 @@ double PressureSensorGetPressure(uint8_t SensorId); int HeadBlowersGetRPM(uint8_t fanId); double PressureSensorInit(); void HeadBlowersInit(); +uint32_t HeadBlowerPidRequestMessage(void* request, int BlowerId); void HeadBlowersCfg(); void HeadBlowersControlLoop (); uint32_t HeadBlowerCommandRequestMessage(int blowerId, float flow); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 2abcc2b31..38379d094 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -55,6 +55,7 @@ #define UNDERHEAT_COUNT_LIMIT 3 #define MIN_ALLOWED_PWM 0 #define MAX_ALLOWED_PWM 255 +#define ARC_ALARM_LIMIT 3 int Overheat_Count_Limit = OVERHEAT_COUNT_LIMIT; int Underheat_Count_Limit = UNDERHEAT_COUNT_LIMIT; @@ -107,6 +108,7 @@ HeaterCommand HeaterCmd[HEATER_TYPE_MAX_HEATERS]; uint32_t ControlIdtoHeaterId [HEATER_TYPE_MAX_HEATERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t ControlIdtoMaxHeaterId [HEATER_TYPE_MAX_HEATERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t OverHeatCounter [HEATER_TYPE_MAX_HEATERS] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +uint32_t BlowerOverHeatCounter[HEATER_TYPE_MAX_HEATERS] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint32_t UnderHeatCounter [HEATER_TYPE_MAX_HEATERS] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; uint32_t MainDryerHeaterMaxTempControl = 0xFF; uint32_t SecondDryerHeaterMaxTempControl = 0xFF; @@ -1110,12 +1112,12 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) } return ERROR; } + uint32_t HeaterBlowerMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) { uint32_t BlowerPt100Read = 0; int index=HEATER_TYPE_MAX_HEATERS; - int32_t MaxreadValue; if (IfIndex>>8 != IfTypeHeaters) { @@ -1143,34 +1145,19 @@ uint32_t HeaterBlowerMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) } } - if ((BlowerPt100Read >= HeaterControl[index].sensormaxvalue) || (BlowerPt100Read > 25500)) + if (BlowerPt100Read > 25500) { - if(OverHeatCounter[index]++ >= Overheat_Count_Limit) + if(BlowerOverHeatCounter[index]++ >= Overheat_Count_Limit) { - OverHeatCounter[index] = Overheat_Count_Limit; - //?????HeaterReady[index] = false; - if (JobIsActive()&&(HeaterReady[index]==true)) + BlowerOverHeatCounter[index] = Overheat_Count_Limit; + + if ((HeaterReady[index]==false)&&(HeaterPreviousRead[index]>HeaterCmd[index].targettemperatue)) { - JobEndReason = JOB_TEMPERATURE_ALARM; - SendJobProgress(0.0,0,false, "Temperature Error"); - AbortJob("Over Temperature Error"); - //SegmentReady(Module_Heaters,ModuleFail); - ReportWithPackageFilter(HeatersFilter, "Temperature Error",__FILE__,__LINE__,index,RpError, 0,0); - return OK; + ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, cooling off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterCmd[index].targettemperatue,0); } - //if (getIdleState() == false) - //not idle, not cooling to temp + else { - if ((HeaterReady[index]==false)&&(HeaterPreviousRead[index]>HeaterCmd[index].targettemperatue)) - { - ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, cooling off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterCmd[index].targettemperatue,0); - } - else - { - ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, turned off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterReady[index],0); - ReportWithPackageFilter(HeatersFilter,"Heater over the max temperature",__FILE__,index,OverHeatCounter[index],RpWarning,HeaterControl[index].sensormaxvalue, 0); - AlarmHandlingSetAlarm(HeaterEventType[index], true); - } + ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, turned off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterReady[index],0); } } if (index == HEATER_TYPE__HeadCoverHeater1) @@ -1184,34 +1171,110 @@ uint32_t HeaterBlowerMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) HeaterRecalculateHeaterParams(HEATER_TYPE__HeadCoverHeater2,0); } HeaterMaxTempFlag[index] = true; - //ReportWithPackageFilter(HeatersFilter,(MinreadValue/100), "Heater Over the max temperature, turned off"); - return OK; - } - if (BlowerPt100Read <= (HeaterControl[index].sensormaxvalue-HeaterControl[index].sensorminvalue)) //was MinreadValue - { - if (HeaterControl[index].sensorminvalue > 0) + } else { + if (BlowerOverHeatCounter[index]) { - if (HeaterMaxTempFlag[index] == true) + if (BlowerPt100Read <= 25300) { - /* ActivateHeater(HEATER_TYPE__DryerMainHeater); - if (HeaterReady[HEATER_TYPE__DryerAirHeater]==false) + BlowerOverHeatCounter[index]--; + if (BlowerOverHeatCounter[index]==0) { - ActivateHeater(HEATER_TYPE__DryerSecondaryHeater); - }*/ - //ReportWithPackageFilter(HeatersFilter, "Heater Cooled Off max temperature, turned on",__FILE__,__LINE__,(MinreadValue/100),RpError, 0,0); + HeaterMaxTempFlag[index] = false; + } } - HeaterMaxTempFlag[index] = false; } - return OK; } + // alarm handling + if ((HeaterPreviousRead[index] >= HeaterControl[index].sensormaxvalue) && (HeaterCmd[index].targettemperatue)) + { + if(OverHeatCounter[index]++ >=Overheat_Count_Limit) + { + OverHeatCounter[index] = Overheat_Count_Limit; + if (JobIsActive()&&(HeaterReady[index]==true)) + { + JobEndReason = JOB_TEMPERATURE_ALARM; + SendJobProgress(0.0,0,false, "Temperature Error"); + AbortJob("Over Temperature Error"); + ReportWithPackageFilter(HeatersFilter, "Temperature Error",__FILE__,__LINE__,index,RpError, 0,0); + return OK; + } - return ERROR; + if ((HeaterReady[index]==false)&&(HeaterPreviousRead[index]>HeaterCmd[index].targettemperatue)) + { + ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, cooling off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterCmd[index].targettemperatue,0); + } + else + { + ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, turned off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterReady[index],0); + ReportWithPackageFilter(HeatersFilter,"Heater over the max temperature",__FILE__,index,OverHeatCounter[index],RpWarning,HeaterControl[index].sensormaxvalue, 0); + AlarmHandlingSetAlarm(HeaterEventType[index], true); + } + } + } + else if ((HeaterPreviousRead[index] < HeaterControl[index].sensormaxvalue) && (!HeaterCmd[index].targettemperatue)) + { + if(OverHeatCounter[index]++ >=Overheat_Count_Limit) + { + OverHeatCounter[index] = Overheat_Count_Limit; + AlarmHandlingSetAlarm(HeaterEventType[index], false); + } + } + else if ((HeaterPreviousRead[index]) < (HeaterControl[index].sensorminvalue)) + { + if (HeaterReady[index]==true) + { + ReportWithPackageFilter(HeatersFilter,"Heater under the min temperature",__FILE__,index,UnderHeatCounter[index],RpWarning,HeaterControl[index].sensorminvalue, 0); + ReportWithPackageFilter(HeatersFilter,"Heater under the min temperature more info",__FILE__,HeaterReady[index],GetHeaterState(index),RpWarning,HeaterPreviousRead[index], 0); + } + if(UnderHeatCounter[index]++ >= Underheat_Count_Limit) + { + UnderHeatCounter[index] = Underheat_Count_Limit; + if (JobIsActive()&&(HeaterReady[index]==true)) + { + JobEndReason = JOB_TEMPERATURE_ALARM; + SendJobProgress(0.0,0,false, "Temperature Error"); + AbortJob("Under Temperature Error"); + ReportWithPackageFilter(HeatersFilter, "Temperature Error",__FILE__,__LINE__,index,RpError, 0,0); + return OK; + } + if (HeaterReady[index]==false) + AlarmHandlingSetAlarm(HeaterUnderEventType[index], true); + else + AlarmHandlingSetAlarm(HeaterUnderEventType_B[index], true); + } + } + else //temperature within limits + { + if(UnderHeatCounter[index] ) + { + UnderHeatCounter[index]--; + if (UnderHeatCounter[index]==0) + { + if (HeaterReady[index]==false) + AlarmHandlingSetAlarm(HeaterUnderEventType[index], false); + else + AlarmHandlingSetAlarm(HeaterUnderEventType_B[index], false); + } + } + if(OverHeatCounter[index] ) + { + if ((HeaterPreviousRead[index]) <= (HeaterControl[index].sensormaxvalue-2)) + { + OverHeatCounter[index]--; + if (OverHeatCounter[index]==0) + { + AlarmHandlingSetAlarm(HeaterEventType[index], false); + } + } + } + } + return OK; } + uint32_t DcHeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) { int index=HEATER_TYPE_MAX_HEATERS; - if (IfIndex>>8 != IfTypeHeaters) { ReportWithPackageFilter(HeatersFilter, "Wrong Interface type",__FILE__,__LINE__,IfIndex,RpError, 0,0); @@ -1221,7 +1284,53 @@ uint32_t DcHeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) //int32_t readValue = MillisecGetTemperatures(HeaterId2PT100Id[index]); if (HeaterControl[index].sensormaxvalue == 0) return OK; - if ((HeaterPreviousRead[index]) < (HeaterControl[index].sensorminvalue)) + if ((HeaterPreviousRead[index]) >= HeaterControl[index].sensormaxvalue) + { + if(OverHeatCounter[index]++ >=Overheat_Count_Limit) + { + OverHeatCounter[index] = Overheat_Count_Limit; + //?????HeaterReady[index] = false; + if (JobIsActive()&&(HeaterReady[index]==true)) + { + JobEndReason = JOB_TEMPERATURE_ALARM; + SendJobProgress(0.0,0,false, "Temperature Error"); + AbortJob("Over Temperature Error"); + //SegmentReady(Module_Heaters,ModuleFail); + ReportWithPackageFilter(HeatersFilter, "Temperature Error",__FILE__,__LINE__,index,RpError, 0,0); + return OK; + } + //if (getIdleState() == false) + //not idle, not cooling to temp + { + if ((HeaterReady[index]==false)&&(HeaterPreviousRead[index]>HeaterCmd[index].targettemperatue)) + { + ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, cooling off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterCmd[index].targettemperatue,0); + } + else + { + ReportWithPackageFilter(HeatersFilter,"DC Heater Over the max temperature, turned off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterReady[index],0); + ReportWithPackageFilter(HeatersFilter,"Heater over the max temperature",__FILE__,index,OverHeatCounter[index],RpWarning,HeaterControl[index].sensormaxvalue, 0); + AlarmHandlingSetAlarm(HeaterEventType[index], true); + } + } + } + if (index == HEATER_TYPE__DryerAirHeater) + { + DeActivateHeater(HEATER_TYPE__DryerMainHeater); + HeaterRecalculateSharedHeatersParams(HEATER_TYPE__DryerMainHeater,0); + DeActivateHeater(HEATER_TYPE__DryerSecondaryHeater); + HeaterRecalculateSharedHeatersParams(HEATER_TYPE__DryerSecondaryHeater,0); + } + else + { + DeActivateHeater(index); + HeaterRecalculateHeaterParams(index, 0); + } + HeaterMaxTempFlag[index] = true; + //ReportWithPackageFilter(HeatersFilter,(MinreadValue/100), "Heater Over the max temperature, turned off"); + return OK; + } + else if ((HeaterPreviousRead[index]) < (HeaterControl[index].sensorminvalue)) { if (HeaterReady[index]==true) { @@ -1276,7 +1385,7 @@ uint32_t DcHeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) } return ERROR; } -bool IncreaseBlower = false; + uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) { int index=HEATER_TYPE_MAX_HEATERS; @@ -1437,30 +1546,17 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) ReportWithPackageFilter(HeatersFilter,"AC Ready",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); HeaterAtTemp[index] = true; HeaterPrepareReady(); - IncreaseBlower = false; } } - if ( (readValue > (HeaterCmd[index].targettemperatue * ((100-HeaterControl[index].outputproportionalband+2)/100))) - && (readValue < (HeaterCmd[index].targettemperatue * ((100+HeaterControl[index].outputproportionalband)/100)))) + else { - if (IncreaseBlower == false) - { - IncreaseBlower = true; - if (BlowerCfg.enabled == true) + if ((readValue < (HeaterCmd[index].targettemperatue * AcHeatersLoweroperationLimit/1000))||(readValue > (HeaterCmd[index].targettemperatue * AcHeatersUpperoperationLimit/1000)))//read value within 0.5 percent from target { - if(Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD) - { - WHS_Set_SetPoint_Q_value(headairflow); - } - else - { - Turn_the_Blower_On();//Turn on with the Default_Voltage - if (BlowerCfg.voltage) - Control_Voltage_To_Blower(BlowerCfg.voltage); - } + //InitialHeating = false; + ReportWithPackageFilter(HeatersFilter,"AC NOT Ready",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); + HeaterAtTemp[index] = false; + HeaterPrepareReady(); } - - } } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { @@ -1606,7 +1702,8 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) } if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) { - ActivateHeater(index); + if (HeaterMaxTempFlag[index] == false) + ActivateHeater(index); //HeaterRecalculateHeaterParams(index, 100); //Heaters OFF until coming into the proportional band //ReportWithPackageFilter(HeatersFilter,"DC HEATER Under temperature ", __FILE__,__LINE__,index, RpMessage, readValue, 0); @@ -1643,6 +1740,15 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) HeaterPrepareReady(); } } + else + { + if ((readValue < (HeaterCmd[index].targettemperatue * DcHeatersLoweroperationLimit/1000))||(readValue > (HeaterCmd[index].targettemperatue * DcHeatersUpperoperationLimit/1000)))//read value within 0.5 percent from target + { + ReportWithPackageFilter(HeatersFilter,"DC NOT Ready",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); + HeaterAtTemp[index] = false; + HeaterPrepareReady(); + } + } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { @@ -2095,10 +2201,12 @@ uint32_t HeadBlowerPidFunc(double setParam,double measuredParam, int blowerId) HeadBlowersCloseLoopTime[blowerId] = HeadBlowerControl[blowerId].m_params.dt; if (calculatedPwm < MIN_ALLOWED_PWM) { + //ReportWithPackageFilter(HeatersFilter,"calculatedPwm < MIN_ALLOWED_PWM",__FILE__,__LINE__,calculatedPwm,RpError, MIN_ALLOWED_PWM,0); HeadBlowerControl[blowerId].m_integral = 0; calculatedPwm = MIN_ALLOWED_PWM; } if (calculatedPwm > MAX_ALLOWED_PWM) { + //ReportWithPackageFilter(HeatersFilter,"calculatedPwm > MAX_ALLOWED_PWM",__FILE__,__LINE__,calculatedPwm,RpError, MAX_ALLOWED_PWM,0); HeadBlowerControl[blowerId].m_integral = 0; calculatedPwm = MAX_ALLOWED_PWM; } @@ -2136,63 +2244,105 @@ uint32_t HeadBlowersOffGet() void ArcHeadAlarms(void) { double currentFlow = 0.0; + static int8_t count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0; + static int8_t count6 = 0, count7 = 0, count8 = 0, count9 = 0, count10 = 0; if (FPGA_Read_limit_Switches(I2C_HEADCARD_COVER_LS_ARC) != LIMIT) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_ARC_LID_IS_OPEN, true); + if (++count9 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_ARC_LID_IS_OPEN, true); + count9 = (count9 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count9); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_ARC_LID_IS_OPEN, false); + if (--count9 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_ARC_LID_IS_OPEN, false); + count9 = (count9 < 0)?(0):(count9); } if (FPGA_Read_limit_Switches(I2C_HEADCARD_COVER_LS_TUNNEL_ARC) != LIMIT) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_TUNNEL_LID_IS_OPEN, true); + if (++count10 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_TUNNEL_LID_IS_OPEN, true); + count10 = (count10 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count10); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_TUNNEL_LID_IS_OPEN, false); + if (--count10 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_TUNNEL_LID_IS_OPEN, false); + count10 = (count10 < 0)?(0):(count10); } if (Head_Fan_Tach[0] == 0x1FFE) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_STOPPED, true); + if (++count1 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_STOPPED, true); + count1 = (count1 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count1); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_STOPPED, false); + if (--count1 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_STOPPED, false); + count1 = (count1 < 0)?(0):(count1); } if (Head_Fan_Tach[1] == 0x1FFE) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_STOPPED, true); + if (++count2 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_STOPPED, true); + count2 = (count2 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count2); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_STOPPED, false); + if (--count2 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_STOPPED, false); + count2 = (count2 < 0)?(0):(count2); } if (HeadBlowersGetRPM(0) < 2000) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_RPM_TOO_LOW, true); + if (++count3 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_RPM_TOO_LOW, true); + count3 = (count3 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count3); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_RPM_TOO_LOW, false); + if (--count3 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FAN_RPM_TOO_LOW, false); + count3 = (count3 < 0)?(0):(count3); } if (HeadBlowersGetRPM(1) < 2000) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_RPM_TOO_LOW, true); + if (++count4 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_RPM_TOO_LOW, true); + count4 = (count4 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count4); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_RPM_TOO_LOW, false); + if (--count4 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FAN_RPM_TOO_LOW, false); + count4 = (count4 < 0)?(0):(count4); } currentFlow = PressureSensorGetPressure(HEAD_PT100_ZONE_5_0X84_0); if (currentFlow > 5.0) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_HIGH, true); + if (++count5 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_HIGH, true); + count5 = (count5 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count5); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_HIGH, false); + if (--count5 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_HIGH, false); + count5 = (count5 < 0)?(0):(count5); } if (currentFlow < 1.0) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_LOW, true); + if (++count6 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_LOW, true); + count6 = (count6 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count6); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_LOW, false); + if (--count6 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_1_FLOW_TOO_LOW, false); + count6 = (count6 < 0)?(0):(count6); } currentFlow = PressureSensorGetPressure(HEAD_PT100_ZONE_7_0X86_0); if (currentFlow > 5.0) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_HIGH, true); + if (++count7 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_HIGH, true); + count7 = (count7 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count7); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_HIGH, false); + if (--count7 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_HIGH, false); + count7 = (count7 < 0)?(0):(count7); } if (currentFlow < 1.0) { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_LOW, true); + if (++count8 == ARC_ALARM_LIMIT) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_LOW, true); + count8 = (count8 > ARC_ALARM_LIMIT)?(ARC_ALARM_LIMIT):(count8); } else { - AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_LOW, false); + if (--count8 == 0) + AlarmHandlingSetAlarm(EVENT_TYPE__DYEING_HEAD_BLOWER_2_FLOW_TOO_LOW, false); + count8 = (count8 < 0)?(0):(count8); } } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c index c06e79311..2e3d61f0c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c @@ -8,6 +8,7 @@ #include "ids.h" #include "ids_ex.h" #include "../control/control.h" +#include "modules/General/process.h" #include "../control/pidalgo.h" #include "../thread/thread.h" #include "PMR/Hardware/Hardwaremotor.pb-c.h" @@ -96,8 +97,11 @@ uint32_t IDS_Cleaning_Move_Actuators() } } else { //arc if (CleaningStageCounter == 0) { - MotorSetSpeed(MotorId, 750); - ReportWithPackageFilter(IDSFilter,"IDS_Cleaning_Motor_Run", __FILE__, __LINE__, 1, RpWarning, CleaningStageCounter, 0); + if (ArcCleaningMotorSpeed>1) + MotorSetSpeed(MotorId, ArcCleaningMotorSpeed); + else + MotorSetSpeed(MotorId, 750); + ReportWithPackageFilter(IDSFilter,"IDS_Cleaning_Motor_Run", __FILE__, __LINE__, 750, RpWarning, (int)ArcCleaningMotorSpeed, 0); } } CleaningStageCounter++; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index c55f10277..991f4ecc0 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -217,6 +217,10 @@ uint32_t IDS_HomeDispenserCallback(uint32_t motorId, uint32_t ReadValue) HomingActive[DispenserId]= false; PrimingActive[DispenserId]= false; Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE +#ifdef DISPENSER_VALVES_OPEN + if (JobIsActive()==false) + Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer +#endif //close dry air valve in the dispenser Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); @@ -336,6 +340,10 @@ uint32_t IDS_StopHomeDispenser (uint32_t DispenserId) HomingActive[DispenserId] = false; PrimingActive[DispenserId] = false; Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE +#ifdef DISPENSER_VALVES_OPEN + if (JobIsActive()==false) + Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer +#endif if (Extended_Motor_Param[MotorId] == true) Power_Step_01_Dispenser_Mode(DispenserId,Voltage); //MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]); @@ -564,7 +572,11 @@ void IDS_Dispenser_Init(uint8_t DispenserId) HomingActive[DispenserId]= false; PrimingActive[DispenserId]= false; Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); +#ifdef DISPENSER_VALVES_OPEN + Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer +#else Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer +#endif //if (Special_Dispensers == true) { if (ControlIdtoInactiveDispenserId[DispenserId] == 0xFF) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 0d81e5447..2ad8db9d6 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -142,7 +142,7 @@ void IDS_Dispenser_SetPreSegmentWFCFValues(double dispenserpresegmentwfcf, doubl uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request) { - int Dispenser_i,i; + /*int Dispenser_i,i; //int temp; for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) { @@ -177,7 +177,7 @@ uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request) DispenserControlConfig[Dispenser_i].m_preError = 0; DispenserControlConfig[Dispenser_i].m_SetParam = DispensersCtrl[Dispenser_i].outputproportionalcycletime;//need to update SetParams on presegment stage - + */ return OK; } uint32_t DispenserPidControlId[MAX_SYSTEM_DISPENSERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; @@ -558,7 +558,6 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl int i; int NumofReadyDispensers = 0; TimerMotors_t HW_Motor_Id; - float updatedSpeed,tempSpeed; JobDispenser **Dispensers; //set the speed only before the first segment, speed is constant accros job int Dispenser_i,n_dispensers; @@ -790,29 +789,29 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl for (Motor_i = 0;Motor_i < MAX_SYSTEM_DISPENSERS;Motor_i++) { TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[Motor_i]; - Pid_Id = Motor_i;/*IDSMotorIdToControlId[Motor_i];*/ - DispenserControlConfig[Motor_i].m_params.MAX = 1; - DispenserControlConfig[Motor_i].m_params.MIN = DispensersControl[Pid_Id].outputproportionalpowerlimit*-1; - DispenserControlConfig[Motor_i].m_params.Kd = DispensersControl[Pid_Id].derivativetime; - DispenserControlConfig[Motor_i].m_params.Kp = DispensersControl[Pid_Id].proportionalgain; - DispenserControlConfig[Motor_i].m_params.Ki = DispensersControl[Pid_Id].integraltime; - DispenserControlConfig[Motor_i].m_params.epsilon = 0.01; - DispenserControlConfig[Motor_i].m_params.dt = eHundredMillisecond; - DispenserControlConfig[Motor_i].m_calculatedError = 0; - DispenserControlConfig[Motor_i].m_integral = 0; - DispenserControlConfig[Motor_i].m_isEnabled = true; - DispenserControlConfig[Motor_i].m_isReady = true; - DispenserControlConfig[Motor_i].m_mesuredParam = 0; - DispenserControlConfig[Motor_i].m_preError = 0; - DispenserControlConfig[Motor_i].m_SetParam = 0;//need to update SetParams on presegment stage - - MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); //set the dispenser to the - /*Start the dispensers to build initial pressure - * check different handling for dispensers that participate in the first segment and idle dispensers - * start control for initial pressure - * - */ - //ValveCommand (Enable,MixerDirection); + /*Pid_Id = Motor_i;//IDSMotorIdToControlId[Motor_i]; + DispenserControlConfig[Motor_i].m_params.MAX = 1; + DispenserControlConfig[Motor_i].m_params.MIN = DispensersControl[Pid_Id].outputproportionalpowerlimit*-1; + DispenserControlConfig[Motor_i].m_params.Kd = DispensersControl[Pid_Id].derivativetime; + DispenserControlConfig[Motor_i].m_params.Kp = DispensersControl[Pid_Id].proportionalgain; + DispenserControlConfig[Motor_i].m_params.Ki = DispensersControl[Pid_Id].integraltime; + DispenserControlConfig[Motor_i].m_params.epsilon = 0.01; + DispenserControlConfig[Motor_i].m_params.dt = eHundredMillisecond; + DispenserControlConfig[Motor_i].m_calculatedError = 0; + DispenserControlConfig[Motor_i].m_integral = 0; + DispenserControlConfig[Motor_i].m_isEnabled = true; + DispenserControlConfig[Motor_i].m_isReady = true; + DispenserControlConfig[Motor_i].m_mesuredParam = 0; + DispenserControlConfig[Motor_i].m_preError = 0; + DispenserControlConfig[Motor_i].m_SetParam = 0;//need to update SetParams on presegment stage + */ + MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); //set the dispenser to the + /*Start the dispensers to build initial pressure + * check different handling for dispensers that participate in the first segment and idle dispensers + * start control for initial pressure + * + */ + //ValveCommand (Enable,MixerDirection); } if (HeaterCheckReady() == true) @@ -866,6 +865,13 @@ bool AdjustDispenserSpeedToPressure(int DispenserId, double RefMaxPressure,doubl ReportWithPackageFilter(IDSFilter,"Inactive dispenser already homing",__FILE__,i,HomingActive[i],RpWarning,PrimingActive[i],0); } } +#ifdef DISPENSER_VALVES_OPEN + else // turn inactive dispenser valve toward the midtank during job + { + if (HomingActive[i] == false) + Control3WayValvesWithCallback ((Valves_t)i, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer + } +#endif } } if (NumOfActiveDispensers) @@ -1230,7 +1236,7 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); } if (segmentfirst_speed > MINIMAL_MOTOR_SPEED) { - char IdMessage[100]; + //char IdMessage[100]; segmentfirst_speed *= (100+WFCF); segmentfirst_speed /= 100; DispenserSegmentReady[DispenserId] = false; @@ -1872,7 +1878,11 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) { MotorStop(DispenserIdToMotorId[Dispenser_i],Hard_Hiz); } - Control3WayValvesWithCallback (Dispenser_i, MidTank_Dispenser, IDS_Valve_EndValveReady); //direction: MidTank_Dispenser or Dispenser_Mixer +#ifdef DISPENSER_VALVES_OPEN + Control3WayValvesWithCallback (Dispenser_i, Dispenser_Mixer, IDS_Valve_EndValveReady); //direction: MidTank_Dispenser or Dispenser_Mixer +#else + Control3WayValvesWithCallback (Dispenser_i, MidTank_Dispenser, IDS_Valve_EndValveReady); //direction: MidTank_Dispenser or Dispenser_Mixer +#endif CurrentDispenserSpeed[Dispenser_i] = 0; //IDS_Dispenser_Close_Valve_And_Stop_Motor(Dispenser_i,IDS_Valve_EndValveReady); @@ -1881,6 +1891,9 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) { // RemoveControlCallback(ControlIdtoInactiveDispenserId[Dispenser_i], IDS_Check_Pressure_Callback ); // ControlIdtoInactiveDispenserId[Dispenser_i] = 0xFF; +#ifdef DISPENSER_VALVES_OPEN + Control3WayValvesWithCallback (Dispenser_i, Dispenser_Mixer, IDS_Valve_EndValveReady); //direction: MidTank_Dispenser or Dispenser_Mixer +#endif IDS_Valve_EndValveReady(Dispenser_i,false); } diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index 747df1a61..d62ad3a43 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -11,10 +11,13 @@ #include <DataDef.h> #include "PMR/Diagnostics/CartridgeSlot.pb-c.h" #include "PMR/Diagnostics/CartridgeTagContent.pb-c.h" +#include <PMR/Diagnostics/EventType.pb-c.h> +#include "PMR/IFS/CartridgeState.pb-c.h" #include <Drivers/I2C_Communication/RFID_NFC/RFIDTagInfo.h> #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"//#include "FPGA_GPIO.h" // use for FPGA IO #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "StateMachines/Initialization/PowerOffSequence.h" +#include <Utilities/RfidTagHandling.h> #include "include.h" #include "Modules/IDS/ids_ex.h" @@ -22,7 +25,6 @@ #include "Modules/AlarmHandling/AlarmHandling.h" #include "CartridgeValidationRequest.pb-c.h" #include "CartridgeValidationResponse.pb-c.h" -#include <PMR/Diagnostics/EventType.pb-c.h> #include "drivers/Valves/Valve.h" #include "../control/control.h" #include "Modules/General/buttons.h" @@ -145,6 +147,7 @@ bool CartridgeInkFull() //currently sensor work properly only until 1.6 - 1.8 Liter (TBD) Report("DetectIfCartridgeFinished", __FILE__,__LINE__,int_MidTank_Pressure_1000, RpMessage, int_MidTank_Pressure_1000, 0); //return true; + //IFS_State = CARTRIDGE_STATE__FillingCompleted; } } return false; @@ -229,7 +232,6 @@ bool CartridgeValidationResponseFunc(MessageContainer* requestContainer) } return OK; } - void ResponseDemo(int MidtankId) { inkAuthenticationPass = true; @@ -274,6 +276,7 @@ void midTankStateMachine(void) break; } //check RFID? (TBD) + //IFS_State = CARTRIDGE_STATE__Inserted; // send request for validation to ppc inkAuthenticationPass = 2; //not defined @@ -295,11 +298,13 @@ void midTankStateMachine(void) Report("MidTank Cartridge authentication wait...", __FILE__, __LINE__, authenticationTimeOutCounter, RpMessage, 0, 0); if (authenticationTimeOutCounter > 60) { midTankState = MidTankStateIdle; + //IFS_State = CARTRIDGE_STATE__Error; } break; } if (inkAuthenticationPass == false) { Report("MidTank Cartridge authentication fail", __FILE__, __LINE__, 0, RpMessage, 0, 0); + //IFS_State = CARTRIDGE_STATE__Error; midTankState = MidTankStateIdle; break; } @@ -311,11 +316,13 @@ void midTankStateMachine(void) cart1.color = fastBILNK; Report("Mid-tank not empty", __FILE__, __LINE__, midTankCapacity, RpMessage, MidTankEmptyLimit, 0); midTankState = MidTankStateIdle; + //IFS_State = CARTRIDGE_STATE__Exists; break; } Report("Mid-tank filling in process", __FILE__,__LINE__,(int)(MidTankEmptyLimit*1000), RpMessage, (int)(midTankCapacity*1000), 0); Pannel_Leds(CART_1, MODE_ON); cart1.color = BLINK; + //IFS_State = CARTRIDGE_STATE__Filling; if (midTankCartColor == MIDTANK_8) { @@ -340,6 +347,7 @@ void midTankStateMachine(void) Report("Cartridge extracted during filling!!!", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); Report("Mid-tank # filling fail", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); midTankState = MidTankStateIdle; + //IFS_State = CARTRIDGE_STATE__Absent; } // if time out or emptying done - idle if (midTankTimeoutCounter++ > CartridgeInkTimeout) { @@ -349,6 +357,7 @@ void midTankStateMachine(void) MidTankValvesAction(Cartridge_MidTank_OFF); Report("Mid-tank # filling fail", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); Report("Call customer support", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); + //IFS_State = CARTRIDGE_STATE__Error; midTankState = MidTankStateIdle; } else if (CartridgeInkFull()) { midTankTimeoutCounter = 0; @@ -357,6 +366,7 @@ void midTankStateMachine(void) MidTankValvesAction(Cartridge_MidTank_OFF); Report("Mid-tank # filling done", __FILE__, __LINE__, midTankState, RpMessage, 0, 0); midTankState = MidTankStateIdle; + //IFS_State = CARTRIDGE_STATE__FillingCompleted; } break; default: diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index e4a573e7b..ed5f5e560 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -1041,7 +1041,6 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,request->delay); response.has_progress = true; } - else if(request->amount == 0xB3) //fast refresh for pressure { @@ -1207,6 +1206,14 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.has_progress = true; } else + if(request->amount == 0xB20) //Set loading arm cycles + { + LOG_ERROR(request->delay,"Set winding calibration data"); + + response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_WINDER_CALIBRATION,request->delay); + response.has_progress = true; + } + else if(request->amount == 0xC3) //suspend I2C task { if (request->delay == 0) @@ -1234,6 +1241,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = request->delay; response.has_progress = true; } +#ifdef 0 else if(request->amount == 0xC12) { @@ -1261,6 +1269,7 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = request->delay; response.has_progress = true; } +#endif else if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 6edc5b3f2..d0d2c1ef7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -16,7 +16,7 @@ #include "Modules/Control/control.h" #include "Modules/General/process.h" #include "Modules/control/pidalgo.h" - +#include "Modules/AlarmHandling/AlarmHandling.h" #include "Modules/heaters/heaters_ex.h" #include "Modules/General/buttons.h" #include "StateMachines/Initialization/InitSequence.h" diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index f4d34284d..0440d2241 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -17,7 +17,7 @@ #include "Common/report/report.h" #include "drivers/FPGA/FPGA.h" - +#include "drivers/Flash_ram/MCU_E2Prom.h" #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" @@ -102,18 +102,25 @@ char ScrewStr[150]; uint32_t InternalWindingConfigMessage(JobSpool* request) { uint32_t status = PASSED; + int limitswitchstartpointoffset = 0; InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses; InternalWinderCfg.spoolbackingrate = request->backingrate; InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; if (request->has_limitswitchstartpointoffset) { - InternalWinderCfg.startoffsetpulses += request->limitswitchstartpointoffset; + //InternalWinderCfg.startoffsetpulses += request->limitswitchstartpointoffset; Report("limit switch start point offset",__FILE__,__LINE__,(int)(request->startoffsetpulses),RpWarning,(int)(request->limitswitchstartpointoffset), 0); } + status |= MCU_E2PromRead(EEPROM_STORAGE_WINDER_CALIBRATION,&limitswitchstartpointoffset); + if ((status!= OK )||(limitswitchstartpointoffset == 0xFFFF)) + limitswitchstartpointoffset = 0; + Report("limit switch start point offset",__FILE__,(int)(request->startoffsetpulses),(int)(limitswitchstartpointoffset),RpWarning,status, 0); + InternalWinderCfg.startoffsetpulses += limitswitchstartpointoffset; + InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*3;//request->rotationsperpassage; - if (request->rotationsperpassage > 6.1) + if (request->rotationsperpassage > 5.1) InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; if (NumberOfRotationPerPassage > 1) { @@ -241,6 +248,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) LOG_ERROR(deviceID,"Screw failed to reach the limit switch!!"); //returned with a timeout Winder_ScrewAtOffsetCallback(0,0); + PrepareReady(Module_Winder, ModuleFail); } else //short jog, etc { @@ -356,7 +364,9 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { //uint32_t Steps; double temp,tempScrewSpeed; - int i,tempmot; +#ifdef FOUR_WINDERS + int tempmot; +#endif //double screw_horizontal_speed = 0; //double RotationsPerSecond; if (WinderMotorSpeedCounter++>=MAX_WINDER_SPEED_CALCULATION) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index e7336cc9d..25f322b2e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -337,7 +337,7 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) }**/ //} -#ifdef FOUR_WINDERS +#ifdef BTSR_NO_TFU if (CurrentControlledSpeed[WINDER_MOTOR]>100) length = dyeingspeed/10; #endif @@ -560,7 +560,6 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) //extern int MotorSamplePointer[MAX_THREAD_MOTORS_NUM]; //read value is the dancer angle int i,index=MAX_THREAD_MOTORS_NUM; - int len; int DancerId; int32_t TranslatedReadValue, avreageSampleValue = 0;//,avreageMotorSampleValue = 0; //double tempcalcspeed = 0; @@ -747,7 +746,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) if (index >= WINDER_MOTOR) { // FirstCalcInJob = false; - len = usnprintf(ATMessage[index], 150, "index %d read %d avg %d error(6) %d integral(9) %d,delta(9) %d, calc(3) %d speed %d %d",index-WINDER_MOTOR+1, + usnprintf(ATMessage[index], 150, "index %d read %d avg %d error(6) %d integral(9) %d,delta(9) %d, calc(3) %d speed %d %d",index-WINDER_MOTOR+1, TranslatedReadValue,avreageSampleValue,(int)(MotorControlConfig[index].m_mesuredParam*1000000), (int)(MotorControlConfig[index].m_integral*1000000000),(int)((MotorControlConfig[index].m_mesuredParam*MotorControlConfig[index].m_params.dt)*1000000000), (int)(MotorControlConfig[index].m_calculatedError*1000),(int)calculated_speed, (int)(InitialDryerSpeed*100/OriginalMotorSpd_2PPS[DRYER_MOTOR])); @@ -784,7 +783,6 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) ReportWithPackageFilter(ThreadFilter,"MotorSpeedUpdated",__FILE__,index,(int)OriginalMotorSpd_2PPS[index],RpWarning,(int)CurrentControlledSpeed[index],0); }*/ #ifdef TEST_PID_THREAD - int len; if ((JobCounter % 2000) == index*100) //if (keepdata == true) { @@ -796,7 +794,7 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormError[controlIndex] = MotorControlConfig[index].m_mesuredParam; mIntegral[controlIndex] = MotorControlConfig[index].m_integral; timestamp[controlIndex] = msec_millisecondCounter;*/ - len = usnprintf(TMessage, 150, "read %d avg %d error(6) %d integral(9) %d,delta(9) %d, calc(3) %d speed %d", + usnprintf(TMessage, 150, "read %d avg %d error(6) %d integral(9) %d,delta(9) %d, calc(3) %d speed %d", ReadValue,avreageSampleValue,(int)(MotorControlConfig[index].m_mesuredParam*1000000), (int)(MotorControlConfig[index].m_integral*1000000000),(int)((MotorControlConfig[index].m_mesuredParam*MotorControlConfig[index].m_params.dt)*1000000000), (int)(MotorControlConfig[index].m_calculatedError*1000),(int)calculated_speed); @@ -916,7 +914,7 @@ uint32_t Release_Right_TFU_TensionCallback(uint32_t deviceID, uint32_t BusyFlag) uint32_t Release_Right_TFU_Tension() { uint32_t status = OK; -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU if (RTFU_Up == true) { Report("Release_Right_TFU_Tension",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_RDANCER,RpMessage,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].pulseperround/4,0); @@ -930,7 +928,7 @@ int SecondFeederCorrection = 4; int PrepareWaitCount = 0; uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadValue) { -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU MotorStop (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,Soft_Stop); //per L6470 errata between mov and run commands Report("Adjust_Right_TFU_Tension_2ndCallback x more steps",__FILE__,__LINE__,MotorId,RpMessage,SecondFeederCorrection,0); if (JobIsActive()==false) @@ -954,7 +952,7 @@ uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadVa } uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue) { -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU Report("Adjust_Right_TFU_Tension_Callback",__FILE__,__LINE__,MotorId,RpMessage,0,0); MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize,SecondFeederCorrection* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].microstep, Adjust_Right_TFU_Tension_2nd_Callback,1000); RTFU_Up = true; @@ -965,7 +963,7 @@ uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue) uint32_t Adjust_Right_TFU_Tension(double tension) { uint32_t status = OK; -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU if (tension > 0.5) //0 = lower position, 1 = high position { if (FPGA_Read_limit_Switches(GPI_LS_RDANCER_UP) == NO_LIMIT) @@ -1092,7 +1090,7 @@ uint32_t ThreadPrepareState(void *JobDetails) IntersegmentLength = JobTicket->intersegmentlength; PrepareWaitCount = 0; -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__LeftDancer, windertension); ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Winder",__FILE__,HARDWARE_DANCER_TYPE__LeftDancer,PrepareWaitCount,RpWarning,(int)windertension,0); status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__MiddleDancer, pullertension); @@ -1214,7 +1212,7 @@ uint32_t ThreadPrepareState(void *JobDetails) ///////////////////////////////////////////////////// MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU 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 { ReportWithPackageFilter(ThreadFilter,"Feeder Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0); @@ -1241,7 +1239,7 @@ uint32_t ThreadPrepareState(void *JobDetails) PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep); PoolerSpeedControlId = AddControlCallback(NULL,PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); } -#ifndef FOUR_WINDERS +#ifndef BTSR_NO_TFU 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 { if (ControlIdtoMotorId[Motor_i] != 0xFF) diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h index 996191b63..cebfba762 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_ex.h @@ -44,9 +44,11 @@ bool WHS_IsContainerFull(); bool WHS_WasteCartridgeLowerPresent(); bool WHS_WasteCartridgeMiddlePresent(); bool WHS_IsEmptying(); +uint32_t Waste_CheckState(void); uint32_t Waste_Prepare(void); bool WHS_IsVocPpmOverAlarmLimit(); + extern bool ReadingVocEverySec; #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c index 28a5720ab..267a4e7be 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c @@ -6,11 +6,13 @@ #include "drivers/Valves/Valve.h" #include "Common/report/report.h" #include "Modules/Waste/Waste_ex.h" +#include "modules/heaters/heaters_ex.h" #include <Drivers/I2C_Communication/RFID_NFC/RFIDTagInfo.h> #include "Drivers/I2C_Communication/RFID_NFC/logi-tag/LT_RFID.h" #include <Drivers/I2C_Communication/RFID_NFC/NFC_MainBaord.h> #include "Drivers/I2C_Communication/RFID_NFC/NFC.h" -//#include <Utilities/RfidTagHandling.h> +#include <Utilities/RfidTagHandling.h> +#include "PMR/IFS/CartridgeState.pb-c.h" #include <PMR/Diagnostics/EventType.pb-c.h> #include "Modules/AlarmHandling/AlarmHandling.h" @@ -19,6 +21,7 @@ #include "CartridgeValidationRequest.pb-c.h" #include "CartridgeValidationResponse.pb-c.h" #include "Modules/General/buttons.h" +#include "modules/General/process.h" #include "Modules/IFS/ifs.h" #include <Drivers/I2C_Communication/I2C_Task.h> #include <Drivers/I2C_Communication/WHS_Card/D_MAX11614_ADC/WHS_MAX11614_A2D.h> @@ -329,7 +332,6 @@ uint32_t Waste_DoorOpenDuringEmptying(uint32_t IfIndex, uint32_t ReadValue) } } return OK; -#warning add alarm on door open } void Waste_StateMachine_OneSecond_Call(void) @@ -501,7 +503,7 @@ void Waste_StateMachine(void) break; } } -uint32_t Waste_Prepare(void) +uint32_t Waste_CheckState(void) { //check if the waste is ready to run - waste level not above overflow level and no cartridge in the slots if (wasteLevel > wasteLevelOverflow) @@ -528,6 +530,62 @@ uint32_t Waste_Prepare(void) return JOB_WASTE_HANDLING_PROBLEM; } } +bool WHS_FlowReady = false,HeadIn_FlowReady = false,HeadOut_FlowReady = false; +uint32_t WasteReadyControlId = 0xFF; +uint32_t Waste_PrepareCallbak(uint32_t IfIndex, uint32_t ReadValue) +{ + bool ready = false, headready = false,whsready = false; + double HeadFlow = GetWHSAirFlow(HEAD_FLOW_METER); + double HeadIn_Flow = PressureSensorGetPressure(HEAD_PT100_ZONE_5_0X84_0); + double HeadOut_Flow = PressureSensorGetPressure(HEAD_PT100_ZONE_7_0X86_0); + if ((HeadFlow<(headairflow*1.07))&&(HeadFlow>(headairflow*0.93))) + { + if (WHS_FlowReady == false) + Report("Module waste WHS_FlowReady ready", __FILE__, __LINE__, (int)(HeadFlow*100), RpMessage, WHS_FlowReady, 0); + WHS_FlowReady = true; + } + if ((HeadIn_Flow<(headBlowersFlow[0]*1.07))&&(HeadIn_Flow>(headBlowersFlow[0]*0.93))) + { + if (HeadIn_FlowReady == false) + Report("Module waste HeadIn_FlowReady ready", __FILE__, __LINE__, (int)(HeadIn_Flow*100), RpMessage, HeadIn_FlowReady, 0); + HeadIn_FlowReady = true; + } + if ((HeadOut_Flow<(headBlowersFlow[1]*1.07))&&(HeadOut_Flow>(headBlowersFlow[1]*0.93))) + { + if (HeadOut_FlowReady == false) + Report("Module waste HeadOut_FlowReady ready", __FILE__, __LINE__, (int)(HeadOut_Flow*100), RpMessage, WHS_FlowReady, 0); + HeadOut_FlowReady = true; + } + if (Head_Type <HEAD_TYPE_FLAT) + headready = true; + else if ((HeadIn_FlowReady == true)&&(HeadOut_FlowReady == true)) + headready = true; + if (WHS_Type == WHS_TYPE_UNKNOWN) + whsready = true; + else if (WHS_FlowReady == true) + whsready = true; + if ((headready == true)&&(whsready == true)) + ready = true; + if (ready == true) + { + SafeRemoveControlCallback(WasteReadyControlId,Waste_PrepareCallbak); + WasteReadyControlId = 0xFF; + Report("Module waste prepare ready!", __FILE__, __LINE__, headready, RpMessage, headready, 0); + PrepareReady(Module_Waste,ModuleDone); + } + Report("Module waste prepare", __FILE__, __LINE__, headready, RpMessage, whsready, 0); + return OK; +} +uint32_t Waste_Prepare(void) +{ + WHS_FlowReady = false;HeadIn_FlowReady = false;HeadOut_FlowReady = false; + if (WasteReadyControlId != 0xFF) + RemoveControlCallback(WasteReadyControlId,Waste_PrepareCallbak); + //check that blowers are within 10% of designated flow: WHS, head blowers + WasteReadyControlId = AddControlCallback("Cartridge Cover Door", Waste_PrepareCallbak, eOneSecond, TemplateDataReadCBFunction, 0, 0, 0); + Report("Module waste prepare", __FILE__, __LINE__, Head_Type, RpMessage, WHS_Type, 0); + return OK; +} bool WHS_IsVocPpmOverAlarmLimit() { @@ -565,3 +623,5 @@ bool WHS_IsVocPpmOverAlarmLimit() return false; } + + |
