From f952ee0e6e7ca0633d49ad1da9e209a0a3aa4621 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 1 Aug 2018 18:03:18 +0300 Subject: handle heater off command, improves screw speed, improve diagnostics --- .../Embedded/Modules/Control/MillisecTask.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 83c20f769..28cdc3702 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -12,7 +12,7 @@ ////////////////////////////////State machine operation//////////////////////////////////// //the state machine operation is used to operate in runtime correct profile flow execution -//by recieved esign flow of the user from the UI +//by recieved design flow of the user from the UI /////////////////////////////////////////////////////////////////////////////////////////// #include "include.h" #include "Modules/General/GeneralHardware.h" @@ -269,11 +269,12 @@ uint32_t MillisecLoop(uint32_t tick) //call all modules Millisec functions //test dancers and speed encoders //check all callback units (state machine waiting for completion of a change) - bool Ten_msTick, Hundred_msTick, Onesecond_Tick,O900Millisecond_Tick; + bool Ten_msTick, Hundred_msTick, Onesecond_Tick,O900Millisecond_Tick,Tick98; Ten_msTick = (tick%eTenMillisecond == 0) ?true:false; Hundred_msTick = (tick%eHundredMillisecond == 0) ?true:false; O900Millisecond_Tick = (tick%eOneSecond == 900) ?true:false; Onesecond_Tick = (tick%eOneSecond == 0) ?true:false; + Tick98 = (tick%eHundredMillisecond == 99) ?true:false; //gather Motor data from FPGA //ROM_IntMasterDisable(); @@ -386,10 +387,23 @@ uint32_t MillisecLoop(uint32_t tick) { Speed_Data = Read_Speed_Sensor(); } + if (Tick98) + { + //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); + //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); + //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); + //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_WINDER); + //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_SCREW); + } if (Hundred_msTick) { for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) MillisecReadFromTempSensor(Sensor_i, NULL); + //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); + //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); + //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); + //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_WINDER); + //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_SCREW); } if (O900Millisecond_Tick) -- cgit v1.3.1 From 4bbece442e2699e88a090de1df07e2295d4fdad8 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 1 Aug 2018 18:48:10 +0300 Subject: fix heaters off command. fix memory leak --- .../Embedded/Modules/Control/MillisecTask.c | 24 +++++++++++----------- .../Embedded/Modules/Heaters/Heaters_print.c | 10 +++++---- .../Embedded/Modules/Thread/Thread_Winder.c | 3 ++- .../Embedded/Modules/Thread/Thread_print.c | 6 +++--- 4 files changed, 23 insertions(+), 20 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 28cdc3702..8243c5faa 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -226,7 +226,7 @@ int32_t MillisecWriteToMotor(TimerMotors_t MotorId, unsigned long Data, int Leng MSBacklog[MsecLogindex]=Data; Motor_Id[MsecLogindex]=MotorId; MsecLogindex++; - if (MsecLogindex>=999) + if (MsecLogindex>=199) MsecLogindex = 0; //========================== if (MotorId >= NUM_OF_MOTORS) return -1; @@ -247,7 +247,7 @@ int32_t MillisecReadFromMotor(TimerMotors_t MotorId, unsigned long Data, int Len MSBacklog[MsecLogindex]=Data; Motor_Id[MsecLogindex]=MotorId; MsecLogindex++; - if (MsecLogindex>=999) + if (MsecLogindex>=199) MsecLogindex = 0; //========================== MotorActivity++; @@ -389,21 +389,21 @@ uint32_t MillisecLoop(uint32_t tick) } if (Tick98) { - //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); - //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); - //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); - //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_WINDER); - //MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_SCREW); + MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); + MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); + MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); + MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_WINDER); + MotorGetSpeedFromFPGA(HARDWARE_MOTOR_TYPE__MOTO_SCREW); } if (Hundred_msTick) { for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) MillisecReadFromTempSensor(Sensor_i, NULL); - //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); - //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); - //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); - //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_WINDER); - //MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_SCREW); + MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); + MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); + MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); + MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_WINDER); + MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_SCREW); } if (O900Millisecond_Tick) diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index d8cfdb846..ff033dbda 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -231,17 +231,19 @@ uint32_t HeaterCommandRequestMessage(int HeaterId, bool OnOff, int Temperature) //set the target operation temperature //set the heater operation mode to fast heating - depended on the current temperature } - else if ((HeaterState == HEATER_ON)&& (OnOff == HEATER_OFF)) //stop heating + else if (OnOff == HEATER_OFF)//((HeaterState == HEATER_ON)&& (OnOff == HEATER_OFF)) //stop heating { //turn off the heater HeatersSingleHeaterEnd(HeaterId); //stop the control HeaterPIDConfig[HeaterId].m_SetParam = 0; } - /*else + /*else //heater off, and the heater is not ready yet { - LOG_ERROR (OnOff, "unsupported command id"); - return ERROR; + //turn off the heater + HeatersSingleHeaterEnd(HeaterId); + //stop the control + HeaterPIDConfig[HeaterId].m_SetParam = 0; }*/ return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 30cbd4db3..794559d57 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -225,7 +225,7 @@ uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { ScrewCurrentDirection = false; } - if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) +/* if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) { ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); Steps += InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; @@ -236,6 +236,7 @@ uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) ScrewCurrentDirection = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); REPORT_MSG(LIMIT, "Winder at left limit"); } +*/ MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,Steps); //process: set point 0, set max speed, move to the specified length, return back. } /* diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 75d54ef02..8d1ea20fa 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -127,8 +127,8 @@ void ThreadUpdateProcessLength (double length, void *Funcptr) ProcessedLengthFuncPtr = (ProcessedLengthFunc)Funcptr; initialpos = 0xFFFF; } -double MotorSentData[100] = {0}; -uint32_t PosDif[100] = {0}; +double MotorSentData[102] = {0}; +uint32_t PosDif[102] = {0}; int MotorDataIndex = 0; @@ -181,7 +181,7 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) //PosDif[MotorDataIndex] = positionDiff; MotorSentData[MotorDataIndex] = length; MotorDataIndex+=1; - if (MotorDataIndex == 99) MotorDataIndex = 0; + if (MotorDataIndex >= 97) MotorDataIndex = 0; static int pooler_counter = 0; pooler_counter++; TotalProcessedLength+= (length/100); -- cgit v1.3.1