diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-06-30 10:07:12 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2019-06-30 10:07:12 +0300 |
| commit | 59487d307a565dfd6258beb0c348ef072fe6039e (patch) | |
| tree | 15177838bbc83b998395204d3c70821a7e18c75c /Software/Embedded_SW | |
| parent | 69355e96c90f1ae473421fd9c9d34b96e47fbeb3 (diff) | |
| parent | 2a72d2b881503a077670b3703a8f360294136ca0 (diff) | |
| download | Tango-59487d307a565dfd6258beb0c348ef072fe6039e.tar.gz Tango-59487d307a565dfd6258beb0c348ef072fe6039e.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Embedded_SW')
30 files changed, 633 insertions, 157 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index f0ee0af19..7fbc9acc8 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,4,0,9}; +TangoVersion_t _gTangoVersion = {1,4,1,0}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Update.c b/Software/Embedded_SW/Embedded/Common/Utilities/Update.c index 422c1632b..c2aad92f1 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Update.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Update.c @@ -31,6 +31,13 @@ void UpdateUsb(void) // Disable all interrupts. // ROM_IntMasterDisable(); +#ifdef WATCHDOG + //ROM_WatchdogResetDisable(WATCHDOG0_BASE); + //ROM_WatchdogReloadSet(WATCHDOG0_BASE, 120000000*35); +#endif + ControlStop(); + MillisecStop(); + HeatersEnd(); // // Disable SysTick and its interrupt. 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/I2C_Communication/ADC_MUX/ADC_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c index fcf055b53..5aea18994 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c @@ -31,7 +31,7 @@ uint32_t MidTank_Pressure_Bits[8];//just for debug static uint8_t Config_Buf[3]; -static double MidThankReadingOffset = 0; +//static double MidThankReadingOffset = 0; uint32_t I2C_ADC_Config(uint32_t I2C_Slave_Add,uint32_t channel ) { @@ -125,7 +125,7 @@ double Calculate_Pressure(uint32_t VsampleInBits ) void MidTankPressureCorrection(double Offset) { - MidThankReadingOffset = Offset; + //MidThankReadingOffset = Offset; } double Calculate_Pressure(uint32_t VsampleInBits )//MidTank diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c index 6ee02783d..1cbd88f3b 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -23,6 +23,7 @@ #include "drivers/I2C_Communication/I2C.h" #include "Blower.h" #include "modules/control/control.h" +#include "drivers/FPGA/FPGA.h" DAC_Union DAC; @@ -237,7 +238,6 @@ uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV) ////////////////////////////////////////////////////////////////////////////////////////// -#include "drivers/FPGA/FPGA.h"; extern SCREW_ENC Screw_RotEnc; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h index 2802d2e95..c9a3a4f38 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_SPARE3_1 + 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_SPARE3_1+1 #define MINIMAL_MOTOR_SPEED 0.2 //typedef enum @@ -184,6 +184,9 @@ uint32_t MotorMove(TimerMotors_t _motorId,bool direction, uint32_t Steps); uint32_t MotorMoveWithCallback (TimerMotors_t _motorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout); uint32_t MotorGotoWithCallback (TimerMotors_t MotorId, uint32_t Steps, uint32_t LimitSwitchId,callback_fptr callback,uint32_t timeout); //TODO +uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32_t Steps, callback_fptr callback,uint32_t timeout); //TODO + +uint32_t MotorGoToDir(TimerMotors_t _motorId,bool direction, uint32_t Steps); bool MotorControlGetnBusyState(uint32_t _motorId, uint32_t parameter); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 3177dc787..a190730cb 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 { @@ -415,6 +431,7 @@ uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t Limit } else { + REPORT_MSG(MotorId,"Motor at limit"); MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction } diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 56e695ca4..b7a6fb67e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -455,12 +455,9 @@ DFUDetachCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgData, // // Release updateSem // - ControlStop(); - MillisecStop(); + UpdateFlag = true; Semaphore_post(updateSem); - ROM_WatchdogResetDisable(WATCHDOG0_BASE); - //ROM_WatchdogReloadSet(WATCHDOG0_BASE, 120000000*90); } diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h index 93719ab3e..95ce37568 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.h @@ -77,6 +77,8 @@ void USBCDCD_Reinit(void); void USBCDCD_hwiHandler(UArg arg0); +extern bool UpdateFlag; + //bool SendChars(char* buffer,size_t length); #ifdef __cplusplus } diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c index ac1cff75e..f2f5aefb6 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.c @@ -108,7 +108,6 @@ uint32_t ReadAppAndProgram(uint32_t ui32FlashStart,uint32_t ui32FileSize,void* b // return(1); } -#warning flash erase is now done only in init. should consider adding before config changes uint32_t EraseFlashSection(uint32_t ui32FlashStart,uint32_t ui32FileSize) { volatile uint32_t ui32Idx; diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h index b920bf47f..68b6dc2c5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/FlashProgram.h @@ -10,9 +10,11 @@ #define FLASH_RAM_BASE 0x000D0000 -#define MOTOR_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0000 ) +#define EMBEDDED_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0000 ) +#define PROCESS_PARAMETERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0400 ) +#define DANCERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X0500) +#define DISPENSERS_MAP_IN_FLASH (FLASH_RAM_BASE + 0X1000) #define ALARM_MAP_IN_FLASH (FLASH_RAM_BASE + 0X2000 ) -#define JOB_MAP_IN_FLASH (FLASH_RAM_BASE + 0X4000 ) #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/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index c50a0057a..a0b853ec8 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -86,7 +86,7 @@ Program.global.ReconnectSem = Semaphore.create(null, semaphore7Params); var MillisecTaskParams = new Task.Params(); MillisecTaskParams.instance.name = "MilliSecond"; -MillisecTaskParams.stackSize = 2048; +MillisecTaskParams.stackSize = 4096; MillisecTaskParams.priority = 12; Program.global.millisec = Task.create("&MillisecTask", MillisecTaskParams); diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index a4cee031d..ba4b3ebf0 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -108,14 +108,14 @@ F3_GPO_01_REG F3_GPO_01_Reg; Types_Site *site; Error_Id eid; int eCode; - +char ErrorPath[50] = "0://ErrFile.txt"; +bool UpdateFlag = false; /* ======== errHook ======== */ Void errHook(Error_Block *eb) { FRESULT Fresult = FR_OK; FIL *FileHandle = 0; //the system supports a single active file uint32_t Bytes = 0; - char ErrorPath[50] = "0://ErrFile.txt"; char File[50] = ""; char message[300]; int len; @@ -128,6 +128,8 @@ Void errHook(Error_Block *eb) ACTIVITY_RED_LED_ON; COMM_RED_LED_ON; + if (UpdateFlag == true) + return; site = Error_getSite(eb); eid = Error_getId(eb); eCode = Error_getCode(eb); @@ -250,6 +252,7 @@ int main(void) InitWatchdog(ui32SysClock*10); #endif + //FlashInitAndLoad(); CommunicationTaskInit(); utilsInit(ui32SysClock); @@ -276,9 +279,6 @@ int main(void) //IDS_ModuleInit(); Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); -#ifndef FPGA_WATCHDOG - Control_WD(DISABLE,0); -#endif //////////////////////////// diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index a4e1379c5..d81b75529 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -24,9 +24,9 @@ #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include "drivers/FPGA/FPGA.h" -#include "PMR/Hardware/HardwareDancerType.pb-c.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h" +#include "Common/SWUpdate/FileSystem.h" #include "modules/thread/thread_ex.h" #include "modules/heaters/heaters_ex.h" @@ -38,6 +38,8 @@ #include <PMR/Diagnostics/StopEventsNotificationRequest.pb-c.h> #include <PMR/Diagnostics/StopEventsNotificationResponse.pb-c.h> +#include <PMR/Hardware/HardwareDancerType.pb-c.h> + #include <PMR/EmbeddedParameters/AlarmHandlingItem.pb-c.h> #include <PMR/EmbeddedParameters/AlarmSourceType.pb-c.h> #include <PMR/EmbeddedParameters/AlarmParameters.pb-c.h> @@ -347,7 +349,7 @@ const AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ }; -char AlarmStorePath[25] ="0://SysInfo//AlarmPrm.cfg"; +char AlarmStorePath[30] ="0://SysInfo//AlarmPrm.cfg"; //bool DispenserInUse[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; bool EventsNotificationRequestAccepted = false; @@ -361,6 +363,30 @@ bool EventsNotificationRequestAccepted = false; //valve OCD //Motor Status //machine cover open +uint32_t AlarmHandlingFlashLoad(void) +{ + +// 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"); + + return sizeof(AlarmHandlingItemStruc)*MAX_SYSTEM_ALARMS; +} +uint32_t AlarmHandlingLoadFile(void) +{ + FRESULT Fresult = FR_OK; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + + Fresult = FileRead(AlarmStorePath, &Bytes, &buffer); + if (Fresult == FR_OK) + { + ReadAppAndProgram(AlarmItem, Bytes,buffer); + free (buffer); + } + return Bytes; +} + void AlarmHandlingInit(void) { Error_Block eb; @@ -378,9 +404,8 @@ void AlarmHandlingInit(void) } AlarmItem = (AlarmHandlingItemStruc *)ALARM_MAP_IN_FLASH; - 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"); + + //AlarmHandlingFlashLoad(); return; } @@ -758,6 +783,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) for (Alarm_i = 0;Alarm_i < MAX_SYSTEM_ALARMS;Alarm_i++) { Status = false; + if (AlarmItem[Alarm_i].AlarmSource > ALARM_SOURCE_TYPE__FluidLevelAlarm) + continue; if (tick%AlarmItem[Alarm_i].Frequency == 0) { switch (AlarmItem[Alarm_i].AlarmSource) diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h index 09dfa3f3d..392b31afc 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.h @@ -9,6 +9,9 @@ #define MODULES_ALARMHANDLING_ALARMHANDLING_H_ #include "StateMachines/Printing/PrintingSTM.h" +uint32_t AlarmHandlingFlashLoad(void); +uint32_t AlarmHandlingLoadFile(void); + uint32_t AlarmHandling_ControlTrigger(uint32_t IfIndex, uint32_t ReadValue); //uint32_t AlarmHandling_CalculateTemperatures(uint32_t SensorId, uint32_t Data); diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 9c7e84bc2..23009d7fb 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -34,6 +34,10 @@ #include "PMR/Hardware/SystemResetRequest.pb-c.h" #include "PMR/Hardware/SystemResetResponse.pb-c.h" +#include "PMR/Printing/ProcessParameters.pb-c.h" +#include "PMR/Printing/UploadProcessParametersRequest.pb-c.h" +#include "PMR/Printing/UploadProcessParametersResponse.pb-c.h" + #include "drivers/I2C_Communication/DAC/Blower.h" #include "drivers/Valves/Valve.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" @@ -55,18 +59,14 @@ HardwareBlower BlowerCfg; char *SW_INFO_DIR = "0://SysInfo"; char HwConfigPath[50] = "0://SysInfo//GenHwCfg.cfg"; -uint32_t HWConfigurationInit(void) +void *HWConfigurationLoadFromFile( uint32_t *NumOfBytes) { FRESULT Fresult = FR_OK; FIL *FileHandle = 0; //the system supports a single active file uint8_t* buffer = NULL; uint32_t Bytes = 0,i,j,k=0; - uint32_t status = OK; - UploadHardwareConfigurationRequest* UploadRequest=0; - - GeneralHwReady = false; - Control_WD(ENABLE,250); + *NumOfBytes = 0; Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) { @@ -84,30 +84,68 @@ uint32_t HWConfigurationInit(void) k+=j; } if (k!=Bytes) + { LOG_ERROR(k,"File read error"); + free (buffer); + buffer = NULL; + } + else + *NumOfBytes = 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); - } - else - { - SetMachineState(MACHINE_STATE_HW_CONFIG_FAILED); - } - free (buffer); } f_close(FileHandle); + free (FileHandle); + } + + return buffer; +} + +uint32_t HWConfigurationInit(void) +{ + void* buffer1 = NULL; + uint32_t status = OK; + UploadHardwareConfigurationRequest* UploadRequest=0; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + + 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); + } } + //buffer = HWConfigurationLoadFromFile(&Bytes); + //status= 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+4); + //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,Bytes); + //ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); + } + else + { + SetMachineState(MACHINE_STATE_HW_CONFIG_FAILED); + } + if (buffer) + free (buffer); + //EmbeddedParametersInit(); IDS_Dispenser_Content_Init(); //ProcessParamsInit(); GeneralHwReady = true; STATUS_RED_LED_OFF; - return Fresult; + return status; } char EmbeddedParametersPath[50] = "0://SysInfo//EmbParam.cfg"; @@ -139,7 +177,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters.has_dispenserbuildpressurespeed = true; EmbeddedParameters.dispenserbuildpressurespeed=500; EmbeddedParameters.has_dispenserbuildpressurelimit = true; - EmbeddedParameters.dispenserbuildpressurelimit=1.5 ; + EmbeddedParameters.dispenserbuildpressurelimit=0.8 ; EmbeddedParameters.has_dispenserbuildpressuretimeout = true; EmbeddedParameters.dispenserbuildpressuretimeout=60000; EmbeddedParameters.has_dispenserbuildpressurelag = true; @@ -160,6 +198,16 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters.startheatingoninitsequence = true; //set to true shlomo 14/5/2019 //size_t n_generalparameters; // EmbeddedParameters.*generalparameters; + EmbeddedParameters.generalparameters = malloc (sizeof(double)*10); + if (EmbeddedParameters.generalparameters) + { + EmbeddedParameters.generalparameters[0] = 1.0; //CheckHardLimitAlarms + EmbeddedParameters.generalparameters[1] = 0.0; //CheckCurrentAlarms + EmbeddedParameters.generalparameters[2] = 0.0; //CheckTamperAlarms + EmbeddedParameters.generalparameters[3] = 800.0; //Winder homing time at end of job + //EmbeddedParameters.generalparameters[4] = 1.0; //Dispenser initial pressure limit + //EmbeddedParameters.generalparameters[5] = 1.0; //Dispenser initial pressure speed + } EmbeddedParameters.has_currentalarmlowlimit = true; EmbeddedParameters.currentalarmlowlimit = 0.80; EmbeddedParameters.has_currentalarmhighlimit = true; @@ -199,29 +247,34 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) FileWrite(response_buffer,response_size,EmbeddedParametersPath); my_free(response_buffer); } - else memcpy (&EmbeddedParameters,Params,sizeof(EmbeddedParameters)); + else + { + memcpy (&EmbeddedParameters,Params,sizeof(EmbeddedParameters)); + } + uint32_t Bytes = sizeof(EmbeddedParameters); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, &EmbeddedParameters); } uint32_t EmbeddedParametersInit(void) { FRESULT Fresult = FR_OK; - void* buffer = NULL; + //void* buffer = NULL; uint32_t Bytes = 0; - //ConfigurationParameters *Params; + ConfigurationParameters *Params; - Fresult = FileRead(EmbeddedParametersPath, &Bytes, &buffer); - /*if (Fresult == FR_OK) + memcpy(&Bytes,(void *)EMBEDDED_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); + + if ((Bytes)&&(Bytes < 1000)) { - Params = configuration_parameters__unpack(NULL, Bytes, buffer); - LoadConfigurationParameters(Params); - DataUpdated=true; - free (buffer); - configuration_parameters__free_unpacked(Params,NULL); + Params = (ConfigurationParameters *)(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4); + memcpy (&EmbeddedParameters,Params,sizeof(EmbeddedParameters)); } - else*/ + else { LoadConfigurationParameters(0); } + IDS_Dispenser_SetTimeOutValues(EmbeddedParameters.closevalvetimeout, EmbeddedParameters.openvalvetimeout); IDS_Dispenser_SetBackLashValues(EmbeddedParameters.initialdispenserpressure, EmbeddedParameters.initialdispensertimeout, EmbeddedParameters.initialdispensertimelag); IDS_Dispenser_SetPrepareValues(EmbeddedParameters.dispenserbuildpressurespeed, EmbeddedParameters.dispenserbuildpressurelimit, EmbeddedParameters.dispenserbuildpressuretimeout, EmbeddedParameters.dispenserbuildpressurelag); @@ -404,9 +457,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); @@ -461,3 +520,78 @@ void HWSystemResetRequest(MessageContainer* requestContainer) HWREG(NVIC_APINT) = NVIC_APINT_VECTKEY | NVIC_APINT_SYSRESETREQ; } +uint32_t FlashInitResults[5] = {0,0,0,0,0}; +void FlashInitAndLoad(void) +{ + FRESULT Fresult = FR_OK; + uint8_t* buffer = NULL; + uint32_t Bytes = 0; + + ConfigurationParameters *Params = NULL; + ProcessParameters* ProcessParams = NULL; + UploadProcessParametersRequest* request = NULL; + + char ProcessParamsPath[50] = "0://SysInfo//ProcessP.cfg"; + + FlashInit(); //initialize flash + Report("Flash Initialized", __FILE__,__LINE__,FLASH_SIZE, RpMessage, FLASH_RAM_BASE, 0); + + buffer = HWConfigurationLoadFromFile(&Bytes); //load hardware config + if (buffer) + { + ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(GENHWCFG_MAP_IN_FLASH+4, Bytes, buffer); + free (buffer); + FlashInitResults[0] = true; + } + Report("Hardware Initialized", __FILE__,__LINE__,Bytes, RpMessage, GENHWCFG_MAP_IN_FLASH, 0); + + StoreDancerConfigMessage(); + Report("Dancer Initialized", __FILE__,DancersCfg[0].zeropoint,DancersCfg[1].zeropoint, RpMessage, DancersCfg[2].zeropoint, 0); + Bytes = AlarmHandlingLoadFile(); + if (Bytes>0) + { + Report("Alarm Initialized from file", __FILE__,__LINE__,Bytes, RpMessage, ALARM_MAP_IN_FLASH, 0); + } + else + { + Bytes = AlarmHandlingFlashLoad(); + Report("Alarm Initialized hard coded", __FILE__,__LINE__,Bytes, RpMessage, ALARM_MAP_IN_FLASH, 0); + } + + Fresult = FileRead(EmbeddedParametersPath, &Bytes, &buffer); + if (Fresult == FR_OK) + { + Params = configuration_parameters__unpack(NULL, Bytes, buffer); + LoadConfigurationParameters(Params); + free (buffer); + configuration_parameters__free_unpacked(Params,NULL); + FlashInitResults[1] = true; + Report("Parameters Initialized from file", __FILE__,__LINE__,sizeof(EmbeddedParameters), RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0); + } + else + { + LoadConfigurationParameters(0); + FlashInitResults[1] = 2; + Report("Parameters Initialized from default", __FILE__,__LINE__,sizeof(EmbeddedParameters), RpMessage, EMBEDDED_PARAMETERS_MAP_IN_FLASH, 0); + } + Bytes = sizeof(EmbeddedParameters); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(EMBEDDED_PARAMETERS_MAP_IN_FLASH+4, Bytes, &EmbeddedParameters); + + Fresult = FileRead(ProcessParamsPath, &Bytes, &buffer); + if (Fresult == FR_OK) + { + request = upload_process_parameters_request__unpack(NULL, Bytes, buffer); + ProcessParams = request->processparameters; + Bytes = sizeof(ProcessParams); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, &ProcessParams); + upload_process_parameters_request__free_unpacked(request,NULL); + FlashInitResults[2] = true; + Report("Process Initialized", __FILE__,__LINE__,Bytes, RpMessage, (int)ProcessParams->dryerzone1temp, 0); + } + else + Report("Process not Initialized", __FILE__,__LINE__,0, RpMessage, 0, 0); + +} diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h index 8fdbad42e..86f164977 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.h @@ -12,6 +12,7 @@ extern ConfigurationParameters EmbeddedParameters; extern uint32_t HWConfigurationFunc(MessageContainer* requestContainer); extern void HWSystemResetRequest(MessageContainer* requestContainer); uint32_t HWConfigurationInit(void); +void FlashInitAndLoad(void); extern HardwareBlower BlowerCfg; diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index b0351b4ff..aafc1c5a9 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -15,13 +15,16 @@ #include "PMR/Printing/UploadProcessParametersResponse.pb-c.h" #include "PMR/Hardware/HardwarePidControlType.pb-c.h" #include "PMR/common/MessageContainer.pb-c.h" + #include "drivers/Valves/Valve.h" #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" + #include "modules/ids/ids_ex.h" #include "third_party/fatfs/src/ffconf.h" #include "Common/SWUpdate/FileSystem.h" #include "StateMachines/Initialization/PowerIdle.h" +#include "drivers/Flash_ram/FlashProgram.h" double dyeingspeed = 0; @@ -182,11 +185,19 @@ void ProcessRequestFunc(MessageContainer* requestContainer) MessageContainer responseContainer; uint8_t* container_buffer; uint32_t status = 0; + uint32_t Bytes = 0; UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ProcessParameters* ProcessParams = request->processparameters; if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters + { FileWrite(requestContainer->data.data, requestContainer->data.len,ProcessParamsConfigPath); + Bytes = sizeof(ProcessParameters); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); + REPORT_MSG(Bytes,"Bytes wrtie to flash"); + + } //////////////////////////////////////////////////////////////////////// /*UploadProcessParametersRequest* requesttest; uint8_t* buffer = NULL; @@ -229,11 +240,11 @@ void ProcessRequestFunc(MessageContainer* requestContainer) uint32_t ProcessParamsInit(void) { FRESULT Fresult = FR_OK; - FIL *FileHandle = 0; //the system supports a single active file - uint8_t* buffer = NULL; - uint32_t Bytes = 0,i,j,k=0; - UploadProcessParametersRequest* request; - + //FIL *FileHandle = 0; //the system supports a single active file + //uint8_t* buffer = NULL; + uint32_t Bytes;// = 0,i,j,k=0; + //UploadProcessParametersRequest* request; +/* FileHandle = my_malloc(sizeof(FIL)); if (FileHandle) { @@ -270,6 +281,16 @@ uint32_t ProcessParamsInit(void) } my_free (FileHandle); } +*/ + + memcpy(&Bytes,(void *)PROCESS_PARAMETERS_MAP_IN_FLASH,sizeof(Bytes)); + REPORT_MSG(Bytes,"Bytes read from flash"); + + if ((Bytes)&&(Bytes < 1000)) + { + ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); + Fresult = HandleProcessParameters(ProcessParams); + } return Fresult; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 88f61637c..fe9671657 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -112,6 +112,7 @@ Mailbox_Handle HeatersControlMsgQ = NULL; //bool InitialHeating = true; //bool DCInitialHeating[MAX_HEATERS_NUM] = {true}; bool HeaterReady[MAX_HEATERS_NUM] = {true}; +bool HeaterAtTemp[MAX_HEATERS_NUM] = {true}; uint32_t HeaterPreviousRead[MAX_HEATERS_NUM] = {0,0,0,0,0,0,0,0,0,0}; //A/C Heaters Cycle time in milliseconds - one for all heaters EventType HeaterEventType[MAX_HEATERS_NUM] = {EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DRYER_ZONE_2_OVERTEMPERATURE,EVENT_TYPE__DRYER_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_1_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_2_OVERTEMPERATURE, EVENT_TYPE__DYEING_HEAD_ZONE_3_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_4_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_5_OVERTEMPERATURE,EVENT_TYPE__DYEING_HEAD_ZONE_6_OVERTEMPERATURE, @@ -158,6 +159,7 @@ void HeatersControlInit(void) { //DCInitialHeating[i] = true; HeaterReady[i] = true; + HeaterAtTemp[i] = true; HeaterCmd[i].targettemperatue = 0; HeaterCmd[i].command = HEATER_OFF; HeaterCmd[i].heaterid = i; @@ -225,7 +227,7 @@ void LoadHeaterState(HeaterType HeaterType,HeaterState *HeaterState) HeaterState->has_isactive = true; HeaterState->isactive = GetHeaterState(HeaterId); HeaterState->has_isrampingup = true; - HeaterState->isrampingup = 1-HeaterReady[HeaterId]; + HeaterState->isrampingup = 1-HeaterAtTemp[HeaterId]; HeaterState->has_isinsetpoint = true; HeaterState->isinsetpoint = HeaterReady[HeaterId]; if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain) @@ -260,6 +262,7 @@ uint32_t HeatersSingleHeaterEnd(HardwarePidControlType HeaterId) DeActivateHeater(HeaterId); HeaterPIDConfig[HeaterId].m_SetParam = 0; HeaterReady[HeaterId] = true; + HeaterAtTemp[HeaterId] = true; } else if (HeaterId < MAX_AC_HEATERS) //AC Heaters { @@ -289,6 +292,7 @@ uint32_t HeatersSingleHeaterEnd(HardwarePidControlType HeaterId) DeActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary); HeaterPIDConfig[HeaterId].m_SetParam = 0; HeaterReady[HeaterId] = true; + HeaterAtTemp[HeaterId] = true; } AlarmHandlingSetAlarm(HeaterUnderEventType[HeaterId], false); @@ -474,6 +478,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary],0); //InitialHeating = true; HeaterReady[HeaterId] = false; + HeaterAtTemp[HeaterId] = false; if (BlowerCfg.enabled == true) { Turn_the_Blower_On();//Turn on with the Default_Voltage @@ -503,6 +508,7 @@ int PrepareDCHeater(int HeaterId, uint32_t Frequency, uint32_t SetTemperatue) //HeaterPIDConfig[HeaterId].m_params.dt *=10; //DCInitialHeating[HeaterId] = true; HeaterReady[HeaterId] = false; + HeaterAtTemp[HeaterId] = false; HeaterRecalculateHeaterParams(HeaterId, 0); //turn all alarms off @@ -593,7 +599,7 @@ bool HeaterCheckReady(void) int i; for (i=0;i<MAX_HEATERS_NUM;i++) { - if (HeaterReady[i] == false) + if (HeaterAtTemp[i] == false) { return false; //not all configured heaters are ready } @@ -609,7 +615,7 @@ void HeaterPrepareReady(void) } for (i=0;i<MAX_HEATERS_NUM;i++) { - if (HeaterReady[i] == false) + if (HeaterAtTemp[i] == false) { return; //not all configured heaters are ready } @@ -677,7 +683,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; @@ -698,7 +705,7 @@ uint32_t HeaterMaxTempCBFunction(uint32_t IfIndex, uint32_t readValue) { ActivateHeater(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary); }*/ - LOG_ERROR ((MinreadValue/100), "Heater Cooled Off max temperature, turned on"); + //LOG_ERROR ((MinreadValue/100), "Heater Cooled Off max temperature, turned on"); } HeaterMaxTempFlag[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain] = false; HeaterMaxTempFlag[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary] = false; @@ -739,7 +746,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; } @@ -905,15 +912,22 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) //Gradual_Increase_Blower(BlowerCfg.heatingvoltage,BlowerCfg.voltage); Control_Voltage_To_Blower(BlowerCfg.voltage); } - -//////////////////////// HeaterReady[index] = true; Disable_Reading_Heaters_Current(HeaterId2CurrentId[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain]); - HeaterPrepareReady(); } return OK; } + if (HeaterAtTemp[index] == false) + { + if ((readValue > (HeaterCmd[index].targettemperatue * AcHeatersLoweroperationLimit/1000))&&(readValue < (HeaterCmd[index].targettemperatue * AcHeatersUpperoperationLimit/1000)))//read value within 0.5 percent from target + { + //InitialHeating = false; + Report("AC Ready",__FILE__,__LINE__,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); + HeaterAtTemp[index] = true; + HeaterPrepareReady(); + } + } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { HeaterPIDConfig[index].m_mesuredParam = readValue; @@ -1056,13 +1070,21 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) Report("DC PID Activating",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); //DCInitialHeating[index] = false; HeatersControlStart(); - HeaterReady[index] = true; AlarmHandlingSetAlarm(HeaterUnderEventType[index], false); Disable_Reading_Heaters_Current(HeaterId2CurrentId[index]); - HeaterPrepareReady(); + HeaterReady[index] = true; } return OK; } + if (HeaterAtTemp[index] == false) + { + if ((readValue > (HeaterCmd[index].targettemperatue * DcHeatersLoweroperationLimit/1000))&&(readValue < (HeaterCmd[index].targettemperatue * DcHeatersUpperoperationLimit/1000)))//read value within 0.5 percent from target + { + Report("DC Ready",__FILE__,index,readValue,RpWarning,(HeaterCmd[index].targettemperatue), 0); + HeaterAtTemp[index] = true; + HeaterPrepareReady(); + } + } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 826a9ff26..c8836a2b4 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -107,8 +107,8 @@ int lInterSegmentLength = 0; uint32_t IDS_DispenserControlInit() { - DispensersControl = (void *)(GENHWCFG_MAP_IN_FLASH + 0x4000); - EraseFlashSection(DispensersControl,sizeof(HardwarePidControl)*MAX_SYSTEM_DISPENSERS); + DispensersControl = (void *)(DISPENSERS_MAP_IN_FLASH); + //EraseFlashSection(DispensersControl,sizeof(HardwarePidControl)*MAX_SYSTEM_DISPENSERS); return OK; } @@ -595,7 +595,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { - if (GetDispenserPressure(i) > 0.80) + if (GetDispenserPressure(i) > DispenserPreparePressure) NumofReadyDispensers++; } } @@ -691,8 +691,8 @@ c. Go to step 2.a x Segment.BrushStopsCount. REPORT_MSG((int)NumOfActiveDispensers, "Num Of Active Dispensers"); for (i = 0; i < MAX_DYE_DISPENSERS; i++) { - dispenserspeed = PrepeareSpeed/MotorsCfg[DispenserIdToMotorId[i]].microstep; - dispenserspeed = 480; + //dispenserspeed = PrepeareSpeed/MotorsCfg[DispenserIdToMotorId[i]].microstep; + dispenserspeed = DispenserPrepareSpeed; //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { @@ -851,9 +851,10 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); segmentfirst_speed /= 100; DispenserSegmentReady[DispenserId] = false; //Control3WayValvesWithCallback (DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer - IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId, - segmentfirst_speed, - NULL); + //IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,segmentfirst_speed,NULL); + MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); + CurrentDispenserSpeed[Dispenser_i] = segmentfirst_speed; + usnprintf(IdsMessage, 80, "WFCF Dispenser %d nl/sec %d nl/pulse %d speed %d", DispenserId, @@ -952,6 +953,37 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) InterSegmentStartWFCFDispensers = lInterSegmentLength-5000; } } + /*if (SegmentId == 0)//first segment - running the DTS out of the drier + { + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away + for (Dispenser_i = 0; Dispenser_i < MAX_SYSTEM_DISPENSERS; Dispenser_i++) + { + HW_Motor_Id = DispenserIdToMotorId[Dispenser_i]; + //MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves + if (DispenserUsedInJob[Dispenser_i]==true)//unconfigured dispenser + { + MotorStop(HW_Motor_Id, Soft_Hiz); + CurrentDispenserSpeed[Dispenser_i] = 0; + } + } + lInterSegmentLength = ((dryerbufferlength*100)*1000/dyeingspeed); + lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication + InterSegmentStepsCount = 0; + DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); + if (DispenserPreSegmentControlId == 0xFF) + { + Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0); + return ERROR; + } + Report("Add control callback ",__FILE__,__LINE__,(int)100,RpWarning,(int)dryerbufferlength,0); + if (EnableCleaning == true) + { + InterSegmentStartSprayCleaner = 500; + InterSegmentStartRocking = 1000; + InterSegmentCenterRockers = 3000; + } + InterSegmentStartWFCFDispensers = lInterSegmentLength-5000; + }*/ if (uploadstrategy == JOB_UPLOAD_STRATEGY__Default) { @@ -1017,8 +1049,10 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) } if ((EnableIntersegment == true)&&(IntersegmentLength>0)) { - MotorStop(HW_Motor_Id,Hard_Hiz); //26/03/19 test without valves + MotorStop(HW_Motor_Id,Soft_Hiz); //26/03/19 test without valves CurrentDispenserSpeed[DispenserId] = 0; + //MotorSetSpeed(HW_Motor_Id, 5); + //CurrentDispenserSpeed[Dispenser_i] = 5; DispenserPreSegmentReady[DispenserId] = true; //27/03/19 check if job should be stopped REPORT_MSG(DispenserId,"Dispenser stopped pre Segment"); } diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 5d50a21c7..1420f7b97 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -52,6 +52,14 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.has_progress = true; } + else + if((request->amount == 0x0CE) && (request->delay == 0x0CE)) //Get Gas Sensor + { + FlashInitAndLoad(); + response.progress = (double)OK; + response.has_progress = true; + + } else if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off { PowerOffInit(); 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..8943e5d30 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -36,6 +36,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue); void ScrewTimerInterruptInit(void); void ScrewsStopControlTimer (void); void ScrewsStartControlTimer (void); +void ScrewTimerInterrupt(int); bool Winder_ScrewHoming = false; bool ScrewCurrentDirection = false; //holds current screw direction @@ -58,6 +59,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 +94,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 +121,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 +176,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 +187,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 +276,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 +359,14 @@ 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); + return OK; +} uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) { - //JobTicket* JobTicket = JobDetails; double screw_horizontal_speed = 0; double RotationsPerSecond; double temp = 0; @@ -361,78 +376,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*(SegmentId-1), 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 +607,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..167616afe 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -22,6 +22,7 @@ typedef enum threadMotorsEnum }threadMotorsEnum; extern double TotalProcessedLength; +extern double PoolerTotalProcessedLength; void ThreadSetBreakSensorLimit(int limit); @@ -42,7 +43,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..5efc3798e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -67,6 +67,7 @@ double PoolerLengthCalculationMultiplier; double TempPoolerTotalProcessedLength = 0.0; double TempTotalProcessedLength = 0.0; +bool InitialProcess = false; bool PrepareState = false; // job parameters bool EnableLubrication = false; @@ -148,10 +149,12 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) double length = 0.0; int index = MAX_THREAD_MOTORS_NUM; - // if (ThreadControlActive == false) - // return OK; - // if (PrepareState == true) - // return OK; +#ifndef FEEDER_LENGTH_CALCULATION + if (ThreadControlActive == false) + return OK; + if (PrepareState == true) + return OK; +#endif if (IfIndex>>8 != IfTypeThread) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -194,13 +197,14 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) } } + TotalProcessedLength += (length/100); + TempTotalProcessedLength = TotalProcessedLength; +#ifdef FEEDER_LENGTH_CALCULATION CurrentProcessedLength+=length; - static int pooler_counter = 0; - pooler_counter++; - TotalProcessedLength+= (length/100); - TempTotalProcessedLength = TotalProcessedLength; - if (pooler_counter%10 == 0) + static int feeder_counter = 0; + feeder_counter++; + if (feeder_counter%10 == 0) { if (PrepareState == true) { @@ -225,18 +229,22 @@ uint32_t ThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) ProcessedLengthFuncPtr(); } -return OK; +#endif + + return OK; } uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { - uint32_t positionDiff = 0; + uint32_t positionDiff = 0,prevprev; double length = 0.0; int index = MAX_THREAD_MOTORS_NUM; +#ifdef FEEDER_LENGTH_CALCULATION if (ThreadControlActive == false) return OK; if (PrepareState == true) return OK; +#endif if (IfIndex>>8 != IfTypeThread) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -258,13 +266,56 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) PoolerPreviousPosition = PoolerCurrentPosition; Poolerinitialpos = 0; } + prevprev = PreviousPosition; positionDiff = Control_Delta_Position_Pass(PoolerCurrentPosition,PoolerPreviousPosition); //positionDiff = positionDiff / MotorsCfg[ThreadMotorIdToMotorId[index]].microstep; PoolerPreviousPosition = PoolerCurrentPosition; length = (double)(positionDiff)*PoolerLengthCalculationMultiplier; - PoolerTotalProcessedLength+= (length/100); - TempPoolerTotalProcessedLength = PoolerTotalProcessedLength; + //if (InitialProcess == false) + { + PoolerTotalProcessedLength+= (length/100); + TempPoolerTotalProcessedLength = PoolerTotalProcessedLength; + } + if (length > 1000) + { + usnprintf(Lenstr, 100, "pooler length huge: length %d, diff 0x%x, pos 0x%x prev 0x%x",(int)length*100,(int)positionDiff,PreviousPosition,prevprev); + SendJobProgress(0.0,0,false, Lenstr); + Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); + length = 0; + + } +#ifndef FEEDER_LENGTH_CALCULATION + CurrentProcessedLength+=length; + + static int puller_counter = 0; + puller_counter++; + if (puller_counter%10 == 0) + { + if (PrepareState == true) + { + //later - add temperatures + TemperatureListString(Lenstr); + + SendJobProgress(0.0,0,false, Lenstr); + } + else + { + SendJobProgress(PoolerTotalProcessedLength,0,false, NULL); + } + + } + if ((CurrentProcessedLength>=CurrentRequestedLength )&&(CurrentRequestedLength > 0.0)) + { + usnprintf(Lenstr, 100, "Total processed length: Feeder: %d Pooler %d",(int)TotalProcessedLength,(int)PoolerTotalProcessedLength); + SendJobProgress(0.0,0,false, Lenstr); + Report(Lenstr,__FILE__,__LINE__,(int)TotalProcessedLength,RpWarning,(int)PoolerTotalProcessedLength,0); + // segment/intersegment/distance to spool finished + if (ProcessedLengthFuncPtr) + ProcessedLengthFuncPtr(); + + } +#endif return OK; } @@ -632,7 +683,6 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) ThreadPreSegmentState(request,0); return OK; } -bool InitialProcess = false; //******************************************************************************************************************** uint32_t ThreadPrepareState(void *JobDetails) @@ -780,6 +830,12 @@ void SetOriginMotorSpeed(float process_speed) MotorSpeedSamples[Motor_i][i] = motor_speed; } } +void ThreadPreSegmentEnded(void) +{ + InitialProcess = false; + REPORT_MSG (0,"First ThreadPreSegmentEnded"); + PreSegmentReady(Module_Thread,ModuleDone); +} //******************************************************************************************************************** uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) @@ -834,6 +890,14 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) PreSegmentState = true; DTSState = false; } + /*else if (InitialProcess==true) + { + ThreadUpdateProcessLength (dryerbufferlength,(void *)ThreadPreSegmentEnded); + REPORT_MSG (dryerbufferlength," ThreadPreSegmentState DTS length (sample)"); + SegmentState = false; + PreSegmentState = true; + DTSState = false; + }*/ else { ThreadUpdateProcessLength (0,(void *)NULL); @@ -893,7 +957,12 @@ uint32_t ThreadDistanceToSpoolState(void ) { seglength = dryerbufferlength; REPORT_MSG (seglength,"ThreadDistanceToSpoolState"); +//#ifdef FEEDER_LENGTH_CALCULATION ThreadUpdateProcessLength (seglength,(void *)ThreadDistanceToSpoolEnded); +/*#else + ThreadUpdateProcessLength (0,(void *)NULL); //move DTS to job start + DistanceToSpoolReady(Module_Thread,ModuleDone); +#endif*/ SegmentState = false; PreSegmentState = false; DTSState = true; diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index ac5fb1b21..a03ab04b0 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,11 @@ +Embedded SW Release note - Version 1.4.1.0 +============================================================= +Move to length calculation FROM PULLER +fix intersegment handling +FLASH - rebuilt. using data from flash instead of FFS +DFU fixed. +Heaters handling fixed. job starts only in proximity to requested temperature + Embedded SW Release note - Version 1.4.0.9 ============================================================= Drivers: diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 9c0c822ae..b33bf09c1 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; @@ -759,6 +763,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes } //previousJobLength = ProcessedLength; jobStatus.has_progress = true; +#ifdef FEEDER_LENGTH_CALCULATION totlength = TotalProcessedLength; if (TotalProcessedLength > job_length) { @@ -766,6 +771,15 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes //TotalProcessedLength = job_length; totlength = job_length; } +#else + totlength = PoolerTotalProcessedLength; + if (PoolerTotalProcessedLength > job_length) + { + Report("job length bigger than assigned",__FILE__,__LINE__,PoolerTotalProcessedLength,RpWarning,job_length, done); + //TotalProcessedLength = job_length; + totlength = job_length; + } +#endif jobStatus.progress = totlength; jobStatus.has_currentsegmentindex = true; jobStatus.currentsegmentindex = SegmentId; |
