From 2a19f41441d85f9c3903cadcf6505ebcb72089d1 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 16 Sep 2018 10:27:06 +0300 Subject: reduce polling of motor status. changed speed sensor to 100msec --- .../Embedded/Modules/Control/MillisecTask.c | 21 ++++++++++++++------- .../Embedded_SW/Embedded/Modules/Control/control.h | 3 ++- 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control') diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 177a3678f..4a864152f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -273,11 +273,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,Tick98; + bool Ten_msTick, Hundred_msTick, Onesecond_Tick,O900Millisecond_Tick,Tick98,OneMinute_Tick; 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; + OneMinute_Tick = (tick%eOneMinute == 0) ?true:false; Tick98 = (tick%eHundredMillisecond == 99) ?true:false; //gather Motor data from FPGA //ROM_IntMasterDisable(); @@ -371,12 +372,13 @@ uint32_t MillisecLoop(uint32_t tick) Dancer_Data[WINDER_DANCER] = Read_Dancer_Position(WINDER_DANCER); if (Ten_msTick) { - Speed_Data = Calculate_Speed_Sensor_Velocity(); +// Speed_Data = Calculate_Speed_Sensor_Velocity(); //MillisecReadFromTempSensor(Sensor_Read, NULL); //if (Sensor_Read++ >= MAX_TEMPERATURE_SENSOR_ID) Sensor_Read = 0; } if (Hundred_msTick) { + Speed_Data = Calculate_Speed_Sensor_Velocity(); for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { MillisecReadFromTempSensor(Sensor_i, NULL); @@ -393,11 +395,6 @@ uint32_t MillisecLoop(uint32_t tick) { CalculateDispenserPressure(Disp_i); } - for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) - { - if (isMotorConfigured(Motor_i)) - MotorGetStatusFromFPGA(Motor_i); - } FPGA_GetAllDispensersValveBusyOCD(); if (watchdogCriticalAlarm == false) { @@ -405,6 +402,16 @@ uint32_t MillisecLoop(uint32_t tick) } DrawerFansStatus = Read_Fans_Tacho(); } + if (OneMinute_Tick) + { + for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) + { + if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_SCREW) + continue; // + if (isMotorConfigured(Motor_i)) + MotorGetStatusFromFPGA(Motor_i); + } + } //ROM_IntMasterEnable(); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index d032c7bd1..0aba4b4ba 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -18,7 +18,8 @@ typedef enum { eOneMillisecond = 1, eTenMillisecond = 10, eHundredMillisecond = 100, - eOneSecond = 1000 + eOneSecond = 1000, + eOneMinute = 60000 }CTRL_TIMING_ENUM; typedef enum { -- cgit v1.3.1 From 871eedf7a346206c670f8032c85b4f90872f490f Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 17 Sep 2018 09:34:52 +0300 Subject: tests for the winder --- .../Embedded/Drivers/FPGA/FPGA_SPI_Comm.c | 5 ++- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c | 5 +++ .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h | 1 + .../Embedded/Modules/Control/MillisecTask.c | 40 ++++++++++++++++++++-- .../Embedded/Modules/Control/MillisecTask.h | 1 + .../Embedded/Modules/Diagnostics/Diagnostics.c | 6 ++-- 6 files changed, 53 insertions(+), 5 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control') diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 556843e98..1140027c2 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -650,7 +650,10 @@ void FPGA_SetMotPosition(TimerMotors_t _motorId)//Mov Fpga_Spi[_motorId].TX_MOSI = temp; //Fpga_Spi[_motorId].AMT_OF_Words = 4; - MillisecWriteToMotor(_motorId, temp, 4, NULL); + if (_motorId == HARDWARE_MOTOR_TYPE__MOTO_SCREW) + MillisecMoveScrew(temp, 4, NULL); + else + MillisecWriteToMotor(_motorId, temp, 4, NULL); // FPGA_SPI_Transnit(_motorId); } diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c index 330ffb2a8..ca9f1df90 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c @@ -169,6 +169,11 @@ uint32_t Read_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7 return Status; } +double Get_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7 +{ + assert (MidTank_ID=199) + MsecLogindex = 0; + //========================== + + ScrewMovePending.Callback = Callback; + ScrewMovePending.Data = Data; + ScrewMovePending.Length = Length; + ScrewMovePending.DataRequired = false; + if (ScrewMovePending.Active == false) + { + MotorActivity++; + ScrewMovePending.Active = true; + } + + return OK; +} int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback) { if (MotorId >= NUM_OF_MOTORS) return -1; @@ -309,6 +332,15 @@ uint32_t MillisecLoop(uint32_t tick) } MotorActivity--; } + if (ScrewMovePending.Active == true) + { + MotorSendFPGARequest(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewMovePending.Data,ScrewMovePending.Length); + MotorActivity--; + ScrewMovePending.Active = false; + if (ScrewMovePending.Callback) + ScrewMovePending.Callback(Motor_i,0); + + } if (SpeedSetPending[Motor_i].Active == true) { MotorSendFPGARequest((HardwareMotorType)Motor_i,SpeedSetPending[Motor_i].Data,SpeedSetPending[Motor_i].Length); @@ -372,13 +404,13 @@ uint32_t MillisecLoop(uint32_t tick) Dancer_Data[WINDER_DANCER] = Read_Dancer_Position(WINDER_DANCER); if (Ten_msTick) { -// Speed_Data = Calculate_Speed_Sensor_Velocity(); + Speed_Data = Calculate_Speed_Sensor_Velocity(); //MillisecReadFromTempSensor(Sensor_Read, NULL); //if (Sensor_Read++ >= MAX_TEMPERATURE_SENSOR_ID) Sensor_Read = 0; } if (Hundred_msTick) { - Speed_Data = Calculate_Speed_Sensor_Velocity(); +// Speed_Data = Calculate_Speed_Sensor_Velocity(); for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { MillisecReadFromTempSensor(Sensor_i, NULL); @@ -404,6 +436,10 @@ uint32_t MillisecLoop(uint32_t tick) } if (OneMinute_Tick) { + for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) + { + Read_MidTank_Pressure_Sensor(i); + } for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) { if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_SCREW) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index 1c1989c1e..fe46018dc 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -15,6 +15,7 @@ typedef uint32_t (* MSecFptr)(uint32_t deviceID, uint32_t ReadValue); int32_t MillisecWriteToMotor(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback); +int32_t MillisecMoveScrew(unsigned long Data, int Length, MSecFptr Callback); int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback); int32_t MillisecReadFromMotor(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback); int MillisecFlushMsgQ(TimerMotors_t MotorId); diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 6355674cf..644918394 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -20,7 +20,7 @@ #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include "drivers/FPGA/FPGA.h" - +#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "modules/ids/ids_ex.h" #include "Modules/Control/MillisecTask.h" #include "Modules/General/GeneralHardware.h" @@ -87,6 +87,7 @@ double dryerzone3temperature[DIAGNOSTICS_LIMIT]; double dispensermotorfrequency[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT]; double dispenserspressure[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT]; +double MidTankpressure[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT]; DoubleArray DispenserFreq[MAX_SYSTEM_DISPENSERS]; DoubleArray DiagnosticsDispenserPressure[MAX_SYSTEM_DISPENSERS]; @@ -316,7 +317,8 @@ void Diagnostic100msecCollection(void) for (i=0;i Date: Mon, 17 Sep 2018 14:22:31 +0300 Subject: priority for screw run commands (set max speed and move) --- .../Embedded/Drivers/FPGA/FPGA_SPI_Comm.c | 5 ++- .../Embedded/Modules/Control/MillisecTask.c | 38 ++++++++++++++++++++-- .../Embedded/Modules/Control/MillisecTask.h | 1 + .../Embedded/Modules/Diagnostics/Diagnostics.c | 4 +-- .../Embedded/Modules/Thread/Thread_print.c | 4 +++ 5 files changed, 47 insertions(+), 5 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Control') diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 1140027c2..ed0deadee 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -609,7 +609,10 @@ void FPGA_SetMotMaxSpeed(TimerMotors_t _motorId)//Mov speed_calc = 0x3FF; temp |= speed_calc<<8; - MillisecWriteToMotor(_motorId, temp, 4, NULL); + if (_motorId == HARDWARE_MOTOR_TYPE__MOTO_SCREW) + MillisecSetScrewSpeed(temp, 4, NULL); + else + MillisecWriteToMotor(_motorId, temp, 4, NULL); } diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index e1f8a593a..6f234e26a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -77,6 +77,7 @@ uint32_t DrawerFansStatus = 0; bool watchdogCriticalAlarm = false; +MillisecMotorDataStruc ScrewSetMaxSpeedPending = {0}; MillisecMotorDataStruc ScrewMovePending = {0}; MillisecMotorDataStruc MotorData[NUM_OF_MOTORS] = {0}; MillisecMotorDataStruc SpeedSetPending[NUM_OF_MOTORS] = {0}; @@ -209,6 +210,29 @@ int32_t MillisecMoveScrew(unsigned long Data, int Length, MSecFptr Callback) return OK; } + +int32_t MillisecSetScrewSpeed(unsigned long Data, int Length, MSecFptr Callback) +{ + //========================== + MSBacklog[MsecLogindex]=Data; + Motor_Id[MsecLogindex]=HARDWARE_MOTOR_TYPE__MOTO_SCREW; + MsecLogindex++; + if (MsecLogindex>=199) + MsecLogindex = 0; + //========================== + + ScrewSetMaxSpeedPending.Callback = Callback; + ScrewSetMaxSpeedPending.Data = Data; + ScrewSetMaxSpeedPending.Length = Length; + ScrewSetMaxSpeedPending.DataRequired = false; + if (ScrewSetMaxSpeedPending.Active == false) + { + MotorActivity++; + ScrewSetMaxSpeedPending.Active = true; + } + + return OK; +} int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback) { if (MotorId >= NUM_OF_MOTORS) return -1; @@ -332,7 +356,17 @@ uint32_t MillisecLoop(uint32_t tick) } MotorActivity--; } - if (ScrewMovePending.Active == true) + + if (ScrewSetMaxSpeedPending.Active == true) + { + MotorSendFPGARequest(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSetMaxSpeedPending.Data,ScrewSetMaxSpeedPending.Length); + MotorActivity--; + ScrewSetMaxSpeedPending.Active = false; + if (ScrewSetMaxSpeedPending.Callback) + ScrewSetMaxSpeedPending.Callback(Motor_i,0); + + } + else if (ScrewMovePending.Active == true) { MotorSendFPGARequest(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewMovePending.Data,ScrewMovePending.Length); MotorActivity--; @@ -438,7 +472,7 @@ uint32_t MillisecLoop(uint32_t tick) { for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) { - Read_MidTank_Pressure_Sensor(i); + Read_MidTank_Pressure_Sensor(Disp_i); } for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) { diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h index fe46018dc..517716c08 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.h @@ -16,6 +16,7 @@ typedef uint32_t (* MSecFptr)(uint32_t deviceID, uint32_t ReadValue); int32_t MillisecWriteToMotor(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback); int32_t MillisecMoveScrew(unsigned long Data, int Length, MSecFptr Callback); +int32_t MillisecSetScrewSpeed(unsigned long Data, int Length, MSecFptr Callback); int32_t MillisecSetMotorSpeed(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback); int32_t MillisecReadFromMotor(TimerMotors_t MotorId, unsigned long Data, int Length, MSecFptr Callback); int MillisecFlushMsgQ(TimerMotors_t MotorId); diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 644918394..934467277 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -249,7 +249,7 @@ void DiagnosticTenMsecCollection(void) DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0,0)); DiagnosticLoadDancer(POOLER_DANCER,Control_Read_Dancer_Position(POOLER_DANCER, 0,0)); DiagnosticLoadDancer(FEEDER_DANCER,Control_Read_Dancer_Position(FEEDER_DANCER, 0,0)); -// DiagnosticLoadSpeedSensor(getSensorSpeedData()); + DiagnosticLoadSpeedSensor(getSensorSpeedData()); } void Diagnostic100msecCollection(void) @@ -261,7 +261,7 @@ void Diagnostic100msecCollection(void) // dancer1angle[DiagnosticsIndex] = Control_Read_Dancer_Position(WINDER_DANCER, 0,0); // dancer2angle[DiagnosticsIndex] = Control_Read_Dancer_Position(POOLER_DANCER, 0,0); // dancer3angle[DiagnosticsIndex] = Control_Read_Dancer_Position(FEEDER_DANCER, 0,0); - DiagnosticLoadSpeedSensor(getSensorSpeedData()); + //if (JobIsActive()) { /* DiagnosticLoadMotor(FEEDER_MOTOR, MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)); ThreadGetMotorSpeed diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 0272255a5..c7d5998c6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -317,6 +317,9 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) if (ThreadControlActive == false) return OK; + if (PrepareState == true) + return OK; + if (IfIndex>>8 != IfTypeThread) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -584,6 +587,7 @@ uint32_t ThreadPreSegmentState(void *JobDetails) LOG_ERROR (dyeingspeed," job speed zero"); return ERROR; } + LOG_ERROR (dyeingspeed," ThreadPreSegmentState"); SetOriginMotorSpeed(process_speed); ThreadControlActive = true; -- cgit v1.3.1