From 0536e840cfe32e13e276568f4f7a607acd22a740 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 5 Nov 2018 10:25:27 +0200 Subject: small changes --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index eb04cadaf..87d264a33 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -22,7 +22,7 @@ #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" bool Winder_ScrewHoming = false; -//bool Winder_Active = 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); @@ -73,7 +73,7 @@ uint32_t Winder_Prepare(void) { uint32_t status = 0; //JobTicket* JobTicket = JobDetails; -// Winder_Active = true; + 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"); -- cgit v1.3.1 From 8cae26aa5d465477a408500ae64f2afc05859a6a Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 7 Nov 2018 11:32:55 +0200 Subject: some memory improvements. job resume fixed, preparation for new winder. --- .../Embedded_SW/Embedded/Common/Utilities/Utils.c | 135 +++---- .../Embedded/Common/Utilities/idle_task.c | 2 +- .../Embedded/Communication/CommunicationTask.c | 2 +- .../Embedded/Communication/Connection.c | 10 +- .../Embedded_SW/Embedded/Communication/Container.c | 6 + Software/Embedded_SW/Embedded/DataDef.h | 2 +- .../Embedded/Drivers/FPGA/FPGA_SPI_Comm.c | 16 + .../Embedded/Drivers/FPGA/FPGA_SPI_Comm.h | 2 + .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 9 + .../Embedded_SW/Embedded/Drivers/Motors/Motor.h | 1 + Software/Embedded_SW/Embedded/Embedded.cfg | 48 +-- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 17 +- .../Embedded/Modules/Diagnostics/Diagnostics.c | 18 +- .../Modules/Diagnostics/DiagnosticsHoming.c | 2 +- .../Embedded_SW/Embedded/Modules/Thread/Thread.h | 1 + .../Embedded/Modules/Thread/Thread_Winder.new | 394 +++++++++++++++++++++ .../Embedded/Modules/Thread/Thread_Winder.old | 366 +++++++++++++++++++ .../Embedded/StateMachines/Printing/JobSTM.c | 5 +- .../Embedded/StateMachines/Printing/PrintingSTM.c | 8 +- .../Embedded/StateMachines/Printing/PrintingSTM.h | 1 + 20 files changed, 895 insertions(+), 150 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new create 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/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c index 4e2a5cdf1..20ab5e2a6 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c @@ -3,6 +3,7 @@ * general module of system utility functions **************************************************************/ +#include "include.h" #include #include #include @@ -15,114 +16,58 @@ static const float speedCoef = 5.3051647697298445256294587790838f;//(200 micro s //***************************************************************************** -bool DanserCheckPosition(uint16_t position , Danser_t danser, bool test) -{ - if (test == false) return true; -#ifdef DEBUG_DANCER - ProfileType_t profileType = GetCurrentProfileType(); - if (position < DANSER_POS_MIN) - { - if(danser == Winder) - { - if(profileType == Manual) - { - JigStopAllWithError("Thread torn in winder danser");//for stoping the system operation - } - else if (profileType == User) - { - //notify the UI about an error and pause the system - SendMessageToHost(ERROR_IN_PROFILE_EXECUTION,"Thread torn in winder danser"); - JigPauseAll(); - } - } - else - { - if(profileType == Manual) - { - JigStopAllWithError("Thread torn in pooler danser");//for stoping the system operation - } - else if (profileType == User) - { - //notify the UI about an error and pause the system - SendMessageToHost(ERROR_IN_PROFILE_EXECUTION,"Thread torn in pooler danser"); - JigPauseAll(); - } - } - return false; - } - - if (position > DANSER_POS_MAX) - { - if(danser == Pooler) - { - if(profileType == Manual) - { - JigStopAllWithError("Thread stocked in pooler danser"); - } - else if (profileType == User) - { - SendMessageToHost(ERROR_IN_PROFILE_EXECUTION,"Thread stuck in pooler danser"); - JigPauseAll(); - } - } - else - { - if(profileType == Manual) - { - JigStopAllWithError("Thread stocked in winder danser"); - } - else if (profileType ==User) - { - SendMessageToHost(ERROR_IN_PROFILE_EXECUTION,"Thread stuck in winder danser"); - JigPauseAll(); - } - } - return false; - } -#endif - return true; -} -#define MAX_MEM_LOG 500 +#define MAX_MEM_LOG 200 int freeIndex=0,malloc_index=0; uint32_t malloc_size[MAX_MEM_LOG]; uint32_t malloc_time[MAX_MEM_LOG]; void * malloc_addr[MAX_MEM_LOG]; -void * free_addr[MAX_MEM_LOG]; +//void * free_addr[MAX_MEM_LOG]; //uint32_t total_allocated = 0; void *my_malloc(size_t _size) { void * addr = malloc (_size); - malloc_addr[malloc_index] = addr; - malloc_size[malloc_index] = _size; - malloc_time[malloc_index] = HibernateRTCSSGet(); - if (malloc_index++>=MAX_MEM_LOG) - malloc_index = 0; + int i; + for (i=0; i< MAX_MEM_LOG;i++) + { + if (malloc_time[i] == 0) + { + malloc_index = i; + break; + } + } + assert (malloc_index=MAX_MEM_LOG) + // malloc_index = 0; return addr; } +int allocated_size = 0; void my_free(void *_ptr) { - free_addr[freeIndex] = _ptr; - if (freeIndex++>=MAX_MEM_LOG) - freeIndex = 0; + int i; if (_ptr) - free(_ptr); - -} -//***************************************************************************** -//convert thread speed recieved in milimeters per second into motor steps of pps -//***************************************************************************** -uint16_t ConvertSpeed2Pps(uint16_t milimeterPerSecond) -{ - float res = speedCoef*(float)milimeterPerSecond; - return (uint16_t)res; -} -//***************************************************************************** - -uint16_t ConvertPpsToSpeed(uint16_t Pps) -{ - float res = (float)Pps/speedCoef; - return (uint16_t)res; - + { + for (i=0; i< MAX_MEM_LOG;i++) + { + if ( malloc_addr[i] == _ptr) + { + malloc_time[i] = 0; + malloc_size[i] = 0; + } + } + allocated_size = 0; + for (i=0; i< MAX_MEM_LOG;i++) + allocated_size+=malloc_size[i]; + free(_ptr); + } } //***************************************************************************** diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c b/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c index 6983d5093..6413c83b1 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/idle_task.c @@ -100,7 +100,7 @@ extern void IDLE_TASK_package_init(void) Task_Params_init(&taskParams); taskParams.instance->name = IdleStTaskName; taskParams.priority = MAX_PRIORITY; - taskParams.stackSize = 2048; + taskParams.stackSize = 512; IdleStTaskHandle = Task_create((Task_FuncPtr)IDLE_statistics_task, &taskParams, &eb); //if (IdleTaskHandle == NULL) { // System_printf("netOpenHook: Failed to create tcpHandler Task\n"); diff --git a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c index ff547311b..ac0f13a2a 100644 --- a/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c +++ b/Software/Embedded_SW/Embedded/Communication/CommunicationTask.c @@ -12,7 +12,7 @@ static void (*callback)(char* buffer, size_t length); Mailbox_Handle CommunicationRxMsgQ = NULL; Mailbox_Handle CommunicationTxMsgQ = NULL; -#define COMMUNICATION_NUM_MSGS 100 +#define COMMUNICATION_NUM_MSGS 15 typedef struct CommRxMessage{ //uint16_t messageId; uint16_t msgSize; diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 7b653bf72..56ca9ab2d 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -92,7 +92,7 @@ void DisconnectionRequest(MessageContainer* requestContainer) { MessageContainer responseContainer; - DisconnectRequest* request = disconnect_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + //DisconnectRequest* request = disconnect_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); DisconnectResponse response = DISCONNECT_RESPONSE__INIT; responseContainer = createContainer(MESSAGE_TYPE__DisconnectResponse, requestContainer->token, true, &response, &disconnect_response__pack, &disconnect_response__get_packed_size); @@ -106,19 +106,19 @@ void DisconnectionRequest(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); - disconnect_request__free_unpacked(request,NULL); + //disconnect_request__free_unpacked(request,NULL); CommunicationMailboxFlush(); USBCDCD_Reinit(); } int KeepAliveOneSecondCounter = 0; -#define KEEPALIVE_COMMUNICATION_ABORT_LIMIT 15 +#define KEEPALIVE_COMMUNICATION_ABORT_LIMIT 30 bool KeepAliveActive = false; void KeepAliveRequestFunc(MessageContainer* requestContainer) { MessageContainer responseContainer; - KeepAliveRequest* request = keep_alive_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + //KeepAliveRequest* request = keep_alive_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); KeepAliveResponse response = KEEP_ALIVE_RESPONSE__INIT; KeepAliveOneSecondCounter = 0; @@ -129,7 +129,7 @@ void KeepAliveRequestFunc(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); SendChars((char*)container_buffer, container_size); - keep_alive_request__free_unpacked(request,NULL); + //keep_alive_request__free_unpacked(request,NULL); } void KeepAliveOneSecondCall(void) { diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index d1bac1ec3..408e88a3d 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -214,6 +214,12 @@ void receive_callback(char* buffer, size_t length) case MESSAGE_TYPE__AbortJobRequest: JobAbortFunc(requestContainer); break; + case MESSAGE_TYPE__CurrentJobRequest: + CurrentJobRequestFunc(requestContainer); + break; + case MESSAGE_TYPE__ResumeCurrentJobRequest: + ResumeCurrentJobRequestFunc(requestContainer); + break; case MESSAGE_TYPE__UploadHardwareConfigurationRequest: HWConfigurationFunc(requestContainer); break; diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 555914a0b..7ace87e27 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -215,7 +215,7 @@ typedef struct //S_SPI extern void *my_malloc(size_t _size); extern void my_free(void *_ptr); - +extern uint32_t msec_millisecondCounter; //--------------------------------------------------------------------- #pragma diag_suppress 169 /* Avoid warnings on VOID * conversions (protobuf issue) The warning: diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 4acb212ef..2bb3f6608 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -597,6 +597,22 @@ void FPGA_SetMotSpeed(TimerMotors_t _motorId)//Run // FPGA_SPI_Transnit(_motorId); //----------------------------------------------------- } +void FPGA_SetMotSpeedDirect(TimerMotors_t _motorId)//Run +{ + uint32_t temp; + + temp = x_RUN | MotorDriverRequest[_motorId].Direction; + temp = temp << 24; + + if (MotorDriverRequest[_motorId].Speed > 0xFFFFF) //TODO to check if it is needed here + MotorDriverRequest[_motorId].Speed = 0xFFFFF; + + temp |= MotorDriverRequest[_motorId].Speed; + + Fpga_Spi[_motorId].TX_MOSI = temp; + Fpga_Spi[_motorId].AMT_OF_Words = 4; + FPGA_SPI_Transnit(_motorId); +} void FPGA_SetMotMaxSpeed(TimerMotors_t _motorId)//Mov { uint32_t temp; diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h index 046d3e5d9..73db4224a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.h @@ -24,6 +24,8 @@ void FPGA_SetMotMaxSpeed(TimerMotors_t _motorId); void FPGA_SetMotMicroStep(TimerMotors_t _motorId); void FPGA_SetMotPosition(TimerMotors_t _motorId); void FPGA_SetMotSpeed(TimerMotors_t _motorId); +void FPGA_SetMotSpeedDirect(TimerMotors_t _motorId); + void FPGA_SetMotorsInit(); uint32_t FPGA_MotorConfig(TimerMotors_t _motorId, MotorDriverConfigStruc *MotorConfig); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index 54a0de3e8..8374133a7 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -148,6 +148,15 @@ uint32_t MotorSetSpeed(TimerMotors_t _motorId, uint32_t _freq)//TODO MicroSteps? return OK; } +uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, uint32_t _freq) +{ + int RunSpeed = SpdCalc(_freq); + MotorDriverRequest[_motorId].Speed = RunSpeed; + FPGA_SetMotSpeedDirect(_motorId); + + return OK; +} + uint32_t MotorGetSpeed(TimerMotors_t _motorId) { diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h index 672b94a18..6d037f3b4 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h @@ -117,6 +117,7 @@ uint32_t MotorGetDirection(TimerMotors_t _motorId); uint32_t MotorSetDirection(TimerMotors_t _motorId,bool _direction); uint32_t MotorSetSpeed(TimerMotors_t _motorId, uint32_t _freq); +uint32_t MotorSetSpeedDirect(TimerMotors_t _motorId, uint32_t _freq); // call directly and not from millisec task uint32_t MotorSetMaxSpeed(TimerMotors_t _motorId, uint32_t MaxSpeed); diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 599609b38..d41241553 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -17,7 +17,7 @@ var Task = xdc.useModule('ti.sysbios.knl.Task'); BIOS.heapSize = 30767; // bios heapmem //Memory.defaultHeapSize = 48767; -Program.heap = 50000; //sysmem +Program.heap = 40000; //sysmem Clock.timerId = 7; @@ -56,6 +56,10 @@ var hwi6Params = new Hwi.Params(); hwi6Params.instance.name = "timer1"; Program.global.timer1 = Hwi.create(37, "&OneMilliSecondMillisecInterrupt", hwi6Params); +var hwi17Params = new Hwi.Params(); +hwi17Params.instance.name = "timer3"; +hwi17Params.arg = 3; +Program.global.timer3 = Hwi.create(51, "&ScrewTimerInterrupt", hwi17Params); /* var semaphore1Params = new Semaphore.Params(); @@ -107,12 +111,13 @@ Program.global.ReconnectSem = Semaphore.create(null, semaphore7Params); });*/ var task8Params = new Task.Params(); task8Params.instance.name = "MilliSecond"; +task8Params.stackSize = 2048; task8Params.priority = 12; Program.global.millisec = Task.create("&MillisecTask", task8Params); var task7Params = new Task.Params(); task7Params.instance.name = "control"; -task7Params.stackSize = 4096; +task7Params.stackSize = 2048; task7Params.priority = 11; Program.global.control = Task.create("&controlTask", task7Params); @@ -129,7 +134,7 @@ Program.global.HeatersControl = Task.create("&HeatersControlTask", task9Params); var task5Params = new Task.Params(); task5Params.instance.name = "process"; -task5Params.stackSize = 4096; +task5Params.stackSize = 2048; task5Params.priority = 8; Program.global.process = Task.create("&jobTask", task5Params); @@ -140,12 +145,13 @@ Program.global.communicationTx = Task.create("&communicationTxTask", task10Param var task12Params = new Task.Params(); task12Params.instance.name = "AlarmHandling"; -task12Params.stackSize = 2048; +task12Params.stackSize = 1024; task12Params.priority = 6; Program.global.AlarmHandling = Task.create("&AlarmHandlingTask", task12Params); var task0Params = new Task.Params(); task0Params.instance.name = "adcProcess"; +task0Params.stackSize = 512; task0Params.priority = 6; Program.global.adcProcess = Task.create("&ADCProcessTask", task0Params); @@ -160,38 +166,6 @@ task6Params.instance.name = "report"; task6Params.priority = 3; Program.global.report = Task.create("&reportService", task6Params); -/*var task3Params = new Task.Params(); -task3Params.instance.name = "update"; -task3Params.priority = 2; -Program.global.update = Task.create("&updateTask", task3Params); - -var task4Params = new Task.Params(); -task4Params.instance.name = "Reconnect"; -task4Params.priority = 2; -Program.global.Reconnect = Task.create("&ReconnectTask", task4Params); -*/ -/* ================ NDK configuration ================ */ -/*var Ndk = xdc.loadPackage('ti.ndk.config'); -var Global = xdc.useModule('ti.ndk.config.Global'); -var Ip = xdc.useModule('ti.ndk.config.Ip'); -var Udp = xdc.useModule('ti.ndk.config.Udp'); -var Tcp = xdc.useModule('ti.ndk.config.Tcp'); - -Global.IPv6 = false; -Global.stackLibType = Global.MIN; -Global.networkOpenHook = "&netOpenHook"; - -/* automatically call fdOpen/CloseSession for our sockets Task */ -/*Global.autoOpenCloseFD = true; - -Global.pktNumFrameBufs = 10; -Global.memRawPageCount = 6; -Global.ndkThreadStackSize = 2048; -Global.lowTaskStackSize = 1024; -Global.normTaskStackSize = 1024; -Global.highTaskStackSize = 1024; -Tcp.transmitBufSize = 1024; -Tcp.receiveBufSize = 1024; /* ================ Text configuration ================ */ var Text = xdc.useModule('xdc.runtime.Text'); /* @@ -251,4 +225,4 @@ Program.gen.debuggerFiles = false; Task.defaultStackSize = 1024; Task.idleTaskVitalTaskFlag = false; Task.enableIdleTask = false; -Program.stack = 2048; +Program.stack = 4096; diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 0dde99140..49d13d07f 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -376,6 +376,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) { int Alarm_i; uint32_t value; + int32_t ivalue; bool Status = false; for (Alarm_i = 0;Alarm_i < MAX_SYSTEM_ALARMS;Alarm_i++) { @@ -385,19 +386,20 @@ uint32_t AlarmHandlingLoop(uint32_t tick) switch (AlarmItem[Alarm_i].AlarmSource) { case TemperatureAlarm: - value = TemperatureSensorRead(AlarmItem[Alarm_i].DeviceId); + ivalue = TemperatureSensorRead(AlarmItem[Alarm_i].DeviceId); if (AlarmItem[Alarm_i].AlarmDirection == true) { - if (value/100 >= AlarmItem[Alarm_i].AlarmValue) + if (ivalue/100 >= AlarmItem[Alarm_i].AlarmValue) { - LOG_ERROR (value,"Temperature spike"); + LOG_ERROR (ivalue/100,"Temperature spike"); Status = true; } } else { - if (value/100 <= AlarmItem[Alarm_i].AlarmValue) + if (ivalue/100 <= AlarmItem[Alarm_i].AlarmValue) { + LOG_ERROR (ivalue/100,"Temperature spike"); Status = true; } } @@ -564,6 +566,7 @@ void AlarmHandlingTask(UArg arg0, UArg arg1) } //StartEventsNotificationResponse StartEventsNotification = START_EVENTS_NOTIFICATION_RESPONSE__INIT; StartEventsNotificationResponse response = START_EVENTS_NOTIFICATION_RESPONSE__INIT; +int LargeMessagesAH = 0; void SendEventNotifications(void) { MessageContainer responseContainer; @@ -574,6 +577,12 @@ void SendEventNotifications(void) return; if (AlarmHandlingToken[0] == 0) return; + if (SuspendLargeMessages == true) + { + LargeMessagesAH++; + return; + } + response.n_events = 0; for (i = 0;idirection == MOTOR_DIRECTION__Forward) //opening the loading system + if (request->direction == MOTOR_DIRECTION__Backward) //opening the loading system { if ( Motor_Id_to_LS_IdUp[MotorId] != MAX_GPI) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index a725468e9..9c42dde01 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -43,6 +43,7 @@ extern HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM]; //extern InternalWinderConfigStruc InternalWinderCfg; extern HardwareDancer DancersCfg[MAX_SYSTEM_DANCERS]; extern uint32_t CurrentControlledSpeed[MAX_THREAD_MOTORS_NUM]; +extern int OriginalMotorSpd_2PPS[MAX_THREAD_MOTORS_NUM]; #define MAX_CONTROL_SAMPLES 10 extern int32_t MotorSamples[MAX_THREAD_MOTORS_NUM][MAX_CONTROL_SAMPLES]; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new new file mode 100644 index 000000000..ba4a5c8e0 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new @@ -0,0 +1,394 @@ +/* + * 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 +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 = 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 ScrewSpeed"); + REPORT_MSG(CurrentControlledSpeed[WINDER_MOTOR], "CalculateNumberOfSteps Winder speed"); + CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; + + } + if ((Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)||(Counter%InternalWinderCfg.SpoolBottomBackingRate == 0)) + { + if (direction != MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) + { + 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; + //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 new file mode 100644 index 000000000..1aaeec556 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.old @@ -0,0 +1,366 @@ +/* + * 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 ; + +} + + diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 353342e08..f4b83a3cf 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -558,6 +558,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes return; + ResumeCurrentJobResponse resumeresponse = RESUME_CURRENT_JOB_RESPONSE__INIT; JobResponse response = JOB_RESPONSE__INIT; JobStatus jobStatus = JOB_STATUS__INIT; @@ -571,13 +572,14 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes jobStatus.has_currentsegmentindex = true; jobStatus.currentsegmentindex = SegmentId; - response.status = &jobStatus; if (JobResumed == true) { + resumeresponse.status = &jobStatus; responseContainer = createContainer(MESSAGE_TYPE__ResumeCurrentJobResponse, JobToken, done, &response, &resume_current_job_response__pack, &resume_current_job_response__get_packed_size); } else { + response.status = &jobStatus; responseContainer = createContainer(MESSAGE_TYPE__JobResponse, JobToken, done, &response, &job_response__pack, &job_response__get_packed_size); } @@ -753,6 +755,7 @@ Void jobTask(UArg arg0, UArg arg1) if (CurrentRequest!= NULL) job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = NULL; + SuspendLargeMessages = true; //CleanState(CurrentJob); break; case PrintingResultsFail: diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index bf07c1546..204410bcd 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -66,6 +66,8 @@ ModuleStateEnum EndWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,M bool Configured[MAX_SYSTEM_MODULES] = {false,false,false,false,false}; +bool SuspendLargeMessages = false; + /******************************************************************************************************************** * this function is for development initial stages. it analyses the hardware configuration to determine which modules are operational * according to the configuration map @@ -368,8 +370,8 @@ static uint32_t DistanceToSpoolState(void *JobDetails) uint32_t EndState(void *JobDetails, char *Message) { - ROM_IntMasterDisable(); - + //ROM_IntMasterDisable(); + SuspendLargeMessages = true; if (Configured[Module_Winder]) { PrepareWaiting[Module_Winder] = ModuleIdle; @@ -403,7 +405,7 @@ uint32_t EndState(void *JobDetails, char *Message) //EndWaiting[Module_Thread] = ModuleWaiting; ThreadEndState(CurrentJob); } - ROM_IntMasterEnable(); + //ROM_IntMasterEnable(); SendJobProgress(0.0,0,true,Message); JobMessageStruc JobMessage; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h index 7e8e68eb8..aa44c6190 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h @@ -153,6 +153,7 @@ uint32_t CurrentJobRequestFunc(MessageContainer* requestContainer); uint32_t ResumeCurrentJobRequestFunc(MessageContainer* requestContainer); bool JobIsActive(void); +extern bool SuspendLargeMessages; void SendJobProgress(double ProcessedLength,int SegmentId, bool done, char *Message); -- cgit v1.3.1 From 7a0d85d98397780aab9909550028f2a51811c184 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Wed, 7 Nov 2018 12:03:11 +0200 Subject: job resume fix. rockers --- .../Embedded/Common/SWUpdate/FileSystem.c | 14 +++++++++--- .../Modules/Diagnostics/DiagnosticActions.c | 25 ---------------------- .../Embedded/Modules/Thread/Thread_print.c | 4 ++-- .../Embedded/StateMachines/Printing/JobSTM.c | 2 +- 4 files changed, 14 insertions(+), 31 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 724522b75..78fba3c49 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -86,6 +86,7 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); + file_upload_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); return OK; @@ -156,6 +157,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) responseContainer.continuous = false; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); + file_chunk_upload_request__free_unpacked(request,NULL); my_free(responseContainer.data.data); SendChars(container_buffer, container_size); @@ -181,6 +183,7 @@ uint32_t ExecuteProcessRequestFunc(MessageContainer* requestContainer) responseContainer.continuous = false; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); + execute_process_request__free_unpacked(request,NULL); my_free(responseContainer.data.data); SendChars(container_buffer, container_size); @@ -207,6 +210,7 @@ uint32_t KillProcessRequestFunc(MessageContainer* requestContainer) uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); + kill_process_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); return OK; @@ -261,6 +265,7 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer) uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); + create_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); return OK; @@ -327,6 +332,7 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); + delete_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); return OK; @@ -370,6 +376,7 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer) uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); + get_storage_info_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); return OK; @@ -392,7 +399,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) FileInfo **FilesInfo = (FileInfo**)my_malloc(sizeof(FileInfo *)*(MAX_NUM_OF_FILES)); FileInfo Data[MAX_NUM_OF_FILES]; - fno[0] = malloc(sizeof(FILINFO)); + fno[0] = my_malloc(sizeof(FILINFO)); memset (fno[0],0,sizeof(FILINFO)); Fresult = f_stat(request->path,fno[0]); if (Fresult == FR_OK) @@ -406,7 +413,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) { for (NumOfFiles = 1;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) { - fno[NumOfFiles] = malloc(sizeof(FILINFO)); + fno[NumOfFiles] = my_malloc(sizeof(FILINFO)); memset (fno[NumOfFiles],0,sizeof(FILINFO)); Fresult = f_readdir(&dir, &fno[NumOfFiles]); /* Read a directory item */ if (Fresult == FR_OK) @@ -449,11 +456,12 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) size_t container_size = message_container__pack(&responseContainer, container_buffer); my_free(responseContainer.data.data); my_free(FilesInfo); + get_files_request__free_unpacked(request,NULL); SendChars(container_buffer, container_size); for (NumOfFiles = 0;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) { if (fno[NumOfFiles]) - free (fno[NumOfFiles]); + my_free (fno[NumOfFiles]); } return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c index 0fb314372..0cdf5635d 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c @@ -185,30 +185,5 @@ uint32_t SetDigitalOutRequestRequestFunc(MessageContainer* requestContainer) return OK; } -/* case: - break; - INTERFACE_IOS__GPO_MIXCHIP_SSR4_CTRL - INTERFACE_IOS__GPO_DYEINGH_SSR5_CTRL - INTERFACE_IOS__GPO_DYEINGH_SSR6_CTRL - INTERFACE_IOS__GPO_DYEINGH_SSR7_CTRL - INTERFACE_IOS__GPO_DYEINGH_SSR8_CTRL - INTERFACE_IOS__GPO_DRYER_SSR1_CTRL - INTERFACE_IOS__GPO_DRYER_SSR2_CTRL - INTERFACE_IOS__GPO_DRYER_SSR3_CTRL - INTERFACE_IOS__GPO_PDOWN_RL1_CTRL - INTERFACE_IOS__GPO_SPARE_SSR12_CTRL - INTERFACE_IOS__GPO_SPARE_SSR13_CTRL - INTERFACE_IOS__GPO_DILUTORPUMP_SSR10_CTRL - INTERFACE_IOS__GPO_WASTECH_PUMP2 - INTERFACE_IOS__GPO_BUZZER - INTERFACE_IOS__GPO_LED1 - INTERFACE_IOS__GPO_LED2 - INTERFACE_IOS__GPO_LED3 - INTERFACE_IOS__GPO_LED4 - INTERFACE_IOS__GPO_TFEED_BREAK_1 - INTERFACE_IOS__GPO_BLOWER_PWM - INTERFACE_IOS__GPO_CHILLER_SSR9_CTRL - INTERFACE_IOS__GPO_WHS_WTANKPUMP2 - */ diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 175cfcc7d..22f54eb50 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -672,12 +672,12 @@ uint32_t ThreadPreSegmentState(void *JobDetails) if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].maxfrequency > 0) { MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize); - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 2); + MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 1); } if (MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].maxfrequency > 0) { MotorSetDirection((TimerMotors_t)HARDWARE_MOTOR_TYPE__MOTO_LLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LLOADING].directionthreadwize); - MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 2); + MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 1); } // #warning rocker disabled diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index f4b83a3cf..02a24c642 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -575,7 +575,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes if (JobResumed == true) { resumeresponse.status = &jobStatus; - responseContainer = createContainer(MESSAGE_TYPE__ResumeCurrentJobResponse, JobToken, done, &response, &resume_current_job_response__pack, &resume_current_job_response__get_packed_size); + responseContainer = createContainer(MESSAGE_TYPE__ResumeCurrentJobResponse, JobToken, done, &resumeresponse, &resume_current_job_response__pack, &resume_current_job_response__get_packed_size); } else { -- cgit v1.3.1 From e67d15360ce355ac9e675079cd5d6442e3fa1905 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 8 Nov 2018 11:23:48 +0200 Subject: fix bugs --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new | 7 +++++++ Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) (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 ba4a5c8e0..f33a134e1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.new @@ -32,6 +32,7 @@ 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; @@ -210,6 +211,12 @@ 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) { diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index f4b83a3cf..f0415fac1 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -755,7 +755,7 @@ Void jobTask(UArg arg0, UArg arg1) if (CurrentRequest!= NULL) job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = NULL; - SuspendLargeMessages = true; + SuspendLargeMessages = false; //CleanState(CurrentJob); break; case PrintingResultsFail: @@ -764,6 +764,7 @@ Void jobTask(UArg arg0, UArg arg1) if (CurrentRequest!= NULL) job_request__free_unpacked(CurrentRequest,NULL); CurrentRequest = NULL; + SuspendLargeMessages = false; //send message data as a validation error message to host ExitState(Message.messageData); break; -- cgit v1.3.1