AN1353
Application note
ASD
ST62000C software description for cooling thermostat applicatons
1
Introduction
In this document, we explain the software of an Electronic thermostat bread board. The
demonstration kit has been developped by STMicroelectronics and is available under
THERM01EVAL reference.
This board illustrates the operation of a low cost electronic thermostat for 220-240V 50Hz
cold appliances, including STMicroelectronics ACS102-5TA, ACST6-7ST and ST62 devices.
The microcontroller will ensure four functions:
●
●
Temperature regulation (temperature capture through NTC resistor + Hysteresis
regulation).
Compressor monitoring: the motor is controlled depending on fridge temperature. To
start it, the starting triac Ts and the run triac Tr are triggered simultaneously for 500ms.
Then, only the run triac will continue to conduct.
Overcurrent detection: this is based on the measure of the peak current using a shunt
resistor. During the one second (500 ms+500 ms) of starting transient, this routine
does not run.
Internal light bulb control.
●
●
2
2.1
Hardware configuration
General information
The power supply of the microcontroller is a capacitive one. Its particularity is that the VSS
is 5V less than the Neutral. This power supply can be called a “negative supply”. This
generates flowing out current from the ACS/ACST gates (ACS are triggered only with a
negative gate current). This feature must also be kept in mind when the overcurrent
detection is implemented. It will define in which polarity the current can be sensed.
Figure 1
illustrates the board electrical circuit.
January 2006
Rev 2
1/17
www.st.com
Hardware configuration
Figure 1.
J1
AN1353
Bread-board schematic
BULB
J4
1
2
L
MOTOR
1
2
3
Start
L_PCB
6µH
R1
33R 1/2W
J3
Tr
Start ACST6
R13
51R
R14
51R
Ts
Run ACST6
R2
160R
R3
160R
VDD
C5
1nF
C6
1nF
Tb
Bulb ACS102
R10
50m 1/2 W
U1
2
3
R6
470K
4
6
5
OSCIN
OSCOUT
NMI
RST
VPP/TEST
15
14
13
12
11
10
8
7
9
16
POT A
100K
C10
2.2nF
C9
2.2nF
S2
doorswitch
C8
2.2nF
R8
62K
C7
2.2nF
R7
33k
R5
1.5K
R4
360R
1
2
Run
DOOR
VDD
D1
LED
J2
1
2
NTC
PA1
PA2
PA3
PB0/AIN
PB1/AIN
PB3/AIN
PB6/AIN
PB7/AIN
PB5/AIN
R12
1K
R9
47K
C11
680pF
C2
100nF
J5
N
1
2
3
C4
10 nF X2
FUSE 6 A / 250 V
F1
VDD
D2
6V2 1.3W
+
C3
2200µF / 10 V
C12
1 µF
1
VDD
ST62T00C
VSS
MAINS
C1
R11
D3
L
470nF X2
47R 1/2 W
Note the following features on the MCU hardware environment:
●
●
●
The clock is achieved by the internal oscillator
No external reset circuit is used, thanks to the Low Voltage Detector option of the MCU
The Zero Voltage Crossing (ZVC) event is sensed through R6 by the NMI pin.
2.2
I/O port configuration
The following table explains what the I/O ports are used for, and how they are configured,
beginning with the Port B which is configured in Input (except for PB1 which is configured as
a push pull output).
All the inputs are configured with a pull up resistor, except for when they are used as an
ADC input. No In-terrupt is active on any of these pins.
Table 1.
Pin Name
PB0
PB1
PB2
PB3
PB4
PB5
PB6
PB7
Not used
Switch ON the LED / Switch OFF the LED
Not existing for ST6200
SHUNT voltage Analog Input / Input with pull up
Not existing for ST6200
Temperature order Analog Input / Input with pull up
Door switch information
Cabinet temperature Analog Input / Input with pull up
Port B configuration registers
USE
DDR
0
1
0
0
0
0
0
0/0
OR
0
1
0
1/0
0
1/0
0
1/0
DR
0
0/1
0
1/0
0
1/0
0
1/0
All port A pins are configured as push pull outputs. Table 2 details the option choices and
configuration reg-isters.
2/17
Rev 2
AN1353
Main program
Table 2.
Pin Name
PA1
PA2
PA3
Port A configuration registers
USE
START ACST6 ON / START ACST6 OFF
RUN ACST6 ON / RUN ACST6 OFF
LIGHT BULB ON / LIGHT BULB OFF
DDR
1
1
1
OR
1
1
1
DR
0/1
0/1
0/1
3
3.1
Main program
Mains period measurement
As the board does not embed an oscillator or resonator, the internal resonator of the MCU is
used to achieve the clock. But, in this case, the running frequency is given within a range of
20%. This is not enough to ensure an optimum pulse gate current control with a power
consumption as little as possible.
To increase the timer accuracy, the MCU uses the Zero Voltage Crossing (ZVC) events to
have time infor-mation. The LINE voltage is connected to the NMI pin through a high
impedance resistor. An interruption will then occur at each ZVC event. The MCU has just to
launch the timer decrementation between two NMI interrupts to calculate how much one
must load the TCR register to count down 20 ms.
Of course, in normal operation, the timer can be used for other tasks than counting the
mains period. The period measurement will then be based on the rest of time from the last
timer utilization and the next NMI interrupt. This measured time is saved as DELTAT (see
Figure 2)
by the software. The 20 ms will then equal the DELTAT, plus the sum of times T1 to
T3, plus the time lost due to calculator operations between each timer stop and launch (see
Section 4.3).
Note:
Such a method is only valid when the mains frequency is know in advance; i.e. for a board
dedicated to one range of AC mains voltage. In our case, the software and hardware are
dedicated to 220/240 V 50 Hz applications.
Rev 2
3/17
Main program
Figure 2.
Timing definition
AN1353
NMI
Mains Voltage
PA3
PA1 / PA2
Subroutines
T1 T2 T3
Calcul
Delay 1
Current
Measure
Motor
Status
Calcul
Delay 2
Loads
Control
T4
T5
DELTAT
3.2
Subroutines execution time checking
In order not to miss the timer interrupt events, the CPU must be completely free and ready
to check the timer interrupt flag. This means that all subroutines must be completed before
the expected end of the timer decrementation.
Figure 2
shows that the subroutines are placed at different moments, depending on their
length. For exam-ple, the longest CPU action is when the MCU calculates the T1 to T5
delays. This action can last up to more than 7.2 ms for a 4 MHz MCU clock frequency. Then,
there is not enough time available between two timer interrupts to calculate these five
values. This is the reason why the delay calculation subroutine has been split into two parts
(Calcul-Delay_1 and Calcul-Delay_2). These two parts are respectively placed during T4
and DELTAT decounts
Table 3
gives the maximum duration of each subroutine (for a 4 MHz clock frequency, and
the for the lon-gest software loops).
Table 3.
Subroutines maximum durations
SUBROUTINE NAME
Loads_Control
Motor_Status
Current_Measure
Calcul_Delay_1
Calcul_Delay_2
MAXIMUM TIME
0.93 ms
0.26 ms
0.92 ms
1.75 ms
5.49 ms
Table 4
gives the code execution maximum times for all the instructions written in the
software, before each subroutine (“code execution time” column). Then, according to the
implemented durations, the time, still available for the CPU, is given with a 0.2 ms safety
margin.
4/17
Rev 2
AN1353
Table 4.
Name
T1
T2
T3
T4
T5
DELTAT
TOTAL
Main program
CPU available time
Duration
(ms)
0.45
1.05
1.75
3.95
2.80
6.75
Code execution time
(ms)
0.25
0.13
0.13
0.85 (T50 Hz average)
0.09
0.08
Subroutines time sum
(ms)
0
0
0
1.75
0.26 + 0.92
5.49 + 0.93
Available time (ms)
0
0.72
1.42
1.15
1.33
0
4.62
3.3
Start-up and smart reset
At each RESET interrupt, the program first checks if the data stored in the RAM are as
scheduled or not. In-deed, a RESET can occur without the supply voltage having fallen
below VRM (Data retention parameter: 0.7 V). In this case, a whole start-up is not
necessary, and the program can keep working with the previous RAM data. This is helpful in
order to avoid missing loads control when a RESET occurs, due to an EMI problem for
example.
If the checked RAM registers are not as expected, then a complete initialization procedure is
launched (see
Appendix B).
This routine, among other things, configures the A and B ports,
waits 100 ms before go on (wait-ing for the stabilization of the supply), and measures the
mains period for the first time.
If the RAM area is adequate, then a “Smart Reset” can be performed. Only the registers
which are used to store internal sub-routines variables are cleared. Only the main registers
keep their previous values (motor status, etc.).
It is important to note that this start-up procedure can miss firing some loads during one
mains cycle. This is why, if the motor was at start-up state before a “Smart Reset”, it is better
to stop the motor. This avoids switching both the Tr and Ts devices ON together when the
split phase capacitor can be charged (refer to AN1354). This is done by simply setting to
high level the overcurrent detection flag.
Rev 2
5/17