diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-08-13 19:27:10 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-08-13 19:27:10 +0300 |
| commit | abc2f5fc8f757eddeccdd10646039c96b58e522d (patch) | |
| tree | c759454707c338f08e602800fb5f4a429d46f4fd /Software/Embedded_SW/Embedded | |
| parent | 7a914abc9e34c12acec0234ab748e17a21833af7 (diff) | |
| download | Tango-abc2f5fc8f757eddeccdd10646039c96b58e522d.tar.gz Tango-abc2f5fc8f757eddeccdd10646039c96b58e522d.zip | |
Version 1.4.3.7 Power off sequence with flushing and cleaning job. VOC alarms, safety, auto filling dispensers
Diffstat (limited to 'Software/Embedded_SW/Embedded')
24 files changed, 598 insertions, 164 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 24d49cb81..163ae4756 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,3,41}; +TangoVersion_t _gTangoVersion = {1,4,3,7}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c index cd47751d1..5c52963eb 100644 --- a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c +++ b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC.c @@ -460,93 +460,6 @@ double Calculate_Pitot_Pressure() // WHS - AN_AIRPRESS_1 return Pressure; } -uint8_t Calculate_Gas_Power_Consumption() // WHS -{ - // TGS 2602 (FIGARO) - - -/* Concentrtion Sensor - [ppm] [v] - 0 0.353 - 18 0.438 - 33 2.919 - 100 4.196 - 316 4.571 -*/ - - double VOC_Vsensor[] = - { - 0.353, //0 PPM - 0.357, //1 PPM - 0.362, //2 PPM - 0.367, //3 PPM - 0.371, //4 PPM - 0.376, //5 PPM - 0.381, //6 PPM - 0.386, //7 PPM - 0.390, //8 PPM - 0.395, //9 PPM - 0.400, //10 PPM - 0.404, //11 PPM - 0.409, //12 PPM - 0.414, //13 PPM - 0.419, //14 PPM - 0.423, //15 PPM - 0.428, //16 PPM - 0.433, //17 PPM - 0.438, //18 PPM - 0.603, //19 PPM - 0.768, //20 PPM - 0.934, //21 PPM - 1.099, //22 PPM - 1.265, //23 PPM - 1.430, //24 PPM - 1.595, //25 PPM - 1.761, //26 PPM - 1.926, //27 PPM - 2.092, //28 PPM - 2.257, //29 PPM - 2.422, //30 PPM - 2.588, //31 PPM - 2.753, //32 PPM - 2.919 //33 PPM - }; - - uint32_t VsampleInBits; - - double temp, VADC = 0.0 ,VSensor; - - uint8_t PPM = sizeof(VOC_Vsensor) / sizeof(VOC_Vsensor[0]), i; - - VsampleInBits = ADC_GetReading(ADC_VOCSENS); - - //---- VBits -> VADC ---- - - //ADC 12 bit -> 4096 -> 2.5V - - temp = VsampleInBits*2.5; - VADC = temp / 4096; - - //---- VADC -> VSensor --- - - //VADC = 1.96 - 10k( VSensor - 1.96) / 46.4k (from the electrical scheme) - // VSensor = 0 V -> VADC = 2.3824 V - // VSensor = 10 V -> VADC = 0.2272 V - - VSensor = (1.96- VADC) * 4.64 + 1.96; - - for(i=0;i<PPM;i++) - { - if(VSensor <= VOC_Vsensor[i]) - { - return i;//PPM - } - } - -return 0xFF;//out of scale - -} - uint32_t Read_Dryer_Heaters_Current(HEATERS_CURRENT Heater_ID) // { diff --git a/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c new file mode 100644 index 000000000..6122c2a87 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/ADC_Sampling/ADC_VOC_Sensor.c @@ -0,0 +1,166 @@ +//***************************************************************************** +// +// This is the data acquisition module. It performs acquisition of data from +// selected channels, starting and stopping data logging, storing acquired +// data, and running the strip chart display. +// +//***************************************************************************** +#include "include.h" +#include <stdbool.h> + +#include <driverlib/adc.h> +#include <driverlib/rom_map.h> +#include <driverlib/interrupt.h> + +#include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" +#include "ADC.h" +#include <inc/hw_memmap.h> +#include <inc/hw_ints.h> +#include "modules/AlarmHandling/AlarmHandling.h" +#include "PMR/Diagnostics/EventType.pb-c.h" + +#define MAX_VOC_SAMPLES 120 + +uint16_t VOC_Index = 0; +uint8_t Gas_PPM[MAX_VOC_SAMPLES] = {0}; +uint32_t VOC_Slope=0,VOC_AverageLimit=0, VOC_Slope_Time=0; + +bool VOC_TimeAlarm = false,VOC_SlopeAlarm = false; + +void CalculateVOCAlarms(void) +{ + int i,slope1=0,slope2=0,slopeindex=0; + double a; + bool alarmstate = false; + for (i = 0; i< MAX_VOC_SAMPLES; i++) + { + a += Gas_PPM[i]; + if(i!=0) + { + slope2 = slope1; + slope1 = Gas_PPM[i]-Gas_PPM[i-1]; + if (slope1 > VOC_Slope) + { + slopeindex++; + if (slopeindex>=VOC_Slope_Time) + { + AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE,true); + Report("CalculateVOCAlarms slope on",__FILE__,__LINE__,(int)slope1,RpWarning,slopeindex,0); + alarmstate = true; + VOC_SlopeAlarm = true; + } + } + + } + } + + if ((alarmstate==false)&&(VOC_SlopeAlarm == true)) + { + AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE,false); + } + + if (a/MAX_VOC_SAMPLES > VOC_AverageLimit) + { + AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_TIME,true); + Report("CalculateVOCAlarms time on",__FILE__,__LINE__,(int)a,RpWarning,VOC_AverageLimit,0); + } + else if (VOC_TimeAlarm == true) + { + AlarmHandlingSetAlarm(EVENT_TYPE__VOC_SENSOR_ALARM_TIME,false); + } + +} + +uint8_t Calculate_Gas_Power_Consumption() // WHS +{ + // TGS 2602 (FIGARO) + + +/* Concentrtion Sensor + [ppm] [v] + 0 0.353 + 18 0.438 + 33 2.919 + 100 4.196 + 316 4.571 +*/ + + double VOC_Vsensor[] = + { + 0.353, //0 PPM + 0.357, //1 PPM + 0.362, //2 PPM + 0.367, //3 PPM + 0.371, //4 PPM + 0.376, //5 PPM + 0.381, //6 PPM + 0.386, //7 PPM + 0.390, //8 PPM + 0.395, //9 PPM + 0.400, //10 PPM + 0.404, //11 PPM + 0.409, //12 PPM + 0.414, //13 PPM + 0.419, //14 PPM + 0.423, //15 PPM + 0.428, //16 PPM + 0.433, //17 PPM + 0.438, //18 PPM + 0.603, //19 PPM + 0.768, //20 PPM + 0.934, //21 PPM + 1.099, //22 PPM + 1.265, //23 PPM + 1.430, //24 PPM + 1.595, //25 PPM + 1.761, //26 PPM + 1.926, //27 PPM + 2.092, //28 PPM + 2.257, //29 PPM + 2.422, //30 PPM + 2.588, //31 PPM + 2.753, //32 PPM + 2.919 //33 PPM + }; + + uint32_t VsampleInBits; + + double temp, VADC = 0.0 ,VSensor; + + uint8_t PPM = sizeof(VOC_Vsensor) / sizeof(VOC_Vsensor[0]), i; + + VsampleInBits = ADC_GetReading(ADC_VOCSENS); + + //---- VBits -> VADC ---- + + //ADC 12 bit -> 4096 -> 2.5V + + temp = VsampleInBits*2.5; + VADC = temp / 4096; + + //---- VADC -> VSensor --- + + //VADC = 1.96 - 10k( VSensor - 1.96) / 46.4k (from the electrical scheme) + // VSensor = 0 V -> VADC = 2.3824 V + // VSensor = 10 V -> VADC = 0.2272 V + + VSensor = (1.96- VADC) * 4.64 + 1.96; + + for(i=0;i<PPM;i++) + { + if(VSensor <= VOC_Vsensor[i]) + { + Gas_PPM[VOC_Index++] = i; + if (VOC_Index >= MAX_VOC_SAMPLES) + VOC_Index = 0; + if (VOC_Index%60 == 0) + { + CalculateVOCAlarms(); + } + return i;//PPM + } + } + +return 0xFF;//out of scale + +} diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 4d243408c..3c9ae591a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -1001,7 +1001,7 @@ void FPGA_SetMotMicroStep(TimerMotors_t _motorId)// CM_VM = MotorDriverResponse[_motorId].DriverMode; temp |= (!x_SYNC_EN | CM_VM | good | x_SYNC_SEL_1)<<16; - Report("FPGA_SetMotMicroStep",__FILE__,__LINE__,_motorId,RpMessage,i,0); + ReportWithPackageFilter(GeneralFilter,"FPGA_SetMotMicroStep",__FILE__,__LINE__,_motorId,RpMessage,i,0); MillisecWriteToMotor(_motorId, temp, 4, NULL); } @@ -1139,7 +1139,7 @@ void FPGA_SetMotKvalHold(TimerMotors_t _motorId) Fpga_Spi[_motorId].TX_MOSI = temp; Fpga_Spi[_motorId].AMT_OF_Words = 4; - Report("FPGA SetKvalHold",__FILE__,__LINE__,_motorId,RpMessage,MotorDriverResponse[_motorId].DriverMode,0); + ReportWithPackageFilter(GeneralFilter,"FPGA SetKvalHold",__FILE__,__LINE__,_motorId,RpMessage,MotorDriverResponse[_motorId].DriverMode,0); MillisecWriteToMotor(_motorId,temp,4,NULL); } @@ -1166,7 +1166,7 @@ void FPGA_SetMotKvalRun(TimerMotors_t _motorId) Fpga_Spi[_motorId].TX_MOSI = temp; Fpga_Spi[_motorId].AMT_OF_Words = 4; - Report("FPGA SetKvalRun",__FILE__,__LINE__,_motorId,RpMessage,temp,0); + ReportWithPackageFilter(GeneralFilter,"FPGA SetKvalRun",__FILE__,__LINE__,_motorId,RpMessage,temp,0); MillisecWriteToMotor(_motorId, temp, 4, NULL); //FPGA_SPI_Transnit(_motorId); diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index ec9ea17db..275a4db22 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -363,7 +363,11 @@ uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callb { if (Valve3WayControlId[_ValveId] != 0xFF) + { Report("Control3WayValvesWithCallback called busy ",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)Valve3WayControlId[_ValveId],0); + RemoveControlCallback(Valve3WayControlId[_ValveId], Valve3WayCallBackFunction ); + } + Valve3WayModuleCallback[_ValveId] = callback; Valve3WayControlId[_ValveId] = AddControlCallback( Valve3WayCallBackFunction, eOneSecond/*eHundredMillisecond*/, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); diff --git a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c index 25aec02a5..f227dcd32 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c @@ -16,16 +16,21 @@ uint32_t MCU_E2PromProgram(int Address,uint32_t Data) { uint32_t Buffer = Data; if (Address>=MAX_EEPROM_STORAGE) + { + Report("MCU_E2PromProgram Error",__FILE__,__LINE__,Address,RpWarning,Data,0); return ERROR; + } Report("MCU_E2PromProgram",__FILE__,__LINE__,Address,RpWarning,Data,0); return (EEPROMProgram((uint32_t *)&Buffer, Address*4, 4)); } uint32_t MCU_E2PromRead(int Address,uint32_t *Data) { - Report("MCU_E2PromRead",__FILE__,__LINE__,Address,RpWarning,*Data,0); if (Address>=MAX_EEPROM_STORAGE) + { + Report("MCU_E2PromRead Error",__FILE__,__LINE__,Address,RpWarning,*Data,0); return ERROR; + } EEPROMRead((uint32_t *)Data,Address*4, 4); Report("MCU_E2PromRead",__FILE__,__LINE__,Address,RpWarning,*Data,0); @@ -37,7 +42,10 @@ float MCU_E2PromReadMidtank_A(int MidtankId) int Address = EEPROM_STORAGE_MIDTANK_1_A+(MidtankId*2); float Data; if (MidtankId>=NUM_OF_MIDTANKS) + { + Report("MCU_E2PromReadMidtank error",__FILE__,__LINE__,Address,RpWarning,(int)Data,0); return ERROR; + } EEPROMRead((uint32_t *)&Data,Address*4, 4); Report("MCU_E2PromRead",__FILE__,__LINE__,Address,RpWarning,(int)Data,0); @@ -48,7 +56,10 @@ float MCU_E2PromReadMidtank_B(int MidtankId) int Address = EEPROM_STORAGE_MIDTANK_1_B+(MidtankId*2); float Data; if (MidtankId>=NUM_OF_MIDTANKS) + { + Report("MCU_E2PromReadMidtank error",__FILE__,__LINE__,Address,RpWarning,(int)Data,0); return ERROR; + } EEPROMRead((uint32_t *)&Data,Address*4, 4); Report("MCU_E2PromRead",__FILE__,__LINE__,Address,RpWarning,(int)Data,0); diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index e04ce0d36..301d0d6c3 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -277,7 +277,6 @@ int main(void) #ifndef EVALUATION_BOARD WHS_init(); - Buttons_Init(); //IDS_ModuleInit(); Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); #endif diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index d1eabb6c7..6f80fdffb 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -178,12 +178,22 @@ AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__DISPENSER_7_OVERPRESSURE}, {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__DISPENSER_8_OVERPRESSURE}, - {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning,0xFF,2,EVENT_TYPE__MID_TANK_1_EMPTY}, - {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning,0xFF,2,EVENT_TYPE__MID_TANK_2_EMPTY}, - {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning,0xFF,2,EVENT_TYPE__MID_TANK_3_EMPTY}, - {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning,0xFF,2,EVENT_TYPE__MID_TANK_4_EMPTY}, - {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning,0xFF,2,EVENT_TYPE__MID_TANK_5_EMPTY}, - {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,60/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning,0xFF,2,EVENT_TYPE__MID_TANK_8_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_1_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_2_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_3_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_4_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_5_LOW_LEVEL}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_6_LOW_LEVEL}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_7_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,50/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_8_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_1_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_2_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_3_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_4_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_5_EMPTY}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_6_EMPTY}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,20/*500cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_8_EMPTY}, {eOneSecond,ALARM_SOURCE_TYPE__MotorAlarm,HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,x_STATUS_OCD,false,DEBUG_LOG_CATEGORY__Error,0xFF,2,EVENT_TYPE__DRYER_MOTOR_OVERCURRENT }, @@ -340,6 +350,9 @@ AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ {eOneSecond, ALARM_SOURCE_TYPE__CurrentAlarm, HEATER_DRYER_CURRENT_2, HEATER_DRYER_CURRENT_2, 0 , FALSE , DEBUG_LOG_CATEGORY__Warning , 0xFF , 2 , EVENT_TYPE__DRYER_HEATERS_ZONE_2_CURRENT_LOOP_BREAK }, /* 6004 */ {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__DYEING_HEAD_THERMAL_CUTOFF}, + {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__VOC_SENSOR_ALARM_TIME}, + {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__VOC_SENSOR_ALARM_SLOPE}, + {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__THREAD_BREAK}, {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_FEEDER_DANCER}, {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Warning,0xFF,0,EVENT_TYPE__THREAD_TENSION_CONTROL_FAILURE_PULLER_DANCER}, @@ -531,11 +544,11 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever { if (Severity == DEBUG_LOG_CATEGORY__Info) { - IDS_Dispenser_Alarm_Off(AlarmItem[AlarmId].ModuleDeviceId); + IDS_Dispenser_Alarm_Off(AlarmItem[AlarmId].ModuleDeviceId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1); } else { - IDS_Dispenser_Alarm_On (AlarmItem[AlarmId].ModuleDeviceId); + IDS_Dispenser_Alarm_On (AlarmItem[AlarmId].ModuleDeviceId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1); } } break; diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index f5ac6cf92..fa94614fd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -88,14 +88,13 @@ uint32_t Dancer_Data[NUM_OF_DANCERS] = {0}; float Speed_Data = 0; uint32_t DrawerFansStatus = 0; uint32_t SystemFansStatus = 0; -uint8_t Gas_PPM = 0; - bool watchdogCriticalAlarm = false; uint32_t msec_millisecondCounter = 0; extern bool Machine_Idle_Mode; +uint8_t Gas_PPM_Info; MillisecMotorDataStruc ScrewSetMaxSpeedPending = {0}; MillisecMotorDataStruc ScrewMovePending = {0}; MillisecMotorDataStruc MotorData[NUM_OF_MOTORS] = {0}; @@ -111,6 +110,7 @@ static GateMutex_Handle gateMillisecDB; uint32_t Millisec_timerBase = TIMER1_BASE; //Timer handle /******************** Functions ********************************************/ uint32_t Control_Delta_Position_Pass(uint32_t Current_Read,uint32_t Previous_Read); +void CalculateVOCAlarms(void); //********************************************************************** /******************** CODE ********************************************/ //********************************************************************** @@ -595,7 +595,6 @@ uint32_t MillisecLowLoop(uint32_t tick) Read_Heaters_Current(Heater_i); } } - Gas_PPM = Calculate_Gas_Power_Consumption(); for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { TemperatureCalc[Sensor_i] = MillisecCalculateTemperatures ( Sensor_i); @@ -615,6 +614,8 @@ uint32_t MillisecLowLoop(uint32_t tick) MotorGetStatusFromFPGA(Motor_i); }*/ midtankDisplay = 1-midtankDisplay; + Gas_PPM_Info = Calculate_Gas_Power_Consumption(); + } if (OneHourTick) { @@ -720,7 +721,7 @@ uint32_t getDrawerFansStatus(void) } uint8_t getGasReading(void) { - return Gas_PPM; + return Gas_PPM_Info; } uint32_t getSystemFansStatus(void) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index f1e19d851..a88f67d5e 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -479,6 +479,14 @@ uint32_t GetControlLowDevice_i(void) { return ControlLowDevice_i; } +ControlCBFunction GetControlCallbackFuncPtr(uint32_t ControlId) +{ + if (ControlArray[ControlId].ControlActive) + return ControlArray[ControlId].ControlCallbackPtr; + else + return NULL; + +} uint32_t ControlLoop(uint32_t tick) { if (MaxHighDevices == 0xFF) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 380040e34..c54909f73 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -47,6 +47,7 @@ int SafeRemoveHighControlCallback(uint32_t deviceId , ControlCBFunction uint32_t TemplateDataReadCBFunction (uint32_t deviceId, uint32_t Parameter1); uint32_t GetControlDevice_i(void); uint32_t GetControlLowDevice_i(void); +ControlCBFunction GetControlCallbackFuncPtr(uint32_t ControlId); extern Task_Handle Control_Task_Handle; extern uint32_t millisecondCounter; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 116988720..8956f417d 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -60,6 +60,7 @@ uint32_t DiagnosticsStop(void); uint32_t Diagnostics_ControlTrigger(uint32_t IfIndex, uint32_t ReadValue); uint32_t Diagnostics_TenMiliControlTrigger(uint32_t IfIndex, uint32_t ReadValue); +uint32_t Diagnostics_OneSecControlTrigger(uint32_t IfIndex, uint32_t ReadValue); uint32_t DispensersCollection(uint32_t IfIndex, uint32_t ReadValue); //#define REDUCED_DIAGNOSTICS @@ -81,7 +82,7 @@ int DiagnosticLimit =eOneSecond; //frequency of data collection int DiagnosticLimit =eHundredMillisecond; //frequency of data collection #endif int DiagnosticFastLimit = eTenMillisecond; //frequency of data collection -#define TEN_MSEC_COLLECTION +//#define TEN_MSEC_COLLECTION //DigitalPin DigitalPinArray[1][DIAGNOSTICS_LIMIT+1]; double dancer1angle[DIAGNOSTICS_LIMIT+1]; double dancer2angle[DIAGNOSTICS_LIMIT+1]; @@ -138,6 +139,7 @@ typedef enum { DiagnosticsTrigger, DiagnosticsTenMiliTrigger, + DiagnosticsOneSecTrigger, }DiagnosticsMessages; typedef struct DiagnosticsMessage{ @@ -338,7 +340,7 @@ void DiagnosticTenMsecCollection(void) { if (DiagnosticsActive == false) return; -#ifdef TEN_MSEC_COLLECTION +//#ifdef TEN_MSEC_COLLECTION /*if (JobIsActive()== false) return;*/ DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0,0)); @@ -350,7 +352,33 @@ void DiagnosticTenMsecCollection(void) DiagnosticLoadDancerError(FEEDER_DANCER,ThreadGetMotorCalculatedError(FEEDER_DANCER)); //DiagnosticLoadSpeedSensor(getSensorSpeedData()); -#endif +//#endif +} +void DiagnosticOneSecCollection(void) +{ + int i; + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__MixerHeater, MillisecGetTemperatures( MIXER_PT100)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP1)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP2)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP3)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP4)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP5)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6, MillisecGetTemperatures(HEAD6_PT100)); + + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DRYER_TEMP1)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DRYER_TEMP2)); + DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DRYER_TEMP3)); + for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) + { + dispensermotorfrequency[i][DiagnosticsIndex] = IdsGetMotorSpeed(i); + //dispensermotorfrequency[i][DiagnosticsIndex] = IDS_Dispenser_Data[i].consumedinnanolitter; + + dispenserspressure[i][DiagnosticsIndex] = GetDispenserPressure(i); //Read_MidTank_Pressure_Sensor + if (midtankDisplay) + MidTankpressure[i][0] = Get_MidTank_Pressure_Sensor(i); + else + MidTankpressure[i][0] = 1.00-(IDS_Dispenser_Data[i].consumedinnanolitter/5800000); + } } void Diagnostic100msecCollection(void) { @@ -358,7 +386,7 @@ void Diagnostic100msecCollection(void) if (DiagnosticsActive == false) return; - DiagnosticLoadSpeedSensor(getSensorSpeedData()); + //DiagnosticLoadSpeedSensor(getSensorSpeedData()); #ifndef REDUCED_DIAGNOSTICS #ifndef TEN_MSEC_COLLECTION DiagnosticTenMsecCollection(); //call the 10msec function every 100 msec to reduce transport @@ -372,6 +400,7 @@ void Diagnostic100msecCollection(void) DiagnosticLoadMotor(SCREW_MOTOR, ThreadGetMotorSpeed (SCREW_MOTOR)); } #endif + /* DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__MixerHeater, MillisecGetTemperatures( MIXER_PT100)); DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP1)); DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, MillisecGetTemperatures(TEMP_SENSE_ANALOG_DYEINGH_TEMP2)); @@ -394,6 +423,7 @@ void Diagnostic100msecCollection(void) else MidTankpressure[i][0] = 1.00-(IDS_Dispenser_Data[i].consumedinnanolitter/5800000); } + */ #ifndef REDUCED_DIAGNOSTICS for (i=0;i<NUM_OF_CURRENT_HEATERS;i++) { @@ -689,6 +719,7 @@ void SendDiagnostics(void) } uint32_t DiagnosticsControlId = 0xff; uint32_t Diagnostics10MSControlId = 0xff; +uint32_t Diagnostics1SecControlId = 0xff; bool DiagnosticRequestAccepted = false; uint32_t DiagnosticsStart(void) { @@ -708,6 +739,10 @@ uint32_t DiagnosticsStart(void) else LOG_ERROR(DiagnosticsControlId,"Diagnostics restarted"); #endif + if (Diagnostics1SecControlId == 0xFF) + Diagnostics1SecControlId = AddControlCallback(Diagnostics_OneSecControlTrigger,eOneSecond,TemplateDataReadCBFunction,0,0,0); + else + LOG_ERROR(Diagnostics1SecControlId,"Diagnostics restarted"); } } @@ -722,9 +757,12 @@ uint32_t DiagnosticsStop(void) RemoveControlCallback(DiagnosticsControlId,Diagnostics_ControlTrigger); if (Diagnostics10MSControlId != 0xFF) RemoveControlCallback(Diagnostics10MSControlId,Diagnostics_TenMiliControlTrigger); + if (Diagnostics1SecControlId != 0xFF) + RemoveControlCallback(Diagnostics1SecControlId,Diagnostics_OneSecControlTrigger); DiagnosticsControlId = 0xFF; Diagnostics10MSControlId = 0xFF; + Diagnostics1SecControlId = 0xFF; } return OK; @@ -794,6 +832,19 @@ uint32_t Diagnostics_TenMiliControlTrigger(uint32_t IfIndex, uint32_t ReadValue) return OK; } +uint32_t Diagnostics_OneSecControlTrigger(uint32_t IfIndex, uint32_t ReadValue) +{ + DiagnosticsMessageStruc Message; + + //send message to the Millisec task + Message.messageId = DiagnosticsOneSecTrigger; + Message.msglen = sizeof(DiagnosticsMessageStruc); + if (DiagnosticsMsgQ != NULL) + Mailbox_post(DiagnosticsMsgQ , &Message, BIOS_NO_WAIT); + + + return OK; +} /****************************************************************************** * ======== messageTsk ======== * Task for this function is created statically. See the project's .cfg file. @@ -817,7 +868,12 @@ void DiagnosticsTask(UArg arg0, UArg arg1) Diagnostic100msecCollection(); break; case DiagnosticsTenMiliTrigger: +#ifdef TEN_MSEC_COLLECTION DiagnosticTenMsecCollection(); +#endif + break; + case DiagnosticsOneSecTrigger: + DiagnosticOneSecCollection(); break; default: break; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 8cd9daddc..eb9425bf3 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -129,6 +129,8 @@ uint32_t HWConfigurationInit(void) //EmbeddedParametersInit(); IDS_Dispenser_Content_Init(); //ProcessParamsInit(); + Buttons_Init(); + GeneralHwReady = true; STATUS_RED_LED_OFF; return status; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h index 33033ad69..a919ce4e1 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h @@ -24,6 +24,8 @@ extern bool DispensersAlarmState[ MAX_SYSTEM_DISPENSERS]; extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS]; +extern bool HomingActive[MAX_SYSTEM_DISPENSERS]; + uint32_t IDS_Dispenser_EmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue); /*typedef struct diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 16545b27d..8f02b5f04 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -107,8 +107,9 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re Control3WayValvesWithCallback ((Valves_t)DispenserId, CloseValve, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer if (DispenserControlId[DispenserId] != 0xFF) - Report("Cannot Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - + { + Report("Cannot Add control callback",__FILE__,(int)DispenserId,GetControlCallbackFuncPtr(DispenserControlId[DispenserId]),RpWarning,(int)DispenserControlId[DispenserId],0); + } DispenserControlId[DispenserId] = AddControlCallback( IDS_Dispenser_Build_Pressure_Callback, DispenserPrepareTimeLag,TemplateDataReadCBFunction ,DispenserId, DispenserId, 0 ); if (DispenserControlId[DispenserId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); @@ -127,7 +128,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re uint32_t IDS_Dispenser_StopMotorCallback(uint32_t DispenserId, uint32_t ReadValue) { - //Report("IDS_Dispenser_Close_Valve_And_Stop_Motor callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); + Report("IDS_Dispenser_Close_Valve_And_Stop_Motor callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); if (SafeRemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_StopMotorCallback )==OK) DispenserControlId[DispenserId] = 0xFF; else @@ -152,13 +153,13 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re Control3WayValvesWithCallback ((Valves_t)DispenserId, CloseValve, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer if (DispenserControlId[DispenserId] != 0xFF) - Report("Cannot Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + Report("Cannot Add control callback",__FILE__,(int)DispenserId,GetControlCallbackFuncPtr(DispenserControlId[DispenserId]),RpWarning,(int)DispenserControlId[DispenserId],0); DispenserControlId[DispenserId] = AddControlCallback( IDS_Dispenser_StopMotorCallback, CloseValveTimeout, TemplateDataReadCBFunction,DispenserId, DispenserId, 0 ); if (DispenserControlId[DispenserId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); - //else - // Report("Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + else + Report("Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); return OK; } @@ -202,7 +203,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee MotorSetSpeed(HW_Motor_Id, MotorSpeed); CurrentDispenserSpeed[DispenserId] = MotorSpeed; if (DispenserControlId[DispenserId] != 0xFF) - Report("Cannot Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + Report("Cannot Add control callback",__FILE__,(int)DispenserId,GetControlCallbackFuncPtr(DispenserControlId[DispenserId]),RpWarning,(int)DispenserControlId[DispenserId],0); //Report("IDS_Dispenser_Start_Motor_and_Open_Valve",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); DispenserControlId[DispenserId] = AddControlCallback( IDS_Dispenser_OpenValveCallback, OpenValveTimeout, TemplateDataReadCBFunction,DispenserId, DispenserId, 0 ); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index e578d593a..51086b09e 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -63,7 +63,7 @@ uint32_t IDS_DispenserControlInit(); uint32_t IDS_HomeDispenser (uint32_t deviceID, uint32_t speed , callback_fptr callback); uint32_t IDS_StopHomeDispenser (uint32_t deviceID); -uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t deviceID); +uint32_t IDS_HomeDispenserWaitForHomingEnd(uint32_t DispenserId, uint32_t timeout , callback_fptr callback); uint32_t IDS_EmptyDispenser (uint32_t deviceID, uint32_t speed , callback_fptr callback); uint32_t IDS_Dispenser_Alarm_On (uint8_t deviceID); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 9a0f23cbd..bfece1890 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -59,9 +59,14 @@ FPGA_GPI_ENUM Dispenser_Id_to_Alarm_LS_Id[MAX_SYSTEM_DISPENSERS*2] = { GPI_LS_DISPENSER_25_8, //MOTO_DISPENSER_8 = 13, }; callback_fptr HomingRequestCallback[MAX_SYSTEM_DISPENSERS]={0,0,0,0,0,0,0,0}; +callback_fptr HomingBacklashCallback[MAX_SYSTEM_DISPENSERS]={0,0,0,0,0,0,0,0}; +uint32_t HomingBacklashTimeout[MAX_SYSTEM_DISPENSERS]; +uint32_t HomingBacklashTime[MAX_SYSTEM_DISPENSERS]; + bool HomingActive[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; bool PrimingActive[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; uint32_t DispenserHomingControlId[MAX_SYSTEM_DISPENSERS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; +uint32_t DispenserBacklashControlId[MAX_SYSTEM_DISPENSERS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; uint32_t DispenserHomingTime[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; #define INITIAL_DISPENSER_PRESSURE 2.10 #define INITIAL_DISPENSER_TIMEOUT_LIMIT 60000 @@ -73,6 +78,9 @@ uint32_t InitialDispenserTimeout = INITIAL_DISPENSER_TIMEOUT_LIMIT; uint32_t InitialDispenserTimeLag = INITIAL_DISPENSER_TIMEOUT; uint32_t InitialDispenserSpeed = INITIAL_DISPENSER_SPEED; +uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t deviceID); + + void IDS_Dispenser_SetBackLashValues(double initialdispenserpressure, uint32_t initialdispensertimeout, uint32_t initialdispensertimelag, uint32_t initialdispenserspeed) { InitialDispenserPressure = initialdispenserpressure; @@ -82,6 +90,49 @@ void IDS_Dispenser_SetBackLashValues(double initialdispenserpressure, uint32 Report("IDS_Dispenser_SetBackLashValues ",__FILE__,InitialDispenserPressure,InitialDispenserTimeout,RpWarning,(int)InitialDispenserTimeLag,0); } +uint32_t IDS_HomeDispenserWaitForHomingEndCallback(uint32_t DispenserId, uint32_t ReadValue) +{ + HomingBacklashTime[DispenserId]+=eOneSecond; + if (( HomingActive[DispenserId]== false) ||((HomingBacklashTime[DispenserId]>=HomingBacklashTimeout[DispenserId])&&(HomingBacklashTimeout[DispenserId]>0))) + { + //stop this control loop + SafeRemoveControlCallback(DispenserBacklashControlId[DispenserId], IDS_HomeDispenserWaitForHomingEndCallback ); + DispenserBacklashControlId[DispenserId] = 0xFF; + + if (HomingBacklashCallback[DispenserId]) + { + if ( HomingActive[DispenserId]== false) + HomingBacklashCallback[DispenserId](DispenserId,OK); + else + HomingBacklashCallback[DispenserId](DispenserId,ERROR); + } + HomingBacklashCallback[DispenserId] = 0; + } + return OK; +} +uint32_t IDS_HomeDispenserWaitForHomingEnd(uint32_t DispenserId, uint32_t timeout , callback_fptr callback) +{ + assert(DispenserId < MAX_SYSTEM_DISPENSERS); + + if (HomingBacklashCallback[DispenserId]!=NULL) + return ERROR; + HomingBacklashCallback[DispenserId] = callback; + HomingBacklashTimeout[DispenserId] = timeout; + HomingBacklashTime[DispenserId] = 0; + + if (DispenserBacklashControlId[DispenserId] != 0xFF) + { + RemoveControlCallback(DispenserBacklashControlId[DispenserId], IDS_HomeDispenserWaitForHomingEndCallback ); + DispenserBacklashControlId[DispenserId] = 0xFF; + //return ERROR; + } + DispenserBacklashControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserWaitForHomingEnd,eOneSecond , TemplateDataReadCBFunction,DispenserId,0, 0 ); + if ( DispenserBacklashControlId[DispenserId] == 0xFF) + return ERROR; + + return OK; +} + uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) { uint8_t DispenserId = motorId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 039b152e5..7a719d39a 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -686,6 +686,19 @@ c. Go to step 2.a x Segment.BrushStopsCount. } return OK; } + uint32_t IDSPrepareStartDispenserAfterHoming(uint32_t DispenserId, uint32_t Result) + { + double dispenserspeed = 0; + Report("IDSPrepare Start Dispenser After Homing",__FILE__,__LINE__,DispenserId,RpWarning,(int)Result,0); + dispenserspeed = DispenserPrepareSpeed; + if (DispenserUsedInJob[DispenserId] == true) //we actually should check for all dispensers + { + Report("Prepare Speed",__FILE__,__LINE__,DispenserId,RpWarning,(int)dispenserspeed,0); + IDS_Dispenser_Start_Motor_and_Open_Valve(DispenserId,dispenserspeed, NULL); + } + return OK; + + } void IDSPrepareStart(void) { int i; @@ -700,9 +713,9 @@ c. Go to step 2.a x Segment.BrushStopsCount. NumOfActiveDispensers = 0; for (i = 0; i < MAX_DYE_DISPENSERS; i++) { - //IDS_StopHomeDispenser(i); if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { + IDS_StopHomeDispenser(i); NumOfActiveDispensers++; } } @@ -714,8 +727,16 @@ c. Go to step 2.a x Segment.BrushStopsCount. dispenserspeed = DispenserPrepareSpeed; if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { - Report("Prepare Speed",__FILE__,__LINE__,i,RpWarning,(int)dispenserspeed,0); - IDS_Dispenser_Start_Motor_and_Open_Valve(i,dispenserspeed, NULL); + if (HomingActive[i] == false) + { + Report("Prepare Speed",__FILE__,__LINE__,i,RpWarning,(int)dispenserspeed,0); + IDS_Dispenser_Start_Motor_and_Open_Valve(i,dispenserspeed, NULL); + } + else + { + Report("IDSPrepare Stop Dispenser Homing",__FILE__,__LINE__,i,RpWarning,(int)HomingActive[i],0); + IDS_HomeDispenserWaitForHomingEnd(i, DispenserPrepareTimeout/2 , IDSPrepareStartDispenserAfterHoming); + } } } } @@ -745,7 +766,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. if (DispenserBuildTimeCounter<(1*eOneSecond)) { - REPORT_MSG(DispenserBuildTimeCounter,"waiting 1 seconds for pressure changes"); + //REPORT_MSG(DispenserBuildTimeCounter,"waiting 1 seconds for pressure changes"); return OK; } if (PreSegmentWCFStarted == true) @@ -782,14 +803,14 @@ c. Go to step 2.a x Segment.BrushStopsCount. } if ((NumofReadyDispensers)&&(DispenserBuildTimeCounter%1000 == 0)) - Report("IDS_PreSegmentPrepare_Callback",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); + Report("IDS_PreSegmentPrepare_Callback",__FILE__,DispenserBuildTimeCounter,InterSegmentStepsCount,RpWarning,(int)NumOfActiveDispensers,0); if (NumofReadyDispensers>=NumOfActiveDispensers) pressureReady = true; if ((DispenserBuildTimeCounter >= DispenserPrepareTimeout)||(pressureReady == true)) { - Report("IDS_PreSegmentPrepare_Callback SafeRemoveControlCallback",__FILE__,DispenserPrepareControlId,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); + Report("IDS_PreSegmentPrepare_Callback SafeRemoveControlCallback",__FILE__,DispenserPrepareControlId,InterSegmentStepsCount,RpWarning,(int)NumOfActiveDispensers,0); SafeRemoveControlCallback(DispenserPrepareControlId, IDS_Prepare_Callback ); DispenserPrepareControlId = 0xFF; @@ -800,7 +821,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. //******************************************************************************************************************** void IDSPresegmentPrepareStart(void) { - int i; + int Dispenser_i,n_dispensers,DispenserId; TimerMotors_t HW_Motor_Id; double segmentfirst_speed; @@ -837,16 +858,16 @@ c. Go to step 2.a x Segment.BrushStopsCount. DispenserUsedInSegment[Dispenser_i] = true; MotorSetSpeed(HW_Motor_Id, DispenserPrepareSpeed); CurrentDispenserSpeed[Dispenser_i] = DispenserPrepareSpeed; - usnprintf(IdsMessage, 80,"WFCF Prepare Dispenser %d speed %d",DispenserId,(int) segmentfirst_speed); + usnprintf(IdsMessage, 80,"Presegment Prepare Dispenser %d speed %d",DispenserId,(int) DispenserPrepareSpeed); //REPORT_MSG(segmentfirst_speed,IdsMessage); - Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); + Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, DispenserPrepareSpeed, 0); //SendJobProgress(0.0, 0, false, IdsMessage); } else { MotorStop(HW_Motor_Id, Hard_Hiz); CurrentDispenserSpeed[Dispenser_i] = 0; - usnprintf(IdsMessage, 80,"WFCF Prepare Dispenser %d stopped",DispenserId,(int) segmentfirst_speed); + usnprintf(IdsMessage, 80,"Presegment Prepare Dispenser %d stopped",DispenserId,(int) segmentfirst_speed); Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); } @@ -960,7 +981,7 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); { IDS_PreSegmentPrepare_Callback(0,0); } - if ((InterSegmentStartWFCFDispensers > 0)&&(InterSegmentStartWFCFDispensers == InterSegmentStepsCount)) + if ((InterSegmentStartWFCFDispensers > 0)&&(InterSegmentStartWFCFDispensers == (lInterSegmentLength-InterSegmentStepsCount))) { Report("start dispensers at rate * WFCF",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); PreSegmentWCFStarted = true; // stop any presegment prepare stages, if still exist @@ -1448,7 +1469,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) InterSegmentStartRocking = 1000; InterSegmentCenterRockers = 3000; }*/ - InterSegmentStartWFCFDispensers = 0; + //InterSegmentStartWFCFDispensers = 0; return OK; @@ -1459,7 +1480,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) //TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[deviceID]; //REPORT_MSG(deviceID,"Dispenser End called"); //MotorStop(HW_Motor_Id,Hard_Hiz); - //IDS_HomeDispenser (deviceID, 800 , NULL); + //IDS_HomeDispenser (deviceID, 1000 , NULL); return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 7e1312464..5d9b26f92 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -59,10 +59,11 @@ static uint32_t WindingConeLocation; static uint32_t WinderBackToBaseTime = 800; InternalWinderConfigStruc InternalWinderCfg = {0}; - +#define READ_SCREW_ENCODER +#ifdef READ_SCREW_ENCODER uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0; uint32_t ScrewLocationRun[3]; - +#endif bool SampleWinding = false; uint32_t Winder_Init(void) { @@ -132,8 +133,10 @@ uint32_t Winder_Prepare(void *JobDetails) return ERROR; }*/ +#ifdef READ_SCREW_ENCODER ScrewLocationRun[0] = 0; ScrewLocationRun[1] = 0; +#endif if (( KeepWindingCone == false)||(WindingConeLocation == 0)) { WindingConeLocation = InternalWinderCfg.startoffsetpulses; @@ -176,10 +179,11 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) //MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,InternalWinderCfg.segmentoffsetpulses); //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); +#ifdef READ_SCREW_ENCODER Read_Screw_Encoder(); ScrewLocationLimitSwitch = Screw_RotEnc.Position; REPORT_MSG(ScrewLocationLimitSwitch, "Winder_PrepareStage2 Encoder Location"); - +#endif REPORT_MSG(millisecondCounter/*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency*/, "Winder_PrepareStage2"); if (ReadValue != LIMIT) @@ -203,6 +207,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) MotorStop (HARDWARE_MOTOR_TYPE__MOTO_SCREW,Soft_Hiz); //per L6470 errata between mov and run commands Task_sleep(5); +#ifdef READ_SCREW_ENCODER Reset_Screw_Encoder(); Task_sleep(5); Read_Screw_Encoder(); @@ -210,10 +215,13 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewLocationStart = Screw_RotEnc.Position; REPORT_MSG(ScrewLocationStart, "Winder_ScrewAtOffsetCallback Encoder Location"); +#endif SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_SCREW); //set this point as the spool home ScrewCurrentDirection = false; +#ifdef READ_SCREW_ENCODER ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; +#endif ScrewSpeed = 0; ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; @@ -302,13 +310,15 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) 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); +#ifdef READ_SCREW_ENCODER + + 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); //usnprintf(ScrewStr, 150, "Winder Encoder:id, diff, intended, winderspeed, rotation, speed, time, mot speed {, %d, %d, %d, %d, %d, %d, %d, %d, }",CalculationDirectionChangeCounter, // abs(ScrewLocationRun[1] - ScrewLocationRun[0]),ScrewNumberOfSteps,(int)(WinderReferenceSpeed),(int)(Rotations*10),(int)ScrewSpeed,(int)ScrewRunningTime,(int)speedf); //usnprintf(ScrewStr, 100, "Winder Encoder: 0 %d 1 %d diff %d ",ScrewLocationRun[0],ScrewLocationRun[1],ScrewLocationRun[1] - ScrewLocationRun[0]); //Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); - +#endif if (ScrewCurrentDirection == 1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize) //next time going out { if (Add100 == true) //once per job @@ -617,11 +627,13 @@ void ScrewTimerInterrupt(int ARG0) if (SCREW_TimerActivated == true) { - Read_Screw_Encoder(); ROM_TimerLoadSet(Screw_timerBase, TIMER_A,(int)ScrewRunningTime); MotorSetDirection (HARDWARE_MOTOR_TYPE__MOTO_SCREW, ScrewCurrentDirection); MotorSetSpeedDirect(HARDWARE_MOTOR_TYPE__MOTO_SCREW,ScrewSpeed); +#ifdef READ_SCREW_ENCODER + Read_Screw_Encoder(); ScrewLocationRun[ScrewCurrentDirection] = Screw_RotEnc.Position; +#endif // ScrewChangeCounter = 0; // ScrewChangeLimit = ScrewRunningTime/12000000; ScrewDirectionChangeCounter++; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index a9b63ea47..91979c8b1 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -51,11 +51,6 @@ void SetMachineState(MACHINE_STATE_STAGES_ENUM NewState) { MachineState = NewState; } -void StopInitSequence(void) -{ - InitStages = INIT_SEQUENCE_END; - InitSequenceStateMachine(InitStages); -} uint32_t HWControlId,InitSchedulerControlId; uint32_t MidTankControlId; @@ -72,6 +67,11 @@ uint32_t InitSequenceMachineReadyToDye(void); uint32_t InitSequenceStateMachine( INIT_SEQUENCE_STAGES_ENUM ReadValue); +void StopInitSequence(void) +{ + InitStages = INIT_SEQUENCE_END; + InitSequenceStateMachine(InitStages); +} uint32_t InitSequenceCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) { if (SafeRemoveControlCallback(HWControlId, InitSequenceCallBackFunction )==OK) diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index 94cb8b623..73421f142 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -36,14 +36,14 @@ typedef enum { POWER_OFF_INIT, + POWER_OFF_STOP_RUNNING_JOB, POWER_OFF_HEAD_CLEAN, POWER_OFF_MIXER_FLUSH, POWER_OFF_HEATERS_OFF, POWER_OFF_STORE_DATA, - POWER_OFF_WAIT_FOR_PROCESSES,//wait for waste emptying, ink filling, thread loading - POWER_OFF_STOP_RUNNING_JOB, POWER_OFF_SET_VALVE_POSITION, POWER_OFF_WAIT_FOR_TEMPERATURE, + POWER_OFF_WAIT_FOR_PROCESSES,//wait for waste emptying, ink filling, thread loading POWER_OFF_TURN_OFF_DRYER_FAN, POWER_OFF_TURN_OFF_COOLER, POWER_OFF_TURN_OFF_BLOWER, @@ -84,7 +84,9 @@ uint32_t PowerOffScheduler(uint32_t IfIndex, uint32_t BusyFlag) uint32_t PowerOffInit(void) { LOG_ERROR(0,"Power Off Init"); - PowerOffMachineState = POWER_OFF_HEAD_CLEAN; + PowerOffMachineState++; + StopInitSequence(); + setmachineActive(true); PowerOffInProcess = true; PowerOffControlId = AddControlCallback( PowerOffScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); return OK; @@ -97,19 +99,96 @@ uint32_t PowerOffCancel(void) PowerOffInProcess = false; return OK; } +/************************************************************************shlomo + + */ +uint32_t PowerOffHeadCleanControlId = 0xff; +uint32_t PowerOffHeadCleanCallback(uint32_t DispenserId, uint32_t ReadValue) +{ + if ( JobIsActive()== false) + { + //stop this control loop + SafeRemoveControlCallback(PowerOffHeadCleanControlId, PowerOffHeadCleanCallback ); + PowerOffHeadCleanControlId = 0xFF; + PowerOffMachineState++; + + } + return OK; +} /*******************************************************************************************************/ uint32_t PowerOffHeadClean(void) { + uint32_t status; + //TBD - PowerOffMachineState = POWER_OFF_MIXER_FLUSH; + ThreadCleaningJobFunc(50); + if (PowerOffHeadCleanControlId != 0xFF) + { + RemoveControlCallback(PowerOffHeadCleanControlId, PowerOffHeadCleanCallback ); + PowerOffHeadCleanControlId = 0xFF; + //return ERROR; + } + PowerOffHeadCleanControlId = AddControlCallback( PowerOffHeadCleanCallback,eOneSecond , TemplateDataReadCBFunction,0,0, 0 ); +// if ( PowerOffHeadCleanControlId == 0xFF) +// return ERROR; + return OK; } /*******************************************************************************************************/ -uint32_t PowerOffMixerFlush(void) +bool DispenserHomingActive[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; +uint32_t PowerOffDispenserHomingCallback(uint32_t DispenserId, uint32_t ReadValue) +{ + DispenserHomingActive[DispenserId] = false; + REPORT_MSG (DispenserId, "PowerOffDispenserHomingCallback"); +} +#define TI_DISPENSER_ID 4 +#define DEFAULT_MIXER_CLEANING_SPEED 1000 +#define DEFAULT_MIXER_CLEANING_TIMEOUT 10000 + +uint32_t PowerOffMixerFlushCallback(void) { //TBD - PowerOffMachineState = POWER_OFF_HEATERS_OFF; + int i; + REPORT_MSG (PowerOffMachineState, "PowerOffMixerFlushCallback"); + SafeRemoveControlCallback(PowerOffHeadCleanControlId, PowerOffMixerFlushCallback ); + + Control3WayValvesWithCallback ((Valves_t)TI_DISPENSER_ID, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer + TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[TI_DISPENSER_ID]; + MotorStop(HW_Motor_Id,Hard_Hiz); + + Task_sleep (20); + for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) + { + if(IDS_HomeDispenser(i,1000,PowerOffDispenserHomingCallback) == OK) + { + DispenserHomingActive[i] = true; + REPORT_MSG (i, "PowerOffDispenserHomingCallback"); + } + } + PowerOffMachineState++; + return OK; +} +uint32_t PowerOffMixerFlushDispenserStopCallback(void) +{ + REPORT_MSG (PowerOffMachineState, "PowerOffMixerFlushDispenserStopCallback"); + IDS_Dispenser_Start_Motor_and_Open_Valve(TI_DISPENSER_ID,DEFAULT_MIXER_CLEANING_SPEED,NULL); + PowerOffHeadCleanControlId = AddControlCallback( PowerOffMixerFlushCallback,DEFAULT_MIXER_CLEANING_TIMEOUT , TemplateDataReadCBFunction,0,0, 0 ); +} +/*******************************************************************************************************/ +uint32_t PowerOffMixerFlush(void) +{ + int i; + REPORT_MSG (PowerOffMachineState, "PowerOffMixerFlush"); + Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); //if intersegment is defined throw the ink away + for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) + { + if (i!=TI_DISPENSER_ID) + IDS_Dispenser_Close_Valve_And_Stop_Motor(i, NULL); + else + IDS_Dispenser_Close_Valve_And_Stop_Motor(i, PowerOffMixerFlushDispenserStopCallback); + } + return OK; } /*******************************************************************************************************/ @@ -133,7 +212,7 @@ uint32_t PowerOffHeatersOff(void) return ERROR; } - PowerOffMachineState = POWER_OFF_STORE_DATA; + PowerOffMachineState++; return OK; } @@ -143,25 +222,35 @@ uint32_t PowerOffStoreData(void) //TBD REPORT_MSG (PowerOffMachineState, "Store Data"); IDS_Dispenser_Store_Data(); - PowerOffMachineState = POWER_OFF_WAIT_FOR_PROCESSES; + PowerOffMachineState++; return OK; } /*******************************************************************************************************/ int WaitForProcessCounter = 0; uint32_t PowerOffWaitForProcessesCallback(uint32_t IfIndex, uint32_t BusyFlag) { + int i; + bool HomingActive = false; + for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) + { + if (DispenserHomingActive[i] ==true) + { + HomingActive = true; + } + } if ((WHS_IsEmptying()|| //MidTankFillingActive()|| ThreadLoadingActive()|| - SwUpgradeActive())&& + SwUpgradeActive()|| + (HomingActive == true))&& (WaitForProcessCounter++<900)) { - REPORT_MSG (PowerOffMachineState, "On going processes, wait for end of process"); + REPORT_MSG (PowerOffMachineState, "Ongoing processes calback, wait for end of process"); resetIdleCounter(); } else { - PowerOffMachineState = POWER_OFF_SET_VALVE_POSITION; + PowerOffMachineState++; SafeRemoveControlCallback(WaitForProcessControlId, PowerOffWaitForProcessesCallback); WaitForProcessControlId = 0xFF; } @@ -172,20 +261,31 @@ uint32_t PowerOffWaitForProcesses(void) { int i; REPORT_MSG (PowerOffMachineState, "Stop dispensers homing"); + bool HomingActive = false; for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) - IDS_StopHomeDispenser(i); + { + if (DispenserHomingActive[i] ==true) + { + HomingActive = true; + IDS_StopHomeDispenser(i); + REPORT_MSG (i, "IDS_StopHomeDispenser"); + IDS_HomeDispenserWaitForHomingEnd(i, 2*eOneMinute /*2 minutes*/ , PowerOffDispenserHomingCallback); + } + } + if (WHS_IsEmptying()|| //MidTankFillingActive()|| ThreadLoadingActive()|| - SwUpgradeActive()) + SwUpgradeActive()|| + (HomingActive == true)) { WaitForProcessCounter = 0; //15 minutes wait - REPORT_MSG (PowerOffMachineState, "On going processes, wait for end of process"); + REPORT_MSG (PowerOffMachineState, "Ongoing processes, wait for end of process"); WaitForProcessControlId = AddControlCallback( PowerOffWaitForProcessesCallback, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); } else { - PowerOffMachineState = POWER_OFF_STOP_RUNNING_JOB; + PowerOffMachineState++; } //TBD return OK; @@ -198,14 +298,14 @@ uint32_t PowerOffStopRunningJob(void) REPORT_MSG (PowerOffMachineState, "Stop running job"); AbortJob("Power off pressed"); } - PowerOffMachineState = POWER_OFF_SET_VALVE_POSITION; + PowerOffMachineState++; return OK; } /*******************************************************************************************************/ uint32_t PowerOffSetValvePosition(void) { //TBD - PowerOffMachineState = POWER_OFF_WAIT_FOR_TEMPERATURE; + PowerOffMachineState++; return OK; } /*******************************************************************************************************/ @@ -267,7 +367,7 @@ uint32_t PowerOffWaitForTemperature(void) uint32_t PowerOffTurnOffDryerFan(void) { Control_Dryer_Fan(STOP,75);//use START or STOP, 0 - 100% - PowerOffMachineState = POWER_OFF_TURN_OFF_COOLER; + PowerOffMachineState++; //TBD return OK; @@ -276,14 +376,14 @@ uint32_t PowerOffTurnOffDryerFan(void) uint32_t PowerOffTurnOffCooler(void) { uint32_t DeActivateChiller(); - PowerOffMachineState = POWER_OFF_TURN_OFF_BLOWER; + PowerOffMachineState++; return OK; } /*******************************************************************************************************/ uint32_t PowerOffTurnOffBlower(void) { Turn_the_Blower_Off();//Turn off - PowerOffMachineState = POWER_OFF_POWER_OFF; + PowerOffMachineState++; return OK; } /*******************************************************************************************************/ diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h index 96d48771d..afc5a3d9d 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.h @@ -11,14 +11,14 @@ typedef enum { POWER_OFF_INIT, + POWER_OFF_STOP_RUNNING_JOB, POWER_OFF_HEAD_CLEAN, POWER_OFF_MIXER_FLUSH, POWER_OFF_HEATERS_OFF, POWER_OFF_STORE_DATA, - POWER_OFF_WAIT_FOR_PROCESSES,//wait for waste emptying, ink filling, thread loading - POWER_OFF_STOP_RUNNING_JOB, POWER_OFF_SET_VALVE_POSITION, POWER_OFF_WAIT_FOR_TEMPERATURE, + POWER_OFF_WAIT_FOR_PROCESSES,//wait for waste emptying, ink filling, thread loading POWER_OFF_TURN_OFF_DRYER_FAN, POWER_OFF_TURN_OFF_COOLER, POWER_OFF_TURN_OFF_BLOWER, diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index b680138fd..af795d91c 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -87,6 +87,8 @@ uint32_t StubControlId = 0xFF; double StubLengthCounter = 0,StubLength = 0,StubSpeed=0; JobTicket Ticket; JobSegment *TSegment; +JobBrushStop *TbrushStop; +JobDispenser *Tdispenser; JobSpool *Tspool; bool CopyConfigured[MAX_SYSTEM_MODULES]; char ErrorMsg[100]; @@ -404,6 +406,76 @@ uint32_t ThreadJoggingFunc(int speed) } return status; } +//******************************************************************************************************************** +uint32_t ThreadCleaningJobFunc(int speed) +{ + ProcessParameters ProcessParametersCopy; + uint32_t status = OK; + if (JobIsActive() == true) + { + status = ERROR; + LOG_ERROR(JobIsActive(),"Jog JobIsActive"); + } + else + { + memcpy(&CopyConfigured,&Configured,sizeof(CopyConfigured)); + //set the job handler to ignore heaters, ids and waste in the state machine + Configured[Module_Thread] = true; + Configured[Module_Winder] = true; + Configured[Module_IDS] = false; + Configured[Module_Heaters] = false; + Configured[Module_Waste] = false; + //set the requested speed without changing other process parameters + memcpy (&ProcessParametersCopy,&ProcessParametersKeep,sizeof(ProcessParameters)); + if(speed) + ProcessParametersCopy.dyeingspeed = speed; + else + ProcessParametersCopy.dyeingspeed = 40; + if (HandleProcessParameters(&ProcessParametersCopy)!= OK) + { + status = FAILED; + } + else + { + //load essential job prameters to enable thread running + Ticket.uploadstrategy = JOB_UPLOAD_STRATEGY__Default; + Ticket.n_segments = 1; + Ticket.enableintersegment = true; + Ticket.intersegmentlength = 200; + n_segments = 2; + Ticket.segments = my_malloc(sizeof(Ticket.segments)*2); + TSegment = my_malloc(sizeof(JobSegment)); + Tspool = my_malloc(sizeof(JobSpool)); + TbrushStop = my_malloc(sizeof(JobBrushStop)); + TSegment->length = 200.0; + TSegment->n_brushstops = 1; + TSegment->brushstops = my_malloc(sizeof(TSegment->brushstops)); + TSegment->brushstops[0] = TbrushStop; + Tdispenser = my_malloc(sizeof(JobDispenser)); + + TbrushStop->has_index =true; + TbrushStop->index = 0; + TbrushStop->n_dispensers = 1; + TbrushStop->dispensers = my_malloc(sizeof(TbrushStop->dispensers)); + TbrushStop->dispensers[0] = Tdispenser; + Tdispenser->nanolitterpersecond = 10000; + Tdispenser->nanoliterperpulse = 2.34; + Tdispenser->dispenserstepdivision = DISPENSER_STEP_DIVISION__Auto; + 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; + Ticket.spool = Tspool; + CurrentJob = &Ticket; + InternalWindingConfigMessage(Tspool); + StartJob(&Ticket); + } + } + return status; +} void ThreadJoggingRequestFunc(MessageContainer* requestContainer) { uint32_t status = OK; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h index b9a82defa..e1a52cef4 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.h @@ -164,6 +164,7 @@ void ThreadAbortJoggingRequestFunc(MessageContainer* requestContainer); void ThreadAbortJoggingFunc(void); uint32_t ThreadJoggingFunc(int speed); +uint32_t ThreadCleaningJobFunc(int speed); uint32_t CurrentJobRequestFunc(MessageContainer* requestContainer); uint32_t ResumeCurrentJobRequestFunc(MessageContainer* requestContainer); |
