From e9b1f4ef6597c73bd5261e312ebf0beef77d153b Mon Sep 17 00:00:00 2001 From: Shai Frieder Date: Mon, 6 Jan 2020 11:06:52 +0200 Subject: newWHS --- .../Embedded/Modules/Waste/newWHS_init.c | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c index d44047fdb..f48a075ca 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/newWHS_init.c @@ -16,9 +16,10 @@ #include #include #include +#include bool test_9555(void); - +bool WHS_I2C_EEprom_Write_Ch_shai_taest(void); bool newWHS_init(void) { @@ -34,9 +35,10 @@ bool newWHS_init(void) // status |= Test_WHS_valve(); // status |= Test_WHS_pump(); // status |= Test_WHS_max11614(); - status |= Test_WHS_AD5272_A2D(); - +// status |= Test_WHS_AD5272_A2D(); + status |= Test_WHS_PT100_ADC(); //test_9555(); +// status |= WHS_I2C_EEprom_Write_Ch_shai_taest(); return status; } @@ -50,4 +52,33 @@ bool test_9555(void) return status; } +uint8_t WHS_Write_Buf[9]; +uint8_t WHS_Read_Buf[9]; + +bool WHS_I2C_EEprom_Write_Ch_shai_taest() +{ + bool status= OK; + +// uint8_t i = 0; + uint8_t address_high_byte = 0x00; + uint8_t address_low_byte = 0x00; + status |= Select_Main_WHS_Mux_Channel(); + + WHS_Write_Buf[0] = address_high_byte; + WHS_Write_Buf[1] = address_low_byte; + WHS_Write_Buf[2] = 0xAA; + WHS_Write_Buf[4] = 0xAA; + WHS_Write_Buf[6] = 0xAA; + WHS_Write_Buf[8] = 0xAA; + WHS_Write_Buf[3] = 0x55; + WHS_Write_Buf[5] = 0x55; + WHS_Write_Buf[7] = 0x55; + + + status |= I2C_Write(I2C_ID_WHS_CARD, I2CEEPROM_ADDRESS, WHS_Write_Buf, 9); + SysCtlDelay(5000000);//Must delay for at least 5 milli. !!! (See data sheet ) + status |= I2C_Write(I2C_ID_WHS_CARD, I2CEEPROM_ADDRESS, WHS_Write_Buf, 2); + status |= I2C_Read(I2C_ID_WHS_CARD, I2CEEPROM_ADDRESS + 1, WHS_Read_Buf, 7); + return status; +} -- cgit v1.3.1 From 26b6af221609c7126a73351e415d7017613c31ae Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 6 Jan 2020 12:34:55 +0200 Subject: some fixes from 1.4.5.110 (Beta +) --- .../Embedded_SW/Embedded/Common/report/filter.c | 5 +++ .../Embedded/Communication/CommunicationTask.c | 2 +- .../Embedded/Communication/Connection.c | 4 +++ .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 12 ++++--- .../Embedded/Drivers/Motors/MotorActions.c | 15 ++++---- .../Embedded/Modules/IDS/IDS_dispenser.c | 4 +-- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 4 +-- Software/Embedded_SW/Embedded/Modules/IFS/ifs.h | 1 + .../Embedded/Modules/Thread/ThreadLoad.c | 42 +++++++++++++--------- .../Embedded/Modules/Thread/Thread_Winder.c | 10 ++++-- .../Embedded/Modules/Thread/Thread_ex.h | 2 ++ 11 files changed, 66 insertions(+), 35 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Common/report/filter.c b/Software/Embedded_SW/Embedded/Common/report/filter.c index febc1ea8c..f0eb5a140 100644 --- a/Software/Embedded_SW/Embedded/Common/report/filter.c +++ b/Software/Embedded_SW/Embedded/Common/report/filter.c @@ -360,6 +360,11 @@ STATUS Report(const char *message, int parameter2) { + if ((FileName == 0)&&(errorCode==0)&&(LineNumber==0)&&(parameter1 == 0)) + { + LOG_ERROR(55,"Error report"); + } + /* if message passes the filter send it to distributor */ if (filterTest(severity) || (GET_PRIVATE_SEVERITY(severity) > 0)) return reportDistribute(REPORT_FORMAT, diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index 99debf806..56ceccd28 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -34,7 +34,7 @@ struct serialBuffer { size_t used; size_t size; } typedef SerialBuffer; -#define SHORT_BUFFER_SIZE 200 +#define SHORT_BUFFER_SIZE 100 char CommShortRxBuffer[10][SHORT_BUFFER_SIZE]; char CommRxBuffer[2][COMM_MAX_BUFFER_SIZE]; SerialBuffer inBuffer[12]; diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 18f176e64..9f355fa59 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -64,6 +64,10 @@ void ConnectionRequest(MessageContainer* requestContainer) if (request->has_unixtime) utilsUpdateDateTime(request->unixtime);//(request->seconds); + ReportStopReporting(); + DiagnosticsStop(); + JobStopReporting(); + AlarmHandlingStop(); /* extern TangoVersion_t _gTangoVersion; extern char Dat[50]; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index d1a3ee958..42e4d673b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -371,37 +371,41 @@ uint32_t SetMotHome(TimerMotors_t _motorId) uint32_t MotorSetMaxSpeed(TimerMotors_t _motorId, uint32_t MaxSpeed) { + if(MotorsCfg[_motorId].maxfrequency != MaxSpeed) + ReportWithPackageFilter(GeneralFilter,"MotorSetMaxSpeed",__FILE__,__LINE__,_motorId,RpMessage,MaxSpeed,0); MotorsCfg[_motorId].maxfrequency = MaxSpeed; FPGA_SetMotMaxSpeed(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetMaxSpeed",__FILE__,__LINE__,_motorId,RpMessage,MaxSpeed,0); return OK; } uint32_t MotorSetMicroStep(TimerMotors_t _motorId, uint32_t microstep) { + if (MotorDriverRequest[_motorId].microstep != microstep) + ReportWithPackageFilter(GeneralFilter,"MotorSetMicroStep",__FILE__,__LINE__,_motorId,RpMessage,microstep,0); MotorDriverRequest[_motorId].microstep = microstep; FPGA_SetMotMicroStep(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetMicroStep",__FILE__,__LINE__,_motorId,RpMessage,microstep,0); return OK; } uint32_t MotorSetKvalHold(TimerMotors_t _motorId, uint8_t Value) { + if(MotorsCfg[_motorId].kvalhold != Value) + ReportWithPackageFilter(GeneralFilter,"MotorSetKvalHold",__FILE__,__LINE__,_motorId,RpMessage,Value,0); MotorsCfg[_motorId].kvalhold = Value; MotorsCfg[_motorId].tvalhold = Value; FPGA_SetMotKvalHold(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetKvalHold",__FILE__,__LINE__,_motorId,RpMessage,Value,0); return OK; } uint32_t MotorSetKvalRun(TimerMotors_t _motorId, uint8_t Value) { + if(MotorsCfg[_motorId].kvalrun != Value) + ReportWithPackageFilter(GeneralFilter,"MotorSetKvalRun",__FILE__,__LINE__,_motorId,RpMessage,Value,0); MotorsCfg[_motorId].kvalrun = Value; MotorsCfg[_motorId].tvalrun = Value; FPGA_SetMotKvalRun(_motorId); - ReportWithPackageFilter(GeneralFilter,"MotorSetKvalRun",__FILE__,__LINE__,_motorId,RpMessage,Value,0); return OK; } diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index b58bba677..ddd0d293c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -260,7 +260,7 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / //REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction stopped"); Report("Motor to stopper stopped",__FILE__,avreageSampleValue,StoredavreageSampleValue,RpWarning,avreageSampleSum,0); Report("Move_To_Stopper_Callback 1",__FILE__,cycles,MotorPosition,RpMessage,Initialcurrentposition,0); - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorVerifiedCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz ); @@ -360,7 +360,7 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea { Report("MotorMoveToDrierPosition end",__FILE__,__LINE__,DrierZeroPosition,RpWarning,ReadValue,0); //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorMoveToDrierPositionCallBackFunction); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction @@ -402,7 +402,6 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb callback(MotorId,0); return OK; } - //Report("MotorMovetoEncoderPosition direction",__FILE__,__LINE__,direction,RpWarning,15,0); //MotorSetDirection( MotorId, direction); @@ -441,7 +440,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO } if (CallbackCalls%200 == 1) { - MotorId = Control_Read_Dryer_Position(0,0); + MotorId = Read_Dryer_ENC_Position(0,0); Report("MotorMoveCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,MotorId,0); } MotorId = IfIndex&0xFF; @@ -455,7 +454,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO Report("MotorControlGetnBusyState stop",__FILE__,__LINE__,MotorDriverResponse[MotorId].Busy,RpMessage,0,0); }*/ //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorMoveCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) @@ -488,7 +487,7 @@ uint32_t MotorSetSpeedCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TO if (BusyFlag == 1) { //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorSetSpeedCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) @@ -523,7 +522,7 @@ uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t Limit if ((LimitSwitch == LIMIT) ||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) { //stop this control loop - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId], MotorMoveToLimitSwitchCallBackFunction); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; if ((MotorId == HARDWARE_MOTOR_TYPE__MOTO_RDANCER)&&(HoldRightDancer == true)) @@ -768,7 +767,7 @@ uint32_t MotorMoveToDancerPositionCallBackFunction(uint32_t IfIndex, uint32_t Re //stop this control loop DancerValueDirection = false; DancerId = 0xFF; - SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); + SafeRemoveControlCallback(MotorControlId[MotorId],MotorMoveToDancerPositionCallBackFunction ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 3d1ba6e78..e2c2b3b1c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -159,8 +159,8 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re DispenserControlId[DispenserId] = AddControlCallback(NULL, IDS_Dispenser_StopMotorCallback, CloseValveTimeout, TemplateDataReadCBFunction,DispenserId, DispenserId, 0 ); if (DispenserControlId[DispenserId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - else - Report("Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + //else + // Report("Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); 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 00d740c7e..d8db2c4a5 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -1299,7 +1299,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) //Task_sleep(5); PreSegmentWCFStarted = false; PreSegmentPrepareStarted = false; - REPORT_MSG(PreSegmentWCFStarted,"START IDSPresegmentPrepareStart"); + //REPORT_MSG(PreSegmentWCFStarted,"START IDSPresegmentPrepareStart"); // IDSPresegmentPrepareStart(); return OK; @@ -1458,7 +1458,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) #else Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Head); #endif - IDS_Cleaning_Stop_Cleaning_Solution(NULL); + //IDS_Cleaning_Stop_Cleaning_Solution(NULL); SegmentNumOfBrushStops = Segment->n_brushstops; BrushStopTime = Segment->length*1000/(double)SegmentNumOfBrushStops; //brushstop in meters //brushstop in millisecond BrushStopTime = ((BrushStopTime*100)/dyeingspeed);//brushstop in seconds diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h index 11ae5b008..36542a1a9 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h @@ -52,6 +52,7 @@ bool MidTankValvesAction(bool action); //Cartridge_MidTank_ON of Cartridge_MidTa bool ColorMatch(); bool IFS_TimeOutAlarm(bool status); void ResponseDemo(int MidtankId); +bool IFS_MidTankFilling(void); bool CartridgeValidationResponseFunc(MessageContainer* requestContainer); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 40000b8bb..25c36f3fd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -359,6 +359,7 @@ else { LoadStages++; + LoadStatus = OK; if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -558,6 +559,8 @@ CallbackCounter--; if (CallbackCounter == 0) { + LoadStatus = OK; + LoadStages++; if (LoadStages != THREAD_LOAD_INITIAL_TENSION) //on this satge we should wait for user call { @@ -681,7 +684,8 @@ //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); LengthCalculationMultiplier = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulleyradius*2*PI)/(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulseperround*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].microstep); TotalLoadedLen = 0; - SpeedTControlId = AddControlCallback(NULL,ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); + DrierPrevLocation = 200; //initial safe value + SpeedTControlId = AddControlCallback(ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); Tinitialpos = 0xFFFF;previousPosition = 0; currentPosition = 0; CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); @@ -709,12 +713,13 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); ThreadJoggingFunc(20); - LoadingControlId = AddControlCallback(NULL,Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } uint32_t Thread_Load_End(void) { REPORT_MSG(LoadStages,"Loading Ended"); + ThreadLoadingReport(); if(LoadingControlId != 0xFF) { MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); @@ -752,6 +757,7 @@ usnprintf(LoadErrorMsg, 100, "Load sequence stopped by user on stage %d",LoadStages); LoadStatus = ERROR; } + LoadStages = THREAD_LOAD_INIT; load.color = colorON; return OK; @@ -766,21 +772,19 @@ return OK; } Screw_Dir = 1-Screw_Dir; - status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,30000); + status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Screw_Dir, 80, screw[Screw_Dir], Thread_Load_switchCallback,13000); return OK; } uint32_t Thread_Load_Dryer_UnLoading_Callback(uint32_t MotorId, uint32_t ReadValue) { numberOfCycles++; - uint32_t temp = Control_Read_Dryer_Position(0,0); - Report("Thread_Load_Dryer_Loading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); - //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); - if ((abs (temp -DrierPrevLocation)>20 )&&(ReadValue == NOTBUSY)) + uint32_t temp = Read_Dryer_ENC_Position(); + Report("Thread_Load_Dryer_UnLoading_Callback",__FILE__,ReadValue,temp,RpMessage,DrierPrevLocation,0); + //Report("Thread_Load_Dryer_UnLoading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); + if ((abs (temp -DrierPrevLocation)>1000 )&&(ReadValue == NOTBUSY)) { DrierPrevLocation = temp; - //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); - //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); if (LoadStages != THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION) { return OK; @@ -801,7 +805,7 @@ { LOG_ERROR(LoadStages,"Load sequence timeout - drier Unloading"); Report("Store Number of cycles in drier - halted",__FILE__,__LINE__,numberOfCycles,RpMessage,LoadArmInfo.LoadArmRounds,0); - MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-numberOfCycles); + MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds-(numberOfCycles-2));//it takes two cycles to identify a stop of the arm TimeoutsCounter = 0; CallbackCounter = 0; if(PullerControlId != 0xFF) @@ -826,12 +830,14 @@ load.color = fastBILNK; usnprintf(LoadErrorMsg, 100, "Load sequence timeout %d motor %d",LoadStages, HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); LoadStatus = ERROR; + TryAgain = true; ThreadLoadingReport(); } return OK; } uint32_t Thread_Load_Dryer_UnLoading(void) { + uint32_t temp; REPORT_MSG(LoadStages, "Thread UnLoad State Machine step"); //LoadArmInfo.LoadArmRounds = 0; //uint32_t numberOfSteps = 0; @@ -899,9 +905,10 @@ numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/**LoadArmInfo.LoadArmRounds*/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; numberOfCycles = 0; - MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&DrierPrevLocation); - - Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,LoadStages,RpMessage, LoadArmInfo.LoadArmRounds,0); + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CENTER,&temp); + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); + DrierPrevLocation = temp; + Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,UnloadingStart,DrierPrevLocation,RpMessage, LoadArmInfo.LoadArmRounds,0); MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius); // status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), // MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); @@ -1002,7 +1009,6 @@ ThreadLoadingReport(); break; case THREAD_LOAD_END: - MessageState = 0; LoadStages = THREAD_LOAD_END; Thread_Load_End(); break; @@ -1025,23 +1031,27 @@ uint32_t ThreadLoadButton(THREAD_LOAD_STAGES_ENUM ReadValue) return ERROR; } Report("ThreadLoadButton",__FILE__,__LINE__,LoadStages,RpMessage,ReadValue,0); + Report("ThreadLoadButton params",__FILE__,LoadStatus,TryAgain,RpMessage,SecondTry,0); if (LoadStatus == ERROR) { if ((SecondTry == false)&&(TryAgain == true)) { LoadStatus = OK; SecondTry = true; + Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0); ThreadLoadStateMachine(LoadStages); } else { SecondTry = false; + Report("Calling State machine",__FILE__,LoadStages,LoadStatus,RpMessage,SecondTry,0); ThreadLoadStateMachine(LoadStages+1); } } else { - ThreadLoadStateMachine(ReadValue); + Report("Calling State machine status OK",__FILE__,ReadValue,LoadStatus,RpMessage,SecondTry,0); + ThreadLoadStateMachine(LoadStages); } return OK; } @@ -1145,7 +1155,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; - MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index f0b709ff2..78092ae2b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -61,6 +61,7 @@ static bool KeepWindingCone = false; static uint32_t WindingConeLocation; static uint32_t WinderBackToBaseTime = 800; +float NumberOfRotationPerPassage = 0.0; InternalWinderConfigStruc InternalWinderCfg = {0}; //#define READ_SCREW_ENCODER #ifdef READ_SCREW_ENCODER @@ -106,12 +107,17 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) InternalWinderCfg.spoolbackingrate = request->backingrate; InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*2;//request->rotationsperpassage; + InternalWinderCfg.NumberOfRotationPerPassage = 3.1415926*3;//request->rotationsperpassage; if (request->rotationsperpassage > 6.1) InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; + if (NumberOfRotationPerPassage > 1) + { + InternalWinderCfg.NumberOfRotationPerPassage = NumberOfRotationPerPassage; + Report("Rotation per passage set from stub",__FILE__,__LINE__,(int)(request->rotationsperpassage*1000),RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); + } InternalWinderCfg.diameter = request->diameter; usnprintf(ScrewStr, 150, "WindingConfig start,offset,head,tail {, %d, %d, %d, %d, %d}",InternalWinderCfg.startoffsetpulses,(int)InternalWinderCfg.segmentoffsetpulses, - (int)InternalWinderCfg.spoolbackingrate,(int)InternalWinderCfg.SpoolBottomBackingRate); + (int)InternalWinderCfg.spoolbackingrate,(int)InternalWinderCfg.SpoolBottomBackingRate,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000)); Report(ScrewStr,__FILE__,__LINE__,(int)InternalWinderCfg.diameter,RpWarning,(int)(InternalWinderCfg.NumberOfRotationPerPassage*1000), 0); return status; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index dd9395248..420b782b5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -42,6 +42,8 @@ uint32_t StoreDancerConfigMessage(void); uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); +extern float NumberOfRotationPerPassage; //debug for rotation per passage trials + uint32_t Winder_Init(void); uint32_t Winder_Prepare(void *JobDetails); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); -- cgit v1.3.1 From f070724e30040ae7cc3fada4c4492ed9e80f8106 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 6 Jan 2020 14:32:44 +0200 Subject: fixes, add dryer control support --- Software/Embedded_SW/Embedded/Modules/IFS/ifs.c | 2 +- .../Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c | 2 +- Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c | 6 +++--- Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c | 10 +++++++--- .../Embedded/StateMachines/Initialization/PowerOffSequence.c | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index 15117e616..78ae257ac 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -402,7 +402,7 @@ uint32_t MidTankReading(void) MidTankCounter = 0; if (IFS_info.Ink.time_out > 0) return ERROR; - MidTankReadControlId = AddControlCallback( MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + MidTankReadControlId = AddControlCallback("MidTankReading", MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c index a058d54f9..5dcabc576 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_FPGARWReg.c @@ -97,7 +97,7 @@ void Stub_FpgaWriteRegRequest(MessageContainer* requestContainer) ptr = (volatile short *) (request->address); if (request->address == (FPGA3_BASE | 0x3D0)) { - ctlId = AddControlCallback( ResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,ptr,ptr, 0 ); + ctlId = AddControlCallback("Reset", ResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,ptr,ptr, 0 ); } else *ptr = (request->value & 0xFFFF); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 25c36f3fd..0aff26320 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -685,7 +685,7 @@ LengthCalculationMultiplier = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulleyradius*2*PI)/(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].pulseperround*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDRIVING].microstep); TotalLoadedLen = 0; DrierPrevLocation = 200; //initial safe value - SpeedTControlId = AddControlCallback(ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); + SpeedTControlId = AddControlCallback("Thread length",ThreadLoadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+HARDWARE_MOTOR_TYPE__MOTO_RDRIVING),HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,0); Tinitialpos = 0xFFFF;previousPosition = 0; currentPosition = 0; CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); @@ -713,7 +713,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); ThreadJoggingFunc(20); - LoadingControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback("Load jog",Thread_Load_Jog_ThreadStop, eOneSecond*25,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } uint32_t Thread_Load_End(void) @@ -1155,7 +1155,7 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) NormalizedError = avreageSampleValue*NormalizedErrorCoEfficient[index]; MotorControlConfig[index].m_mesuredParam = NormalizedError; - MotorControlConfig[index].m_calculatedError = AdvancedPIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, + MotorControlConfig[index].m_calculatedError = PIDAlgorithmCalculation((float)MotorControlConfig[index].m_SetParam , (float)MotorControlConfig[index].m_mesuredParam, &MotorControlConfig[index].m_params, &MotorControlConfig[index].m_preError, &MotorControlConfig[index].m_integral); if (index != FEEDER_MOTOR) //feeder unit handles errors opposite to left unit { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 0a3a9e149..45ab2cb19 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -41,7 +41,11 @@ double CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM] = {0}; +#ifndef DRIER_CONTROL_TEST +TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,HARDWARE_MOTOR_TYPE__MOTO_WINDER,HARDWARE_MOTOR_TYPE__MOTO_SCREW}; +#else TimerMotors_t ThreadMotorIdToMotorId[MAX_THREAD_MOTORS_NUM] = {HARDWARE_MOTOR_TYPE__MOTO_RDRIVING,HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,HARDWARE_MOTOR_TYPE__MOTO_WINDER,HARDWARE_MOTOR_TYPE__MOTO_SCREW}; +#endif HardwareDancerType ThreadMotorIdToDancerId[MAX_THREAD_MOTORS_NUM] = {FEEDER_DANCER,NUM_OF_DANCERS,POOLER_DANCER,WINDER_DANCER,NUM_OF_DANCERS}; uint32_t ControlIdtoMotorId [MAX_THREAD_MOTORS_NUM] = {0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t SpeedControlId=0xFF; @@ -848,7 +852,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) } // if (HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled // AddControlCallback(ThreadSpeedControlCBFunction, eOneMillisecond,TemplateDataReadCBFunction,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],0); - if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled + if (Motor_i == ThreadMotorIdToMotorId[DRYER_MOTOR]) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled continue; } #ifdef TEST_PID_THREAD @@ -897,7 +901,7 @@ uint32_t ThreadDryerRampUp(uint32_t IfIndex, uint32_t BusyFlag) ControlIdtoMotorId[DRYER_MOTOR] = 0xFF; } - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); + MotorSetSpeed(ThreadMotorIdToMotorId[DRYER_MOTOR],InitialDryerSpeed ); //ReportWithPackageFilter(ThreadFilter,"ThreadDryerRampUp",__FILE__,ControlIdtoMotorId[DRYER_MOTOR],(int)InitialDryerSpeed,RpWarning,(int)OriginalMotorSpd_2PPS[DRYER_MOTOR],0); @@ -927,7 +931,7 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) DrierDivider = dyeingspeed/5; //ramp up drier in 5 cm/sec steps ReportWithPackageFilter(ThreadFilter,"Drier ramp up",__FILE__,__LINE__,(int)dyeingspeed,RpWarning,(int)DrierDivider,0); InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]/DrierDivider; - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); + MotorSetSpeed(ThreadMotorIdToMotorId[DRYER_MOTOR],InitialDryerSpeed ); ControlIdtoMotorId[DRYER_MOTOR] = AddControlCallback("DryerRampUp",ThreadDryerRampUp, 200,TemplateDataReadCBFunction,0,0,0); #endif #ifdef HUNDRED_MICROSECONDS_DANCER_READ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index 1fb77a540..e1866a6d9 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -653,7 +653,7 @@ uint32_t AbortPowerDownFunc(MessageContainer* requestContainer) SendChars((char*)container_buffer, container_size); PowerDownUpdate(POWER_OFF_CANCELLED); - ctlId = AddControlCallback( AbortPowerDownResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + ctlId = AddControlCallback("Abort", AbortPowerDownResetCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); Report("HWSystemResetRequest", __FILE__,__LINE__,0, RpMessage, 2, 0); -- cgit v1.3.1