From 338edba081dba2a2aefb634811be1cc84ec93d64 Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Tue, 25 Aug 2020 10:08:01 +0300 Subject: merge --- .../Embedded/Modules/Diagnostics/Diagnostics.c | 33 ++++---- .../Modules/Diagnostics/DiagnosticsHoming.c | 30 ++++--- .../Embedded/Modules/Heaters/Heaters_print.c | 2 +- .../Embedded/Modules/IDS/IDS_Cleaning.c | 1 + Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h | 1 + .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 15 +++- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 54 +++++++++--- Software/Embedded_SW/Embedded/Modules/IFS/ifs.c | 1 + .../Embedded_SW/Embedded/Modules/Thread/Thread.h | 10 +++ .../Embedded/Modules/Thread/ThreadLoad.c | 53 +++++++----- .../Embedded/Modules/Thread/Thread_Winder.c | 77 +++++++++++++++--- .../Embedded/Modules/Thread/Thread_print.c | 95 ++++++++++++++++++++-- .../Embedded/Modules/Waste/Waste_maint.c | 2 - 13 files changed, 295 insertions(+), 79 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 7963a9290..a76142b00 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -332,26 +332,26 @@ uint32_t DiagnosticsLoadDigitalValues(void) DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPI_WCONTAINER_WARN; DigitalOutputState[index++].value = WHS_IsContainerEmpty(); - DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_SPARE1_1; /*waste lower cartridge presence*/ - DigitalOutputState[index++].value = WHS_WasteCartridgeLowerPresent(); - - DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_SPARE1_2; /*waste middle cartridge presence*/ - DigitalOutputState[index++].value = WHS_WasteCartridgeMiddlePresent(); - DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_SPARE_SSR12_CTRL; /*lubricant valve*/ DigitalOutputState[index++].value = GetLubricantState(); - DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_TFEED_BREAK_1; /*Secondary Pump Active*/ - DigitalOutputState[index++].value = SecondaryPumpActive; - DigitalOutputState[index].interfaceio = INTERFACE_IOS__CART1; /*Secondary Pump Active*/ - DigitalOutputState[index++].value = IFS_CartridgeLowerPresent(); + DigitalOutputState[index++].value = Is_Cartridge_Present(CART_1); DigitalOutputState[index].interfaceio = INTERFACE_IOS__CART2; /*Secondary Pump Active*/ - DigitalOutputState[index++].value = WHS_WasteCartridgeMiddlePresent(); + DigitalOutputState[index++].value = Is_Cartridge_Present(CART_2); DigitalOutputState[index].interfaceio = INTERFACE_IOS__CART3; /*Secondary Pump Active*/ - DigitalOutputState[index++].value = WHS_WasteCartridgeLowerPresent(); + DigitalOutputState[index++].value = Is_Cartridge_Present(CART_3); + + DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_SPARE1_1; /*Waste filling middle cartridge*/ + DigitalOutputState[index++].value = (cartGetState(WasteCartridge_middle)==CartridgeStateACTIVE)?1:0; + + DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_SPARE1_2; /*Waste filling lower cartridge*/ + DigitalOutputState[index++].value = (cartGetState(WasteCartridge_lower)==CartridgeStateACTIVE)?1:0; + + DigitalOutputState[index].interfaceio = INTERFACE_IOS__GPO_TFEED_BREAK_1; /*IFS MidTank Filling*/ + DigitalOutputState[index++].value = IFS_MidTankFilling(); return index; } @@ -593,8 +593,8 @@ void DiagnosticOneMinuteCollection(void) } DiagnosticsMonitor.n_overalltemperature = 1; - OverallTemperature = max(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1),MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)); - OverallTemperature = ((int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1)/100)*1000 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)/100)); + OverallTemperature = (max(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1),MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)))/100; + //OverallTemperature = ((int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP1)/100)*1000 + (int)(MillisecGetTemperatures(TEMP_SENSE_AN_ENCLOSURETEMP2)/100)); DiagnosticsMonitor.overalltemperature = &OverallTemperature; DiagnosticsMonitor.n_midtank1level = 1; @@ -856,8 +856,8 @@ void DiagnosticOneSecCollection(void) if (Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD) //rapid/pp machines { AcVoltage = ReadVAC(); - DiagnosticsMonitor.whsblower2voltage = &AcVoltage; - DiagnosticsMonitor.n_whsblower2voltage = 1; + //DiagnosticsMonitor.whsblower2voltage = &AcVoltage; + //DiagnosticsMonitor.n_whsblower2voltage = 1; DiagnosticsMonitor.incomingvoltage = &AcVoltage; DiagnosticsMonitor.n_incomingvoltage = 1; } @@ -880,6 +880,7 @@ void DiagnosticOneSecCollection(void) if ((GetMachineState()=MACHINE_STATE_WAIT_FOR_COOLER)) { InitCounter-=1.0; + if(InitCounter<0)InitCounter = 0; DiagnosticsMonitor.chillertemperature = &InitCounter; } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 047293ea9..d9f8d30fd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -43,11 +43,12 @@ uint32_t HomingControlId[NUM_OF_MOTORS]; uint32_t Diagnostics_Dryer_UnLoading(void); uint32_t Diagnostics_Dryer_Loading(void); +int kval_upper_value; /******************************************************************************** * Motor Homing ********************************************************************************/ -//int32_t keepkvalright,keepkvalleft; +int32_t keepkvalright,keepkvalleft; uint32_t MotorHomingProgressReport(uint32_t deviceID, uint32_t ReadValue) { if (HomingToken[deviceID][0] == 0) @@ -88,11 +89,11 @@ uint32_t MotorHomingRequestCallback(uint32_t deviceID, uint32_t ReadValue) if(deviceID == HARDWARE_MOTOR_TYPE__MOTO_RLOADING) { - MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 24); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, keepkvalright); } if(deviceID == HARDWARE_MOTOR_TYPE__MOTO_LLOADING) { - MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 24); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, keepkvalleft); } if (resetPullerDancer == true) { @@ -101,7 +102,7 @@ uint32_t MotorHomingRequestCallback(uint32_t deviceID, uint32_t ReadValue) } if (resetWinderDancer == true) { - resetPullerDancer = false; + resetWinderDancer = false; MCU_E2PromProgram(EEPROM_WINDER_TENSION_POSITION,1); } if (HomingControlId[deviceID] != 0xff) @@ -146,9 +147,8 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) LoadArmRounds = (int)dryerbufferlength; - int kval_upper_value; if (Is_PP_Machine()) - kval_upper_value = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + kval_upper_value = 28; else kval_upper_value = 70; @@ -200,12 +200,12 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) } if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_RLOADING) { - //keepkvalright = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + keepkvalright = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, kval_upper_value); } if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_LLOADING) { - //keepkvalleft = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].kvalrun; + keepkvalleft = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].kvalrun; MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, kval_upper_value); } MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdUp[MotorId], MotorHomingRequestCallback,30000); @@ -241,12 +241,12 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_RLOADING) { - //keepkvalright = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + keepkvalright = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, kval_upper_value); } if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_LLOADING) { - //keepkvalleft = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].kvalrun; + keepkvalleft = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].kvalrun; MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, kval_upper_value); } MotorMovetoLimitSwitch (MotorId,MotorsCfg[MotorId].directionthreadwize, speed, Motor_Id_to_LS_IdDown[MotorId], MotorHomingRequestCallback,30000); @@ -298,6 +298,16 @@ uint32_t MotorAbortHomingRequestFunc(MessageContainer* requestContainer) { resetWinderDancer = false; } + if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_RLOADING) + { + if (keepkvalright) + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, keepkvalright); + } + if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_LLOADING) + { + if (keepkvalleft) + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, keepkvalleft); + } responseContainer = createContainer(MESSAGE_TYPE__MotorAbortHomingResponse, requestContainer->token, false, &response, &motor_abort_homing_response__pack, &motor_abort_homing_response__get_packed_size); responseContainer.continuous = false; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 52e9a6e85..ce3ced6ef 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -724,7 +724,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) { if(Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD) { - WHS_Set_SetPoint_Q_value(headairflow*2/3); + WHS_Set_SetPoint_Q_value(headairflow); } else { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c index abfb5f229..09f5ae108 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_Cleaning.c @@ -123,6 +123,7 @@ uint32_t IDS_Cleaning_Spray_Cleaning_Solution (int dispenserSpeed,callback_fptr Tdelay1 = LeftRockerSpeed%100; Tdelay2 = RightRockerSpeed; status = IDS_Dispenser_Start_Motor_and_Open_Valve(CLEANER_DISPENSER, dispenserSpeed, callback); + Init_CleaningStageCounter(); Report("IDS_Cleaning_Spray_Cleaning_Solution", __FILE__, __LINE__, CLEANER_DISPENSER, RpWarning, dispenserSpeed, 0); Report("IDS_Cleaning parameters", __FILE__, Tup*100, Tdelay1*100, RpWarning, Tdelay2*100, 0); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index 831fa18cd..9973e4c7c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -49,6 +49,7 @@ extern bool ActuatorsCleaningSequence; extern bool DispenserUsedInJob[MAX_SYSTEM_DISPENSERS]; extern int32_t CurrentDispenserSpeed[MAX_SYSTEM_DISPENSERS]; +extern bool DispenserLastMovementDown[MAX_SYSTEM_DISPENSERS]; bool IDS_MapDispenserUsedinJob(void *JobDetails); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 8dc12e615..14bb59661 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -296,6 +296,8 @@ uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr Report("IDS_HomeDispenser ",__FILE__,(int)(midTankContent*1000),(int)DispenserId,RpWarning,speed,0); } CurrentDispenserSpeed[DispenserId] = (-1*CurrentDispenserSpeed[DispenserId]); + DispenserLastMovementDown[DispenserId] = true; + return OK; } return ERROR; @@ -531,15 +533,24 @@ uint32_t IDS_Check_Pressure_Callback(uint32_t DispenserId, uint32_t ReadValue) if (GetDispenserPressure(DispenserId)>3.0) { - Report("Pulling dispenser down to reduce pressure",__FILE__,DispenserId,(int)(GetDispenserPressure(DispenserId)*100),RpWarning,200,0); + //10/8/2020 pulling down 2000 steps + Report("Pulling dispenser down to reduce pressure",__FILE__,DispenserId,(int)(GetDispenserPressure(DispenserId)*100),RpWarning,2000,0); if ((HomingActive[DispenserId] == true)||(PrimingActive[DispenserId] == true)) { Report("Dispenser in pressure but homing active",__FILE__,DispenserId,(int)HomingActive[DispenserId],RpWarning,PrimingActive[DispenserId],0); LOG_ERROR(DispenserId,"IDS_Check_Pressure_Callback homing active"); return ERROR; } - MotorMove(HW_Motor_Id,1-MotorsCfg[HW_Motor_Id].directionthreadwize,200*MotorsCfg[HW_Motor_Id].microstep); + MotorMove(HW_Motor_Id,1-MotorsCfg[HW_Motor_Id].directionthreadwize,2000*MotorsCfg[HW_Motor_Id].microstep); AddControlCallback("IDS_ReCheck_Pressure", IDS_ReCheck_Pressure_Callback, eOneSecond*4,TemplateDataReadCBFunction ,DispenserId, 0, 0 ); + if (GetDispenserPressure(DispenserId)>5.5) + { + //stop job on pressure rise above 5.5 bar + IDS_Dispenser_Alarm_On(DispenserId); + //open valve toward mixer on pressure rise above 5.5 bar + Task_sleep(100); + Control3WayValvesWithCallback ((Valves_t)DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer + } } return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 3f30e755a..9c82cb1bf 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -452,6 +452,9 @@ c. Go to step 2.a x Segment.BrushStopsCount. uint32_t DispenserPrepareControlId = 0xFF; int NumOfActiveDispensers = 0; int DispenserBuildTimeCounter = 0; +#define DISPENSER_UP_MOVEMENT + int DispenserTotalPrepareSteps[MAX_SYSTEM_DISPENSERS]; + bool DispenserLastMovementDown[MAX_SYSTEM_DISPENSERS]; #define PRESSURE_READ_TIME_GAP 100 uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) { @@ -508,6 +511,7 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) return OK; // all configured heaters are ready } char IdsMessage[100]; + char IdMessage[100]; int SegmentPrepareWFCFCounter = 0; bool pressureReady = false,endOfPrepareWCF = false; //******************************************************************************************************************** @@ -532,6 +536,11 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) { if (DispenserBuildTimeCounter<(2*eOneSecond)) { + for (i = 0; i < MAX_DYE_DISPENSERS; i++) + { + DispenserTotalPrepareSteps[i]+=(CurrentDispenserSpeed[i]*PRESSURE_READ_TIME_GAP/eOneSecond); + DispenserLastMovementDown[i] = false; + } //REPORT_MSG(DispenserBuildTimeCounter,"waiting 2 seconds for pressure changes"); return OK; } @@ -541,10 +550,18 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { + DispenserTotalPrepareSteps[i]+=(CurrentDispenserSpeed[i]*PRESSURE_READ_TIME_GAP/eOneSecond); + HW_Motor_Id = DispenserIdToMotorId[i]; if (GetDispenserPressure(i) > DispenserPreparePressure*1.05) { - NumofReadyDispensers++; +#ifdef DISPENSER_UP_MOVEMENT + if (DispenserTotalPrepareSteps[i]>120000) +#endif + { + NumofReadyDispensers++; + Report("Dispenser total prepare steps ready",__FILE__,DispenserTotalPrepareSteps[i],(int)(DispenserPreparePressure*100),RpWarning,IDS_Dispenser_Data[i].consumedinnanolitter,0); + } if (Special_Dispensers == true) { MotorStop(HW_Motor_Id, Hard_Hiz); @@ -582,8 +599,9 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) { HW_Motor_Id = DispenserIdToMotorId[CLEANER_DISPENSER]; MotorStop(HW_Motor_Id, Hard_Hiz); + if (CurrentDispenserSpeed[CLEANER_DISPENSER]) + Report("IDS stop cleaner",__FILE__,CLEANER_DISPENSER,(int)(GetDispenserPressure(CLEANER_DISPENSER)*100),RpWarning,(int)CurrentDispenserSpeed[CLEANER_DISPENSER] ,0); CurrentDispenserSpeed[CLEANER_DISPENSER] = 0; - //Report("IDS stop cleaner",__FILE__,CLEANER_DISPENSER,(int)(GetDispenserPressure(CLEANER_DISPENSER)*100),RpWarning,(int)CurrentDispenserSpeed[CLEANER_DISPENSER] ,0); } if ((NumofReadyDispensers)&&(DispenserBuildTimeCounter%1000 == 0)) @@ -599,7 +617,7 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) { DispenserBuildTimeCounter = 0; pressureReady = true; - Report("pressureReady = true or timeout;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); + Report("pressureReady = true or timeout;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)(DispenserPreparePressure*100),0); } } else if (endOfPrepareWCF == false) @@ -641,7 +659,6 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) } if (segmentfirst_speed > MINIMAL_MOTOR_SPEED) { - char IdMessage[100]; segmentfirst_speed *= (100+WFCF); segmentfirst_speed /= 100; DispenserSegmentReady[DispenserId] = false; @@ -730,7 +747,7 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) JobTicket* JobTicket = JobDetails; JobEndSequence = false; - if ((pressurebuildup>0.1)&&(pressurebuildup<2.5)) + if ((pressurebuildup>0.1)&&(pressurebuildup<4.0)) { Report("Setting pressure from RML feeder tension",__FILE__,__LINE__,(int)(pressurebuildup*100),RpWarning,(int)(DispenserPreparePressure*100),0); DispenserPreparePressure = pressurebuildup; @@ -742,7 +759,7 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) } if ((cleanerFlow>200)&&(cleanerFlow<1150)) { - Report("Setting pressure from RML feeder tension",__FILE__,__LINE__,(int)(cleanerFlow),RpWarning,(int)CleaningDispenserSpeed,0); + Report("Setting cleanerFlow from RML cleanerFlow",__FILE__,__LINE__,(int)(cleanerFlow),RpWarning,(int)CleaningDispenserSpeed,0); CleaningDispenserSpeed = cleanerFlow; } else if (cleanerFlow <= 10) @@ -813,6 +830,8 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) Report("Stop active dispenser homing ",__FILE__,i,HomingActive[i],RpWarning,CurrentDispenserSpeed[i],0); IDS_StopHomeDispenser(i); } + DispenserTotalPrepareSteps[i] = 0; + Report("Dispenser total prepare steps zero",__FILE__,i,DispenserTotalPrepareSteps[i],RpWarning,IDS_Dispenser_Data[i].consumedinnanolitter,0); } else { @@ -1220,8 +1239,11 @@ uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId) uint32_t status = OK; JobDescriptionFileBrushStop * tFileBrushStop; int Brush_i; + Task_Stat statbuf; //check and close previous segment + RemoveControlCallback(BrushStopControlId,IDSBrushStopRestartCallback); + BrushStopControlId = 0xFF; if (PrevSegment) { if (JobBrushStopIdbrushstopscount) //we did not finish reading the brushstops of the previous segment @@ -1229,7 +1251,7 @@ uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId) Report("Unhandled brushstops remained",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)PrevSegment->brushstopscount,0); //REPORT_MSG (Segment->brushstopscount, "Segment->brushstopscount"); //for (Brush_i=JobBrushStopId;Brush_ibrushstopscount;Brush_i++) #bug 3348 - unhandled jobstops stops too soon - for (Brush_i=JobBrushStopId;Brush_i<=PrevSegment->brushstopscount;Brush_i++) + for (Brush_i=JobBrushStopId;Brush_ibrushstopscount;Brush_i++) { if (status == ERROR) break; @@ -1241,13 +1263,19 @@ uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId) } else { + Task_stat(Task_self(),&statbuf); + Report("Unhandled BrushStopRead Error",__FILE__,statbuf.used,(int)statbuf.stackSize,RpWarning,(int)statbuf.stackHeap,0); + //JobEndReason = JOB_OUT_OF_DYE; + //SegmentReady(Module_IDS,ModuleFail); + Report("Unhandled brushstops ERROR",__FILE__,__LINE__,(int)tFileBrushStop,RpWarning,(int)PrevSegment->brushstopscount,0); status = ERROR; break; } }//for brushstops } } - return status; + Report("Unhandled brushstops result",__FILE__,__LINE__,(int)Brush_i,RpWarning,(int)PrevSegment->brushstopscount,0); + return OK; } uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) { @@ -1525,7 +1553,7 @@ uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) Task_Stat statbuf; if(BrushStopStartTime+BrushStopLength+100 < msec_millisecondCounter ) { - Report("!!!!!!!!!!!!Overtime!",__FILE__,msec_millisecondCounter,(int)BrushStopStartTime,RpWarning,(int)BrushStopLength,0); + Report("!!!!!!!!!!!!Overtime!",__FILE__,msec_millisecondCounter,(int)BrushStopStartTime,RpWarning,(int)BrushStopLength,0); } if(++BrushStopCounter < BrushStopTime) @@ -1535,6 +1563,11 @@ uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) BrushStopCounter = 0; BrushStopStartTime = msec_millisecondCounter; + if (BrushStopControlId == 0xFF) + { + Report("!!!BrushStopControlId = 0xFF",__FILE__,msec_millisecondCounter,(int)BrushStopStartTime,RpWarning,(int)BrushStopLength,0); + return OK; + } if (JobEndSequence == true) { @@ -1563,7 +1596,8 @@ uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) } else { - LOG_ERROR(FileBrushStop,"BrushStopReadError"); + Task_stat(Task_self(),&statbuf); + Report("BrushStopRead Error",__FILE__,statbuf.used,(int)statbuf.stackSize,RpWarning,(int)statbuf.stackHeap,0); JobEndReason = JOB_OUT_OF_DYE; SegmentReady(Module_IDS,ModuleFail); } diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index e0a2f79d5..f822c869c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -286,6 +286,7 @@ void midTankStateMachine(void) } if (doorState != prevDoorState) { prevDoorState = doorState; + Report("Door state change", __FILE__, __LINE__, doorState, RpMessage, prevDoorState, 0); } break; case MidTankStateWait: diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index c912bca21..aea0dd93a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -42,6 +42,15 @@ typedef struct PID_Config_Params m_params; }MotorControlConfig_t; +#ifdef FOUR_WINDERS +#define SCREW_2_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE2_1 +#define SCREW_3_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE1_1 +#define SCREW_4_Motor HARDWARE_MOTOR_TYPE__MOTO_RDANCER +#define Winder_2_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE2_2 +#define Winder_3_Motor HARDWARE_MOTOR_TYPE__MOTO_SPARE1_2 +#define Winder_4_Motor HARDWARE_MOTOR_TYPE__MOTO_RLOADARM +#endif + #define MAX_THREAD_FEED_MOTORS (WINDER_MOTOR+1) #define MAX_SYSTEM_DANCERS (HARDWARE_DANCER_TYPE__RightDancer+1) @@ -84,6 +93,7 @@ uint32_t DancerConfigMessage(HardwareDancer * request); uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read); void SetOriginMotorSpeed(float process_speed); +uint32_t UpdatePidDuringRun(HardwarePidControl *hardwarepidcontrol); uint32_t ThreadPrepare_Tension (int DancerId, double tension); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index c7ec8a58c..c478b82de 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -164,7 +164,7 @@ { if (Is_PP_Machine()) - kval_upperValue = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + kval_upperValue = 28; else kval_upperValue = 70; @@ -208,7 +208,7 @@ { if(Head_Type > HEAD_TYPE_FLAT_WITHOUT_CARD) { - WHS_Set_SetPoint_Q_value(headairflow*2/3); + WHS_Set_SetPoint_Q_value(headairflow); } else { @@ -349,7 +349,10 @@ if (Head_Type != HEAD_TYPE_ARC) { CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,10000); + if (MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 300, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,20000)==ERROR) + { + Thread_Load_HomingCallback(HARDWARE_MOTOR_TYPE__MOTO_DH_LID,NO_LIMIT); + } } CallbackCounter++; //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID].directionthreadwize, 200, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID], Thread_Load_HomingCallback,10000); @@ -366,8 +369,8 @@ if (Head_Type == HEAD_TYPE_FLAT) { Report("Thread_Load_Lift_actuators",__FILE__,__LINE__,LOW,RpMessage,false,0); - Trigger_Head_Actuators_Control(ACT_IN_AND_OUT, LOW,true); - //Trigger_Head_Actuators_Control(ACTIN, LOW,true); + Trigger_Head_Actuators_Stub(ACTOT, ENABLE, UP); + Trigger_Head_Actuators_Stub(ACTIN, ENABLE, UP); } return OK; } @@ -395,8 +398,8 @@ { keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; - if (keepkvalrun>=25) - keepkvalrun = 25; + /*if (keepkvalrun>=25) + keepkvalrun = 25;*/ Report("Read_Dryer_ENC_Position()",__FILE__,__LINE__,0,RpWarning,Read_Dryer_ENC_Position(),0); @@ -428,6 +431,7 @@ if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) { REPORT_MSG(LIMIT, "No cone in winder"); + Thread_Load_HomingCallback(HARDWARE_MOTOR_TYPE__MOTO_WINDER,NO_LIMIT); //return ERROR; } CallbackCounter++; @@ -440,8 +444,8 @@ { keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; - if (keepkvalrun>=25) - keepkvalrun = 25; + /*if (keepkvalrun>=25) + keepkvalrun = 25;*/ Report("Thread_Load_Close_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8); @@ -460,7 +464,7 @@ uint32_t Thread_Load_Close_Dancers(void) //Send Dancer Motors To Preset Location, Check That The Dancers Are On The Thread { - uint32_t current = 0; + uint32_t current = 1; REPORT_MSG(LoadStages, "Thread Load State Machine step Thread_Load_Close_Dancers"); CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,10000); @@ -500,14 +504,14 @@ if (Head_Type == HEAD_TYPE_FLAT) { Report("Thread_Load_Close_actuators",__FILE__,__LINE__,LOW,RpMessage,true,0); - Trigger_Head_Actuators_Control(ACTOT, LOW,false); - //Trigger_Head_Actuators_Control(ACTIN, LOW,false); + Trigger_Head_Actuators_Stub(ACTOT, ENABLE, DOWN); + //Trigger_Head_Actuators_Stub(ACTIN, ENABLE, DOWN); HeadCard_Actuators_Relocate(); } if (Head_Type != HEAD_TYPE_ARC) { CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,10000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DH_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DH_LID].directionthreadwize, 300, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID], Thread_Load_HomingCallback,20000); } CallbackCounter++; // MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID].directionthreadwize, 200, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID], Thread_Load_HomingCallback,10000); @@ -1227,11 +1231,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) index = IfIndex&0xFF; DancerId = ThreadMotorIdToDancerId[index]; - if (ReadValue < 10) + /*if (ReadValue < 10) { Report("Dancer value read too small.",__FILE__,__LINE__,DancerId,RpError,ReadValue,0); return OK; - } + }*/ if (ReadValue == 0x3FFF) { return OK; @@ -1242,6 +1246,11 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) //pooler dancer is right sided: data is opposite TranslatedReadValue = (-1*TranslatedReadValue); } + if (abs(TranslatedReadValue) > 0x2000) + { + TranslatedReadValue = 0x3FFF- TranslatedReadValue; //overcome zero environment + } + //TranslatedReadValue = 0;//test MotorSamples[index][MotorSamplePointer[index]] = TranslatedReadValue;//(-1 * TranslatedReadValue); MotorSamplePointer[index]++; @@ -1344,10 +1353,16 @@ void ThreadLoadRequest(MessageContainer* requestContainer) responseContainer = createContainer(MESSAGE_TYPE__StubHeatingTestResponse, requestContainer->token, false, &response, &stub_heating_test_response__pack, &stub_heating_test_response__get_packed_size); container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - int LoadStage = (int)request->dryerzone1temp; - LoadStages = LoadStage; - ThreadLoadStateMachine(LoadStage); + if (request->hardwarepidcontrol1!=NULL) + { + UpdatePidDuringRun(request->hardwarepidcontrol1); + } + else + { + LoadStages = LoadStage; + ThreadLoadStateMachine(LoadStage); + } /*if (status) { @@ -1463,7 +1478,7 @@ uint32_t ThreadLoadingReport(void) uint32_t TryThreadLoadingFunc(MessageContainer* requestContainer) { - TryThreadLoadingRequest *request = continue_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + TryThreadLoadingRequest *request = try_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); TryThreadLoadingResponse Cresponse = TRY_THREAD_LOADING_RESPONSE__INIT; MessageContainer responseContainer; MessageState = 2; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 420141d5b..1ce27115d 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -133,6 +133,7 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) * 1. move home to the limit switch (check that the cart is clear from the limit switch, start moving, with acceleration to maximal speed. enable interrupt on the limit switch, upon interrupt stop. * report ready to the job STM */ +int Screw_wait_counter; uint32_t Winder_Prepare(void *JobDetails) { JobTicket* JobTicket = JobDetails; @@ -199,7 +200,16 @@ uint32_t Winder_Prepare(void *JobDetails) //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); Winder_ScrewHoming = true; //REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit"); + Screw_wait_counter=1; status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2,2000); +#ifdef FOUR_WINDERS + Screw_wait_counter++; + status = MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, Winder_PrepareStage2,2000); + Screw_wait_counter++; + status = MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, Winder_PrepareStage2,2000); + Screw_wait_counter++; + status = MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, Winder_PrepareStage2,2000); +#endif } return status; } @@ -214,7 +224,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) uint32_t status=OK; uint32_t numOfSteps = WindingConeLocation*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); + //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); #ifdef READ_SCREW_ENCODER Read_Screw_Encoder(); @@ -223,11 +233,12 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) #endif REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2"); + Screw_wait_counter--; if (ReadValue != LIMIT) { if (JobIsActive()==true) { - LOG_ERROR(ReadValue,"Screw failed to reach the limit switch!!"); + LOG_ERROR(deviceID,"Screw failed to reach the limit switch!!"); //returned with a timeout Winder_ScrewAtOffsetCallback(0,0); } @@ -238,18 +249,38 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) } else { + if (Screw_wait_counter!=0) + { + ReportWithPackageFilter(ThreadFilter,"waiting for winders",__FILE__,__LINE__,Screw_wait_counter,RpWarning,deviceID, 0); + return status; + } + Screw_wait_counter++; status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback,1000); +#ifdef FOUR_WINDERS + Screw_wait_counter++; + status |= MotorMoveWithCallback (SCREW_2_Motor,(1-MotorsCfg[SCREW_2_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000); + Screw_wait_counter++; + status |= MotorMoveWithCallback (SCREW_3_Motor,(1-MotorsCfg[SCREW_3_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000); + Screw_wait_counter++; + status |= MotorMoveWithCallback (SCREW_4_Motor,(1-MotorsCfg[SCREW_4_Motor].directionthreadwize), numOfSteps, Winder_ScrewAtOffsetCallback,1000); +#endif } //set motor location 0 here return status; } -uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) +uint32_t Winder_ScrewAtOffsetCallback(uint32_t MotorId, uint32_t BusyFlag) { //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency); - - MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands + Screw_wait_counter--; + + MotorStop (MotorId,Soft_Hiz); //per L6470 errata between mov and run commands +/*#ifdef FOUR_WINDERS + MotorStop(SCREW_2_Motor, Hard_Hiz); + MotorStop(SCREW_3_Motor, Hard_Hiz); + MotorStop(SCREW_4_Motor, Hard_Hiz); +#endif*/ Task_sleep(5); #ifdef READ_SCREW_ENCODER Reset_Screw_Encoder(); @@ -260,7 +291,12 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location"); #endif - SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home + SetMotHome(MotorId); //set this point as the spool home +/*#ifdef FOUR_WINDERS + SetMotHome(SCREW_2_Motor); + SetMotHome(SCREW_3_Motor); + SetMotHome(SCREW_4_Motor); +#endif*/ ScrewCurrentDirection = false; #ifdef READ_SCREW_ENCODER @@ -269,8 +305,9 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; - REPORT_MSG(millisecondCounter, "Winder_ScrewAtOffsetCallback"); - PrepareReady(Module_Winder, ModuleDone); + ReportWithPackageFilter(ThreadFilter,"Winder_ScrewAtOffsetCallback",__FILE__,millisecondCounter,Screw_wait_counter,RpWarning,MotorId, 0); + if (Screw_wait_counter == 0) + PrepareReady(Module_Winder, ModuleDone); return OK; } @@ -565,6 +602,11 @@ uint32_t ScrewDTSCallback(uint32_t deviceID, uint32_t BusyFlag) //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); //MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, WinderDistanceToSpoolEnded,2000); +#ifdef FOUR_WINDERS + MotorMovetoLimitSwitch (SCREW_2_Motor,MotorsCfg[SCREW_2_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE2_2, NULL,2000); + MotorMovetoLimitSwitch (SCREW_3_Motor,MotorsCfg[SCREW_3_Motor].directionthreadwize, ScrewSpeed, GPI_LS_SPARE1_2, NULL,2000); + MotorMovetoLimitSwitch (SCREW_4_Motor,MotorsCfg[SCREW_4_Motor].directionthreadwize, ScrewSpeed, GPI_LS_RDANCER_UP, NULL,2000); +#endif return OK; } @@ -594,9 +636,14 @@ uint32_t Winder_End(void) //MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL,0); //MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //bug #2709 +#ifdef FOUR_WINDERS + MotorAbortMovetoLimitSwitch (SCREW_2_Motor); + MotorAbortMovetoLimitSwitch (SCREW_3_Motor); + MotorAbortMovetoLimitSwitch (SCREW_4_Motor); +#endif return OK; } -void Winder_ScrewHomeLimitSwitchInterrupt(void) +/*void Winder_ScrewHomeLimitSwitchInterrupt(void) { //uint32_t status; //handle glitch - send information to the next time that the motor stops @@ -611,7 +658,7 @@ void Winder_ScrewOutLimitSwitchInterrupt(void) //handle glitch - send information to the next time that the motor stops //uint32_t status; MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_SCREW,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);//make sure to move the cart out -} +}*/ uint32_t Screw_timerBase = TIMER3_BASE; //Timer handle @@ -655,7 +702,17 @@ void ScrewTimerInterrupt(int ARG0) { ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); +#ifdef FOUR_WINDERS + MotorSetDirection (SCREW_2_Motor, ScrewCurrentDirection); + MotorSetDirection (SCREW_3_Motor, ScrewCurrentDirection); + MotorSetDirection (SCREW_4_Motor, ScrewCurrentDirection); +#endif MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); +#ifdef FOUR_WINDERS + MotorSetSpeedDirect (SCREW_2_Motor, ScrewSpeed); + MotorSetSpeedDirect (SCREW_3_Motor, ScrewSpeed); + MotorSetSpeedDirect (SCREW_4_Motor, ScrewSpeed); +#endif #ifdef READ_SCREW_ENCODER Read_Screw_Encoder(); ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 2bdf1b17f..98147f6b2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -696,7 +696,8 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) }*`/ }*/ calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*OriginalMotorSpd_2PPS[index]; - calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR]; + if (index != WINDER_MOTOR) + calculated_speed = calculated_speed*InitialDryerSpeed/OriginalMotorSpd_2PPS[DRYER_MOTOR]; //calculated_speed = (1-MotorControlConfig[index].m_calculatedError)*CurrentControlledSpeed[index]; if (0)//(JobCounter % 1000 == 0) //if (JobCounter < 100)//(FirstCalcInJob == true) @@ -728,6 +729,14 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) }*/ CurrentControlledSpeed[index] = calculated_speed; MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed); +#ifdef FOUR_WINDERS + if (index == WINDER_MOTOR) + { + MotorSetSpeed(Winder_2_Motor, calculated_speed); + MotorSetSpeed(Winder_3_Motor, calculated_speed); + MotorSetSpeed(Winder_4_Motor, calculated_speed); + } +#endif } else { @@ -841,19 +850,21 @@ 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 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); RTFU_Up = false; status = MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].pulseperround/4* MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].microstep, Release_Right_TFU_TensionCallback,1000); } - +#endif return status; } int SecondFeederCorrection = 4; int PrepareWaitCount = 0; uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadValue) { +#ifndef FOUR_WINDERS 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) @@ -872,20 +883,23 @@ uint32_t Adjust_Right_TFU_Tension_2nd_Callback(uint32_t MotorId, uint32_t ReadVa ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_TensionCallback Prepare Ready",__FILE__,__LINE__,2,RpWarning,PrepareWaitCount,0); PrepareReady(Module_Thread,ModuleDone); } - +#endif return OK; } uint32_t Adjust_Right_TFU_Tension_Callback(uint32_t MotorId, uint32_t ReadValue) { +#ifndef FOUR_WINDERS 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; +#endif return OK; } uint32_t Adjust_Right_TFU_Tension(double tension) { uint32_t status = OK; +#ifndef FOUR_WINDERS if (tension > 0.5) //0 = lower position, 1 = high position { if (FPGA_Read_limit_Switches(GPI_LS_RDANCER_UP) == NO_LIMIT) @@ -895,7 +909,7 @@ uint32_t Adjust_Right_TFU_Tension(double tension) Report("Adjust_Right_TFU_Tension",__FILE__,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize,HARDWARE_MOTOR_TYPE__MOTO_RDANCER,RpMessage,PrepareWaitCount,0); } } - +#endif return status; } uint32_t ThreadPrepare_TensionCallback (int MotorId, double tension) @@ -1013,11 +1027,11 @@ uint32_t ThreadPrepareState(void *JobDetails) PrepareWaitCount = 0; status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__LeftDancer, windertension); - ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Winder",__FILE__,HARDWARE_DANCER_TYPE__LeftDancer,PrepareWaitCount,RpFatalError,(int)windertension,0); + ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Winder",__FILE__,HARDWARE_DANCER_TYPE__LeftDancer,PrepareWaitCount,RpWarning,(int)windertension,0); status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__MiddleDancer, pullertension); - ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Puller",__FILE__,HARDWARE_DANCER_TYPE__MiddleDancer,PrepareWaitCount,RpFatalError,(int)pullertension,0); + ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Puller",__FILE__,HARDWARE_DANCER_TYPE__MiddleDancer,PrepareWaitCount,RpWarning,(int)pullertension,0); status = ThreadPrepare_Tension (HARDWARE_DANCER_TYPE__RightDancer, feedertension); - ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Feeder",__FILE__,HARDWARE_DANCER_TYPE__RightDancer,PrepareWaitCount,RpFatalError,(int)feedertension,0); + ReportWithPackageFilter(ThreadFilter,"ThreadPrepare_Tension Feeder",__FILE__,HARDWARE_DANCER_TYPE__RightDancer,PrepareWaitCount,RpWarning,(int)feedertension,0); FirstCalcInJob = true; if(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].speedmaster == false) @@ -1034,14 +1048,14 @@ uint32_t ThreadPrepareState(void *JobDetails) /*if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) != LIMIT) { - ReportWithPackageFilter(ThreadFilter,"Dyeing head is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpFatalError,LIMIT,0); + ReportWithPackageFilter(ThreadFilter,"Dyeing head is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpWarning,LIMIT,0); //JobEndReason = JOB_LIDS_OPEN; //PrepareReady(Module_Thread,ModuleFail); //return ERROR; } if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID]) != LIMIT) { - ReportWithPackageFilter(ThreadFilter,"Dryer lid is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpFatalError,LIMIT,0); + ReportWithPackageFilter(ThreadFilter,"Dryer lid is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpWarning,LIMIT,0); //JobEndReason = JOB_LIDS_OPEN; //PrepareReady(Module_Thread,ModuleFail); //return ERROR; @@ -1120,6 +1134,7 @@ uint32_t ThreadPrepareState(void *JobDetails) ///////////////////////////////////////////////////// MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); +#ifndef FOUR_WINDERS 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); @@ -1132,6 +1147,7 @@ uint32_t ThreadPrepareState(void *JobDetails) LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep); SpeedControlId = AddControlCallback(NULL,ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); } +#endif if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled { ReportWithPackageFilter(ThreadFilter,"Puller Control",__FILE__,Motor_i,MotorControlConfig[Motor_i].m_params.Kp,RpWarning,MotorControlConfig[Motor_i].m_params.Ki,0); @@ -1145,6 +1161,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 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) @@ -1159,6 +1176,7 @@ uint32_t ThreadPrepareState(void *JobDetails) //AddControlCallback(NULL,ThreadControlSpeedReadFunction, eHundredMillisecond,MotorGetSpeedFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); #endif } +#endif if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will n//ot be controlled { if (ControlIdtoMotorId[Motor_i] != 0xFF) @@ -1196,7 +1214,57 @@ uint32_t ThreadPrepareState(void *JobDetails) //set 3 dancers to the profile positions return OK; } +uint32_t UpdatePidDuringRun(HardwarePidControl *request) +{ + int Motor_i = MAX_THREAD_MOTORS_NUM,i; + double temp_dt; + for (i=0;ihardwarepidcontroltype) + { + Motor_i = i; + break; + } + } + if (Motor_i == MAX_THREAD_MOTORS_NUM) + return ERROR; + + + if (request->derivativetime == true) + { + MotorControlConfig[Motor_i].m_params.Kd = request->derivativetime; + ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Kd",__FILE__,Motor_i,(int)(request->derivativetime),RpWarning,0,0); + } + if (request->proportionalgain == true) + { + MotorControlConfig[Motor_i].m_params.Kp = request->proportionalgain; + ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Kp",__FILE__,Motor_i,(int)(request->proportionalgain),RpWarning,0,0); + } + if (request->integraltime == true) + { + MotorControlConfig[Motor_i].m_params.Ki = request->integraltime; + ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun Ki",__FILE__,Motor_i,(int)(request->integraltime),RpWarning,0,0); + } + if (request->epsilon == true) + { + MotorControlConfig[Motor_i].m_params.epsilon = request->epsilon; + ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun epsilon",__FILE__,Motor_i,(int)(request->epsilon*10000),RpWarning,0,0); + } + if (request->has_controloutputtype == true) + { + MotorControlConfig[Motor_i].m_params.dt = request->controloutputtype; + temp_dt = MotorControlConfig[Motor_i].m_params.dt/0.001; + MotorTiming[Motor_i] = (int)temp_dt; + if (MotorTiming[Motor_i]) + { + MotorTimer[Motor_i] = MotorTiming[Motor_i]-1; + } + ReportWithPackageFilter(ThreadFilter,"UpdatePidDuringRun dt",__FILE__,Motor_i,(int)(request->controloutputtype*1000),RpWarning,temp_dt,0); + } +////////////////////////////////////////////////// + return OK; +} void SetOriginMotorSpeed(float process_speed) { int Motor_i, HW_Motor_Id; @@ -1451,6 +1519,15 @@ char Endstr[150]; for ( Motor_i = 0;Motor_i <= WINDER_MOTOR;Motor_i++) { MotorStop(ThreadMotorIdToMotorId[Motor_i],Hard_Hiz); +#ifdef FOUR_WINDERS + if (Motor_i == WINDER_MOTOR) + { + MotorStop(Winder_2_Motor, Hard_Hiz); + MotorStop(Winder_3_Motor, Hard_Hiz); + MotorStop(Winder_4_Motor, Hard_Hiz); + } +#endif + } MotorStop(HARDWARE_MOTOR_TYPE__MOTO_RLOADING,Hard_Hiz); MotorStop(HARDWARE_MOTOR_TYPE__MOTO_LLOADING,Hard_Hiz); diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c index c0e51a143..222b618d2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_maint.c @@ -526,6 +526,4 @@ uint32_t Waste_Prepare(void) //PrepareReady(Module_Waste,ModuleFail); return JOB_OTHER_ALARM; } - return; - } -- cgit v1.3.1