heat control  r71
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hc.c File Reference
#include <math.h>
#include "types.h"
#include "hc.h"
#include "init.h"
#include "adc.h"
#include "lcdisp.h"
#include "timer.h"
#include "comm.h"
#include "setup.h"
Include dependency graph for hc.c:

Go to the source code of this file.

Functions

int main (void)
 main controlling task More...
 
MEASSETDoControl (INT inTemp, INT outTemp, UINT forTemp, UCHAR learning, UINT min, UCHAR sec)
 realizes the main heater controlling algorithm
the value of inner temperature distinguishes between the controlling strategy:
leading the inner temperature if not equal to INVALID_VAL_I16, leading the forerun otherwise More...
 
UINT FindForeRun (INT *outTemp, const UCHAR range, UINT const delLim)
 gets the forerun temperature of the closest outer temperature which was recorded in learning phase
a predefined hysteresis supports a proper hit More...
 
void ControlEngine (ENG_MODE em)
 takes care of the heating curve recording in eeprom
records only if outer temp value does not exist (specific hysteresis respected) More...
 
void PrintMeasValues (MEASSET *ms, OP_MODE opm, UCHAR msrFull)
 puts the measurement values on screen More...
 
void PrintValue (DATTYPE dt, UCHAR col, UCHAR row, UCHAR name, void *value)
 put a specific value on screen More...
 
void DoEngineTest (BTN_CODE bc)
 do engine testing dependent on button request, simply drives the mixer engine unconditionally More...
 
UCHAR CalcPrevIndex (UCHAR curIdx, UCHAR delIdx)
 

Variables

HCREC EEMEM ge_hcRec [NUM_HR]
 
UCHAR EEMEM ge_hcrCnt = 0
 
UCHAR EEMEM e_dummy [3] = ".."
 
MEASSET EEMEM ge_msRec [NUM_MSR]
 
MEASSET g_sets [NUM_MS]
 
volatile CTRL_MODE g_ctm
 
ENG_TIMER volatile g_et
 
UINT old_min = -IV_MEAS
 

Function Documentation

UCHAR CalcPrevIndex ( UCHAR  curIdx,
UCHAR  delIdx 
)

Definition at line 517 of file hc.c.

References CHAR, NUM_MS, and UCHAR.

void ControlEngine ( ENG_MODE  em)

takes care of the heating curve recording in eeprom
records only if outer temp value does not exist (specific hysteresis respected)

Parameters
recCntrecord counter for list indexing
setcurrent valid measurement set takes care of the mixer engine controlling (output pin switching)
emcurrent engine mode
mxpmixer engine's step position

Definition at line 432 of file hc.c.

References EM_CCW, EM_CW, EM_STOP, ENG_RUN_CCW, ENG_RUN_CW, ENG_STOP_CCW, and ENG_STOP_CW.

Referenced by DoControl(), and DoEngineTest().

Here is the caller graph for this function:

MEASSET* DoControl ( INT  inTemp,
INT  outTemp,
UINT  forTemp,
UCHAR  learning,
UINT  min,
UCHAR  sec 
)

realizes the main heater controlling algorithm
the value of inner temperature distinguishes between the controlling strategy:
leading the inner temperature if not equal to INVALID_VAL_I16, leading the forerun otherwise

Parameters
inTempinner temperature
outTempouter temperature
forTemptemperature of forerun
learningspecifies whether in learning mode -> TRUE, or forerun controlling required -> FALSE
minminute value
secsecond value
Returns
meas set on next valid interval, NULL otherwise

Definition at line 279 of file hc.c.

References ENG_TIMER::allow, CM_DENY, CM_FOR, CM_MEAS, CM_REC, CM_SHDN, ENG_TIMER::cnt, ControlEngine(), DEL_FOR_TEMP, ENG_TIMER::em, EM_CCW, EM_CW, EM_STOP, FindForeRun(), MEASSET::forTemp, g_ctm, INT, MEASSET::inTemp, INVALID_VAL_U16, MAX_DEL_OUTER_TEMP, MAX_FOR_TEMP, MIN_FOR_TEMP, NUM_HR, old_min, MEASSET::outTemp, TRUE, UCHAR, and UINT.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void DoEngineTest ( BTN_CODE  bc)

do engine testing dependent on button request, simply drives the mixer engine unconditionally

Parameters
bcbutton code of request

Definition at line 495 of file hc.c.

References BC_DN, BC_DNUP, BC_NONE, BC_UP, ControlEngine(), EM_CCW, EM_CW, and EM_STOP.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

UINT FindForeRun ( INT outTemp,
const UCHAR  range,
UINT const  delLim 
)

gets the forerun temperature of the closest outer temperature which was recorded in learning phase
a predefined hysteresis supports a proper hit

Parameters
outTempouter temperature as a parameter to find a proper close forerun temperature, will be updated on a hit by the value from eep
rangedelimits the number of entries in eeprom being searched - depends on the number of recorded entries (the recording state)
delLimthe delta limit against which to check the calculated difference of the outer temperature
Returns
a valid forerun temperature if there was a hit, INVALID_VAL_U16 otherwise

Definition at line 387 of file hc.c.

References HCREC::forTemp, ge_hcRec, INT, INVALID_VAL_U16, HCREC::outTemp, and UCHAR.

Referenced by DoControl().

Here is the caller graph for this function:

int main ( void  )

main controlling task

Returns
will never return in normal operation

nominal temperature from setup

inner temp for controlling

outer temp for controlling

supply voltege of temperature sender

forerun temp for controlling

trace whether the context runs in the very first controlling cycle

offset value of button action for payload changes

counter for indexing the heating curve recording sets in e_hcRec of eeprom

indexer for measurement sets in ram, its value is an indicator of the time stamp when a set was captured - depending on the measurement interval

operation mode during controlling

button code for capturing

remember the previous seconds value

remember a time span of 5 seconds for meas value visualization

delta seconds

common time stamp for capturing

running tenth of a second

running seconds

running minutes

temporary measurement set in ram

previous control mode, indicator to write again

name of control mode in hrf

Definition at line 52 of file hc.c.

References ADC_TMP_INNER_ID, ADC_TMP_OUTER_ID, BC_DNUP, BC_NONE, CalcAdcTemp(), CalcSupplyVoltage(), CHAR, CM_DENY, DecodeButton(), DIR_UP, DoControl(), DoEngineTest(), DoSetup(), DT_INT, DT_TIME, DT_UCHAR, DT_UINT, FALSE, MEASSET::forTemp, g_ctm, g_min, g_sec, ge_hcrCnt, ge_msRec, GetCtrlMode(), GetSenderValues(), gMov(), Init(), INVALID_VAL_I16, INVALID_VAL_U16, NM_CNT, NM_OPMODE, NM_TFOR, NM_TIME, NM_TIN, NM_TOUT, NM_VOLT, NUM_HR, NUM_MS, NUM_MSR, old_min, OM_CONTI, OM_ENGTEST, OM_SENDER, OM_SETUP, OM_SHMEAS, OM_TMPCTRL, OP_MODES, OVM_MSR, PrintMeasValues(), PrintValue(), SetLimitValue(), sMov(), TRUE, UCHAR, UINT, and WriteCtrlMode().

Here is the call graph for this function:

void PrintMeasValues ( MEASSET ms,
OP_MODE  opm,
UCHAR  msrFull 
)

puts the measurement values on screen

Parameters
mscurrent measurement set
opmcurrent operation mode

Definition at line 455 of file hc.c.

References DT_INT, DT_UINT, MEASSET::forTemp, MEASSET::inTemp, NM_MSRFULL, NM_TFOR, NM_TIN, NM_TOUT, OM_SETUP, OM_SHMEAS, MEASSET::outTemp, and PrintValue().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

void PrintValue ( DATTYPE  dt,
UCHAR  col,
UCHAR  row,
UCHAR  name,
void *  value 
)

put a specific value on screen

Parameters
dtvalue's data type
colstarting column of the output
rowstarting row of the output
nameof value
valueto put on screen

Definition at line 480 of file hc.c.

References LCD_POS::col, MEASVAL::dt, MEASVAL::name, MEASVAL::pos, LCD_POS::row, MEASVAL::value, and WriteMeasVal().

Referenced by main(), and PrintMeasValues().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

UCHAR EEMEM e_dummy[3] = ".."

dummy to consume some bytes of eeprom, without this the compiler seems to confuse the very last data in eeprom

Definition at line 27 of file hc.c.

volatile CTRL_MODE g_ctm

control mode tracing

control mode

Definition at line 27 of file timer.c.

Referenced by DoControl(), ISR(), and main().

ENG_TIMER volatile g_et

mixer engine control structure

Definition at line 31 of file timer.c.

MEASSET g_sets[NUM_MS]

list of measurement sets in ram

Definition at line 35 of file hc.c.

Referenced by Init().

UCHAR EEMEM ge_hcrCnt = 0

counter for indexing of heating curve recording structures in eeprom

Definition at line 23 of file hc.c.

Referenced by main().

HCREC EEMEM ge_hcRec[NUM_HR]

nominal temperature in eeprom heating curve recording structures in eeprom

Definition at line 19 of file hc.c.

Referenced by FindForeRun().

MEASSET EEMEM ge_msRec[NUM_MSR]

recording current temperature values to get a clue

recording current temperature values to get a clue 5 hrs interval * 12 sets = 60 hrs period

Definition at line 20 of file setup.c.

Referenced by main().

UINT old_min = -IV_MEAS

Definition at line 46 of file hc.c.

Referenced by DoControl(), and main().