diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-06-17 13:53:39 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-06-17 13:53:39 +0300 |
| commit | 55387f5654403fff0ca3173f5bfcd69a12825ed8 (patch) | |
| tree | c44a89f97a7fb1495eb20ef383f74fc064864c9b /Software/Embedded_SW/Embedded | |
| parent | 401131666124c2df283fb66db80a24843b8115fa (diff) | |
| download | Tango-55387f5654403fff0ca3173f5bfcd69a12825ed8.tar.gz Tango-55387f5654403fff0ca3173f5bfcd69a12825ed8.zip | |
preparation for sample winding, preparation for work with FLASH instead of FFS
Diffstat (limited to 'Software/Embedded_SW/Embedded')
17 files changed, 233 insertions, 73 deletions
diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c index a47ff627b..53754f409 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c @@ -52,7 +52,7 @@ void job_ticket__free_unpacked assert(message->base.descriptor == &job_ticket__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor job_ticket__field_descriptors[12] = +static const ProtobufCFieldDescriptor job_ticket__field_descriptors[14] = { { "Guid", @@ -198,6 +198,30 @@ static const ProtobufCFieldDescriptor job_ticket__field_descriptors[12] = 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "units", + 13, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_UINT32, + offsetof(JobTicket, has_units), + offsetof(JobTicket, units), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "SampleWinding", + 14, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BOOL, + offsetof(JobTicket, has_samplewinding), + offsetof(JobTicket, samplewinding), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned job_ticket__field_indices_by_name[] = { 2, /* field[2] = EnableInterSegment */ @@ -208,15 +232,17 @@ static const unsigned job_ticket__field_indices_by_name[] = { 4, /* field[4] = Length */ 1, /* field[1] = Name */ 5, /* field[5] = ProcessParameters */ + 13, /* field[13] = SampleWinding */ 8, /* field[8] = Segments */ 7, /* field[7] = Spool */ 9, /* field[9] = UploadStrategy */ 6, /* field[6] = WindingMethod */ + 12, /* field[12] = units */ }; static const ProtobufCIntRange job_ticket__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 12 } + { 0, 14 } }; const ProtobufCMessageDescriptor job_ticket__descriptor = { @@ -226,7 +252,7 @@ const ProtobufCMessageDescriptor job_ticket__descriptor = "JobTicket", "", sizeof(JobTicket), - 12, + 14, job_ticket__field_descriptors, job_ticket__field_indices_by_name, 1, job_ticket__number_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h index bf75643a9..d54a9c32e 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h @@ -50,10 +50,14 @@ struct _JobTicket char *jobdescriptionfile; protobuf_c_boolean has_enablelubrication; protobuf_c_boolean enablelubrication; + protobuf_c_boolean has_units; + uint32_t units; + protobuf_c_boolean has_samplewinding; + protobuf_c_boolean samplewinding; }; #define JOB_TICKET__INIT \ { PROTOBUF_C_MESSAGE_INIT (&job_ticket__descriptor) \ - , NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, JOB_WINDING_METHOD__Embroidery, NULL, 0,NULL, 0, JOB_UPLOAD_STRATEGY__Default, NULL, 0, 0 } + , NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, 0, JOB_WINDING_METHOD__Embroidery, NULL, 0,NULL, 0, JOB_UPLOAD_STRATEGY__Default, NULL, 0, 0, 0, 0, 0, 0 } /* JobTicket methods */ 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 de5c18332..0bcf9d192 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -91,7 +91,7 @@ static FpgaMotMap_t FpgaMotMap[NUM_OF_MOTORS] = {&F1_MOTO_RLOADARM_A1_TX_00, &F1_MOTO_RLOADARM_A1_TX_01, &F1_MOTO_RLOADARM_A1_RX_00 ,&F1_MOTO_RLOADARM_A1_RX_01 ,&F1_MOTO_RLOADARM_A1_WORDS ,&F1_Moto_Driver_NBUSY2_D, &F1_SPI_Busy1_D}, //MOTOR_RLOADING - Right Loading {&F1_MOTO_RLOADING_A1_TX_00, &F1_MOTO_RLOADING_A1_TX_01, &F1_MOTO_RLOADING_A1_RX_00, &F1_MOTO_RLOADING_A1_RX_01, &F1_MOTO_RLOADING_A1_WORDS, &F1_Moto_Driver_NBUSY2_D, &F1_SPI_Busy1_D}, -/* + //MOTOR_SPARE1_1 - Spare {&F3_MOTO_SPARE1_1_A1_TX_00, &F3_MOTO_SPARE1_1_A1_TX_01, &F3_MOTO_SPARE1_1_A1_RX_00 ,&F3_MOTO_SPARE1_1_A1_RX_01 ,&F3_MOTO_SPARE1_1_A1_WORDS ,&F3_Moto_Driver_NBUSY1_D, &F3_SPI_Busy1_D}, //MOTOR_SPARE1_2 - Spare @@ -100,7 +100,7 @@ static FpgaMotMap_t FpgaMotMap[NUM_OF_MOTORS] = {&F3_MOTO_SPARE2_1_A1_TX_00, &F3_MOTO_SPARE2_1_A1_TX_01, &F3_MOTO_SPARE2_1_A1_RX_00 ,&F3_MOTO_SPARE2_1_A1_RX_01 ,&F3_MOTO_SPARE2_1_A1_WORDS ,&F3_Moto_Driver_NBUSY1_D, &F3_SPI_Busy1_D}, //MOTOR_SPARE2_2 - Spare {&F3_MOTO_SPARE2_2_A1_TX_00, &F3_MOTO_SPARE2_2_A1_TX_01, &F3_MOTO_SPARE2_2_A1_RX_00 ,&F3_MOTO_SPARE2_2_A1_RX_01 ,&F3_MOTO_SPARE2_2_A1_WORDS ,&F3_Moto_Driver_NBUSY1_D, &F3_SPI_Busy1_D}, -*/ + }; uint8_t FPGA_SPI_Transnit(TimerMotors_t _motorId) diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h index d4454136b..bce65e89b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h @@ -20,8 +20,8 @@ #define TimerMotors_t HardwareMotorType -#define NUM_OF_MOTORS (HARDWARE_MOTOR_TYPE__MOTO_RLOADING + 1) // TODO After the integration with mulbery change to: -//#define NUM_OF_MOTORS HARDWARE_MOTOR_TYPE__MOTO_SPARE1_1 +//#define NUM_OF_MOTORS (HARDWARE_MOTOR_TYPE__MOTO_RLOADING + 1) // TODO After the integration with mulbery change to: +#define NUM_OF_MOTORS HARDWARE_MOTOR_TYPE__MOTO_SPARE2_2+1 #define MINIMAL_MOTOR_SPEED 0.2 //typedef enum diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 3177dc787..b394a4391 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -149,6 +149,22 @@ uint32_t MotorGotoWithCallback (TimerMotors_t MotorId, uint32_t Steps, uint32_t MotorControlCallback[MotorId] = MotorMoveCallBackFunction; return MotorControlId[MotorId]; } +uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout) //TODO +{ + assert (callback); + //assert (isValid(deviceId)); + + //call driver action to device id with the parameter + //SetMotorSpeed (deviceId, parameter); + MotorCallback[MotorId] = callback; + + //MotorStop(MotorId,Hard_Hiz ); + int sign = direction?1:-1; + MotorGoTo(MotorId,Steps*sign ); + MotorControlId[MotorId] = AddControlCallback( MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlCallback[MotorId] = MotorMoveCallBackFunction; + return MotorControlId[MotorId]; +} uint32_t MotorMoveWithCallback (TimerMotors_t MotorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout) //TODO { diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h index b920bf47f..b5c0e7373 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h @@ -13,6 +13,7 @@ #define MOTOR_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0000 ) #define ALARM_MAP_IN_FLASH (FLASH_RAM_BASE + 0X2000 ) #define JOB_MAP_IN_FLASH (FLASH_RAM_BASE + 0X4000 ) +#define DANCERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0XA000) #define GENHWCFG_MAP_IN_FLASH (FLASH_RAM_BASE + 0X10000) #define OTHER_MAP_IN_FLASH (FLASH_RAM_BASE + 0X12000) diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index a4e1379c5..b651f2448 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -378,9 +378,9 @@ void AlarmHandlingInit(void) } AlarmItem = (AlarmHandlingItemStruc *)ALARM_MAP_IN_FLASH; - EraseFlashSection(ALARM_MAP_IN_FLASH,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); +// EraseFlashSection(ALARM_MAP_IN_FLASH,sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS); ReadAppAndProgram(AlarmItem, sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS, HardCodedAlarmItem); - LOG_ERROR(AlarmItem[2].EventName,"Flash Test"); +// LOG_ERROR(AlarmItem[2].EventName,"Flash Test"); return; } diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 9c7e84bc2..2d64c8515 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -60,6 +60,7 @@ uint32_t HWConfigurationInit(void) FRESULT Fresult = FR_OK; FIL *FileHandle = 0; //the system supports a single active file uint8_t* buffer = NULL; + void* buffer1 = NULL; uint32_t Bytes = 0,i,j,k=0; uint32_t status = OK; UploadHardwareConfigurationRequest* UploadRequest=0; @@ -67,6 +68,17 @@ uint32_t HWConfigurationInit(void) GeneralHwReady = false; Control_WD(ENABLE,250); + memcpy(&Bytes,(void *)GENHWCFG_MAP_IN_FLASH,sizeof(Bytes)); + + if ((Bytes)&&(Bytes < 4000)) + { + buffer1 = my_malloc (Bytes); + if (buffer1) + { + memcpy(buffer1, (void *)(GENHWCFG_MAP_IN_FLASH+4),Bytes); + UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer1); + } + } Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) { @@ -86,13 +98,15 @@ uint32_t HWConfigurationInit(void) if (k!=Bytes) LOG_ERROR(k,"File read error"); } + Fresult= memcmp(buffer,buffer1,Bytes); UploadRequest = upload_hardware_configuration_request__unpack(NULL, Bytes, buffer); status = HWConfiguration(UploadRequest); if (status ==OK) { upload_hardware_configuration_request__free_unpacked(UploadRequest,NULL); - EraseFlashSection(GENHWCFG_MAP_IN_FLASH,Bytes); - ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, Bytes, buffer); + //EraseFlashSection(GENHWCFG_MAP_IN_FLASH,Bytes+4); + //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,Bytes); + //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); } else { @@ -404,9 +418,15 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) uint32_t HWConfigurationFunc(MessageContainer* requestContainer) { uint32_t status = 0; + uint32_t DataLen = 0; MessageContainer responseContainer; UploadHardwareConfigurationResponse response = UPLOAD_HARDWARE_CONFIGURATION_RESPONSE__INIT; + EraseFlashSection(GENHWCFG_MAP_IN_FLASH,requestContainer->data.len+4); + DataLen = requestContainer->data.len; + ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&DataLen); + ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, requestContainer->data.len, requestContainer->data.data); + FileWrite(requestContainer->data.data, requestContainer->data.len,HwConfigPath); UploadHardwareConfigurationRequest* UploadRequest = upload_hardware_configuration_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 88f61637c..3ebf56c7f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -677,7 +677,8 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) { if (HeaterMaxTempFlag[index] == false) { - LOG_ERROR (MaxreadValue/100, "Heater Over the max temperature, turned off"); + //LOG_ERROR (MaxreadValue/100, "Heater Over the max temperature, turned off"); + Report(" AC Heater Over the max temperature, turned off",__FILE__,index,HeaterReady[index],RpWarning,HeaterControl[index].sensormaxvalue, 0); } DeActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain); HeaterMaxTempFlag[index] = true; @@ -739,7 +740,7 @@ uint32_t DcHeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) HeaterRecalculateHeaterParams(index, 0); HeaterMaxTempFlag[index] = true; //LOG_ERROR ((MinreadValue/100), "Heater Over the max temperature, turned off"); - Report("Heater Over the max temperature, turned off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterControl[index].sensormaxvalue,0); + Report("DC Heater Over the max temperature, turned off",__FILE__,index,HeaterPreviousRead[index],RpWarning, HeaterReady[index],0); AlarmHandlingSetAlarm(HeaterEventType[index], true); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 826a9ff26..4cc6eac30 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -107,7 +107,7 @@ int lInterSegmentLength = 0; uint32_t IDS_DispenserControlInit() { - DispensersControl = (void *)(GENHWCFG_MAP_IN_FLASH + 0x4000); + DispensersControl = (void *)(DANCERS_MAP_IN_FLASH + 1024); EraseFlashSection(DispensersControl,sizeof(HardwarePidControl)*MAX_SYSTEM_DISPENSERS); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c index 6bfb3f322..03c05e105 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Dancer.c @@ -67,6 +67,16 @@ void Stub_DancerPositionRequest(MessageContainer* requestContainer) response.detailed_status = DANCER_ENC[request->dancer_id].Det_status; response.has_general_status = true; } + else if(Dancer_Id < NUM_OF_ROTENC*2) + { + int Dancer = Dancer_Id - NUM_OF_ROTENC; + response.position = DancersCfg[Dancer].zeropoint; + response.has_position = true; + response.general_status = DANCER_ENC[Dancer].Gen_status; + response.has_general_status = true; + response.detailed_status = DANCER_ENC[Dancer].Det_status; + response.has_general_status = true; + } else { response.detailed_status = ERROR; // use the Reserved bits to send our errors diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 0093a5a2a..230d06601 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -52,6 +52,9 @@ extern HardwarePidControlType ThreadMotorIdToControlId[MAX_THREAD_MOTORS_NUM]; extern bool BreakSensorenabled; extern int32_t BreakSensordebouncetimemilli; +extern bool SampleWinding; + + //extern MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]; extern HardwarePidControl MotorsControl[MAX_THREAD_MOTORS_NUM]; //extern InternalWinderConfigStruc InternalWinderCfg; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 297cea44b..4f6585f2a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -58,6 +58,7 @@ InternalWinderConfigStruc InternalWinderCfg = {0}; uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0; uint32_t ScrewLocationRun[3]; +bool SampleWinding = false; uint32_t Winder_Init(void) { ScrewTimerInterruptInit(); @@ -92,8 +93,10 @@ uint32_t InternalWindingConfigMessage(JobSpool* request) * 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 Winder_Prepare(void *JobDetails) { + JobTicket* JobTicket = JobDetails; + uint32_t status = 0; //JobTicket* JobTicket = JobDetails; //float process_speed = JobTicket->processparameters->dyeingspeed; @@ -117,6 +120,11 @@ uint32_t Winder_Prepare(void) ScrewLocationRun[0] = 0; ScrewLocationRun[1] = 0; + if (JobTicket->has_samplewinding == true) + { + SampleWinding = JobTicket->samplewinding; + SampleWinding = true; + } if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) { //REPORT_MSG(LIMIT, "Winder_Prepare at limit"); @@ -167,7 +175,6 @@ 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 //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,temp_MaxFrequency); MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands @@ -179,6 +186,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewLocationStart = Screw_RotEnc.Position; REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location"); + SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home ScrewCurrentDirection = false; ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; @@ -267,6 +275,8 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) ScrewCurrentDirection = 1-ScrewCurrentDirection; CalculationDirectionChangeCounter++; + if (SampleWinding) + return OK; //double calcsteps = (ScrewRunningTime/SYS_CLK_FREQ)*ScrewSpeed; //REPORT_MSG((abs(ScrewLocationRun[1] - ScrewLocationRun[0]), "Screw Run NumberOfSteps"); // usnprintf(ScrewStr, 100, "Winder Encoder: 0 0x%x 1 0x%x diff %d intent %d rot %d",ScrewLocationRun[0],ScrewLocationRun[1],abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,Rotations*10); @@ -348,10 +358,13 @@ uint32_t WinderPresegmentReady(uint32_t deviceID, uint32_t ReadValue) { return PreSegmentReady(Module_Winder,ModuleDone); } +uint32_t WinderSamplesSegmentCallback(uint32_t SegmentDetails, uint32_t SegmentId) +{ + ScrewTimerInterrupt(0); +} uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) { - //JobTicket* JobTicket = JobDetails; double screw_horizontal_speed = 0; double RotationsPerSecond; double temp = 0; @@ -361,78 +374,110 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) 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) + if ((SegmentId == 0)||(SampleWinding)) // 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. - ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - ScrewNumberOfSteps -= 100; - 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 / (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; - ScrewSpeed = DEFAULT_SCREW_SPEED; + ScrewCurrentDirection = 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize; + if ((SegmentId > 0)&&(SampleWinding)) + { + InternalWinderCfg.segmentoffsetpulses = 120; + MotorGotoWithBusyCallback (HARDWARE_MOTOR_TYPE__MOTO_SCREW,true, (InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep*(SegmentId-1)), WinderSamplesSegmentCallback,2000); //TODO + Report("ScrewsMotorGoTo direction,speed ", __FILE__,__LINE__,InternalWinderCfg.segmentoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep, RpMessage, ScrewSpeed, 0); + InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples + InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples + InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw + JobSegment* Segment = SegmentDetails; + InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw + ScrewSpeed = InternalWinderCfg.segmentoffsetpulses/(((Segment->length *100)/dyeingspeed)/3); + ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); - usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed); - //REPORT_MSG(segmentfirst_speed,ScrewStr); - Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0); - SendJobProgress(0.0,0,false, ScrewStr); -*/ - // * 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 pulses, number of rotations per traverse ==> length of traverse per rotation. - ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; - screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; //steps per winder cycle - // calculation input#2: number of rotations per second - speed/winder diameter. WE USE HERE 39 MM AS ATHE WINDER DIAMETER - SOME AVERAGE BETWEEN EMPTY AND FULL - RotationsPerSecond = (dyeingspeed*10.0)/(19.50*PI); - // 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; + //three passages during the segment + } + else if (SampleWinding) //first segment + { + //InternalWinderCfg.segmentoffsetpulses = 120; + InternalWinderCfg.spoolbackingrate = 2000; //no cone for samples + InternalWinderCfg.SpoolBottomBackingRate = 2000; //no cone shape for samples + InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw + JobSegment* Segment = SegmentDetails; + InternalWinderCfg.NumberOfRotationPerPassage = 100; // a very slow movement of the screw + ScrewSpeed = InternalWinderCfg.segmentoffsetpulses/(((Segment->length *100)/dyeingspeed)/20); + ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; + } + else if ((SegmentId == 0)&&(SampleWinding == false)) + { + /* + // * 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. + ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; + ScrewNumberOfSteps -= 100; + 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 / (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; + ScrewSpeed = DEFAULT_SCREW_SPEED; + + //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); + usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond,(int)screw_horizontal_speed,(int)ScrewSpeed); + //REPORT_MSG(segmentfirst_speed,ScrewStr); + Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0); + SendJobProgress(0.0,0,false, ScrewStr); + */ + // * 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 pulses, number of rotations per traverse ==> length of traverse per rotation. + ScrewNumberOfSteps = InternalWinderCfg.segmentoffsetpulses;//*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; + screw_horizontal_speed = InternalWinderCfg.segmentoffsetpulses / InternalWinderCfg.NumberOfRotationPerPassage; //steps per winder cycle + // calculation input#2: number of rotations per second - speed/winder diameter. WE USE HERE 39 MM AS ATHE WINDER DIAMETER - SOME AVERAGE BETWEEN EMPTY AND FULL + RotationsPerSecond = (dyeingspeed*10.0)/(19.50*PI); + // 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; + ScrewNumberOfSteps -= 100; + Add100 = false; + LOG_ERROR(Add100, "Add100 = false"); + } usnprintf(ScrewStr, 100, "SCREW speed Rot/sec %d horizon %d pulses %d",(int)RotationsPerSecond*100,(int)screw_horizontal_speed*100,(int)ScrewSpeed); //REPORT_MSG(segmentfirst_speed,ScrewStr); Report(ScrewStr,__FILE__,__LINE__,RotationsPerSecond,RpWarning,ScrewSpeed,0); SendJobProgress(0.0,0,false, ScrewStr); - ScrewNumberOfSteps -= 100; + ScrewDirectionChangeCounter = 1; + CalculationDirectionChangeCounter = 1; + memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) ); + WinderMotorSpeedCounter=0; + TotalWinderSpeed = 0; + WinderMotorSpeedRollOver=false; /////////////////////// CurrentControlledSpeed[SCREW_MOTOR] = ScrewSpeed; OriginalMotorSpd_2PPS[SCREW_MOTOR] = ScrewSpeed; WinderReferenceSpeed = OriginalMotorSpd_2PPS[WINDER_MOTOR]; //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 + // * 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 temp = SYS_CLK_FREQ; temp *= ScrewNumberOfSteps; temp /= ScrewSpeed; ScrewRunningTime = temp;//(SYS_CLK_FREQ*InternalWinderCfg.segmentoffsetpulses)/ScrewSpeed; - REPORT_MSG(ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); - REPORT_MSG(ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); -// MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); + REPORT_MSG((int)ScrewNumberOfSteps,"Winder pre segment - ScrewNumberOfSteps"); + REPORT_MSG((int)ScrewRunningTime,"Winder pre segment - ScrewRunningTime"); + //MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); //ScrewDirection = 1-ScrewDirection; REPORT_MSG(SegmentId,"Winder pre segment - SegmentId"); REPORT_MSG(ScrewSpeed,"Winder pre segment - ScrewSpeed"); //MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); ScrewsStartControlTimer (); - ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0); - ScrewDirectionChangeCounter = 1; - CalculationDirectionChangeCounter = 1; - memset (WinderMotorSpeed,0,sizeof(WinderMotorSpeed) ); - WinderMotorSpeedCounter=0; - TotalWinderSpeed = 0; - WinderMotorSpeedRollOver=false; - Add100 = false; - LOG_ERROR(Add100, "Add100 = false"); } + if (SegmentId == 0) + { + ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0); + } PreSegmentReady(Module_Winder,ModuleDone); return OK; @@ -560,6 +605,7 @@ void ScrewTimerInterrupt(int ARG0) TimerDisable(Screw_timerBase, TIMER_A); } ROM_IntMasterEnable(); + //Report("ScrewsStartControlTimer direction,speed ", __FILE__,__LINE__,ScrewCurrentDirection, RpMessage, ScrewSpeed, 0); //MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); //Rotations+=0.03; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 9d773c1af..81fa33ef2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -42,7 +42,7 @@ uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); uint32_t Winder_Init(void); -uint32_t Winder_Prepare(void); +uint32_t Winder_Prepare(void *JobDetails); uint32_t Winder_Presegment(void *JobDetails, uint32_t SegmentId); uint32_t WinderDistanceToSpoolState(void ); uint32_t Winder_End(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index b741f33f3..529e4d260 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -17,6 +17,7 @@ #include "Common/SWUpdate/FileSystem.h" #include "drivers/Flash_Memory/fatfs/ff.h" #include "drivers/SSI_Comm/Dancer/Dancer.h" +#include "drivers/Flash_ram/FlashProgram.h" #include "thread.h" MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]={0}; @@ -151,6 +152,12 @@ uint32_t StoreDancerConfigMessage() response_size = hardware_configuration__pack(&DancerConfig, response_buffer); } Fresult = FileWrite(response_buffer,response_size,DancerConfigPath); + EraseFlashSection(DANCERS_MAP_IN_FLASH,1024); + for (Dancer_i = 0; Dancer_i < MAX_SYSTEM_DANCERS; Dancer_i++) + { + ReadAppAndProgram(DANCERS_MAP_IN_FLASH, sizeof(Dancers), Dancers); + } + my_free(response_buffer); return Fresult; @@ -163,6 +170,9 @@ uint32_t LoadDancerConfigMessage() HardwareConfiguration *DancerConfig; int Dancer_i; + HardwareDancer DancersCfg1[MAX_SYSTEM_DANCERS] = {0}; + + memcpy(DancersCfg1,(void *)DANCERS_MAP_IN_FLASH,sizeof(DancersCfg1)); Fresult = FileRead(DancerConfigPath, &Bytes, &buffer); if (Fresult == FR_OK) @@ -175,6 +185,12 @@ uint32_t LoadDancerConfigMessage() hardware_configuration__free_unpacked(DancerConfig,NULL); free (buffer); } + + if (DancersCfg[0].zeropoint != DancersCfg1[0].zeropoint) LOG_ERROR(DancersCfg[0].zeropoint,"DancersMismatch"); + else if (DancersCfg[1].zeropoint != DancersCfg1[1].zeropoint) LOG_ERROR(DancersCfg[1].zeropoint,"DancersMismatch"); + else if (DancersCfg[2].zeropoint != DancersCfg1[2].zeropoint) LOG_ERROR(DancersCfg[2].zeropoint,"DancersMismatch"); + else LOG_ERROR(DancersCfg[0].zeropoint,"Dancers Match!!"); + return Fresult; } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index b9a28fe57..d0124fcc0 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -780,6 +780,11 @@ void SetOriginMotorSpeed(float process_speed) MotorSpeedSamples[Motor_i][i] = motor_speed; } } +void ThreadPreSegmentEnded(void) +{ + REPORT_MSG (0,"First ThreadPreSegmentEnded"); + PreSegmentReady(Module_Thread,ModuleDone); +} //******************************************************************************************************************** uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) @@ -834,6 +839,14 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) PreSegmentState = true; DTSState = false; } + else if ((InitialProcess==true) && (SampleWinding == true)) + { + ThreadUpdateProcessLength (dryerbufferlength,(void *)ThreadPreSegmentEnded); + REPORT_MSG (dryerbufferlength," ThreadPreSegmentState DTS length (sample)"); + SegmentState = false; + PreSegmentState = true; + DTSState = false; + } else { ThreadUpdateProcessLength (0,(void *)NULL); diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 9c0c822ae..f552636cd 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -218,7 +218,7 @@ static ReturnCode PrepareState(void *JobDetails) } if (Configured[Module_Winder]) { - if( Winder_Prepare()!= OK) + if( Winder_Prepare(CurrentJob)!= OK) { SendJobProgress(0.0, 0, false, "Winder prepare failed !!!!"); } @@ -388,13 +388,13 @@ uint32_t ThreadJoggingFunc(int speed) Ticket.segments = my_malloc(sizeof(Ticket.segments)); TSegment = my_malloc(sizeof(JobSegment)); Tspool = my_malloc(sizeof(JobSpool)); - TSegment->length = 5000.0; + TSegment->length = 200.0; TSegment->n_brushstops = 0; Ticket.segments[0] = TSegment; - Tspool->backingrate = 30; - Tspool->bottombackingrate = 18; + Tspool->backingrate = 32; + Tspool->bottombackingrate = 32; Tspool->segmentoffsetpulses = 1000; - Tspool->startoffsetpulses = 240; + Tspool->startoffsetpulses = 220; Tspool->rotationsperpassage = 3.1415926*2; Ticket.spool = Tspool; CurrentJob = &Ticket; @@ -640,6 +640,10 @@ void JobRequestFunc(MessageContainer* requestContainer) if (JobAlarmReason ==OK) { n_unit_segments = n_segments; + if ((Ticket->has_units)&&(Ticket->units > 1)) + { + n_units = Ticket->units; + } if (n_units>1) { n_segments = n_segments*n_units; |
