INOS
cinostempcontroller.h
Go to the documentation of this file.
1//******************************************************************************
25//******************************************************************************
26
27#ifndef INC_CINOSTEMPCONTROL_H
28#define INC_CINOSTEMPCONTROL_H
29
30//------------------------------------------------------------------------------
31// defines
32//------------------------------------------------------------------------------
33//
34#define DF_INOS_TEMP_CONTROLLER_NAME "CINOSTempController" // controller name
35//
36#define DF_INOS_TEMP_PID_FLAG_ACTIVE 0x00000001 // pid set is active
37
38// anti-windup methods
39#define DF_INOS_TEMP_AWM_BACKCALCULATION 0 // back-calculation (currently not implemented)
40#define DF_INOS_TEMP_AWM_CLAMPING 1 // clamping
41#define DF_INOS_TEMP_AWM_SATURATION 2 // saturation
42#define DF_INOS_TEMP_AWM_NONE 3 // none
43
44//
45// --- controller errors -------------------------------------------------------
46//
48#define ER_INOS_TEMP_CONTROLLER_BREAK 0x00010000 // sensor break
50#define ER_INOS_TEMP_CONTROLLER_SHORT_CIRCUIT 0x00020000 // sensor short circuit
52#define ER_INOS_TEMP_CONTROLLER_ALARM 0x00040000 // alarm temp reached
54#define ER_INOS_TEMP_CONTROLLER_OUT_FAILURE 0x00080000 // output failure
56#define ER_INOS_TEMP_CONTROLLER_DELTA 0x00100000 // max. temp delta
58#define ER_INOS_TEMP_CONTROLLER_OUTPWM_SYNC 0x00200000 // outpwm sync does not toggle
59//
60// --- controller warnings -----------------------------------------------------
61//
62#define WR_INOS_TEMP_CONTROLLER_LOW_TEMP 0x00010000 // temperature to low
63#define WR_INOS_TEMP_CONTROLLER_HIGH_TEMP 0x00020000 // temperature to high
64//
65// --- tuning ------------------------------------------------------------------
66
67// flags
68//
69#define DF_INOS_TEMP_TUNE_FLAG_ACCEPT "Accept" // tuning flag autoaccept
70//
71// types
72//
73#define DF_INOS_TEMP_TUNE_TYPE_HCP "Type=Hcp" // tuning type 'hcp'
74#define DF_INOS_TEMP_TUNE_TYPE_PID "Type=Pid" // tuning type 'pid'
75#define DF_INOS_TEMP_TUNE_TYPE_FFS "Type=ffS" // tuning type 'ffS'
76#define DF_INOS_TEMP_TUNE_TYPE_BLZ "Type=Blz" // tuning type 'Blz'
77//
78// tune type hcp
79//
80#define DF_INOS_TEMP_TUNE_STATE_HCP_POWER_SET 0 // set output
81#define DF_INOS_TEMP_TUNE_STATE_HCP_POWER_WAIT 1 // wait time
82#define DF_INOS_TEMP_TUNE_STATE_HCP_SYSTEM_WAIT 2 // wait for system
83#define DF_INOS_TEMP_TUNE_STATE_HCP_WAIT_MAX 3 // wait for max
84//
85// tune type pid
86//
87#define DF_INOS_TEMP_TUNE_STATE_PID_STEP_POWER_SET 10 // set output
88#define DF_INOS_TEMP_TUNE_STATE_PID_STEP_SYSTEM_WAIT 11 // wait pulse time
89#define DF_INOS_TEMP_TUNE_STATE_PID_STEP_WAIT_MAX 12 // wait for max
90//
91#define DF_INOS_TEMP_TUNE_STATE_PID_SWING_PULSE_SET 20 // set output
92#define DF_INOS_TEMP_TUNE_STATE_PID_SWING_PULSE_WAIT 21 // wait pulse time
93#define DF_INOS_TEMP_TUNE_STATE_PID_SWING_WAIT_MAX 22 // wait for max
94#define DF_INOS_TEMP_TUNE_STATE_PID_SWING_WAIT_MIN 23 // wait for min
95#define DF_INOS_TEMP_TUNE_STATE_PID_SWING_RELAX 24 // relax
96#define DF_INOS_TEMP_TUNE_STATE_PID_SWING_SETTLE 25 // settle
97//
98// tune type ffs
99//
100#define DF_INOS_TEMP_TUNE_STATE_FFS_WAIT 30 // wait 2 min
101//
102// tune type blz
103//
104#define DF_INOS_TEMP_TUNE_STATE_BLZ_WAIT 40 // wait 2 min
105//
106// pid range indices
107//
108#define DF_INOS_TEMP_PID_RANGE_LOW 0
109#define DF_INOS_TEMP_PID_RANGE_MEDIUM 1
110#define DF_INOS_TEMP_PID_RANGE_HIGH 2
111//
112//------------------------------------------------------------------------------
113// includes
114//------------------------------------------------------------------------------
115//
116// system
117#include <cinosbasecontroller.h>
118//
119// C++
120//
121// project
122//
123//------------------------------------------------------------------------------
124//--- structures ---------------------------------------------------------------
125//------------------------------------------------------------------------------
126//
128 //; structure of PID parameters
129{
130 real64 m_rKp;
131 real64 m_rKi;
132 real64 m_rKd;
133 real64 m_rTi;
134 real64 m_rTd;
135 real64 m_rAff;
136 real64 m_rVff;
137 real64 m_rBff;
138 real64 m_rSff;
139 real64 m_rSffoffset;
140 real64 m_rSignalFF;
141 uint32 m_uFlags;
142};
143//
145{
146 real64 m_rTime;
147 real64 m_rTemp;
148 real64 m_rOut;
149};
150//------------------------------------------------------------------------------
151// class definition
152//------------------------------------------------------------------------------
153//
155{
156 //--- user interface ---------------------------------------------------
157
158 // public member functions
159 public :
160
161 // constructor/destructor
162
163 CINOSTempController(const char* apInpName, const char* apOutName);
164 //; constructor
165 virtual ~CINOSTempController();
166 //; destructor
167 virtual void SetCycleTime(real64 arCycleTime);
168 //; set controller cycle time [sec]
169
170 virtual void Activate(bool abCheckVal = true, bool abSimulateVal = false,
171 bool abSimulateOut = false, bool abSimulateAct = false);
172 //; overwritten to handle m_bIgnoreAlarmTemp
173
174 // Tune
175
176 virtual uint32 Tune(const char* apParam);
177 //; tune controller
178
179 virtual CINCOObject* GetRegister();
180 //; do inco registration and return pointer to it
181
182 bool SetPidRunParamKp(uint32 auRangeIndex, real64 arKp);
183 bool SetPidRunParamKi(uint32 auRangeIndex, real64 arKi);
184 bool SetPidRunParamKd(uint32 auRangeIndex, real64 arKd);
185 //; set specific run PID parameter of given temperature range
186 virtual bool SetPidRunParam(uint32 auRangeIndex, uint32 auParamIndex, real64 arParamValue);
187 //; set generic run PID parameter of given temperature range
188
189 bool SetPidHaltParamKp(uint32 auRangeIndex, real64 arKp);
190 bool SetPidHaltParamKi(uint32 auRangeIndex, real64 arKi);
191 bool SetPidHaltParamKd(uint32 auRangeIndex, real64 arKd);
192 //; set specific run PID parameter of given temperature range
193 virtual bool SetPidHaltParam(uint32 auRangeIndex, uint32 auParamIndex, real64 arParamValue);
194 //; set generic run PID parameter of given temperature range
195
196 //--- internals --------------------------------------------------------
197
198 friend class CINCOTempCtrPar;
199 friend class CINCOTempBlzPar;
200
201 // protected member functions
202 protected:
203 virtual void Reset();
204 //; reset controller values (called whenever the controller is
205 //; switched on)
206 virtual void Jump(real64 arSrc, real64 arDst);
207 //; jump detected
208 virtual void StopJump();
209 //; stop controller jump
210 virtual void StopTune();
211 //; stop controller tune
212 virtual void PreControl();
213 //; called before control
214 virtual bool IsSettled(bool abAdjAllowed=false);
215 //; return true if settled
216 ICACHE virtual void Control();
217 //; do a control cycle
218 ICACHE void SetActPidSet();
219 //; set pointer to actual pid set
220 void CalcBoltzmann();
221 //; calc boltzmann internals
222 real64 GetBoltzmann(real64 arT);
223 //; calc boltzmann radiant power of temperature arT
224 real64 GetffS(real64 arT);
225 //; calc feed forward
226 void iFeedForward();
227 //; internal standard feed forward
228 void iControl();
229 //; internal standard control
230 void iJumpCalcPolynom();
231 //; calc polynom of 3rd degree
232 void iJumpPrepareForHalt();
233 //; prepare jump for halt
234 void iJumpFeedForward();
235 //; internal jump feed forward
236 void iJumpControl();
237 //; internal jump control
238 bool iTuning();
239 //; internal tuning method
240 bool iTuningWaitTime(real64 arTime);
241 //; internal tuning method
242 bool iTuningWaitTmax();
243 //; internal tuning method
244 bool iTuningWaitTmin();
245 //; internal tuning method
246 bool iTuningSupervision();
247 //; tuning supervision
248 bool iTuningCheckResult();
249 //; check tuning result
250 uint32 iTuningGetPidIndex();
251 //; internal tuning method
252 void SetPid(SPidTemp* apSet, uint32 auIndex, real64 arValue);
253 //; set pid value
254 virtual const char* GetStateText();
255 //; get pointer to actual state text
256
257 // protected members
258 protected:
259 // controller flag mask
260 uint32 m_uFlagMask;
261
262 // pid parameter ranges
263 real64 m_rMedium;
264 //; begin of medium range (ends at begin of high range)
265 real64 m_rHigh;
266 //; begin of high range
267
268 // controller parameters (0-low, 1-medium, 2-high)
269 SPidTemp m_PidHalt[3];
270 //; pid parameters during halt and jump
271 SPidTemp m_PidRun[3];
272 //; pid parameters during ramping
273 SPidTemp m_PidTune;
274 //; pid parameters during tuning
275 SPidTemp* m_pActSet;
276 //; pointer to actual set
277 real64 m_rSint;
278 //; actual value integrator
279 real64 m_rSintMin;
280 //; min. allowed value integrator
281 real64 m_rSintMax;
282 //; max. allowed value integrator
283 uint16 m_uAwMethod;
284 //; anti-windup method
285 real64 m_rOutact_1;
286 //; actual output of the previous cycle, i.e. after actuator saturation is considered
287 real64 m_rOutlin;
288 //; output in the linear range (i.e. before actuator saturation is considered)
289 real64 m_rSerr_1;
290 //; error of the previous control cycle
291
292 // temperatures
293 real64 m_rTmin;
294 // min temperature
295 real64 m_rTmax;
296 // max temperature
297 real64 m_rTalarm;
298 // alarm temperature
299 real64 m_rTalarmHyst;
300 // alarm temperature hysteresis
301 bool m_bIgnoreAlarmTemp;
302 // whether the alarm temperature must be ignored undershoot since last
303 // activation. See also comments on
304 // DF_INOS_BASE_CONTROLLER_FLAG_IGN_ALM_ACT. Note that the
305 // hysteresis is also taken into account. Means that the
306 // temperature must be below (m_rTalarm-m_rTalarmHyst) until the
307 // alarm temperature will be checked.
308 real64 m_rTbreak;
309 // break temperature
310 real64 m_rThalt;
311 // halt temperature (if fabs(Scmd-Sact)<=thalt -> settle)
312
313 // output
314 real64 m_rOutSff;
315 // feed forward S
316 real64 m_rOutAff;
317 // feed forward A
318 real64 m_rOutVff;
319 // feed forward V
320 real64 m_rOutBlz;
321 // feed forward Boltzmann
322 real64 m_rOutTune;
323 // feed forward tuning
324
325 // Boltzmann compensation
326 real64 m_rBlzTmin;
327 //; min. temp
328 real64 m_rBlzTmax;
329 //; max. temp
330 real64 m_rBlzPmax;
331 //; power at Tmax
332 double m_dBlzTmin4;
333 //; min. temp ^ 4
334 double m_dBlzFactor;
335 //; d*e*A
336
337 real64 m_rHeatFactor;
338 //; measured 'm*c' [J/K]
339
340 real64 m_rOutDelta;
341 //; [°C] min. delta to be reached within outtimeout time
342 //; otherwise -> output failure
343 real64 m_rOutTimeout;
344 //; [ms] max. allowed time
345
346 // jump handling
347 uint16 m_uJmpType;
348 //; jumping type (0-forward, 1-backward)
349 uint16 m_uJmpStatePff;
350 //; jumping subsstate feed forward P
351 uint16 m_uJmpStateCtr;
352 //; jumping subsstate control
353 real64 m_rJmpTimer;
354 //; time since start of jump
355 real64 m_rJmpVmax;
356 //; max. V ever reached
357 real64 m_rJmpTp;
358 //; time base of polynom
359 real64 m_rJmpTpe;
360 //; Te part of polynom
361 real64 m_rJmpOut;
362 //; jump output
363 real64 m_rJmpTc;
364 //; time base of polynom
365 real64 m_rJmpTce;
366 //; Te part of polynom
367 real64 m_rJmpSe;
368 //; jump end
369 real64 m_rJmpA;
370 //; a part of polynom
371 real64 m_rJmpB;
372 //; b part of polynom
373 real64 m_rJmpC;
374 //; c part of polynom
375 real64 m_rJmpD;
376 //; d part of polynom
377
378 // tuning handling
379
380 bool m_bTuneAccept;
381 //; true if autoaccept requested
382 uint16 m_uTuneState;
383 //; actual tune state
384 uint16 m_uTunePid;
385 //; actual pid index to be tuned
386 real64 m_rTuneTimer;
387 //; tuning timer
388 real64 m_rTuneMin;
389 //; tuning min
390 real64 m_rTuneMax;
391 //; tuning max
392 real64 m_rTuneTemp;
393 //; tuning temp
394 real64 m_rTuneTime;
395 //; tuning time
396 real64 m_rTuneTimePoint;
397 //; tuning time of last point
398 real64 m_rTuneOut;
399 //; tuning out
400 real64 m_rTunePulseOut;
401 //; tuning pulse out
402 real64 m_rTunePulseTime;
403 //; tuning pulse time
404 real64 m_rTunePulseTimeout;
405 //; tuning pulse timeout
406 int32 m_iTunePulseStart;
407 //; pulse starting ticks
408 real64 m_rTuneWaveActTime;
409 //; tuning wave act time
410 real64 m_rTuneWaveMinTime;
411 //; tuning wave min time
412 real64 m_rTuneWaveMaxTime;
413 //; tuning wave max time
414 real64 m_rTuneWaveMinAmpl;
415 //; tuning wave min ampl
416 real64 m_rTuneWaveMaxAmpl;
417 //; tuning wave max ampl
418 real64 m_rTuneWaveMinPower;
419 //; tuning wave min power
420 real64 m_rTuneWaveMaxPower;
421 //; tuning wave max power
422 uint16 m_uTuneWaveMinCnt;
423 //; requested number of tuning waves
424 uint16 m_uTuneWaveReqCnt;
425 //; requested additional number of tuning waves
426 uint16 m_uTuneWaveCnt;
427 //; actual number of tuning waves
428 STunePoint m_TuneHigh[2];
429 //; tuning peak points
430 STunePoint m_TuneLow[2];
431 //; tuning low points
432 char m_cTuneState[16];
433 //; tuning state
434 char m_cTuneResultState[16];
435 //; tune result state
436 char m_cTuneParam[64];
437 //; tune params
438 uint16 m_uTuneCavg;
439 //; internal counter
440 real64 m_rTunePavg;
441 //; tuning P average
442 real64 m_rTuneTavg;
443 //; tuning T average
444 real64 m_rTuneHcpFactor;
445 //; calculated hcp factor
446 real64 m_rTuneffSoffset;
447 //; ffS offset
448 real64 m_rTuneffS;
449 //; ffS
450 real64 m_rTuneBlzTmin;
451 //; blz tmin
452 real64 m_rTuneBlzTmax;
453 //; blz tmax
454 real64 m_rTuneBlzPmax;
455 //; blz pmax
456 real64 m_rTuneVmax;
457 //; vmax
458 real64 m_rTuneVmaxTime;
459 //; time at vmax
460 real64 m_rTuneVmaxSact;
461 //; Sact at vmax
462
463 CINOSProcessImageChannel* m_pCmpChannel;
464 //; pointer to compensation element channel or nullptr
465 CINOSBit* m_pOutChannelBit;
467 class CINOSOutPwm* m_pOutPwm;
468 //; pointer to outpwm handler or nullptr
469 uint32 m_uOutPwmSyncCount{};
470 //; last sync count
471 int32 m_iOutPwmTicks{};
472 //; got pwm sync count at this 1ms ticks
473
474 // signal feed forward
475
476 inosName32 m_cSignalName;
477 //; signal name (analog input or analog output)
478 CINOSAdcChannel* m_pAdcSignal;
479 //; analog input
480 CINOSDacChannel* m_pDacSignal;
481 //; analog output
482
483 // allow dynamic object handling (new/delete)
484 DECLARE_DYNAMIC_CACHE(CINOSTempController);
485};
486
487
488//------------------------------------------------------------------------------
489// end of file
490//------------------------------------------------------------------------------
491
492#endif // INC_CINOSTEMPCONTROLLER_H
Short comment.
Definition cinosadcchannel.h:53
Definition cinosbasecontroller.h:110
Definition cinosbit.h:54
Definition cinosdacchannel.h:52
Definition cinosmcmodule.h:1900
Definition cinosprocessimagechannel.h:111
Definition cinostempcontroller.h:155
class CINOSOutPwm * m_pOutPwm
pointer to output channel if bit
Definition cinostempcontroller.h:467
Definition cinostempcontroller.h:129
Definition cinostempcontroller.h:145