From 8d4920307ed4bbb6760245728934b91e249fe6c4 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 13 Nov 2018 10:41:45 +0200 Subject: prevent sending diagnostics message if the prev one did not run. improve winding --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new index f33a134e1..537d27775 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new @@ -177,14 +177,14 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) float screw_horizontal_speed = 0; float RotationsPerSecond; - if (Counter%InternalWinderCfg.spoolbackingrate == 0) + if (Counter%InternalWinderCfg.spoolbackingrate == 1) { NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); ScrewNumberOfSteps--; screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage; // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; + RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; @@ -194,7 +194,7 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; } - if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)) + if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) { if (direction != MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) { -- cgit v1.3.1 From aeacbdabd448b2e7455e16460b996c8090731d9d Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 15 Nov 2018 14:54:51 +0200 Subject: many logs. improve job handling and IDS. NEW WINDER ALGORITHM (Interrupts) --- .../Embedded/Common/report/distributor.c | 2 +- .../Embedded/Communication/CommunicationTask.c | 2 +- .../Embedded/Drivers/Flash_Memory/Flash_Memory.c | 2 +- .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 2 + .../Embedded_SW/Embedded/Drivers/Valves/Valve.c | 16 +- Software/Embedded_SW/Embedded/Include.h | 2 +- .../Embedded_SW/Embedded/Modules/Control/control.c | 13 +- .../Embedded/Modules/Diagnostics/Diagnostics.c | 37 ++-- .../Embedded/Modules/Heaters/Heaters_print.c | 8 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 20 ++- .../Embedded/Modules/Thread/Thread_Winder.c | 194 +++++++++++++-------- .../Embedded/Modules/Thread/Thread_print.c | 14 +- .../Embedded/StateMachines/Printing/JobSTM.c | 10 +- .../Embedded/StateMachines/Printing/PrintingSTM.c | 3 +- 14 files changed, 212 insertions(+), 113 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c index cbc754a7e..a7fe93862 100644 --- a/Software/Embedded_SW/Embedded/Common/report/distributor.c +++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c @@ -240,7 +240,7 @@ Void reportService(UArg arg0, UArg arg1) int DistTableEntry;//,msgLen, errCode, par1, par2; ReportInitParams InitParams; - InitParams.DistributorQueueMaxMsgs = 15; + InitParams.DistributorQueueMaxMsgs = 25; InitParams.DistributorTaskPriority = 6; InitParams.MaxNumOfFilterNames = 1; InitParams.MaxNumberOfPrivateDistributors = 2; diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index b27ab687d..9711cebb3 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -15,7 +15,7 @@ static void (*callback)(char* buffer, size_t length); Mailbox_Handle CommunicationRxMsgQ = NULL; Mailbox_Handle CommunicationTxMsgQ = NULL; -#define COMMUNICATION_NUM_MSGS 20 +#define COMMUNICATION_NUM_MSGS 40 typedef struct CommRxMessage{ //uint16_t messageId; uint16_t msgSize; diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c index 28b466ffe..80d532b58 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c +++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/Flash_Memory.c @@ -390,7 +390,7 @@ return 0; } #ifdef EVALUATION_BOARD -int Init_Ext_Flash() +int Init_SSI_Ext_Flash() { uint32_t pui32Dummy[1]; uint32_t ui32SysClockFreq; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index 8374133a7..780e2ede3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -488,6 +488,8 @@ uint32_t MotorMovetoLimitSwitch (TimerMotors_t _motorId,bool direction, uint32_t MotorSetDirection( _motorId, direction); MotorSetSpeed(_motorId, Freq); MotorMovetoLimitSwitchControlId[_motorId] = AddControlCallback( MotorMoveToLimitSwitchCallBackFunction, eOneMillisecond , FPGA_Read_limit_Switches,(IfTypeMotors*0x100+_motorId), LimitSwitchId, 0 ); + if ( MotorMovetoLimitSwitchControlId[_motorId] == 0xFF) + return ERROR; MotorMovetoLimitSwitchCallback[_motorId] = callback; return OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index c2dca51cd..5ae8a5ad3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -338,13 +338,19 @@ uint32_t Valve3WayCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { EnableDisableDispenserValve((Valves_t)ValveId, DISABLE); //stop this control loop - RemoveControlCallback(Valve3WayControlId[ValveId], Valve3WayCallBackFunction ); + if (RemoveControlCallback(Valve3WayControlId[ValveId], Valve3WayCallBackFunction )==OK) + Valve3WayControlId[ValveId] == 0xFF; + + //LOG_ERROR(Valve3WayControlId[ValveId], "Remove control callback"); //call the module callback if (Valve3WayModuleCallback[ValveId]) Valve3WayModuleCallback[ValveId](ValveId,BusyFlag); Valve3WayModuleCallback[ValveId] = NULL; } + //else + // LOG_ERROR (ValveId, "Valve busy"); + return OK; } @@ -354,14 +360,18 @@ uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callb Valve3WayModuleCallback[_ValveId] = callback; + Valve3WayControlId[_ValveId] = AddControlCallback( Valve3WayCallBackFunction, eTenMillisecond, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); + /*if (Valve3WayControlId[_ValveId] == 0xFF) + LOG_ERROR(_ValveId, "Add control callback failed"); + else + LOG_ERROR(_ValveId, "Add control callback");*/ + EnableDisableDispenserValve(_ValveId, ENABLE); SysCtlDelay(1);//Need Small delay (0.1-1)ms Valve_Set(_ValveId, direction); - Valve3WayControlId[_ValveId] = AddControlCallback( Valve3WayCallBackFunction, eTenMillisecond, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); - return Valve3WayControlId[_ValveId]; } diff --git a/Software/Embedded_SW/Embedded/Include.h b/Software/Embedded_SW/Embedded/Include.h index d99971021..6fe485b1e 100644 --- a/Software/Embedded_SW/Embedded/Include.h +++ b/Software/Embedded_SW/Embedded/Include.h @@ -56,7 +56,7 @@ #define PI 3.1415926 -#define COMM_MAX_BUFFER_SIZE 4000 +#define COMM_MAX_BUFFER_SIZE 6000 typedef uint32_t (* callback_fptr)(uint32_t deviceID, uint32_t ReadValue); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 78cdd5324..2110029e4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -202,7 +202,7 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF unsigned int key; uint32_t device_i; - uint32_t deviceId = 0xFFFFFFFF; + uint32_t deviceId = 0xFF; for(device_i = 0;device_i < MAX_TANGO_CONTROL_DEVICES;device_i++) { if (ControlArray[device_i].ControlActive == false) @@ -211,8 +211,8 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF break; } } - if (deviceId == 0xFFFFFFFF) - return 0xFFFFFFFF; + if (deviceId == 0xFF) + return 0xFF; key = GateMutex_enter(gateControlDB); ControlArray[deviceId].ControlTiming = CtrlFrequency; ControlArray[deviceId].ControlCallbackPtr = Callback; @@ -221,6 +221,7 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF ControlArray[deviceId].Parameter1 = Parameter1; ControlArray[deviceId].IfIndex = IfIndex; GateMutex_leave(gateControlDB, key); + //LOG_ERROR(deviceId, "Add Callback"); return deviceId; @@ -239,11 +240,17 @@ int RemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback) ControlArray[deviceId].ControlCallbackPtr = NULL; ControlArray[deviceId].ControlDataReadPtr = NULL; ControlArray[deviceId].ControlActive = false; + ControlArray[deviceId].Parameter1 = 0; + ControlArray[deviceId].IfIndex = 0; + //LOG_ERROR(deviceId, "Remove Callback "); GateMutex_leave(gateControlDB, key); return OK; } else + { + LOG_ERROR(deviceId, "Remove Callback failed"); return ERROR; + } } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 01e683dae..50d5f2093 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -60,7 +60,7 @@ DiagnosticsMonitors DiagnosticsMonitor = DIAGNOSTICS_MONITORS__INIT; #define DIAGNOSTICS_LIMIT 5 #define DIAGNOSTICS_DANCER_LIMIT 50 int DiagnosticsIndex = 0; -int DiagnosticCollectionLimit = 3; //number of data samples to collect before sending to the host +int DiagnosticCollectionLimit = 2; //number of data samples to collect before sending to the host //int DiagnosticLimit = eHundredMillisecond; //frequency of data collection //int DiagnosticFastLimit = eTenMillisecond; //frequency of data collection int DiagnosticLimit =eHundredMillisecond; //frequency of data collection @@ -249,9 +249,10 @@ void DiagnosticLoadTemperature(int HeaterId, int temperature) void DiagnosticLoadSpeedSensor(float value) { SpeedValue[SpeedCounterIndex] = (double)(value); - SpeedCounterIndex++; - if (SpeedCounterIndex>=DIAGNOSTICS_DANCER_LIMIT ) - SpeedCounterIndex = 0; + if (SpeedCounterIndex=DIAGNOSTICS_DANCER_LIMIT ) + // SpeedCounterIndex = 0; } void DiagnosticLoadDancer(int DancerId, uint16_t value) @@ -262,9 +263,10 @@ void DiagnosticLoadDancer(int DancerId, uint16_t value) return; } DancerValue[DancerId][DancerCounterIndex[DancerId]] = value; - DancerCounterIndex[DancerId]++; - if (DancerCounterIndex[DancerId]>=DIAGNOSTICS_DANCER_LIMIT ) - DancerCounterIndex[DancerId] = 0; + if (DancerCounterIndex[DancerId]=DIAGNOSTICS_DANCER_LIMIT ) + // DancerCounterIndex[DancerId] = 0; } void DiagnosticLoadDancerError(int DancerId, double value) { @@ -274,9 +276,10 @@ void DiagnosticLoadDancerError(int DancerId, double value) return; } DancerErrorValue[DancerId][DancerErrorCounterIndex[DancerId]] = value; - DancerErrorCounterIndex[DancerId]++; - if (DancerErrorCounterIndex[DancerId]>=DIAGNOSTICS_DANCER_LIMIT ) - DancerErrorCounterIndex[DancerId] = 0; + if (DancerErrorCounterIndex[DancerId]=DIAGNOSTICS_DANCER_LIMIT ) + // DancerErrorCounterIndex[DancerId] = 0; } void DiagnosticTenMsecCollection(void) @@ -587,20 +590,20 @@ void SendDiagnostics(void) { DiagnosticsStop(); } - else + /*else { Report("Diagnostic Messgage",__FILE__,__LINE__,container_size,RpWarning,msec_millisecondCounter, msec_millisecondCounter); - } - diag_size[diag_index] = container_size; - diag_time[diag_index] = msec_millisecondCounter; - if (diag_index++>=MAX_DIAG_LOG) - diag_index = 0; + }*/ + //diag_size[diag_index] = container_size; + //diag_time[diag_index] = msec_millisecondCounter; + //if (diag_index++>=MAX_DIAG_LOG) + // diag_index = 0; } else { LOG_ERROR(Task_self(),"my_malloc failed"); DiagnosticsStop(); - CommunicationMailboxFlush(); + //CommunicationMailboxFlush(); } } else diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 6222378bb..0e4466d81 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -358,7 +358,13 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) #endif InitialHeating = true; HeaterReady[HeaterId] = false; - Turn_the_Blower_Off(); + if (BlowerCfg.enabled == true) + { + Turn_the_Blower_On();//Turn on with the Default_Voltage + if (BlowerCfg.voltage) + Control_Voltage_To_Blower(BlowerCfg.voltage-500); + + } } /* if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain) //Dryer Heaters { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 64855daed..57b346513 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -192,11 +192,11 @@ bool IDS_isDispenserUsedNextSegment(void *JobDetails,int DispenserId, int Segmen { if (DispenserPreSegmentReady[i] == false) { - REPORT_MSG(i,"IDS_Valve_Presegment Not Ready"); + //REPORT_MSG(i,"IDS_Valve_Presegment Not Ready"); return OK; //not all configured heaters are ready } } - REPORT_MSG(deviceID,"IDS_Valve_PresegmentReady"); + //REPORT_MSG(deviceID,"IDS_Valve_PresegmentReady"); PreSegmentReady(Module_IDS,ModuleDone); return OK; // all configured heaters are ready } @@ -233,14 +233,23 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) { n_dispensers = JobTicket->segments[SegmentId]->brushstops[JobBrushStopId]->n_dispensers; for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) + { + //prepare the SW structures + DispenserId = JobTicket->segments[SegmentId]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->index; + DispenserPreSegmentReady[DispenserId] = false; + LOG_ERROR(DispenserId,"Dispenser PreSegment Start"); + } + for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) { DispenserId = JobTicket->segments[SegmentId]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->index; HW_Motor_Id = DispenserIdToMotorId[DispenserId]; if (MotorsCfg[HW_Motor_Id].hardwaremotortype != DispenserIdToMotorId[DispenserId])//unconfigured dispenser + { + LOG_ERROR(DispenserId,"Dispenser PreSegment not configured"); continue; - DispenserPreSegmentReady[DispenserId] = false; - LOG_ERROR(DispenserId,"Dispenser PreSegment Start"); - if (IDS_isDispenserUsedNextSegment(JobDetails,DispenserId,SegmentId) == false) + } + if (JobTicket->segments[SegmentId]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond==0) + //if (IDS_isDispenserUsedNextSegment(JobDetails,Dispenser_i,SegmentId) == false) { Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, IDS_Valve_PresegmentReady); //direction: MidTank_Dispenser or Dispenser_Mixer LOG_ERROR(DispenserId,"Dispenser Not Used Next Segment"); @@ -258,7 +267,6 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) MotorSetMicroStep(HW_Motor_Id,JobTicket->segments[SegmentId]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); else*/ //MotorSetMicroStep(HW_Motor_Id,MotorsCfg[HW_Motor_Id].microstep); - } } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index ce4395e0f..305c0e767 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -21,23 +21,35 @@ #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +#include +#include +#include + + bool Winder_ScrewHoming = false; -bool Winder_Active = false; uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag); uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue); bool ScrewCurrentDirection = false; //holds current screw direction bool BusyfirstCall = true; //Ignores first call after activating the screw - too early -double ScrewSpeed = 0; //ScrewSpeed +double ScrewSpeed = 0; +double ScrewRunningTime = 0; +bool ScrewDirection = false; +bool SCREW_TimerActivated = false; +//ScrewSpeed uint32_t ScrewControlId = 0xFF; uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone uint32_t DirectionChangeCounter = 0; //holds the current number of runs of the screw - will be used to build the cone InternalWinderConfigStruc InternalWinderCfg = {0}; +void ScrewTimerInterruptInit(void); +void ScrewsStopControlTimer (void); +void ScrewsStartControlTimer (void); uint32_t Winder_Init(void) { + ScrewTimerInterruptInit(); return OK; } @@ -73,9 +85,9 @@ uint32_t Winder_Prepare(void) { uint32_t status = 0; //JobTicket* JobTicket = JobDetails; - Winder_Active = true; //float process_speed = JobTicket->processparameters->dyeingspeed; - double ScrewSpeed = 1000;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now + double ScrewSpeed = 1500;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now + //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); /* * 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. @@ -84,12 +96,12 @@ uint32_t Winder_Prepare(void) */ if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) { - REPORT_MSG(LIMIT, "Winder_Prepare at limit"); + //REPORT_MSG(LIMIT, "Winder_Prepare at limit"); Winder_PrepareStage2(0,0); } else { - REPORT_MSG(ScrewSpeed, "Winder_Prepare"); + //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); Winder_ScrewHoming = true; //REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit"); status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2); @@ -107,7 +119,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) uint32_t status=OK; uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*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"); REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2"); @@ -119,16 +131,15 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) { - SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home + //SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home + //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency); ScrewCurrentDirection = false; - BusyfirstCall = true; ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; DirectionChangeCounter = 0; REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); - PrepareReady(Module_Winder, ModuleDone); return OK; } @@ -136,15 +147,6 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) /* * this is the main operational function of the screw - run back and forth until stopped */ -/* - -bool ScrewCurrentDirection = false; -bool BusyfirstCall = true; -double ScrewSpeed = 0; -uint32_t ScrewControlId = 0xFF; -uint32_t ScrewNumberOfSteps = 0; -uint32_t DirectionChangeCounter = 0; -*/ /* InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses; InternalWinderCfg.spoolbackingrate = request->backingrate; @@ -171,80 +173,55 @@ numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__ */ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) { - uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; + uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; float screw_horizontal_speed = 0; float RotationsPerSecond; - if (Counter) - { - if (Counter%InternalWinderCfg.spoolbackingrate == 1) + if (Counter%InternalWinderCfg.spoolbackingrate == 0) { NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); - REPORT_MSG(ScrewNumberOfSteps, "Head Backing"); + REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); ScrewNumberOfSteps--; - /* - screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; + screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage; // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = dyeingspeed / (InternalWinderCfg.diameter * PI); - RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; + RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; - MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps"); + //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + //REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps ScrewSpeed"); + //REPORT_MSG(CurrentControlledSpeed[WINDER_MOTOR], "CalculateNumberOfSteps Winder speed"); CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; - */ + } if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) { - if (direction != MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) + if (direction == MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize)//because the direction is already reversed at the interrupt { NumberOfSteps += (Counter/InternalWinderCfg.SpoolBottomBackingRate); ScrewNumberOfSteps++; - REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing"); + REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing ScrewNumberOfSteps"); } } - } return NumberOfSteps; } -uint32_t wtick=0,prevwtick = 0; -uint32_t wgap[100]; -uint32_t wgap_counter=0; uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { uint32_t Steps; + double temp; if (BusyfirstCall) { BusyfirstCall = false; + DirectionChangeCounter++; return OK; } -// if (Winder_Active == false) -// return OK; - wtick++; //ScrewCurrentDirection: false moves out, true moves home if (BusyFlag == NOTBUSY) { - if (wtick-prevwtick>10) - { - wgap[wgap_counter++] = wtick-prevwtick; - prevwtick = wtick; - if (wgap_counter >=99) - wgap_counter = 0; - } - else - return OK; CalculateNumberOfSteps (DirectionChangeCounter++, ScrewCurrentDirection); Steps = ScrewNumberOfSteps; - if (ScrewCurrentDirection == false) - { - ScrewCurrentDirection = true; - } - else - { - ScrewCurrentDirection = false; - } /* if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) { ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); @@ -257,8 +234,17 @@ uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) 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. - REPORT_MSG(ScrewCurrentDirection, "ScrewDirectionChange"); + temp = SYS_CLK_FREQ; + temp *= Steps; + temp /= ScrewSpeed; + //LOG_ERROR(Steps,"ScrewDirectionChange - ScrewNumberOfSteps"); + + /*if (ScrewRunningTime != temp) + { + REPORT_MSG(temp, "ScrewDirectionChange ScrewRunningTime changed"); + }*/ + ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed; + //MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,Steps); //process: set point 0, set max speed, move to the specified length, return back. } return OK; @@ -275,7 +261,7 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId) float screw_horizontal_speed = 0; float RotationsPerSecond; char Message[80]; - + double temp = 0; if (dyeingspeed == 0) { LOG_ERROR (dyeingspeed," job speed zero"); @@ -292,31 +278,36 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId) // * calculation input: traverse length in milimeters/pulses, number of rotations per traverse ==> length of traverse per rotation. screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = dyeingspeed / (InternalWinderCfg.diameter * PI); - RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; + //RotationsPerSecond = dyeingspeed / (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulleyradius * PI); + RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; - MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); usnprintf(Message, 80, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed); //LOG_ERROR(segmentfirst_speed,Message); //Report(Message,__FILE__,__LINE__,Dispenser_i,RpWarning,segmentfirst_speed,0); SendJobProgress(0.0,0,false, Message); CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; + OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed; //screw_horizontal_speed = InternalWinderCfg.milimetersperrotation // * 2. determine optimal micro-step setting // * 3. calculate cart travel length from winding parameters // * 4. start move of travel length // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed - ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,ScrewNumberOfSteps); //process: set point 0, set max speed, move to the specified length, return back. - wtick = 0;prevwtick = 0; - ScrewControlId = AddControlCallback(ScrewDirectionChange, eOneMillisecond,MotorControlGetnBusyState,(IfTypeMotors*0x100+HARDWARE_MOTOR_TYPE__MOTO_SCREW), HARDWARE_MOTOR_TYPE__MOTO_SCREW, 0); - - // MotorSetSpeedWithCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW, screw_horizontal_speed,WinderPresegmentReady); - //in a callback: calculate backing rate for top and bottom, update point 0, update passing length, call the appropriate move to 0 / move; - + ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; + temp = SYS_CLK_FREQ; + temp *= InternalWinderCfg.segmentoffsetpulses; + temp /= ScrewSpeed; + ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed; + LOG_ERROR(ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); + LOG_ERROR(ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); +// MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); + //ScrewDirection = 1-ScrewDirection; + LOG_ERROR(ScrewSpeed,"Winder pre segment - ScrewSpeed"); + //MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + ScrewsStartControlTimer (); } PreSegmentReady(Module_Winder,ModuleDone); @@ -327,11 +318,11 @@ uint32_t Winder_End(void) int pend; //stop screw ScrewNumberOfSteps = 0; -// Winder_Active = false; if (ScrewControlId != 0xFF) RemoveControlCallback(ScrewControlId,ScrewDirectionChange); CurrentControlledSpeed[SCREW_MOTOR] = 0; - pend = MillisecFlushMsgQ(HARDWARE_MOTOR_TYPE__MOTO_SCREW); + ScrewsStopControlTimer(); + return MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); } void Winder_ScrewHomeLimitSwitchInterrupt(void) @@ -351,3 +342,60 @@ void Winder_ScrewOutLimitSwitchInterrupt(void) 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 + +bool Screw_Restart = false; +void ScrewTimerInterruptInit(void) +{ + ROM_TimerConfigure(Screw_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer + ROM_TimerEnable(Screw_timerBase, TIMER_A); + ROM_IntEnable(INT_TIMER3A); + ROM_TimerIntEnable(Screw_timerBase, TIMER_TIMA_TIMEOUT); + Screw_Restart = false; + +} +void ScrewsStopControlTimer (void) +{ + SCREW_TimerActivated = false; + ROM_TimerDisable(Screw_timerBase, TIMER_A); + //ROM_IntDisable(INT_TIMER3A); + //ROM_TimerIntDisable(Screw_timerBase, TIMER_TIMA_TIMEOUT); +} +void ScrewsStartControlTimer (void) +{ + if (SCREW_TimerActivated == true) + return; + SCREW_TimerActivated = true; + //ROM_TimerConfigure(Screw_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer + TimerEnable(Screw_timerBase, TIMER_A); + ROM_IntEnable(INT_TIMER3A); + ROM_TimerIntEnable(Screw_timerBase, TIMER_TIMA_TIMEOUT); + ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)1200000/*10 millisec*/ ); + Report("ScrewsStartControlTimer direction,speed ", __FILE__,__LINE__,ScrewCurrentDirection, RpMessage, ScrewSpeed, 0); + return; +} +void ScrewTimerInterrupt(int ARG0) +{ + bool dir = ScrewCurrentDirection; + ROM_TimerIntClear(Screw_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt + ROM_IntMasterDisable(); + ScrewDirectionChange(0,NOTBUSY); + if (SCREW_TimerActivated == true) + { + MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); + ScrewCurrentDirection = 1-ScrewCurrentDirection; + MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); + } + else + { + TimerDisable(Screw_timerBase, TIMER_A); + } + //Report("ScrewTimerInterrupt duration, speed", __FILE__,__LINE__,ScrewRunningTime, RpMessage, ScrewSpeed, 0); + // + // Enable all interrupts. + // + ROM_IntMasterEnable(); + return ; + +} diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 3b17cd5dd..e189e2639 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -42,7 +42,7 @@ uint32_t CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM] = {0}; 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}; 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}; +uint32_t ControlIdtoMotorId [MAX_THREAD_MOTORS_NUM] = {0xFF,0xFF,0xFF,0xFF,0xFF}; uint32_t SpeedControlId=0xFF; uint32_t PoolerSpeedControlId=0xFF; @@ -706,16 +706,20 @@ uint32_t ThreadPreSegmentState(void *JobDetails) return OK; } +int REPSegmentId = 0; void ThreadInterSegmentEnded(void) { + LOG_ERROR (REPSegmentId,"ThreadInterSegmentEnded"); PreSegmentReady(Module_Thread,ModuleDone); } void ThreadSegmentEnded(void) { + LOG_ERROR (REPSegmentId," ThreadSegmentState"); SegmentReady(Module_Thread,ModuleDone); } void ThreadDistanceToSpoolEnded(void) { + LOG_ERROR (REPSegmentId," ThreadDistanceToSpoolEnded"); DistanceToSpoolReady(Module_Thread,ModuleDone); } double seglength = 0.0; @@ -723,8 +727,10 @@ double seglength = 0.0; uint32_t ThreadSegmentState(void *JobDetails, int SegmentId) { JobTicket* JobTicket = JobDetails; + REPSegmentId = SegmentId; seglength = JobTicket->segments[SegmentId]->length; CurrentSegmentId = SegmentId; + LOG_ERROR (seglength," ThreadSegmentState"); ThreadUpdateProcessLength (seglength,(void *)ThreadSegmentEnded); return OK; } @@ -733,6 +739,7 @@ uint32_t ThreadSegmentState(void *JobDetails, int SegmentId) uint32_t ThreadDistanceToSpoolState(void ) { seglength = dryerbufferlength; + LOG_ERROR (seglength,"ThreadDistanceToSpoolState"); ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); return OK; } @@ -766,7 +773,10 @@ char Endstr[150]; { if (ControlIdtoMotorId[Motor_i] != 0xFF) { - RemoveControlCallback(ControlIdtoMotorId[Motor_i],ThreadControlCBFunction); + if(RemoveControlCallback(ControlIdtoMotorId[Motor_i],ThreadControlCBFunction) == OK) + ControlIdtoMotorId[Motor_i] == 0xFF; + else + LOG_ERROR (ControlIdtoMotorId[Motor_i],"Remove Control failed"); } MotorStop(ThreadMotorIdToMotorId[Motor_i],Hard_Hiz); } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 67cb7c666..5d2345e43 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -202,7 +202,10 @@ static ReturnCode PrepareState(void *JobDetails) } if (Configured[Module_Winder]) { - Winder_Prepare(); + if( Winder_Prepare()!= OK) + { + SendJobProgress(0.0, 0, false, "Winder prepare failed !!!!"); + } } return retcode; @@ -488,6 +491,7 @@ void JobRequestFunc(MessageContainer* requestContainer) } if (status == PASSED) { + Report("Job Request ",__FILE__,__LINE__,Ticket->processparameters->dyeingspeed,RpWarning,Ticket->n_segments, Ticket->intersegmentlength); StartJob(CurrentJob); } } @@ -550,11 +554,11 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes //REPORT_MSG(msdid++,logmsg); //Report(logmsg,__FILE__,__LINE__,SegmentId,RpWarning,SegmentId, done); - if (Message) + /*if (Message) { strcpy (infomsg,Message); Report(infomsg,__FILE__,__LINE__,55,RpWarning,33, 44); - } + }*/ if (JobToken[0] == 0) return; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 204410bcd..4463304e7 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -441,6 +441,7 @@ void StartPrinting(void) void StopPrinting(void) { } +int SegmentId = 0; void PrintSTMMsgHandler(void * msg) { JobMessageStruc *Message = msg; @@ -453,7 +454,6 @@ void PrintSTMMsgHandler(void * msg) //REPORT_ERR ... return; } - static int SegmentId = 0; switch(PrtMessage->messageId) { case PrintRequest: @@ -468,6 +468,7 @@ void PrintSTMMsgHandler(void * msg) break; case SegmentResultsOk: SegmentId++; + LOG_ERROR(SegmentId, "SegmentResultsOk segmentId"); if (SegmentId >= CurrentJob->n_segments) { if (dryerbufferlength == 0) -- cgit v1.3.1 From 53b5ef734132b543838e1663fe96d70457d8a62b Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 18 Nov 2018 08:16:57 +0200 Subject: my pc changes. HardwareBlower with a heating voltage --- .../Embedded/Common/report/distributor.c | 2 +- .../Embedded/Communication/CommunicationTask.c | 2 +- .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 2 ++ .../Embedded_SW/Embedded/Drivers/Valves/Valve.c | 3 +- Software/Embedded_SW/Embedded/Main.c | 9 +++--- .../Embedded_SW/Embedded/Modules/Control/control.c | 6 ++-- .../Embedded/Modules/Diagnostics/Diagnostics.c | 23 +++++++++------- .../Embedded/Modules/Heaters/Heaters_print.c | 8 +++++- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 32 +--------------------- .../Embedded/Modules/Thread/Thread_Winder.new | 10 +++---- .../Embedded/Modules/Thread/Thread_print.c | 7 +++++ .../Embedded/StateMachines/Printing/JobSTM.c | 6 +++- .../Embedded/StateMachines/Printing/PrintingSTM.c | 3 +- .../PMR/Messages/Hardware/HardwareBlower.proto | 2 ++ 14 files changed, 56 insertions(+), 59 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/report/distributor.c b/Software/Embedded_SW/Embedded/Common/report/distributor.c index cbc754a7e..0bd4574e0 100644 --- a/Software/Embedded_SW/Embedded/Common/report/distributor.c +++ b/Software/Embedded_SW/Embedded/Common/report/distributor.c @@ -240,7 +240,7 @@ Void reportService(UArg arg0, UArg arg1) int DistTableEntry;//,msgLen, errCode, par1, par2; ReportInitParams InitParams; - InitParams.DistributorQueueMaxMsgs = 15; + InitParams.DistributorQueueMaxMsgs = 40; InitParams.DistributorTaskPriority = 6; InitParams.MaxNumOfFilterNames = 1; InitParams.MaxNumberOfPrivateDistributors = 2; diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index b27ab687d..1fffc3c21 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -15,7 +15,7 @@ static void (*callback)(char* buffer, size_t length); Mailbox_Handle CommunicationRxMsgQ = NULL; Mailbox_Handle CommunicationTxMsgQ = NULL; -#define COMMUNICATION_NUM_MSGS 20 +#define COMMUNICATION_NUM_MSGS 50 typedef struct CommRxMessage{ //uint16_t messageId; uint16_t msgSize; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index 8374133a7..780e2ede3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -488,6 +488,8 @@ uint32_t MotorMovetoLimitSwitch (TimerMotors_t _motorId,bool direction, uint32_t MotorSetDirection( _motorId, direction); MotorSetSpeed(_motorId, Freq); MotorMovetoLimitSwitchControlId[_motorId] = AddControlCallback( MotorMoveToLimitSwitchCallBackFunction, eOneMillisecond , FPGA_Read_limit_Switches,(IfTypeMotors*0x100+_motorId), LimitSwitchId, 0 ); + if ( MotorMovetoLimitSwitchControlId[_motorId] == 0xFF) + return ERROR; MotorMovetoLimitSwitchCallback[_motorId] = callback; return OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index c2dca51cd..09c4ccb0c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -361,7 +361,8 @@ uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callb Valve_Set(_ValveId, direction); Valve3WayControlId[_ValveId] = AddControlCallback( Valve3WayCallBackFunction, eTenMillisecond, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); - + if (Valve3WayControlId[_ValveId] == 0xFF) + LOG_ERROR(_ValveId, "Add control callback failed"); return Valve3WayControlId[_ValveId]; } diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 2f337b12c..2a8fc78a6 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -166,6 +166,10 @@ int main(void) SysCtlUSBPLLEnable(); +#ifndef EVALUATION_BOARD + DeActivateAllSSR(); +#endif + #ifdef WATCHDOG InitWatchdog(ui32SysClock); #endif @@ -202,12 +206,9 @@ int main(void) SysCtlDelay(1000); Erase_Block(0);*/ //----------------------------------------------------------- -#ifndef EVALUATION_BOARD +#ifndef EVALUATION_BOARD //Turn_the_Blower_On();//Turn on with the Default_Voltage - - DeActivateAllSSR(); - ActivateChiller();//SSR12 #endif //EMAC_initEMAC(); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 78cdd5324..1e9237320 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -202,7 +202,7 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF unsigned int key; uint32_t device_i; - uint32_t deviceId = 0xFFFFFFFF; + uint32_t deviceId = 0xFF; for(device_i = 0;device_i < MAX_TANGO_CONTROL_DEVICES;device_i++) { if (ControlArray[device_i].ControlActive == false) @@ -211,8 +211,8 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF break; } } - if (deviceId == 0xFFFFFFFF) - return 0xFFFFFFFF; + if (deviceId == 0xFF) + return 0xFF; key = GateMutex_enter(gateControlDB); ControlArray[deviceId].ControlTiming = CtrlFrequency; ControlArray[deviceId].ControlCallbackPtr = Callback; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 01e683dae..89793cfcd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -249,9 +249,10 @@ void DiagnosticLoadTemperature(int HeaterId, int temperature) void DiagnosticLoadSpeedSensor(float value) { SpeedValue[SpeedCounterIndex] = (double)(value); - SpeedCounterIndex++; - if (SpeedCounterIndex>=DIAGNOSTICS_DANCER_LIMIT ) - SpeedCounterIndex = 0; + if (SpeedCounterIndex=DIAGNOSTICS_DANCER_LIMIT ) + // SpeedCounterIndex = 0; } void DiagnosticLoadDancer(int DancerId, uint16_t value) @@ -262,9 +263,10 @@ void DiagnosticLoadDancer(int DancerId, uint16_t value) return; } DancerValue[DancerId][DancerCounterIndex[DancerId]] = value; - DancerCounterIndex[DancerId]++; - if (DancerCounterIndex[DancerId]>=DIAGNOSTICS_DANCER_LIMIT ) - DancerCounterIndex[DancerId] = 0; + if (DancerCounterIndex[DancerId]=DIAGNOSTICS_DANCER_LIMIT ) + // DancerCounterIndex[DancerId] = 0; } void DiagnosticLoadDancerError(int DancerId, double value) { @@ -274,9 +276,10 @@ void DiagnosticLoadDancerError(int DancerId, double value) return; } DancerErrorValue[DancerId][DancerErrorCounterIndex[DancerId]] = value; - DancerErrorCounterIndex[DancerId]++; - if (DancerErrorCounterIndex[DancerId]>=DIAGNOSTICS_DANCER_LIMIT ) - DancerErrorCounterIndex[DancerId] = 0; + if (DancerErrorCounterIndex[DancerId]=DIAGNOSTICS_DANCER_LIMIT ) + // DancerErrorCounterIndex[DancerId] = 0; } void DiagnosticTenMsecCollection(void) @@ -589,7 +592,7 @@ void SendDiagnostics(void) } else { - Report("Diagnostic Messgage",__FILE__,__LINE__,container_size,RpWarning,msec_millisecondCounter, msec_millisecondCounter); + Report("Diagnostic Message",__FILE__,__LINE__,container_size,RpWarning,msec_millisecondCounter, msec_millisecondCounter); } diag_size[diag_index] = container_size; diag_time[diag_index] = msec_millisecondCounter; diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 6222378bb..0e4466d81 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -358,7 +358,13 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) #endif InitialHeating = true; HeaterReady[HeaterId] = false; - Turn_the_Blower_Off(); + if (BlowerCfg.enabled == true) + { + Turn_the_Blower_On();//Turn on with the Default_Voltage + if (BlowerCfg.voltage) + Control_Voltage_To_Blower(BlowerCfg.voltage-500); + + } } /* if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain) //Dryer Heaters { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 64855daed..36c9dbf60 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -150,36 +150,6 @@ void DispenserPrepareReady(void) } DispenserPrepareReady(); return OK; -} -bool IDS_isDispenserUsedNextSegment(void *JobDetails,int DispenserId, int SegmentId) -{ - JobTicket* JobTicket = JobDetails; - int Dispenser_i,n_dispensers; - if (JobTicket->n_segments == 0) - return false; - if (JobTicket->n_segments <= SegmentId) - return false; - if (JobTicket->segments[SegmentId]->brushstops[0]->n_dispensers) - { - n_dispensers = JobTicket->segments[SegmentId]->brushstops[0]->n_dispensers; - for (Dispenser_i = 0;Dispenser_i < n_dispensers;Dispenser_i++) - { - if (DispenserId == JobTicket->segments[SegmentId]->brushstops[0]->dispensers[Dispenser_i]->index) //dispenser is in use next segment - { - if (JobTicket->segments[SegmentId]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond>0) - { - return true; - } - else - { - return false; - } - } - } - } - - return false; - } //******************************************************************************************************************** uint32_t IDS_Valve_PresegmentReady(uint32_t deviceID, uint32_t ReadValue) @@ -240,7 +210,7 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) continue; DispenserPreSegmentReady[DispenserId] = false; LOG_ERROR(DispenserId,"Dispenser PreSegment Start"); - if (IDS_isDispenserUsedNextSegment(JobDetails,DispenserId,SegmentId) == false) + if (JobTicket->segments[SegmentId]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond==0) { Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, IDS_Valve_PresegmentReady); //direction: MidTank_Dispenser or Dispenser_Mixer LOG_ERROR(DispenserId,"Dispenser Not Used Next Segment"); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new index 537d27775..e21114603 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new @@ -177,7 +177,7 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) float screw_horizontal_speed = 0; float RotationsPerSecond; - if (Counter%InternalWinderCfg.spoolbackingrate == 1) + if (Counter%InternalWinderCfg.spoolbackingrate == 0) { NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); @@ -189,14 +189,14 @@ uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps ScrewSpeed"); - REPORT_MSG(CurrentControlledSpeed[WINDER_MOTOR], "CalculateNumberOfSteps Winder speed"); + //REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps ScrewSpeed"); + //REPORT_MSG(CurrentControlledSpeed[WINDER_MOTOR], "CalculateNumberOfSteps Winder speed"); CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; } if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) { - if (direction != MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) + if (direction == MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize)//because the direction is already reversed at the interrupt { NumberOfSteps += (Counter/InternalWinderCfg.SpoolBottomBackingRate); ScrewNumberOfSteps++; @@ -391,7 +391,7 @@ void ScrewTimerInterrupt(int ARG0) { TimerDisable(Screw_timerBase, TIMER_A); } - Report("ScrewTimerInterrupt duration, speed", __FILE__,__LINE__,ScrewRunningTime, RpMessage, ScrewSpeed, 0); + //Report("ScrewTimerInterrupt duration, speed", __FILE__,__LINE__,ScrewRunningTime, RpMessage, ScrewSpeed, 0); // // Enable all interrupts. // diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 3b17cd5dd..40fd14fde 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -706,16 +706,20 @@ uint32_t ThreadPreSegmentState(void *JobDetails) return OK; } +int REPSegmentId = 0; void ThreadInterSegmentEnded(void) { + LOG_ERROR (REPSegmentId," ThreadSegmentState"); PreSegmentReady(Module_Thread,ModuleDone); } void ThreadSegmentEnded(void) { + LOG_ERROR (REPSegmentId," ThreadSegmentState"); SegmentReady(Module_Thread,ModuleDone); } void ThreadDistanceToSpoolEnded(void) { + LOG_ERROR (REPSegmentId," ThreadSegmentState"); DistanceToSpoolReady(Module_Thread,ModuleDone); } double seglength = 0.0; @@ -723,8 +727,10 @@ double seglength = 0.0; uint32_t ThreadSegmentState(void *JobDetails, int SegmentId) { JobTicket* JobTicket = JobDetails; + REPSegmentId = SegmentId; seglength = JobTicket->segments[SegmentId]->length; CurrentSegmentId = SegmentId; + LOG_ERROR (seglength," ThreadSegmentState"); ThreadUpdateProcessLength (seglength,(void *)ThreadSegmentEnded); return OK; } @@ -733,6 +739,7 @@ uint32_t ThreadSegmentState(void *JobDetails, int SegmentId) uint32_t ThreadDistanceToSpoolState(void ) { seglength = dryerbufferlength; + LOG_ERROR (seglength,"ThreadDistanceToSpoolState"); ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); return OK; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 67cb7c666..d595f1fe4 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -202,7 +202,10 @@ static ReturnCode PrepareState(void *JobDetails) } if (Configured[Module_Winder]) { - Winder_Prepare(); + if( Winder_Prepare()!= OK) + { + SendJobProgress(0.0, 0, false, "Winder prepare failed !!!!"); + } } return retcode; @@ -488,6 +491,7 @@ void JobRequestFunc(MessageContainer* requestContainer) } if (status == PASSED) { + Report("Job Request ",__FILE__,__LINE__,Ticket->processparameters->dyeingspeed,RpWarning,Ticket->n_segments, Ticket->intersegmentlength); StartJob(CurrentJob); } } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 204410bcd..4463304e7 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -441,6 +441,7 @@ void StartPrinting(void) void StopPrinting(void) { } +int SegmentId = 0; void PrintSTMMsgHandler(void * msg) { JobMessageStruc *Message = msg; @@ -453,7 +454,6 @@ void PrintSTMMsgHandler(void * msg) //REPORT_ERR ... return; } - static int SegmentId = 0; switch(PrtMessage->messageId) { case PrintRequest: @@ -468,6 +468,7 @@ void PrintSTMMsgHandler(void * msg) break; case SegmentResultsOk: SegmentId++; + LOG_ERROR(SegmentId, "SegmentResultsOk segmentId"); if (SegmentId >= CurrentJob->n_segments) { if (dryerbufferlength == 0) diff --git a/Software/PMR/Messages/Hardware/HardwareBlower.proto b/Software/PMR/Messages/Hardware/HardwareBlower.proto index 22f73f585..f628fea36 100644 --- a/Software/PMR/Messages/Hardware/HardwareBlower.proto +++ b/Software/PMR/Messages/Hardware/HardwareBlower.proto @@ -24,4 +24,6 @@ message HardwareBlower double Voltage = 3; + double HeatingVoltage = 4; + } -- cgit v1.3.1 From 18999a12b60a4d1713c77f353bd662e3a8743ab5 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 18 Nov 2018 14:37:45 +0200 Subject: improved winder algorithm. some logs for heaters PID and for control debug --- .../Embedded_SW/Embedded/Drivers/Valves/Valve.c | 4 +- .../Embedded_SW/Embedded/Modules/General/process.c | 2 +- .../Embedded/Modules/Heaters/Heaters_print.c | 47 ++++--- .../Embedded/Modules/Thread/Thread_Winder.c | 139 ++++++++++----------- .../Embedded/Modules/Thread/Thread_print.c | 20 +-- 5 files changed, 107 insertions(+), 105 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index 5ae8a5ad3..6c9255466 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -340,8 +340,8 @@ uint32_t Valve3WayCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //stop this control loop if (RemoveControlCallback(Valve3WayControlId[ValveId], Valve3WayCallBackFunction )==OK) Valve3WayControlId[ValveId] == 0xFF; - - //LOG_ERROR(Valve3WayControlId[ValveId], "Remove control callback"); + else + LOG_ERROR(ValveId, "Remove control callback"); //call the module callback if (Valve3WayModuleCallback[ValveId]) diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index 919a93148..1ab1365d0 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -158,7 +158,7 @@ void ProcessRequestFunc(MessageContainer* requestContainer) container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - REPORT_MSG (ProcessParams->dryerzone1temp,"Process Params Dryer"); + //REPORT_MSG (ProcessParams->dryerzone1temp,"Process Params Dryer"); if (status == 0) status = HandleProcessParameters(ProcessParams); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 0e4466d81..aa3d695de 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -341,21 +341,19 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) HeaterPIDConfig[HeaterId].m_SetParam = SetTemperatue*100;//need to update SetParams on presegment stage if (HeaterId >= MAX_AC_HEATERS) //DC Heaters { - ControlIdtoHeaterId [HeaterId] = AddControlCallback( DCHeaterControlCBFunction, /*eOneSecond*/eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); + if (ControlIdtoHeaterId [HeaterId] == 0xFF) + ControlIdtoHeaterId [HeaterId] = AddControlCallback( DCHeaterControlCBFunction, /*eOneSecond*/eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); DCInitialHeating[HeaterId] = true; HeaterReady[HeaterId] = false; } else if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature) //AC Heaters { -#ifdef DEMO_TEMPERATURE - ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, eHundredMillisecond,DemoTemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature,0); - MainDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,DemoTemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain,0); - SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,DemoTemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary,0); -#else - ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),DryerInternalPT100Id,0); - MainDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain],0); - SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary],0); -#endif + if (ControlIdtoHeaterId [HeaterId] == 0xFF) + ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),DryerInternalPT100Id,0); + if (MainDryerHeaterMaxTempControl == 0xFF) + MainDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain],0); + if (SecondDryerHeaterMaxTempControl == 0xFF) + SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary],0); InitialHeating = true; HeaterReady[HeaterId] = false; if (BlowerCfg.enabled == true) @@ -366,16 +364,6 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) } } -/* if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain) //Dryer Heaters - { - MainDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); - } - if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary) //Dryer Heaters - { - SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eHundredMillisecond,TemperatureSensorRead,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); - } -*/ - return OK; } bool HeaterCheckReady(void) @@ -481,11 +469,12 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) } return ERROR; } +char ACheatstr[100]; +int printindex=0; uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) { int index=MAX_HEATERS_NUM; - /*char str[100]; - uint8_t len = 0;*/ + uint8_t len = 0; if (IfIndex>>8 != IfTypeHeaters) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -497,6 +486,7 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) LOG_ERROR (IfIndex, "Wrong Interface "); return 0xFFFFFFFF; } + if (printindex++>MAX_HEATERS_NUM)printindex=0; if (HeaterCmd[index].targettemperatue == 0) { DeActivateHeater(index); @@ -557,6 +547,11 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) //check only for the proportional band limits HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); + len = usnprintf(ACheatstr, 254, "ACD%d: Temp %d Integral %d Output %d ",index,(int)HeaterPIDConfig[index].m_mesuredParam ,(int)HeaterPIDConfig[index].m_integral,(int)HeaterPIDConfig[index].m_calculatedError); + // Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); + // #warning PID is now only proportional (above) + if (printindex==index) + Report(ACheatstr,__FILE__,__LINE__,index,RpWarning,readValue, HeaterPIDConfig[index].m_calculatedError); HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, (int)(HeaterPIDConfig[index].m_calculatedError/100)); } } @@ -574,13 +569,13 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) //float output[HARDWARE_PID_CONTROL_TYPE__MixerHeater][100]; //int Counter[HARDWARE_PID_CONTROL_TYPE__MixerHeater] = {0,0,0,0,0,0,0}; //char logmsg[HARDWARE_PID_CONTROL_TYPE__MixerHeater][254]; +char heatstr[100]; uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) { int index=MAX_HEATERS_NUM; int len; - /*char str[100]; - uint8_t len = 0;*/ + //uint8_t len = 0; if (IfIndex>>8 != IfTypeHeaters) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -654,9 +649,11 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) // output[index][Counter[index]] = HeaterPIDConfig[index].m_calculatedError; // if (Counter[index]++ >=100) // Counter[index] = 0; - // len = usnprintf(logmsg[index], 254, "PID%d: Temp %d Integral %d Output %d ",index,(int)HeaterPIDConfig[index].m_mesuredParam ,(int)HeaterPIDConfig[index].m_integral,(int)HeaterPIDConfig[index].m_calculatedError); + len = usnprintf(heatstr, 254, "PID%d: Temp %d Integral %d Output %d ",index,(int)HeaterPIDConfig[index].m_mesuredParam ,(int)HeaterPIDConfig[index].m_integral,(int)HeaterPIDConfig[index].m_calculatedError); // Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); // #warning PID is now only proportional (above) + if (printindex==index) + Report(heatstr,__FILE__,__LINE__,index,RpWarning,readValue, HeaterPIDConfig[index].m_calculatedError); HeaterRecalculateHeaterParams(index, (int)(HeaterPIDConfig[index].m_calculatedError/100)); } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 305c0e767..0c4a3b80a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -28,19 +28,22 @@ bool Winder_ScrewHoming = false; +#define MAX_WINDER_SPEED_CALCULATION 100 uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag); uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue); bool ScrewCurrentDirection = false; //holds current screw direction -bool BusyfirstCall = true; //Ignores first call after activating the screw - too early +uint32_t ScrewDirectionChangeCounter = 1; //holds the current number of runs of the screw - will be used to build the cone +uint32_t CalculationDirectionChangeCounter = 1; //holds the current number of runs of the screw - will be used to build the cone +uint32_t WinderMotorSpeed[MAX_WINDER_SPEED_CALCULATION]; +uint8_t WinderMotorSpeedCounter=0; +uint32_t WinderMotorSpeedRollOver=0; double ScrewSpeed = 0; double ScrewRunningTime = 0; -bool ScrewDirection = false; +uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone bool SCREW_TimerActivated = false; //ScrewSpeed uint32_t ScrewControlId = 0xFF; -uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone -uint32_t DirectionChangeCounter = 0; //holds the current number of runs of the screw - will be used to build the cone InternalWinderConfigStruc InternalWinderCfg = {0}; void ScrewTimerInterruptInit(void); @@ -138,7 +141,6 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; - DirectionChangeCounter = 0; REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); PrepareReady(Module_Winder, ModuleDone); return OK; @@ -171,81 +173,68 @@ InternalWinderCfg.segmentoffsetpulses numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; */ -uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) +uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) { - uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; + uint32_t Steps,i,winderspeed=0; + double temp; + uint32_t WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR]; float screw_horizontal_speed = 0; float RotationsPerSecond; - if (Counter%InternalWinderCfg.spoolbackingrate == 0) - { - NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); - REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); - ScrewNumberOfSteps--; - screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage; - // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; - // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. - ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; + WinderMotorSpeed[WinderMotorSpeedCounter] = CurrentControlledSpeed[WINDER_MOTOR]; + if (WinderMotorSpeedCounter++>=MAX_WINDER_SPEED_CALCULATION) + { + WinderMotorSpeedCounter=0; + WinderMotorSpeedRollOver++; + } + + if (ScrewDirectionChangeCounter == CalculationDirectionChangeCounter) + return OK; - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - //REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps ScrewSpeed"); - //REPORT_MSG(CurrentControlledSpeed[WINDER_MOTOR], "CalculateNumberOfSteps Winder speed"); - CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; + ScrewCurrentDirection = 1-ScrewCurrentDirection; + CalculationDirectionChangeCounter++; - } - if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) + if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out + { + if ((CalculationDirectionChangeCounter/2)%InternalWinderCfg.spoolbackingrate == 0) { - if (direction == MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize)//because the direction is already reversed at the interrupt - { - NumberOfSteps += (Counter/InternalWinderCfg.SpoolBottomBackingRate); - ScrewNumberOfSteps++; - REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing ScrewNumberOfSteps"); - } + ScrewNumberOfSteps--; + REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); } - return NumberOfSteps; - -} -uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) -{ - uint32_t Steps; - double temp; - if (BusyfirstCall) - { - BusyfirstCall = false; - DirectionChangeCounter++; - return OK; } - //ScrewCurrentDirection: false moves out, true moves home - if (BusyFlag == NOTBUSY) + else //next time going back { - CalculateNumberOfSteps (DirectionChangeCounter++, ScrewCurrentDirection); - Steps = ScrewNumberOfSteps; -/* if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) + if ((CalculationDirectionChangeCounter/2)%InternalWinderCfg.SpoolBottomBackingRate == 0) { - ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); - Steps += InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - REPORT_MSG(LIMIT, "Winder at right limit"); + ScrewNumberOfSteps++; + REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing ScrewNumberOfSteps"); } - else if (FPGA_Read_limit_Switches(GPI_LS_SCREW_LEFT)==LIMIT) + } + if (WinderMotorSpeedRollOver) + { + for (i=0;i Date: Mon, 19 Nov 2018 10:59:09 +0200 Subject: Version 1.1.4.3: Cart goes to the edge at job end to enable spool change --- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 22 +++++++++++----------- .../Embedded/Modules/Thread/Thread_Winder.c | 5 +++-- .../Embedded/Modules/Thread/Thread_print.c | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index 6dd23d8b9..5faf7fbe4 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {001,001,004,002}; +TangoVersion_t _gTangoVersion = {001,001,004,003}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index eb371a4de..53f850352 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -116,22 +116,22 @@ AlarmHandlingItem AlarmItem[MAX_SYSTEM_ALARMS]={ {eHundredMillisecond,LimitSwitchAlarm,LimitSwitchAlarmLow_6,false,true,DEBUG_LOG_CATEGORY__Warning,5,0,0,false,EVENT_TYPE__Dispenser6LowLevel,NULL,"Dispenser6LowLevel"}, {eHundredMillisecond,LimitSwitchAlarm,LimitSwitchAlarmLow_7,false,true,DEBUG_LOG_CATEGORY__Warning,6,0,0,false,EVENT_TYPE__Dispenser7LowLevel,NULL,"Dispenser7LowLevel"}, {eHundredMillisecond,LimitSwitchAlarm,LimitSwitchAlarmLow_8,false,true,DEBUG_LOG_CATEGORY__Warning,7,0,0,false,EVENT_TYPE__Dispenser8LowLevel,NULL,"Dispenser8LowLevel"},*/ -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP3,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"Mixer Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP3,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"Mixer Over Temperature"}, //{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP1,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"GeneralInternal Over Temperature"}, //{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP2,80,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"GeneralInternal Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP1,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead1OverTemperature,NULL,"DyeingHead1 Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP2,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead2OverTemperature,NULL,"DyeingHead2 Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP3,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead3OverTemperature,NULL,"DyeingHead3 Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP4,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead4OverTemperature,NULL,"DyeingHead4 Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP5,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead5OverTemperature,NULL,"DyeingHead5 Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_MIXCHIP_TEMP,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead6OverTemperature,NULL,"DyeingHead6 Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP1,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead1OverTemperature,NULL,"DyeingHead1 Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP2,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead2OverTemperature,NULL,"DyeingHead2 Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP3,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead3OverTemperature,NULL,"DyeingHead3 Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP4,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead4OverTemperature,NULL,"DyeingHead4 Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP5,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead5OverTemperature,NULL,"DyeingHead5 Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_MIXCHIP_TEMP,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead6OverTemperature,NULL,"DyeingHead6 Over Temperature"}, {eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DRYER_TEMP1,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DryerOverTemperature,NULL,"Dryer Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DRYER_TEMP2,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DryerOverTemperature,NULL,"Dryer Over Temperature"}, -{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DRYER_TEMP3,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DryerOverTemperature,NULL,"Dryer Over Temperature"}, -/*{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP3,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"Mixer PT100 Not Working"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DRYER_TEMP1,270,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DryerOverTemperature,NULL,"Dryer Over Temperature"}, +{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DRYER_TEMP1,300,true,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DryerOverTemperature,NULL,"Dryer Over Temperature"}, +//{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP3,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__GeneralInternalOverTemperature,NULL,"Mixer PT100 Not Working"}, //{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP1,250,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,0,false,EVENT_TYPE__GeneralInternalPT100 Not Working,NULL,"GeneralInternalPT100 Not Working"}, //{eHundredMillisecond,TemperatureAlarm,TEMP_SENSE_AN_ENCLOSURETEMP2,80,true,DEBUG_LOG_CATEGORY__Error,0xFF,0,0,false,EVENT_TYPE__GeneralInternalPT100 Not Working,NULL,"GeneralInternalPT100 Not Working"}, -{eOneSecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP1,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead1OverTemperature,NULL,"DyeingHead 1 PT100 Not Working"}, +/*{eOneSecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP1,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead1OverTemperature,NULL,"DyeingHead 1 PT100 Not Working"}, {eOneSecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP2,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead2OverTemperature,NULL,"DyeingHead 2 PT100 Not Working"}, {eOneSecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP3,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead3OverTemperature,NULL,"DyeingHead 3 PT100 Not Working"}, {eOneSecond,TemperatureAlarm,TEMP_SENSE_ANALOG_DYEINGH_TEMP4,9,false,DEBUG_LOG_CATEGORY__Error,0xFF,10,0,false,EVENT_TYPE__DyeingHead4OverTemperature,NULL,"DyeingHead 4 PT100 Not Working"}, diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 0c4a3b80a..fd577311e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -309,7 +309,6 @@ uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId) } uint32_t Winder_End(void) { - int pend; //stop screw ScrewNumberOfSteps = 0; if (ScrewControlId != 0xFF) @@ -319,8 +318,10 @@ uint32_t Winder_End(void) } CurrentControlledSpeed[SCREW_MOTOR] = 0; ScrewsStopControlTimer(); + //move the cart to the edge so the spool can be easily replaced + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, 1000, GPI_LS_SCREW_RIGHT, NULL); - return MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); + return OK; } void Winder_ScrewHomeLimitSwitchInterrupt(void) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index ea86c2892..5390ed0a7 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -775,7 +775,7 @@ char Endstr[150]; PoolerSpeedControlId = 0xFF; } - for ( Motor_i = 0;Motor_i < MAX_THREAD_MOTORS_NUM;Motor_i++) + for ( Motor_i = 0;Motor_i <= WINDER_MOTOR;Motor_i++) { if (ControlIdtoMotorId[Motor_i] != 0xFF) { -- cgit v1.3.1 From 4f6efa33a5693da6e5c3182dce96b8e2d3e9d9aa Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 20 Nov 2018 11:44:31 +0200 Subject: temparatures not in integer numbers --- .../Embedded/Modules/Diagnostics/Diagnostics.c | 3 +- .../Embedded/Modules/Thread/Thread_Winder.new | 401 --------------------- .../Embedded/Modules/Thread/Thread_Winder.old | 366 ------------------- 3 files changed, 2 insertions(+), 768 deletions(-) delete mode 100644 Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new delete mode 100644 Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.old (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 003a2510a..20fce7cf6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -232,6 +232,7 @@ void DiagnosticsLoadDigitalValues(void) } void DiagnosticLoadTemperature(int HeaterId, int temperature) { + double temp = temperature; if (HeaterId >= MAX_HEATERS_NUM) { LOG_ERROR(HeaterId,"wrong Heater Id"); @@ -241,7 +242,7 @@ void DiagnosticLoadTemperature(int HeaterId, int temperature) { return; } - HeaterTemperature[HeaterId][HeaterCounterIndex[HeaterId]] = temperature/100; + HeaterTemperature[HeaterId][HeaterCounterIndex[HeaterId]] = temp/100; HeaterCounterIndex[HeaterId]++; if (HeaterCounterIndex[HeaterId]>=DIAGNOSTICS_LIMIT ) HeaterCounterIndex[HeaterId] = 0; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new deleted file mode 100644 index e21114603..000000000 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Thread_Winder.c - * - * Created on: 25 áîøõ 2018 - * Author: shlomo - */ -#include"include.h" -#include "thread.h" - -#include "drivers/Motors/Motor.h" -#include "StateMachines/Printing/PrintingSTM.h" -#include "Modules/Control/Control.h" -#include "Modules/Control/MillisecTask.h" - -#include "modules/General/process.h" - -#include "Common/report/report.h" - -#include "drivers/FPGA/FPGA.h" - -#include "drivers/FPGA/FPGA_SPI_Comm.h" -#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" - -#include -#include -#include - - -bool Winder_ScrewHoming = false; - -uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag); -uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue); - -bool ScrewCurrentDirection = false; //holds current screw direction -bool BusyfirstCall = true; //Ignores first call after activating the screw - too early -double ScrewSpeed = 0; -double ScrewRunningTime = 0; -bool ScrewDirection = false; -bool SCREW_TimerActivated = false; -//ScrewSpeed -uint32_t ScrewControlId = 0xFF; -uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone -uint32_t DirectionChangeCounter = 0; //holds the current number of runs of the screw - will be used to build the cone - -InternalWinderConfigStruc InternalWinderCfg = {0}; -void ScrewTimerInterruptInit(void); -void ScrewsStopControlTimer (void); -void ScrewsStartControlTimer (void); - -uint32_t Winder_Init(void) -{ - ScrewTimerInterruptInit(); - return OK; -} - - -uint32_t InternalWinderConfigMessage(HardwareWinder* request) -{ - uint32_t status = PASSED; - - InternalWinderCfg.milimetersperrotation = request->millimeterperrotation; - - return status; -} -uint32_t InternalWindingConfigMessage(JobSpool* request) -{ - uint32_t status = PASSED; - - InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses; - InternalWinderCfg.spoolbackingrate = request->backingrate; - InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; - InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; - InternalWinderCfg.diameter = request->diameter; - - return status; -} -/* - *uint32_t Winder_Prepare(void *JobDetails) - - * 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 - */ -uint32_t Winder_Prepare(void) -{ - uint32_t status = 0; - //JobTicket* JobTicket = JobDetails; - //float process_speed = JobTicket->processparameters->dyeingspeed; - double ScrewSpeed = 1500;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); - //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); - /* - * 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. - * 2. move back x steps - according to thehw specifications and bobine definitions in the job. move for a predefined number of steps. get a callback when done - * report ready to the job STM - */ - if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) - { - //REPORT_MSG(LIMIT, "Winder_Prepare at limit"); - Winder_PrepareStage2(0,0); - } - else - { - //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); - Winder_ScrewHoming = true; - //REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit"); - status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2); - } - return status; -} -/* - * uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) - * 2. move back x steps - according to thehw specifications and bobine definitions in the job. move for a predefined number of steps. get a callback when done - * report ready to the job STM - */ - -uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) -{ - uint32_t status=OK; - uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); - //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); - REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2"); - - status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback); - //set motor location 0 here - return status; - -} - -uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) -{ - //SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency); - - ScrewCurrentDirection = false; - ScrewSpeed = 0; - ScrewControlId = 0xFF; - ScrewNumberOfSteps = 0; - DirectionChangeCounter = 0; - REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); - PrepareReady(Module_Winder, ModuleDone); - return OK; -} - -/* - * this is the main operational function of the screw - run back and forth until stopped - */ -/* - InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses; - InternalWinderCfg.spoolbackingrate = request->backingrate; - InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; - InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; - * -Calculate the number of steps. -Initial home position = ... -Initial out movement = ScrewNumberOfSteps -if DirectionChangeCounter %= backingrate : reduce one from the ScrewNumberOfSteps -if DirectionChangeCounter %= bottombackingrate && direction was out: ADD one to the ScrewNumberOfSteps, -// WRONG? if the flag is raised - lower it and reduce one from the ScrewNumberOfSteps -30:100 - 70 -30:99 - 69 -30:98 - 68 -29:98 - 69 -29:97 -68 -InternalWinderCfg.segmentoffsetpulses - int32_t backingrate; - int32_t bottombackingrate; - -numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; -*/ -uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) -{ - uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - float screw_horizontal_speed = 0; - float RotationsPerSecond; - - if (Counter%InternalWinderCfg.spoolbackingrate == 0) - { - NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); - REPORT_MSG(ScrewNumberOfSteps, "Head Backing ScrewNumberOfSteps"); - ScrewNumberOfSteps--; - screw_horizontal_speed = ScrewNumberOfSteps / InternalWinderCfg.NumberOfRotationPerPassage; - // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; - // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. - ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; - - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - //REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps ScrewSpeed"); - //REPORT_MSG(CurrentControlledSpeed[WINDER_MOTOR], "CalculateNumberOfSteps Winder speed"); - CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; - - } - if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) - { - if (direction == MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize)//because the direction is already reversed at the interrupt - { - NumberOfSteps += (Counter/InternalWinderCfg.SpoolBottomBackingRate); - ScrewNumberOfSteps++; - REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing ScrewNumberOfSteps"); - } - - } - return NumberOfSteps; - -} -uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) -{ - uint32_t Steps; - double temp; - if (BusyfirstCall) - { - BusyfirstCall = false; - DirectionChangeCounter++; - return OK; - } - //ScrewCurrentDirection: false moves out, true moves home - if (BusyFlag == NOTBUSY) - { - CalculateNumberOfSteps (DirectionChangeCounter++, ScrewCurrentDirection); - Steps = ScrewNumberOfSteps; -/* 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; - REPORT_MSG(LIMIT, "Winder at right limit"); - } - else if (FPGA_Read_limit_Switches(GPI_LS_SCREW_LEFT)==LIMIT) - { - ScrewCurrentDirection = (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); - REPORT_MSG(LIMIT, "Winder at left limit"); - } -*/ - temp = SYS_CLK_FREQ; - temp *= Steps; - temp /= ScrewSpeed; - //LOG_ERROR(Steps,"ScrewDirectionChange - ScrewNumberOfSteps"); - - if (ScrewRunningTime != temp) - { - REPORT_MSG(temp, "ScrewDirectionChange ScrewRunningTime changed"); - } - ScrewRunningTime = temp;//(SYS_CLK_FREQ*Steps)/ScrewSpeed; - //MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,Steps); //process: set point 0, set max speed, move to the specified length, return back. - } - return OK; - -} - -uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue) -{ - return PreSegmentReady(Module_Winder,ModuleDone); -} - -uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId) -{ - //JobTicket* JobTicket = JobDetails; - float screw_horizontal_speed = 0; - float RotationsPerSecond; - char Message[80]; - double temp = 0; - if (dyeingspeed == 0) - { - LOG_ERROR (dyeingspeed," job speed zero"); - return ERROR; - } - - if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job) - { - ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); - - // * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec) - // * calculate - // * 1. calculate speed according to JobTicket->processparameters->dyeingspeed - // * calculation input: traverse length in milimeters/pulses, number of rotations per traverse ==> length of traverse per rotation. - screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; - // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - //RotationsPerSecond = dyeingspeed / (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulleyradius * PI); - RotationsPerSecond = OriginalMotorSpd_2PPS[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; - // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. - ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; - - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - usnprintf(Message, 80, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed); - //LOG_ERROR(segmentfirst_speed,Message); - //Report(Message,__FILE__,__LINE__,Dispenser_i,RpWarning,segmentfirst_speed,0); - SendJobProgress(0.0,0,false, Message); - - CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; - OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed; - //screw_horizontal_speed = InternalWinderCfg.milimetersperrotation - // * 2. determine optimal micro-step setting - // * 3. calculate cart travel length from winding parameters - // * 4. start move of travel length - // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed - ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - temp = SYS_CLK_FREQ; - temp *= InternalWinderCfg.segmentoffsetpulses; - temp /= ScrewSpeed; - ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed; - LOG_ERROR(ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); - LOG_ERROR(ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); -// MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); - //ScrewDirection = 1-ScrewDirection; - LOG_ERROR(ScrewSpeed,"Winder pre segment - ScrewSpeed"); - //MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - ScrewsStartControlTimer (); - } - PreSegmentReady(Module_Winder,ModuleDone); - - return OK; -} -uint32_t Winder_End(void) -{ - int pend; - //stop screw - ScrewNumberOfSteps = 0; - if (ScrewControlId != 0xFF) - RemoveControlCallback(ScrewControlId,ScrewDirectionChange); - CurrentControlledSpeed[SCREW_MOTOR] = 0; - ScrewsStopControlTimer(); - - return MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); -} -void Winder_ScrewHomeLimitSwitchInterrupt(void) -{ - //uint32_t status; - //handle glitch - send information to the next time that the motor stops - if (Winder_ScrewHoming) - { - MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); //stop ASAP - } - MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);//make sure to move the cart out -} -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 - -bool Screw_Restart = false; -void ScrewTimerInterruptInit(void) -{ - ROM_TimerConfigure(Screw_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer - ROM_TimerEnable(Screw_timerBase, TIMER_A); - ROM_IntEnable(INT_TIMER3A); - ROM_TimerIntEnable(Screw_timerBase, TIMER_TIMA_TIMEOUT); - Screw_Restart = false; - -} -void ScrewsStopControlTimer (void) -{ - SCREW_TimerActivated = false; - ROM_TimerDisable(Screw_timerBase, TIMER_A); - //ROM_IntDisable(INT_TIMER3A); - //ROM_TimerIntDisable(Screw_timerBase, TIMER_TIMA_TIMEOUT); -} -void ScrewsStartControlTimer (void) -{ - if (SCREW_TimerActivated == true) - return; - SCREW_TimerActivated = true; - //ROM_TimerConfigure(Screw_timerBase, TIMER_CFG_PERIODIC); // 32 bits Timer - TimerEnable(Screw_timerBase, TIMER_A); - ROM_IntEnable(INT_TIMER3A); - ROM_TimerIntEnable(Screw_timerBase, TIMER_TIMA_TIMEOUT); - ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)1200000/*10 millisec*/ ); - Report("ScrewsStartControlTimer direction,speed ", __FILE__,__LINE__,ScrewCurrentDirection, RpMessage, ScrewSpeed, 0); - return; -} -void ScrewTimerInterrupt(int ARG0) -{ - bool dir = ScrewCurrentDirection; - ROM_TimerIntClear(Screw_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt - ROM_IntMasterDisable(); - ScrewDirectionChange(0,NOTBUSY); - if (SCREW_TimerActivated == true) - { - MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); - ScrewCurrentDirection = 1-ScrewCurrentDirection; - MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); - } - else - { - TimerDisable(Screw_timerBase, TIMER_A); - } - //Report("ScrewTimerInterrupt duration, speed", __FILE__,__LINE__,ScrewRunningTime, RpMessage, ScrewSpeed, 0); - // - // Enable all interrupts. - // - ROM_IntMasterEnable(); - return ; - -} diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.old b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.old deleted file mode 100644 index 1aaeec556..000000000 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.old +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Thread_Winder.c - * - * Created on: 25 áîøõ 2018 - * Author: shlomo - */ -#include"include.h" -#include "thread.h" - -#include "drivers/Motors/Motor.h" -#include "StateMachines/Printing/PrintingSTM.h" -#include "Modules/Control/Control.h" -#include "Modules/Control/MillisecTask.h" - -#include "modules/General/process.h" - -#include "Common/report/report.h" - -#include "drivers/FPGA/FPGA.h" - -#include "drivers/FPGA/FPGA_SPI_Comm.h" -#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" - -#include -#include -#include - -bool Winder_ScrewHoming = false; -//bool Winder_Active = false; - -uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag); -uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue); - -bool ScrewCurrentDirection = false; //holds current screw direction -bool BusyfirstCall = true; //Ignores first call after activating the screw - too early -double ScrewSpeed = 0; //ScrewSpeed -uint32_t ScrewControlId = 0xFF; -uint32_t ScrewNumberOfSteps = 0; //holds the current number of steps for the next screw run - will be used to build the cone -uint32_t DirectionChangeCounter = 0; //holds the current number of runs of the screw - will be used to build the cone - -InternalWinderConfigStruc InternalWinderCfg = {0}; - -uint32_t Winder_Init(void) -{ - return OK; -} - - -uint32_t InternalWinderConfigMessage(HardwareWinder* request) -{ - uint32_t status = PASSED; - - InternalWinderCfg.milimetersperrotation = request->millimeterperrotation; - - return status; -} -uint32_t InternalWindingConfigMessage(JobSpool* request) -{ - uint32_t status = PASSED; - - InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses; - InternalWinderCfg.spoolbackingrate = request->backingrate; - InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; - InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; - InternalWinderCfg.diameter = request->diameter; - - return status; -} -/* - *uint32_t Winder_Prepare(void *JobDetails) - - * 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 - */ -uint32_t Winder_Prepare(void) -{ - uint32_t status = 0; - //JobTicket* JobTicket = JobDetails; -// Winder_Active = true; - //float process_speed = JobTicket->processparameters->dyeingspeed; - double ScrewSpeed = 1000;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now - //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); - /* - * 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. - * 2. move back x steps - according to thehw specifications and bobine definitions in the job. move for a predefined number of steps. get a callback when done - * report ready to the job STM - */ - if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) - { - REPORT_MSG(LIMIT, "Winder_Prepare at limit"); - Winder_PrepareStage2(0,0); - } - else - { - REPORT_MSG(ScrewSpeed, "Winder_Prepare"); - Winder_ScrewHoming = true; - //REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit"); - status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2); - } - return status; -} -/* - * uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) - * 2. move back x steps - according to thehw specifications and bobine definitions in the job. move for a predefined number of steps. get a callback when done - * report ready to the job STM - */ - -uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) -{ - uint32_t status=OK; - uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - - MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); - //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); - REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency, "Winder_PrepareStage2"); - - status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback); - //set motor location 0 here - return status; - -} - -uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) -{ - SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home - - ScrewCurrentDirection = false; - BusyfirstCall = true; - ScrewSpeed = 0; - ScrewControlId = 0xFF; - ScrewNumberOfSteps = 0; - DirectionChangeCounter = 0; - REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); - - PrepareReady(Module_Winder, ModuleDone); - return OK; -} - -/* - * this is the main operational function of the screw - run back and forth until stopped - */ -/* - -bool ScrewCurrentDirection = false; -bool BusyfirstCall = true; -double ScrewSpeed = 0; -uint32_t ScrewControlId = 0xFF; -uint32_t ScrewNumberOfSteps = 0; -uint32_t DirectionChangeCounter = 0; -*/ -/* - InternalWinderCfg.segmentoffsetpulses = request->segmentoffsetpulses; - InternalWinderCfg.spoolbackingrate = request->backingrate; - InternalWinderCfg.startoffsetpulses = request->startoffsetpulses; - InternalWinderCfg.SpoolBottomBackingRate = request->bottombackingrate; - InternalWinderCfg.NumberOfRotationPerPassage = request->rotationsperpassage; - * -Calculate the number of steps. -Initial home position = ... -Initial out movement = ScrewNumberOfSteps -if DirectionChangeCounter %= backingrate : reduce one from the ScrewNumberOfSteps -if DirectionChangeCounter %= bottombackingrate && direction was out: ADD one to the ScrewNumberOfSteps, -// WRONG? if the flag is raised - lower it and reduce one from the ScrewNumberOfSteps -30:100 - 70 -30:99 - 69 -30:98 - 68 -29:98 - 69 -29:97 -68 -InternalWinderCfg.segmentoffsetpulses - int32_t backingrate; - int32_t bottombackingrate; - -numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; -*/ -uint32_t CalculateNumberOfSteps (uint32_t Counter, bool direction) -{ - uint32_t NumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - float screw_horizontal_speed = 0; - float RotationsPerSecond; - - if (Counter) - { - if (Counter%InternalWinderCfg.spoolbackingrate == 1) - { - NumberOfSteps -= (Counter/InternalWinderCfg.spoolbackingrate); - REPORT_MSG(ScrewNumberOfSteps, "Head Backing"); - ScrewNumberOfSteps--; - /* - screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; - // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = dyeingspeed / (InternalWinderCfg.diameter * PI); - RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; - // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. - ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; - - MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - REPORT_MSG(ScrewSpeed, "CalculateNumberOfSteps"); - CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; - */ - } - if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 1)) - { - if (direction != MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) - { - NumberOfSteps += (Counter/InternalWinderCfg.SpoolBottomBackingRate); - ScrewNumberOfSteps++; - REPORT_MSG(ScrewNumberOfSteps, "Bottom Backing"); - } - - } - } - return NumberOfSteps; - -} -uint32_t wtick=0,prevwtick = 0; -uint32_t wgap[100]; -uint32_t wgap_counter=0; -uint32_t ScrewDirectionChange(uint32_t deviceID, uint32_t BusyFlag) -{ - uint32_t Steps; - if (BusyfirstCall) - { - BusyfirstCall = false; - return OK; - } -// if (Winder_Active == false) -// return OK; - wtick++; - //ScrewCurrentDirection: false moves out, true moves home - if (BusyFlag == NOTBUSY) - { - if (wtick-prevwtick>10) - { - wgap[wgap_counter++] = wtick-prevwtick; - prevwtick = wtick; - if (wgap_counter >=99) - wgap_counter = 0; - } - else - return OK; - CalculateNumberOfSteps (DirectionChangeCounter++, ScrewCurrentDirection); - Steps = ScrewNumberOfSteps; - if (ScrewCurrentDirection == false) - { - ScrewCurrentDirection = true; - } - else - { - ScrewCurrentDirection = false; - } -/* 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; - REPORT_MSG(LIMIT, "Winder at right limit"); - } - else if (FPGA_Read_limit_Switches(GPI_LS_SCREW_LEFT)==LIMIT) - { - 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. - REPORT_MSG(ScrewCurrentDirection, "ScrewDirectionChange"); - } - return OK; - -} - -uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue) -{ - return PreSegmentReady(Module_Winder,ModuleDone); -} - -uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId) -{ - //JobTicket* JobTicket = JobDetails; - float screw_horizontal_speed = 0; - float RotationsPerSecond; - char Message[80]; - - if (dyeingspeed == 0) - { - LOG_ERROR (dyeingspeed," job speed zero"); - return ERROR; - } - - if (SegmentId == 0) // do all this only in the beginning of the job. do not touch after that (assuming spool does not change mid job) - { - ScrewCurrentDirection = (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize); - - // * speed is set by the winding parameters and by winder rotational speed (read POSITION every 10msec) - // * calculate - // * 1. calculate speed according to JobTicket->processparameters->dyeingspeed - // * calculation input: traverse length in milimeters/pulses, number of rotations per traverse ==> length of traverse per rotation. - screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; - // calculation input#2: number of rotations per second - (basically: speed/winder perimeter. later - according to winder actual speed - calculate according to winder position accumulation in the last second. - RotationsPerSecond = dyeingspeed / (InternalWinderCfg.diameter * PI); - RotationsPerSecond = CurrentControlledSpeed[WINDER_MOTOR] / MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].pulseperround; - // calculation input#3: speed = rotation per second * traverse per rotation = traverse per second. speed set: traverse per second (mm) * pulses per mm. - ScrewSpeed = screw_horizontal_speed*RotationsPerSecond; - - MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - usnprintf(Message, 80, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed); - //LOG_ERROR(segmentfirst_speed,Message); - //Report(Message,__FILE__,__LINE__,Dispenser_i,RpWarning,segmentfirst_speed,0); - SendJobProgress(0.0,0,false, Message); - - CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; - //screw_horizontal_speed = InternalWinderCfg.milimetersperrotation - // * 2. determine optimal micro-step setting - // * 3. calculate cart travel length from winding parameters - // * 4. start move of travel length - // * 5. register motor nBusy callback. this callback will flip between move(traverse length, hardstop) and goto(0), with handline og the coneshape and adjusting maxspeed - ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - MotorMove (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewCurrentDirection,ScrewNumberOfSteps); //process: set point 0, set max speed, move to the specified length, return back. - wtick = 0;prevwtick = 0; - ScrewControlId = AddControlCallback(ScrewDirectionChange, eOneMillisecond,MotorControlGetnBusyState,(IfTypeMotors*0x100+HARDWARE_MOTOR_TYPE__MOTO_SCREW), HARDWARE_MOTOR_TYPE__MOTO_SCREW, 0); - - // MotorSetSpeedWithCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW, screw_horizontal_speed,WinderPresegmentReady); - //in a callback: calculate backing rate for top and bottom, update point 0, update passing length, call the appropriate move to 0 / move; - - } - PreSegmentReady(Module_Winder,ModuleDone); - - return OK; -} -uint32_t Winder_End(void) -{ - int pend; - //stop screw - ScrewNumberOfSteps = 0; -// Winder_Active = false; - if (ScrewControlId != 0xFF) - RemoveControlCallback(ScrewControlId,ScrewDirectionChange); - CurrentControlledSpeed[SCREW_MOTOR] = 0; - pend = MillisecFlushMsgQ(HARDWARE_MOTOR_TYPE__MOTO_SCREW); - return MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); -} -void Winder_ScrewHomeLimitSwitchInterrupt(void) -{ - //uint32_t status; - //handle glitch - send information to the next time that the motor stops - if (Winder_ScrewHoming) - { - MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); //stop ASAP - } - MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize);//make sure to move the cart out -} -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 - -void ScrewTimerInterrupt(int ARG0) -{ - ROM_TimerIntClear(Screw_timerBase, TIMER_TIMA_TIMEOUT); // Clear the timer interrupt - return ; - -} - - -- cgit v1.3.1 From cfd5d9ffa46286f27d8523d7fd4cc524d267da8a Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 22 Nov 2018 14:34:02 +0200 Subject: Version 1.1.4.4: waste valve handling, L6470 errate fix, and other bugs --- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- Software/Embedded_SW/Embedded/DataDef.h | 2 ++ Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c | 6 ++++-- .../Embedded/Drivers/FPGA/FPGA_SSI_Comm.c | 5 ++++- Software/Embedded_SW/Embedded/Embedded.cfg | 12 ++++++++++++ Software/Embedded_SW/Embedded/Main.c | 9 +++++---- Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h | 2 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_init.c | 6 ++++++ .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 9 ++++++++- .../Embedded/Modules/Stubs_Handler/Stub_Valve.c | 3 ++- .../Embedded/Modules/Thread/Thread_Winder.c | 1 + .../Embedded/StateMachines/Printing/JobSTM.c | 2 +- .../Embedded/StateMachines/Printing/PrintingSTM.h | 1 + Software/PMR/Messages/Common/ErrorCode.proto | 21 ++++++++++++++++++++- 14 files changed, 68 insertions(+), 13 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index 5faf7fbe4..3a7d2b109 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {001,001,004,003}; +TangoVersion_t _gTangoVersion = {001,001,004,004}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 7ace87e27..da6a95cd8 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -46,6 +46,8 @@ enum #define Cartridge_MidTank_OFF 0 #define Atm_MidTank_ON 1 #define Atm_MidTank_OFF 0 +#define Mixer_Head 0 +#define Mixer_Waste 1 #define NEW 0 diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index f661afb2f..649de045e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -83,6 +83,7 @@ int FPGA_ReadVersion(unsigned char FPGA_NUM, unsigned char *Version, unsigned c { VER1 Ver1; VER2 Ver2; +#ifndef EVALUATION_BOARD switch(FPGA_NUM) { @@ -112,7 +113,7 @@ int FPGA_ReadVersion(unsigned char FPGA_NUM, unsigned char *Version, unsigned c *Day = Ver1.bytes.Day; *Year = Ver2.bytes.Year; // to check how many digits is needed *Version = Ver2.bytes.Ver_num; - +#endif return PASSED; } @@ -193,6 +194,7 @@ uint32_t Read_Fans_Tacho() { uint32_t Status = 0; uint32_t Drawer_Fan_Speed_RPM = 0; +#ifndef EVALUATION_BOARD // The big Fan in the drawer Drawer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(25000000, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); @@ -237,7 +239,7 @@ uint32_t Read_Fans_Tacho() else Status&= ~(0x01<<4);//working } - +#endif return Status; } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SSI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SSI_Comm.c index 25b18e48a..9bc8f3db6 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SSI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SSI_Comm.c @@ -70,16 +70,19 @@ static FpgaDancerMap_t FpgaSpeedSensorMap = uint8_t FPGA_SSI_Speed_Sensor_Transnit() { +#ifndef EVALUATION_BOARD //if(*FpgaSpeedSensorMap.SSI_Busy == NOTBUSY) { uint32_t SSI_Dummy_TX= 0x123456; // Dummy *FpgaSpeedSensorMap.TX_Reg = SSI_Dummy_TX ; } +#endif return OK; } uint32_t FPGA_SSI_Speed_Sensor_Receive() { +#ifndef EVALUATION_BOARD INT2SHORT Int2Short; //unsigned int temp; @@ -88,7 +91,7 @@ uint32_t FPGA_SSI_Speed_Sensor_Receive() Int2Short.ushort.MSB = *FpgaSpeedSensorMap.RX_M; //temp = Int2Short.uint; SpeedSensorResponseS.Speed = Int2Short.uint; - +#endif //return OK; return SpeedSensorResponseS.Speed; } diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 0017003a9..a49f86836 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -137,7 +137,19 @@ task5Params.instance.name = "process"; task5Params.stackSize = 2048; task5Params.priority = 8; Program.global.process = Task.create("&jobTask", task5Params); +/* +var task8Params = new Task.Params(); +task8Params.instance.name = "MilliSecondLow"; +task8Params.stackSize = 2048; +task8Params.priority = 7; +Program.global.millisec = Task.create("&MillisecTask", task8Params); +var task7Params = new Task.Params(); +task7Params.instance.name = "controlLow"; +task7Params.stackSize = 2048; +task7Params.priority = 7; +Program.global.control = Task.create("&controlTask", task7Params); +*/ var task10Params = new Task.Params(); task10Params.instance.name = "communicationTx"; task10Params.priority = 7; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index c82a2f9e1..14b43b8bd 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -129,7 +129,7 @@ int main(void) ROM_SysTickIntEnable(); ROM_SysTickEnable(); - Calculateinit(); + //Calculateinit(); PortFunctionInit(); @@ -218,17 +218,18 @@ int main(void) Heaters_Init(); ControlStart(); MotorsInit(); + IDS_ModuleInit(); //////////////////////////// -/* - FRESULT iFResult = Init_Flash_File_System(true); + + FRESULT iFResult = Init_Flash_File_System(false); if(iFResult != FR_OK) { LOG_ERROR (iFResult, "Error during init Flash File System"); assert(iFResult); } //Control_File_System();// test file system -*/ + //////////////////////////// // Enable interrupts to the processor. diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index 2b8779207..db2277659 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -29,7 +29,7 @@ typedef enum { LimitSwitchAlarmLow_8, //MOTO_DISPENSER_8 = 13, }LimitSwitchAlarms; -void Calculateinit (void); +void IDS_ModuleInit (void); uint32_t IDSPrepareState(void *JobDetails); uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c index b035ff97b..43984f8d1 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_init.c @@ -13,6 +13,7 @@ #include "drivers/Motors/Motor.h" #include "drivers/ADC_Sampling/adc.h" +#include "drivers/valves/valve.h" #define MAX_CONTROL_SAMPLES 10 @@ -89,4 +90,9 @@ uint32_t DispenserConfigMessage(HardwareDispenser * request) else return Dispenser_i; } +void IDS_ModuleInit(void) +{ + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); + Calculateinit(); +} diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 57b346513..f9c4c1bc3 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -116,6 +116,7 @@ void DispenserPrepareReady(void) int Motor_i, HW_Motor_Id, Pid_Id,i; //start IDS control for all motors IDS_Active = true; + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); for (Motor_i = 0;Motor_i < MAX_SYSTEM_DISPENSERS;Motor_i++) { HW_Motor_Id = DispenserIdToMotorId[Motor_i]; @@ -229,6 +230,11 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) LOG_ERROR(JobBrushStopId,"Error JobBrushStopId"); return ERROR; } + if (( JobTicket->enableintersegment == true)&&(JobTicket->intersegmentlength>0)) + { + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away + } + if (JobTicket->segments[SegmentId]->brushstops[JobBrushStopId]->n_dispensers) { n_dispensers = JobTicket->segments[SegmentId]->brushstops[JobBrushStopId]->n_dispensers; @@ -299,7 +305,6 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) double segmentfirst_speed; int CurrentSegment = SegmentId; - if (CurrentSegment>=JobTicket->n_segments) { LOG_ERROR(CurrentSegment,"Error Segment"); @@ -310,6 +315,7 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) LOG_ERROR(JobBrushStopId,"Error JobBrushStopId"); return ERROR; } + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Head); if (JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->n_dispensers) { n_dispensers = JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->n_dispensers; @@ -393,6 +399,7 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) { int Dispenser_i; IDS_Active = false; + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); for ( Dispenser_i = 0;Dispenser_i < MAX_SYSTEM_DISPENSERS;Dispenser_i++) { MotorStop(DispenserIdToMotorId[Dispenser_i],Hard_Hiz); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c index 759d76a43..5f087c50a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Valve.c @@ -32,8 +32,9 @@ void Stub_ValveRequest(MessageContainer* requestContainer) request->inkflow request->valveon */ - Control3WayValvesWithCallback (request->valveid, request->valveon, NULL); + //Control3WayValvesWithCallback (request->valveid, request->valveon, NULL); //test_valve_3_way(request->valveid, request->valveon); + Valve_Set(request->valveid, request->valveon); StubValveResponse response = STUB_VALVE_RESPONSE__INIT; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index fd577311e..b6392249a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -142,6 +142,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); + MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands PrepareReady(Module_Winder, ModuleDone); return OK; } diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index e3cd3ca64..2eed69f24 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -66,7 +66,7 @@ Mailbox_Handle JobmsgQ = NULL; //static Clock_Params jobclkParams; JobEndReasonEnum JobEndReason = JOB_OK; -ErrorCode JobError_to_ErrorCode[JOB_OTHER_ALARM+1] = {ERROR_CODE__NONE,ERROR_CODE__JOB_UNSPECIFIED_ERROR,ERROR_CODE__JOB_THREAD_BREAK,ERROR_CODE__JOB_WINDER_DANCER_FAIL, +ErrorCode JobError_to_ErrorCode[JOB_ERRORS_MAX+1] = {ERROR_CODE__NONE,ERROR_CODE__JOB_UNSPECIFIED_ERROR,ERROR_CODE__JOB_THREAD_BREAK,ERROR_CODE__JOB_WINDER_DANCER_FAIL, ERROR_CODE__JOB_POOLER_DANCER_FAIL,ERROR_CODE__JOB_FEEDER_DANCER_FAIL,ERROR_CODE__JOB_OUT_OF_DYE,ERROR_CODE__JOB_OTHER_ALARM, ERROR_CODE__JOB_TEMPERATURE_ALARM,ERROR_CODE__JOB_LS_ALARM,ERROR_CODE__JOB_PRESSURE_ALARM,ERROR_CODE__JOB_CURRENT_ALARM,ERROR_CODE__JOB_MOTOR_ALARM}; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h index 795daa836..0b9c68394 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h @@ -94,6 +94,7 @@ typedef enum JOB_CURRENT_ALARM, JOB_MOTOR_ALARM, + JOB_ERRORS_MAX }JobEndReasonEnum; extern JobEndReasonEnum JobEndReason; diff --git a/Software/PMR/Messages/Common/ErrorCode.proto b/Software/PMR/Messages/Common/ErrorCode.proto index 563edfaf1..97f5a65a4 100644 --- a/Software/PMR/Messages/Common/ErrorCode.proto +++ b/Software/PMR/Messages/Common/ErrorCode.proto @@ -20,8 +20,27 @@ enum ErrorCode FILE_NOT_FOUND = 1001; //Returned by ExecuteProcessResponse when the FileName was not found. INVALID_PROCESS_ID = 1002; //Returned by KillProcessResponse when the process id was not found. FILE_LENGTH_OUT_OF_RANGE = 1003; //Returned by FileChunkUploadResponse when the uploaded file size exceeds the expected Length from FileUploadRequest. + FILE_REQUEST_DISK_ERR = 1004; + FILE_REQUEST_INT_ERR = 1005; + FILE_REQUEST_NOT_READY = 1006; + FILE_REQUEST_NO_FILE = 1007; + FILE_REQUEST_NO_PATH = 1008; + FILE_REQUEST_INVALID_NAME = 1009; + FILE_REQUEST_DENIED = 1010; + FILE_REQUEST_EXIST = 1011; + FILE_REQUEST_INVALID_OBJECT = 1012; + FILE_REQUEST_WRITE_PROTECTED = 1013; + FILE_REQUEST_INVALID_DRIVE = 1014; + FILE_REQUEST_NOT_ENABLED = 1015; + FILE_REQUEST_NO_FILESYSTEM = 1016; + FILE_REQUEST_MKFS_ABORTED = 1017; + FILE_REQUEST_TIMEOUT = 1018; + FILE_REQUEST_LOCKED = 1019; + FILE_REQUEST_NOT_ENOUGH_CORE = 1020; + FILE_REQUEST_TOO_MANY_OPEN_FILES = 1021; + FILE_REQUEST_INVALID_PARAMETER = 1022; - //Job Failure + //Job Failure JOB_UNSPECIFIED_ERROR = 2000; JOB_THREAD_BREAK = 2001; JOB_WINDER_DANCER_FAIL = 2002; -- cgit v1.3.1