diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-12-24 16:20:59 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-12-24 16:20:59 +0200 |
| commit | 71f7f59a5345c2df5d2fa8c641a88bf1d12bf063 (patch) | |
| tree | bea86c782bb1a56cef3c824468680e8f0b9df476 /Software | |
| parent | 49251db3f95a2c3146fc94ef2d487042891a6220 (diff) | |
| parent | a7d02907a37ba35da13b03264ba5110bd08f83c1 (diff) | |
| download | Tango-71f7f59a5345c2df5d2fa8c641a88bf1d12bf063.tar.gz Tango-71f7f59a5345c2df5d2fa8c641a88bf1d12bf063.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software')
25 files changed, 241 insertions, 58 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c index d1143ada2..822294092 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.c @@ -13,6 +13,7 @@ #include "driverlib/hibernate.h" #include <driverlib/Watchdog.h> #include <ti/sysbios/hal/Seconds.h> +#include "drivers/Flash_ram/MCU_E2Prom.h" //***************************************************************************** @@ -137,16 +138,21 @@ void utilsInit(uint32_t ui32SysClock) // // HibernateCounterMode(HIBERNATE_COUNTER_24HR); // Configure the hibernate module counter to RTC counter mode. - HibernateCounterMode(HIBERNATE_COUNTER_RTC); + HibernateCounterMode(HIBERNATE_COUNTER_24HR); -#define STARTTIME 1564403262 - Seconds_set(STARTTIME); +//#define STARTTIME 1564403262 +// Seconds_set(STARTTIME); } void utilsUpdateDateTime(uint32_t StartTime) { Seconds_set(StartTime); } +void utilsStoreLocalTime() +{ + time_t time_store = umktime(&LocalTime); + MCU_E2PromProgram(EEPROM_LOCAL_TIME,time_store); +} uint32_t UsersysTickGet (void) { uint32_t tick = 0; diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h index b54453e2c..779534182 100644 --- a/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h +++ b/Software/Embedded_SW/Embedded/Common/Utilities/Utils.h @@ -23,6 +23,7 @@ typedef enum void utilsInit(uint32_t ui32SysClock); void utilsUpdateDateTime(uint32_t StartTime); +void utilsStoreLocalTime(void); uint32_t UsersysTickGet (void); bool DanserCheckPosition(uint16_t position , Danser_t danser, bool test); void InitWatchdog(uint32_t clock); diff --git a/Software/Embedded_SW/Embedded/Common/report/filter.c b/Software/Embedded_SW/Embedded/Common/report/filter.c index 753123ee7..78e0ef7eb 100644 --- a/Software/Embedded_SW/Embedded/Common/report/filter.c +++ b/Software/Embedded_SW/Embedded/Common/report/filter.c @@ -333,7 +333,13 @@ void ReportSeveritySet(ErrorSeverity level) SeverityLevel = level; } +uint32_t safeReport(char *message, char *FileName, int LineNumber,int errorCode,int Severity,int parameter1,int parameter2) +{ + if (isReportActive() == false) + return OK; + return (Report(message, FileName, LineNumber, errorCode, Severity, parameter1, parameter2)); +} /*************************************************************************** * * Name : Report diff --git a/Software/Embedded_SW/Embedded/Common/report/report.h b/Software/Embedded_SW/Embedded/Common/report/report.h index 84063fb0f..94017ff20 100644 --- a/Software/Embedded_SW/Embedded/Common/report/report.h +++ b/Software/Embedded_SW/Embedded/Common/report/report.h @@ -131,6 +131,8 @@ uint32_t OpenLogFile(void); uint32_t CloseLogFile(void); bool isReportActive(void); uint32_t LogToFile(char *message, char *FileName, int LineNumber,int errorCode,int Severity,int parameter); +uint32_t safeReport(char *message, char *FileName, int LineNumber,int errorCode,int Severity,int parameter1,int parameter2); + /*************************************************************************** diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 8292cdeda..4b056b0d8 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -101,7 +101,7 @@ uint32_t OpenLogFile(void) f_lseek(LogFileHandle, 0); f_truncate (LogFileHandle); } - len = usnprintf(RepMessage, 80, "\r\n*******\r\nLog File start %s %s",__DATE__, __TIME__); + len = usnprintf(RepMessage, 80, "\r\n*******\r\nLog File start %d/%d/%d %d:%d:%d",LocalTime.tm_mday,LocalTime.tm_mon+1,LocalTime.tm_year,LocalTime.tm_hour,LocalTime.tm_min,LocalTime.tm_sec); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); ReportResetReason(); } @@ -110,8 +110,9 @@ uint32_t OpenLogFile(void) LogFresult = FR_INT_ERR; return LogFresult; -#endif +#else return OK; +#endif } uint32_t CloseLogFile(void) { @@ -119,13 +120,14 @@ uint32_t CloseLogFile(void) #ifdef STORE_DEBUG_LOGS int len; uint32_t Bytes = 0; - len = usnprintf(RepMessage, 80, "Closing Log File %s %s",__DATE__, __TIME__); + len = usnprintf(RepMessage, 80, "\r\n*******\r\nClosing Log File %d/%d/%d %d:%d:%d",LocalTime.tm_mday,LocalTime.tm_mon+1,LocalTime.tm_year,LocalTime.tm_hour,LocalTime.tm_min,LocalTime.tm_sec); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); LogFresult = f_close(LogFileHandle); LogFileHandle = NULL; return LogFresult; -#endif +#else return OK; +#endif } uint32_t LogToFile(char *message, /* The formatted message */ @@ -143,13 +145,13 @@ uint32_t LogToFile(char *message, /* The formatted message if (LogFileHandle == NULL) return OK; - len = usnprintf(RepMessage, 300, "\r\nfile %s\t line %d\t code %d\t sev %d,\tparam %d,\t %s",FileName, LineNumber,errorCode, Severity, parameter,message); + len = usnprintf(RepMessage, 300, "\r\n %d:%d:%d %s ,file %s\t line %d\t code %d\t sev %d,\tparam %d",LocalTime.tm_hour,LocalTime.tm_min,LocalTime.tm_sec,message,FileName, LineNumber,errorCode, Severity, parameter); LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); return LogFresult; -#endif +#else return OK; - +#endif } int ReportResponseFunc(char *message, /* The formatted message */ char *FileName, diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index 5396938fd..ec15c1596 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -24,6 +24,7 @@ #include <utils/ustdlib.h> #include "drivers/FPGA/FPGA.h" #include "Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +#include "driverlib/hibernate.h" #include "StateMachines/Printing/PrintingSTM.h" #include "StateMachines/Initialization/InitSequence.h" @@ -100,8 +101,8 @@ void ConnectionRequest(MessageContainer* requestContainer) if (request->has_unixtime) utilsUpdateDateTime(request->unixtime);//(request->seconds); ulocaltime(request->unixtime, &LocalTime); - LocalTime.tm_mon +=1;//since we get from ulocaltime Months since January - [0,11] - + HibernateCalendarSet(&LocalTime); + ReportWithPackageFilter(ThreadFilter,"Set Time: ",__FILE__,LocalTime.tm_hour,LocalTime.tm_min,RpWarning,(int) LocalTime.tm_sec,0); LocalTimeToAScii(); StopRecurringReports(); /* diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 10e6a78f6..3115f6828 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -331,6 +331,8 @@ typedef enum #define BIT30 0x40000000 //0x01 << 30 #define BIT31 0x80000000 //0x01 << 31 +extern struct tm LocalTime;//Months since January - [0,11] + //LocalTimeInAScii typedef union { diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c index 4b343a383..d9315f9af 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c @@ -18,6 +18,7 @@ #include "Drivers/I2C_Communication/Head_Card/IO_Ports/Head_IO.h" #include <Drivers/I2C_Communication/I2C_Task.h> +#include <Utilities/utils.h> #include <Utilities/delay.h> FPGA_GPI FPGA_Gpi; @@ -487,9 +488,9 @@ uint32_t DeActivateCleanerPump() return OK; } //---------------------------------- - void Power_Off()//Power Down { + utilsStoreLocalTime(); #ifdef WATCHDOG ROM_WatchdogResetDisable(WATCHDOG0_BASE); #endif @@ -499,6 +500,7 @@ void Power_Off()//Power Down void Power_Reset()// Resets the MCU { + utilsStoreLocalTime(); F3_SW_RESET_reg &= ~BIT0; SysCtlDelay(1000); F3_SW_RESET_reg |= BIT0; diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c index 632dfb0d5..5140b8202 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c +++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/ff.c @@ -898,7 +898,7 @@ FRESULT put_fat ( if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ { res = FR_INT_ERR; - Report("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); + safeReport("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); } } else { @@ -934,7 +934,7 @@ FRESULT put_fat ( default : res = FR_INT_ERR; - Report("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->fs_type,0); + safeReport("put_fat FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->fs_type,0); } fs->wflag = 1; @@ -965,7 +965,7 @@ FRESULT remove_chain ( if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ res = FR_INT_ERR; - Report("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); + safeReport("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fs->n_fatent,0); } else { res = FR_OK; while (clst < fs->n_fatent) { /* Not a last link? */ @@ -973,7 +973,7 @@ FRESULT remove_chain ( if (nxt == 0) break; /* Empty cluster? */ if (nxt == 1) { res = FR_INT_ERR; - Report("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)res,RpWarning,(int)fs->n_fatent,0); + safeReport("remove_chain FR_INT_ERR",__FILE__,__LINE__,(int)res,RpWarning,(int)fs->n_fatent,0); break; } /* Internal error? */ if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ @@ -1108,7 +1108,7 @@ FRESULT dir_sdi ( clst = dj->sclust; if (clst == 1 || clst >= dj->fs->n_fatent) /* Check start cluster range */ { - Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); + safeReport("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); return FR_INT_ERR; } if (!clst && dj->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ @@ -1118,7 +1118,7 @@ FRESULT dir_sdi ( dj->clust = clst; if (idx >= dj->fs->n_rootdir) /* Index is out of range */ { - Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)idx,RpWarning,(int)dj->fs->n_rootdir,0); + safeReport("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)idx,RpWarning,(int)dj->fs->n_rootdir,0); return FR_INT_ERR; } dj->sect = dj->fs->dirbase + idx / (SS(dj->fs) / SZ_DIR); /* Sector# */ @@ -1130,7 +1130,7 @@ FRESULT dir_sdi ( if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ if (clst < 2 || clst >= dj->fs->n_fatent) /* Reached to end of table or int error */ { - Report("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); + safeReport("dir_sdi FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)dj->fs->n_fatent,0); return FR_INT_ERR; } idx -= ic; @@ -2578,7 +2578,7 @@ FRESULT f_write ( if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->flag & FA__ERROR) /* Aborted file? */ { - Report("f_write FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)btw,0); + safeReport("f_write FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)btw,0); LEAVE_FF(fp->fs, FR_INT_ERR); } if (!(fp->flag & FA_WRITE)) /* Check access mode */ @@ -2620,7 +2620,7 @@ FRESULT f_write ( sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ if (!sect) { - Report("f_write FR_INT_ERR",__FILE__,__LINE__,(int)sect,RpWarning,(int)btw,0); + safeReport("f_write FR_INT_ERR",__FILE__,__LINE__,(int)sect,RpWarning,(int)btw,0); ABORT(fp->fs, FR_INT_ERR); } sect += csect; @@ -2913,7 +2913,7 @@ FRESULT f_lseek ( if (res != FR_OK) LEAVE_FF(fp->fs, res); if (fp->flag & FA__ERROR) /* Check abort flag */ { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)FA__ERROR,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)FA__ERROR,0); LEAVE_FF(fp->fs, FR_INT_ERR); } @@ -3000,7 +3000,7 @@ FRESULT f_lseek ( clst = create_chain(fp->fs, 0); if (clst == 1) { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)FA__ERROR,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)FA__ERROR,0); ABORT(fp->fs, FR_INT_ERR); } if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); @@ -3023,7 +3023,7 @@ FRESULT f_lseek ( if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); if (clst <= 1 || clst >= fp->fs->n_fatent) { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fp->fs->n_fatent,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)clst,RpWarning,(int)fp->fs->n_fatent,0); ABORT(fp->fs, FR_INT_ERR); } fp->clust = clst; @@ -3035,7 +3035,7 @@ FRESULT f_lseek ( nsect = clust2sect(fp->fs, clst); /* Current sector */ if (!nsect) { - Report("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)nsect,RpWarning,(int)0,0); + safeReport("f_lseek FR_INT_ERR",__FILE__,__LINE__,(int)nsect,RpWarning,(int)0,0); ABORT(fp->fs, FR_INT_ERR); } nsect += ofs / SS(fp->fs); @@ -3227,7 +3227,7 @@ FRESULT f_getfree ( if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } if (stat == 1) { - Report("f_getfree FR_INT_ERR",__FILE__,__LINE__,(int)stat,RpWarning,(int)0,0); + safeReport("f_getfree FR_INT_ERR",__FILE__,__LINE__,(int)stat,RpWarning,(int)0,0); res = FR_INT_ERR; break; } if (stat == 0) n++; } while (++clst < fs->n_fatent); @@ -3277,7 +3277,7 @@ FRESULT f_truncate ( res = validate(fp); /* Check validity of the object */ if (res == FR_OK) { if (fp->flag & FA__ERROR) { /* Check abort flag */ - Report("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)0,0); + safeReport("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)fp->flag,RpWarning,(int)0,0); res = FR_INT_ERR; } else { if (!(fp->flag & FA_WRITE)) /* Check access mode */ @@ -3297,7 +3297,7 @@ FRESULT f_truncate ( if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; if (ncl == 1) { - Report("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)ncl,RpWarning,(int)0,0); + safeReport("f_truncate FR_INT_ERR",__FILE__,__LINE__,(int)ncl,RpWarning,(int)0,0); res = FR_INT_ERR; } if (res == FR_OK && ncl < fp->fs->n_fatent) { @@ -3350,7 +3350,7 @@ FRESULT f_unlink ( dclst = ld_clust(dj.fs, dir); if (res == FR_OK && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-dir? */ if (dclst < 2) { - Report("f_unlink FR_INT_ERR",__FILE__,__LINE__,(int)dclst,RpWarning,(int)0,0); + safeReport("f_unlink FR_INT_ERR",__FILE__,__LINE__,(int)dclst,RpWarning,(int)0,0); res = FR_INT_ERR; } else { mem_cpy(&sdj, &dj, sizeof (DIR)); /* Check if the sub-dir is empty or not */ diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h index 2102d1716..aee812973 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.h @@ -38,7 +38,7 @@ typedef enum { EEPROM_ALARM_SUPPORT, EEPROM_ORIFICE1_ZERO_VALUE, EEPROM_ORIFICE3_ZERO_VALUE, - EEPROM_WASTE_TANK_ZERO_VALUE, + EEPROM_LOCAL_TIME, EEPROM_PULLER_TENSION_POSITION, EEPROM_WINDER_TENSION_POSITION, EEPROM_INIT_FAILURE_COUNTER, diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index b42fca6e9..899143c36 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -13,6 +13,7 @@ */ #include <driverlib/sysctl.h> #include "driverlib/eeprom.h" +#include "driverlib/hibernate.h" #include "Drivers/USB_Communication/USBCDCD.h" #include "Drivers/I2C_Communication/I2C.h" @@ -168,6 +169,8 @@ Void errHook(Error_Block *eb) { FirstErrorFlag = false; MCU_E2PromProgram(EEPROM_INIT_FAILURE_COUNTER,InitFailures+1); + utilsStoreLocalTime(); + len = usnprintf(message, 300, "\r\nerror task 0x%x %s context prev task 0x%x,%s", PrevTask,Task_Handle_name(PrevTask),NextTask,Task_Handle_name(NextTask)); f_write(LogFileHandle,message,len,&Bytes ); site = Error_getSite(eb); @@ -234,6 +237,7 @@ void Init_EVB() int main(void) { FRESULT Fresult = FR_OK; + time_t time_store = 0; // Enable interrupts to the processor. // ROM_IntMasterDisable(); @@ -301,6 +305,13 @@ int main(void) #endif } + utilsInit(ui32SysClock); + MCU_E2PromRead(EEPROM_LOCAL_TIME,&time_store); + if (time_store) + { + ulocaltime(time_store+5,&LocalTime); + HibernateCalendarSet(&LocalTime); + } OpenLogFile(); Data = MCU_E2PromEmbeddedVersionRead(); memcpy (&Version,&Data,4); @@ -371,7 +382,6 @@ int main(void) #endif CommunicationTaskInit(); - utilsInit(ui32SysClock); #ifndef EVALUATION_BOARD //Turn_the_Blower_On();//Turn on with the Default_Voltage diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 13cd797a7..fd861a985 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -22,6 +22,10 @@ #include "MillisecTask.h" #include <driverlib/timer.h> +#include <time.h> +#include "Common/Utilities/Utils.h" +#include "driverlib/hibernate.h" + #include <Drivers/SSI_Comm/SSI_Comm.h> #include <Drivers/SSI_Comm/Speed_Sensor/Speed_Sensor.h> #include <Drivers/SSI_Comm/Dancer/Dancer.h> @@ -741,6 +745,11 @@ uint32_t MillisecLowLoop(uint32_t tick) DispensersCollectionCall(); if (O200Millisecond_Tick) { + + ulocaltime(umktime(&LocalTime)+1,&LocalTime); + HibernateCalendarSet(&LocalTime); + //ReportWithPackageFilter(ThreadFilter,"Time: ",__FILE__,LocalTime.tm_min,LocalTime.tm_sec,RpWarning,(int) msec_millisecondCounter,0); + Trigger_WHS_MAX11614_Read_allADC(); FPGA_GetAllDispensersValveBusyOCD(); Read_Dryer_Fan_Tacho(); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h index 7c11b12bf..7e3f6252f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_ex.h @@ -40,6 +40,8 @@ void Heaters_SetOverHeatTimeOutValues(uint32_t OverHeatTimeout, uint32_t UnderHe void Heaters_SetOperationLimits(int acheatersloweroperationlimit,int acheatersupperoperationlimit,int dcheatersloweroperationlimit,int dcheatersupperoperationlimit); uint32_t DrierHeaterVoltageSetup(void); +//this function returns preparation ratio for the most cool heater (current temperature/ target temerature) +double HeatersPrepareProgress(void); uint32_t HeatersEnd(void); void HeatersControlStart(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index db7261090..d48139255 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -574,6 +574,27 @@ uint32_t HeatersSingleHeaterEnd(int HeaterId) return status; } +//this function returns preparation ratio for the most cool heater (current temperature/ target temerature) +double HeatersPrepareProgress(void) +{ + HardwarePidControlType i; + double MaxDifference = 1.00,temp = 0; + for (i=0;i<HEATER_TYPE_MAX_HEATERS;i++) + { + if(HeaterCmd[i].targettemperatue) + { + if (MillisecGetTemperatures(HeaterId2PT100Id[i])>=HeaterCmd[i].targettemperatue) + continue; + temp = MillisecGetTemperatures(HeaterId2PT100Id[i])/HeaterCmd[i].targettemperatue; + if (temp<MaxDifference) + MaxDifference = temp; + } + } + Report("HeatersPrepareProgress" ,__FILE__,__LINE__,(int)(MaxDifference*100),RpWarning,0,0); + + return MaxDifference; + +} uint32_t HeatersEnd(void) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 4ee94dae4..4d103395c 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -33,6 +33,29 @@ uint32_t OpenValveTimeout = 10; #define DISPENSER_BUILD_PRESSURE_TIMEOUT 120000 #define DISPENSER_BUILD_PRESSURE_LAG 50 #define DEFAULT_NANOLITER_PER_PULSE 2.34 + +FPGA_GPI_ENUM Dispenser_Id_to_LS_50_Id[MAX_SYSTEM_DISPENSERS] = { + GPI_LS_DISPENSER_50_1, //MOTO_DISPENSER_1 = 6, + GPI_LS_DISPENSER_50_2, //MOTO_DISPENSER_2 = 7, + GPI_LS_DISPENSER_50_3, //MOTO_DISPENSER_3 = 8, + GPI_LS_DISPENSER_50_4, //MOTO_DISPENSER_4 = 9, + GPI_LS_DISPENSER_50_5, //MOTO_DISPENSER_5 = 10, + GPI_LS_DISPENSER_50_6, //MOTO_DISPENSER_6 = 11, + GPI_LS_DISPENSER_50_7, //MOTO_DISPENSER_7 = 12, + GPI_LS_DISPENSER_50_8, //MOTO_DISPENSER_8 = 13, +}; +FPGA_GPI_ENUM Dispenser_Id_to_LS_25_Id[MAX_SYSTEM_DISPENSERS] = { + GPI_LS_DISPENSER_25_1, //MOTO_DISPENSER_1 = 6, + GPI_LS_DISPENSER_25_2, //MOTO_DISPENSER_2 = 7, + GPI_LS_DISPENSER_25_3, //MOTO_DISPENSER_3 = 8, + GPI_LS_DISPENSER_25_4, //MOTO_DISPENSER_4 = 9, + GPI_LS_DISPENSER_25_5, //MOTO_DISPENSER_5 = 10, + GPI_LS_DISPENSER_25_6, //MOTO_DISPENSER_6 = 11, + GPI_LS_DISPENSER_25_7, //MOTO_DISPENSER_7 = 12, + GPI_LS_DISPENSER_25_8, //MOTO_DISPENSER_8 = 13, +}; +bool DispenserDirectionFlag_50[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; +bool DispenserDirectionFlag_25[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; uint32_t DispenserPrepareSpeed = DISPENSER_BUILD_PRESSURE_SPEED; double DispenserPreparePressure = DISPENSER_BUILD_PRESSURE_LIMIT; uint32_t DispenserPrepareTimeout = DISPENSER_BUILD_PRESSURE_TIMEOUT; @@ -380,6 +403,16 @@ void IDS_Dispenser_Content_Calculation (char DispenserId) { ReportWithPackageFilter(IDSFilter,"IDS_Dispenser_Data ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)CurrentDispenserSpeed[DispenserId],0); } + if ((Dispenser_Id_to_LS_50_Id[DispenserId])&&(DispenserDirectionFlag_50[DispenserId]==false)) + { + DispenserDirectionFlag_50[DispenserId]= true; + ReportWithPackageFilter(IDSFilter,"Dispenser at 50% ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)65000000,0); + } + if ((Dispenser_Id_to_LS_25_Id[DispenserId])&&(DispenserDirectionFlag_25[DispenserId]==false)) + { + DispenserDirectionFlag_25[DispenserId]= true; + ReportWithPackageFilter(IDSFilter,"Dispenser at 25% ",__FILE__,DispenserId,(int)IDS_Dispenser_Data[DispenserId].consumedinnanolitter,RpWarning,(int)32500000,0); + } } if (DispenserId == 0) { @@ -410,6 +443,8 @@ void IDS_Dispenser_RefillStarted (char DispenserId,char MicroSteps) IDS_Dispenser_Data[DispenserId].nanolitterperpulse = assumedFlow; IDS_Dispenser_Data[DispenserId].microsteps = 1; IDS_Dispenser_Data[DispenserId].direction = 0;*/ + DispenserDirectionFlag_50[DispenserId] = false; + DispenserDirectionFlag_25[DispenserId] = false; ReportWithPackageFilter(IDSFilter,"IDS_Dispenser_RefillStarted",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)(CurrentDispenserSpeed[DispenserId]),0); } void IDS_Dispenser_RefillEnded (char DispenserId,char MicroSteps) @@ -419,6 +454,8 @@ void IDS_Dispenser_RefillEnded (char DispenserId,char MicroSteps) IDS_Dispenser_Data[DispenserId].numberofrefills++; //IDS_Dispenser_Data[DispenserId].direction = 1; IDS_Dispenser_Data[DispenserId].consumedinnanolitter = 0; + DispenserDirectionFlag_50[DispenserId] = false; + DispenserDirectionFlag_25[DispenserId] = false; ReportWithPackageFilter(IDSFilter,"IDS_Dispenser_RefillEnded",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)IDS_Dispenser_Data[DispenserId].numberofrefills,0); } void DispenserDataRequestFunc(MessageContainer* requestContainer) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index 0a8060496..ceb504099 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -60,6 +60,9 @@ void IDS_Dispenser_Content_Init (void); uint32_t IDSPrepareState(void *JobDetails); void IDSPrepareStart(void); +//this function returns preparation ratio for the most cool heater (current temperature/ target temerature) +double IdsPrepareProgress(void); + uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId); uint32_t IDSCheckSegmentData(void *SegmentDetails, int SegmentId); uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 1528a9a3b..9c422444f 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -195,6 +195,7 @@ uint32_t IDS_Honing_Timeout_Callback(uint32_t DispenserId, uint32_t ReadValue) ReportWithPackageFilter(IDSFilter,"IDS_Honing_Timeout_Callback",__FILE__,DispenserId,(int)(GetDispenserPressure(DispenserId)*100),RpWarning,2000,0); SafeRemoveControlCallback(DispenserHomingTimeoutControlId[DispenserId], IDS_Honing_Timeout_Callback ); AlarmHandlingSetAlarm (DispenserId+EVENT_TYPE__DISPENSER_1_REFILL_FAILURE,true); + return OK; } uint32_t IDS_HomeDispenserCallback(uint32_t motorId, uint32_t ReadValue) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 2d371595c..aaa371aac 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -459,11 +459,31 @@ c. Go to step 2.a x Segment.BrushStopsCount. uint32_t DispenserPrepareControlId = 0xFF; int NumOfActiveDispensers = 0; int DispenserBuildTimeCounter = 0; - double TargetNumberOfStepsPreRun,MaximalPressurePreRun; + double TargetNumberOfStepsPreRun = 120000,MaximalPressurePreRun = 4; int DispenserTotalPrepareSteps[MAX_SYSTEM_DISPENSERS]; bool DispenserLastMovementDown[MAX_SYSTEM_DISPENSERS]; #define PRESSURE_READ_TIME_GAP 100 + //this function returns preparation ratio for the most cool heater (current temperature/ target temerature) + double IdsPrepareProgress(void) + { + HardwarePidControlType i; + double MaxDifference = 1.00,temp = 0; + if (TargetNumberOfStepsPreRun == 0) + return 1.00; + for (i = 0; i < MAX_DYE_DISPENSERS; i++) + { + if (DispenserUsedInJob[i] == false) //we actually should check for all dispensers + continue; + if (DispenserTotalPrepareSteps[i]>TargetNumberOfStepsPreRun) + continue; + temp = DispenserTotalPrepareSteps[i]/TargetNumberOfStepsPreRun; + if (temp<MaxDifference) + MaxDifference = temp; + } + Report("IdsPrepareProgress" ,__FILE__,__LINE__,(int)(MaxDifference*100),RpWarning,0,0); + return MaxDifference; + } uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) { diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index 469e82aa8..2c67a623b 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -157,6 +157,7 @@ bool CartridgeInkFull() int GetCartridgeFillPercent() { double MidTank_Pressure = 0; + double percent; #ifdef IFS_DEBUG static int percent = 0; if (midTankState == MidTankStateFilling) { @@ -169,7 +170,8 @@ int GetCartridgeFillPercent() return percent; #else MidTank_Pressure = Read_MidTank_Pressure_Sensor(midTankCartColor); - return (((MidTank_Pressure - midTankCapacity)* 100) / CARTRIDGE_CAPATICY); + percent = (((MidTank_Pressure - midTankCapacity)* 100) / CARTRIDGE_CAPATICY); + return percent; #endif } diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h index 0f95fb2e2..7d68621e9 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h @@ -13,7 +13,7 @@ #define CARTRIDGE_INK_TIMEOUT 420 #define MidTank_Pressure_EMPTY 0.3 -#define CARTRIDGE_CAPATICY 1500 +#define CARTRIDGE_CAPATICY 1.5 typedef enum{ MidTankStateIdle, diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h index 13032f49d..aedb49a62 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread.h @@ -22,16 +22,6 @@ #define NORMAL_COEF_DIVIDER 100 typedef struct { - uint32_t startoffsetpulses; - uint32_t spoolbackingrate; - uint32_t segmentoffsetpulses;// the spool winding initial length in mm - uint32_t milimetersperrotation; - uint32_t SpoolBottomBackingRate;// the angle of the bottom of the spool - double NumberOfRotationPerPassage; // how many rotations per spool passage - double diameter; -}InternalWinderConfigStruc; -typedef struct -{ bool m_isEnabled; int32_t m_SetParam; float m_mesuredParam; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index 4ce48a639..05cacd20e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -14,7 +14,18 @@ #define WINDER_4_DANCER HARDWARE_DANCER_TYPE__RightDancer #define NUM_OF_DANCERS NUM_OF_ROTENC -//} DANCER_ENUM; + +typedef struct +{ + uint32_t startoffsetpulses; + uint32_t spoolbackingrate; + uint32_t segmentoffsetpulses;// the spool winding initial length in mm + uint32_t milimetersperrotation; + uint32_t SpoolBottomBackingRate;// the angle of the bottom of the spool + double NumberOfRotationPerPassage; // how many rotations per spool passage + double diameter; +}InternalWinderConfigStruc; + typedef enum threadMotorsEnum { FEEDER_MOTOR, @@ -55,6 +66,7 @@ uint32_t LoadDancerConfigMessage(void); //uint32_t MotorPidRequestMessage(HardwarePidControl* request); extern float NumberOfRotationPerPassage; //debug for rotation per passage trials +extern InternalWinderConfigStruc InternalWinderCfg; uint32_t Winder_Init(void); uint32_t Winder_Check_Cone(void); diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index 402a40e2e..55bb213d2 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,14 @@ +Embedded SW Release note - Version 1.6.0(1) - Pack 4 - Gen #2 +============================================================= +Flash RAM handling: flash reduced to 0x4000 bytes only (16K) - used for semi-permanent data only - embedded parameters and alarm file. +hw configuration stored only in flash file system (uploaded from PPC/MS on every connection anyway) +dispensers data and process parameters stored in internal EEPROM - Addresses 0x200, 0x400. +homing tokens - dynamic allocation +Dispensers filling timeout alarm (after one hour) +IDS - gradient brushstop offset size from the file +store real time and use in error log +BTSR Support + Embedded SW Release note - Version 1.5.3(4) - Pack 3 ============================================================= remove ErrFile.txt handling (storing logs while report is disconnected) - from release version diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index dedf8ba98..aef2af830 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -115,6 +115,8 @@ ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,Modu double job_length = 0.0; char infomsg[190]; +bool prepare_state = false; + /******************************************************************************************** * functions describes motor operation flow and movement state during profile execution * used to operate in runtime correct profileflow execution @@ -212,6 +214,8 @@ static ReturnCode PrepareState(void *JobDetails) usnprintf(ErrorMsg, 80,"Configured Thrd %d Wind %d IDS %d Heat %d WHS %d",Configured[Module_Thread],Configured[Module_Winder],Configured[Module_IDS],Configured[Module_Heaters],Configured[Module_Waste]); Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); + prepare_state = true; + if (Configured[Module_IDS]) { PrepareWaiting[Module_IDS] = ModuleWaiting; @@ -305,6 +309,7 @@ uint32_t PrepareReady(int ModuleId, ModuleStateEnum result) Report(infomsg, __FILE__, __LINE__, ready, RpError, status, 0); SendJobProgress(0.0,0,false, infomsg); + prepare_state = false; SendJobProgress(0.0, 0, false, "Prepare Ready"); if (status == OK) Message.messageId = PreparationResultsOk; else Message.messageId = PreparationResultsFail; @@ -456,11 +461,26 @@ uint32_t ThreadJoggingFunc(int speed) TSegment->length = 200.0; TSegment->n_brushstops = 0; Ticket.segments[0] = TSegment; - Tspool->backingrate = 32; - Tspool->bottombackingrate = 32; - Tspool->segmentoffsetpulses = 1000; - Tspool->startoffsetpulses = 220; - Tspool->rotationsperpassage = 3.1415926*2; + if (InternalWinderCfg.spoolbackingrate) + Tspool->backingrate = InternalWinderCfg.spoolbackingrate; + else + Tspool->backingrate = 32; + if (InternalWinderCfg.SpoolBottomBackingRate) + Tspool->bottombackingrate = InternalWinderCfg.SpoolBottomBackingRate; + else + Tspool->bottombackingrate = 32; + if (InternalWinderCfg.segmentoffsetpulses) + Tspool->segmentoffsetpulses = InternalWinderCfg.segmentoffsetpulses; + else + Tspool->segmentoffsetpulses = 1000; + if (InternalWinderCfg.startoffsetpulses) + Tspool->startoffsetpulses = InternalWinderCfg.startoffsetpulses; + else + Tspool->startoffsetpulses = 220; + if (InternalWinderCfg.NumberOfRotationPerPassage) + Tspool->rotationsperpassage = InternalWinderCfg.NumberOfRotationPerPassage; + else + Tspool->rotationsperpassage = 3.1415926*3; Tspool->has_limitswitchstartpointoffset = false; Ticket.spool = Tspool; Ticket.threadparameters = &SavedThreadParameters; @@ -638,11 +658,27 @@ uint32_t ThreadCleaningJob(int speed) Tdispenser->index = 4; //TI dispenser Ticket.segments[0] = TSegment; Ticket.segments[1] = TSegment; - Tspool->backingrate = 32; - Tspool->bottombackingrate = 32; - Tspool->segmentoffsetpulses = 1000; - Tspool->startoffsetpulses = 220; - Tspool->rotationsperpassage = 3.1415926*2; + if (InternalWinderCfg.spoolbackingrate) + Tspool->backingrate = InternalWinderCfg.spoolbackingrate; + else + Tspool->backingrate = 32; + if (InternalWinderCfg.SpoolBottomBackingRate) + Tspool->bottombackingrate = InternalWinderCfg.SpoolBottomBackingRate; + else + Tspool->bottombackingrate = 32; + if (InternalWinderCfg.segmentoffsetpulses) + Tspool->segmentoffsetpulses = InternalWinderCfg.segmentoffsetpulses; + else + Tspool->segmentoffsetpulses = 1000; + if (InternalWinderCfg.startoffsetpulses) + Tspool->startoffsetpulses = InternalWinderCfg.startoffsetpulses; + else + Tspool->startoffsetpulses = 220; + if (InternalWinderCfg.NumberOfRotationPerPassage) + Tspool->rotationsperpassage = InternalWinderCfg.NumberOfRotationPerPassage; + else + Tspool->rotationsperpassage = 3.1415926*3; + Tspool->has_limitswitchstartpointoffset = false; Tspool->has_limitswitchstartpointoffset = false; Ticket.spool = Tspool; Ticket.threadparameters = &SavedThreadParameters; @@ -1136,6 +1172,12 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes Report(infomsg,__FILE__,__LINE__,55,RpWarning,33, 44); }*/ //UInt Key = Task_disable(); + + if (prepare_state == true) + { + double prepare_progress = 0.9*HeatersPrepareProgress()+0.1*IdsPrepareProgress(); + Report("prepare_progress" ,__FILE__,__LINE__,(int)(prepare_progress*100),RpWarning,0,0); + } double totlength = 0; if (JobToken[0] != 0) @@ -1247,6 +1289,7 @@ void SendJobProgress(double ProcessedLength, int SegmentId, bool done, char *Mes CurrentRequest = NULL; } JobStopReporting(); + prepare_state = false; HandleJobEnd(JobEndReason); } // if (responseContainer.data.data) diff --git a/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs b/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs index 49ef0ebc7..851bdceff 100644 --- a/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs +++ b/Software/Stubs Collection/stubs/embeddedparametersbuild_w_cleaning.cs @@ -156,12 +156,12 @@ configurationParameters.GeneralParameters.Add(SublimationBlowTime); /*11*/ double AllowedRangeForHeadBlowerDeviation = new Double(); -AllowedRangeForHeadBlowerDeviation = 7; +AllowedRangeForHeadBlowerDeviation = 0.07; configurationParameters.GeneralParameters.Add(AllowedRangeForHeadBlowerDeviation); /*12*/ double AllowedRangeForWasteBlowerDeviation = new Double(); -AllowedRangeForWasteBlowerDeviation = 20; +AllowedRangeForWasteBlowerDeviation = 0.20; configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation); /*13*/ |
