From 87e24883ea2c5f1947943547cff29357bc8cbd2f Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 24 Oct 2019 17:08:31 +0300 Subject: small fix --- Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 88d62a495..8c42735cb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -11,7 +11,7 @@ #include "PMR/Hardware/HardwareDancer.pb-c.h" #include "PMR/Hardware/HardwareWinder.pb-c.h" #include "PMR/Hardware/HardwareBreakSensor.pb-c.h" -#include +#include "PMR/Diagnostics/EventType.pb-c.h" #include "Modules/AlarmHandling/AlarmHandling.h" #include "PMR/Printing/JobSpool.pb-c.h" -- cgit v1.3.1 From cd18fb27a2499072f18cb0320ddeb85a0500a93e Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Thu, 31 Oct 2019 10:16:10 +0200 Subject: version 1.4.6.0 - going forward --- Software/Embedded_SW/Embedded/.cproject | 4 +- .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 2 +- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 2 +- .../PMR/Diagnostics/DiagnosticsMonitors.pb-c.c | 32 ++- .../PMR/Diagnostics/DiagnosticsMonitors.pb-c.h | 6 +- .../PMR/Diagnostics/InterfaceIOs.pb-c.c | 34 ++-- .../PMR/Diagnostics/InterfaceIOs.pb-c.h | 1 + .../Communication/PMR/Printing/JobTicket.pb-c.c | 8 +- .../Communication/PMR/Printing/JobTicket.pb-c.h | 4 +- .../Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c | 11 +- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c | 22 +- .../Drivers/I2C_Communication/ADC_MUX/ADC_MUX.h | 6 +- .../Drivers/I2C_Communication/DAC/Blower.c | 2 +- .../Dispenser_Card/IO_Ports/Dispenser_IO.c | 4 + .../Dispenser_Card/IO_Ports/Dispenser_IO.h | 1 + .../Embedded/Drivers/I2C_Communication/I2C.h | 2 + .../Embedded/Drivers/I2C_Communication/I2C_Task.c | 85 ++++++++ .../Embedded_SW/Embedded/Drivers/Motors/Motor.c | 14 +- .../Embedded_SW/Embedded/Drivers/Motors/Motor.h | 1 + .../Embedded/Drivers/Motors/MotorActions.c | 30 +-- .../Embedded_SW/Embedded/Drivers/Valves/Valve.c | 2 +- Software/Embedded_SW/Embedded/Embedded.cfg | 6 + .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 102 +++++++--- .../Modules/Control/DriverWithCallbackExample.c | 4 +- .../Embedded/Modules/Control/MillisecTask.c | 19 +- .../Embedded_SW/Embedded/Modules/Control/control.c | 10 +- .../Embedded_SW/Embedded/Modules/Control/control.h | 2 +- .../Modules/Diagnostics/DiagnosticActions.c | 6 + .../Embedded/Modules/Diagnostics/Diagnostics.c | 225 +++++++++++++++------ .../Modules/Diagnostics/DiagnosticsHoming.c | 9 +- .../Embedded/Modules/General/GeneralHardware.c | 4 +- .../Embedded/Modules/General/MachineStatus.c | 2 +- .../Embedded_SW/Embedded/Modules/General/Safety.c | 21 +- .../Embedded_SW/Embedded/Modules/General/buttons.c | 6 +- .../Embedded/Modules/Heaters/Heaters_print.c | 18 +- Software/Embedded_SW/Embedded/Modules/IDS/IDS.h | 1 + .../Embedded/Modules/IDS/IDS_dispenser.c | 12 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 12 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 10 +- .../Embedded/Modules/Stubs_Handler/Progress.c | 16 -- .../Embedded/Modules/Thread/ThreadLoad.c | 83 +++++--- .../Embedded/Modules/Thread/Thread_Winder.c | 4 +- .../Embedded/Modules/Thread/Thread_init.c | 56 ++--- .../Embedded/Modules/Thread/Thread_print.c | 26 ++- .../Embedded/Modules/Waste/Waste_init.c | 46 ++--- .../Embedded/Software Release Notes.txt | 40 ++++ .../StateMachines/Initialization/InitSequence.c | 11 +- .../StateMachines/Initialization/PowerIdle.c | 4 +- .../Initialization/PowerOffSequence.c | 10 +- .../Embedded/StateMachines/Printing/JobSTM.c | 30 ++- .../Embedded/embeddedparametersbuild.cs | 2 +- 51 files changed, 748 insertions(+), 322 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Drivers/I2C_Communication/I2C_Task.c (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 1998a5e88..c46e66ca2 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -269,7 +269,7 @@ - + @@ -441,7 +441,7 @@ - + diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 8818d51e5..e15ae2dc4 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -130,7 +130,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) CurrentRunningFile = 0; File_i = 0; //add control 1 second - ActivateVersionControlId = AddControlCallback( ActivateVersionCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + ActivateVersionControlId = AddControlCallback(NULL, ActivateVersionCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); } for (File_i = 0;File_in_filedescriptors;File_i++) { 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 67e778c73..5e0a5c31a 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,5,95}; +TangoVersion_t _gTangoVersion = {1,4,6,0}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.c index 2a5974162..dfa72d2db 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.c @@ -52,7 +52,7 @@ void diagnostics_monitors__free_unpacked assert(message->base.descriptor == &diagnostics_monitors__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor diagnostics_monitors__field_descriptors[63] = +static const ProtobufCFieldDescriptor diagnostics_monitors__field_descriptors[65] = { { "Dancer1Angle", @@ -810,6 +810,30 @@ static const ProtobufCFieldDescriptor diagnostics_monitors__field_descriptors[63 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "DispensersInkLevel", + 64, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(DiagnosticsMonitors, n_dispensersinklevel), + offsetof(DiagnosticsMonitors, dispensersinklevel), + &double_array__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "MidTanksInkLevel", + 65, + PROTOBUF_C_LABEL_REPEATED, + PROTOBUF_C_TYPE_MESSAGE, + offsetof(DiagnosticsMonitors, n_midtanksinklevel), + offsetof(DiagnosticsMonitors, midtanksinklevel), + &double_array__descriptor, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned diagnostics_monitors__field_indices_by_name[] = { 38, /* field[38] = BlowerVoltage */ @@ -834,6 +858,7 @@ static const unsigned diagnostics_monitors__field_indices_by_name[] = { 34, /* field[34] = Dispenser8MotorFrequency */ 46, /* field[46] = Dispenser8Pressure */ 22, /* field[22] = DispensersAngularEncoders */ + 63, /* field[63] = DispensersInkLevel */ 23, /* field[23] = DispensersLinearPositions */ 21, /* field[21] = DispensersMotorsFrequency */ 24, /* field[24] = DispensersPressure */ @@ -867,6 +892,7 @@ static const unsigned diagnostics_monitors__field_indices_by_name[] = { 52, /* field[52] = MidTank6Level */ 53, /* field[53] = MidTank7Level */ 54, /* field[54] = MidTank8Level */ + 64, /* field[64] = MidTanksInkLevel */ 62, /* field[62] = Mixer1HeaterCurrent */ 9, /* field[9] = MixerTemperature */ 5, /* field[5] = PollerMotor */ @@ -879,7 +905,7 @@ static const unsigned diagnostics_monitors__field_indices_by_name[] = { static const ProtobufCIntRange diagnostics_monitors__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 63 } + { 0, 65 } }; const ProtobufCMessageDescriptor diagnostics_monitors__descriptor = { @@ -889,7 +915,7 @@ const ProtobufCMessageDescriptor diagnostics_monitors__descriptor = "DiagnosticsMonitors", "", sizeof(DiagnosticsMonitors), - 63, + 65, diagnostics_monitors__field_descriptors, diagnostics_monitors__field_indices_by_name, 1, diagnostics_monitors__number_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.h index 13ebbaf21..ef860a31f 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/DiagnosticsMonitors.pb-c.h @@ -153,10 +153,14 @@ struct _DiagnosticsMonitors double *headzone5_6heatercurrent; size_t n_mixer1heatercurrent; double *mixer1heatercurrent; + size_t n_dispensersinklevel; + DoubleArray **dispensersinklevel; + size_t n_midtanksinklevel; + DoubleArray **midtanksinklevel; }; #define DIAGNOSTICS_MONITORS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&diagnostics_monitors__descriptor) \ - , 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL } + , 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL, 0,NULL } /* DiagnosticsMonitors methods */ diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.c index b15763408..e51a7693c 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.c @@ -7,7 +7,7 @@ #endif #include "InterfaceIOs.pb-c.h" -static const ProtobufCEnumValue interface_ios__enum_values_by_number[41] = +static const ProtobufCEnumValue interface_ios__enum_values_by_number[42] = { { "ANALOG_MIXCHIP_TEMP", "INTERFACE_IOS__ANALOG_MIXCHIP_TEMP", 0 }, { "GPO_MIXCHIP_SSR4_CTRL", "INTERFACE_IOS__GPO_MIXCHIP_SSR4_CTRL", 19 }, @@ -40,6 +40,7 @@ static const ProtobufCEnumValue interface_ios__enum_values_by_number[41] = { "Midtank7Cartridge", "INTERFACE_IOS__Midtank7Cartridge", 179 }, { "Midtank8Cartridge", "INTERFACE_IOS__Midtank8Cartridge", 180 }, { "SW_SPARE", "INTERFACE_IOS__SW_SPARE", 224 }, + { "GPO_BUZZER", "INTERFACE_IOS__GPO_BUZZER", 270 }, { "GPO_LED4", "INTERFACE_IOS__GPO_LED4", 274 }, { "GPO_TFEED_BREAK_1", "INTERFACE_IOS__GPO_TFEED_BREAK_1", 296 }, { "GPO_SPARE1_1", "INTERFACE_IOS__GPO_SPARE1_1", 318 }, @@ -52,15 +53,16 @@ static const ProtobufCEnumValue interface_ios__enum_values_by_number[41] = { "VALVE_WASTE_TANK", "INTERFACE_IOS__VALVE_WASTE_TANK", 346 }, }; static const ProtobufCIntRange interface_ios__value_ranges[] = { -{0, 0},{19, 1},{43, 6},{54, 9},{64, 11},{163, 12},{224, 30},{274, 31},{296, 32},{318, 33},{341, 35},{0, 41} +{0, 0},{19, 1},{43, 6},{54, 9},{64, 11},{163, 12},{224, 30},{270, 31},{274, 32},{296, 33},{318, 34},{341, 36},{0, 42} }; -static const ProtobufCEnumValueIndex interface_ios__enum_values_by_name[41] = +static const ProtobufCEnumValueIndex interface_ios__enum_values_by_name[42] = { { "ANALOG_MIXCHIP_TEMP", 0 }, - { "GPI_WCONTAINER_FULL", 35 }, - { "GPI_WCONTAINER_WARN", 36 }, - { "GPO_BLOWER_PWM", 37 }, - { "GPO_CHILLER_SSR9_CTRL", 38 }, + { "GPI_WCONTAINER_FULL", 36 }, + { "GPI_WCONTAINER_WARN", 37 }, + { "GPO_BLOWER_PWM", 38 }, + { "GPO_BUZZER", 31 }, + { "GPO_CHILLER_SSR9_CTRL", 39 }, { "GPO_DILUTORPUMP_SSR10_CTRL", 12 }, { "GPO_DRYER_SSR1_CTRL", 6 }, { "GPO_DRYER_SSR2_CTRL", 7 }, @@ -70,15 +72,15 @@ static const ProtobufCEnumValueIndex interface_ios__enum_values_by_name[41] = { "GPO_DYEINGH_SSR7_CTRL", 4 }, { "GPO_DYEINGH_SSR8_CTRL", 5 }, { "GPO_EXTWINDER_SSR11_CTRL", 11 }, - { "GPO_LED4", 31 }, + { "GPO_LED4", 32 }, { "GPO_MIXCHIP_SSR4_CTRL", 1 }, - { "GPO_SPARE1_1", 33 }, - { "GPO_SPARE1_2", 34 }, + { "GPO_SPARE1_1", 34 }, + { "GPO_SPARE1_2", 35 }, { "GPO_SPARE_SSR12_CTRL", 9 }, { "GPO_SPARE_SSR13_CTRL", 10 }, - { "GPO_TFEED_BREAK_1", 32 }, + { "GPO_TFEED_BREAK_1", 33 }, { "GPO_WASTECH_PUMP2", 13 }, - { "GPO_WHS_WTANKPUMP2", 39 }, + { "GPO_WHS_WTANKPUMP2", 40 }, { "Midtank1Air", 14 }, { "Midtank1Cartridge", 22 }, { "Midtank2Air", 15 }, @@ -96,7 +98,7 @@ static const ProtobufCEnumValueIndex interface_ios__enum_values_by_name[41] = { "Midtank8Air", 21 }, { "Midtank8Cartridge", 29 }, { "SW_SPARE", 30 }, - { "VALVE_WASTE_TANK", 40 }, + { "VALVE_WASTE_TANK", 41 }, }; const ProtobufCEnumDescriptor interface_ios__descriptor = { @@ -105,11 +107,11 @@ const ProtobufCEnumDescriptor interface_ios__descriptor = "InterfaceIOs", "InterfaceIOs", "", - 41, + 42, interface_ios__enum_values_by_number, - 41, + 42, interface_ios__enum_values_by_name, - 11, + 12, interface_ios__value_ranges, NULL,NULL,NULL,NULL /* reserved[1234] */ }; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.h index eea1cb6b8..31e40ba6e 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Diagnostics/InterfaceIOs.pb-c.h @@ -51,6 +51,7 @@ typedef enum _InterfaceIOs { INTERFACE_IOS__Midtank7Cartridge = 179, INTERFACE_IOS__Midtank8Cartridge = 180, INTERFACE_IOS__SW_SPARE = 224, + INTERFACE_IOS__GPO_BUZZER = 270, INTERFACE_IOS__GPO_LED4 = 274, INTERFACE_IOS__GPO_TFEED_BREAK_1 = 296, INTERFACE_IOS__GPO_SPARE1_1 = 318, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c index 53754f409..70d17789c 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.c @@ -199,12 +199,12 @@ static const ProtobufCFieldDescriptor job_ticket__field_descriptors[14] = 0,NULL,NULL /* reserved1,reserved2, etc */ }, { - "units", + "NumberOfUnits", 13, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_UINT32, - offsetof(JobTicket, has_units), - offsetof(JobTicket, units), + offsetof(JobTicket, has_numberofunits), + offsetof(JobTicket, numberofunits), NULL, NULL, 0, /* flags */ @@ -231,13 +231,13 @@ static const unsigned job_ticket__field_indices_by_name[] = { 10, /* field[10] = JobDescriptionFile */ 4, /* field[4] = Length */ 1, /* field[1] = Name */ + 12, /* field[12] = NumberOfUnits */ 5, /* field[5] = ProcessParameters */ 13, /* field[13] = SampleWinding */ 8, /* field[8] = Segments */ 7, /* field[7] = Spool */ 9, /* field[9] = UploadStrategy */ 6, /* field[6] = WindingMethod */ - 12, /* field[12] = units */ }; static const ProtobufCIntRange job_ticket__number_ranges[1 + 1] = { diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h index d54a9c32e..3d555b717 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Printing/JobTicket.pb-c.h @@ -50,8 +50,8 @@ struct _JobTicket char *jobdescriptionfile; protobuf_c_boolean has_enablelubrication; protobuf_c_boolean enablelubrication; - protobuf_c_boolean has_units; - uint32_t units; + protobuf_c_boolean has_numberofunits; + uint32_t numberofunits; protobuf_c_boolean has_samplewinding; protobuf_c_boolean samplewinding; }; 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 26996ad48..1f871a4cc 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 @@ -547,17 +547,18 @@ bool Is_FPGA_WD_Occurred() LOG_ERROR (FPGA_WD_Counter, "FPGA WD Occurred"); FPGA_WD_Counter = FPGA_WD_Counter+1; FPGA_WD_Occurred = true; -/* + //To recover: //1. Disable all FPGA's WD: Control_WD(DISABLE,0); //2. Enqable all FPGA's WD: Control_WD(ENABLE,250); //3. Call FPGA_SetMotorsInit: - FPGA_SetMotorsInit(); + //FPGA_SetMotorsInit(); //4. Init Motor's Drivers: - Init_Motors_Drivers_After_FPGA_WD(); - + //Init_Motors_Drivers_After_FPGA_WD(); + Motor_ReconfigAllMotors(); +/* //OR //Reset MCU (will reset also the FPGA): //Power_Reset(); @@ -789,7 +790,7 @@ uint32_t SecondaryPumpCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) void PumpActivation(uint32_t seconds) { Pumps_Control(WASTECH_PUMP2, OPEN); - SecondaryPumpControlId = AddControlCallback( SecondaryPumpCallBackFunction, seconds*1000/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + SecondaryPumpControlId = AddControlCallback(NULL, SecondaryPumpCallBackFunction, seconds*1000/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); } /* uint8_t Buttons_LEDS(BUTTON Button, OPERATION_MODE LED_Mode) diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c index 331913816..fe8a96b32 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/ADC_MUX/ADC_MUX.c @@ -26,6 +26,7 @@ #include "ADC_MUX.h" #include "Modules/AlarmHandling/AlarmHandling.h" +#include "modules/ids/ids_ex.h" bool MidTank_Pressure_Read_Enable[NUM_OF_MIDTANKS] = {true,true,true,true,true,true,true,true}; double MidTank_Pressure[NUM_OF_MIDTANKS] = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}; @@ -388,10 +389,10 @@ double Get_MidTank_Pressure_Sensor(MidTank_t MidTank_ID) //0-7 assert (MidTank_ID +#include +#include "include.h" +#include "inc/hw_memmap.h" + +#include "drivers/ADC_Sampling/adc.h" + +#include "ADC_MUX/ADC_MUX.h" +#include "modules/ids/ids_ex.h" + +Mailbox_Handle I2C_ReadingMsgQ = NULL; +typedef enum +{ + Midtank_Pressure_Reading, + Heater_Current_Reading +}I2C_ReadingMessages; + +typedef struct I2C_ReadingMessage{ + uint16_t messageId; + uint16_t parameter; +}I2C_ReadingMessageStruc; + +void Trigger_Heater_Current_Read(void) +{ + I2C_ReadingMessageStruc I2C_ReadingMessage; + uint8_t Heater_i; + + for (Heater_i = 0;Heater_i < NUM_OF_CURRENT_HEATERS;Heater_i++) + { + I2C_ReadingMessage.messageId = Heater_Current_Reading; + I2C_ReadingMessage.parameter = Heater_i; + if (I2C_ReadingMsgQ != NULL) + Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); + } + return; + +} + +void Trigger_MidTank_Pressure_Read(void) +{ + I2C_ReadingMessageStruc I2C_ReadingMessage; + uint8_t Midtank_i; + + for (Midtank_i = 0;Midtank_i < MAX_SYSTEM_DISPENSERS;Midtank_i++) + { + I2C_ReadingMessage.messageId = Midtank_Pressure_Reading; + I2C_ReadingMessage.parameter = Midtank_i; + if (I2C_ReadingMsgQ != NULL) + Mailbox_post(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_NO_WAIT); + } + return; + +} +void I2C_ReadingTask(UArg arg0, UArg arg1) +{ + I2C_ReadingMessageStruc I2C_ReadingMessage; + Error_Block eb; + Error_init(&eb); + I2C_ReadingMsgQ = Mailbox_create(sizeof(I2C_ReadingMessageStruc), 40, NULL,&eb); + + while(1) + { + Mailbox_pend(I2C_ReadingMsgQ , &I2C_ReadingMessage, BIOS_WAIT_FOREVER); + switch (I2C_ReadingMessage.messageId) + { + case Midtank_Pressure_Reading: + //Report("Read_MidTank_Pressure_Sensor",__FILE__,__LINE__,255,RpWarning,0,0); + Read_MidTank_Pressure_Sensor(I2C_ReadingMessage.parameter); + break; + case Heater_Current_Reading: + //Report("Read_Heaters_Current",__FILE__,__LINE__,255,RpWarning,0,0); + Read_Heaters_Current(I2C_ReadingMessage.parameter); + break; + default: + break; + } + } +} diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c index 7ea2ea79a..4a5a48f04 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.c @@ -86,7 +86,19 @@ uint32_t MotorConfig(TimerMotors_t _motorId, MotorDriverConfigStruc *MotorConfig return FPGA_MotorConfig( _motorId, MotorConfig); #endif } - +uint32_t Motor_ReconfigAllMotors(void) +{ + TimerMotors_t Motor_i; + uint32_t status = PASSED; + for (Motor_i = 0; Motor_i < NUM_OF_MOTORS ; Motor_i++) + { + if (isMotorConfigured(Motor_i)) + { + status |= MotorConfig( Motor_i, &MotorsCfg[Motor_i]); + } + } + return status; +} bool isMotorConfigured(TimerMotors_t _motorId) { return MotorConfigState[_motorId]; diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h index afacb50c3..59a8726f3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/Motor.h @@ -131,6 +131,7 @@ extern MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]; uint32_t MotorsInit(void); //set the motor configuration uint32_t MotorConfig(TimerMotors_t _motorId, MotorDriverConfigStruc *MotorConfig); +uint32_t Motor_ReconfigAllMotors(void); bool isMotorConfigured(TimerMotors_t _motorId); diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 5c25a87ca..b39b9f325 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -147,7 +147,7 @@ uint32_t MotorGotoWithCallback (TimerMotors_t MotorId, uint32_t Steps, uint32_t MotorStop(MotorId,Hard_Hiz ); Task_sleep(100); MotorGoTo(MotorId,Steps ); - MotorControlId[MotorId] = AddControlCallback( MotorMoveToLimitSwitchCallBackFunction, eTenMillisecond, FPGA_Read_limit_Switches,(IfTypeMotors*0x100+MotorId), LimitSwitchId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveToLimitSwitchCallBackFunction, eTenMillisecond, FPGA_Read_limit_Switches,(IfTypeMotors*0x100+MotorId), LimitSwitchId, 0 ); MotorControlCallback[MotorId] = MotorMoveToLimitSwitchCallBackFunction; return MotorControlId[MotorId]; } @@ -163,7 +163,7 @@ uint32_t MotorGotoWithBusyCallback (TimerMotors_t MotorId,bool direction, uint32 //MotorStop(MotorId,Hard_Hiz ); int sign = direction?1:-1; MotorGoTo(MotorId,Steps*sign ); - MotorControlId[MotorId] = AddControlCallback( MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveCallBackFunction; return MotorControlId[MotorId]; } @@ -184,7 +184,7 @@ uint32_t MotorMoveWithCallback (TimerMotors_t MotorId,bool direction, uint32_t S //MotorStop(MotorId,Hard_Hiz ); MotorMove(MotorId,direction,Steps ); - MotorControlId[MotorId] = AddControlCallback( MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveCallBackFunction, /*eTenMillisecond*/20, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveCallBackFunction; return MotorControlId[MotorId]; } @@ -284,7 +284,7 @@ uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Spee StoredMotorPosition[MotorId] = MotorGetPosition(MotorId); REPORT_MSG(StoredMotorPosition[MotorId],"MotorMoveToStopper initial position"); MotorSetSpeed (MotorId, Speed); - MotorControlId[MotorId] = AddControlCallback( MotorVerifiedCallBackFunction, 20,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorVerifiedCallBackFunction, 10,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorVerifiedCallBackFunction; return MotorControlId[MotorId]; } @@ -321,7 +321,7 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea MotorStop(MotorId,Hard_Stop ); //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); //call the module callback if (MotorCallback[MotorId]) @@ -359,7 +359,7 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb //MotorSetDirection( MotorId, direction); MotorSetSpeed (MotorId, 50); - MotorControlId[MotorId] = AddControlCallback( MotorMoveToDrierPositionCallBackFunction, 2,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveToDrierPositionCallBackFunction, 2,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveToDrierPositionCallBackFunction; return MotorControlId[MotorId]; @@ -370,7 +370,7 @@ uint32_t MotorSetSpeedWithCallback (TimerMotors_t MotorId, uint32_t _freq, callb //assert (callback); MotorCallback[MotorId] = callback; - MotorControlId[MotorId] = AddControlCallback( MotorSetSpeedCallBackFunction, eTenMillisecond, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorSetSpeedCallBackFunction, eTenMillisecond, MotorControlGetnBusyState,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorSetSpeedCallBackFunction; MotorSetSpeed(MotorId, _freq); @@ -409,7 +409,7 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); //call the module callback if (MotorCallback[MotorId]) @@ -436,7 +436,7 @@ uint32_t MotorSetSpeedCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TO MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); //call the module callback if (MotorCallback[MotorId]) @@ -483,7 +483,7 @@ uint32_t MotorMoveToLimitSwitchCallBackFunction(uint32_t IfIndex, uint32_t Limit } //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DH_LID) { if (CloseMagnet == true) @@ -542,7 +542,7 @@ uint32_t MotorMovetoLimitSwitch (TimerMotors_t MotorId,bool direction, uint32_t MotorSetDirection( MotorId, direction); MotorSetSpeed(MotorId, Freq); - MotorControlId[MotorId] = AddControlCallback( MotorMoveToLimitSwitchCallBackFunction, MotorTimeLag[MotorId] , FPGA_Read_limit_Switches,(IfTypeMotors*0x100+MotorId), LimitSwitchId, 0 ); + MotorControlId[MotorId] = AddControlCallback("MoveToLimitSwitch", MotorMoveToLimitSwitchCallBackFunction, MotorTimeLag[MotorId] , FPGA_Read_limit_Switches,(IfTypeMotors*0x100+MotorId), LimitSwitchId, 0 ); if ( MotorControlId[MotorId] == 0xFF) return ERROR; MotorCallback[MotorId] = callback; @@ -575,7 +575,7 @@ uint32_t MotorMoveToBreakSensorCallBackFunction(uint32_t IfIndex, uint32_t Limit MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); //call the module callback if (MotorCallback[MotorId]) @@ -601,7 +601,7 @@ uint32_t MotorMovetoBreakSensor (TimerMotors_t MotorId,bool direction, uint32_t MotorSetDirection( MotorId, direction); MotorSetSpeed(MotorId, Freq); - MotorControlId[MotorId] = AddControlCallback( MotorMoveToBreakSensorCallBackFunction, eOneMillisecond , ReadBreakSensor,(IfTypeMotors*0x100+MotorId), 0, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveToBreakSensorCallBackFunction, eOneMillisecond , ReadBreakSensor,(IfTypeMotors*0x100+MotorId), 0, 0 ); if ( MotorControlId[MotorId] == 0xFF) return ERROR; MotorCallback[MotorId] = callback; @@ -646,7 +646,7 @@ uint32_t MotorMoveToDancerPositionCallBackFunction(uint32_t IfIndex, uint32_t Re MotorStop(MotorId,Hard_Hiz); //TODO in run time limit switch just reverse direction //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); //call the module callback if (MotorCallback[MotorId]) @@ -669,7 +669,7 @@ uint32_t MotorMovetoDancerPosition (TimerMotors_t MotorId,bool direction, uint32 DancerId = dancerid; MotorSetDirection( MotorId, direction); MotorSetSpeed(MotorId, Freq); - MotorControlId[MotorId] = AddControlCallback( MotorMoveToDancerPositionCallBackFunction, eTenMillisecond , Control_Read_Dancer_Position,(IfTypeMotors*0x100+MotorId), DancerId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveToDancerPositionCallBackFunction, eTenMillisecond , Control_Read_Dancer_Position,(IfTypeMotors*0x100+MotorId), DancerId, 0 ); if ( MotorControlId[MotorId] == 0xFF) return ERROR; MotorCallback[MotorId] = callback; diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index 66be6a21a..06e5b4b0d 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -371,7 +371,7 @@ uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callb Valve3WayModuleCallback[_ValveId] = callback; - Valve3WayControlId[_ValveId] = AddControlCallback( Valve3WayCallBackFunction, eOneSecond/*eHundredMillisecond*/, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); + Valve3WayControlId[_ValveId] = AddControlCallback("Valve3WayControlId", Valve3WayCallBackFunction, eOneSecond/*eHundredMillisecond*/, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); if (Valve3WayControlId[_ValveId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)Valve3WayControlId[_ValveId],0); //else diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 4d70067e9..8cdb27e47 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -102,6 +102,12 @@ FPGALoad.stackSize = 4096; FPGALoad.priority = 5; Program.global.FPGALoad = Task.create("&FPGALoadTask", FPGALoad); +var I2C_Reading = new Task.Params(); +I2C_Reading.instance.name = "I2C_Reading"; +I2C_Reading.stackSize = 2048; +I2C_Reading.priority = 3; +Program.global.I2C_Reading = Task.create("&I2C_ReadingTask", I2C_Reading); + var ControlTaskParams = new Task.Params(); ControlTaskParams.instance.name = "control"; ControlTaskParams.stackSize = 2048; diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index c7a3a5e22..daaf922cf 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -54,6 +54,8 @@ #include "drivers/Heater/TemperatureSensor.h" #include "drivers/Flash_ram/FlashProgram.h" +#include "drivers/Valves/Valve.h" + Task_Handle AlarmHandling_Task_Handle; Mailbox_Handle AlarmHandlingMsgQ = NULL; @@ -213,22 +215,31 @@ 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_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__FluidLevelAlarm,0,0,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_1_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_2_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_3_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_4_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_5_LOW_LEVEL}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_6_LOW_LEVEL}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_7_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_8_LOW_LEVEL}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_1_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_2_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_3_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_4_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_5_EMPTY}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_6_EMPTY}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_EMPTY}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_8_EMPTY}, + + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_1_OVERFLOW}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_2_OVERFLOW}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_3_OVERFLOW}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_4_OVERFLOW}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_5_OVERFLOW}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_6_OVERFLOW}, + //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_OVERFLOW}, + {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_8_OVERFLOW}, {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 }, @@ -519,6 +530,7 @@ void AlarmHandlingSetCurrentLimits(double currentalarmhighlimit,double curre { CurrentAlarmHighLimit = currentalarmhighlimit; CurrentAlarmLowLimit = currentalarmlowlimit; + ReportWithPackageFilter(AlarmFilter,"Alarm Current Limits", __FILE__,__LINE__,(int)(currentalarmhighlimit*100), RpMessage, (int)(currentalarmlowlimit*100), 0); } void AlarmHandlingSetFlags(bool checkHardLimitAlarms,bool checkCurrentAlarms, bool checkTamperAlarms, bool checkMotorAlarms) @@ -604,6 +616,18 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever IDS_Dispenser_Alarm_On (AlarmItem[AlarmId].ModuleDeviceId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1); } } + break; + case ALARM_SOURCE_TYPE__FluidLevelAlarm: + if (Severity == DEBUG_LOG_CATEGORY__Error) + { + ReportWithPackageFilter(AlarmFilter,"fluid level alarm", __FILE__,AlarmItem[AlarmId].ModuleDeviceId,AlarmId, RpMessage, AlarmItem[AlarmId].AlarmSource, 0); + if (AlarmItem[AlarmId].EventType >= EVENT_TYPE__MID_TANK_1_OVERFLOW) + { + Valve_Set(IDS_Id_to_AirValve[AlarmItem[AlarmId].DeviceId], AlarmItem[AlarmId].DeviceId ); //AlarmItem[AlarmId].DeviceId/ON + Valve_Set(IDS_Id_to_CartrideValve[AlarmItem[AlarmId].DeviceId], AlarmItem[AlarmId].DeviceId ); //Atm_MidTank_OFF/ON + } + } + break; default: break; @@ -634,8 +658,8 @@ uint32_t AlarmHandlingConsequentActions(uint32_t AlarmId, DebugLogCategory Sever { JobEndReason = getEndReason(AlarmId); AbortJob(AlarmReasonStr); - //Report(AlarmReasonStr, __FILE__,__LINE__,AlarmId, RpMessage, DEBUG_LOG_CATEGORY__Error, 0); - ReportWithPackageFilter(AlarmFilter,AlarmReasonStr, __FILE__,__LINE__,AlarmId, RpMessage, DEBUG_LOG_CATEGORY__Error, 0); + //Report(AlarmReasonStr, __FILE__,__LINE__,AlarmId, RpMessage, Severity, 0); + ReportWithPackageFilter(AlarmFilter,AlarmReasonStr, __FILE__,__LINE__,AlarmId, RpMessage, Severity, 0); } /*switch (AlarmItem[AlarmId].AlarmSource) { @@ -752,19 +776,27 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) if (AlarmState[Alarm_i].Status == true) { status = JOB_TAMPER_ALARM; + ReportWithPackageFilter(AlarmFilter,"tamper alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0); AlarmId = Alarm_i; break; } } - /*if (AlarmItem[Alarm_i].AlarmSource == ALARM_SOURCE_TYPE__FluidLevelAlarm) + if (AlarmItem[Alarm_i].AlarmSource == ALARM_SOURCE_TYPE__FluidLevelAlarm) { if (AlarmState[Alarm_i].Status == true) { - status = ERROR; - AlarmId = Alarm_i; - break; + if (AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Error) + { + if (DispenserUsedInJob[AlarmItem[Alarm_i].DeviceId] == true) + { + status = ERROR; + ReportWithPackageFilter(AlarmFilter,"fluid level alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0); + AlarmId = Alarm_i; + break; + } + } } - }*/ + } if (AlarmItem[Alarm_i].AlarmSource == ALARM_SOURCE_TYPE__MotorAlarm) { if (AlarmState[Alarm_i].Status == true) @@ -772,6 +804,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) if(AlarmItem[Alarm_i].Severity>=DEBUG_LOG_CATEGORY__Error) { status = JOB_MOTOR_ALARM; + ReportWithPackageFilter(AlarmFilter,"motor alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0); AlarmId = Alarm_i; break; } @@ -795,6 +828,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) { status = JOB_TEMPERATURE_ALARM; AlarmId = Alarm_i; + ReportWithPackageFilter(AlarmFilter,"temperature alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0); break; } } @@ -804,6 +838,7 @@ JobEndReasonEnum AlarmHandlingPrepareJob(void *CurrentJob) { status = JOB_TEMPERATURE_ALARM; AlarmId = Alarm_i; + ReportWithPackageFilter(AlarmFilter,"temperature alarm preventing job", __FILE__,__LINE__,AlarmItem[Alarm_i].EventType, AlarmItem[Alarm_i].Severity, AlarmItem[Alarm_i].DeviceId, 0); break; } } @@ -874,6 +909,13 @@ void AlarmHandlingInternalSetAlarm(uint32_t AlarmId, bool value) AlarmState[Alarm_i].Status = value; } ReportWithPackageFilter(AlarmFilter,"Alarm ON ", __FILE__,AlarmState[Alarm_i].EventPtr,AlarmItem[Alarm_i].EventType, RpMessage, value, Alarm_i); + if ((AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Critical)&&(JobIsActive())) + { + JobEndReason = getEndReason(Alarm_i); + SendJobProgress(0.0,0, false, "Critical alarm!!!!"); + AbortJob("Critical alarm"); + ReportWithPackageFilter(AlarmFilter, AlarmReasonStr,__FILE__,__LINE__,Alarm_i,RpError, 0,0); + } } else { @@ -900,7 +942,7 @@ uint32_t AlarmHandlingStart(void) if ( AlarmHandlingActive == false) { AlarmHandlingActive = true; - AlarmHandlingControlId = AddControlCallback(AlarmHandling_ControlTrigger,eTenMillisecond,TemplateDataReadCBFunction,0,0,0); + AlarmHandlingControlId = AddControlCallback("Alarm Handling",AlarmHandling_ControlTrigger,eTenMillisecond,TemplateDataReadCBFunction,0,0,0); } return OK; } @@ -930,6 +972,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) uint32_t drawer_small2; uint32_t drawer_small3; + double doubleValue = 0.0; + @@ -1027,20 +1071,22 @@ uint32_t AlarmHandlingLoop(uint32_t tick) case ALARM_SOURCE_TYPE__CurrentAlarm: if (CheckCurrentAlarms) { - if (Get_Heaters_Current_Integer(AlarmItem[Alarm_i].DeviceId, &value) == OK) + if (Get_Heaters_Current_float(AlarmItem[Alarm_i].DeviceId, &doubleValue) == OK) { if (AlarmItem[Alarm_i].AlarmDirection == true) { - if ((value >= (AlarmItem[Alarm_i].AlarmValue*CurrentAlarmHighLimit)) || (value <= (AlarmItem[Alarm_i].AlarmValue*CurrentAlarmLowLimit))) + if ((doubleValue >= (AlarmItem[Alarm_i].AlarmValue*CurrentAlarmHighLimit)) || (doubleValue <= (AlarmItem[Alarm_i].AlarmValue*CurrentAlarmLowLimit))) { Status = true; + //ReportWithPackageFilter(AlarmFilter,"OverCurrent Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,AlarmItem[Alarm_i].EventType, RpMessage, (int)doubleValue, 0); } } else { - if (value == 0) + if (doubleValue <= 0.1) { Status = true; + //ReportWithPackageFilter(AlarmFilter,"llop break Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,AlarmItem[Alarm_i].EventType, RpMessage, (int)doubleValue, 0); } } @@ -1084,7 +1130,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) FluidLevelWarning = AlarmItem[Alarm_i].AlarmValue; else if (AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Error) FluidLevelError = AlarmItem[Alarm_i].AlarmValue; - value = Get_MidTank_Int100_Sensor(AlarmItem[Alarm_i].DeviceId); + value = Get_MidTank_Int1000_Sensor(AlarmItem[Alarm_i].DeviceId); if (AlarmItem[Alarm_i].AlarmDirection == OVER_VALUE) { if (value > AlarmItem[Alarm_i].AlarmValue) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c index 881034e40..9dcb3affb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/DriverWithCallbackExample.c @@ -26,7 +26,7 @@ uint32_t DriverActionWithCallback (uint32_t deviceId, uint32_t parameter, callba ModuleCallback = callback; //start control: - uint32_t ControlId = AddControlCallback( callback, eOneMillisecond, NULL, (IfTypeNone*0x100+deviceId),deviceId, parameter ); + uint32_t ControlId = AddControlCallback(NULL, callback, eOneMillisecond, NULL, (IfTypeNone*0x100+deviceId),deviceId, parameter ); return ControlId; } @@ -38,7 +38,7 @@ uint32_t ControlCallBackFunction(uint32_t deviceId, uint32_t ReadValue) //stop this control loop RemoveControlCallback(deviceId, ControlCallBackFunction ); //possibly: start regular control (speed etc) - //uint32_t ControlId = AddControlCallback(ControlCBFunction Callback, eOneMillisecond, NULL, deviceId, Parameter ); + //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, NULL, deviceId, Parameter ); //call the module callback ModuleCallback(deviceId,ReadValue); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 53ddda9f9..7e5020336 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -38,6 +38,7 @@ #include #include "drivers/Valves/Valve.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" +#include "Drivers/I2C_Communication/I2C.h" #include "modules/thread/thread_ex.h" #include "modules/ids/ids_ex.h" @@ -557,7 +558,6 @@ uint32_t MillisecLowLoop(uint32_t tick) for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) { CalculateDispenserPressure(Disp_i); - //Read_MidTank_Pressure_Sensor(Disp_i); } ADC_TriggerCollection(); } @@ -576,13 +576,13 @@ uint32_t MillisecLowLoop(uint32_t tick) for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) { CalculateDispenserPressure(Disp_i); - //Read_MidTank_Pressure_Sensor(Disp_i); } } FPGA_GetAllDispensersValveBusyOCD(); temp = Read_Fans_Tacho(); DrawerFansStatus = temp & 0x1F; SystemFansStatus = temp & 0xE0; + MachineUpdateResponseFunc(); //KeepAliveOneSecondCall(); for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) { @@ -593,24 +593,25 @@ uint32_t MillisecLowLoop(uint32_t tick) } if (!(OneMinute_Tick)) { - for (Heater_i = 0;Heater_i < NUM_OF_CURRENT_HEATERS;Heater_i++) + Trigger_Heater_Current_Read(); + /*for (Heater_i = 0;Heater_i < NUM_OF_CURRENT_HEATERS;Heater_i++) { - //Read_Heaters_Current(Heater_i); - } + Read_Heaters_Current(Heater_i); + }*/ } for (Sensor_i = 0;Sensor_i < MAX_TEMPERATURE_SENSOR_ID;Sensor_i++) { TemperatureCalc[Sensor_i] = MillisecCalculateTemperatures ( Sensor_i); } - MachineUpdateResponseFunc(); } if (OneMinute_Tick) { - for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) + Trigger_MidTank_Pressure_Read(); + /*for (Disp_i = 0;Disp_i < MAX_SYSTEM_DISPENSERS;Disp_i++) { Read_MidTank_Pressure_Sensor(Disp_i); - } - //MachineUpdateResponseFunc(); + }*/ +// MachineUpdateResponseFunc(); /* for (Motor_i = 0;Motor_i < NUM_OF_MOTORS;Motor_i++) { if (Motor_i == HARDWARE_MOTOR_TYPE__MOTO_SCREW) diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 80afb7ac6..b7d117efe 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -71,6 +71,7 @@ typedef struct DataReadCBFunction ControlDataReadPtr; ControlCBFunction ControlCallbackPtr; uint32_t ControlTiming; + char *Name; }ControlDeviceStruc; typedef enum @@ -132,6 +133,7 @@ void ControlInit(void) ControlArray[Device_i].ControlCallbackPtr = NULL; ControlArray[Device_i].ControlDataReadPtr = NULL; ControlArray[Device_i].ControlTiming = eNoControl; + ControlArray[Device_i].Name = NULL; } gateControlDB = GateMutex_create(NULL, &eb); if (gateControlDB == NULL) @@ -166,7 +168,10 @@ uint32_t ControlActivityLed( uint32_t Parameter1) COMM_RED_LED_ON; ACTIVITY_RED_LED_OFF; // Heaters indication - all the Heaters OFF if(FPGA_WD_Occurred == true) + { ACTIVITY_GREEN_LED_ON; + HWConfigurationInit(); + } if(power.color == fastBILNK) Pannel_Leds(POWER_ON_OFF,MODE_OFF); @@ -298,7 +303,7 @@ void ControlStart(void) TimerEnable(Control_timerBase, TIMER_A); ADCAcquireStart(0,1); - AddControlCallback( ControlEmptyCBFunction, eHundredMillisecond, ControlActivityLed,0, 0, 0 ); + AddControlCallback("ControlActivityLed", ControlEmptyCBFunction, eHundredMillisecond, ControlActivityLed,0, 0, 0 ); SysCtlDelay(12000000); MillisecStart(); @@ -313,7 +318,7 @@ void ControlStart(void) * both these callbacks can be removed. if a new call is arriving, it invalidates the previous one (no dual control or data) * ***************************************************************************************************************************************************/ -uint32_t AddControlCallback( ControlCBFunction Callback, uint32_t CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ) +uint32_t AddControlCallback(char* Name, ControlCBFunction Callback, uint32_t CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ) { assert(Callback); assert(DriverfPtr); @@ -364,6 +369,7 @@ uint32_t AddControlCallback( ControlCBFunction Callback, uint32_t CtrlFrequency ControlArray[deviceId].Parameter1 = Parameter1; ControlArray[deviceId].IfIndex = IfIndex; ControlArray[deviceId].StartTick = millisecondCounter; + ControlArray[deviceId].Name = Name; GateMutex_leave(gateControlDB, key); //LOG_ERROR(deviceId, "Add Callback"); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.h b/Software/Embedded_SW/Embedded/Modules/Control/control.h index 450646a68..4b82aab30 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.h +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.h @@ -38,7 +38,7 @@ typedef enum void ControlInit(void); void ControlStop(void); void ControlStart(void); -uint32_t AddControlCallback( ControlCBFunction Callback, uint32_t CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); +uint32_t AddControlCallback(char *Name, ControlCBFunction Callback, uint32_t CtrlFrequency, DataReadCBFunction DriverfPtr, uint16_t IfIndex, uint32_t Parameter1, uint32_t Parameter2 ); int RemoveControlCallback(uint32_t deviceId, ControlCBFunction Callback ); //The safe remove command can be used ONLY when called from the control callback itself int SafeRemoveControlCallback(uint32_t deviceId , ControlCBFunction Callback); diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c index 4597efa93..9a81854e6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c @@ -271,6 +271,12 @@ uint32_t SetDigitalOutRequestRequestFunc(MessageContainer* requestContainer) case INTERFACE_IOS__GPO_TFEED_BREAK_1: Pumps_Control(WASTECH_PUMP2, request->value); break; + case INTERFACE_IOS__GPO_BUZZER: + if (request->value == true) + Buzzer(MODE_ON);//use START or STOP, 0 - 100%(); + else + Buzzer(MODE_OFF);//use START or STOP, 0 - 100%(); + break; default: responseContainer.has_error = true; responseContainer.error = ERROR_CODE__GENERAL_ERROR; diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 6db76e842..d4e1636a5 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -63,7 +63,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); +uint32_t Diagnostics_OneMinControlTrigger(uint32_t IfIndex, uint32_t ReadValue); DiagnosticsMonitors DiagnosticsMonitor = DIAGNOSTICS_MONITORS__INIT; @@ -100,12 +100,16 @@ double dryerzone3temperature[DIAGNOSTICS_LIMIT+1]; double dispensermotorfrequency[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT+1]; double dispenserspressure[MAX_SYSTEM_DISPENSERS][DIAGNOSTICS_LIMIT+1]; +double dispenserinklevel[MAX_SYSTEM_DISPENSERS][1]; +double midtankinklevel[MAX_SYSTEM_DISPENSERS][1]; double MidTankpressure[MAX_SYSTEM_DISPENSERS][1]; double HeatersCurrent[NUM_OF_CURRENT_HEATERS][1]; double VOC_Sensor; DoubleArray DispenserFreq[MAX_SYSTEM_DISPENSERS]; DoubleArray DiagnosticsDispenserPressure[MAX_SYSTEM_DISPENSERS]; +DoubleArray DispenserInkLevel[MAX_SYSTEM_DISPENSERS]; +DoubleArray DiagnosticsMidTankInkLevel[MAX_SYSTEM_DISPENSERS]; HeaterState **heatersstates; HeaterState HeaterInfo[HEATER_TYPE__MixerHeater+1]; @@ -136,6 +140,7 @@ typedef enum DiagnosticsTrigger, DiagnosticsTenMiliTrigger, DiagnosticsOneSecTrigger, + DiagnosticsOneMinuteTrigger }DiagnosticsMessages; typedef struct DiagnosticsMessage{ @@ -164,14 +169,16 @@ void DiagnosticsInit(void) DiagnosticsMsgQ = Mailbox_create(sizeof(DiagnosticsMessageStruc), 40, NULL,&eb); - DiagnosticsMonitor.dispensersmotorsfrequency = (DoubleArray**)my_malloc(sizeof(DoubleArray *)*8); - DiagnosticsMonitor.dispenserspressure = (DoubleArray**)my_malloc(sizeof(DoubleArray)*8); - DiagnosticsMonitor.dispenserslinearpositions = (DoubleArray**)my_malloc(sizeof(DoubleArray)*8); - DiagnosticsMonitor.dispensersangularencoders = (DoubleArray**)my_malloc(sizeof(DoubleArray)*8); + DiagnosticsMonitor.dispensersmotorsfrequency = (DoubleArray**)my_malloc(sizeof(DoubleArray *)*MAX_SYSTEM_DISPENSERS); + DiagnosticsMonitor.dispenserspressure = (DoubleArray**)my_malloc(sizeof(DoubleArray)*MAX_SYSTEM_DISPENSERS); + DiagnosticsMonitor.midtanksinklevel = (DoubleArray**)my_malloc(sizeof(DoubleArray)*MAX_SYSTEM_DISPENSERS); + DiagnosticsMonitor.dispensersinklevel = (DoubleArray**)my_malloc(sizeof(DoubleArray)*MAX_SYSTEM_DISPENSERS); for (i = 0; i= Diagnostic_Extended_Mode) @@ -448,13 +551,7 @@ void Diagnostic100msecCollection(void) MidTankpressure[i][0] = 1.00-(IDS_Dispenser_Data[i].consumedinnanolitter/5800000); } */ - if (DiagnosticMode == Diagnostic_Extreme_Mode) - { - for (i=0;i= Diagnostic_Extreme_Mode) + DiagnosticTenMsecCollection(); break; case DiagnosticsOneSecTrigger: DiagnosticOneSecCollection(); break; + case DiagnosticsOneMinuteTrigger: + DiagnosticOneMinuteCollection(); + break; default: break; } diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 14c083b4d..497556878 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -27,6 +27,7 @@ #include "drivers/Motors/Motor.h" #include "drivers/Valves/Valve.h" #include "Drivers/I2C_Communication/DAC/blower.h" +#include "drivers/Flash_ram/MCU_E2Prom.h" #include "ids/ids_ex.h" #include "General/process.h" @@ -57,7 +58,7 @@ return OK; uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { uint32_t numberOfSteps = 0; - uint32_t LoadArmRounds = (int)dryerbufferlength; + uint32_t LoadArmRounds = 0; MessageContainer responseContainer; @@ -66,6 +67,12 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) MotorHomingResponse response = MOTOR_HOMING_RESPONSE__INIT; TimerMotors_t MotorId = (TimerMotors_t)request->motortype; + + if (dryerbufferlength) + LoadArmRounds = (int)dryerbufferlength; + else + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmRounds); + if (LoadArmRounds <= 2) LoadArmRounds = 20; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 58d1e1c37..dcbd6b9b0 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -214,7 +214,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->generalparameters[7] = AutoHoming_JobEnd_PowerOn_off; // } EmbeddedParameters->has_currentalarmlowlimit = true; - EmbeddedParameters->currentalarmlowlimit = 0.80; + EmbeddedParameters->currentalarmlowlimit = 0.77; EmbeddedParameters->has_currentalarmhighlimit = true; EmbeddedParameters->currentalarmhighlimit= 1.07; EmbeddedParameters->has_ids_segmentrefilltimeout = true; @@ -485,7 +485,7 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) Enable_MidTank_Pressure_Reading(Dispenser_i); Valve_Set(IDS_Id_to_AirValve[Dispenser_i], Atm_MidTank_ON ); //Atm_MidTank_OFF/ON } - GenHWControlId = AddControlCallback( GenHWInitCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + GenHWControlId = AddControlCallback(NULL, GenHWInitCallBackFunction, 2* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); */ ControlStart(); AlarmHandlingStart(); diff --git a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c index ff4909438..4958139e6 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c +++ b/Software/Embedded_SW/Embedded/Modules/General/MachineStatus.c @@ -68,7 +68,7 @@ int MachineUpdateResponseFunc(void) double dispcapacity = (1.00-(IDS_Dispenser_Data[i].consumedinnanolitter/5800000))*130*1000*1000; IDS_Level[i].dispenserlevel = (int32_t)dispcapacity; IDS_Level[i].has_midtanklevel = true; - IDS_Level[i].midtanklevel = Get_MidTank_Int100_Sensor(i); + IDS_Level[i].midtanklevel = Get_MidTank_Int1000_Sensor(i); MachineStatus.idspackslevels[MachineStatus.n_idspackslevels] = &IDS_Level[i]; MachineStatus.n_idspackslevels++; } diff --git a/Software/Embedded_SW/Embedded/Modules/General/Safety.c b/Software/Embedded_SW/Embedded/Modules/General/Safety.c index a5a586e07..6a0b9a67b 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/Safety.c +++ b/Software/Embedded_SW/Embedded/Modules/General/Safety.c @@ -33,7 +33,7 @@ bool AirFilterAlarmState = false; bool WasteOverflowAlarmState = false; void Safety_Init(void) { - SafetyControlId = AddControlCallback( Safety_Main_State, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + SafetyControlId = AddControlCallback("Safety", Safety_Main_State, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); //return; } uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) @@ -110,6 +110,10 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) //report dispenser over pressure AlarmHandlingSetAlarm(EVENT_TYPE__DISPENSER_1_OVERPRESSURE+Disp_i, true); DispenserAlarm[Disp_i] = EVENT_TYPE__DISPENSER_1_OVERPRESSURE+Disp_i; + if (DispenserAlarm[Disp_i] == false) + { + IDS_Dispenser_Alarm_On(Disp_i); + } DispenserOverPressure[Disp_i] = true; Report("Dispenser Safety - over pressure", __FILE__,__LINE__,Disp_i, RpFatalError, (int)(1000*GetDispenserPressure(Disp_i)), 0); } @@ -117,6 +121,10 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) { AlarmHandlingSetAlarm(EVENT_TYPE__DISPENSER_1_UPPER_HARD_LIMIT+Disp_i, true); DispenserAlarm[Disp_i] = EVENT_TYPE__DISPENSER_1_UPPER_HARD_LIMIT+Disp_i; + if (DispenserAlarm[Disp_i] == false) + { + IDS_Dispenser_Alarm_On(Disp_i); + } DispenserOverPressure[Disp_i] = true; Report("Dispenser upper hard limit", __FILE__,__LINE__,Disp_i, RpFatalError, Get_Notification_Disp_UP(Disp_i), 0); } @@ -124,12 +132,16 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) { AlarmHandlingSetAlarm(EVENT_TYPE__DISPENSER_1_LOWER_HARD_LIMIT+Disp_i, true); DispenserAlarm[Disp_i] = EVENT_TYPE__DISPENSER_1_LOWER_HARD_LIMIT+Disp_i; + if (DispenserAlarm[Disp_i] == false) + { + IDS_Dispenser_Alarm_On(Disp_i); + } DispenserOverPressure[Disp_i] = true; Report("Dispenser lower hard limit", __FILE__,__LINE__,Disp_i, RpFatalError, Get_Notification_Disp_Down(Disp_i), 0); } else { - Report("Dispenser unknown safety alarm", __FILE__,__LINE__,Disp_i, RpFatalError, 1-DispenserBypass, 0); + Report("Dispenser unknown safety alarm", __FILE__,__LINE__,Disp_i, RpFatalError,Get_Notification_Disp_Full(Disp_i), 0); } } @@ -144,8 +156,11 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) { if (Check_Disp_Safety_Stop_Indication(Disp_i) == false) { - //report dispenser over pressure AlarmHandlingSetAlarm(DispenserAlarm[Disp_i], false); + if (DispenserAlarm[Disp_i] == true) + { + IDS_Dispenser_Alarm_Off(Disp_i); + } DispenserAlarm[Disp_i] = 0; DispenserOverPressure[Disp_i] = false; } diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index d5ed5cef9..0a5cfc2f3 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -210,7 +210,7 @@ uint32_t Buttons_Init(void) power.state = sttON; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING power.count = 0; - AddControlCallback( ButtonPowerCBFunction, BUTTONS_SAMPLE_TIME, ButtonPowerCallBackFunction, 0,0,0 ); // eFiftyMillisecond + AddControlCallback("ButtonPowerCB", ButtonPowerCBFunction, BUTTONS_SAMPLE_TIME, ButtonPowerCallBackFunction, 0,0,0 ); // eFiftyMillisecond strcpy(jog.bttn_name, "jog"); jog.bttn_status = RELEASE; // 0=RELEASE 1=PRESS @@ -220,7 +220,7 @@ uint32_t Buttons_Init(void) jog.state = sttENABLE; // sttDISABLE, sttENABLE, sttJOGGING jog.count = 0; - AddControlCallback( ButtonJogCBFunction, BUTTONS_SAMPLE_TIME, ButtonJogCallBackFunction, 0,0,0 ); // + AddControlCallback("ButtonJogCB", ButtonJogCBFunction, BUTTONS_SAMPLE_TIME, ButtonJogCallBackFunction, 0,0,0 ); // strcpy(load.bttn_name, "load"); load.bttn_status = RELEASE; // 0=RELEASE 1=PRESS @@ -229,7 +229,7 @@ uint32_t Buttons_Init(void) load.state = sttRDY; // load.count = 0; - AddControlCallback( ButtonLoadCBFunction, BUTTONS_SAMPLE_TIME, ButtonLoadCallBackFunction, 0,0,0 ); // + AddControlCallback("ButtonLoadCB", ButtonLoadCBFunction, BUTTONS_SAMPLE_TIME, ButtonLoadCallBackFunction, 0,0,0 ); // return OK; } diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index 2eab5225d..a086fe898 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -276,7 +276,7 @@ void HeatersControlStart(void) { if (ControlIdtoInternalId [i] == 0xFF) { - ControlIdtoInternalId [i] = AddControlCallback( HeatersTestInternalAlarmsCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+i),0,0); + ControlIdtoInternalId [i] = AddControlCallback("Internal Heaters", HeatersTestInternalAlarmsCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+i),0,0); } } } @@ -535,7 +535,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) { if (ControlIdtoHeaterId [HeaterId] == 0xFF) { - ControlIdtoHeaterId [HeaterId] = AddControlCallback( HeaterControlCBFunction, Frequency/*eOneSecond*/,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),DryerInternalPT100Id,0); + ControlIdtoHeaterId [HeaterId] = AddControlCallback("HeatersControl", HeaterControlCBFunction, Frequency/*eOneSecond*/,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),DryerInternalPT100Id,0); //HeaterPreviousRead[HeaterId] = MillisecGetTemperatures(DryerInternalPT100Id); HeaterPreviousRead[HeaterId] = MillisecGetTemperatures(HeaterId2PT100Id[HeaterId]);// //ReportWithPackageFilter(HeatersFilter,"PrepareHeater AC Read", __FILE__,HeaterId, SetTemperatue, RpWarning,HeaterPreviousRead[HeaterId], 0); @@ -579,7 +579,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) AlarmHandlingSetAlarm(HeaterEventType[HeaterId], false); if (ControlIdtoMaxHeaterId [HeaterId] == 0xFF) - ControlIdtoMaxHeaterId [HeaterId] = AddControlCallback( DcHeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); + ControlIdtoMaxHeaterId [HeaterId] = AddControlCallback("HeatersMax", DcHeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); Enable_Reading_Heaters_Current(HeaterId2CurrentId[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain]); Enable_Reading_Heaters_Current(HeaterId2CurrentId[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary]); @@ -587,9 +587,9 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 0); HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary, 0); if (MainDryerHeaterMaxTempControl == 0xFF) - MainDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain],0); + MainDryerHeaterMaxTempControl = AddControlCallback("HeatersMax", HeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain],0); if (SecondDryerHeaterMaxTempControl == 0xFF) - SecondDryerHeaterMaxTempControl = AddControlCallback( HeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary],0); + SecondDryerHeaterMaxTempControl = AddControlCallback("HeatersMax", HeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary),HeaterId2PT100Id[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary],0); //InitialHeating = true; HeaterReady[HeaterId] = false; HeaterAtTemp[HeaterId] = false; @@ -616,7 +616,7 @@ void PrepareACHeater(int HeaterId,uint32_t Frequency, uint32_t SetTemperatue) int PrepareDCHeater(int HeaterId, uint32_t Frequency, uint32_t SetTemperatue) { if (DisasterControlId == 0xFF) - DisasterControlId = AddControlCallback( HeatersDisasterControl, eOneSecond,TemplateDataReadCBFunction,0,0, 0); + DisasterControlId = AddControlCallback("Heaters Disaster", HeatersDisasterControl, eOneSecond,TemplateDataReadCBFunction,0,0, 0); HeaterPreviousRead[HeaterId] = MillisecGetTemperatures(HeaterId2PT100Id[HeaterId]);//MillisecGetTemperatures(HeaterId2PT100Id[HeaterId]); if((HeaterPreviousRead[HeaterId]<=MINIMUM_HEATER_READ*100)||(MAXIMUM_HEATER_READ*100<=HeaterPreviousRead[HeaterId])) @@ -639,7 +639,7 @@ int PrepareDCHeater(int HeaterId, uint32_t Frequency, uint32_t SetTemperatue) return ERROR; } if (ControlIdtoHeaterId [HeaterId] == 0xFF) - ControlIdtoHeaterId [HeaterId] = AddControlCallback( DCHeaterControlCBFunction, Frequency/*eOneSecond*/,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); + ControlIdtoHeaterId [HeaterId] = AddControlCallback("DCHeatersControl", DCHeaterControlCBFunction, Frequency/*eOneSecond*/,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); //HeaterPIDConfig[HeaterId].m_params.dt *=10; //DCInitialHeating[HeaterId] = true; HeaterReady[HeaterId] = false; @@ -655,7 +655,7 @@ int PrepareDCHeater(int HeaterId, uint32_t Frequency, uint32_t SetTemperatue) //ReportWithPackageFilter(HeatersFilter,"PrepareHeater Read", __FILE__,HeaterId, SetTemperatue, RpWarning,HeaterPreviousRead[HeaterId], 0); if (ControlIdtoMaxHeaterId [HeaterId] == 0xFF) - ControlIdtoMaxHeaterId [HeaterId] = AddControlCallback( DcHeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); + ControlIdtoMaxHeaterId [HeaterId] = AddControlCallback("DcHeatersMax", DcHeaterMaxTempCBFunction, eOneSecond,MillisecGetTemperatures,(IfTypeHeaters*0x100+HeaterId),HeaterId2PT100Id[HeaterId],0); return OK; } @@ -697,7 +697,7 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) int band = 10; if (HeaterControl[HeaterId].outputproportionalband) { - band = HeaterControl[HeaterId].outputproportionalband+2; //sometimes the dryer heat drops after PID starts. + band = HeaterControl[HeaterId].outputproportionalband+2; //sometimes after PID is started the temp is falling a little bit. we want to avoid an alarm } temp = SetTemperatue*(100+band); //temp = SetTemperatue*110.0; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h index a919ce4e1..3e2cf6ecb 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h @@ -15,6 +15,7 @@ extern uint32_t DispenserPrepareTimeLag ; extern int32_t CurrentDispenserSpeed[MAX_SYSTEM_DISPENSERS]; extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS]; +extern bool JobStartStopBackLash[MAX_SYSTEM_DISPENSERS]; extern float DispenserPressure[MAX_SYSTEM_DISPENSERS]; uint32_t DispenserConfigMessage(HardwareDispenser * request); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index b9ab97714..9c15885fc 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -111,7 +111,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re { 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 ); + DispenserControlId[DispenserId] = AddControlCallback(NULL, 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); else @@ -156,7 +156,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re if (DispenserControlId[DispenserId] != 0xFF) 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 ); + DispenserControlId[DispenserId] = AddControlCallback(NULL, 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 @@ -207,7 +207,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee 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 ); + DispenserControlId[DispenserId] = AddControlCallback(NULL, IDS_Dispenser_OpenValveCallback, OpenValveTimeout, TemplateDataReadCBFunction,DispenserId, DispenserId, 0 ); if (DispenserControlId[DispenserId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); //else @@ -235,6 +235,12 @@ void IDS_Dispenser_Content_Init (void) HW_Motor_Id = DispenserIdToMotorId[i]; dispenser_running_data__init(&IDS_Dispenser_Data[i]); dispenserdata[i] = &IDS_Dispenser_Data[i]; + IDS_Dispenser_Data[i].has_consumedinnanolitter = true; + IDS_Dispenser_Data[i].has_direction = true; + IDS_Dispenser_Data[i].has_microsteps = true; + IDS_Dispenser_Data[i].has_nanolitterperpulse = true; + IDS_Dispenser_Data[i].has_numberofrefills = true; + IDS_Dispenser_Data[i].has_totalconsumedinnanolitter = true; IDS_Dispenser_Data[i].nanolitterperpulse = DEFAULT_NANOLITER_PER_PULSE; IDS_Dispenser_Data[i].microsteps = MotorsCfg[HW_Motor_Id].microstep; } diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c index 1302d262a..f3528d4c8 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -136,7 +136,7 @@ uint32_t IDS_HomeDispenserWaitForHomingEnd(uint32_t DispenserId, uint32_t timeo DispenserBacklashControlId[DispenserId] = 0xFF; //return ERROR; } - DispenserBacklashControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserWaitForHomingEnd,eOneSecond , TemplateDataReadCBFunction,DispenserId,0, 0 ); + DispenserBacklashControlId[DispenserId] = AddControlCallback(NULL, IDS_HomeDispenserWaitForHomingEnd,eOneSecond , TemplateDataReadCBFunction,DispenserId,0, 0 ); if ( DispenserBacklashControlId[DispenserId] == 0xFF) return ERROR; @@ -146,7 +146,7 @@ uint32_t IDS_HomeDispenserWaitForHomingEnd(uint32_t DispenserId, uint32_t timeo uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) { uint8_t DispenserId = motorId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1; - if ((GetDispenserPressure(DispenserId)>=InitialDispenserPressure)||(DispenserHomingTime[DispenserId]>InitialDispenserTimeout)) + if ((GetDispenserPressure(DispenserId)>=InitialDispenserPressure)||(DispenserHomingTime[DispenserId]>InitialDispenserTimeout)||(JobStartStopBackLash[DispenserId] == true)) { MotorStop(motorId,Hard_Hiz); CurrentDispenserSpeed[DispenserId] = 0; @@ -161,6 +161,8 @@ uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); Disable_MidTank_Pressure_Reading(DispenserId); + if (JobStartStopBackLash[DispenserId] == true) + JobStartStopBackLash[DispenserId] = false; Report("End backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); if (SafeRemoveControlCallback(DispenserHomingControlId[DispenserId], IDS_HomeDispenserBackMoveCallback )==OK) DispenserHomingControlId[DispenserId] = 0xFF; @@ -191,7 +193,7 @@ uint32_t IDS_HomeDispenserCallback(uint32_t motorId, uint32_t ReadValue) // HomingActive[DispenserId]= false; IDS_Dispenser_RefillEnded ( DispenserId, MotorsCfg[motorId].microstep); Report("Start backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - DispenserHomingControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); + DispenserHomingControlId[DispenserId] = AddControlCallback(NULL, IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); MotorSetDirection(motorId,MotorsCfg[motorId].directionthreadwize); Task_sleep(10); MotorSetSpeed(motorId, InitialDispenserSpeed); @@ -213,7 +215,7 @@ uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr } if (Get_MidTank_Pressure_Sensor(DispenserId)<0.2) { - Report("IDS_HomeDispenser - Midtank is empty",__FILE__,Get_MidTank_Int100_Sensor(DispenserId),(int)DispenserId,RpWarning,LIMIT,0); + Report("IDS_HomeDispenser - Midtank is empty",__FILE__,Get_MidTank_Int1000_Sensor(DispenserId),(int)DispenserId,RpWarning,LIMIT,0); return ERROR; } //if Safety is active @@ -363,7 +365,7 @@ uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) } // HomingActive[DispenserId]= false; Report("Start backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - DispenserHomingControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); + DispenserHomingControlId[DispenserId] = AddControlCallback("DispenserBackLash", IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); Task_sleep(10); MotorSetDirection(motorId,MotorsCfg[motorId].directionthreadwize); Task_sleep(10); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 791b3c47b..1bab2c65d 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -55,6 +55,7 @@ uint32_t IDS_Valve_DistanceToSpoolReady(uint32_t deviceID, uint32_t ReadValue); uint32_t IDS_Valve_PresegmentReady(uint32_t deviceID, uint32_t ReadValue); uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue); //bool IDS_isDispenserUsedNextSegment(void *JobDetails,int DispenserId, int SegmentId); +bool JobStartStopBackLash[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; /******************** GLOBAL PARAMETERS ********************************************/ DispenserControlConfig_t DispenserControlConfig[MAX_SYSTEM_DISPENSERS]; uint32_t ControlIdtoDispenserId [MAX_SYSTEM_DISPENSERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; @@ -549,6 +550,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { IDS_StopHomeDispenser(i); + JobStartStopBackLash[i] = true; NumOfActiveDispensers++; } else @@ -585,7 +587,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. } } DispenserBuildTimeCounter = 0; - DispenserPrepareControlId = AddControlCallback( IDS_Prepare_Callback, PRESSURE_READ_TIME_GAP,TemplateDataReadCBFunction ,0, 0, 0 ); + DispenserPrepareControlId = AddControlCallback(NULL, IDS_Prepare_Callback, PRESSURE_READ_TIME_GAP,TemplateDataReadCBFunction ,0, 0, 0 ); setRapidPressureRead(true); } @@ -978,7 +980,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) lInterSegmentLength = ((IntersegmentLength*100)*1000/dyeingspeed); lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication InterSegmentStepsCount = 0; - DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); + DispenserPreSegmentControlId = AddControlCallback(NULL,IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); if (DispenserPreSegmentControlId == 0xFF) { Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0); @@ -1256,7 +1258,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) JobBrushStopId++; if ((BrushStopTime)&&(SegmentNumOfBrushStops > 1)) { - BrushStopControlId = AddControlCallback( IDSBrushStopRestartCallback, BrushStopTime,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 ); + BrushStopControlId = AddControlCallback(NULL, IDSBrushStopRestartCallback, BrushStopTime,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 ); if (BrushStopControlId == 0xFF) { Report("Add control callback failed",__FILE__,__LINE__,(int)BrushStopTime,RpWarning,(int)0,0); @@ -1327,7 +1329,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) lInterSegmentLength = (dryerbufferCentimeters*1000/dyeingspeed); lInterSegmentLength-=(lInterSegmentLength%100); //round to a 100 multiplication InterSegmentStepsCount = 0; - DispenserPreSegmentControlId = AddControlCallback( IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); + DispenserPreSegmentControlId = AddControlCallback(NULL, IDSPreSegmentStateCallbackRunner, 100,TemplateDataReadCBFunction ,0, 0, 0 ); if (DispenserPreSegmentControlId == 0xFF) { Report("Add control callback failed",__FILE__,__LINE__,(int)100,RpWarning,(int)0,0); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 8f9628f20..79e4b202a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -16,8 +16,6 @@ #include "drivers/ADC_Sampling/adc.h" #include "Drivers/I2C_Communication/Head_Card/PT100/PT100_ADC.h" -#include "Drivers/I2C_Communication/Head_Card/Fan/fan_click.h" -#include "Drivers/I2C_Communication/Head_Card/Fan/Head_Fan.h" #include "drivers/Motors/Motor.h" #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "Modules/IFS/ifs.h" @@ -25,10 +23,6 @@ //#include "graphics_adapter.h" extern uint8_t Input_Voltage; extern uint8_t Test_Read_Buf[4]; - -extern uint8_t Head_Fan_PWM_1_Command; -extern uint16_t Head_Fan_Tach[2]; - void Stub_ProgressRequest(MessageContainer* requestContainer) { MessageContainer responseContainer; @@ -77,16 +71,6 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = Calculate_Pitot_Pressure(false); response.has_progress = true; - } - else - if((request->amount == 0xFAC) /*&& (request->delay == 0xFAC)*/) //measured sensor voltage without flow (orifice flow meter) - { - Head_Fan_PWM_1_Command = (request->delay & 0xFF) ; - Test_fan_Click(); - //response.progress = Fan_Click_Info.Product_ID; - response.progress = Head_Fan_Tach[0]; - response.has_progress = true; - } else if((request->amount == 0x0A) && ((request->delay >= 0) && (request->delay < 8))) //read the midtank calibration diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 5a1bb9063..50fad6503 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -29,6 +29,7 @@ #include "drivers/I2C_Communication/DAC/Blower.h" #include "drivers/SSI_Comm/Dancer/Dancer.h" #include "drivers/motors/motor.h" +#include "drivers/Flash_ram/MCU_E2Prom.h" #include "PMR/Stubs/StubHeatingTestRequest.pb-c.h" #include "PMR/Stubs/StubHeatingTestResponse.pb-c.h" @@ -78,7 +79,7 @@ uint32_t LoadArmBackLash; }LoadArmInfoStruc; LoadArmInfoStruc LoadArmInfo; - char LoadArmPath[50] = "0://SysInfo//LoadArm.cfg"; + //char LoadArmPath[50] = "0://SysInfo//LoadArm.cfg"; //RUN MOTOR TO SWITCH WITH TIMEOUT //RUN MOTOR TO BREAK SENSOR @@ -96,14 +97,21 @@ } uint32_t Thread_Load_Init(void) { - void* buffer = NULL; - uint32_t Bytes = 0; - FRESULT Fresult = FR_OK; + //void* buffer = NULL; + //uint32_t Bytes = 0; + //FRESULT Fresult = FR_OK; REPORT_MSG(LoadStages, "Thread Load State Machine step"); LoadArmInfo.LoadArmBackLash = 5; - LoadArmInfo.LoadArmRounds = 0xFF; - Fresult = f_mkdir(SW_INFO_DIR); + //LoadArmInfo.LoadArmRounds = 0xFF; + //EEPROM_STORAGE_DRYER_CYCLES + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); + if (LoadArmInfo.LoadArmRounds <= 2) + LoadArmInfo.LoadArmRounds = 20; + MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); + Report("MotorMovetoEncoderPosition",__FILE__,__LINE__,LoadArmInfo.LoadArmRounds,RpWarning,LoadArmInfo.LoadArmBackLash,0); + + /*Fresult = f_mkdir(SW_INFO_DIR); if ((Fresult == FR_OK)||(Fresult == FR_EXIST)) { @@ -114,9 +122,9 @@ memcpy (&LoadArmInfo,buffer,sizeof(LoadArmInfo)); free (buffer); } - } + }*/ - Report("Thread_Load_Init",__FILE__,__LINE__,LoadArmInfo.LoadArmBackLash,RpMessage,LoadArmInfo.LoadArmRounds,0); + Report("Thread_Load_Init",__FILE__,__LINE__,LoadArmInfo.LoadArmRounds,RpMessage,LoadArmInfo.LoadArmRounds,0); StopInitSequence(); memcpy (&ProcessParametersRecover,&ProcessParametersKeep,sizeof(ProcessParameters)); //NumberOfDrierLoaderCycles = loadLoadArmParameters(); @@ -175,6 +183,8 @@ { Report("Thread_Load_Set_Load_Arm_To_Start_Position_Callback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); //storeLoadArmParameters(); + MotorMove(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize,LoadArmInfo.LoadArmBackLash ); + SetMotHome(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM); //set this point as the spool home LoadStages++; ThreadLoadStateMachine(LoadStages); @@ -228,7 +238,7 @@ } else //number of circles is not known - compare to position of the motor to verify location at the stopper { - Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + Report("Thread_Load_Set_Load_Arm_To_Start_Position unknown cycles",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/2, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); @@ -251,6 +261,15 @@ { Report("Thread_Load_HomingCallback",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); // REPORT_MSG(MotorId, "Thread_Load_HomingCallback Motor Id"); + if ((LoadStages == THREAD_LOAD_CLOSE_ROCKERS)||(LoadStages == THREAD_LOAD_LIFT_ROCKERS)) + { + if((MotorId == HARDWARE_MOTOR_TYPE__MOTO_RLOADING)||(MotorId == HARDWARE_MOTOR_TYPE__MOTO_LLOADING)) + { + MotorSetMicroStep(MotorId, keepmicrostep); + MotorSetKvalRun(MotorId, keepkvalrun); + } + } + if (CallbackCounter) { CallbackCounter--; @@ -269,13 +288,6 @@ else { LoadStages++; - if (LoadStages == THREAD_LOAD_CLOSE_ROCKERS) - { - MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, keepmicrostep); - MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, keepmicrostep); - MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, keepkvalrun); - MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, keepkvalrun); - } if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -331,6 +343,10 @@ { keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + if (keepkvalrun>=25) + keepkvalrun = 25; + Report("Thread_Load_Lift_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0); + REPORT_MSG(LoadStages, "Thread Load State Machine step"); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8); MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 8); @@ -360,6 +376,17 @@ } uint32_t Thread_Load_Close_Rockers(void) { + keepmicrostep = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].microstep; + keepkvalrun = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].kvalrun; + if (keepkvalrun>=25) + keepkvalrun = 25; + Report("Thread_Load_Close_Rockers",__FILE__,__LINE__,keepkvalrun,RpMessage,keepmicrostep,0); + + MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 8); + MotorSetMicroStep(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 8); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_RLOADING, 70); + MotorSetKvalRun(HARDWARE_MOTOR_TYPE__MOTO_LLOADING, 70); + REPORT_MSG(LoadStages, "Thread Load State Machine step"); CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RLOADING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RLOADING].directionthreadwize, 250, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RLOADING], Thread_Load_HomingCallback,25000); @@ -464,15 +491,19 @@ uint32_t Thread_Load_Dryer_Loading(void) { REPORT_MSG(LoadStages, "Thread Load State Machine step"); - LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; - if (LoadArmInfo.LoadArmRounds <= 2) - LoadArmInfo.LoadArmRounds = 20; + + if (dryerbufferlength) + LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; + //if (LoadArmInfo.LoadArmRounds <= 2) + // LoadArmInfo.LoadArmRounds = 20; float numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 SetOriginMotorSpeed(19); // OriginalMotorSpd_2PPS[FEEDER_MOTOR] = 1000; // CurrentControlledSpeed[FEEDER_MOTOR] = 1000; + MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CYCLES,LoadArmInfo.LoadArmRounds); + numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmInfo.LoadArmRounds*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; numberOfSteps -= 100; //numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*3.3*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; @@ -498,7 +529,7 @@ MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius); - LoadingControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback(NULL,ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); Report("AddControlCallback feeder",__FILE__,__LINE__,LoadingControlId,RpMessage,IfTypeThread*0x100+FEEDER_MOTOR,0); CallbackCounter++; Report("Thread_Load_Dryer_Loading",__FILE__,__LINE__,LoadStages,RpMessage,CallbackCounter,0); @@ -507,7 +538,7 @@ //Keep Notation How Many Rotations In The Dryer //LoadArmInfo.LoadArmBackLash = 0; - LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; + //LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; //FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER); return OK; } @@ -526,7 +557,7 @@ { REPORT_MSG(LoadStages, "Thread Load State Machine step"); ThreadJoggingFunc(20); - LoadingControlId = AddControlCallback(Thread_Load_Jog_ThreadStop, eOneSecond*5,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); + LoadingControlId = AddControlCallback(NULL,Thread_Load_Jog_ThreadStop, eOneSecond*5,Control_Read_Dancer_Position,(IfTypeThread*0x100+FEEDER_MOTOR),FEEDER_DANCER,FEEDER_MOTOR); return OK; } uint32_t Thread_Load_End(void) @@ -592,7 +623,7 @@ MotorControlConfig[POOLER_MOTOR].m_SetParam = 0;//need to update SetParams on presegment stage MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_LDRIVING,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDRIVING].directionthreadwize); - PullerControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),POOLER_DANCER,POOLER_MOTOR); + PullerControlId = AddControlCallback(NULL,ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+POOLER_MOTOR),POOLER_DANCER,POOLER_MOTOR); Report("AddControlCallback Puller",__FILE__,__LINE__,PullerControlId,RpMessage,IfTypeThread*0x100+POOLER_MOTOR,0); //////////////////////// MotorControlConfig[WINDER_MOTOR].m_params.MAX = 1; @@ -614,7 +645,7 @@ MotorControlConfig[WINDER_MOTOR].m_SetParam = 0;//need to update SetParams on presegment stage MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_WINDER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_WINDER].directionthreadwize); - WinderControlId = AddControlCallback(ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+WINDER_MOTOR),WINDER_DANCER,WINDER_MOTOR); + WinderControlId = AddControlCallback(NULL,ThreadLoadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+WINDER_MOTOR),WINDER_DANCER,WINDER_MOTOR); Report("AddControlCallback Winder",__FILE__,__LINE__,WinderControlId,RpMessage,IfTypeThread*0x100+WINDER_MOTOR,0); //////////////////////// @@ -631,9 +662,9 @@ MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); //Keep Notation How Many Rotations In The Dryer - //LoadArmInfo.LoadArmBackLash = 0; + LoadArmInfo.LoadArmBackLash = 5; LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; - FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER); + //FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER); 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 9d57cd29f..a93387e0a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -547,7 +547,7 @@ uint32_t Winder_Presegment(void *SegmentDetails, uint32_t SegmentId) } if (SegmentId == 0) { - ScrewControlId = AddControlCallback(Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0); + ScrewControlId = AddControlCallback("screw control",Screw100msecDirectionChange, eHundredMillisecond,TemplateDataReadCBFunction,0,0,0); } PreSegmentReady(Module_Winder,ModuleDone); @@ -583,7 +583,7 @@ uint32_t WinderDistanceToSpoolState(void ) double DTS_Time = (dryerbufferCentimeters/dyeingspeed)*1000;//distance to spool time in milliseconds REPORT_MSG ((int)DTS_Time,"WinderDistanceToSpoolState"); - ScrewDTSControlId = AddControlCallback(ScrewDTSCallback, DTS_Time-WinderBackToBaseTime,TemplateDataReadCBFunction,0,0,0); + ScrewDTSControlId = AddControlCallback("screw DTS",ScrewDTSCallback, DTS_Time-WinderBackToBaseTime,TemplateDataReadCBFunction,0,0,0); REPORT_MSG ((int)msec_millisecondCounter,"ScrewDTSCallback start"); return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 8c42735cb..416b53494 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -148,12 +148,13 @@ char DancerConfigPath[50] = "0://SysInfo//DancCfg.cfg"; uint32_t StoreDancerConfigMessage() { - FRESULT Fresult = FR_OK; - HardwareConfiguration DancerConfig; - HardwareDancer Dancers[MAX_SYSTEM_DANCERS]; - uint8_t* response_buffer; - size_t response_size = 0; - int Dancer_i; + uint32_t status = OK; + /* FRESULT Fresult = FR_OK; + // HardwareConfiguration DancerConfig; + // HardwareDancer Dancers[MAX_SYSTEM_DANCERS]; + // uint8_t* response_buffer; + // size_t response_size = 0; + // int Dancer_i; hardware_configuration__init(&DancerConfig); DancerConfig.dancers = (HardwareDancer**)my_malloc(sizeof(HardwareDancer*)*MAX_SYSTEM_DANCERS); @@ -168,11 +169,12 @@ uint32_t StoreDancerConfigMessage() DancerConfig.n_dancers++; DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint; } - MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); - MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); - MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); + */ + status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); + status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); + status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); Report("Store eeprom 0",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg[1].zeropoint,RpWarning,(int)DancersCfg[2].zeropoint,0); - +/* response_buffer = my_malloc(hardware_configuration__get_packed_size(&DancerConfig)); if (response_buffer) { @@ -187,43 +189,23 @@ uint32_t StoreDancerConfigMessage() my_free(response_buffer); - - return Fresult; +*/ + return status; } uint32_t LoadDancerConfigMessage() { - void* buffer = NULL; - uint32_t Bytes = 0; - FRESULT Fresult = FR_OK; - - HardwareConfiguration *DancerConfig; - int Dancer_i; - HardwareDancer DancersCfg1[MAX_SYSTEM_DANCERS] = {0}; - HardwareDancer DancersCfg2[MAX_SYSTEM_DANCERS] = {0}; + uint32_t status = OK; - memcpy(DancersCfg1,(void *)DANCERS_MAP_IN_FLASH,sizeof(DancersCfg1)); - - Fresult = FileRead(DancerConfigPath, &Bytes, &buffer); - if (Fresult == FR_OK) - { - DancerConfig = hardware_configuration__unpack(NULL, Bytes, buffer); - for (Dancer_i = 0; Dancer_i < DancerConfig->n_dancers ; Dancer_i++) - { - DancersCfg2[Dancer_i].zeropoint = DancerConfig->dancers[Dancer_i]->zeropoint; - } - hardware_configuration__free_unpacked(DancerConfig,NULL); - free (buffer); - } MCU_E2PromRead(EEPROM_STORAGE_DANCER_0,&DancersCfg[0].zeropoint); MCU_E2PromRead(EEPROM_STORAGE_DANCER_1,&DancersCfg[1].zeropoint); MCU_E2PromRead(EEPROM_STORAGE_DANCER_2,&DancersCfg[2].zeropoint); - Report("Dancer 0 Store data flash, internal flash, eeprom ",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg1[0].zeropoint,RpWarning,(int)DancersCfg2[0].zeropoint,0); - Report("Dancer 1 Store data flash, internal flash, eeprom ",__FILE__,DancersCfg[1].zeropoint,(int)DancersCfg1[1].zeropoint,RpWarning,(int)DancersCfg2[1].zeropoint,0); - Report("Dancer 2 Store data flash, internal flash, eeprom ",__FILE__,DancersCfg[2].zeropoint,(int)DancersCfg1[2].zeropoint,RpWarning,(int)DancersCfg2[2].zeropoint,0); + status |= Report("Dancer 0 Store data eeprom ",__FILE__,__LINE__,0,RpWarning,(int)DancersCfg[0].zeropoint,0); + status |= Report("Dancer 1 Store data eeprom ",__FILE__,__LINE__,1,RpWarning,(int)DancersCfg[1].zeropoint,0); + status |= Report("Dancer 2 Store data eeprom ",__FILE__,__LINE__,2,RpWarning,(int)DancersCfg[2].zeropoint,0); - return Fresult; + return status; } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 45acfabea..28ba11fcd 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -732,6 +732,18 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, Hard_Stop); + if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DH_LID]) != LIMIT) + { + ReportWithPackageFilter(ThreadFilter,"Dyeing head is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DH_LID,RpFatalError,LIMIT,0); + PrepareReady(Module_Thread,ModuleFail); + return ERROR; + } + if (FPGA_Read_limit_Switches(Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID]) != LIMIT) + { + ReportWithPackageFilter(ThreadFilter,"Dryer lid is open!!!",__FILE__,__LINE__,HARDWARE_MOTOR_TYPE__MOTO_DRYER_LID,RpFatalError,LIMIT,0); + PrepareReady(Module_Thread,ModuleFail); + return ERROR; + } //start thread control for all motors for (Motor_i = 0;Motor_i < MAX_THREAD_MOTORS_NUM;Motor_i++) @@ -768,7 +780,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) } //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); LengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep); - SpeedControlId = AddControlCallback(ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); + SpeedControlId = AddControlCallback(NULL,ThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); } if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled { @@ -781,7 +793,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) } //SetMotHome(ThreadMotorIdToMotorId[Motor_i]); PoolerLengthCalculationMultiplier = (MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulleyradius*2*PI)/(MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].pulseperround*MotorsCfg[ThreadMotorIdToMotorId[Motor_i]].microstep); - PoolerSpeedControlId = AddControlCallback(PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); + PoolerSpeedControlId = AddControlCallback(NULL,PoolerThreadLengthCBFunction, eHundredMillisecond,MotorGetPositionFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); } if (Motor_i == FEEDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled { @@ -793,8 +805,8 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) CurrentControlledSpeed[Motor_i] = 0; } #ifndef TEST_PID_THREAD - ControlIdtoMotorId[Motor_i] = AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); - //AddControlCallback(ThreadControlSpeedReadFunction, eHundredMillisecond,MotorGetSpeedFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); + ControlIdtoMotorId[Motor_i] = AddControlCallback(NULL,ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); + //AddControlCallback(NULL,ThreadControlSpeedReadFunction, eHundredMillisecond,MotorGetSpeedFromFPGA,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToMotorId[Motor_i],Motor_i); #endif } if (Motor_i == POOLER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will n//ot be controlled @@ -807,7 +819,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) ControlIdtoMotorId[Motor_i] = 0xFF; } #ifndef TEST_PID_THREAD - ControlIdtoMotorId[Motor_i] = AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); + ControlIdtoMotorId[Motor_i] = AddControlCallback(NULL,ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); #endif } if (Motor_i == WINDER_MOTOR) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will n//ot be controlled @@ -821,7 +833,7 @@ uint32_t ThreadInitialTestStub(HardwareMotor * request) ControlIdtoMotorId[Motor_i] = 0xFF; } #ifndef TEST_PID_THREAD - ControlIdtoMotorId[Motor_i] = AddControlCallback(ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); + ControlIdtoMotorId[Motor_i] = AddControlCallback(NULL,ThreadControlCBFunction, eOneMillisecond,Control_Read_Dancer_Position,(IfTypeThread*0x100+Motor_i),ThreadMotorIdToDancerId[Motor_i],Motor_i); #endif } // if (HW_Motor_Id == HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING) // dryer motor is speed controlled. later a speed sensor will be utilized, but for now it will not be controlled @@ -912,7 +924,7 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) #else InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]/10; MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); - ControlIdtoMotorId[DRYER_MOTOR] = AddControlCallback(ThreadDryerRampUp, 200,TemplateDataReadCBFunction,0,0,0); + ControlIdtoMotorId[DRYER_MOTOR] = AddControlCallback("DryerRampUp",ThreadDryerRampUp, 200,TemplateDataReadCBFunction,0,0,0); #endif #endif #ifdef HUNDRED_MICROSECONDS_DANCER_READ diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c index c2451118d..90df9cfb1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c @@ -589,7 +589,7 @@ bool initWHS_WasteTank() WHS_info.WHS_sensors.waste_tank_empty_sensor = RdWasteTankEmptySensor(); WHS_info.WHS_sensors.waste_tank_full_sensor = SENSORnotFULL; UpdateStateMachine(); - AddControlCallback(WasteTankCBFunction, WasteTankCallBackTime , WasteTankCallBackFunction, 0,0,0);//eOneMinute + AddControlCallback("Waste tank",WasteTankCBFunction, WasteTankCallBackTime , WasteTankCallBackFunction, 0,0,0);//eOneMinute return OK; } @@ -663,7 +663,7 @@ WHS_sensor WasteTankCallBackFunction() /* bool start_WHS_machin() { - AddControlCallback( WasteTankCBFunction, eTenMillisecond, WasteTankCallBackFunction, 0,0,0 );// eOneMinute + AddControlCallback(NULL, WasteTankCBFunction, eTenMillisecond, WasteTankCallBackFunction, 0,0,0 );// eOneMinute return OK; } */ @@ -700,7 +700,7 @@ bool WasteTankCBFunction() REPORT_MSG(WHS_filling," ------------ WHS_empty ----------------- "); ret = CartridgeWasteFilling(OFF); WHS_info.Cartridge_Cover_device_Id = RemoveControlCallback(WHS_info.Cartridge_Cover_device_Id, WasteTankCBFunction ); - WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeCoverCallBackTime, CartridgeCoverCallBackFunction, 0,0,0 );//eOneSecond + WHS_info.Cartridge_Cover_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeCoverCallBackTime, CartridgeCoverCallBackFunction, 0,0,0 );//eOneSecond WrRFIDStatus(WHS_info.active_cartridge, WasteFull);//write RFID status todo } else @@ -726,7 +726,7 @@ bool WasteTankCBFunction() WHS_info.sttMachine = WHS_full; REPORT_MSG(WHS_emptying," ------------ WHS_full ----------------- "); WHS_info.Cartridge_Cover_device_Id = RemoveControlCallback(WHS_info.Cartridge_Cover_device_Id, WasteTankCBFunction ); - WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeCoverCallBackFastTime , CartridgeCoverCallBackFunction, 0,0,0 );//eTenMillisecond + WHS_info.Cartridge_Cover_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeCoverCallBackFastTime , CartridgeCoverCallBackFunction, 0,0,0 );//eTenMillisecond if (RdRFIDStatus (WHS_info.active_cartridge) == WasteEmpty) { ret = WrRFIDStatus(WHS_info.active_cartridge, WasteFilling);//write RFID status todo @@ -794,9 +794,9 @@ bool WasteTankCBFunction() if ( !PowerOffInProcessGetState() ) { - IFS_info.Cartridge_Ink_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeInkCallBackTime , CartridgeInkCallBackFunction , 0,0,0 ); //eOneSecond - WHS_info.Cartridge_Waste1_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeWaste1CallBackTime, CartridgeWaste1CallBackFunction, 0,0,0 ); //eOneSecond - WHS_info.Cartridge_Waste2_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeWaste2CallBackTime, CartridgeWaste2CallBackFunction, 0,0,0 ); //eOneSecond + IFS_info.Cartridge_Ink_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeInkCallBackTime , CartridgeInkCallBackFunction , 0,0,0 ); //eOneSecond + WHS_info.Cartridge_Waste1_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeWaste1CallBackTime, CartridgeWaste1CallBackFunction, 0,0,0 ); //eOneSecond + WHS_info.Cartridge_Waste2_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeWaste2CallBackTime, CartridgeWaste2CallBackFunction, 0,0,0 ); //eOneSecond } else { @@ -848,11 +848,11 @@ bool WasteTankCBFunction() cart1.color = BLINK; //add timeout IFS_info.Ink.time_out = 1; - IFS_info.Cartridge_Ink_TimeOut_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeInkTimeOutCallBackTime, CartridgeInkTimeOutCallBackFunction, 0,0,0 ); //eOneSecond + IFS_info.Cartridge_Ink_TimeOut_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeInkTimeOutCallBackTime, CartridgeInkTimeOutCallBackFunction, 0,0,0 ); //eOneSecond // //add callback for midtank status is full -// IFS_info.Cartridge_Ink_TimeOut_device_Id = AddControlCallback( WasteTankCBFunction, CartridgeInkTimeOutCallBackTime, CartridgeInkTimeOutCallBackFunction, 0,0,0 ); //eOneSecond +// IFS_info.Cartridge_Ink_TimeOut_device_Id = AddControlCallback(NULL, WasteTankCBFunction, CartridgeInkTimeOutCallBackTime, CartridgeInkTimeOutCallBackFunction, 0,0,0 ); //eOneSecond // Enable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color); // Read_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color); // if ( Get_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color) > MidTank_Pressure_FULL ) @@ -1257,11 +1257,11 @@ bool InitCartStatus() if (WHS_info.WHS_sensors.cartridge_cover == WHS_CartridgeCoverOPEN) { REPORT_MSG(parameter," ------------ WHS_CartridgeCoverOPEN : add callback for cart1 and cart 2 ----------------- "); - IFS_info.Cartridge_Ink_device_Id = AddControlCallback( WasteTankCBFunction, eOneSecond, CartridgeInkCallBackFunction, 0,0,0 ); - WHS_info.Cartridge_Waste1_device_Id = AddControlCallback( WasteTankCBFunction, eOneSecond, CartridgeWaste1CallBackFunction, 0,0,0 ); - WHS_info.Cartridge_Waste2_device_Id = AddControlCallback( WasteTankCBFunction, eOneSecond, CartridgeWaste2CallBackFunction, 0,0,0 ); + IFS_info.Cartridge_Ink_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeInkCallBackFunction, 0,0,0 ); + WHS_info.Cartridge_Waste1_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeWaste1CallBackFunction, 0,0,0 ); + WHS_info.Cartridge_Waste2_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeWaste2CallBackFunction, 0,0,0 ); } - WHS_info.Cartridge_Cover_device_Id = AddControlCallback( WasteTankCBFunction, eOneSecond, CartridgeCoverCallBackFunction, 0,0,0 ); + WHS_info.Cartridge_Cover_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeCoverCallBackFunction, 0,0,0 ); return OK; } @@ -1355,7 +1355,7 @@ U8 RdWastePrecenseSensor(cartridge_name name) /* U8 cartridge_handeling() { - AddControlCallback( CartridgePrecenceCBFunction, eOneMinute, CartridgePrecenceCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, CartridgePrecenceCBFunction, eOneMinute, CartridgePrecenceCallBackFunction, 0,0,0 ); // return OK; } */ @@ -1802,23 +1802,23 @@ uint32_t start_WHS_machin() switch( WHS_info.sttMachine ) { case WHS_empty: // last OnOffPBstate was OFF - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankEmptyCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankEmptyCallBackFunction, 0,0,0 ); // break; case WHS_filling : // last OnOffPBstate was COUNTPB - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankEmptyCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankEmptyCallBackFunction, 0,0,0 ); // break; case WHS_emptying: // last OnOffPBstate was SHORTPB - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankEmptyCallBackFunction, 0,0,0 ); // - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankEmptyCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // break; case WHS_full: - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankOverflowCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankOverflowCallBackFunction, 0,0,0 ); // break; case WHS_overflow: - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // - AddControlCallback( EmptyWasteTankCBFunction, eOneMinute, WasteTankOverflowCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankFullCallBackFunction, 0,0,0 ); // + AddControlCallback(NULL, EmptyWasteTankCBFunction, eOneMinute, WasteTankOverflowCallBackFunction, 0,0,0 ); // break; default: // WHS_sttError break; diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index ac9a49feb..e366ef378 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -1,3 +1,43 @@ +Embedded SW Release note - Version 1.4.5.9 (alpha 3) +============================================================= +I2C reading task for better handling of slow I2C interactions (head etc) +textual names for control calls to help debuggng +add midtank and dispenser ink content to diagnostics +*observe and handle FPGA watchdog reset (reinitialize motors) + +alarm handling: midtamk overflow, fix current alarms, consequent actions and job verification, critical alrms. +diagnostics: improved +*heaters: band alarm fixed +IDS: *dispenser data, *improve autofill on job start, *puller_tension from RML as cleaner speed +Thread: *real dryer rampup. dancers from EEPROM only. *insure rockers motors voltage value; +print: *prevent job on open covers (dryer, head) + + +Embedded SW Release note - Version 1.4.5.95 (alpha 2) +============================================================= +Embedded SW Release note - Version 1.4.5.9 (alpha 1) +============================================================= +common: + log filtering by severity and modules + file transfer chuck size reduced (slower transfer +drivers: + fpga: motor init improved, WD handling fixed, secondary pump, powerstep 01 handling. + I2C: midtank calibration, safety improved, head card and RFID preparations + valves: bug fixed. +modules: + alarm handling: current alarms, fans alarms, bugs fixes. + control: current reading disabled, machine status, led on FPGA reset. + general: buttons fixed. handling of config failures, dryer buffer length: number of dryer cycles *76 cm + 90 cm (dryer to winder), safety alarms. + heaters: machine internal alrms, bugs fixed. + IDS: dispenser data store in FFS, homing - consider safety bypass, midtank content, active homing. use RML's feeder_tension as pressure buildup limit. + thread: load fixed. hold dryer arm. + waste, IFS: tested and fixed +state machines + Init: open and cloase dispensers valve, fix problems, + power off sequence and clean job fixed. + print: job length fixed. + + Embedded SW Release note - Version 1.4.4.6 ============================================================= drivers: diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index cb30919bf..fe6f12053 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -116,8 +116,8 @@ uint32_t Start_InitSequence(void) { MachineStateDetail = MACHINE_STATE_HW_CONFIG; SetMachineStatus(MACHINE_STATE__Initializing); - HWControlId = AddControlCallback( InitSequenceCallBackFunction, 4* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); - InitSchedulerControlId = AddControlCallback( InitScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + HWControlId = AddControlCallback("Init HW Init", InitSequenceCallBackFunction, 4* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + InitSchedulerControlId = AddControlCallback("InitScheduler", InitScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); return OK; } void InitSequenceResetReason(void) @@ -211,13 +211,13 @@ uint32_t InitSequenceInitialBlowerActivation(void) Control_Voltage_To_Blower(BlowerCfg.voltage); else Control_Voltage_To_Blower(3000); - HWControlId = AddControlCallback( InitSequenceBlowerCallBackFunction, 10* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + HWControlId = AddControlCallback("Init Blower", InitSequenceBlowerCallBackFunction, 10* eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); /*if (RdInkCartridgeSensor()) //if there is a cartridge in the ink slot skip the valves procedure { MidTankOperationCounter = 32; Report("There is a cartridge in the ink slot. skipping the valves procedure",__FILE__,__LINE__,(int)MidTankOperationCounter,RpWarning,(int)InitStages,0); }*/ - MidTankControlId = AddControlCallback( InitSequenceMidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + MidTankControlId = AddControlCallback("Init Midtank", InitSequenceMidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); return OK; } @@ -265,6 +265,7 @@ uint32_t InitSequenceStartHeatingCallBackFunction(uint32_t IfIndex, uint32_t Bus if (HeaterCheckReady()==true) { MachineStateDetail = MACHINE_STATE_MACHINE_READY_TO_DYE; + SetMachineStatus(MACHINE_STATE__Ready); if (SafeRemoveControlCallback(HWControlId, InitSequenceStartHeatingCallBackFunction )==OK) HWControlId = 0xFF; else @@ -287,7 +288,7 @@ uint32_t InitSequenceStartHeating(void) if (ProcessParamsInit() ==OK) { MachineStateDetail = MACHINE_STATE_HEATING_STARTED; - HWControlId = AddControlCallback( InitSequenceStartHeatingCallBackFunction, 2*eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + HWControlId = AddControlCallback("Init Heating", InitSequenceStartHeatingCallBackFunction, 2*eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); //start heaters with predefined / store process parameters } else diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c index 3cf2a363d..df2f3705c 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c @@ -94,7 +94,7 @@ uint32_t PowerIdleCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) } void PowerIdleInit(void) { - IdleControlId = AddControlCallback( PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + IdleControlId = AddControlCallback("IdleCounter", PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); if (IdleControlId == 0xFF) Report("AddControlCallback failed",__FILE__,__LINE__,(int)IdleControlId,RpWarning,(int)0,0); Report("PowerIdleInit ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)0,0); @@ -128,7 +128,7 @@ void PowerIdleOutOfIdleState(void) return ; } if (IdleControlId == 0xFF) - IdleControlId = AddControlCallback( PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + IdleControlId = AddControlCallback("IdleCounter", PowerIdleCallBackFunction, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); if (IdleControlId == 0xFF) Report("AddControlCallback failed",__FILE__,__LINE__,(int)IdleControlId,RpWarning,(int)0,0); SetMachineStatus(MACHINE_STATE__Ready); diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index 94567a1c7..67e86397c 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -90,7 +90,7 @@ uint32_t PowerOffInit(void) StopInitSequence(); setmachineActive(true); PowerOffInProcess = true; - PowerOffControlId = AddControlCallback( PowerOffScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + PowerOffControlId = AddControlCallback("PowerOff", PowerOffScheduler, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); SetMachineStatus(MACHINE_STATE__PowerOff); return OK; } @@ -133,7 +133,7 @@ uint32_t PowerOffHeadClean(void) PowerOffHeadCleanControlId = 0xFF; //return ERROR; } - PowerOffHeadCleanControlId = AddControlCallback( PowerOffHeadCleanCallback,eOneSecond , TemplateDataReadCBFunction,0,0, 0 ); + PowerOffHeadCleanControlId = AddControlCallback(NULL, PowerOffHeadCleanCallback,eOneSecond , TemplateDataReadCBFunction,0,0, 0 ); } else { @@ -187,7 +187,7 @@ 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 ); + PowerOffHeadCleanControlId = AddControlCallback("Poweroff cleaning", PowerOffMixerFlushCallback,DEFAULT_MIXER_CLEANING_TIMEOUT , TemplateDataReadCBFunction,0,0, 0 ); return OK; } /*******************************************************************************************************/ @@ -296,7 +296,7 @@ uint32_t PowerOffWaitForProcesses(void) { WaitForProcessCounter = 0; //15 minutes wait REPORT_MSG (PowerOffMachineState, "Ongoing processes, wait for end of process"); - WaitForProcessControlId = AddControlCallback( PowerOffWaitForProcessesCallback, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + WaitForProcessControlId = AddControlCallback("ongoing processes", PowerOffWaitForProcessesCallback, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); } else { @@ -373,7 +373,7 @@ uint32_t PowerOffWaitForTemperature(void) if (WaitForProcessControlId == 0xFF) { WaitForProcessCounter = 0; - WaitForProcessControlId = AddControlCallback( PowerOffWaitForTemperatureCallback, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); + WaitForProcessControlId = AddControlCallback("poweroff cooling", PowerOffWaitForTemperatureCallback, eOneSecond, TemplateDataReadCBFunction,0,0, 0 ); } //TBD return OK; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 3cdc4d1b8..1f6ff685e 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -102,7 +102,7 @@ JobUploadStrategy uploadstrategy = JOB_UPLOAD_STRATEGY__Default; ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle}; -uint16_t job_length = 0; +double job_length = 0.0; /******************************************************************************************** * functions describes motor operation flow and movement state during profile execution @@ -517,7 +517,23 @@ void ThreadJoggingRequestFunc(MessageContainer* requestContainer) ThreadJoggingResponse response = THREAD_JOGGING_RESPONSE__INIT; - status = ThreadJoggingFunc(request->speed); + if (JobIsActive() == true) + { + AbortJob(0); + //set the job handler to handle heaters, ids and waste in the state machine + Task_sleep(100); //let the job end procedure role before returning the configuration to normal. + usnprintf(ErrorMsg, 80,"Copy Configured T %d W %d I %d H %d W %d",CopyConfigured[Module_Thread],CopyConfigured[Module_Winder],CopyConfigured[Module_IDS],CopyConfigured[Module_Heaters],CopyConfigured[Module_Waste]); + Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); + + + my_free(Ticket.segments); + my_free(TSegment); + my_free(Tspool); + } + else + { + status = ThreadJoggingFunc(request->speed); + } responseContainer = createContainer(MESSAGE_TYPE__ThreadJoggingResponse, requestContainer->token, true, &response, &thread_jogging_response__pack, &thread_jogging_response__get_packed_size); if (status!= OK) @@ -536,7 +552,7 @@ void ThreadJoggingRequestFunc(MessageContainer* requestContainer) } void ThreadAbortJoggingFunc(void) { - if (JobIsActive() == true) +/* if (JobIsActive() == true) { AbortJob(0); //set the job handler to handle heaters, ids and waste in the state machine @@ -549,7 +565,7 @@ void ThreadAbortJoggingFunc(void) my_free(TSegment); my_free(Tspool); } - +*/ } void ThreadAbortJoggingRequestFunc(MessageContainer* requestContainer) { @@ -640,7 +656,7 @@ void Stub_JobRequest(MessageContainer* requestContainer) StubLength = Ticket->length*100; StubLengthCounter = 0; ustrncpy (JobToken, requestContainer->token,36); - StubControlId = AddControlCallback( SendStubJobProgress, eOneSecond,TemplateDataReadCBFunction,0,0,0); + StubControlId = AddControlCallback(NULL, SendStubJobProgress, eOneSecond,TemplateDataReadCBFunction,0,0,0); jobStatus.has_progress = true; jobStatus.progress = 0.0; @@ -753,9 +769,9 @@ void JobRequestFunc(MessageContainer* requestContainer) if (JobAlarmReason ==OK) { n_unit_segments = n_segments; - if ((Ticket->has_units)&&(Ticket->units > 1)) + if ((Ticket->has_numberofunits)&&(Ticket->numberofunits > 1)) { - n_units = Ticket->units; + n_units = Ticket->numberofunits; } if (n_units>1) { diff --git a/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs b/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs index 4aad16764..3b2ff042b 100644 --- a/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs +++ b/Software/Embedded_SW/Embedded/embeddedparametersbuild.cs @@ -81,7 +81,7 @@ configurationParameters.SwitchToIdleTimeinSeconds = 3600; configurationParameters.IdleDrierTemperature = 80; configurationParameters.IdleHeadTemperature = 80; configurationParameters.IdleMixerTemperature = 0; -configurationParameters.PowerOffTemperatureLimit = 100; +configurationParameters.PowerOffTemperatureLimit = 50; //general parameters, ORDER MUST BE PRESERVED!!!! //check the dispensers hard limit alarms -- cgit v1.3.1 From a282b0a50f0b19712a11e16320a5de7d337ffa30 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 19 Nov 2019 16:46:51 +0200 Subject: update mastrer with latest changes in Alpha + embedded version --- .../Embedded/Common/SWUpdate/FileSystem.c | 4 - .../Embedded/Common/SWUpdate/FirmwareUpgrade.c | 1 + .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.c | 12 +- .../Embedded_SW/Embedded/Common/SW_Info/SW_Info.h | 1 + .../Embedded/Common/report/reportInit.c | 2 + Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c | 1 + .../I2C_Communication/RFID_NFC/NFC_I2C/NFC_I2C.c | 2 +- .../I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.c | 44 +- .../I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.h | 2 +- .../Embedded/Drivers/Motors/MotorActions.c | 39 +- .../Embedded_SW/Embedded/Drivers/Valves/Valve.c | 3 + .../Embedded/Drivers/flash_ram/MCU_E2Prom.c | 5 + .../Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.c | 281 ++++++ .../Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.h | 22 + .../Embedded/Drivers/logi-tag/LT_NFC_Info.h | 74 ++ .../Embedded/Drivers/logi-tag/LT_NFC_Settings.h | 75 ++ .../Embedded/Drivers/logi-tag/LT_RFID.c | 946 +++++++++++++++++++++ .../Embedded/Drivers/logi-tag/LT_RFID.h | 97 +++ Software/Embedded_SW/Embedded/Embedded.cfg | 2 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 39 +- .../Embedded/Modules/Control/MillisecTask.c | 2 + .../Embedded_SW/Embedded/Modules/Control/control.c | 2 + .../Modules/Diagnostics/DiagnosticsHoming.c | 19 +- .../Embedded/Modules/General/GeneralHardware.c | 19 +- .../Embedded_SW/Embedded/Modules/General/Safety.c | 8 +- .../Embedded_SW/Embedded/Modules/General/process.c | 56 +- .../Embedded_SW/Embedded/Modules/General/process.h | 2 +- .../Embedded/Modules/Heaters/Heaters_print.c | 1 + Software/Embedded_SW/Embedded/Modules/IDS/IDS.h | 3 +- .../Embedded/Modules/IDS/IDS_dispenser.c | 10 +- Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h | 2 + .../Embedded_SW/Embedded/Modules/IDS/IDS_maint.c | 206 ++--- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 87 +- Software/Embedded_SW/Embedded/Modules/IFS/ifs.c | 136 ++- Software/Embedded_SW/Embedded/Modules/IFS/ifs.h | 1 + .../Embedded/Modules/Stubs_Handler/Progress.c | 34 +- .../Embedded/Modules/Thread/ThreadLoad.c | 67 +- .../Embedded/Modules/Thread/Thread_Winder.c | 17 +- .../Embedded/Modules/Thread/Thread_init.c | 7 +- .../Embedded/Modules/Thread/Thread_print.c | 7 +- .../Embedded/Modules/Waste/Waste_init.c | 14 +- .../Embedded/Software Release Notes.txt | 22 + .../StateMachines/Initialization/InitSequence.c | 4 +- .../StateMachines/Initialization/PowerIdle.c | 19 +- .../Initialization/PowerOffSequence.c | 2 +- .../Embedded/StateMachines/Printing/JobSTM.c | 40 +- .../PMR/Messages/MachineStatus/MachineStatus.proto | 1 + 47 files changed, 2135 insertions(+), 305 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.c create mode 100644 Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.h create mode 100644 Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Info.h create mode 100644 Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Settings.h create mode 100644 Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.c create mode 100644 Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.h (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index 018e83ce0..7871c5e28 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -31,14 +31,10 @@ #include #include -#include "third_party/fatfs/src/ffconf.h" -#include "third_party/fatfs/src/diskio.h" #include "drivers/Flash_Memory/Flash_Memory.h" #include "drivers/Flash_Memory/fatfs/ff.h" #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" -#include "third_party/fatfs/src/ffconf.h" - #include "StateMachines/Printing/PrintingSTM.h" diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index e15ae2dc4..12f336749 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -139,6 +139,7 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) switch(VersionPackage->filedescriptors[File_i]->destination) { case VERSION_FILE_DESTINATION__MCU: + CurrentRunningFile++; break; case VERSION_FILE_DESTINATION__FPGA1: case VERSION_FILE_DESTINATION__FPGA2: 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 5e0a5c31a..92ef02008 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,6,0}; +TangoVersion_t _gTangoVersion = {1,4,8,0}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d @@ -56,5 +56,15 @@ uint16_t GetTangoVersion(uint8_t* _buffer) //_buffer[size++] = '\0'; return size; } +char EmbMessage[50]; +void ReportEmbeddedVersion(void) +{ + memset (EmbMessage,0,sizeof(EmbMessage)); + + strcpy(EmbMessage, "Embedded Version "); + usnprintf(EmbMessage, 50, "Embedded Version %d.%d.%d.%d build %s",_gTangoVersion.m_major,_gTangoVersion.m_minor, _gTangoVersion.m_patch,_gTangoVersion.m_build,BUILD_DATE); + + Report(EmbMessage, __FILE__, __LINE__, _gTangoVersion.m_patch, RpWarning, _gTangoVersion.m_build, 0); +} diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.h b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.h index 7cec18731..873b5da70 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.h +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.h @@ -22,6 +22,7 @@ extern char _gTangoName [MAX_STRING_LEN];//d uint16_t GetTangoVersion(uint8_t* _buffer); +void ReportEmbeddedVersion(void); #endif /* COMMON_SW_INFO_SW_INFO_H_ */ diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 857c0ad82..5ae55736d 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -41,6 +41,7 @@ #include "PMR/debugging/SetDebugLogCategoryResponse.pb-c.h" #include "modules/General/process.h" +#include "Common/SW_Info/SW_Info.h" PackageHandle ControlFilter; PackageHandle HeatersFilter; @@ -193,6 +194,7 @@ uint32_t ReportInitMessage(MessageContainer* requestContainer) */ ReportResetReason(); Task_sleep (100); + ReportEmbeddedVersion(); /*SysCtlResetCauseClear(RESC);*/ #ifdef TEST_PID_THREAD diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index 867f0c336..e2e71c4cc 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -6,6 +6,7 @@ #include "driverlib/epi.h" #include "inc/hw_memmap.h" #include +#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include "FPGA_Rename.h" #include "FPGA_COMM.h" diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/NFC_I2C.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/NFC_I2C.c index 03fbb3aa2..a6391e2ef 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/NFC_I2C.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/NFC_I2C.c @@ -20,7 +20,7 @@ #define I2C_MUX_Slave_Add 0xE0//Mux I2C address #define I2C_NFC_Slave_Add (0x28<<1)//The OM5578/PN7150S kit comes with default 0x28 (7 bits) I2C address. -#define MaxNoBytesToRead 7// +#define MaxNoBytesToRead 100// #define MaxNoBytesToWrite 100// uint8_t NFC_I2C_Read_buf[MaxNoBytesToRead]; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.c index 8b5ea642d..e2886c4bc 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/RFID_NFC/NFC_I2C/Test_NFC.c @@ -17,7 +17,7 @@ uint32_t NCICoreReset() //stage 1 uint32_t Status = OK; const uint8_t CORE_RESET_CMD[] = {0x20,0x00,0x01,0x01}; - const uint8_t Expedted_Answer_Length = 6;// CORE_RESET_RSP 40 00 03 00 11 01 (PN7150 RESET RESPONSE) + const uint8_t CORE_RESET_RSP[] = {0x40,0x00,0x03,0x00,0x11,0x01};//PN7150 RESET RESPONSE int i = 0; @@ -30,18 +30,24 @@ uint32_t NCICoreReset() //stage 1 delayms(1000); I2C_NFC_Set_For_Read_Ch(); SysCtlDelay(5); - I2C_NFC_Read_Ch(Expedted_Answer_Length); + I2C_NFC_Read_Ch(sizeof(CORE_RESET_RSP)); delayms(5); + for(i=0; i>8 != IfTypeMotors) { LOG_ERROR (IfIndex, "Wrong Interface type"); @@ -213,17 +219,34 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / } Read_Dryer_ENC_Position(); //trigger the next call + ArmSamples[ArmSamplePointer] = MotorPosition;//(-1 * TranslatedReadValue); if (FirstCall<5) { FirstCall++; return OK; } + ArmSamples[ArmSamplePointer] = MotorPosition;//(-1 * TranslatedReadValue); + ArmSamplePointer++; + if (ArmSamplePointer >= MAX_CONTROL_SAMPLES) + ArmSamplePointer = 0; + for (i=0;i=10)) /*Motor did not move in the last time lag*/ - if (abs(MotorPosition - StoredMotorPosition[MotorId])<=10) +// if (abs(MotorPosition - StoredMotorPosition[MotorId])<=10) + if (abs(avreageSampleValue-StoredavreageSampleValue)<=2) { //stop this control loop - REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction stopped"); + //REPORT_MSG(MotorPosition,"MotorVerifiedCallBackFunction stopped"); + Report("Motor to stopper stopped",__FILE__,avreageSampleValue,StoredavreageSampleValue,RpWarning,avreageSampleSum,0); SafeRemoveControlCallback(MotorControlId[MotorId], MotorControlCallback[MotorId] ); MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; @@ -246,7 +269,11 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / MotorCallback[MotorId](MotorId,ArmPosition); } - else StoredMotorPosition[MotorId] = MotorPosition; + else + { + StoredMotorPosition[MotorId] = MotorPosition; + StoredavreageSampleValue = avreageSampleValue; + } return OK; } @@ -278,13 +305,15 @@ uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Spee CallbackCalls = 0; FirstCall = 0; MotorGetPositionFromFPGA(MotorId); + memset(ArmSamples,0,sizeof(ArmSamples)); + ArmSamplePointer = 0; Task_sleep(5); Read_Dryer_ENC_Position(); //trigger the next call StoredMotorPosition[MotorId] = MotorGetPosition(MotorId); - REPORT_MSG(StoredMotorPosition[MotorId],"MotorMoveToStopper initial position"); + Report("MotorMoveToStopper initial position",__FILE__,__LINE__,StoredMotorPosition[MotorId],RpWarning,Speed,0); MotorSetSpeed (MotorId, Speed); - MotorControlId[MotorId] = AddControlCallback(NULL, MotorVerifiedCallBackFunction, 10,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); + MotorControlId[MotorId] = AddControlCallback(NULL, MotorVerifiedCallBackFunction, 30,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorVerifiedCallBackFunction; return MotorControlId[MotorId]; } diff --git a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c index 06e5b4b0d..bc5cb5096 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c +++ b/Software/Embedded_SW/Embedded/Drivers/Valves/Valve.c @@ -362,6 +362,7 @@ uint32_t Valve3WayCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callback_fptr callback) //direction: MidTank_Dispenser or Dispenser_Mixer { + uint32_t busy = false; //Report("Control3WayValvesWithCallback ",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)direction,0); if (Valve3WayControlId[_ValveId] != 0xFF) { @@ -371,6 +372,8 @@ uint32_t Control3WayValvesWithCallback (Valves_t _ValveId, bool direction, callb Valve3WayModuleCallback[_ValveId] = callback; + busy = FPGA_GetDispenserValveBusyOCD(_ValveId,0); + Report("Set valve id, dir, busy",__FILE__,_ValveId,(int)direction,RpWarning,(int)busy,0); Valve3WayControlId[_ValveId] = AddControlCallback("Valve3WayControlId", Valve3WayCallBackFunction, eOneSecond/*eHundredMillisecond*/, FPGA_GetDispenserValveBusyOCD,(IfTypeDisopenser*0x100+_ValveId), _ValveId, 0 ); if (Valve3WayControlId[_ValveId] == 0xFF) Report("Add control callback failed",__FILE__,__LINE__,(int)_ValveId,RpWarning,(int)Valve3WayControlId[_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 96ff259b2..aae9ce2e9 100644 --- a/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c +++ b/Software/Embedded_SW/Embedded/Drivers/flash_ram/MCU_E2Prom.c @@ -20,6 +20,11 @@ uint32_t MCU_E2PromProgram(int Address,uint32_t Data) Report("MCU_E2PromProgram Error",__FILE__,__LINE__,Address,RpWarning,Data,0); return ERROR; } + if ((Address>=EEPROM_STORAGE_DANCER_0)&&(Address<=EEPROM_STORAGE_DANCER_2)) + { + Report("~~~~~~Store dancers eeprom ",__FILE__,__LINE__,(int)Address,RpWarning,(int)Data,0); + + } Report("MCU_E2PromProgram",__FILE__,__LINE__,Address,RpWarning,Data,0); return (EEPROMProgram((uint32_t *)&Buffer, Address*4, 4)); diff --git a/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.c b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.c new file mode 100644 index 000000000..68ae6c107 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.c @@ -0,0 +1,281 @@ +#include "LT_NFC.h" +#include "LT_NFC_Settings.h" +#include + +uint8_t rBuf[MAX_NCI_FRAME_SIZE]; +uint16_t readLen = 0; + +uint32_t I2C_Base = I2C6_BASE; +uint32_t EN_Port = GPIO_PORTK_BASE; +uint32_t EN_Pin = GPIO_PIN_1; +uint32_t IRQ_Port = GPIO_PORTK_BASE; +uint32_t IRQ_Pin = GPIO_PIN_2; + +void NFC_HardwareReset(){ + ROM_GPIOPinWrite(EN_Port, EN_Pin, 0); + delayms(10); + ROM_GPIOPinWrite(EN_Port, EN_Pin, EN_Pin); + delayms(10); +} + +bool NFC_WaitForIRQ(uint16_t timeout){ + uint16_t i = 0; + for(i=0; i= 2) && (rBuf[0] == 0x40) && (rBuf[1] == 0x00)) + return true; + } + delayms(500); + } + return false; +} + +bool NFC_CoreInit(uint32_t *fwVersion){ + const uint8_t NCICoreInit[] = {0x20, 0x01, 0x00}; + if(!NFC_Transceive(NCICoreInit, sizeof(NCICoreInit))) + return false; + if ((readLen < 20) || (rBuf[0] != 0x40) || (rBuf[1] != 0x01) || (rBuf[3] != 0x00)) + return false; + if (rBuf[17+rBuf[8]] != 0x10) // PN7150 is generation 2 + return false; + *fwVersion = rBuf[17+rBuf[8]]; + *fwVersion |= ((uint32_t)rBuf[18+rBuf[8]]) << 8; + *fwVersion |= ((uint32_t)rBuf[19+rBuf[8]]) << 16; + return true; +} + +bool NFC_Connect(uint32_t *fwVersion){ + NFC_HardwareReset(); + if(!NFC_CoreReset()) + return false; + if(!NFC_CoreInit(fwVersion)) + return false; + return true; +} + +void NFC_Disconnect(){ + ROM_GPIOPinWrite(EN_Port, EN_Pin, 0); +} + +bool NFC_ConfigSettings(){ + if(!NFC_Config(NxpNci_CORE_CONF, sizeof(NxpNci_CORE_CONF))) + return false; + if(!NFC_Transceive(NxpNci_CORE_STANDBY, sizeof(NxpNci_CORE_STANDBY))) + return false; + if ((readLen < 4) || (rBuf[0] != 0x4F) || (rBuf[1] != 0x00) || (rBuf[3] != 0x00)) + return false; + const uint8_t NCIReadTS[] = {0x20, 0x03, 0x03, 0x01, 0xA0, 0x14}; + if(!NFC_Transceive(NCIReadTS, sizeof(NCIReadTS))) // Read timestamp stored in NFC Controller + return false; + if ((readLen < 9) || (rBuf[0] != 0x40) || (rBuf[1] != 0x03) || (rBuf[3] != 0x00)) + return false; + uint8_t currentTS[32] = __TIMESTAMP__; + if(memcmp(&rBuf[8], currentTS, sizeof(currentTS)) != 0){ // Compare stored timestamp with current build timestamp + if(!NFC_Config(NxpNci_CORE_CONF_EXTN, sizeof(NxpNci_CORE_CONF_EXTN))) + return false; + if(!NFC_Config(NxpNci_CLK_CONF, sizeof(NxpNci_CLK_CONF))) + return false; + if(!NFC_Config(NxpNci_TVDD_CONF_2ndGen, sizeof(NxpNci_TVDD_CONF_2ndGen))) + return false; + if(!NFC_Config(NxpNci_RF_CONF_2ndGen, sizeof(NxpNci_RF_CONF_2ndGen))) + return false; + uint8_t NCIWriteTS[7+32] = {0x20, 0x02, 0x24, 0x01, 0xA0, 0x14, 0x20}; + memcpy(&NCIWriteTS[7], currentTS, sizeof(currentTS)); + if(!NFC_Config(NCIWriteTS, sizeof(NCIWriteTS))) // Save current build timestamp + return false; + } + if(!NFC_CoreReset()) + return false; + uint32_t tmp; + if(!NFC_CoreInit(&tmp)) + return false; + return true; +} + +bool NFC_ConfigMode(){ + const uint8_t NxpNci_PropAct[] = {0x2F, 0x02, 0x00}; + if(!NFC_Transceive(NxpNci_PropAct, sizeof(NxpNci_PropAct))) // Enable Proprietary interface for T4T card presence check procedure + return false; + if ((readLen < 4) || (rBuf[0] != 0x4F) || (rBuf[1] != 0x02) || (rBuf[3] != 0x00)) + return false; + if(!NFC_Transceive(NxpNci_DiscoverMap, sizeof(NxpNci_DiscoverMap))) + return false; + if ((readLen < 4) || (rBuf[0] != 0x41) || (rBuf[1] != 0x00) || (rBuf[3] != 0x00)) + return false; + return true; +} + +bool NFC_StartDiscovery(){ + if(!NFC_Transceive(NxpNci_StartDiscoveryChars, sizeof(NxpNci_StartDiscoveryChars))) + return false; + if ((readLen < 4) || (rBuf[0] != 0x41) || (rBuf[1] != 0x03) || (rBuf[3] != 0x00)) + return false; + return true; +} + +bool NFC_StopDiscovery(){ + const uint8_t NxpNci_StopDiscovery[] = {0x21, 0x06, 0x01, 0x00}; + if(!NFC_Transceive(NxpNci_StopDiscovery, sizeof(NxpNci_StopDiscovery))) + return false; + if ((readLen < 4) || (rBuf[0] != 0x41) || (rBuf[1] != 0x06) || (rBuf[3] != 0x00)) + return false; + if(!NFC_Receive(TIMEOUT_COMMAND)) + return false; + return true; +} + +void NFC_FillInterfaceInfo(NxpNci_RfIntf_t* tagInfo){ + uint8_t* pBuf = &rBuf[10]; + uint8_t i, temp; + switch(tagInfo->ModeTech){ + case (MODE_POLL | TECH_PASSIVE_NFCA): + memcpy(tagInfo->Info.NFC_APP.SensRes, &pBuf[0], 2); + temp = 2; + tagInfo->Info.NFC_APP.NfcIdLen = pBuf[temp]; + temp++; + memcpy(tagInfo->Info.NFC_APP.NfcId, &pBuf[3], tagInfo->Info.NFC_APP.NfcIdLen); + temp+=pBuf[2]; + tagInfo->Info.NFC_APP.SelResLen = pBuf[temp]; + temp++; + if(tagInfo->Info.NFC_APP.SelResLen == 1) tagInfo->Info.NFC_APP.SelRes[0] = pBuf[temp]; + temp+=4; + if(pBuf[temp] != 0){ + temp++; + tagInfo->Info.NFC_APP.RatsLen = pBuf[temp]; + memcpy(tagInfo->Info.NFC_APP.Rats, &pBuf[temp+1], pBuf[temp]); + } + else tagInfo->Info.NFC_APP.RatsLen = 0; + break; + case (MODE_POLL | TECH_PASSIVE_NFCB): + tagInfo->Info.NFC_BPP.SensResLen = pBuf[0]; + memcpy(tagInfo->Info.NFC_BPP.SensRes, &pBuf[1], tagInfo->Info.NFC_BPP.SensResLen); + temp = pBuf[0] + 4; + if(pBuf[temp] != 0){ + temp++; + tagInfo->Info.NFC_BPP.AttribResLen = pBuf[temp]; + memcpy(tagInfo->Info.NFC_BPP.AttribRes, &pBuf[temp+1], pBuf[temp]); + } + else tagInfo->Info.NFC_BPP.AttribResLen = 0; + break; + case (MODE_POLL | TECH_PASSIVE_NFCF): + tagInfo->Info.NFC_FPP.BitRate = pBuf[0]; + tagInfo->Info.NFC_FPP.SensResLen = pBuf[1]; + memcpy(tagInfo->Info.NFC_FPP.SensRes, &pBuf[2], tagInfo->Info.NFC_FPP.SensResLen); + break; + case (MODE_POLL | TECH_PASSIVE_15693): + tagInfo->Info.NFC_VPP.AFI = pBuf[0]; + tagInfo->Info.NFC_VPP.DSFID = pBuf[1]; + for(i=0; i<8; i++) + tagInfo->Info.NFC_VPP.ID[7-i] = pBuf[2+i]; + break; + default: break; + } +} + +uint8_t NFC_WaitForDiscoveryNotification(NxpNci_RfIntf_t *tagInfo){ + do { + if(!NFC_Receive(TIMEOUT_DISCOVERY)) + return 0; + } while((rBuf[0] != 0x61) || ((rBuf[1] != 0x05) && (rBuf[1] != 0x03))); + if (rBuf[1] == 0x05){ + tagInfo->Interface = rBuf[4]; + tagInfo->Protocol = rBuf[5]; + tagInfo->ModeTech = rBuf[6]; + NFC_FillInterfaceInfo(tagInfo); + } + else{ + uint8_t protocol = rBuf[4]; + while(rBuf[readLen-1] == 0x02){ // Remaining NTF ? + if(!NFC_Receive(TIMEOUT_EXT)) + return 2; + } + uint8_t NCIRfDiscoverSelect[] = {0x21, 0x04, 0x03, 0x01, PROT_ISODEP, INTF_ISODEP}; + NCIRfDiscoverSelect[4] = protocol; + if (tagInfo->Protocol == PROT_ISODEP) + NCIRfDiscoverSelect[5] = INTF_ISODEP; + else if (tagInfo->Protocol == PROT_NFCDEP) + NCIRfDiscoverSelect[5] = INTF_NFCDEP; + else if (tagInfo->Protocol == PROT_MIFARE) + NCIRfDiscoverSelect[5] = INTF_TAGCMD; + else NCIRfDiscoverSelect[5] = INTF_FRAME; + if(!NFC_Transceive(NCIRfDiscoverSelect, sizeof(NCIRfDiscoverSelect))) // In case of multiple cards, select the first one + return 2; + if ((readLen < 4) || (rBuf[0] != 0x41) || (rBuf[1] != 0x04) || (rBuf[3] != 0x00)) + return 2; + if(!NFC_Receive(TIMEOUT_EXT)) + return 2; + if ((rBuf[0] == 0x61) || (rBuf[1] == 0x05)) + { + tagInfo->Interface = rBuf[4]; + tagInfo->Protocol = rBuf[5]; + tagInfo->ModeTech = rBuf[6]; + NFC_FillInterfaceInfo(tagInfo); + } + else return 2; + } + if (tagInfo->Interface == INTF_UNDETERMINED) // In case of unknown target align protocol information + tagInfo->Protocol = PROT_UNDETERMINED; + if((tagInfo->ModeTech & MODE_MASK) != MODE_POLL) + return 2; + return 1; +} + +bool NFC_ReaderTagCmd(uint8_t *command, uint8_t commandSize, uint8_t *answer, uint8_t *answerSize){ + uint8_t cmd[MAX_NCI_FRAME_SIZE] = {0, 0, commandSize}; + memcpy(&cmd[3], command, commandSize); + if(!NFC_Transceive(cmd, commandSize + 3)) + return false; + if(!NFC_Receive(TIMEOUT_COMMAND)) + return false; + if((rBuf[0] != 0) || (rBuf[1] != 0)) + return false; + *answerSize = rBuf[2]; + memcpy(answer, &rBuf[3], *answerSize); + return true; +} diff --git a/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.h b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.h new file mode 100644 index 000000000..622d7dcec --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC.h @@ -0,0 +1,22 @@ +#ifndef LT_NFC_H +#define LT_NFC_H + +#include "include.h" +#include "LT_NFC_Info.h" + +extern uint32_t I2C_Base; +extern uint32_t EN_Port; +extern uint32_t EN_Pin; +extern uint32_t IRQ_Port; +extern uint32_t IRQ_Pin; + +bool NFC_Connect(uint32_t *fwVersion); +void NFC_Disconnect(); +bool NFC_ConfigSettings(); +bool NFC_ConfigMode(); +bool NFC_StartDiscovery(); +bool NFC_StopDiscovery(); +uint8_t NFC_WaitForDiscoveryNotification(NxpNci_RfIntf_t *tagInfo); +bool NFC_ReaderTagCmd(uint8_t *command, uint8_t commandSize, uint8_t *answer, uint8_t *answerSize); + +#endif diff --git a/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Info.h b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Info.h new file mode 100644 index 000000000..a12d875e4 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Info.h @@ -0,0 +1,74 @@ +#ifndef LT_NFC_INFO_H +#define LT_NFC_INFO_H + +// Flag definition used as Interface values +#define INTF_UNDETERMINED 0x0 +#define INTF_FRAME 0x1 +#define INTF_ISODEP 0x2 +#define INTF_NFCDEP 0x3 +#define INTF_TAGCMD 0x80 +// Flag definition used as Protocol values +#define PROT_UNDETERMINED 0x0 +#define PROT_T1T 0x1 +#define PROT_T2T 0x2 +#define PROT_T3T 0x3 +#define PROT_ISODEP 0x4 +#define PROT_NFCDEP 0x5 +#define PROT_ISO15693 0x6 +#define PROT_MIFARE 0x80 +// Flag definition used as Mode values +#define MODE_POLL 0x00 +#define MODE_LISTEN 0x80 +#define MODE_MASK 0xF0 +// Flag definition used as Technologies values +#define TECH_PASSIVE_NFCA 0 +#define TECH_PASSIVE_NFCB 1 +#define TECH_PASSIVE_NFCF 2 +#define TECH_ACTIVE_NFCA 3 +#define TECH_ACTIVE_NFCF 5 +#define TECH_PASSIVE_15693 6 + +typedef struct{ + unsigned char SensRes[2]; + unsigned char NfcIdLen; + unsigned char NfcId[10]; + unsigned char SelResLen; + unsigned char SelRes[1]; + unsigned char RatsLen; + unsigned char Rats[20]; +} NxpNci_RfIntf_info_APP_t; // POLL passive type A + +typedef struct{ + unsigned char SensResLen; + unsigned char SensRes[12]; + unsigned char AttribResLen; + unsigned char AttribRes[17]; +} NxpNci_RfIntf_info_BPP_t; // POLL passive type B + +typedef struct{ + unsigned char BitRate; + unsigned char SensResLen; + unsigned char SensRes[18]; +} NxpNci_RfIntf_info_FPP_t; // POLL passive type F + +typedef struct{ + unsigned char AFI; + unsigned char DSFID; + unsigned char ID[8]; +} NxpNci_RfIntf_info_VPP_t; // POLL passive type ISO15693 + +typedef union{ + NxpNci_RfIntf_info_APP_t NFC_APP; + NxpNci_RfIntf_info_BPP_t NFC_BPP; + NxpNci_RfIntf_info_FPP_t NFC_FPP; + NxpNci_RfIntf_info_VPP_t NFC_VPP; +} NxpNci_RfIntf_Info_t; + +typedef struct{ + unsigned char Interface; + unsigned char Protocol; + unsigned char ModeTech; + NxpNci_RfIntf_Info_t Info; +} NxpNci_RfIntf_t; // Definition of discovered remote device properties + +#endif diff --git a/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Settings.h b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Settings.h new file mode 100644 index 000000000..5cadc151d --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_NFC_Settings.h @@ -0,0 +1,75 @@ +#ifndef LT_NFC_SETTINGS_H +#define LT_NFC_SETTINGS_H + +#define NXPNCI_I2C_ADDR 0x28 +#define MAX_NCI_FRAME_SIZE 258 +#define TIMEOUT_COMMAND 1000 +#define TIMEOUT_DISCOVERY 200 +#define TIMEOUT_EXT 100 + +// NCI standard dedicated settings +// Refer to NFC Forum NCI standard for more details +const unsigned char NxpNci_CORE_CONF[]={0x20, 0x02, 0x05, 0x01, /* CORE_SET_CONFIG_CMD */ + 0x00, 0x02, 0x00, 0x01 /* TOTAL_DURATION */ +}; + +// NXP-NCI extension dedicated setting +// Refer to NFC controller User Manual for more details +const unsigned char NxpNci_CORE_CONF_EXTN[]={0x20, 0x02, 0x0D, 0x03, /* CORE_SET_CONFIG_CMD */ + 0xA0, 0x40, 0x01, 0x00, /* TAG_DETECTOR_CFG */ + 0xA0, 0x41, 0x01, 0x04, /* TAG_DETECTOR_THRESHOLD_CFG */ + 0xA0, 0x43, 0x01, 0x00 /* TAG_DETECTOR_FALLBACK_CNT_CFG */ +}; + +// NXP-NCI standby enable setting +// Refer to NFC controller User Manual for more details +const unsigned char NxpNci_CORE_STANDBY[]={0x2F, 0x00, 0x01, 0x01}; /* last byte indicates enable/disable */ + +// NXP-NCI CLOCK configuration +// Refer to NFC controller Hardware Design Guide document for more details +// Xtal configuration +const unsigned char NxpNci_CLK_CONF[]={0x20, 0x02, 0x05, 0x01, /* CORE_SET_CONFIG_CMD */ + 0xA0, 0x03, 0x01, 0x08 /* CLOCK_SEL_CFG */ +}; + +// NXP-NCI TVDD configuration +// Refer to NFC controller Hardware Design Guide document for more details +// CFG2: external 5V is used to generate the VDD(TX) through TXLDO +const unsigned char NxpNci_TVDD_CONF_2ndGen[]={0x20, 0x02, 0x07, 0x01, 0xA0, 0x0E, 0x03, 0x06, 0x64, 0x00}; + +// RF configuration related to 2nd generation of NXP-NCI controller (e.g PN7150) +// Following configuration relates to performance optimization of OM5578/PN7150 NFC Controller demo kit +const unsigned char NxpNci_RF_CONF_2ndGen[]={0x20, 0x02, 0xA3, 0x13, + 0xA0, 0x0D, 0x06, 0x04, 0x35, 0x90, 0x01, 0xF4, 0x01, /* RF_CLIF_CFG_INITIATOR CLIF_AGC_INPUT_REG */ + 0xA0, 0x0D, 0x06, 0x06, 0x44, 0x01, 0x90, 0x03, 0x00, /* RF_CLIF_CFG_TARGET CLIF_ANA_RX_REG */ + 0xA0, 0x0D, 0x06, 0x06, 0x30, 0xB0, 0x01, 0x10, 0x00, /* RF_CLIF_CFG_TARGET CLIF_SIGPRO_ADCBCM_THRESHOLD_REG */ + 0xA0, 0x0D, 0x06, 0x06, 0x42, 0x02, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_TARGET CLIF_ANA_TX_AMPLITUDE_REG */ + 0xA0, 0x0D, 0x03, 0x06, 0x3F, 0x04, /* RF_CLIF_CFG_TARGET CLIF_TEST_CONTROL_REG */ + 0xA0, 0x0D, 0x06, 0x20, 0x42, 0x88, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_TECHNO_I_TX15693 CLIF_ANA_TX_AMPLITUDE_REG */ + 0xA0, 0x0D, 0x04, 0x22, 0x44, 0x22, 0x00, /* RF_CLIF_CFG_TECHNO_I_RX15693 CLIF_ANA_RX_REG */ + 0xA0, 0x0D, 0x06, 0x22, 0x2D, 0x50, 0x34, 0x0C, 0x00, /* RF_CLIF_CFG_TECHNO_I_RX15693 CLIF_SIGPRO_RM_CONFIG1_REG */ + 0xA0, 0x0D, 0x06, 0x32, 0x42, 0xF8, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_BR_106_I_TXA CLIF_ANA_TX_AMPLITUDE_REG */ + 0xA0, 0x0D, 0x06, 0x34, 0x2D, 0x24, 0x37, 0x0C, 0x00, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_SIGPRO_RM_CONFIG1_REG */ + 0xA0, 0x0D, 0x06, 0x34, 0x33, 0x86, 0x80, 0x00, 0x70, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_AGC_CONFIG0_REG */ + 0xA0, 0x0D, 0x04, 0x34, 0x44, 0x22, 0x00, /* RF_CLIF_CFG_BR_106_I_RXA_P CLIF_ANA_RX_REG */ + 0xA0, 0x0D, 0x06, 0x42, 0x2D, 0x15, 0x45, 0x0D, 0x00, /* RF_CLIF_CFG_BR_848_I_RXA CLIF_SIGPRO_RM_CONFIG1_REG */ + 0xA0, 0x0D, 0x04, 0x46, 0x44, 0x22, 0x00, /* RF_CLIF_CFG_BR_106_I_RXB CLIF_ANA_RX_REG */ + 0xA0, 0x0D, 0x06, 0x46, 0x2D, 0x05, 0x59, 0x0E, 0x00, /* RF_CLIF_CFG_BR_106_I_RXB CLIF_SIGPRO_RM_CONFIG1_REG */ + 0xA0, 0x0D, 0x06, 0x44, 0x42, 0x88, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_BR_106_I_TXB CLIF_ANA_TX_AMPLITUDE_REG */ + 0xA0, 0x0D, 0x06, 0x56, 0x2D, 0x05, 0x9F, 0x0C, 0x00, /* RF_CLIF_CFG_BR_212_I_RXF_P CLIF_SIGPRO_RM_CONFIG1_REG */ + 0xA0, 0x0D, 0x06, 0x54, 0x42, 0x88, 0x00, 0xFF, 0xFF, /* RF_CLIF_CFG_BR_212_I_TXF CLIF_ANA_TX_AMPLITUDE_REG */ + 0xA0, 0x0D, 0x06, 0x0A, 0x33, 0x80, 0x86, 0x00, 0x70 /* RF_CLIF_CFG_I_ACTIVE CLIF_AGC_CONFIG0_REG */ +}; + +const unsigned char NxpNci_DiscoverMap[] = {0x21, 0x00, 0x10, 0x5, /* Discover Map Command */ + 0x1, 0x1, 0x1, 0x2, 0x1, 0x1, 0x3, 0x1, 0x1, 0x4, 0x1, 0x2, 0x80, 0x01, 0x80 /* DM_RW */ +}; + +const unsigned char NxpNci_StartDiscoveryChars[] = {0x21, 0x03, 0x09, 0x04, + 0x00, 0x01, /* MODE_POLL | TECH_PASSIVE_NFCA */ + 0x02, 0x01, /* MODE_POLL | TECH_PASSIVE_NFCF */ + 0x01, 0x01, /* MODE_POLL | TECH_PASSIVE_NFCB */ + 0x06, 0x01, /* MODE_POLL | TECH_PASSIVE_15693 */ +}; + +#endif diff --git a/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.c b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.c new file mode 100644 index 000000000..2b340c535 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.c @@ -0,0 +1,946 @@ +#include "LT_RFID.h" +#include "LT_NFC.h" + +#define NUM_OF_READERS 4 +#define T2T_BLOCK_SIZE 4 // tested only in NTAG216 + +#define READER_0_I2C I2C6_BASE +#define READER_0_EN_PORT GPIO_PORTK_BASE +#define READER_0_EN_PIN GPIO_PIN_1 +#define READER_0_IRQ_PORT GPIO_PORTK_BASE +#define READER_0_IRQ_PIN GPIO_PIN_2 +#define READER_1_I2C I2C6_BASE // to be changed +#define READER_1_EN_PORT GPIO_PORTK_BASE // to be changed +#define READER_1_EN_PIN GPIO_PIN_1 // to be changed +#define READER_1_IRQ_PORT GPIO_PORTK_BASE // to be changed +#define READER_1_IRQ_PIN GPIO_PIN_2 // to be changed +#define READER_2_I2C I2C6_BASE // to be changed +#define READER_2_EN_PORT GPIO_PORTK_BASE // to be changed +#define READER_2_EN_PIN GPIO_PIN_1 // to be changed +#define READER_2_IRQ_PORT GPIO_PORTK_BASE // to be changed +#define READER_2_IRQ_PIN GPIO_PIN_2 // to be changed +#define READER_3_I2C I2C6_BASE // to be changed +#define READER_3_EN_PORT GPIO_PORTK_BASE // to be changed +#define READER_3_EN_PIN GPIO_PIN_1 // to be changed +#define READER_3_IRQ_PORT GPIO_PORTK_BASE // to be changed +#define READER_3_IRQ_PIN GPIO_PIN_2 // to be changed + +bool readerInitialized[NUM_OF_READERS] = {false}; +bool readerFwVersion[NUM_OF_READERS] = {0}; + +bool SetReader(uint32_t readerID){ + switch(readerID){ + case 0: + I2C_Base = READER_0_I2C; + EN_Port = READER_0_EN_PORT; + EN_Pin = READER_0_EN_PIN; + IRQ_Port = READER_0_IRQ_PORT; + IRQ_Pin = READER_0_IRQ_PIN; + break; + case 1: + I2C_Base = READER_1_I2C; + EN_Port = READER_1_EN_PORT; + EN_Pin = READER_1_EN_PIN; + IRQ_Port = READER_1_IRQ_PORT; + IRQ_Pin = READER_1_IRQ_PIN; + break; + case 2: + I2C_Base = READER_2_I2C; + EN_Port = READER_2_EN_PORT; + EN_Pin = READER_2_EN_PIN; + IRQ_Port = READER_2_IRQ_PORT; + IRQ_Pin = READER_2_IRQ_PIN; + break; + case 3: + I2C_Base = READER_3_I2C; + EN_Port = READER_3_EN_PORT; + EN_Pin = READER_3_EN_PIN; + IRQ_Port = READER_3_IRQ_PORT; + IRQ_Pin = READER_3_IRQ_PIN; + break; + default: return false; + } + return true; +} + +RFID_RETURN_CODE RFID_Connect(uint32_t readerID){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + if(!NFC_Connect(&readerFwVersion[readerID])) + return ERR_CONNECTION; + if(!NFC_ConfigSettings()) + return ERR_CONFIG_SETTINGS; + if(!NFC_ConfigMode()) + return ERR_CONFIG_MODE; + readerInitialized[readerID] = true; + return SUCCESS; +} + +RFID_RETURN_CODE RFID_Disconnect(uint32_t readerID){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + NFC_Disconnect(); + readerInitialized[readerID] = false; + return SUCCESS; +} + +RFID_RETURN_CODE RFID_HardReset(uint32_t readerID){ + RFID_RETURN_CODE retCode = RFID_Disconnect(readerID); + if(retCode != SUCCESS) + return retCode; + return RFID_Connect(readerID); +} + +RFID_RETURN_CODE RFID_GetFwVersion(uint32_t readerID, uint32_t *fwVersion){ + if(readerID >= NUM_OF_READERS) + return ERR_UNDEFINED_READER; + if(!readerInitialized[readerID]) + return ERR_NOT_INITIALIZED; + *fwVersion = readerFwVersion[readerID]; + return SUCCESS; +} + +RFID_RETURN_CODE RFID_ConfigureSettings(RFID_SERTTINGS rfidSettings){ + // to be defined + return SUCCESS; +} + +RFID_RETURN_CODE RFID_StartDiscovery(uint32_t readerID){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + if(!readerInitialized[readerID]) + return ERR_NOT_INITIALIZED; + if(!NFC_StartDiscovery()) + return ERR_START_DISCOVERY; + return SUCCESS; +} + +RFID_RETURN_CODE RFID_StopDiscovery(uint32_t readerID){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + if(!readerInitialized[readerID]) + return ERR_NOT_INITIALIZED; + if(!NFC_StopDiscovery()) + return ERR_STOP_DISCOVERY; + return SUCCESS; +} + +RFID_RETURN_CODE RFID_WaitForDiscoveryNotification(uint32_t readerID, NxpNci_RfIntf_t *tagInfo){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + if(!readerInitialized[readerID]) + return ERR_NOT_INITIALIZED; + uint8_t retCode = NFC_WaitForDiscoveryNotification(tagInfo); + if(retCode == 1) + return SUCCESS; + else if(retCode == 2){ + if(!NFC_StopDiscovery()) + return ERR_STOP_DISCOVERY; + if(!NFC_StartDiscovery()) + return ERR_START_DISCOVERY; + } + return TAG_NOT_DETECTED; + +} + +bool ReadISO14443_3A(uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize){ + uint8_t commandRead[2] = {0x30}; + uint8_t answerSize = 0; + *succeededSize = 0; + while(*succeededSize < dataSize){ + commandRead[1] = startBlock + (*succeededSize / T2T_BLOCK_SIZE); + if(!NFC_ReaderTagCmd(commandRead, sizeof(commandRead), &data[*succeededSize], &answerSize)) + return false; + if(answerSize < (T2T_BLOCK_SIZE + 1)) + return false; + if(data[*succeededSize + answerSize - 1] != 0) + return false; + *succeededSize += answerSize - 1; + } + return true; +} + +int checkPwd(uint8_t *pwd, uint8_t *PACK) +{ + uint8_t commandWrite[1 + T2T_BLOCK_SIZE] = {0x1B}; + uint8_t tmpBuf[64]; + uint8_t answerSize = 0; + uint16_t dataSize = BLOCK_SIZE; + + memcpy(&commandWrite[1], pwd, dataSize); + if(!NFC_ReaderTagCmd(commandWrite, sizeof(commandWrite), tmpBuf, &answerSize)) + return -1; + if(answerSize < 2) + return -1; + if(tmpBuf[answerSize - 1] != 0) + return -1; + if ( tmpBuf[0] != PACK[0] || tmpBuf[1] != PACK[1] )// check PACK competability + return -2; + + return 1; +} + +bool setPwdValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *newPwd ) +{ + uint8_t succeededSize, pwdAddr = 0xE5; + //if ( pwdAuth( oldPwd, BLOCK_SIZE, &succeededSize) == true) + //{ + if ( RFID_CardModeSend( readerID, tagInfo, newPwd, pwdAddr, BLOCK_SIZE, &succeededSize) == SUCCESS ) + return true; + //} + return false; +} + +bool setPACKValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *newPwd ) +{ + uint8_t succeededSize, pwdAddr = 0xE6, dataSize = 2; + + if ( RFID_CardModeSend( readerID, tagInfo, newPwd, pwdAddr, dataSize, &succeededSize) == SUCCESS ) + return true; + + return false; +} + +bool activatePwd( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t startingBlock ) +{ + uint8_t pageData[100], dataAddr = 0xE3; + uint16_t succeededSize; + if ( RFID_CardModeReceive( readerID, tagInfo, pageData, dataAddr, BLOCK_SIZE, &succeededSize ) != SUCCESS ) + return false; + pageData[3] = startingBlock; + if ( RFID_CardModeSend( readerID, tagInfo, pageData, dataAddr, BLOCK_SIZE, &succeededSize) == SUCCESS ) + return true; + return false; + +} + +bool WriteISO14443_3A(uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize){ + uint8_t commandWrite[2 + T2T_BLOCK_SIZE] = {0xA2}; + uint8_t tmpBuf[64]; + uint8_t answerSize = 0; + *succeededSize = 0; + while(*succeededSize < dataSize){ + commandWrite[1] = startBlock + (*succeededSize / T2T_BLOCK_SIZE); + memcpy(&commandWrite[2], &data[*succeededSize], T2T_BLOCK_SIZE); + if(!NFC_ReaderTagCmd(commandWrite, sizeof(commandWrite), tmpBuf, &answerSize)) + return false; + if(answerSize < 2) + return false; + if(tmpBuf[answerSize - 1] != 0) + return false; + *succeededSize += T2T_BLOCK_SIZE; + } + if ( ( tmpBuf[0] & 0x0A ) == 0x0A ) + return true; + return false; +} + +bool ReadISO14443_4(uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize){ // test + #define KEY 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + uint8_t commandAuthenticate[] = {0x40, startBlock/4, 0x10, KEY}; + uint8_t answerSize = 0; + *succeededSize = 0; + if(!NFC_ReaderTagCmd(commandAuthenticate, sizeof(commandAuthenticate), data, &answerSize)) + return false; + if(data[answerSize-1] != 0) + return false; + + + return true; +} + +bool WriteISO14443_4(uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize){ // test + + + return false; +} + +RFID_RETURN_CODE RFID_CardModeReceive(uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + if(!readerInitialized[readerID]) + return ERR_NOT_INITIALIZED; + if(dataSize == 0) + return ERR_LENGTH; + if(tagInfo->Protocol == PROT_T2T){ + if(ReadISO14443_3A(data, startBlock, dataSize, succeededSize)) + return SUCCESS; + return ERR_TAG_MEMORY_READ; + } + else if(tagInfo->Protocol == PROT_ISODEP){ + if(ReadISO14443_4(data, startBlock, dataSize, succeededSize)) + return SUCCESS; + return ERR_TAG_MEMORY_READ; + } + return UNSUPPORTED_PROTOCOL; +} + +RFID_RETURN_CODE RFID_CardModeSend(uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize){ + if(!SetReader(readerID)) + return ERR_UNDEFINED_READER; + if(!readerInitialized[readerID]) + return ERR_NOT_INITIALIZED; + if(dataSize == 0) + return ERR_LENGTH; + if(tagInfo->Protocol == PROT_T2T){ + if(WriteISO14443_3A(data, startBlock, dataSize, succeededSize)) + return SUCCESS; + return ERR_TAG_MEMORY_WRITE; + } + if(tagInfo->Protocol == PROT_ISODEP){ + if(WriteISO14443_4(data, startBlock, dataSize, succeededSize)) + return SUCCESS; + return ERR_TAG_MEMORY_WRITE; + } + return UNSUPPORTED_PROTOCOL; +} + +bool IsTagValid(uint32_t readerID, NxpNci_RfIntf_t *tagInfo){ + uint8_t data[16], tagValid; + if ( ReadValue( readerID, tagInfo, data, 29, &tagValid ) == SUCCESS ) + return (bool)tagValid; + return false; + + + +} + +uint32_t GetCounter (uint32_t readerID, NxpNci_RfIntf_t *tagInfo) +{ + uint8_t data[16]; + uint32_t counter = 0; + if ( ReadValue( readerID, &tagInfo, data, 28, &counter ) == SUCCESS ) + return counter; + return 0; +} + +uint16_t GetBlockLocation(uint16_t byte) +{ + return byte / BLOCK_SIZE; +} + +void GetBlocksToRead( uint16_t* firstBlock, uint16_t* lastBlock, uint16_t beginByte, uint16_t length) +{ + *firstBlock = (uint16_t)(beginByte / BLOCK_SIZE); + *lastBlock = (uint16_t)( ( beginByte + length - 1 ) / BLOCK_SIZE); +} + +// the function gets a value and places it into an array that can be written back to the memory +RFID_RETURN_CODE SetFieldValueIntoBlocks( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *data, uint8_t* dataLen, uint8_t *value, uint8_t valueIndex ){ + uint16_t firstBlock, lastBlock; + RFID_RETURN_CODE retCode; + uint16_t succeededReadSize = 0; + GetBlocksToRead( &firstBlock, &lastBlock, Fields[valueIndex].fieldLocation, Fields[valueIndex].fieldLength ); + retCode = RFID_CardModeReceive( readerID, tagInfo, data, firstBlock, ( lastBlock - firstBlock + 1 ) * BLOCK_SIZE, &succeededReadSize); + *dataLen = 0; + if ( retCode == SUCCESS ) + { + //memcpy( data, dataRead, Fields[valueIndex].fieldLength ) ;//get current value of the memory + memcpy( &data[Fields[valueIndex].fieldLocation - firstBlock*BLOCK_SIZE], value, Fields[valueIndex].fieldLength ) ;// put the new value into the array + //memcpy( &data[Fields[valueIndex].fieldLocation + Fields[valueIndex].fieldLength], &dataRead[Fields[valueIndex].fieldLocation + Fields[valueIndex].fieldLength], succeededReadSize - Fields[valueIndex].fieldLocation - Fields[valueIndex].fieldLength ) ;//add the rest of the array (behind the value) + *dataLen = succeededReadSize > ( lastBlock - firstBlock + 1 ) * BLOCK_SIZE ? ( lastBlock - firstBlock + 1 ) * BLOCK_SIZE : succeededReadSize; + } + + return retCode; + +} + +RFID_RETURN_CODE WriteValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *value, uint8_t valueIndex, uint32_t valueNum ) +{ + RFID_RETURN_CODE retCode; + uint8_t dataSize; + int i; + uint8_t data[512], valueNumChar[4] = {0}; + uint16_t succeededSize = 0; + uint8_t startBlock; + if ( Fields[valueIndex].isNum == true ) + { + for ( i = Fields[valueIndex].fieldLength - 1; i >= 0 ; i-- ) + { + valueNumChar[i] = (uint8_t)valueNum; + valueNum >>= 8; + } + retCode = SetFieldValueIntoBlocks( readerID, tagInfo, data, &dataSize, valueNumChar, valueIndex); + } + else + retCode = SetFieldValueIntoBlocks( readerID, tagInfo, data, &dataSize, value, valueIndex); + if ( retCode != SUCCESS ) + return retCode; + startBlock = GetBlockLocation( Fields[valueIndex].fieldLocation ); + retCode = RFID_CardModeSend( readerID, tagInfo, data, startBlock, dataSize, &succeededSize); + return retCode; +} + +RFID_RETURN_CODE ReadValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *value, uint8_t valueIndex, uint32_t *valueNum ) +{ + RFID_RETURN_CODE retCode; + uint8_t i, data[512]; + uint16_t succeededSize = 0; + uint8_t startBlock = GetBlockLocation( Fields[valueIndex].fieldLocation ); + retCode = RFID_CardModeReceive( readerID, tagInfo, data, startBlock, Fields[valueIndex].fieldLength + BLOCK_SIZE, &succeededSize); + if ( retCode != SUCCESS ) + return retCode; + memcpy( value, &data[ Fields[valueIndex].fieldLocation % BLOCK_SIZE], Fields[valueIndex].fieldLength ) ; + if ( Fields[valueIndex].isNum == true ) + { + *valueNum = 0; + for ( i = 0; i < Fields[valueIndex].fieldLength; i++ ) + { + *valueNum += value[i]; + if ( i < Fields[valueIndex].fieldLength - 1 ) + *valueNum <<= 8; + } + } + return retCode; +} + +RFID_RETURN_CODE getUID( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *uid ) +{ + RFID_RETURN_CODE retCode = 0; + uint16_t succeededSize = 0, block = 0, bytes = 7; + uint8_t data[512]; + retCode = RFID_CardModeReceive( readerID, tagInfo, data, block, bytes, &succeededSize); + if ( retCode != SUCCESS ) + return retCode; + memcpy( uid, &data[0], 3 ) ;//first 3 bytes of block 0 + memcpy( &uid[3], &data[4], 4 ) ;//all 4 bytes of block 1 + return retCode; +} + +RFID_RETURN_CODE getPwd( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *pwd ) +{ + RFID_RETURN_CODE retCode = 0; + uint16_t succeededSize = 0, block = 230, bytes = 4; + retCode = RFID_CardModeReceive( readerID, tagInfo, pwd, block, bytes, &succeededSize); + if ( retCode != SUCCESS ) + return retCode; + return retCode; +} + +void InitFields() +{ + //serial + Fields[0].fieldLocation = 16; + Fields[0].fieldLength = 16; + Fields[0].isNum = false; + + //factory ID + Fields[1].fieldLocation = 32; + Fields[1].fieldLength = 3; + Fields[1].isNum = false; + //filling system ID + Fields[2].fieldLocation = 35; + Fields[2].fieldLength = 2; + Fields[2].isNum = true; + //work order + Fields[3].fieldLocation = 37; + Fields[3].fieldLength = 10; + Fields[3].isNum = false; + //color name + Fields[4].fieldLocation = 47; + Fields[4].fieldLength = 12; + Fields[4].isNum = false; + //category + Fields[5].fieldLocation = 59; + Fields[5].fieldLength = 2; + Fields[5].isNum = false; + //type + Fields[6].fieldLocation = 61; + Fields[6].fieldLength = 4; + Fields[6].isNum = true; + //cartSize + Fields[7].fieldLocation = 65; + Fields[7].fieldLength = 4; + Fields[7].isNum = true; + //inkVolume + Fields[8].fieldLocation = 69; + Fields[8].fieldLength = 4; + Fields[8].isNum = true; + //inkBatch + Fields[9].fieldLocation = 73; + Fields[9].fieldLength = 10; + Fields[9].isNum = false; + //inkMfgDate + Fields[10].fieldLocation = 83; + Fields[10].fieldLength = 8; + Fields[10].isNum = false; + //inkEolDate + Fields[11].fieldLocation = 91; + Fields[11].fieldLength = 8; + Fields[11].isNum = false; + //CartFillDate + Fields[12].fieldLocation = 99; + Fields[12].fieldLength = 8; + Fields[12].isNum = false; + //WasteFillDate + Fields[13].fieldLocation = 128; + Fields[13].fieldLength = 8; + Fields[13].isNum = false; + //Misc + Fields[14].fieldLocation = 136; + Fields[14].fieldLength = 4; + Fields[14].isNum = true; + //pluginCounter + Fields[15].fieldLocation = 140; + Fields[15].fieldLength = 2; + Fields[15].isNum = true; + //inkFill + Fields[16].fieldLocation = 142; + Fields[16].fieldLength = 1; + Fields[16].isNum = true; + //inkUsed + Fields[17].fieldLocation = 143; + Fields[17].fieldLength = 1; + Fields[17].isNum = true; + //inkEmpty + Fields[18].fieldLocation = 144; + Fields[18].fieldLength = 1; + Fields[18].isNum = true; + //wasteEmpty + Fields[19].fieldLocation = 145; + Fields[19].fieldLength = 1; + Fields[19].isNum = true; + //wasteFilling + Fields[20].fieldLocation = 146; + Fields[20].fieldLength = 1; + Fields[20].isNum = true; + //wasteFull + Fields[21].fieldLocation = 147; + Fields[21].fieldLength = 1; + Fields[21].isNum = true; + //blocked + Fields[22].fieldLocation = 148; + Fields[22].fieldLength = 1; + Fields[22].isNum = true; + //fail + Fields[23].fieldLocation = 149; + Fields[23].fieldLength = 1; + Fields[23].isNum = true; + //wasteCounter + Fields[24].fieldLocation = 150; + Fields[24].fieldLength = 2; + Fields[24].isNum = true; + //MachineIdInl + Fields[25].fieldLocation = 152; + Fields[25].fieldLength = 16; + Fields[25].isNum = false; + //MachineIdWst + Fields[26].fieldLocation = 168; + Fields[26].fieldLength = 16; + Fields[26].isNum = false; + //reserved + Fields[27].fieldLocation = 184; + Fields[27].fieldLength = 16; + Fields[27].isNum = false; + //counter + Fields[28].fieldLocation = 197; + Fields[28].fieldLength = 4; + Fields[28].isNum = true; + //tagValid + Fields[29].fieldLocation = 201; + Fields[29].fieldLength = 1; + Fields[29].isNum = true; + //hash + Fields[30].fieldLocation = 202; + Fields[30].fieldLength = 16; + Fields[30].isNum = false; +} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//MD5 +/* Constants for MD5Transform routine. + */ +#define S11 7 +#define S12 12 +#define S13 17 +#define S14 22 +#define S21 5 +#define S22 9 +#define S23 14 +#define S24 20 +#define S31 4 +#define S32 11 +#define S33 16 +#define S34 23 +#define S41 6 +#define S42 10 +#define S43 15 +#define S44 21 + +static void MD5Transform( uint32_t State[4], uint8_t Block[64] ); +static void Encode( uint8_t *, uint32_t *, uint32_t ); +static void Decode( uint32_t *, uint8_t *, uint32_t ); + +static uint8_t PADDING[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G, H and I are basic MD5 functions. */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define I(x, y, z) ((y) ^ ((x) | (~z))) + +/* ROTATE_LEFT rotates x left n bits. */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. */ +/* Rotation is separate from addition to prevent recomputation. */ +#define FF(a, b, c, d, x, s, ac) { \ + (a) += F ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define GG(a, b, c, d, x, s, ac) { \ + (a) += G ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define HH(a, b, c, d, x, s, ac) { \ + (a) += H ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } +#define II(a, b, c, d, x, s, ac) { \ + (a) += I ((b), (c), (d)) + (x) + (uint32_t)(ac); \ + (a) = ROTATE_LEFT ((a), (s)); \ + (a) += (b); \ + } + +/* + * MD5Init() + * MD5 initialization. Begins an MD5 operation, writing a new context. + */ +void MD5Init( MD5_CTX *context ) +{ + context->count[0] = context->count[1] = 0; + + /* Load magic initialization constants. */ + context->state[0] = 0x67452301; + context->state[1] = 0xefcdab89; + context->state[2] = 0x98badcfe; + context->state[3] = 0x10325476; +} + +/* + * MD5Update() + * + * MD5 block update operation. Continues an MD5 message-digest + * operation, processing another message block, and updating the + * context. + */ +void MD5Update( MD5_CTX *context, uint8_t *input, uint32_t inputLen) +{ + uint32_t i, index, partLen; + + /* Compute number of bytes mod 64 */ + index = (uint32_t)((context->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if( (context->count[0]+=((uint32_t)inputLen << 3)) < ((uint32_t)inputLen << 3) ) + context->count[1]++; + context->count[1] += ((uint32_t)inputLen >> 29); + + partLen = 64 - index; + + /* Transform as many times as possible. */ + if( inputLen >= partLen ) + { + memcpy((uint8_t *)&context->buffer[index], (uint8_t *)input, partLen); + MD5Transform (context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD5Transform (context->state, &input[i]); + + index = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy((uint8_t *)&context->buffer[index],(uint8_t *)&input[i],inputLen-i); +} + + +/* + * MD5Final() + * + * MD5 finalization. Ends an MD5 message-digest operation, writing the + * the message digest and zeroizing the context. + */ +void MD5Final( uint8_t digest[16], MD5_CTX *context ) +{ + uint8_t bits[8]; + uint32_t index, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64. */ + index = (uint32_t)((context->count[0] >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + MD5Update (context, PADDING, padLen); + + /* Append length (before padding) */ + MD5Update (context, bits, 8); + + /* Store state in digest */ + Encode( digest, context->state, 16 ); + + /* Zeroize sensitive information. */ + //mmZeroInit( (uint8_t *)context, sizeof(*context) ); + memset( (uint8_t *)context, 0, sizeof(*context)); +} + + +/* + * MD5Transform() + * + * MD5 basic transformation. Transforms state based on block. + */ +static void MD5Transform( uint32_t state[4], uint8_t block[64] ) +{ + uint32_t a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + + /* Round 1 */ + FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ + FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ + FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ + FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ + FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ + FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ + FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ + FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ + FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ + FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ + FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ + FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ + FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ + FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ + FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ + FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ + + /* Round 2 */ + GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ + GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ + GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ + GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ + GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ + GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ + GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ + GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ + GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ + GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ + GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ + GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ + GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ + GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ + GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ + GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ + + /* Round 3 */ + HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ + HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ + HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ + HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ + HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ + HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ + HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ + HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ + HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ + HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ + HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ + HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ + HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ + HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ + HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ + HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ + + /* Round 4 */ + II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ + II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ + II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ + II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ + II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ + II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ + II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ + II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ + II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ + II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ + II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ + II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ + II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ + II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ + II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ + II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ + + state[0] += a; + state[1] += b; + state[2] += c; + state[3] += d; + + /* Zeroize sensitive information. */ + //mmZeroInit( (uint8_t *)x, sizeof(x) ); + memset( (uint8_t *)x, 0, sizeof(x) ); +} + +/* + * Encode() + * + * Encodes input (uint32_t) into output (uint8_t). Assumes len is + * a multiple of 4. + */ +static void Encode( uint8_t *output, uint32_t *input, uint32_t len) +{ + uint32_t i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + { + output[j] = (uint8_t)(input[i] & 0xff); + output[j+1] = (uint8_t)((input[i] >> 8) & 0xff); + output[j+2] = (uint8_t)((input[i] >> 16) & 0xff); + output[j+3] = (uint8_t)((input[i] >> 24) & 0xff); + } +} + +/* + * Decode() + * + * Decodes input (uint8_t) into output (uint32_t). Assumes len is + * a multiple of 4. + */ +static void Decode( uint32_t *output, uint8_t *input, uint32_t len ) +{ + uint32_t i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((uint32_t)input[j]) | (((uint32_t)input[j+1]) << 8) | + (((uint32_t)input[j+2]) << 16) | (((uint32_t)input[j+3]) << 24); +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void calcHash( uint8_t *input, uint16_t inputLen, uint8_t *output ) +{ + MD5_CTX context; + //uint8_t md5Val[16] = {0}; + MD5Init( &context ); + MD5Update( &context, input, inputLen); + MD5Final( output, &context); +} + +bool setHashValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *uid, uint16_t inputLen ) +{ + RFID_RETURN_CODE retCode; + uint8_t hashValue[16], dummy = 0; + calcHash( uid, inputLen, hashValue); + retCode = WriteValue( readerID, tagInfo, hashValue, 30, dummy ); + if ( retCode == SUCCESS ) + return true; + return false; +} + +int checkHashValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *uid, uint16_t inputLen ) +{ + RFID_RETURN_CODE retCode; + uint8_t i, hashValueCalc[16], hashValueOnTag[16], dummy = 0; + int ret; + calcHash( uid, inputLen, hashValueCalc); + retCode = ReadValue( readerID, tagInfo, hashValueOnTag, 30, &dummy ); + if ( retCode == SUCCESS ) + { + for ( i = 0; i < 7; i++ ) + { + if ( hashValueCalc[i] != hashValueOnTag[i] ) + { + setTagInvalidAndLock( readerID, tagInfo ); + return -1; + } + + } + return 1; + } + return -2; +} + +bool lockDataSetOnInit( uint32_t readerID, NxpNci_RfIntf_t *tagInfo ) +{ + RFID_RETURN_CODE retCode; + uint16_t succeededSize = 0; + uint8_t block = 2, data[16]; + + retCode = RFID_CardModeReceive( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize); + if ( retCode == SUCCESS ) + { + data[2] = 0xFF; + data[3] = 0xFF; + retCode = RFID_CardModeSend( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize);//lock blocks 3 - 15 + if ( retCode == SUCCESS ) + { + block = 0xE2; + retCode = RFID_CardModeReceive( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize); + if ( retCode == SUCCESS ) + { + data[0] = 0x01;//lock pages 16 - 31 + retCode = RFID_CardModeSend( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize);//lock blocks 16 - 31 + if ( retCode == SUCCESS ) + { + return true; + } + } + + } + + } + return false; +} + +bool setTagInvalidAndLock( uint32_t readerID, NxpNci_RfIntf_t *tagInfo ) +{ + RFID_RETURN_CODE retCode; + uint16_t succeededSize = 0; + uint8_t block = 0xE2, data[16], tagValid = 0; + //set TagValid = 0 + retCode = WriteValue( readerID, tagInfo, data, 29, tagValid ); + //lock page 50, pages 48 - 63 (bit 02 of byte 1) + retCode = RFID_CardModeReceive( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize); + if ( retCode == SUCCESS ) + { + retCode = RFID_CardModeReceive( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize); + if ( retCode == SUCCESS ) + { + data[0] |= 0x08;//lock pages 48 - 63 (bit 02 of byte 1) + retCode = RFID_CardModeSend( readerID, tagInfo, data, block, BLOCK_SIZE, &succeededSize); + if ( retCode == SUCCESS ) + { + return true; + } + } + + } + return false; +} + +int incrementCounterAndCompare( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, int limit ) +{ + RFID_RETURN_CODE retCode; + uint16_t succeededSize = 0; + uint32_t counter; + uint8_t tagMemory[1024]; + retCode = ReadValue( readerID, tagInfo, tagMemory, 28, &counter ); + if ( retCode != SUCCESS ) + return -2; + if ( counter >= limit ) + return -1; + counter++; + retCode = WriteValue( readerID, tagInfo, tagMemory, 28, counter ); + if ( retCode != SUCCESS ) + return -2; + return 1; +} + diff --git a/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.h b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.h new file mode 100644 index 000000000..315831f91 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Drivers/logi-tag/LT_RFID.h @@ -0,0 +1,97 @@ +#ifndef LT_RFID_H +#define LT_RFID_H + +#include "include.h" +#include "LT_NFC_Info.h" + +typedef enum { + SUCCESS = 0, + ERR_UNDEFINED_READER, + ERR_NOT_INITIALIZED, + ERR_CONNECTION, + ERR_CONFIG_SETTINGS, + ERR_CONFIG_MODE, + ERR_START_DISCOVERY, + ERR_STOP_DISCOVERY, + ERR_LENGTH, + ERR_TAG_MEMORY_READ, + ERR_TAG_MEMORY_WRITE, + TAG_NOT_DETECTED, + UNSUPPORTED_PROTOCOL +} RFID_RETURN_CODE; + +#define CCM_LOOP_TIMEOUT 500000 + +/* +volatile bool g_bContextReadyFlag; +volatile bool g_bParthashReadyFlag; +volatile bool g_bInputReadyFlag; +volatile bool g_bOutputReadyFlag; +volatile bool g_bContextInDMADoneFlag; +volatile bool g_bDataInDMADoneFlag; +volatile bool g_bContextOutDMADoneFlag; +*/ + +/* MD5 context. */ +typedef struct { + uint32_t state[4]; /* state (ABCD) */ + uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD5_CTX; + +#define BLOCK_SIZE 4 +#define BLK_TAG_VALID 49 +#define BLK_COUNTER 48 +#define NUMBER_OF_FIELDS 32 +typedef struct{ + // to be defined +} RFID_SERTTINGS; + +typedef struct{ + uint16_t fieldLocation; + uint16_t fieldLength; + bool isNum; +} FIELDS_LOCATIONS; + +FIELDS_LOCATIONS Fields[NUMBER_OF_FIELDS]; + +RFID_RETURN_CODE RFID_Connect(uint32_t readerID); +RFID_RETURN_CODE RFID_Disconnect(uint32_t readerID); +RFID_RETURN_CODE RFID_HardReset(uint32_t readerID); +RFID_RETURN_CODE RFID_GetFwVersion(uint32_t readerID, uint32_t *fwVersion); +RFID_RETURN_CODE RFID_ConfigureSettings(RFID_SERTTINGS rfidSettings); +RFID_RETURN_CODE RFID_StartDiscovery(uint32_t readerID); +RFID_RETURN_CODE RFID_StopDiscovery(uint32_t readerID); +RFID_RETURN_CODE RFID_WaitForDiscoveryNotification(uint32_t readerID, NxpNci_RfIntf_t *pRfIntf); +RFID_RETURN_CODE RFID_CardModeReceive(uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize); +RFID_RETURN_CODE RFID_CardModeSend(uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *data, uint8_t startBlock, uint16_t dataSize, uint16_t *succeededSize); +bool IsTagValid(uint32_t readerID, NxpNci_RfIntf_t *tagInfo); +uint32_t GetCounter (uint32_t readerID, NxpNci_RfIntf_t *tagInfo); +RFID_RETURN_CODE WriteValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *value, uint8_t valueIndex, uint32_t valueNum ); +RFID_RETURN_CODE ReadValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *value, uint8_t valueIndex, uint32_t *valueNum ); +RFID_RETURN_CODE getUID( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *uid ); +void calcHash( uint8_t *input, uint16_t inputLen, uint8_t *output ); +bool setHashValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *uid, uint16_t inputLen ); +int checkHashValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *uid, uint16_t inputLen ); +RFID_RETURN_CODE getPwd( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *pwd ); +int checkPwd(uint8_t *pwd, uint8_t *PACK ); +bool setPwdValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *newPwd ); +bool setPACKValue( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *newPwd ); +bool activatePwd( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t startingBlock ); +bool lockDataSetOnInit( uint32_t readerID, NxpNci_RfIntf_t *tagInfo ); +bool setTagInvalidAndLock( uint32_t readerID, NxpNci_RfIntf_t *tagInfo ); +int incrementCounterAndCompare( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, int limit ); +///////////////////////////////////////////////////////////////////////////////////// +void MD5Init( MD5_CTX * ); +void MD5Update( MD5_CTX *, unsigned char *, unsigned int ); +void MD5Final( unsigned char results[16], MD5_CTX * ); + +////////////////////////////////////// +// helpers +void InitFields(); +void SetFieldsLocationLen(); +uint16_t GetBlockLocation(uint16_t byte); +void GetBlocksToRead( uint16_t* firstBlock, uint16_t* lastBlock, uint16_t beginByte, uint16_t length); +RFID_RETURN_CODE SetFieldValueIntoBlocks( uint32_t readerID, NxpNci_RfIntf_t *tagInfo, uint8_t *data, uint8_t* dataLen, uint8_t *value, uint8_t valueIndex ); +///////////////////////////////////// +#endif diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 8cdb27e47..1f8651545 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -169,7 +169,7 @@ Program.global.adcProcess = Task.create("&ADCProcessTask", ADCProcessTaskParams) var ReportTaskParams = new Task.Params(); ReportTaskParams.instance.name = "report"; -ReportTaskParams.stackSize = 2048; +ReportTaskParams.stackSize = 4096; ReportTaskParams.priority = 7; Program.global.report = Task.create("&reportService", ReportTaskParams); diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index 44caacc55..6d5dc00b2 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -215,21 +215,21 @@ AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ /* 7006 */ {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__DISPENSER_7_OVERPRESSURE}, /* 7007 */ {eOneSecond,ALARM_SOURCE_TYPE__DoNotPollAlarm,0,0,0,0,DEBUG_LOG_CATEGORY__Critical,0xFF,0,EVENT_TYPE__DISPENSER_8_OVERPRESSURE}, -/* 8000 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_1_LOW_LEVEL}, -/* 8001 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_2_LOW_LEVEL}, -/* 8002 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_3_LOW_LEVEL}, -/* 8003 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_4_LOW_LEVEL}, -/* 8004 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_5_LOW_LEVEL}, -/* 8005 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_6_LOW_LEVEL}, -/* 8006 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_7_LOW_LEVEL}, -/* 8007 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,500/*500cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_8_LOW_LEVEL}, +/* 8000 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_1_LOW_LEVEL}, +/* 8001 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_2_LOW_LEVEL}, +/* 8002 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_3_LOW_LEVEL}, +/* 8003 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_4_LOW_LEVEL}, +/* 8004 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_5_LOW_LEVEL}, +/* 8005 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_6_LOW_LEVEL}, +/* 8006 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_7_LOW_LEVEL}, +/* 8007 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,300/*300cc*/,false,DEBUG_LOG_CATEGORY__Warning, 0xFF,2,EVENT_TYPE__MID_TANK_8_LOW_LEVEL}, /* 8008 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_1_EMPTY}, /* 8009 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,1,1,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_2_EMPTY}, /* 8010 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,2,2,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_3_EMPTY}, /* 8011 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_4_EMPTY}, /* 8012 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_5_EMPTY}, /* 8013 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_6_EMPTY}, -/* 8014 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_EMPTY}, +/* 8014 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_EMPTY}, /* 8015 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,200/*200cc*/,false,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_8_EMPTY}, /* 8016 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,0,0,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_1_OVERFLOW}, @@ -238,7 +238,7 @@ AlarmHandlingItemStruc HardCodedAlarmItem[MAX_SYSTEM_ALARMS]={ /* 8019 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,3,3,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_4_OVERFLOW}, /* 8020 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,4,4,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_5_OVERFLOW}, /* 8021 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,5,5,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_6_OVERFLOW}, -/* 8022 */ //{eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_OVERFLOW}, +/* 8022 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,6,6,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_7_OVERFLOW}, /* 8023 */ {eOneSecond,ALARM_SOURCE_TYPE__FluidLevelAlarm,7,7,1800/*1800cc*/,true,DEBUG_LOG_CATEGORY__Error, 0xFF,2,EVENT_TYPE__MID_TANK_8_OVERFLOW}, @@ -989,7 +989,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) { int Alarm_i; uint32_t value; - uint32_t valueL; + double doubleValue = 0.0; +/* uint32_t valueL; uint32_t valueR; uint32_t valueN; uint32_t drawer_big; @@ -997,8 +998,7 @@ uint32_t AlarmHandlingLoop(uint32_t tick) uint32_t drawer_small1; uint32_t drawer_small2; uint32_t drawer_small3; - - double doubleValue = 0.0; +*/ @@ -1126,6 +1126,11 @@ uint32_t AlarmHandlingLoop(uint32_t tick) case ALARM_SOURCE_TYPE__MotorAlarm: if (CheckMotorAlarms) { + if (FPGA_WD_Occurred == true) + { + Status = false; + break; + } if (isMotorConfigured((TimerMotors_t)AlarmItem[Alarm_i].DeviceId) == false) { Status = false; @@ -1189,12 +1194,12 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if (AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Critical ) { value = getSystemFansStatus(); - valueR = value & MASKSYSTEMRIGHT; +/* valueR = value & MASKSYSTEMRIGHT; valueL = value & MASKSYSTEMLEFT; valueN = value & MASKSYSTEMnotUSED; - /*if (valueR) + if (valueR) ReportWithPackageFilter(AlarmFilter,"----------- Right FAN System is not connected----------------", __FILE__,__LINE__,valueR, RpMessage, value, 0); else ReportWithPackageFilter(AlarmFilter,"----------- Right FAN System is connected----------------", __FILE__,__LINE__,valueR, RpMessage, value, 0); @@ -1217,12 +1222,12 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if (AlarmItem[Alarm_i].Severity == DEBUG_LOG_CATEGORY__Critical ) { value = getDrawerFansStatus(); - drawer_big = value & MASKDRYERBIG; +/* drawer_big = value & MASKDRYERBIG; drawer_small0 = value & MASKDRYERSMALL0; drawer_small1 = value & MASKDRYERSMALL1; drawer_small2 = value & MASKDRYERSMALL2; drawer_small3 = value & MASKDRYERSMALL3; -/* + if (drawer_big) ReportWithPackageFilter(AlarmFilter,"----------- drawer_big FAN is not connected----------------", __FILE__,__LINE__,drawer_big, RpMessage, value, 0); else diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 28febe8f2..2f4a1e2d2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -41,6 +41,7 @@ #include "Drivers/I2C_Communication/I2C.h" #include "modules/thread/thread_ex.h" +#include "modules/ifs/ifs.h" #include "modules/ids/ids_ex.h" #include "modules/Diagnostics/Diagnostics.h" #include "Modules/General/MachineStatus.h" @@ -662,6 +663,7 @@ uint32_t MillisecLowLoop(uint32_t tick) PumpActivation(900); PumpCounter = 0; } + MidTankReading(); } //ROM_IntMasterEnable(); diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index b7d117efe..1f5e008d3 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -172,6 +172,8 @@ uint32_t ControlActivityLed( uint32_t Parameter1) ACTIVITY_GREEN_LED_ON; HWConfigurationInit(); } + else + ACTIVITY_GREEN_LED_OFF; if(power.color == fastBILNK) Pannel_Leds(POWER_ON_OFF,MODE_OFF); diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c index 497556878..38f9b73ba 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticsHoming.c @@ -58,7 +58,7 @@ return OK; uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { uint32_t numberOfSteps = 0; - uint32_t LoadArmRounds = 0; + uint32_t LoadArmRounds = (int)dryerbufferlength; MessageContainer responseContainer; @@ -67,14 +67,8 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) MotorHomingResponse response = MOTOR_HOMING_RESPONSE__INIT; TimerMotors_t MotorId = (TimerMotors_t)request->motortype; - - if (dryerbufferlength) - LoadArmRounds = (int)dryerbufferlength; - else - MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmRounds); - if (LoadArmRounds <= 2) - LoadArmRounds = 20; + LoadArmRounds = 30; int speed = request->speed; if (speed == 0) speed = 150; @@ -96,8 +90,11 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) { numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmRounds*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; Report("MotorHomingRequestFunc Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,numberOfSteps,RpMessage,LoadArmRounds,0); - MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), - numberOfSteps, MotorHomingRequestCallback,1000); + MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), + MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/2, MotorHomingRequestCallback,0,1000); + + //MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), + // numberOfSteps, MotorHomingRequestCallback,1000); return OK; } if ( Motor_Id_to_LS_IdDown[MotorId] != MAX_GPI) @@ -120,7 +117,7 @@ uint32_t MotorHomingRequestFunc(MessageContainer* requestContainer) if(MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { if (LoadArmRounds <= 2) - LoadArmRounds = 20; + LoadArmRounds = 30; numberOfSteps = MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround*LoadArmRounds*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulleyradius; numberOfSteps -= 100; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index 40bc50b4f..fab62d6ee 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -184,7 +184,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->has_dispenserbuildpressurelimit = true; EmbeddedParameters->dispenserbuildpressurelimit=1.0 ; EmbeddedParameters->has_dispenserbuildpressuretimeout = true; - EmbeddedParameters->dispenserbuildpressuretimeout=60000; + EmbeddedParameters->dispenserbuildpressuretimeout=150000; EmbeddedParameters->has_dispenserbuildpressurelag = true; EmbeddedParameters->dispenserbuildpressurelag=50; EmbeddedParameters->has_acheatersloweroperationlimit = true; @@ -212,7 +212,7 @@ void LoadConfigurationParameters(ConfigurationParameters *Params) EmbeddedParameters->generalparameters[4] = 800.0; //Winder homing time at end of job EmbeddedParameters->generalparameters[5] = 1000.0; //Dispenser initial pressure speed EmbeddedParameters->generalparameters[6] = Diagnostic_Extended_Mode; //Diagnostic Mode SetDiagnosticMode - EmbeddedParameters->generalparameters[7] = AutoHoming_PowerOn_off; // + EmbeddedParameters->generalparameters[7] = AutoHoming_JobEnd_PowerOn_off; // } EmbeddedParameters->has_currentalarmlowlimit = true; EmbeddedParameters->currentalarmlowlimit = 0.78; @@ -295,7 +295,7 @@ uint32_t EmbeddedParametersInit(void) } else { - IDS_Dispenser_SetBackLashValues(EmbeddedParameters->initialdispenserpressure, EmbeddedParameters->initialdispensertimeout, EmbeddedParameters->initialdispensertimelag,900); + IDS_Dispenser_SetBackLashValues(EmbeddedParameters->initialdispenserpressure, EmbeddedParameters->initialdispensertimeout, EmbeddedParameters->initialdispensertimelag,1000); } IDS_Dispenser_SetTimeOutValues(EmbeddedParameters->closevalvetimeout, EmbeddedParameters->openvalvetimeout); @@ -437,6 +437,8 @@ uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) { for (Dispenser_i = 0; Dispenser_i < request->n_dispensers ; Dispenser_i++) { + Valve_Set(IDS_Id_to_AirValve[Dispenser_i], Atm_MidTank_OFF ); //Atm_MidTank_OFF/ON + Valve_Set(IDS_Id_to_CartrideValve[Dispenser_i], Atm_MidTank_OFF ); //Atm_MidTank_OFF/ON status += DispenserConfigMessage(request->dispensers[Dispenser_i]); if (Check_Dispenser_Type(request->dispensers[Dispenser_i]->index) == LS_STATUS_ERROR) { @@ -565,12 +567,13 @@ uint32_t MidTankDataSetupFunc(MessageContainer* requestContainer) Report("MidTankData Read", __FILE__,__LINE__,(int)(a*1000), RpMessage, (int)(b*1000), 0); } //debug only + /* Task_sleep(1000); MCU_E2PromSerialNumProgram ("Take me to the sky"); memset (Serial,0,20); MCU_E2PromSerialNumRead(&Serial); Report(Serial, __FILE__,__LINE__,22, RpMessage, 21, 0); - + */ MidTankDataSetupResponse response = MID_TANK_DATA_SETUP_RESPONSE__INIT; @@ -642,8 +645,14 @@ void HWSystemResetRequest(MessageContainer* requestContainer) uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); SendChars((char*)container_buffer, container_size); + Report("HWSystemResetRequest before sleep", __FILE__,__LINE__,0, RpMessage, 2, 0); + + //ROM_SysCtlDelay(SYS_CLK_FREQ); + Task_sleep(2000); + Report("HWSystemResetRequest after sleep", __FILE__,__LINE__,2, RpMessage, 4, 0); - ROM_SysCtlDelay(SYS_CLK_FREQ); + //ROM_SysCtlDelay(SYS_CLK_FREQ); + Task_sleep(2000); SysCtlReset(); diff --git a/Software/Embedded_SW/Embedded/Modules/General/Safety.c b/Software/Embedded_SW/Embedded/Modules/General/Safety.c index 73736f8d4..139763c75 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/Safety.c +++ b/Software/Embedded_SW/Embedded/Modules/General/Safety.c @@ -39,9 +39,10 @@ void Safety_Init(void) uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) { int Disp_i; + bool Indication = false; bool AllDispensersInSafety = true; bool AnyDispensersInSafety = false; - bool DispenserBypass = false; + //bool DispenserBypass = false; bool mDrierDoorAlarmState = false; bool mAirFlowAlarmState = false; bool mAirFilterAlarmState = false; @@ -50,8 +51,9 @@ uint32_t Safety_Main_State(uint32_t IfIndex, uint32_t BusyFlag) { if (isMotorConfigured(Disp_i + HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1)==true) { - AllDispensersInSafety &= Check_Disp_Safety_Stop_Indication(Disp_i); - AnyDispensersInSafety |= Check_Disp_Safety_Stop_Indication(Disp_i); + Indication = Check_Disp_Safety_Stop_Indication(Disp_i); + AllDispensersInSafety &= Indication; + AnyDispensersInSafety |= Indication; } } diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.c b/Software/Embedded_SW/Embedded/Modules/General/process.c index b74ba79b3..d7de5797d 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.c +++ b/Software/Embedded_SW/Embedded/Modules/General/process.c @@ -65,9 +65,9 @@ void HeatersStopControlOnHeatersOff(ProcessParameters* ProcessParams) REPORT_MSG(temp_sum,"Heating control off - temperatures off"); } } -uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) +uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData) { - uint32_t status = 0; + uint32_t status = 0,Bytes = 0; if (ProcessParams==NULL) { status = ERROR_CODE__INVALID_PARAMETER; @@ -89,7 +89,19 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) { memcpy (&ProcessParametersKeep,ProcessParams,sizeof(ProcessParameters)); } - if (ProcessParams->mixertemp) + if (saveData == true) + { + if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters + { + Bytes = sizeof(ProcessParameters); + FileWrite(ProcessParams,Bytes,ProcessParamsConfigPath,BIOS_WAIT_FOREVER); + EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH,Bytes+4); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); + ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); + REPORT_MSG(Bytes,"Bytes write to flash"); + } + } + if (ProcessParams->mixertemp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__MixerHeater, true, ProcessParams->mixertemp); @@ -97,7 +109,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__MixerHeater, false, ProcessParams->mixertemp); - if (ProcessParams->headzone1temp) + if (ProcessParams->headzone1temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, true, ProcessParams->headzone1temp); @@ -105,7 +117,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, false, ProcessParams->headzone1temp); - if (ProcessParams->headzone2temp) + if (ProcessParams->headzone2temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, true, ProcessParams->headzone2temp); @@ -113,7 +125,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, false, ProcessParams->headzone2temp); - if (ProcessParams->headzone3temp) + if (ProcessParams->headzone3temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3, true, ProcessParams->headzone3temp); @@ -121,7 +133,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ3, false, ProcessParams->headzone3temp); - if (ProcessParams->headzone4temp) + if (ProcessParams->headzone4temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4, true, ProcessParams->headzone4temp); @@ -129,7 +141,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4, false, ProcessParams->headzone4temp); - if (ProcessParams->headzone5temp) + if (ProcessParams->headzone5temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5, true, ProcessParams->headzone5temp); @@ -137,7 +149,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5, false, ProcessParams->headzone5temp); - if (ProcessParams->headzone6temp) + if (ProcessParams->headzone6temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6, true, ProcessParams->headzone6temp); @@ -145,7 +157,7 @@ uint32_t HandleProcessParameters(ProcessParameters* ProcessParams) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6, false, ProcessParams->headzone6temp); - if (ProcessParams->dryerzone1temp) + if (ProcessParams->dryerzone1temp>1) status |= HeaterCommandRequestMessage( HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, true, ProcessParams->dryerzone1temp); @@ -193,20 +205,9 @@ void ProcessRequestFunc(MessageContainer* requestContainer) MessageContainer responseContainer; uint8_t* container_buffer; uint32_t status = 0; - uint32_t Bytes = 0; UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ProcessParameters* ProcessParams = request->processparameters; - if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters - { - FileWrite(requestContainer->data.data, requestContainer->data.len,ProcessParamsConfigPath,BIOS_WAIT_FOREVER); - Bytes = sizeof(ProcessParameters); - EraseFlashSection(PROCESS_PARAMETERS_MAP_IN_FLASH,Bytes+4); - ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH, 4,&Bytes); - ReadAppAndProgram(PROCESS_PARAMETERS_MAP_IN_FLASH+4, Bytes, ProcessParams); - REPORT_MSG(Bytes,"Bytes write to flash"); - - } //////////////////////////////////////////////////////////////////////// /*UploadProcessParametersRequest* requesttest; uint8_t* buffer = NULL; @@ -234,7 +235,7 @@ void ProcessRequestFunc(MessageContainer* requestContainer) PowerIdleOutOfIdleState(); if (status == 0) - status = HandleProcessParameters(ProcessParams); + status = HandleProcessParameters(ProcessParams,true); if (status) { responseContainer.has_error = true; @@ -255,10 +256,9 @@ uint32_t LoadProcessParamsFromFile(void) Fresult = FileRead(ProcessParamsConfigPath, &Bytes, &buffer); if (Fresult == FR_OK) { - UploadProcessParametersRequest* request = upload_process_parameters_request__unpack(NULL, Bytes, buffer); - ProcessParameters* ProcessParams = request->processparameters; + ProcessParameters* ProcessParams = (ProcessParameters*)buffer; - if ((request!= NULL)&&(ProcessParams!=NULL)) + if (ProcessParams!=NULL) { if ((ProcessParams->dryerzone1temp > 0.1)&&(ProcessParams->headzone2temp > 0.1)&&(ProcessParams->headzone3temp > 0.1)&&(ProcessParams->headzone4temp > 0.1))//NOT turning off heaters { @@ -272,7 +272,7 @@ uint32_t LoadProcessParamsFromFile(void) } else { - Report("process parameters not loaded",__FILE__,__LINE__,(int)request,RpWarning,(int)request,0); + Report("process parameters not loaded",__FILE__,__LINE__,(int)0,RpWarning,(int)0,0); return ERROR; } } @@ -290,7 +290,7 @@ uint32_t ProcessParamsInit(void) if ((Bytes)&&(Bytes < 1000)) { ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); - Fresult = HandleProcessParameters(ProcessParams); + Fresult = HandleProcessParameters(ProcessParams,false); } else { @@ -302,7 +302,7 @@ uint32_t ProcessParamsInit(void) if ((Bytes)&&(Bytes < 1000)) { ProcessParameters* ProcessParams = (ProcessParameters *)(PROCESS_PARAMETERS_MAP_IN_FLASH+4); - Fresult = HandleProcessParameters(ProcessParams); + Fresult = HandleProcessParameters(ProcessParams,false); } } } diff --git a/Software/Embedded_SW/Embedded/Modules/General/process.h b/Software/Embedded_SW/Embedded/Modules/General/process.h index 2b02c28c7..97d28f1ef 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/process.h +++ b/Software/Embedded_SW/Embedded/Modules/General/process.h @@ -25,7 +25,7 @@ extern double dryerbufferCentimeters; extern ProcessParameters ProcessParametersKeep; extern void ProcessRequestFunc(MessageContainer* requestContainer); -extern uint32_t HandleProcessParameters(ProcessParameters* ProcessParams); +extern uint32_t HandleProcessParameters(ProcessParameters* ProcessParams,bool saveData); uint32_t ProcessParamsInit(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index b05f236c5..4d1fbddba 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -37,6 +37,7 @@ #include "drivers/I2C_Communication/ADC_MUX/ADC_MUX.h" #include "StateMachines/Printing/PrintingSTM.h" +#include "StateMachines/Initialization/PowerIdle.h" /******************** Data Structures ********************************************/ diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h index 3e2cf6ecb..eba93d445 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS.h @@ -12,10 +12,10 @@ extern uint32_t DispenserPrepareSpeed ; extern double DispenserPreparePressure ; extern uint32_t DispenserPrepareTimeout ; extern uint32_t DispenserPrepareTimeLag ; +extern uint32_t InitialDispenserSpeed; extern int32_t CurrentDispenserSpeed[MAX_SYSTEM_DISPENSERS]; extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS]; -extern bool JobStartStopBackLash[MAX_SYSTEM_DISPENSERS]; extern float DispenserPressure[MAX_SYSTEM_DISPENSERS]; uint32_t DispenserConfigMessage(HardwareDispenser * request); @@ -26,6 +26,7 @@ extern bool DispensersAlarmState[ MAX_SYSTEM_DISPENSERS]; extern uint32_t DispenserIdToMotorId[MAX_SYSTEM_DISPENSERS]; extern bool HomingActive[MAX_SYSTEM_DISPENSERS]; +extern bool PrimingActive[MAX_SYSTEM_DISPENSERS]; uint32_t IDS_Dispenser_EmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 9c15885fc..3d1ba6e78 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -189,7 +189,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee DispenserCallback[DispenserId] = callback; TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; - if (CurrentDispenserSpeed[DispenserId]) //motor already running + /*if (CurrentDispenserSpeed[DispenserId]) //motor already running { MotorSetSpeed(HW_Motor_Id, MotorSpeed); CurrentDispenserSpeed[DispenserId] = MotorSpeed; @@ -200,7 +200,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee } } else - { + {*/ MotorSetSpeed(HW_Motor_Id, MotorSpeed); CurrentDispenserSpeed[DispenserId] = MotorSpeed; if (DispenserControlId[DispenserId] != 0xFF) @@ -212,7 +212,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee 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); - } + //} return OK; } @@ -224,7 +224,7 @@ char DispenserStorePath[50] = "0://SysInfo//DispStor.cfg"; void IDS_Dispenser_Content_Init (void) { int i; - FRESULT Fresult = FR_OK; + //FRESULT Fresult = FR_OK; void* buffer = NULL; TimerMotors_t HW_Motor_Id; uint32_t Bytes = 0; @@ -287,7 +287,7 @@ uint16_t seconds_counter = 0; bool DispenserDataUpdated = false; uint32_t IDS_Dispenser_Store_Data (void) { - uint32_t timing = msec_millisecondCounter; + //uint32_t timing = msec_millisecondCounter; FRESULT Status = FR_OK; IDSDispenserData.n_dispenserinfo = MAX_SYSTEM_DISPENSERS; IDSDispenserData.dispenserinfo = dispenserdata; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index ac3928c3e..9074f867a 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -68,9 +68,11 @@ uint32_t IDS_StopLubrication(void); uint32_t IDS_DispenserPidRequestMessage(HardwarePidControl* request); uint32_t IDS_DispenserControlInit(); +void IDS_Dispenser_Init(uint8_t DispenserId); uint32_t IDS_HomeDispenser (uint32_t deviceID, uint32_t speed , callback_fptr callback); uint32_t IDS_StopHomeDispenser (uint32_t deviceID); uint32_t IDS_HomeDispenserWaitForHomingEnd(uint32_t DispenserId, uint32_t timeout , callback_fptr callback); +bool IDS_IsHomingActive(uint32_t DispenserId); 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 db6184fdb..5fe02bb71 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_maint.c @@ -143,16 +143,16 @@ uint32_t IDS_HomeDispenserWaitForHomingEnd(uint32_t DispenserId, uint32_t timeo return OK; } -uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) +/*uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) { uint8_t DispenserId = motorId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1; - if ((GetDispenserPressure(DispenserId)>=InitialDispenserPressure)||(DispenserHomingTime[DispenserId]>InitialDispenserTimeout)||(JobStartStopBackLash[DispenserId] == true)) + if ((GetDispenserPressure(DispenserId)>=InitialDispenserPressure)||(DispenserHomingTime[DispenserId]>InitialDispenserTimeout)) { MotorStop(motorId,Hard_Hiz); CurrentDispenserSpeed[DispenserId] = 0; if (Extended_Motor_Param == true) Power_Step_01_Dispenser_Mode(DispenserId,Voltage); - MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); + //MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); HomingActive[DispenserId]= false; PrimingActive[DispenserId]= false; Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE @@ -161,8 +161,6 @@ uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); Disable_MidTank_Pressure_Reading(DispenserId); - if (JobStartStopBackLash[DispenserId] == true) - JobStartStopBackLash[DispenserId] = false; Report("End backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); if (SafeRemoveControlCallback(DispenserHomingControlId[DispenserId], IDS_HomeDispenserBackMoveCallback )==OK) DispenserHomingControlId[DispenserId] = 0xFF; @@ -175,23 +173,16 @@ uint32_t IDS_HomeDispenserBackMoveCallback(uint32_t motorId, uint32_t ReadValue) DispenserHomingTime[DispenserId]+=InitialDispenserTimeLag; } return OK; -} +}*/ uint32_t IDS_HomeDispenserCallback(uint32_t motorId, uint32_t ReadValue) { uint8_t DispenserId = motorId-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1; - MotorStop(motorId,Hard_Hiz); - CurrentDispenserSpeed[DispenserId] = 0; - if (Extended_Motor_Param == true) - Power_Step_01_Dispenser_Mode(DispenserId,Voltage); Read_MidTank_Pressure_Sensor(DispenserId); //close dry air valve in the dispenser - Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); - Disable_MidTank_Pressure_Reading(DispenserId); - MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); - HomingActive[DispenserId]= false; - PrimingActive[DispenserId]= false; - Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE + //Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); + //Disable_MidTank_Pressure_Reading(DispenserId); + // MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); if (HomingRequestCallback[DispenserId]) { HomingRequestCallback[DispenserId](DispenserId,0); @@ -199,16 +190,31 @@ uint32_t IDS_HomeDispenserCallback(uint32_t motorId, uint32_t ReadValue) } // HomingActive[DispenserId]= false; IDS_Dispenser_RefillEnded ( DispenserId, MotorsCfg[motorId].microstep); - Report("End homing no backlash backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - /*Report("Start backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - DispenserHomingControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); + Report("Homing ended",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); +// DispenserHomingControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); MotorSetDirection(motorId,MotorsCfg[motorId].directionthreadwize); Task_sleep(10); - MotorSetSpeed(motorId, InitialDispenserSpeed); - CurrentDispenserSpeed[DispenserId] = InitialDispenserSpeed;*/ +// MotorSetSpeed(motorId, InitialDispenserSpeed); + CurrentDispenserSpeed[DispenserId] = 0; +///////////////////////////////////////////////////////////// + if (Extended_Motor_Param == true) + Power_Step_01_Dispenser_Mode(DispenserId,Voltage); + //MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); + HomingActive[DispenserId]= false; + PrimingActive[DispenserId]= false; + Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE + + //close dry air valve in the dispenser + Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); + Disable_MidTank_Pressure_Reading(DispenserId); + + //////////////////////////////////////////////////////// return OK; } - +bool IDS_IsHomingActive(uint32_t DispenserId) +{ + return HomingActive[DispenserId]; +} uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr callback) { assert(DispenserId < MAX_SYSTEM_DISPENSERS); @@ -219,11 +225,17 @@ uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr if (FPGA_Read_limit_Switches(Dispenser_Id_to_LS_Id[DispenserId]) == LIMIT) { Report("IDS_HomeDispenser - Disp is full",__FILE__,Dispenser_Id_to_LS_Id[DispenserId],(int)DispenserId,RpWarning,LIMIT,0); - return OK; + return ERROR; } if (Get_MidTank_Pressure_Sensor(DispenserId)<0.2) { - Report("IDS_HomeDispenser - Midtank is empty",__FILE__,Get_MidTank_Int1000_Sensor(DispenserId),(int)DispenserId,RpWarning,LIMIT,0); + Report("IDS_HomeDispenser - Midtank is empty",__FILE__,Get_MidTank_Int100_Sensor(DispenserId),(int)DispenserId,RpWarning,LIMIT,0); + return ERROR; + } + midTankContent = Read_MidTank_Pressure_Sensor(DispenserId); + if (midTankContent < 0.2) //midtank is empty - abort!!!! + { + Report("IDS_HomeDispenser - Mid Tank Empty!!! ",__FILE__,__LINE__,(int)(midTankContent * 1000),RpWarning,DispenserId,0); return ERROR; } //if Safety is active @@ -233,8 +245,6 @@ uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr Report("IDS_HomeDispenser - Homing/priming already active",__FILE__,HomingActive[DispenserId],(int)DispenserId,RpWarning,PrimingActive[DispenserId],0); return ERROR; } - else - HomingActive[DispenserId] = true; if (Check_Disp_Safety_Stop_Indication(DispenserId) == true) { @@ -249,62 +259,35 @@ uint32_t IDS_HomeDispenser (uint32_t DispenserId, uint32_t speed , callback_fptr TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1 + DispenserId; if ( Dispenser_Id_to_LS_Id[DispenserId] != MAX_GPI) { + HomingActive[DispenserId] = true; //open dispenser valve dispenser to midtank direction Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer - KeepMicrostep[DispenserId] = MotorsCfg[MotorId].microstep; if (Extended_Motor_Param == true) Power_Step_01_Dispenser_Mode(DispenserId,Current); - MotorSetMicroStep(MotorId, 1); - SysCtlDelay(180000); + KeepMicrostep[DispenserId] = MotorsCfg[MotorId].microstep; + //MotorSetMicroStep(MotorId, 1); //open dry air valve in the dispenser Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_ON); Enable_MidTank_Pressure_Reading(DispenserId); - SysCtlDelay(1200000); - midTankContent = Read_MidTank_Pressure_Sensor(DispenserId); - if (midTankContent < 0.2) //midtank is empty - abort!!!! - { - Report("IDS_HomeDispenser - Mid Tank Empty!!! ",__FILE__,__LINE__,(int)(midTankContent * 1000),RpWarning,DispenserId,0); - Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); - STATUS_GREEN_LED_OFF; - STATUS_RED_LED_ON; - - return ERROR; - } IDS_Dispenser_RefillStarted(DispenserId,1); - MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Dispenser_Id_to_LS_Id[DispenserId], IDS_HomeDispenserCallback,0); - CurrentDispenserSpeed[DispenserId] = speed; + if (DispenserId== LUBRICANT_DISPENSER) + { + MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed/2, Dispenser_Id_to_LS_Id[DispenserId], IDS_HomeDispenserCallback,0); + CurrentDispenserSpeed[DispenserId] = speed/2; + Report("IDS_HomeDispenser ",__FILE__,__LINE__,(int)DispenserId,RpWarning,speed/2,0); + } + else + { + MotorMovetoLimitSwitch (MotorId,1-MotorsCfg[MotorId].directionthreadwize, speed, Dispenser_Id_to_LS_Id[DispenserId], IDS_HomeDispenserCallback,0); + CurrentDispenserSpeed[DispenserId] = speed; + Report("IDS_HomeDispenser ",__FILE__,__LINE__,(int)DispenserId,RpWarning,speed,0); + } CurrentDispenserSpeed[DispenserId] = (-1*CurrentDispenserSpeed[DispenserId]); - Report("IDS_HomeDispenser ",__FILE__,__LINE__,(int)DispenserId,RpWarning,speed,0); return OK; } return ERROR; } -uint32_t IDS_Dispenser_Alarm_On (uint8_t DispenserId) -{ - uint32_t status = OK; - Report("IDS_Dispenser_Alarm_On",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,0,0); - DispensersAlarmState[DispenserId] = true; - TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1 + DispenserId; - status |= MotorAbortMovetoLimitSwitch(MotorId); - Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); - Enable_MidTank_Pressure_Reading(DispenserId); - if (Extended_Motor_Param == true) - Power_Step_01_Dispenser_Mode(DispenserId,Voltage); - status |= MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]); - status |= MotorStop(DispenserId, Hard_Hiz); - CurrentDispenserSpeed[DispenserId] = 0; - JobEndReason = JOB_OUT_OF_DYE; - return status; -} -uint32_t IDS_Dispenser_Alarm_Off (uint8_t DispenserId) -{ - uint32_t status = OK; - DispensersAlarmState[DispenserId] = false; - Report("IDS_Dispenser_Alarm_Off",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,0,0); - return status; -} - uint32_t IDS_StopHomeDispenser (uint32_t DispenserId) { assert(DispenserId < MAX_SYSTEM_DISPENSERS); @@ -323,24 +306,24 @@ uint32_t IDS_StopHomeDispenser (uint32_t DispenserId) Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer - if (HomingActive[DispenserId] == true) +/* if (HomingActive[DispenserId] == true) { IDS_StopHomeDispenserBuildPressure(DispenserId); - } - if (PrimingActive[DispenserId] == true) + }*/ + if (HomingActive[DispenserId] == true) { if (DispenserId == LUBRICANT_DISPENSER) { Lubricant_2Way_Valve (STOP); } - PrimingActive[DispenserId] = false; - Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE - if (Extended_Motor_Param == true) - Power_Step_01_Dispenser_Mode(DispenserId,Voltage); - MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]); - CurrentDispenserSpeed[DispenserId] = 0; - CurrentDispenserSpeed[DispenserId] = 0; } + HomingActive[DispenserId] = false; + PrimingActive[DispenserId] = false; + Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE + if (Extended_Motor_Param == true) + Power_Step_01_Dispenser_Mode(DispenserId,Voltage); + //MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]); + CurrentDispenserSpeed[DispenserId] = 0; return OK; } uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) @@ -365,25 +348,15 @@ uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) //close dry air valve in the dispenser Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); Disable_MidTank_Pressure_Reading(DispenserId); - CurrentDispenserSpeed[DispenserId] = 0; - if (Extended_Motor_Param == true) - Power_Step_01_Dispenser_Mode(DispenserId,Voltage); - MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); - + // MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); if (HomingRequestCallback[DispenserId]) { HomingRequestCallback[DispenserId](DispenserId,0); HomingRequestCallback[DispenserId] = NULL; } // HomingActive[DispenserId]= false; - JobStartStopBackLash[DispenserId] = false; - Report("End homing no backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - /*if (JobStartStopBackLash[DispenserId] == true) - { - JobStartStopBackLash[DispenserId] = false; - Report("End homing for job start",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); - } - else + Report("End homing for job start",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); + /* else { Report("homing aborted,start backlash",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,(int)DispenserHomingTime[DispenserId],0); DispenserHomingControlId[DispenserId] = AddControlCallback( IDS_HomeDispenserBackMoveCallback, InitialDispenserTimeLag, GetDispenserPressure,motorId, motorId, 0 ); @@ -393,7 +366,7 @@ uint32_t IDS_StopHomeDispenserBuildPressure (uint32_t DispenserId) MotorSetSpeed(motorId, 1000); CurrentDispenserSpeed[DispenserId] = 1000; }*/ - IDS_Dispenser_RefillEnded ( DispenserId, MotorsCfg[motorId].microstep); + //IDS_Dispenser_RefillEnded ( DispenserId, MotorsCfg[motorId].microstep); return OK; } @@ -427,7 +400,7 @@ uint32_t IDS_EmptyDispenserCallback(uint32_t motorId, uint32_t ReadValue) CurrentDispenserSpeed[DispenserId] = 0; if (Extended_Motor_Param == true) Power_Step_01_Dispenser_Mode(DispenserId,Voltage); - MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); + //MotorSetMicroStep(motorId, KeepMicrostep[DispenserId]); PrimingActive[DispenserId]= false; Control_TCA9534ByPass(DispenserId,DISABLE);// use ENABLE or DISABLE if (DispenserId == LUBRICANT_DISPENSER) @@ -451,10 +424,10 @@ uint32_t IDS_EmptyDispenser (uint32_t DispenserId, uint32_t speed , callback_fpt //if (DispensersAlarmState[DispenserId] == true) // return ERROR; if ((HomingActive[DispenserId] == true)||(PrimingActive[DispenserId] == true)) + { + Report("IDS_HomeDispenser - Homing/priming already active",__FILE__,HomingActive[DispenserId],(int)DispenserId,RpWarning,PrimingActive[DispenserId],0); return ERROR; - else - PrimingActive[DispenserId] = true; - HomingRequestCallback[DispenserId] = callback; + } if (Check_Disp_Safety_Stop_Indication(DispenserId) == true) { if ((Get_Notification_Disp_Down(DispenserId) == false)||(Get_Notification_Over_Press(DispenserId) == false)) @@ -466,13 +439,15 @@ uint32_t IDS_EmptyDispenser (uint32_t DispenserId, uint32_t speed , callback_fpt TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1 + DispenserId; if ( Dispenser_Id_to_LS_Empty_Id[DispenserId] != MAX_GPI) { + PrimingActive[DispenserId] = true; + HomingRequestCallback[DispenserId] = callback; //open dispenser valve dispenser to midtank direction Control3WayValvesWithCallback ((Valves_t)DispenserId, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer if (Extended_Motor_Param == true) Power_Step_01_Dispenser_Mode(DispenserId,Current); //Valve_Set((Valves_t) request->index, Dispenser_Mixer); KeepMicrostep[DispenserId] = MotorsCfg[MotorId].microstep; - MotorSetMicroStep(MotorId, 1); + //MotorSetMicroStep(MotorId, 1); Task_sleep(100); //open dry air valve in the dispenser //Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_ON); @@ -486,3 +461,40 @@ uint32_t IDS_EmptyDispenser (uint32_t DispenserId, uint32_t speed , callback_fpt } return ERROR; } +uint32_t IDS_Dispenser_Alarm_On (uint8_t DispenserId) +{ + uint32_t status = OK; + Report("IDS_Dispenser_Alarm_On",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,0,0); + assert(DispenserId < MAX_SYSTEM_DISPENSERS); + DispensersAlarmState[DispenserId] = true; + TimerMotors_t MotorId = HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1 + DispenserId; + status |= MotorAbortMovetoLimitSwitch(MotorId); + Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); + Disable_MidTank_Pressure_Reading(DispenserId); + if (Extended_Motor_Param == true) + Power_Step_01_Dispenser_Mode(DispenserId,Voltage); + //status |= MotorSetMicroStep(MotorId, KeepMicrostep[DispenserId]); + status |= MotorStop(DispenserId, Hard_Hiz); + IDS_Dispenser_Init(DispenserId); + JobEndReason = JOB_OUT_OF_DYE; + return status; +} +uint32_t IDS_Dispenser_Alarm_Off (uint8_t DispenserId) +{ + uint32_t status = OK; + assert(DispenserId < MAX_SYSTEM_DISPENSERS); + DispensersAlarmState[DispenserId] = false; + Report("IDS_Dispenser_Alarm_Off",__FILE__,millisecondCounter,(int)DispenserId,RpWarning,0,0); + return status; +} + +void IDS_Dispenser_Init(uint8_t DispenserId) +{ + assert(DispenserId < MAX_SYSTEM_DISPENSERS); + Report("IDS_Dispenser_Init",__FILE__,DispenserId,HomingActive[DispenserId],RpWarning,PrimingActive[DispenserId],0); + CurrentDispenserSpeed[DispenserId] = 0; + HomingActive[DispenserId]= false; + PrimingActive[DispenserId]= false; + Valve_Set(IDS_Id_to_AirValve[DispenserId], Atm_MidTank_OFF); + Control3WayValvesWithCallback ((Valves_t)DispenserId, MidTank_Dispenser, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer +} diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 1bab2c65d..ca9a15008 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -55,10 +55,10 @@ uint32_t IDS_Valve_DistanceToSpoolReady(uint32_t deviceID, uint32_t ReadValue); uint32_t IDS_Valve_PresegmentReady(uint32_t deviceID, uint32_t ReadValue); uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue); //bool IDS_isDispenserUsedNextSegment(void *JobDetails,int DispenserId, int SegmentId); -bool JobStartStopBackLash[MAX_SYSTEM_DISPENSERS] = {false,false,false,false,false,false,false,false}; /******************** GLOBAL PARAMETERS ********************************************/ DispenserControlConfig_t DispenserControlConfig[MAX_SYSTEM_DISPENSERS]; uint32_t ControlIdtoDispenserId [MAX_SYSTEM_DISPENSERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; +uint32_t ControlIdtoInactiveDispenserId [MAX_SYSTEM_DISPENSERS] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; int OriginalDispenserSpd_2PPS[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; bool DispenserPreSegmentReady[MAX_SYSTEM_DISPENSERS] = {true,true,true,true,true,true,true,true}; bool DispenserSegmentReady[MAX_SYSTEM_DISPENSERS] = {true,true,true,true,true,true,true,true}; @@ -375,6 +375,22 @@ c. Go to step 2.a x Segment.BrushStopsCount. int NumOfActiveDispensers = 0; int DispenserBuildTimeCounter = 0; #define PRESSURE_READ_TIME_GAP 100 +uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) +{ + if (AutoHoming_Config >= AutoHoming_JobEnd_PowerOn_off) + { + if ((HomingActive[DispenserId] == false)&&(PrimingActive == false)) + { + Report("Homing Inactive dispenser",__FILE__,DispenserId,HomingActive[DispenserId],RpWarning,PrimingActive[DispenserId],0); + IDS_HomeDispenser (DispenserId, 1000 , NULL); + } + else + { + Report("Inactive dispenser already homing",__FILE__,DispenserId,HomingActive[DispenserId],RpWarning,PrimingActive[DispenserId],0); + } + } + return OK; +} void DispenserPrepareReady(void) { int i; @@ -387,6 +403,17 @@ c. Go to step 2.a x Segment.BrushStopsCount. } REPORT_MSG(Module_IDS,"All Dispensers Prepare Ready"); PrepareReady(Module_IDS,ModuleDone); + for (i=0;i3.0) + { + Report("Pulling dispenser down to reduce pressure",__FILE__,DispenserId,(int)(GetDispenserPressure(DispenserId)*100),RpWarning,200,0); + MotorMove(HW_Motor_Id,1-MotorsCfg[HW_Motor_Id].directionthreadwize,200); + } + return OK; } + void IDSPrepareStart(void) { int i; @@ -545,20 +593,24 @@ c. Go to step 2.a x Segment.BrushStopsCount. } NumOfActiveDispensers = 0; + IDS_StopHomeDispenser(CLEANER_DISPENSER); for (i = 0; i < MAX_DYE_DISPENSERS; i++) { if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { - IDS_StopHomeDispenser(i); - JobStartStopBackLash[i] = true; NumOfActiveDispensers++; + if (HomingActive[i] == true) + { + Report("Stop active dispenser homing ",__FILE__,i,HomingActive[i],RpWarning,CurrentDispenserSpeed[i],0); + IDS_StopHomeDispenser(i); + } } else { - if (AutoHoming_Config >= AutoHoming_JobEnd_PowerOn_off) + if ((HomingActive[i] == false)&&(PrimingActive == false)) { - REPORT_MSG((int)i, "Homing inactive dispenser"); - IDS_HomeDispenser (i, 1000 , NULL); + Report("Inactive dispenser open valve",__FILE__,i,HomingActive[i],RpWarning,PrimingActive[i],0); + Control3WayValvesWithCallback (i, Dispenser_Mixer, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer } } } @@ -572,17 +624,17 @@ c. Go to step 2.a x Segment.BrushStopsCount. if (DispenserUsedInJob[i] == true) //we actually should check for all dispensers { - if (HomingActive[i] == false) + //if (HomingActive[i] == false) { - Report("Prepare Speed",__FILE__,__LINE__,i,RpWarning,(int)dispenserspeed,0); + Report("Prepare Speed",__FILE__,HomingActive[i],i,RpWarning,(int)dispenserspeed,0); MotorSetDirection((TimerMotors_t)HW_Motor_Id,MotorsCfg[HW_Motor_Id].directionthreadwize); //set the dispenser to the IDS_Dispenser_Start_Motor_and_Open_Valve(i,dispenserspeed, NULL); } - else + /*else { Report("IDSPrepare Stop Dispenser Homing",__FILE__,__LINE__,i,RpWarning,(int)HomingActive[i],0); IDS_HomeDispenserWaitForHomingEnd(i, DispenserPrepareTimeout/2 , IDSPrepareStartDispenserAfterHoming); - } + }*/ } } } @@ -890,11 +942,12 @@ uint32_t IDS_Cleaning_Stop_Cleaning_Solution (callback_fptr callback); CurrentDispenserSpeed[Dispenser_i] = segmentfirst_speed; usnprintf(IdMessage, 80, - "WFCF Dispenser %d nl/sec %d nl/pulse %d speed %d", + "WFCF Dispenser %d nl/sec %d nl/pulse %d Pulse/sec %d speed %d", DispenserId, (int) Dispensers[Dispenser_i]->nanolitterpersecond, (int) Dispensers[Dispenser_i]->nanoliterperpulse, - (int) segmentfirst_speed); + (int) Dispensers[Dispenser_i]->pulsepersecond*1000, + (int) segmentfirst_speed*1000); //REPORT_MSG(segmentfirst_speed,IdsMessage); Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); //SendJobProgress(0.0, 0, false, IdsMessage); @@ -1159,10 +1212,11 @@ void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) MotorSetSpeed(HW_Motor_Id, segmentfirst_speed); CurrentDispenserSpeed[DispenserId] = segmentfirst_speed; usnprintf(IdsMessage, 80, - "Dispenser %d nl/sec %d nl/pulse %d speed %d steps %d/%d", + "Dispenser %d nl/sec %d nl/pulse %d Pulse/sec %d speed %d steps %d/%d", DispenserId, (int) Dispensers[Dispenser_i]->nanolitterpersecond, (int) Dispensers[Dispenser_i]->nanoliterperpulse, + (int) Dispensers[Dispenser_i]->pulsepersecond*1000, (int) (segmentfirst_speed*1000),Dispensers[Dispenser_i]->dispenserstepdivision,MotorsCfg[HW_Motor_Id].microstep); //REPORT_MSG(segmentfirst_speed,IdsMessage); Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); @@ -1231,6 +1285,7 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Head); + IDS_Cleaning_Stop_Cleaning_Solution(NULL); SegmentNumOfBrushStops = Segment->n_brushstops; BrushStopTime = Segment->length/SegmentNumOfBrushStops; //brushstop in meters BrushStopTime = ((BrushStopTime*100)/dyeingspeed);//brushstop in seconds @@ -1400,6 +1455,8 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) } else { + RemoveControlCallback(ControlIdtoInactiveDispenserId[Dispenser_i], IDS_Check_Pressure_Callback ); + ControlIdtoInactiveDispenserId[Dispenser_i] = 0xFF; IDS_Valve_EndValveReady(Dispenser_i,false); } diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c index fc50173fc..545495646 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.c @@ -18,6 +18,7 @@ #include "include.h" #include "Modules/Waste/Waste.h" +#include "Modules/IDS/ids_ex.h" #include "Modules/IFS/ifs.h" #include "Modules/AlarmHandling/AlarmHandling.h" #include "CartridgeValidationRequest.pb-c.h" @@ -25,6 +26,7 @@ #include #include "drivers/Valves/Valve.h" #include "Modules/Waste/Waste.h" +#include "../control/control.h" bool IFS_TimeOutAlarm(bool status); bool ColorMatch(); @@ -49,8 +51,37 @@ void IFS_Init(void) }*/ +/** + * + * @brief detect cartridge INK Empty + * this function detect changes in IFS INK cartridge + * when MidTank average is bigger the 98% of midtank pressure + * the INK cartridge is empty + * @return bool ret OK = 0 , CartridgeFinished = 1 + */ +bool DetectIfCartridgeFinished(int int_MidTank_Pressure_1000) +{ +#define CartridgeFinished 1 + bool ret = OK; + static int measure_midtank[5] ; + static int count_measure_midtank = 0; + int i=0; + int sum = 0; + int average = 0; + + if ( count_measure_midtank == 5) count_measure_midtank = 0; + measure_midtank[count_measure_midtank] = int_MidTank_Pressure_1000; + count_measure_midtank += 1; + for (i=0;i<5;i++) + sum += measure_midtank[i]; + average = sum/5; + if (abs(average - int_MidTank_Pressure_1000)<10) ret = CartridgeFinished; + //if (average > (int_MidTank_Pressure_1000 * 0.98) ) ret = CartridgeFinished; + + return ret; +} @@ -99,14 +130,18 @@ WHS_sensor CartridgeInkTimeOutCallBackFunction() { WHS_sensor ret = WHS_no_event; double MidTank_Pressure = 0; + int int_MidTank_Pressure_1000 = 0; + + //Enable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color); MidTank_Pressure = Read_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color);// Get_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color); - ReportWithPackageFilter(WasteFilter,"------------ IFS_info.Ink.time_out and Pressure -----------------", __FILE__,__LINE__,(IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int)(MidTank_Pressure*1000), 0); + //Disable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color); + int_MidTank_Pressure_1000 = ((int)(MidTank_Pressure*1000)); + ReportWithPackageFilter(WasteFilter,"------------ IFS_info.Ink.time_out and Pressure -----------------", __FILE__,__LINE__,(IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0); if (IFS_info.Ink.time_out) IFS_info.Ink.time_out += 1; /*** counter ***/ -//#ifdef timeout_capacity /*** detect the MidTank capacity is full ***/ //Read_MidTank_Pressure_Sensor(IFS_info.Ink.cart_color); if (MidTank_Pressure >= IFS_info.MidTank_capacity + CARTRIDGE_CAPATICY) @@ -115,7 +150,18 @@ WHS_sensor CartridgeInkTimeOutCallBackFunction() WHS_info.event = IFS_MidTankFull; return IFS_MidTankFull; } -//#endif + + /**** detect if the MidTank_Pressure is the same, 5 times ****/ + if (DetectIfCartridgeFinished(int_MidTank_Pressure_1000)) + { + ReportWithPackageFilter(WasteFilter,"------------ INK Cartrigde is empty (by average) -----------------", __FILE__,__LINE__,(IFS_info.Ink.time_out * SECONDS_5), RpMessage, (int_MidTank_Pressure_1000), 0); + IFS_info.Ink.time_out = 0; + WHS_info.event = IFS_MidTankFull; + return IFS_MidTankFull; + } + + + /*** first TimeOut ***/ if (IFS_info.Ink.time_out == CARTRIDGE_INK_TIMEOUT) { @@ -156,36 +202,9 @@ WHS_sensor CartridgeInkTimeOutCallBackFunction() bool IFS_TimeOutAlarm(bool status) { bool ret = OK; - switch (IFS_info.Ink.cart_color) //todo enter the correct color from RFID - { - case 1 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_1_FILL_TIMEOUT, status); - break; - case 2 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_2_FILL_TIMEOUT, status); - break; - case 3 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_3_FILL_TIMEOUT, status); - break; - case 4 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_4_FILL_TIMEOUT, status); - break; - case 5 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_5_FILL_TIMEOUT, status); - break; - case 6 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_6_FILL_TIMEOUT, status); - break; - case 7 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_7_FILL_TIMEOUT, status); - break; - case 8 : - AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_8_FILL_TIMEOUT, status); - break; - default: //wrong color - ret = notOK; - break; - } + + AlarmHandlingSetAlarm( EVENT_TYPE__MID_TANK_1_FILL_TIMEOUT+IFS_info.Ink.cart_color, status); + return ret; } @@ -211,6 +230,7 @@ bool MidTankValvesAction(bool action) //Cartridge_MidTank_ON of Cartridge_MidTan { Disable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color); } +#warning check that the dispenser is not in homing before CLOSING the air valve Valve_Set(IDS_Id_to_AirValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON Valve_Set(IDS_Id_to_CartrideValve[IFS_info.Ink.cart_color], action ); //Atm_MidTank_OFF/ON @@ -330,6 +350,56 @@ void ResponseDemo(int MidtankId) IFS_info.Ink.cart_color = MidtankId; WasteTankCBFunction();//call cart is ok } +uint32_t MidTankReadControlId = 0xFF; +int MidTankCounter = 0; +uint32_t MidTankCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + int MidTankOpenAir = 8; + int MidTankReadPressure = 16; + int MidTankCloseAir = 40; + int MidTankEnd = 48; + int portId; + + if (MidTankCounter >= MidTankEnd) + { + SafeRemoveControlCallback(MidTankReadControlId, MidTankCallBackFunction); + } + else if (MidTankCounter >= MidTankCloseAir) + { + //close air valve for midtank (MidTankCounter-MidTankCloseAir) + portId = (MidTankCounter - MidTankCloseAir) ; //0-7 + if (IDS_IsHomingActive(portId) == false) + { + Disable_MidTank_Pressure_Reading(portId); + Valve_Set(IDS_Id_to_AirValve[portId], Atm_MidTank_OFF ); //Atm_MidTank_OFF/ON + } + } + else if (MidTankCounter >= MidTankReadPressure) + { + //read pressure for midtank (MidTankCounter-MidTankCloseAir) + for (portId = 0;portId < MAX_SYSTEM_DISPENSERS;portId++) + { + Read_MidTank_Pressure_Sensor(portId); + } + } + else if (MidTankCounter >= MidTankOpenAir) + { + //open air valve for midtank (MidTankCounter-MidTankOpenAir) + portId = (MidTankCounter - MidTankOpenAir) ; //0-7 + Enable_MidTank_Pressure_Reading(portId); + Valve_Set(IDS_Id_to_AirValve[portId], Atm_MidTank_ON ); //Atm_MidTank_OFF/ON + } + MidTankCounter++; + return OK; +} + +uint32_t MidTankReading(void) +{ + MidTankCounter = 0; + MidTankReadControlId = AddControlCallback( MidTankCallBackFunction, 300/*eHundredMillisecond*/, TemplateDataReadCBFunction,0,0, 0 ); + + return OK; +} bool INKCartridgeAuthentication(cartridge_name cart_name) { diff --git a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h index a7e80a31e..11ae5b008 100644 --- a/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h +++ b/Software/Embedded_SW/Embedded/Modules/IFS/ifs.h @@ -55,5 +55,6 @@ void ResponseDemo(int MidtankId); bool CartridgeValidationResponseFunc(MessageContainer* requestContainer); +uint32_t MidTankReading(void); #endif /* MODULES_IFS_IFS_H_ */ diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 3504c3134..5850ff7cf 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -15,12 +15,14 @@ #include "drivers/Heater/TemperatureSensor.h" #include "drivers/ADC_Sampling/adc.h" -#include "Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.h" +#include "Drivers/I2C_Communication/Head_Card/PT100/PT100_ADC.h" #include "Drivers/I2C_Communication/Head_Card/Fan/fan_click.h" #include "Drivers/I2C_Communication/Head_Card/Fan/Head_Fan.h" #include "drivers/Motors/Motor.h" #include "drivers/FPGA/FPGA_SPI_Comm.h" #include "Modules/IFS/ifs.h" +#include "Modules/IDS/ids_ex.h" +#include "Modules/Control/MillisecTask.h" //#include "graphics_adapter.h" extern uint8_t Input_Voltage; @@ -45,20 +47,14 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.has_progress = true; } else - if((request->amount == 0xAD) && (request->delay == 0xAD01)) //undef AUTO_HOME_DISPENSERS - { - #undef AUTO_HOME_DISPENSERS - response.progress = 01; - response.has_progress = true; - } - else - if((request->amount == 0xAD) && (request->delay == 0xAD00)) //define AUTO_HOME_DISPENSERS - { - #define AUTO_HOME_DISPENSERS - response.progress = 01; - response.has_progress = true; - } - else + if(request->amount == 0xAD) //undef AUTO_HOME_DISPENSERS + { + if ((request->delay >=AutoHoming_off )&&(request->delay<=AutoHoming_JobEnd_PowerOn_off )) + IDS_Dispenser_SetAutoHoming_Config(request->delay); + response.progress = 01; + response.has_progress = true; + } + else if((request->amount == 0x01) && ((request->delay &0x010000) == 0x010000)) //change mode powerset01 { response.progress = Power_Step_01_Mode(((request->delay &0x00FF00)>>8), request->delay &0x0000FF); @@ -167,6 +163,14 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = (double)OK; response.has_progress = true; + } + else + if(request->amount == 0xE0) //fast refresh for pressure + { + setRapidPressureRead(request->delay); + response.progress = (double)OK; + response.has_progress = true; + } else if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index c5cdb00d6..5a2307384 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -18,6 +18,7 @@ #include "Modules/control/pidalgo.h" #include "Modules/heaters/heaters_ex.h" +#include "Modules/General/buttons.h" #include "StateMachines/Initialization/InitSequence.h" #include "PMR/Hardware/HardwareMotor.pb-c.h" @@ -151,7 +152,7 @@ ProcessParametersClear.headzone6temp = 0; ProcessParametersClear.dyeingspeed = 40; ProcessParametersClear.dryerbufferlength = ProcessParametersKeep.dryerbufferlength; - if (HandleProcessParameters(&ProcessParametersClear)!= OK) + if (HandleProcessParameters(&ProcessParametersClear,false)!= OK) { LOG_ERROR (LoadStages, "Thread_Load_Init failed"); } @@ -223,7 +224,7 @@ ThreadLoadStateMachine(LoadStages); return OK; } - uint32_t Thread_Load_Set_Load_Arm_To_Start_Position(void) + /*uint32_t Thread_Load_Set_Load_Arm_To_Start_Position(void) { uint32_t numberOfSteps = 0; REPORT_MSG(LoadStages, "Thread Load State Machine step"); @@ -238,14 +239,14 @@ } else //number of circles is not known - compare to position of the motor to verify location at the stopper { - Report("Thread_Load_Set_Load_Arm_To_Start_Position unknown cycles",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + Report("Thread_Load_Set_Load_Arm_To_Start_Position",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); status |= MotorMoveToStopper(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize), - MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/2, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); + MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].pulseperround/4*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].microstep, Thread_Load_Set_Load_Arm_To_Stopper_Callback,LoadArmInfo.LoadArmBackLash,1000); } //Use Notation How Many Rotations In The Drier, Or Check Against Stopper. Move Slowly return OK; - } + }*/ uint32_t Thread_Load_Jog_Feeder_To_Middle_Point_Callback(uint32_t deviceID, uint32_t BusyFlag) { CallbackCounter--; @@ -265,6 +266,12 @@ { if((MotorId == HARDWARE_MOTOR_TYPE__MOTO_RLOADING)||(MotorId == HARDWARE_MOTOR_TYPE__MOTO_LLOADING)) { + if(LoadStages == THREAD_LOAD_CLOSE_ROCKERS) + { + MotorMove(MotorId,MotorsCfg[MotorId].directionthreadwize,400); + Report("Move rockers further down",__FILE__,__LINE__,MotorId,RpMessage,400,0); + Task_sleep(200); + } MotorSetMicroStep(MotorId, keepmicrostep); MotorSetKvalRun(MotorId, keepkvalrun); } @@ -273,6 +280,7 @@ if (CallbackCounter) { CallbackCounter--; + load.color = BLINK; if (ReadValue != LIMIT) { //returned with a timeout @@ -284,10 +292,12 @@ { LOG_ERROR(LoadStages,"Load sequence timeout"); TimeoutsCounter = 0; + load.color = fastBILNK; } else { LoadStages++; + load.color = colorON; if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -296,6 +306,10 @@ { ThreadLoadStateMachine(LoadStages); } + else + { + load.color = fastBILNK; + } } } } @@ -334,7 +348,7 @@ CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,15000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 600, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,25000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdUp[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,25000); return OK; } @@ -403,7 +417,7 @@ CallbackCounter++; MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_RDANCER,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_RDANCER].directionthreadwize, 15, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_RDANCER], Thread_Load_HomingCallback,10000); CallbackCounter++; - MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 600, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,25000); + MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_LDANCER1,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1].directionthreadwize, 500, Motor_Id_to_LS_IdDown[HARDWARE_MOTOR_TYPE__MOTO_LDANCER1], Thread_Load_HomingCallback,25000); return OK; } @@ -426,7 +440,7 @@ REPORT_MSG(LoadStages, "Thread Load State Machine step"); ActivateHeadMagnet(); - if (HandleProcessParameters(&ProcessParametersRecover)!= OK) + if (HandleProcessParameters(&ProcessParametersRecover,false)!= OK) { LOG_ERROR (LoadStages, "Thread_Load_Resume_Heating failed"); } @@ -494,8 +508,8 @@ if (dryerbufferlength) LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; - //if (LoadArmInfo.LoadArmRounds <= 2) - // LoadArmInfo.LoadArmRounds = 20; + if (LoadArmInfo.LoadArmRounds <= 2) + LoadArmInfo.LoadArmRounds = 30; float numberOfSteps = 0; //Start Feeder Pid, Rotate Loading Arm Counter Thread Direction X Circles According To Rml. Feeder Speed Is 40 SetOriginMotorSpeed(19); @@ -591,6 +605,7 @@ MotorStopAction(HARDWARE_MOTOR_TYPE__MOTO_DH_LID); MotorStop(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,Hard_Stop); LoadStages = THREAD_LOAD_INIT; + load.color = colorOFF; return OK; } uint32_t Thread_Load_Dryer_UnLoading(void) @@ -664,7 +679,8 @@ //Keep Notation How Many Rotations In The Dryer LoadArmInfo.LoadArmBackLash = 5; LoadArmInfo.LoadArmRounds = (int)dryerbufferlength; - //FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER); + FileWrite(&LoadArmInfo, sizeof(LoadArmInfo),LoadArmPath,BIOS_WAIT_FOREVER); + load.color = BLINK; return OK; } @@ -825,6 +841,35 @@ uint32_t ThreadLoadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) CurrentControlledSpeed[index] = calculated_speed; MotorSetSpeed(ThreadMotorIdToMotorId[index], calculated_speed); } + if (index == POOLER_MOTOR) + { + if ((TranslatedReadValue)<(-1200)) + { + if(PullerControlId != 0xFF) + { + Report("Puller stoped",__FILE__,__LINE__,ReadValue,RpWarning,(int)DancersCfg[DancerId].zeropoint,0); + MotorStop(ThreadMotorIdToMotorId[POOLER_MOTOR],Hard_Hiz); + RemoveControlCallback(PullerControlId, ThreadLoadControlCBFunction ); + PullerControlId = 0xFF; + } + } + + } + if (index == WINDER_MOTOR) + { + if ((TranslatedReadValue)<(-1200)) + { + if(WinderControlId != 0xFF) + { + Report("Winder stoped",__FILE__,__LINE__,ReadValue,RpWarning,(int)DancersCfg[DancerId].zeropoint,0); + MotorStop(ThreadMotorIdToMotorId[WINDER_MOTOR],Hard_Hiz); + RemoveControlCallback(WinderControlId, ThreadLoadControlCBFunction ); + WinderControlId = 0xFF; + } + + } + + } /* LoadCounter++; if ((LoadCounter % 5001) == 0) { diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index a93387e0a..741fed7af 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -66,6 +66,7 @@ InternalWinderConfigStruc InternalWinderCfg = {0}; #ifdef READ_SCREW_ENCODER uint32_t ScrewLocationLimitSwitch = 0,ScrewLocationStart = 0; uint32_t ScrewLocationRun[3]; +uint32_t ScrewLocationPrev[3]; float WinderRunAverage = 0.0,WinderRunSum = 0.0; int WinderRunSamples = 0; #endif @@ -305,7 +306,7 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) // WinderMotorSpeedCounter=0; } // } - if (flipflop == 0) + /*if (flipflop == 0) { MotorGetSpeedFromFPGA1(HARDWARE_MOTOR_TYPE__MOTO_SCREW); } @@ -314,11 +315,11 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) speedf = MotorGetSpeedFromFPGA_Res(HARDWARE_MOTOR_TYPE__MOTO_SCREW); } flipflop ++; - + */ if (ScrewDirectionChangeCounter == CalculationDirectionChangeCounter) return OK; //deley TODO - flipflop = 0; + //flipflop = 0; ScrewCurrentDirection = 1-ScrewCurrentDirection; CalculationDirectionChangeCounter++; @@ -342,6 +343,16 @@ uint32_t Screw100msecDirectionChange(uint32_t deviceID, uint32_t BusyFlag) Report(ScrewStr,__FILE__,__LINE__,CalculationDirectionChangeCounter,RpWarning,ScrewLocationStart, 0); } } + if (abs(ScrewLocationPrev[1]-ScrewLocationRun[1])>21) + { + Report("Winder difference",__FILE__,CalculationDirectionChangeCounter,ScrewLocationPrev[1],RpWarning,ScrewLocationRun[1], 0); + } + ScrewLocationPrev[1] = ScrewLocationRun[1]; + if (abs(ScrewLocationPrev[0]-ScrewLocationRun[0])>21) + { + Report("Winder difference",__FILE__,CalculationDirectionChangeCounter,ScrewLocationPrev[0],RpWarning,ScrewLocationRun[0], 0); + } + ScrewLocationPrev[0] = ScrewLocationRun[0]; //else // Report("winder run error value" ,__FILE__,WinderRun,ScrewLocationRun[0],RpWarning,ScrewLocationRun[1], 0); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 416b53494..226bb2559 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -23,6 +23,7 @@ #include "drivers/Flash_ram/FlashProgram.h" #include "drivers/Flash_ram/MCU_E2Prom.h" +#include "modules/ids/ids_ex.h" #include "thread.h" MotorDriverConfigStruc MotorsCfg[NUM_OF_MOTORS]={0}; @@ -105,6 +106,10 @@ uint32_t MotorsConfigMessage(HardwareConfiguration * HWrequest) MotorsCfg[Motor_i].toffmin = request->toffmin ; status = MotorConfig( Motor_i, &MotorsCfg[Motor_i]); + if ((Motor_i >= HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1)&&(Motor_i <= HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_8)) + { + IDS_Dispenser_Init(Motor_i-HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1); + } // if (Motor_i == MOTOR_RDRIVING) // ThreadInitialTestStub(request); } @@ -173,7 +178,7 @@ uint32_t StoreDancerConfigMessage() status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); - Report("Store eeprom 0",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg[1].zeropoint,RpWarning,(int)DancersCfg[2].zeropoint,0); + Report("~~~~~~Store eeprom 0",__FILE__,DancersCfg[0].zeropoint,(int)DancersCfg[1].zeropoint,RpWarning,(int)DancersCfg[2].zeropoint,0); /* response_buffer = my_malloc(hardware_configuration__get_packed_size(&DancerConfig)); if (response_buffer) diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 41d98e892..9d408a4a6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -883,9 +883,10 @@ void ThreadPreSegmentEnded(void) } #define DRYER_RAMPUP 1 #ifdef DRYER_RAMPUP +int DrierDivider = 10; uint32_t ThreadDryerRampUp(uint32_t IfIndex, uint32_t BusyFlag) { - InitialDryerSpeed += (OriginalMotorSpd_2PPS[DRYER_MOTOR]/10); + InitialDryerSpeed += (OriginalMotorSpd_2PPS[DRYER_MOTOR]/DrierDivider); if (InitialDryerSpeed >= OriginalMotorSpd_2PPS[DRYER_MOTOR]) { InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]; @@ -924,7 +925,9 @@ uint32_t ThreadPreSegmentState(void *SegmentDetails, uint32_t SegmentId) #ifndef DRYER_RAMPUP MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING, OriginalMotorSpd_2PPS[DRYER_MOTOR]); #else - InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]/10; + DrierDivider = dyeingspeed/5; //ramp up drier in 5 cm/sec steps + Report("Drier ramp up",__FILE__,__LINE__,(int)dyeingspeed,RpWarning,(int)DrierDivider,0); + InitialDryerSpeed = OriginalMotorSpd_2PPS[DRYER_MOTOR]/DrierDivider; MotorSetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING,InitialDryerSpeed ); ControlIdtoMotorId[DRYER_MOTOR] = AddControlCallback("DryerRampUp",ThreadDryerRampUp, 200,TemplateDataReadCBFunction,0,0,0); #endif diff --git a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c index f3812cc2c..9c4628f4f 100644 --- a/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Waste/Waste_init.c @@ -830,6 +830,7 @@ bool WasteTankCBFunction() { //WHS_info.cartridge_1.autheticate = PASSED; //='0' //???WHS_info.WHS_valve = waste_cartridge1; // or we should do it only before pumping???? + AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, false); } else { @@ -858,6 +859,7 @@ bool WasteTankCBFunction() //WHS_info.cartridge_2.autheticate = PASSED; //='0' //???WHS_info.WHS_valve = waste_cartridge2; // or we should do it only before pumping???? //???SetValveDirection(); // or we should do it only before pumping???? + AlarmHandlingSetAlarm( EVENT_TYPE__ALL_WASTE_CARTRIDGES_FULL, false); } else { @@ -917,12 +919,12 @@ bool WasteTankCBFunction() REPORT_MSG(WHS_full," ------------ call customer support ----------------- "); Pannel_Leds(CART_1, MODE_ON); cart1.color = fastBILNK; - IFS_TimeOutAlarm(true); + //IFS_TimeOutAlarm(); break; case IFS_MidTankFull: // Disable_MidTank_Pressure_Reading(IFS_info.Ink.cart_color); - WHS_info.Cartridge_Ink_TimeOut_device_Id = RemoveControlCallback(WHS_info.Cartridge_Ink_TimeOut_device_Id, WasteTankCBFunction ); + IFS_info.Cartridge_Ink_TimeOut_device_Id = RemoveControlCallback(IFS_info.Cartridge_Ink_TimeOut_device_Id, WasteTankCBFunction ); REPORT_MSG(WHS_full," ------------ Change cartridge status to Waste Empty ----------------- "); Pannel_Leds(CART_1, MODE_OFF); cart1.color = colorOFF; @@ -1157,11 +1159,11 @@ bool InitCartStatus() if (WHS_info.WHS_sensors.cartridge_cover == WHS_CartridgeCoverOPEN) { REPORT_MSG(parameter," ------------ WHS_CartridgeCoverOPEN : add callback for cart1 and cart 2 ----------------- "); - IFS_info.Cartridge_Ink_device_Id = AddControlCallback("Ink Cartridge CB" , WasteTankCBFunction, eOneSecond, CartridgeInkCallBackFunction , 0,0,0 ); - WHS_info.Cartridge_Waste1_device_Id = AddControlCallback("Waste1 Cartridge CB", WasteTankCBFunction, eOneSecond, CartridgeWaste1CallBackFunction, 0,0,0 ); - WHS_info.Cartridge_Waste2_device_Id = AddControlCallback("Waste2 Cartridge CB", WasteTankCBFunction, eOneSecond, CartridgeWaste2CallBackFunction, 0,0,0 ); + IFS_info.Cartridge_Ink_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeInkCallBackFunction, 0,0,0 ); + WHS_info.Cartridge_Waste1_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeWaste1CallBackFunction, 0,0,0 ); + WHS_info.Cartridge_Waste2_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeWaste2CallBackFunction, 0,0,0 ); } - WHS_info.Cartridge_Cover_device_Id = AddControlCallback("Cartridge Cover Door", WasteTankCBFunction, eOneSecond, CartridgeCoverCallBackFunction, 0,0,0 ); + WHS_info.Cartridge_Cover_device_Id = AddControlCallback(NULL, WasteTankCBFunction, eOneSecond, CartridgeCoverCallBackFunction, 0,0,0 ); return OK; } diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index a652e9035..091d74d92 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -38,6 +38,28 @@ state machines print: job length fixed. +94=>97 +Add job error types +Ouf of idle restarts heating, activated by pressing the power for 1 seconds, +Thread: dryer ramp-up, prevent job if a lid is opened +Fix the reset button in machine studio +Process parameters are stored from job request too. +Idle to power down after 2 hours +93=>94 +Fix read safety indication +Fix valve handling in IDS and on init +Alarm handling – improve reporting phase 1, fix current alarms +Machine status improved and fixed +Ouf of idle by pressing the power for 2 seconds +Heaters – fix 2 bugs (dryer underheat and machine temp) +IDS – fix bugs in ink filling +Stubs – Dispensers auto homing control +Thread load improved (press rockers down, , fix current problem) +Jobs – fix a length bug +Press rockers a step down after closing + + + Embedded SW Release note - Version 1.4.4.6 ============================================================= drivers: diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c index a6e0f7d12..f384210b4 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/InitSequence.c @@ -152,8 +152,8 @@ uint32_t InitSequenceMidTankCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag { int MidTankOpenAir = 8; int MidTankReadPressure = 16; - int MidTankCloseAir = 24; - int MidTankEnd = 32; + int MidTankCloseAir = 40; + int MidTankEnd = 48; int portId; if (MidTankOperationCounter >= MidTankEnd) diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c index 9fb7e097d..b0d101809 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerIdle.c @@ -17,6 +17,7 @@ #include "Modules/General/MachineStatus.h" #include "StateMachines/Printing/PrintingSTM.h" +#include "StateMachines/Initialization/PowerOffSequence.h" #include "InitSequence.h" #include "drivers/I2C_Communication/DAC/Blower.h" @@ -38,9 +39,20 @@ bool powerIdleState = false; bool machineActive = false; uint32_t IdleControlId = 0xFF; uint32_t IdleHeatingControlId = 0xFF; +uint32_t IdleToPowerDownControlId = 0xFF; ProcessParameters ActiveProcessParameters,ProcessParametersClear; + +uint32_t PowerIdleToPowerDownCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +{ + if (SafeRemoveControlCallback(IdleToPowerDownControlId, PowerIdleToPowerDownCallBackFunction )==OK) + IdleToPowerDownControlId = 0xFF; + Report("PowerIdle calling power off ",__FILE__,__LINE__,(int)eOneHour*2,RpWarning,(int)0,0); + PowerOffInit(); + return OK; +} void PowerIdleSetIdle(void) { + Report("PowerIdle Set ",__FILE__,__LINE__,(int)powerIdleSecondsLimit,RpWarning,(int)powerIdleSecondsCounter,0); memcpy (&ActiveProcessParameters,&ProcessParametersKeep,sizeof(ProcessParameters)); ProcessParameters ProcessParametersClear; ProcessParametersClear.dryerzone1temp = (ActiveProcessParameters.dryerzone1temp<80)? ActiveProcessParameters.dryerzone1temp:IdleDrierTemperature; @@ -54,7 +66,7 @@ void PowerIdleSetIdle(void) ProcessParametersClear.headzone5temp = (ActiveProcessParameters.headzone5temp <80)? ActiveProcessParameters.headzone5temp :IdleHeadTemperature; ProcessParametersClear.headzone6temp = (ActiveProcessParameters.headzone6temp <80)? ActiveProcessParameters.headzone6temp :IdleHeadTemperature; ProcessParametersClear.dyeingspeed = (ActiveProcessParameters.dyeingspeed <40)? ActiveProcessParameters.dyeingspeed :IdleHeadTemperature; - if (HandleProcessParameters(&ProcessParametersClear)!= OK) + if (HandleProcessParameters(&ProcessParametersClear,false)!= OK) { LOG_ERROR (1, "Turn Heaters idle failed"); return; @@ -68,6 +80,7 @@ void PowerIdleSetIdle(void) Control_Voltage_To_Blower(BlowerCfg.voltage-500); } SetMachineStatus(MACHINE_STATE__Sleep); + IdleToPowerDownControlId = AddControlCallback("IdleToPowerDown",PowerIdleToPowerDownCallBackFunction, eOneHour*2, TemplateDataReadCBFunction,0,0, 0 ); } uint32_t PowerIdleCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) @@ -139,8 +152,10 @@ void PowerIdleOutOfIdleState(void) if (powerIdleState == true) { powerIdleState = false; + RemoveControlCallback(IdleToPowerDownControlId, PowerIdleToPowerDownCallBackFunction ); + IdleToPowerDownControlId = 0xFF; SetPowerMachineState(sttON); - if (HandleProcessParameters(&ActiveProcessParameters)!= OK) + if (HandleProcessParameters(&ActiveProcessParameters,false)!= OK) { LOG_ERROR (1, "Turn Heaters active failed"); return ; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index 285c6ee74..909135c71 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -223,7 +223,7 @@ uint32_t PowerOffHeatersOff(void) ProcessParametersClear.headzone5temp = 0; ProcessParametersClear.headzone6temp = 0; ProcessParametersClear.dyeingspeed = 40; - if (HandleProcessParameters(&ProcessParametersClear)!= OK) + if (HandleProcessParameters(&ProcessParametersClear,false)!= OK) { LOG_ERROR (PowerOffMachineState, "Turn Off Heaters failed"); return ERROR; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 5c0c77baa..42f5572cf 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -82,7 +82,7 @@ JobEndReasonEnum JobEndReason = JOB_OK; ErrorCode JobError_to_ErrorCode[JOB_ERRORS_MAX+1] = {ERROR_CODE__NONE,ERROR_CODE__JOB_UNSPECIFIED_ERROR,ERROR_CODE__JOB_THREAD_BREAK,ERROR_CODE__JOB_WINDER_DANCER_FAIL, ERROR_CODE__JOB_POOLER_DANCER_FAIL,ERROR_CODE__JOB_FEEDER_DANCER_FAIL,ERROR_CODE__JOB_OUT_OF_DYE,ERROR_CODE__JOB_OTHER_ALARM, ERROR_CODE__JOB_TEMPERATURE_ALARM,ERROR_CODE__JOB_LS_ALARM,ERROR_CODE__JOB_PRESSURE_ALARM,ERROR_CODE__JOB_CURRENT_ALARM, - ERROR_CODE__JOB_MOTOR_ALARM,ERROR_CODE__JOB_LIDS_OPEN,ERROR_CODE__JOB_ABORTED_BY_USER,ERROR_CODE__JOB_SAFETY_ALARM,ERROR_CODE__JOB_OTHER_ALARM}; + ERROR_CODE__JOB_MOTOR_ALARM,ERROR_CODE__JOB_LIDS_OPEN,ERROR_CODE__JOB_LIDS_OPEN,ERROR_CODE__JOB_ABORTED_BY_USER,ERROR_CODE__JOB_SAFETY_ALARM}; JobTicket *CurrentJob = NULL; JobRequest *CurrentRequest = NULL; @@ -389,7 +389,7 @@ uint32_t ThreadJoggingFunc(int speed) ProcessParametersCopy.dyeingspeed = speed; else ProcessParametersCopy.dyeingspeed = 40; - if (HandleProcessParameters(&ProcessParametersCopy)!= OK) + if (HandleProcessParameters(&ProcessParametersCopy,false)!= OK) { status = FAILED; } @@ -435,6 +435,14 @@ uint32_t ThreadCleaningJobFunc(int speed) status = ERROR; LOG_ERROR(JobIsActive(),"Jog No cleaner dispenser"); } + else if ((ProcessParametersKeep.dryerzone1temp == 0)||((ProcessParametersKeep.headzone1temp == 0)&&(ProcessParametersKeep.headzone2temp == 0)&&(ProcessParametersKeep.headzone3temp == 0))) + { + status = ERROR; + usnprintf(ErrorMsg, 80,"Cleaning job Heaters are off D %d H1 %d H2 %d H3 %d M %d", + (int)ProcessParametersKeep.dryerzone1temp,(int)ProcessParametersKeep.headzone1temp,(int)ProcessParametersKeep.headzone2temp, + (int)ProcessParametersKeep.headzone3temp,(int)ProcessParametersKeep.mixertemp); + Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); + } else { memcpy(&CopyConfigured,&Configured,sizeof(CopyConfigured)); @@ -454,7 +462,7 @@ uint32_t ThreadCleaningJobFunc(int speed) ProcessParametersCopy.dyeingspeed = speed; else ProcessParametersCopy.dyeingspeed = 40; - if (HandleProcessParameters(&ProcessParametersCopy)!= OK) + if (HandleProcessParameters(&ProcessParametersCopy,false)!= OK) { LOG_ERROR(FAILED,"Jog HandleProcessParameters"); status = FAILED; @@ -518,23 +526,7 @@ void ThreadJoggingRequestFunc(MessageContainer* requestContainer) ThreadJoggingResponse response = THREAD_JOGGING_RESPONSE__INIT; - if (JobIsActive() == true) - { - AbortJob(0); - //set the job handler to handle heaters, ids and waste in the state machine - Task_sleep(100); //let the job end procedure role before returning the configuration to normal. - usnprintf(ErrorMsg, 80,"Copy Configured T %d W %d I %d H %d W %d",CopyConfigured[Module_Thread],CopyConfigured[Module_Winder],CopyConfigured[Module_IDS],CopyConfigured[Module_Heaters],CopyConfigured[Module_Waste]); - Report(ErrorMsg, __FILE__, __LINE__, 0, RpWarning, 0, 0); - - - my_free(Ticket.segments); - my_free(TSegment); - my_free(Tspool); - } - else - { - status = ThreadJoggingFunc(request->speed); - } + status = ThreadJoggingFunc(request->speed); responseContainer = createContainer(MESSAGE_TYPE__ThreadJoggingResponse, requestContainer->token, true, &response, &thread_jogging_response__pack, &thread_jogging_response__get_packed_size); if (status!= OK) @@ -553,7 +545,7 @@ void ThreadJoggingRequestFunc(MessageContainer* requestContainer) } void ThreadAbortJoggingFunc(void) { -/* if (JobIsActive() == true) + if (JobIsActive() == true) { AbortJob(0); //set the job handler to handle heaters, ids and waste in the state machine @@ -566,7 +558,7 @@ void ThreadAbortJoggingFunc(void) my_free(TSegment); my_free(Tspool); } -*/ + } void ThreadAbortJoggingRequestFunc(MessageContainer* requestContainer) { @@ -781,7 +773,7 @@ void JobRequestFunc(MessageContainer* requestContainer) //#warning Process parameters in job request are not handled. push separately for now if (Ticket->processparameters) { - if (HandleProcessParameters(Ticket->processparameters)!= OK) + if (HandleProcessParameters(Ticket->processparameters,true)!= OK) { status = FAILED; error = ERROR_CODE__INVALID_PARAMETER; @@ -1197,7 +1189,7 @@ Void jobTask(UArg arg0, UArg arg1) case PrintingResultsFail: JobActive = false; setmachineActive(false); - SetMachineStatus(MACHINE_STATE__Error); + //SetMachineStatus(MACHINE_STATE__Error); resetIdleCounter(); CurrentJob = NULL; //if (CurrentRequest!= NULL) diff --git a/Software/PMR/Messages/MachineStatus/MachineStatus.proto b/Software/PMR/Messages/MachineStatus/MachineStatus.proto index dde725ee2..9b7d2e22b 100644 --- a/Software/PMR/Messages/MachineStatus/MachineStatus.proto +++ b/Software/PMR/Messages/MachineStatus/MachineStatus.proto @@ -10,4 +10,5 @@ message MachineStatus { MachineState State = 1; repeated IDSPackLevel IDSPacksLevels = 2; + double MachineTemperature = 3; } \ No newline at end of file -- cgit v1.3.1 From 9b712a41f08f8a0c13366db730fba6ec927a97d3 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Tue, 10 Dec 2019 18:13:09 +0200 Subject: improved vesrion after initial testing without head card --- .../Embedded/Drivers/Heater/TemperatureSensor.c | 3 ++- .../Embedded/Drivers/Heater/TemperatureSensor.h | 3 ++- .../Embedded/Modules/Control/MillisecTask.c | 28 +++++++++++++++++++-- .../Embedded_SW/Embedded/Modules/Control/control.c | 12 +++++++-- .../Embedded/Modules/Diagnostics/Diagnostics.c | 8 ++++-- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 29 +++++++++++++++++----- .../Embedded/Modules/Thread/Thread_init.c | 10 ++++---- .../Embedded/Modules/Thread/Thread_print.c | 5 +++- .../Embedded/Software Release Notes.txt | 9 +++++++ .../Initialization/PowerOffSequence.c | 2 ++ .../Embedded/StateMachines/Printing/JobSTM.c | 4 --- .../Embedded/StateMachines/Printing/PrintingSTM.c | 7 +++++- 12 files changed, 95 insertions(+), 25 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.c b/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.c index 201df8ec8..1fab20d7e 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.c +++ b/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.c @@ -177,6 +177,7 @@ int TemperatureSensorRead(TEMPERATURE_SENSOR_ID_ENUM SensorId) return TempSensorResponse[SensorId].Temperature_C_mult_by_100; } +#ifndef Use_Head_Card int TemperatureListString(char* str) { int len; @@ -188,7 +189,7 @@ int TemperatureListString(char* str) ,TempSensorResponse[TEMP_SENSE_AN_ENCLOSURETEMP3].Temperature_C_mult_by_100/100); return len; } - +#endif uint32_t Filter_Temparature_Measurement(TEMPERATURE_SENSOR_ID_ENUM SensorId, int32_t Current_Measurement_C, uint32_t NoOfAvrSamples) diff --git a/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.h b/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.h index 88fe8f50a..4f9cb6c79 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.h +++ b/Software/Embedded_SW/Embedded/Drivers/Heater/TemperatureSensor.h @@ -164,8 +164,9 @@ uint32_t CalculateTemperatures(TEMPERATURE_SENSOR_ID_ENUM SensorId, uint32_t Dat int TemperatureSensorRead(TEMPERATURE_SENSOR_ID_ENUM SensorId); // read from buffer +#ifndef Use_Head_Card int TemperatureListString(char* str); - +#endif //The temparature will be at: //TempSensorResponse[TEMP_SENSE_ANALOG_DYEINGH_TEMP1].Temperature_C_mult_by_100 diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 48a28ffe4..8897dfdbb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -226,13 +226,18 @@ void OneMilliSecondMillisecInterrupt(UArg arg0) return ; } uint32_t PT100Activity = 0; +int32_t MillisecReadFromI2CTempSensor(uint32_t TempSensorId, MSecFptr Callback) +{ +#warning call I2C temeratures + return OK; +} + int32_t MillisecReadFromTempSensor(uint32_t TempSensorId, MSecFptr Callback) { if (TempSensorId >= MAX_MAIN_CARD_TEMP_SENS_ID) return -1; PT100Activity++; //read request PT100Data[TempSensorId].Callback = Callback; PT100Data[TempSensorId].Active = true; - return OK; } //typedef uint32_t (* MSecFptr)(uint32_t deviceID, uint32_t ReadValue); @@ -574,11 +579,13 @@ uint32_t MillisecLowLoop(uint32_t tick) //call all modules Millisec functions //test dancers and speed encoders //check all callback units (state machine waiting for completion of a change) - bool Ten_msTick, Hundred_msTick , m90msecTick, Onesecond_Tick,OneMinute_Tick,OneHourTick; + bool Ten_msTick, Hundred_msTick , m20msecTick,m70msecTick,m90msecTick, Onesecond_Tick,OneMinute_Tick,OneHourTick; bool O100Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick; //bool O100Millisecond_Tick,O200Millisecond_Tick,O400Millisecond_Tick,O500Millisecond_Tick,O600Millisecond_Tick,O800Millisecond_Tick,O900Millisecond_Tick; Ten_msTick = (tick%eTenMillisecond == 0) ?true:false; Hundred_msTick = (tick%eHundredMillisecond == 0) ?true:false; + m20msecTick = (tick%eHundredMillisecond == 20) ?true:false; + m70msecTick = (tick%eHundredMillisecond == 70) ?true:false; m90msecTick = (tick%eHundredMillisecond == 90) ?true:false; O100Millisecond_Tick = (tick%eOneSecond == 100) ?true:false; O200Millisecond_Tick = (tick%eOneSecond == 200) ?true:false; @@ -603,6 +610,23 @@ uint32_t MillisecLowLoop(uint32_t tick) if(Machine_Idle_Mode == true) Machine_Idle_Breathing_Led(); } +#ifdef Use_Head_Card + if (m20msecTick) //read odd PT1000 + { + for (Sensor_i = HEAD_PT100_ZONE_1_0X80_0;Sensor_i < HEAD_PT100_ZONE_2_0X80_1;Sensor_i++) + { + MillisecReadFromI2CTempSensor(Sensor_i, NULL); + } +#warning call chip select replace in I2C + } + if (m70msecTick) //read odd PT1000 + { + for (Sensor_i = HEAD_PT100_ZONE_2_0X80_1;Sensor_i < HEAD_PT100_RESERVE_0X8E_1;Sensor_i++) + { + MillisecReadFromI2CTempSensor(Sensor_i, NULL); + } + } +#endif if (m90msecTick) { #ifdef Use_Head_Card diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index f9e6e7009..b60fb3aa4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -45,17 +45,25 @@ //by recieved esign flow of the user from the UI /////////////////////////////////////////////////////////////////////////////////////////// #include "include.h" -#include "Modules/General/GeneralHardware.h" #include #include +#include + #include "drivers/adc_sampling/adc.h" +#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" + #include "Modules/General/buttons.h" +#include "Modules/General/GeneralHardware.h" + +#include "StateMachines/Printing/PrintingSTM.h" #include "control.h" #include "MillisecTask.h" -#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" + + + /******************** Definitions ********************************************/ #define MAX_TANGO_CONTROL_DEVICES 120 /******************** STRUCTURES AND ENUMs ********************************************/ diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index fff75fd54..6e8b50c02 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -514,6 +514,7 @@ void DiagnosticOneSecCollection(void) dispenserspressure[i][DiagnosticsIndex] = GetDispenserPressure(i); //Read_MidTank_Pressure_Sensor + MidTankpressure[i][0] = Get_MidTank_Pressure_Sensor(i); } } void Diagnostic100msecCollection(void) @@ -523,7 +524,7 @@ void Diagnostic100msecCollection(void) return; //DiagnosticLoadSpeedSensor(getSensorSpeedData()); - if (DiagnosticMode == Diagnostic_Extreme_Mode) + if (DiagnosticMode != Diagnostic_Extreme_Mode) DiagnosticTenMsecCollection(); //call the 10msec function every 100 msec to reduce transport if (DiagnosticMode >= Diagnostic_Extended_Mode) @@ -681,13 +682,14 @@ void SendDiagnostics(void) DiagnosticsMonitor.headzone4temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4]; DiagnosticsMonitor.headzone5temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5]; DiagnosticsMonitor.headzone6temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6]; +#ifdef Use_Head_Card DiagnosticsMonitor.headzone7temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ7]; DiagnosticsMonitor.headzone8temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ8]; DiagnosticsMonitor.headzone9temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ9]; DiagnosticsMonitor.headzone10temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ10]; DiagnosticsMonitor.headzone11temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ11]; DiagnosticsMonitor.headzone12temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ12]; - +#endif DiagnosticsMonitor.dryerzone1temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature]; DiagnosticsMonitor.dryerzone2temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain]; DiagnosticsMonitor.dryerzone3temperature = HeaterTemperature[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary]; @@ -699,12 +701,14 @@ void SendDiagnostics(void) DiagnosticsMonitor.n_headzone4temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ4]; DiagnosticsMonitor.n_headzone5temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ5]; DiagnosticsMonitor.n_headzone6temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ6]; +#ifdef Use_Head_Card DiagnosticsMonitor.n_headzone7temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ7]; DiagnosticsMonitor.n_headzone8temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ8]; DiagnosticsMonitor.n_headzone9temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ9]; DiagnosticsMonitor.n_headzone10temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ10]; DiagnosticsMonitor.n_headzone11temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ11]; DiagnosticsMonitor.n_headzone12temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ12]; +#endif DiagnosticsMonitor.n_dryerzone1temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature]; DiagnosticsMonitor.n_dryerzone2temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain]; DiagnosticsMonitor.n_dryerzone3temperature = HeaterCounterIndex[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary]; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 3b55758e4..3af6416cb 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -48,7 +48,7 @@ int DispenserSamplePointer[MAX_SYSTEM_DISPENSERS] = {0}; double DispenserNormalizedErrorCoEfficient[MAX_SYSTEM_DISPENSERS] = {0}; double lubricant_speed = 0.0; HardwarePidControlType ThreadDispenserIdToControlId[MAX_SYSTEM_DISPENSERS] = { HARDWARE_PID_CONTROL_TYPE__Dispenser1,HARDWARE_PID_CONTROL_TYPE__Dispenser2,HARDWARE_PID_CONTROL_TYPE__Dispenser3,HARDWARE_PID_CONTROL_TYPE__Dispenser4,HARDWARE_PID_CONTROL_TYPE__Dispenser5,HARDWARE_PID_CONTROL_TYPE__Dispenser6,HARDWARE_PID_CONTROL_TYPE__Dispenser7,HARDWARE_PID_CONTROL_TYPE__Dispenser8}; - +JobUploadStrategy uploadstrategy = JOB_UPLOAD_STRATEGY__Default; bool DispenserReady[MAX_SYSTEM_DISPENSERS] = {true}; bool IDS_Active = false; /******************** STRUCTURES AND ENUMs ********************************************/ @@ -300,7 +300,8 @@ JobDescriptionFileBrushStop *FirstBrushStop = NULL; { LOG_ERROR (BrushStop->index, "no dispensers in brushstop"); } - FreeBrushStopFileData(BrushStop); + if (FirstBrushStop!= BrushStop) + FreeBrushStopFileData(BrushStop); BrushStop = NULL; } else @@ -356,6 +357,7 @@ c. Go to step 2.a x Segment.BrushStopsCount. JobTicket* JobTicket = JobDetails; int Dispenser_i, Segment_i,Brush_i,DispenserId; + uploadstrategy = JobTicket->uploadstrategy; if (JobTicket->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) { return (IDS_MapDispenserUsedinFileJob(JobDetails)); @@ -480,7 +482,6 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) //******************************************************************************************************************** uint32_t IDS_Prepare_Callback(uint32_t DispenserId, uint32_t ReadValue) { - bool pressureReady = false; int i; int NumofReadyDispensers = 0; TimerMotors_t HW_Motor_Id; @@ -534,16 +535,18 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) if (NumofReadyDispensers>=NumOfActiveDispensers) { pressureReady = true; + Report("pressureReady = true;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); } if ((DispenserBuildTimeCounter >= DispenserPrepareTimeout)||(pressureReady == true)) { DispenserBuildTimeCounter = 0; pressureReady = true; + Report("pressureReady = true or timeout;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); } } else if (endOfPrepareWCF == false) { - if ((0 == DispenserBuildTimeCounter)&&(FirstBrushStop)) + if ((DispenserBuildTimeCounter == PRESSURE_READ_TIME_GAP)&&(FirstBrushStop)) { Report("start prepare dispensers at rate * WFCF",__FILE__,__LINE__,InterSegmentStepsCount,RpWarning,(int)lInterSegmentLength,0); if (FirstBrushStop) @@ -600,6 +603,16 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); //SendJobProgress(0.0, 0, false, IdsMessage); } + else + { + if (DispenserUsedInJob[DispenserId] == true) + { + MotorStop(HW_Motor_Id, Hard_Hiz); + CurrentDispenserSpeed[Dispenser_i] = 0; + usnprintf(IdsMessage, 80,"Presegment Prepare Dispenser %d stopped",DispenserId,(int) segmentfirst_speed); + Report(IdsMessage, __FILE__, __LINE__, Dispenser_i, RpWarning, segmentfirst_speed, 0); + } + } }//for }//if n_dis } @@ -609,9 +622,13 @@ uint32_t InactiveDispenserHome(uint32_t DispenserId, uint32_t ReadValue) //close waste valve one second before segment - trial Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Head); } - if (InterSegmentStartWFCFDispensers >= DispenserBuildTimeCounter) + if (DispenserBuildTimeCounter >= InterSegmentStartWFCFDispensers) { endOfPrepareWCF = true; + FreeBrushStopFileData(FirstBrushStop); + FirstBrushStop =NULL; + Report("endOfPrepareWCF = true;",__FILE__,DispenserBuildTimeCounter,NumofReadyDispensers,RpWarning,(int)NumOfActiveDispensers,0); + } } //start new stage @@ -1242,7 +1259,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) } else { - LOG_ERROR(FileBrushStop,"BrushStopReadError"); + LOG_ERROR(FileBrushStop,"End run - BrushStopReadError"); JobEndReason = JOB_OUT_OF_DYE; PreSegmentReady(Module_IDS,ModuleFail); } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 226bb2559..0df950f34 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -154,12 +154,12 @@ char DancerConfigPath[50] = "0://SysInfo//DancCfg.cfg"; uint32_t StoreDancerConfigMessage() { uint32_t status = OK; - /* FRESULT Fresult = FR_OK; - // HardwareConfiguration DancerConfig; - // HardwareDancer Dancers[MAX_SYSTEM_DANCERS]; + // FRESULT Fresult = FR_OK; + HardwareConfiguration DancerConfig; + HardwareDancer Dancers[MAX_SYSTEM_DANCERS]; // uint8_t* response_buffer; // size_t response_size = 0; - // int Dancer_i; + int Dancer_i; hardware_configuration__init(&DancerConfig); DancerConfig.dancers = (HardwareDancer**)my_malloc(sizeof(HardwareDancer*)*MAX_SYSTEM_DANCERS); @@ -174,7 +174,7 @@ uint32_t StoreDancerConfigMessage() DancerConfig.n_dancers++; DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint; } - */ + status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_0,DancersCfg[0].zeropoint); status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_1,DancersCfg[1].zeropoint); status |= MCU_E2PromProgram(EEPROM_STORAGE_DANCER_2,DancersCfg[2].zeropoint); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 8ccde6feb..34934af0c 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -300,9 +300,12 @@ uint32_t PoolerThreadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue) { if (PrepareState == true) { +#ifdef Use_Head_Card + strcpy(Lenstr,"Heating up"); +#else //later - add temperatures TemperatureListString(Lenstr); - +#endif SendJobProgress(0.0,0,false, Lenstr); } else diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt index 63b06e673..8e4424747 100644 --- a/Software/Embedded_SW/Embedded/Software Release Notes.txt +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -12,6 +12,15 @@ IDS: *dispenser data, *improve autofill on job start, *puller_tension from RML a Thread: *real dryer rampup. dancers from EEPROM only. *insure rockers motors voltage value; print: *prevent job on open covers (dryer, head) + +Embedded SW Release note - Version 1.4.5.104 (alpha 1 ++) +============================================================= +restart HW and report if FPGA fails +stop led blinking when jogging job fails +fix IDS bug that prevented cleaning job at power off +log power off temperature. fix bug that causes premature shutoff (PT100 spike) + + Embedded SW Release note - Version 1.4.5.100 (alpha 1 +) ============================================================= magnet handling improved diff --git a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c index 79191072a..e4efad2a0 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Initialization/PowerOffSequence.c @@ -70,6 +70,7 @@ void PowerOffSetTemperatureThreshold (int32_t temperature) if (temperature) { PowerOffTemperatureThreshold = temperature*100; + Report("PowerOff Set Temperature",__FILE__,__LINE__,(int)PowerOffTemperatureThreshold,RpWarning,(int)3600,0); } } /*******************************************************************************************************/ @@ -373,6 +374,7 @@ uint32_t PowerOffWaitForTemperatureCallback(uint32_t IfIndex, uint32_t BusyFlag) /*******************************************************************************************************/ uint32_t PowerOffWaitForTemperature(void) { + Report("PowerOff Wait For Temperature",__FILE__,__LINE__,(int)PowerOffTemperatureThreshold,RpWarning,(int)3600,0); if (WaitForProcessControlId == 0xFF) { WaitForProcessCounter = 0; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c index 651cc636e..83f4f032e 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/JobSTM.c @@ -98,8 +98,6 @@ JobSpool *Tspool; bool CopyConfigured[MAX_SYSTEM_MODULES]; bool CleaningJobActive = false, JoggingJobActive = false; char ErrorMsg[100]; -JobUploadStrategy uploadstrategy = JOB_UPLOAD_STRATEGY__Default; - ModuleStateEnum PrepareWaiting[MAX_SYSTEM_MODULES] = {ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle,ModuleIdle}; double job_length = 0.0; @@ -747,11 +745,9 @@ void JobRequestFunc(MessageContainer* requestContainer) if (CurrentJob->uploadstrategy == JOB_UPLOAD_STRATEGY__JobDescriptionFile) { LOG_ERROR(JobActive, "Job upload strategy file"); - uploadstrategy = JOB_UPLOAD_STRATEGY__JobDescriptionFile; } else { - uploadstrategy = JOB_UPLOAD_STRATEGY__Default; n_segments = CurrentJob->n_segments; } status = PASSED; diff --git a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c index 671ab1dd8..587b1d2e8 100644 --- a/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c +++ b/Software/Embedded_SW/Embedded/StateMachines/Printing/PrintingSTM.c @@ -384,7 +384,11 @@ uint32_t PreSegmentReady(int ModuleId, ModuleStateEnum result) } PreSegmentWaiting[ModuleId] = result; - if (result == ModuleFail) status = ERROR; + if (result == ModuleFail) + { + status = ERROR; + Report("PreSegmentReady Fail!",__FILE__,__LINE__,(int)ModuleId,RpWarning,(int)result,0); + } for (i=0;imessageId = PreSegmentResultsFail; SendJobProgress(0.0, 0, false, "PreSegment Failed"); + Report("PreSegment Fail!",__FILE__,__LINE__,(int)ModuleId,RpWarning,(int)result,0); } //memcpy(Message.messageData,JobDetails,MAX_MSG_LEN); Message.msglen = 10; -- cgit v1.3.1 From e1a2dde7fe9c728dfb3247b34d89b947b4132fd2 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Mon, 23 Dec 2019 10:54:31 +0200 Subject: support stop loading message and some fixes to the thread loading --- .../Embedded_SW/Embedded/Communication/Container.c | 3 + .../Communication/PMR/Common/MessageType.pb-c.c | 14 +- .../Communication/PMR/Common/MessageType.pb-c.h | 4 +- .../PMR/MachineStatus/MachineState.pb-c.c | 4 +- .../PMR/MachineStatus/MachineState.pb-c.h | 2 +- .../PMR/MachineStatus/MachineStatus.pb-c.h | 2 +- .../ThreadLoading/StopThreadLoadingRequest.pb-c.c | 72 +++++++ .../ThreadLoading/StopThreadLoadingRequest.pb-c.h | 70 ++++++ .../ThreadLoading/StopThreadLoadingResponse.pb-c.c | 72 +++++++ .../ThreadLoading/StopThreadLoadingResponse.pb-c.h | 70 ++++++ .../Embedded/Drivers/Motors/MotorActions.c | 37 ++-- .../Embedded/Drivers/SSI_Comm/Dancer/Dancer.c | 1 + .../Embedded/Drivers/SSI_Comm/Dancer/Dancer.h | 2 +- .../Embedded/Modules/AlarmHandling/AlarmHandling.c | 6 +- .../Embedded/Modules/Control/MillisecTask.c | 2 +- .../Embedded/Modules/Diagnostics/Diagnostics.c | 6 +- .../Embedded_SW/Embedded/Modules/IDS/IDS_print.c | 11 +- .../Embedded/Modules/Stubs_Handler/Progress.c | 14 ++ .../Embedded/Modules/Thread/ThreadLoad.c | 234 ++++++++++++++++++--- .../Embedded/Modules/Thread/Thread_Winder.c | 6 +- .../Embedded/Modules/Thread/Thread_ex.h | 1 + .../Embedded/Modules/Thread/Thread_init.c | 2 +- 22 files changed, 566 insertions(+), 69 deletions(-) create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.c create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.c create mode 100644 Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h (limited to 'Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c') diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index 220a83110..eed14b2e7 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -470,6 +470,9 @@ void receive_callback(char* buffer, size_t length) case MESSAGE_TYPE__ContinueThreadLoadingRequest: ContinueThreadLoadingFunc(requestContainer); break; + case MESSAGE_TYPE__StopThreadLoadingRequest: + StopThreadLoadingFunc(requestContainer); + break; default: //unsupported message type !! LOG_ERROR (requestContainer->type,"unsupported message type"); diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.c index 11b3ec7b2..9bfdc7232 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.c @@ -7,7 +7,7 @@ #endif #include "MessageType.pb-c.h" -static const ProtobufCEnumValue message_type__enum_values_by_number[237] = +static const ProtobufCEnumValue message_type__enum_values_by_number[239] = { { "None", "MESSAGE_TYPE__None", 0 }, { "ErrorResponse", "MESSAGE_TYPE__ErrorResponse", 1 }, @@ -246,11 +246,13 @@ static const ProtobufCEnumValue message_type__enum_values_by_number[237] = { "StartThreadLoadingResponse", "MESSAGE_TYPE__StartThreadLoadingResponse", 11001 }, { "ContinueThreadLoadingRequest", "MESSAGE_TYPE__ContinueThreadLoadingRequest", 11002 }, { "ContinueThreadLoadingResponse", "MESSAGE_TYPE__ContinueThreadLoadingResponse", 11003 }, + { "StopThreadLoadingRequest", "MESSAGE_TYPE__StopThreadLoadingRequest", 11004 }, + { "StopThreadLoadingResponse", "MESSAGE_TYPE__StopThreadLoadingResponse", 11005 }, }; static const ProtobufCIntRange message_type__value_ranges[] = { -{0, 0},{3, 2},{1000, 104},{2000, 121},{3000, 167},{4000, 177},{5000, 185},{6000, 189},{7000, 195},{8000, 219},{9000, 225},{10000, 229},{11000, 233},{0, 237} +{0, 0},{3, 2},{1000, 104},{2000, 121},{3000, 167},{4000, 177},{5000, 185},{6000, 189},{7000, 195},{8000, 219},{9000, 225},{10000, 229},{11000, 233},{0, 239} }; -static const ProtobufCEnumValueIndex message_type__enum_values_by_name[237] = +static const ProtobufCEnumValueIndex message_type__enum_values_by_name[239] = { { "AbortJobRequest", 169 }, { "AbortJobResponse", 170 }, @@ -377,6 +379,8 @@ static const ProtobufCEnumValueIndex message_type__enum_values_by_name[237] = { "StopEventsNotificationResponse", 154 }, { "StopMachineStatusUpdateRequest", 227 }, { "StopMachineStatusUpdateResponse", 228 }, + { "StopThreadLoadingRequest", 237 }, + { "StopThreadLoadingResponse", 238 }, { "StubAbortJobRequest", 100 }, { "StubAbortJobResponse", 101 }, { "StubCartridgeReadRequest", 6 }, @@ -497,9 +501,9 @@ const ProtobufCEnumDescriptor message_type__descriptor = "MessageType", "MessageType", "", - 237, + 239, message_type__enum_values_by_number, - 237, + 239, message_type__enum_values_by_name, 13, message_type__value_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.h index 1989c473a..3c6bbc146 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Common/MessageType.pb-c.h @@ -256,7 +256,9 @@ typedef enum _MessageType { MESSAGE_TYPE__StartThreadLoadingRequest = 11000, MESSAGE_TYPE__StartThreadLoadingResponse = 11001, MESSAGE_TYPE__ContinueThreadLoadingRequest = 11002, - MESSAGE_TYPE__ContinueThreadLoadingResponse = 11003 + MESSAGE_TYPE__ContinueThreadLoadingResponse = 11003, + MESSAGE_TYPE__StopThreadLoadingRequest = 11004, + MESSAGE_TYPE__StopThreadLoadingResponse = 11005 PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(MESSAGE_TYPE) } MessageType; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.c index 0cfa95c0e..e3753082e 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.c @@ -9,7 +9,7 @@ #include "MachineState.pb-c.h" static const ProtobufCEnumValue machine_state__enum_values_by_number[7] = { - { "Initializing", "MACHINE_STATE__Initializing", 0 }, + { "PowerUp", "MACHINE_STATE__PowerUp", 0 }, { "Ready", "MACHINE_STATE__Ready", 1 }, { "Sleep", "MACHINE_STATE__Sleep", 2 }, { "Error", "MACHINE_STATE__Error", 3 }, @@ -23,8 +23,8 @@ static const ProtobufCIntRange machine_state__value_ranges[] = { static const ProtobufCEnumValueIndex machine_state__enum_values_by_name[7] = { { "Error", 3 }, - { "Initializing", 0 }, { "PowerOff", 4 }, + { "PowerUp", 0 }, { "PreparingJob", 5 }, { "Ready", 1 }, { "RunningJob", 6 }, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.h index 32fa5f56f..bbb414d42 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineState.pb-c.h @@ -20,7 +20,7 @@ PROTOBUF_C__BEGIN_DECLS /* --- enums --- */ typedef enum _MachineState { - MACHINE_STATE__Initializing = 0, + MACHINE_STATE__PowerUp = 0, MACHINE_STATE__Ready = 1, MACHINE_STATE__Sleep = 2, MACHINE_STATE__Error = 3, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineStatus.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineStatus.pb-c.h index 0777f8855..a8a54eb13 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineStatus.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/MachineStatus/MachineStatus.pb-c.h @@ -37,7 +37,7 @@ struct _MachineStatus }; #define MACHINE_STATUS__INIT \ { PROTOBUF_C_MESSAGE_INIT (&machine_status__descriptor) \ - , 0, MACHINE_STATE__Initializing, 0,NULL, 0, 0 } + , 0, MACHINE_STATE__PowerUp, 0,NULL, 0, 0 } /* MachineStatus methods */ diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.c new file mode 100644 index 000000000..7087a56e7 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.c @@ -0,0 +1,72 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: StopThreadLoadingRequest.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "StopThreadLoadingRequest.pb-c.h" +void stop_thread_loading_request__init + (StopThreadLoadingRequest *message) +{ + static const StopThreadLoadingRequest init_value = STOP_THREAD_LOADING_REQUEST__INIT; + *message = init_value; +} +size_t stop_thread_loading_request__get_packed_size + (const StopThreadLoadingRequest *message) +{ + assert(message->base.descriptor == &stop_thread_loading_request__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t stop_thread_loading_request__pack + (const StopThreadLoadingRequest *message, + uint8_t *out) +{ + assert(message->base.descriptor == &stop_thread_loading_request__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t stop_thread_loading_request__pack_to_buffer + (const StopThreadLoadingRequest *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &stop_thread_loading_request__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +StopThreadLoadingRequest * + stop_thread_loading_request__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (StopThreadLoadingRequest *) + protobuf_c_message_unpack (&stop_thread_loading_request__descriptor, + allocator, len, data); +} +void stop_thread_loading_request__free_unpacked + (StopThreadLoadingRequest *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &stop_thread_loading_request__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +#define stop_thread_loading_request__field_descriptors NULL +#define stop_thread_loading_request__field_indices_by_name NULL +#define stop_thread_loading_request__number_ranges NULL +const ProtobufCMessageDescriptor stop_thread_loading_request__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "StopThreadLoadingRequest", + "StopThreadLoadingRequest", + "StopThreadLoadingRequest", + "", + sizeof(StopThreadLoadingRequest), + 0, + stop_thread_loading_request__field_descriptors, + stop_thread_loading_request__field_indices_by_name, + 0, stop_thread_loading_request__number_ranges, + (ProtobufCMessageInit) stop_thread_loading_request__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h new file mode 100644 index 000000000..0c9e6d894 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h @@ -0,0 +1,70 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: StopThreadLoadingRequest.proto */ + +#ifndef PROTOBUF_C_StopThreadLoadingRequest_2eproto__INCLUDED +#define PROTOBUF_C_StopThreadLoadingRequest_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _StopThreadLoadingRequest StopThreadLoadingRequest; + + +/* --- enums --- */ + + +/* --- messages --- */ + +struct _StopThreadLoadingRequest +{ + ProtobufCMessage base; +}; +#define STOP_THREAD_LOADING_REQUEST__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&stop_thread_loading_request__descriptor) \ + } + + +/* StopThreadLoadingRequest methods */ +void stop_thread_loading_request__init + (StopThreadLoadingRequest *message); +size_t stop_thread_loading_request__get_packed_size + (const StopThreadLoadingRequest *message); +size_t stop_thread_loading_request__pack + (const StopThreadLoadingRequest *message, + uint8_t *out); +size_t stop_thread_loading_request__pack_to_buffer + (const StopThreadLoadingRequest *message, + ProtobufCBuffer *buffer); +StopThreadLoadingRequest * + stop_thread_loading_request__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void stop_thread_loading_request__free_unpacked + (StopThreadLoadingRequest *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*StopThreadLoadingRequest_Closure) + (const StopThreadLoadingRequest *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor stop_thread_loading_request__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_StopThreadLoadingRequest_2eproto__INCLUDED */ diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.c new file mode 100644 index 000000000..69b3c91f4 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.c @@ -0,0 +1,72 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: StopThreadLoadingResponse.proto */ + +/* Do not generate deprecated warnings for self */ +#ifndef PROTOBUF_C__NO_DEPRECATED +#define PROTOBUF_C__NO_DEPRECATED +#endif + +#include "StopThreadLoadingResponse.pb-c.h" +void stop_thread_loading_response__init + (StopThreadLoadingResponse *message) +{ + static const StopThreadLoadingResponse init_value = STOP_THREAD_LOADING_RESPONSE__INIT; + *message = init_value; +} +size_t stop_thread_loading_response__get_packed_size + (const StopThreadLoadingResponse *message) +{ + assert(message->base.descriptor == &stop_thread_loading_response__descriptor); + return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); +} +size_t stop_thread_loading_response__pack + (const StopThreadLoadingResponse *message, + uint8_t *out) +{ + assert(message->base.descriptor == &stop_thread_loading_response__descriptor); + return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); +} +size_t stop_thread_loading_response__pack_to_buffer + (const StopThreadLoadingResponse *message, + ProtobufCBuffer *buffer) +{ + assert(message->base.descriptor == &stop_thread_loading_response__descriptor); + return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); +} +StopThreadLoadingResponse * + stop_thread_loading_response__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data) +{ + return (StopThreadLoadingResponse *) + protobuf_c_message_unpack (&stop_thread_loading_response__descriptor, + allocator, len, data); +} +void stop_thread_loading_response__free_unpacked + (StopThreadLoadingResponse *message, + ProtobufCAllocator *allocator) +{ + if(!message) + return; + assert(message->base.descriptor == &stop_thread_loading_response__descriptor); + protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); +} +#define stop_thread_loading_response__field_descriptors NULL +#define stop_thread_loading_response__field_indices_by_name NULL +#define stop_thread_loading_response__number_ranges NULL +const ProtobufCMessageDescriptor stop_thread_loading_response__descriptor = +{ + PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, + "StopThreadLoadingResponse", + "StopThreadLoadingResponse", + "StopThreadLoadingResponse", + "", + sizeof(StopThreadLoadingResponse), + 0, + stop_thread_loading_response__field_descriptors, + stop_thread_loading_response__field_indices_by_name, + 0, stop_thread_loading_response__number_ranges, + (ProtobufCMessageInit) stop_thread_loading_response__init, + NULL,NULL,NULL /* reserved[123] */ +}; diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h new file mode 100644 index 000000000..69803107b --- /dev/null +++ b/Software/Embedded_SW/Embedded/Communication/PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h @@ -0,0 +1,70 @@ +/* Generated by the protocol buffer compiler. DO NOT EDIT! */ +/* Generated from: StopThreadLoadingResponse.proto */ + +#ifndef PROTOBUF_C_StopThreadLoadingResponse_2eproto__INCLUDED +#define PROTOBUF_C_StopThreadLoadingResponse_2eproto__INCLUDED + +#include + +PROTOBUF_C__BEGIN_DECLS + +#if PROTOBUF_C_VERSION_NUMBER < 1003000 +# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. +#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. +#endif + + +typedef struct _StopThreadLoadingResponse StopThreadLoadingResponse; + + +/* --- enums --- */ + + +/* --- messages --- */ + +struct _StopThreadLoadingResponse +{ + ProtobufCMessage base; +}; +#define STOP_THREAD_LOADING_RESPONSE__INIT \ + { PROTOBUF_C_MESSAGE_INIT (&stop_thread_loading_response__descriptor) \ + } + + +/* StopThreadLoadingResponse methods */ +void stop_thread_loading_response__init + (StopThreadLoadingResponse *message); +size_t stop_thread_loading_response__get_packed_size + (const StopThreadLoadingResponse *message); +size_t stop_thread_loading_response__pack + (const StopThreadLoadingResponse *message, + uint8_t *out); +size_t stop_thread_loading_response__pack_to_buffer + (const StopThreadLoadingResponse *message, + ProtobufCBuffer *buffer); +StopThreadLoadingResponse * + stop_thread_loading_response__unpack + (ProtobufCAllocator *allocator, + size_t len, + const uint8_t *data); +void stop_thread_loading_response__free_unpacked + (StopThreadLoadingResponse *message, + ProtobufCAllocator *allocator); +/* --- per-message closures --- */ + +typedef void (*StopThreadLoadingResponse_Closure) + (const StopThreadLoadingResponse *message, + void *closure_data); + +/* --- services --- */ + + +/* --- descriptors --- */ + +extern const ProtobufCMessageDescriptor stop_thread_loading_response__descriptor; + +PROTOBUF_C__END_DECLS + + +#endif /* PROTOBUF_C_StopThreadLoadingResponse_2eproto__INCLUDED */ diff --git a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c index 54a7b1219..08ffac91f 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c +++ b/Software/Embedded_SW/Embedded/Drivers/Motors/MotorActions.c @@ -183,6 +183,9 @@ uint32_t MotorMoveWithCallback (TimerMotors_t MotorId,bool direction, uint32_t S //call driver action to device id with the parameter //SetMotorSpeed (deviceId, parameter); MotorCallback[MotorId] = callback; + MotorTimeout[MotorId] = 0; + MotorTimeLag[MotorId] = 20; + MotorTimeLimit[MotorId] = timeout; //MotorStop(MotorId,Hard_Hiz ); MotorMove(MotorId,direction,Steps ); @@ -261,6 +264,7 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / MotorControlCallback[MotorId] = 0; MotorControlId[MotorId] = 0xFF; MotorStop(MotorId,Hard_Hiz ); + /* Task_sleep(5); MotorMove(MotorId,DrierBackLashDirection,DryerBackLash ); Report("Motor to stopper move to backlash",__FILE__,MotorId,DryerBackLash,RpWarning,DrierBackLashDirection,0); @@ -269,15 +273,17 @@ uint32_t MotorVerifiedCallBackFunction(uint32_t IfIndex, uint32_t ArmPosition) / MotorStop(MotorId,Hard_Stop ); Task_sleep(5); Read_Dryer_ENC_Position(); //trigger the next call - Task_sleep(5); - DrierZeroPosition = Read_Dryer_ENC_Position(); //trigger the next call - MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CENTER,DrierZeroPosition); + Task_sleep(5);*/ +// MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CENTER,DrierZeroPosition); Report("MotorVerifiedCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,DryerBackLash,0); //call the module callback if (MotorCallback[MotorId]) MotorCallback[MotorId](MotorId,ArmPosition); + MotorSetDirection(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize); + MotorMovetoEncoderPosition(HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM,NULL,1000); + DrierZeroPosition = Read_Dryer_ENC_Position(); //trigger the next call } else @@ -319,11 +325,11 @@ uint32_t MotorMoveToStopper (TimerMotors_t MotorId,bool direction, uint32_t Spee memset(ArmSamples,0,sizeof(ArmSamples)); ArmSamplePointer = 0; Read_Dryer_ENC_Position(); - Task_sleep(20); - Initialcurrentposition = Control_Read_Dryer_Position(0,0); + Task_sleep(10); + Initialcurrentposition = Read_Dryer_ENC_Position(); cycles = 0; - StoredMotorPosition[MotorId] = MotorGetPosition(MotorId); - Report("MotorMoveToStopper initial position",__FILE__,__LINE__,StoredMotorPosition[MotorId],RpWarning,Speed,0); + StoredMotorPosition[MotorId] = Read_Dryer_ENC_Position(); + Report("MotorMoveToStopper initial position",__FILE__,__LINE__,StoredMotorPosition[MotorId],RpWarning,Initialcurrentposition,0); MotorSetSpeed (MotorId, Speed); MotorControlId[MotorId] = AddControlCallback(NULL, MotorVerifiedCallBackFunction, 20,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorVerifiedCallBackFunction; @@ -350,7 +356,7 @@ uint32_t MotorMoveToDrierPositionCallBackFunction(uint32_t IfIndex, uint32_t Rea //CallbackCalls = 0; } Read_Dryer_ENC_Position(); - if (abs(ReadValue - DrierZeroPosition)<5) + if (abs(ReadValue - DrierZeroPosition)<1) { Report("MotorMoveToDrierPosition end",__FILE__,__LINE__,DrierZeroPosition,RpWarning,ReadValue,0); //stop this control loop @@ -396,10 +402,11 @@ uint32_t MotorMovetoEncoderPosition (TimerMotors_t MotorId, callback_fptr callb callback(MotorId,0); return OK; } + //Report("MotorMovetoEncoderPosition direction",__FILE__,__LINE__,direction,RpWarning,15,0); //MotorSetDirection( MotorId, direction); - MotorSetSpeed (MotorId, 50); + MotorSetSpeed (MotorId, 30); MotorControlId[MotorId] = AddControlCallback(NULL, MotorMoveToDrierPositionCallBackFunction, 2,Control_Read_Dryer_Position,(IfTypeMotors*0x100+MotorId), MotorId, 0 ); MotorControlCallback[MotorId] = MotorMoveToDrierPositionCallBackFunction; return MotorControlId[MotorId]; @@ -436,9 +443,10 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO MotorId = Control_Read_Dryer_Position(0,0); Report("MotorMoveCallBackFunction",__FILE__,__LINE__,DrierZeroPosition,RpWarning,MotorId,0); } - MotorId = IfIndex&0xFF; - if (BusyFlag == NOTBUSY) + MotorTimeout[MotorId]+=MotorTimeLag[MotorId]; + + if ((BusyFlag == NOTBUSY)||((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0))) { /*if (MotorId == HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM) { @@ -451,10 +459,15 @@ uint32_t MotorMoveCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) //TODO MotorControlId[MotorId] = 0xFF; //possibly: start regular control (speed etc) //uint32_t ControlId = AddControlCallback(NULL,ControlCBFunction Callback, eOneMillisecond, (IfTypeMotors*0x100+MotorId), deviceId, Parameter ); - + if ((MotorTimeout[MotorId]>=MotorTimeLimit[MotorId])&&(MotorTimeLimit[MotorId]>0)) + { + Report("motor timeout",__FILE__,__LINE__,MotorId,RpMessage,MotorTimeout[MotorId],0); + } //call the module callback if (MotorCallback[MotorId]) + { MotorCallback[MotorId](MotorId,BusyFlag); + } } return OK; diff --git a/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.c b/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.c index de2ceb698..b2be0d407 100644 --- a/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.c +++ b/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.c @@ -82,6 +82,7 @@ uint32_t Read_Dryer_ENC_Position () // must call FPGA_SSI_Dryer_ENC_Transnit first! FPGA_SSI_Dryer_ENC_Receive(); FPGA_SSI_Dryer_ENC_Transnit(); + //REPORT_MSG(Dryer_ENC.Position,"Read_Dryer_ENC_Position"); return Dryer_ENC.Position; } uint32_t Control_Read_Dryer_Position(HardwareDancerType DancerId, uint32_t Parameter1) diff --git a/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.h b/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.h index 2b3b33dff..33a961c58 100644 --- a/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.h +++ b/Software/Embedded_SW/Embedded/Drivers/SSI_Comm/Dancer/Dancer.h @@ -10,7 +10,7 @@ #include "PMR/Hardware/HardwareDancerType.pb-c.h" uint32_t Read_Dancer_Position (HardwareDancerType DancerId); -uint32_t Control_Read_Dancer_Position(HardwareDancerType DancerId, uint32_t Parameter1, uint32_t Parameter2); +uint32_t Control_Read_Dancer_Position(HardwareDancerType DancerId, uint32_t Parameter1); uint32_t Read_Dryer_ENC_Position (); uint32_t Control_Read_Dryer_Position(uint32_t DryerID, uint32_t Parameter1); diff --git a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c index eea72d6b5..5c16bda14 100644 --- a/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c +++ b/Software/Embedded_SW/Embedded/Modules/AlarmHandling/AlarmHandling.c @@ -1114,7 +1114,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if ((doubleValue >= (float)(AlarmItem[Alarm_i].AlarmValue*CurrentAlarmHighLimit)) || (doubleValue <= (float)(AlarmItem[Alarm_i].AlarmValue*CurrentAlarmLowLimit))) { Status = true; - ReportWithPackageFilter(AlarmFilter,"OverCurrent Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,AlarmItem[Alarm_i].EventType, RpMessage, (int)(doubleValue*100), 0); + if (AlarmState[Alarm_i].Status == false) + ReportWithPackageFilter(AlarmFilter,"OverCurrent Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,(int)(AlarmItem[Alarm_i].AlarmValue*100), RpMessage, (int)(doubleValue*100), 0); } } else @@ -1122,7 +1123,8 @@ uint32_t AlarmHandlingLoop(uint32_t tick) if (doubleValue <= 0.1) { Status = true; - ReportWithPackageFilter(AlarmFilter,"loop break Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,AlarmItem[Alarm_i].EventType, RpMessage, (int)(doubleValue*100), 0); + if (AlarmState[Alarm_i].Status == false) + ReportWithPackageFilter(AlarmFilter,"loop break Alarm ON ", __FILE__,AlarmItem[Alarm_i].DeviceId,(int)(AlarmItem[Alarm_i].AlarmValue*100), RpMessage, (int)(doubleValue*100), 0); } } diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 1605092e5..fb3fd1afb 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -442,7 +442,7 @@ uint32_t MillisecLoop(uint32_t tick) /*else if(Sensor_i < MAX_HEAD_CARD_TEMP_SENS_ID) - move to the function control_HeadCard_PT100 { //HeadCard_Toggle_PT100(Sensor_i); - //deley?? + //delay?? //HeadADCPT100_SendReadDataCommand(Sensor_i); } else if(Sensor_i < MAX_WHS_CARD_TEMP_SENS_ID) diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index 6b2cf0021..61767c2d6 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -386,9 +386,9 @@ void DiagnosticTenMsecCollection(void) /*if (JobIsActive()== false) return;*/ - DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0,0)); - DiagnosticLoadDancer(POOLER_DANCER,Control_Read_Dancer_Position(POOLER_DANCER, 0,0)); - DiagnosticLoadDancer(FEEDER_DANCER,Control_Read_Dancer_Position(FEEDER_DANCER, 0,0)); + DiagnosticLoadDancer(WINDER_DANCER,Control_Read_Dancer_Position(WINDER_DANCER, 0)); + DiagnosticLoadDancer(POOLER_DANCER,Control_Read_Dancer_Position(POOLER_DANCER, 0)); + DiagnosticLoadDancer(FEEDER_DANCER,Control_Read_Dancer_Position(FEEDER_DANCER, 0)); DiagnosticLoadDancerError(WINDER_DANCER,ThreadGetMotorCalculatedError(WINDER_DANCER)); DiagnosticLoadDancerError(POOLER_DANCER,ThreadGetMotorCalculatedError(POOLER_DANCER)); diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 9fdcaaf1f..28bb191fe 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -1308,6 +1308,7 @@ uint32_t IDSPreSegmentState(void *SegmentDetails, int SegmentId) uint32_t SegmentNumOfBrushStops = 0; double BrushStopTime = 0; +uint32_t BrushStopCounter = 0; void IDS_StartBrushStop(int n_dispensers, JobDispenser** Dispensers) { @@ -1383,6 +1384,13 @@ uint32_t IDSBrushStopRestartCallback(uint32_t IfIndex, uint32_t readValue) int n_dispensers = 0; JobSegment* Segment = (void *)IfIndex; + if(BrushStopCounter++ < BrushStopTime) + { + return OK; + } + BrushStopCounter = 0; + + if (JobEndSequence == true) { Report("JobEndSequence",__FILE__,__LINE__,(int)JobBrushStopId,RpWarning,(int)SegmentNumOfBrushStops,0); @@ -1478,7 +1486,8 @@ uint32_t IDSSegmentState(void *SegmentDetails, int SegmentId) JobBrushStopId++; if ((BrushStopTime)&&(SegmentNumOfBrushStops > 1)) { - BrushStopControlId = AddControlCallback(NULL, IDSBrushStopRestartCallback, BrushStopTime,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 ); + BrushStopCounter = BrushStopTime+10; //move the IDS brush stop handling to highest priority in timing + BrushStopControlId = AddControlCallback(NULL, IDSBrushStopRestartCallback, eOneMillisecond,TemplateDataReadCBFunction ,SegmentDetails, 0, 0 ); if (BrushStopControlId == 0xFF) { Report("Add control callback failed",__FILE__,__LINE__,(int)BrushStopTime,RpWarning,(int)0,0); diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c index 45cc80dff..6fd2e0eb1 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Progress.c @@ -14,6 +14,7 @@ #include "drivers/adc_sampling/adc.h" #include "drivers/Heater/TemperatureSensor.h" #include "drivers/ADC_Sampling/adc.h" +#include "drivers/Flash_ram/MCU_E2Prom.h" #include "Drivers/I2C_Communication/Head_Card/PT100/Head_PT100_ADC.h" #include "Drivers/I2C_Communication/Head_Card/Fan/fan_click.h" @@ -252,6 +253,19 @@ void Stub_ProgressRequest(MessageContainer* requestContainer) response.progress = (double)OK; response.has_progress = true; + } + else + if(request->amount == 0xB1) //fast refresh for pressure + { + LOG_ERROR(request->delay,"Set loading arm center"); + Read_Dryer_ENC_Position(); + Task_sleep(500); + Read_Dryer_ENC_Position(); + Task_sleep(500); + + response.progress = (double)MCU_E2PromProgram(EEPROM_STORAGE_DRYER_CENTER,Read_Dryer_ENC_Position(0,0)); + response.has_progress = true; + } else if((request->amount == 0xDF) && (request->delay == 0xDF)) //Power off diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 13b98bcb0..f3eb9cb60 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -40,6 +40,8 @@ #include "PMR/ThreadLoading/StartThreadLoadingResponse.pb-c.h" #include "PMR/ThreadLoading/ContinueThreadLoadingRequest.pb-c.h" #include "PMR/ThreadLoading/ContinueThreadLoadingResponse.pb-c.h" +#include "PMR/ThreadLoading/StopThreadLoadingRequest.pb-c.h" +#include "PMR/ThreadLoading/StopThreadLoadingResponse.pb-c.h" //#include //#include @@ -86,6 +88,7 @@ uint32_t ThreadLoadLengthCBFunction(uint32_t IfIndex, uint32_t ReadValue); uint32_t Thread_Load_Dryer_UnLoading(void); uint32_t ThreadLoadingReport(void); + bool ThreadLoaded(void); typedef struct { @@ -115,7 +118,7 @@ //uint32_t Bytes = 0; //FRESULT Fresult = FR_OK; REPORT_MSG(LoadStages, "Thread Load State Machine step"); - + load.color = BLINK; LoadStatus = OK; LoadArmInfo.LoadArmBackLash = MCU_E2PromDryerBacklashRead(); REPORT_MSG(LoadArmInfo.LoadArmBackLash, "Thread Load MCU_E2PromDryerBacklashRead"); @@ -125,8 +128,10 @@ //EEPROM_STORAGE_DRYER_CYCLES MCU_E2PromRead(EEPROM_STORAGE_DRYER_CYCLES,&LoadArmInfo.LoadArmRounds); - if (LoadArmInfo.LoadArmRounds <= 2) - LoadArmInfo.LoadArmRounds = 20; + Read_Dryer_ENC_Position(); + + //if (LoadArmInfo.LoadArmRounds <= 2) + // LoadArmInfo.LoadArmRounds = 20; Report("MotorMovetoEncoderPosition",__FILE__,__LINE__,LoadArmInfo.LoadArmRounds,RpWarning,LoadArmInfo.LoadArmBackLash,0); /*Fresult = f_mkdir(SW_INFO_DIR); @@ -225,7 +230,7 @@ WinderControlId = 0xFF; } - MotorStop(HARDWARE_MOTOR_TYPE__MOTO_SCREW,Hard_Hiz); + MotorAbortMovetoLimitSwitch(HARDWARE_MOTOR_TYPE__MOTO_SCREW); /*Task_sleep(5) MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz); MotorStop(ThreadMotorIdToMotorId[FEEDER_MOTOR],Hard_Hiz);*/ @@ -301,7 +306,6 @@ if (CallbackCounter) { CallbackCounter--; - load.color = BLINK; if (ReadValue != LIMIT) { //returned with a timeout @@ -321,7 +325,6 @@ else { LoadStages++; - load.color = colorON; if (LoadStages == THREAD_LOAD_CLOSE_DANCERS) { MotorSetKvalHold(HARDWARE_MOTOR_TYPE__MOTO_RDANCER, keepkvalhold); @@ -332,7 +335,7 @@ } else { - load.color = fastBILNK; + load.color = colorON; ThreadLoadingReport(); } } @@ -402,6 +405,7 @@ uint32_t Thread_Load_Initial_Tension(void) //Check Spool Presence, run Winder Until Break Sensor Is Identifieing Movement For A Second { REPORT_MSG(LoadStages, "Thread Load State Machine step"); + load.color = BLINK; if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) { REPORT_MSG(LIMIT, "No cone in winder"); @@ -525,30 +529,57 @@ } float numberOfSteps = 0; float numberOfCycles = 0; + uint32_t DrierPrevLocation = 0; uint32_t Thread_Load_Dryer_Loading_Callback(uint32_t MotorId, uint32_t ReadValue) { numberOfCycles++; - //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); - //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); - if (LoadStages != THREAD_LOAD_DRYER_LOADING) - { - return OK; - } - if (numberOfCycles20 )&&(ReadValue == NOTBUSY)) { - MotorMoveWithCallback (HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM, MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_DRYER_LOADARM].directionthreadwize, - numberOfSteps, Thread_Load_Dryer_Loading_Callback, 100000); + DrierPrevLocation = temp; + //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); + if (LoadStages != THREAD_LOAD_DRYER_LOADING) + { + return OK; + } + if (numberOfCycles20 )&&(ReadValue == NOTBUSY)) + { + DrierPrevLocation = temp; + //Report("Thread_Load_Dryer_Loading_Callback",__FILE__,__LINE__,LoadStages,RpMessage,NumberOfDrierLoaderCycles,0); + //Report("Thread_Load_Dryer_Loading_Callback details",__FILE__,(int)(TotalLoadedLen),numberOfCycles,RpMessage,CallbackCounter,0); + if (LoadStages != THREAD_LOAD_SET_LOAD_ARM_TO_START_POSITION) + { + return OK; + } + if (numberOfCyclesdata.len, requestContainer->data.data); ustrncpy (ThreadLoadingToken, requestContainer->token,36); MessageState = 1; + Report("StartThreadLoadingFunc",__FILE__,__LINE__,0,RpWarning,(int)LoadStages,0); ThreadLoadingReport(); return OK; @@ -1149,6 +1287,14 @@ uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer) MessageContainer responseContainer; MessageState = 2; ThreadLoadingReport(); + if (request->processparameters) + { + dryerbufferlength = request->processparameters->dryerbufferlength; + LoadArmInfo.LoadArmRounds = (int)(request->processparameters->dryerbufferlength); + + } + Report("ContinueThreadLoadingFunc",__FILE__,__LINE__,(int)(request->processparameters->dryerbufferlength),RpWarning,(int)LoadStages,0); + responseContainer = createContainer(MESSAGE_TYPE__ContinueThreadLoadingResponse, requestContainer->token, true, &Cresponse, &continue_thread_loading_response__pack, &continue_thread_loading_response__get_packed_size); responseContainer.continuous = false; uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); @@ -1158,3 +1304,21 @@ uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer) return OK; } +uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer) +{ + StopThreadLoadingRequest *request = stop_thread_loading_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + StopThreadLoadingResponse Cresponse = STOP_THREAD_LOADING_RESPONSE__INIT; + MessageContainer responseContainer; + MessageState = 2; + Thread_Load_End(); + Report("StopThreadLoadingFunc",__FILE__,__LINE__,(int)(request->processparameters->dryerbufferlength),RpWarning,(int)LoadStages,0); + + responseContainer = createContainer(MESSAGE_TYPE__StopThreadLoadingResponse, requestContainer->token, true, &Cresponse, &stop_thread_loading_response__pack, &stop_thread_loading_response__get_packed_size); + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + SendChars((char*)container_buffer, container_size); + 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 4db985954..f0b709ff2 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -143,9 +143,9 @@ uint32_t Winder_Prepare(void *JobDetails) if (FPGA_Read_limit_Switches(GPI_SW_SPOOL_EXISTS)==LIMIT) { REPORT_MSG(LIMIT, "No cone in winder"); - // PrepareReady(Module_Winder,ModuleFail); - // AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true); - // return ERROR; + PrepareReady(Module_Winder,ModuleFail); + AlarmHandlingSetAlarm(EVENT_TYPE__WINDER_CONE_DOES_NOT_EXIST,true); + return ERROR; } #ifdef READ_SCREW_ENCODER diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h index cc0bf6c77..dd9395248 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_ex.h @@ -76,6 +76,7 @@ void ThreadLoadRequest(MessageContainer* requestContainer); uint32_t StartThreadLoadingFunc(MessageContainer* requestContainer); uint32_t ContinueThreadLoadingFunc(MessageContainer* requestContainer); +uint32_t StopThreadLoadingFunc(MessageContainer* requestContainer); uint32_t Thread_Load_End(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 0df950f34..fb3b78752 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -170,7 +170,7 @@ uint32_t StoreDancerConfigMessage() Dancers[Dancer_i].has_zeropoint = true; Dancers[Dancer_i].hardwaredancertype = Dancer_i; Dancers[Dancer_i].has_hardwaredancertype = true; - DancerConfig.dancers[Dancer_i]->zeropoint=Control_Read_Dancer_Position(Dancer_i,0,0); + DancerConfig.dancers[Dancer_i]->zeropoint=Control_Read_Dancer_Position(Dancer_i,0); DancerConfig.n_dancers++; DancersCfg[Dancer_i].zeropoint = DancerConfig.dancers[Dancer_i]->zeropoint; } -- cgit v1.3.1