diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-11-05 09:51:08 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-11-05 09:51:08 +0200 |
| commit | 648a3fdc373fc1555a8d1e1908e8b4dfa2203820 (patch) | |
| tree | 4001df7aa6478335e8ca9782724bf4233708fcb4 /Software/Embedded_SW/Embedded | |
| parent | 93591843e7fc3a68e955cb305838fe7e68d1c137 (diff) | |
| download | Tango-648a3fdc373fc1555a8d1e1908e8b4dfa2203820.tar.gz Tango-648a3fdc373fc1555a8d1e1908e8b4dfa2203820.zip | |
Heaters PID enabled per configuration. USB reinitialized. new HW handling with error report
Diffstat (limited to 'Software/Embedded_SW/Embedded')
11 files changed, 140 insertions, 108 deletions
diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 719c4f7ea..54b867936 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -311,6 +311,7 @@ <option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.GCC.783099317" name="Enable support for GCC extensions (DEPRECATED) (--gcc)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.GCC" value="true" valueType="boolean"/> <option id="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEFINE.1812125275" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_16.9.compilerID.DEFINE" valueType="definedSymbols"> <listOptionValue builtIn="false" value="${COM_TI_RTSC_TIRTOSTIVAC_SYMBOLS}"/> + <listOptionValue builtIn="false" value="ENABLE_LFN"/> <listOptionValue builtIn="false" value="DEBUG_TEST_FUNCTIONS"/> <listOptionValue builtIn="false" value="TARGET_IS_TM4C129_RA0"/> <listOptionValue builtIn="false" value="ccs="ccs""/> diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.c b/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.c index c2e0f4a75..018902936 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.c +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.c @@ -52,7 +52,7 @@ void hardware_pid_control__free_unpacked assert(message->base.descriptor == &hardware_pid_control__descriptor); protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); } -static const ProtobufCFieldDescriptor hardware_pid_control__field_descriptors[18] = +static const ProtobufCFieldDescriptor hardware_pid_control__field_descriptors[20] = { { "HardwarePidControlType", @@ -270,17 +270,43 @@ static const ProtobufCFieldDescriptor hardware_pid_control__field_descriptors[18 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, + { + "PidActive", + 19, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_BOOL, + offsetof(HardwarePidControl, has_pidactive), + offsetof(HardwarePidControl, pidactive), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, + { + "Epsilon", + 20, + PROTOBUF_C_LABEL_OPTIONAL, + PROTOBUF_C_TYPE_DOUBLE, + offsetof(HardwarePidControl, has_epsilon), + offsetof(HardwarePidControl, epsilon), + NULL, + NULL, + 0, /* flags */ + 0,NULL,NULL /* reserved1,reserved2, etc */ + }, }; static const unsigned hardware_pid_control__field_indices_by_name[] = { 16, /* field[16] = AcHeatersHalfCycleTime */ 10, /* field[10] = ControlOutputType */ 4, /* field[4] = DerivativeTime */ + 19, /* field[19] = Epsilon */ 0, /* field[0] = HardwarePidControlType */ 3, /* field[3] = IntegralTime */ 12, /* field[12] = OutputOnOffHysteresisValue */ 2, /* field[2] = OutputProportionalBand */ 15, /* field[15] = OutputProportionalCycleTime */ 1, /* field[1] = OutputProportionalPowerLimit */ + 18, /* field[18] = PidActive */ 13, /* field[13] = ProcessVariableSamplingRate */ 17, /* field[17] = ProportionalGain */ 14, /* field[14] = PvInputFilterFactorMode */ @@ -294,7 +320,7 @@ static const unsigned hardware_pid_control__field_indices_by_name[] = { static const ProtobufCIntRange hardware_pid_control__number_ranges[1 + 1] = { { 1, 0 }, - { 0, 18 } + { 0, 20 } }; const ProtobufCMessageDescriptor hardware_pid_control__descriptor = { @@ -304,7 +330,7 @@ const ProtobufCMessageDescriptor hardware_pid_control__descriptor = "HardwarePidControl", "", sizeof(HardwarePidControl), - 18, + 20, hardware_pid_control__field_descriptors, hardware_pid_control__field_indices_by_name, 1, hardware_pid_control__number_ranges, diff --git a/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.h b/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.h index 579b3c19a..ce89d708e 100644 --- a/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.h +++ b/Software/Embedded_SW/Embedded/Communication/PMR/Hardware/HardwarePidControl.pb-c.h @@ -63,10 +63,14 @@ struct _HardwarePidControl int32_t acheatershalfcycletime; protobuf_c_boolean has_proportionalgain; double proportionalgain; + protobuf_c_boolean has_pidactive; + protobuf_c_boolean pidactive; + protobuf_c_boolean has_epsilon; + double epsilon; }; #define HARDWARE_PID_CONTROL__INIT \ { PROTOBUF_C_MESSAGE_INIT (&hardware_pid_control__descriptor) \ - , 0, HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, 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, HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, 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 } /* HardwarePidControl methods */ diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c index ef842bf68..5b8bc40fd 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c +++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c @@ -118,11 +118,7 @@ FRESULT Init_Flash_File_System(bool Need_mkfs) } if(Need_mkfs == true) - iFResult = f_mkfs( 0, 0, 512 ); //Create File System on the Drive -// if(iFResult != FR_OK) -// { -// while(1); -// } + iFResult = f_mkfs( 0, 0, 512 ); //Create File System on the Drive return iFResult; } @@ -207,17 +203,6 @@ int FFS_Directory() { return(fresult); } - -// // -// // Close the current directory -// // -// fresult |= f_closedir(&g_sDirObject); -// if(fresult != FR_OK) -// { -// return(fresult); -// } - - return 0; } diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 0d42057b8..76592f0d5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -770,21 +770,21 @@ void USBCDCD_init(void) void USBCDCD_Reinit(void) { - //USBDCDCTerm(USBDComposite); + USBDCDCTerm(USBDComposite); /* State specific variables */ - //state = USBCDCD_STATE_UNCONFIGURED; + state = USBCDCD_STATE_UNCONFIGURED; /* Set the USB stack mode to Device mode with VBUS monitoring */ - //USBStackModeSet(0, eUSBModeForceDevice, 0); + USBStackModeSet(0, eUSBModeForceDevice, 0); USBBufferInit(&txBuffer); USBBufferInit(&rxBuffer); - /*USBDComposite = USBDCDCInit(0, &g_sCDCDevice); + USBDComposite = USBDCDCInit(0, &g_sCDCDevice); if (!USBDComposite) { System_abort("Error initializing the serial device"); - }*/ + } } diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index ca658a2f8..599609b38 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -15,7 +15,7 @@ var GIO = xdc.useModule('ti.sysbios.io.GIO'); var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore'); var Task = xdc.useModule('ti.sysbios.knl.Task'); -//BIOS.heapSize = 30767; // bios heapmem +BIOS.heapSize = 30767; // bios heapmem //Memory.defaultHeapSize = 48767; Program.heap = 50000; //sysmem diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index 9eb9d9822..5785bafe4 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -486,6 +486,10 @@ uint32_t MillisecLoop(uint32_t tick) { MillisecReadFromTempSensor(Sensor_i, NULL); } + if (watchdogCriticalAlarm == false) + { + Control_WD(ENABLE,5); //activate heaters/dispenser watchdog, 0.5 seconds + } } if (O900Millisecond_Tick) @@ -499,10 +503,6 @@ uint32_t MillisecLoop(uint32_t tick) CalculateDispenserPressure(Disp_i); } FPGA_GetAllDispensersValveBusyOCD(); - if (watchdogCriticalAlarm == false) - { - Control_WD(ENABLE,50); //activate heaters/dispenser watchdog, 5 seconds - } DrawerFansStatus = Read_Fans_Tacho(); KeepAliveOneSecondCall(); } diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index a5f3f48cf..ed1f23cb1 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -26,14 +26,10 @@ HardwareBlower BlowerCfg; -uint32_t HWConfigurationFunc(MessageContainer* requestContainer) +uint32_t HWConfiguration(UploadHardwareConfigurationRequest* UploadRequest) { uint32_t status = 0; int Motor_i, Dancer_i, Dispenser_i,PID_i; - MessageContainer responseContainer; - UploadHardwareConfigurationResponse response = UPLOAD_HARDWARE_CONFIGURATION_RESPONSE__INIT; - - UploadHardwareConfigurationRequest* UploadRequest = upload_hardware_configuration_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); if (UploadRequest == NULL) { @@ -42,6 +38,10 @@ uint32_t HWConfigurationFunc(MessageContainer* requestContainer) } HardwareConfiguration *request = UploadRequest->hardwareconfiguration; + if (JobIsActive()) + { + return ERROR; + } PrintingHWConfiguration(request); if (request->n_winders == 1) status += InternalWinderConfigMessage(request->winders); @@ -122,8 +122,28 @@ uint32_t HWConfigurationFunc(MessageContainer* requestContainer) AlarmHandlingStart(); //ThreadInitialTestStub(request); + return OK; + + + +} +uint32_t HWConfigurationFunc(MessageContainer* requestContainer) +{ + uint32_t status = 0; + int Motor_i, Dancer_i, Dispenser_i,PID_i; + MessageContainer responseContainer; + UploadHardwareConfigurationResponse response = UPLOAD_HARDWARE_CONFIGURATION_RESPONSE__INIT; + + UploadHardwareConfigurationRequest* UploadRequest = upload_hardware_configuration_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + + status = HWConfiguration(UploadRequest); responseContainer = createContainer(MESSAGE_TYPE__UploadHardwareConfigurationResponse, requestContainer->token, true, &response, &upload_hardware_configuration_response__pack, &upload_hardware_configuration_response__get_packed_size); + if (status!= OK) + { + responseContainer.error = ERROR_CODE__INVALID_PARAMETER; + responseContainer.errormessage = "JOb Active or incorrect parameters"; + } uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); free(responseContainer.data.data); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h index 6a682969f..975635342 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters.h @@ -22,25 +22,23 @@ typedef struct HeaterPIDControlConfigstruc { bool configured; int id; //HardwarePidControlType - char name[20]; int32_t outputproportionalpowerlimit; float outputproportionalband; - int32_t integraltime; - int32_t derivativetime; - int32_t sensorcorrectionadjustment; - int32_t sensortypeandsetpointlimits; - int32_t setpointramprateorsoftstartramp; - int32_t setpointcontroloutputrate; - float controloutputtype; - int32_t ssrcontroloutputtype; - int32_t outputonoffhysteresisvalues; - int32_t processvariablesamplingrate; - int32_t pvinputfilterfactormode; + //int32_t sensorcorrectionadjustment; + //int32_t sensortypeandsetpointlimits; + //int32_t setpointramprateorsoftstartramp; + //int32_t setpointcontroloutputrate; + //int32_t outputonoffhysteresisvalues; + //int32_t processvariablesamplingrate; + //int32_t pvinputfilterfactormode; int32_t sensormaxvalue; int32_t sensorminvalue; double kp; double ki; double kd; + double epsilon; + double dt; + bool pidactive; }HeaterPIDControlConfig; typedef struct HeaterCommandstruc diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c index bf1f1128d..6f6cf702d 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_init.c @@ -140,58 +140,44 @@ uint32_t HeaterConfigRequestMessage(HardwarePidControl* request) { HeaterControl[HeaterId].configured = true; HeaterControl[HeaterId].id = HeaterId; - //strncpy (HeaterControl[HeaterId].name, request->name, 20); HeaterControl[HeaterId].outputproportionalpowerlimit = request->outputproportionalpowerlimit; HeaterControl[HeaterId].outputproportionalband = request->outputproportionalband; - HeaterControl[HeaterId].integraltime = request->integraltime; - HeaterControl[HeaterId].derivativetime = request->derivativetime; - HeaterControl[HeaterId].sensorcorrectionadjustment = request->sensorcorrectionadjustment; - //sensorminvalue,sensormaxvalue are used for the dryer heater as internal heater control if (HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature) - //if ((HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain)||(HeaterId != HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary)) { HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain].sensormaxvalue = request->sensormaxvalue; HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain].sensorminvalue = request->sensorminvalue; HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].sensormaxvalue = request->sensormaxvalue; HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].sensorminvalue = request->sensorminvalue; } - //HeaterControl[HeaterId].sensortypeandsetpointlimits = request->sensortypeandsetpointlimits; - HeaterControl[HeaterId].setpointramprateorsoftstartramp = request->setpointramprateorsoftstartramp; - HeaterControl[HeaterId].setpointcontroloutputrate = request->setpointcontroloutputrate; - HeaterControl[HeaterId].controloutputtype = request->controloutputtype; - HeaterControl[HeaterId].ssrcontroloutputtype = request->ssrcontroloutputtype; - HeaterControl[HeaterId].outputonoffhysteresisvalues = request->outputonoffhysteresisvalue; - HeaterControl[HeaterId].processvariablesamplingrate = request->processvariablesamplingrate; - HeaterControl[HeaterId].pvinputfilterfactormode = request->pvinputfilterfactormode; - //HeaterControl[HeaterId].kp = 0.5; - //HeaterControl[HeaterId].ki = 0.1; - //HeaterControl[HeaterId].kd = 0.0; HeaterControl[HeaterId].kp = request->proportionalgain; HeaterControl[HeaterId].ki = request->integraltime; HeaterControl[HeaterId].kd = request->derivativetime; + HeaterControl[HeaterId].dt = request->controloutputtype; + HeaterControl[HeaterId].epsilon = request->epsilon; + HeaterControl[HeaterId].pidactive = request->pidactive; + //HeaterControl[HeaterId].sensorcorrectionadjustment = request->sensorcorrectionadjustment; + //sensorminvalue,sensormaxvalue are used for the dryer heater as internal heater control + //HeaterControl[HeaterId].sensortypeandsetpointlimits = request->sensortypeandsetpointlimits; + //HeaterControl[HeaterId].setpointramprateorsoftstartramp = request->setpointramprateorsoftstartramp; + //HeaterControl[HeaterId].setpointcontroloutputrate = request->setpointcontroloutputrate; + //HeaterControl[HeaterId].ssrcontroloutputtype = request->ssrcontroloutputtype; + //HeaterControl[HeaterId].outputonoffhysteresisvalues = request->outputonoffhysteresisvalue; + //HeaterControl[HeaterId].processvariablesamplingrate = request->processvariablesamplingrate; + //HeaterControl[HeaterId].pvinputfilterfactormode = request->pvinputfilterfactormode; if (HeaterId < MAX_AC_HEATERS) AcHeaterConfigured[HeaterId] = true; //check if all A/C heaters are defined. if they are - validate the configuration - if (((HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain)||(HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary)) + /*if (((HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain)||(HeaterId == HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary)) &&HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain].configured - &&HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].configured - /*&&HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeater200w2].id*/) + &&HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].configured) { if (HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain].outputproportionalpowerlimit - + HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].outputproportionalpowerlimit - /*+ HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeater200w2].outputproportionalpowerlimit*/> 100) - ValidationError += 2; - if (ValidationError) - { + + HeaterControl[HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary].outputproportionalpowerlimit > 100) LOG_ERROR (ValidationError, "Validation Error in Heaters Control"); return ERROR; - } - else - { - } - } + }*/ 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 1a4086a34..8ae7a117b 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -329,8 +329,8 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) HeaterPIDConfig[HeaterId].m_params.Kd = HeaterControl[HeaterId].kd; HeaterPIDConfig[HeaterId].m_params.Kp = HeaterControl[HeaterId].kp; HeaterPIDConfig[HeaterId].m_params.Ki = HeaterControl[HeaterId].ki; - HeaterPIDConfig[HeaterId].m_params.dt = 0.01; - HeaterPIDConfig[HeaterId].m_params.epsilon = 10; + HeaterPIDConfig[HeaterId].m_params.dt = HeaterControl[HeaterId].dt; + HeaterPIDConfig[HeaterId].m_params.epsilon = HeaterControl[HeaterId].epsilon; //0.1 degree HeaterPIDConfig[HeaterId].m_calculatedError = 0; HeaterPIDConfig[HeaterId].m_integral = 0; HeaterPIDConfig[HeaterId].m_isEnabled = true; @@ -532,20 +532,26 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { HeaterPIDConfig[index].m_mesuredParam = readValue; - if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band + if (HeaterControl[index].pidactive == false) { - HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 100); - //REPORT_MSG (readValue,"AC HEATER Over temperature"); + if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band + { + HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 100); + //REPORT_MSG (readValue,"AC HEATER Over temperature"); + } + else if (readValue > ((HeaterCmd[index].targettemperatue * (100+HeaterControl[index].outputproportionalband))/100)) + { + HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 0); + //REPORT_MSG (readValue,"AC HEATER Under temperature"); + } } - else if (readValue > ((HeaterCmd[index].targettemperatue * (100+HeaterControl[index].outputproportionalband))/100)) + else //PID active { - HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, 0); - //REPORT_MSG (readValue,"AC HEATER Under temperature"); + //check only for the proportional band limits + HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, + &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); + HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, (int)(HeaterPIDConfig[index].m_calculatedError/100)); } -//check only for the proportional band limits - HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, - &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); - //HeaterRecalculateSharedHeatersParams(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, (int)(HeaterPIDConfig[index].m_calculatedError/100)); } @@ -618,30 +624,36 @@ uint32_t DCHeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) } if(HeaterPIDConfig[index].m_isEnabled && (HeaterPIDConfig[index].m_SetParam != 0)) { - if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band + if (HeaterControl[index].pidactive == false) { - HeaterRecalculateHeaterParams(index, 100); + if (readValue < ((HeaterCmd[index].targettemperatue * (100-HeaterControl[index].outputproportionalband))/100)) //below proportional band + { + HeaterRecalculateHeaterParams(index, 100); + } + else if (readValue > ((HeaterCmd[index].targettemperatue * (100+HeaterControl[index].outputproportionalband))/100)) + { + HeaterRecalculateHeaterParams(index, 0); + } + } - else if (readValue > ((HeaterCmd[index].targettemperatue * (100+HeaterControl[index].outputproportionalband))/100)) + else ///pid active { - HeaterRecalculateHeaterParams(index, 0); - } + //check only for the proportional band limits + HeaterPIDConfig[index].m_mesuredParam = readValue; + HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, + &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); + // error[index][Counter[index]] = HeaterPIDConfig[index].m_preError; + // integral[index][Counter[index]] = HeaterPIDConfig[index].m_integral; + // output[index][Counter[index]] = HeaterPIDConfig[index].m_calculatedError; + // if (Counter[index]++ >=100) + // Counter[index] = 0; + // len = usnprintf(logmsg[index], 254, "PID%d: Temp %d Integral %d Output %d ",index,(int)HeaterPIDConfig[index].m_mesuredParam ,(int)HeaterPIDConfig[index].m_integral,(int)HeaterPIDConfig[index].m_calculatedError); + // Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); + // #warning PID is now only proportional (above) + HeaterRecalculateHeaterParams(index, (int)(HeaterPIDConfig[index].m_calculatedError/100)); -//check only for the proportional band limits - HeaterPIDConfig[index].m_mesuredParam = readValue; - HeaterPIDConfig[index].m_calculatedError = PIDAlgorithmCalculation(HeaterPIDConfig[index].m_SetParam , HeaterPIDConfig[index].m_mesuredParam, - &HeaterPIDConfig[index].m_params, &HeaterPIDConfig[index].m_preError, &HeaterPIDConfig[index].m_integral); - -// error[index][Counter[index]] = HeaterPIDConfig[index].m_preError; -// integral[index][Counter[index]] = HeaterPIDConfig[index].m_integral; -// output[index][Counter[index]] = HeaterPIDConfig[index].m_calculatedError; -// if (Counter[index]++ >=100) -// Counter[index] = 0; -// len = usnprintf(logmsg[index], 254, "PID%d: Temp %d Integral %d Output %d ",index,(int)HeaterPIDConfig[index].m_mesuredParam ,(int)HeaterPIDConfig[index].m_integral,(int)HeaterPIDConfig[index].m_calculatedError); -// Report(logmsg[index],__FILE__,__LINE__,index,RpWarning,index, Counter[index]); + } - #warning PID is now only proportional (above) - //HeaterRecalculateHeaterParams(index, (int)(HeaterPIDConfig[index].m_calculatedError/100)); } |
