a cation note - · pdf filelication note 2010 samsung electronics co., ... use of the...

42
S3F84ZB Thermostat Demo System Revision 0.00 May 2010 A A p p p p l l i i c c a a t t i i o o n n N N o o t t e e 2010 Samsung Electronics Co., Ltd. All rights reserved.

Upload: lexuyen

Post on 12-Mar-2018

215 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB Thermostat Demo System

Revision 0.00

May 2010

AApppplliiccaattiioonn NNoottee

2010 Samsung Electronics Co., Ltd. All rights reserved.

Page 2: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

Important Notice

"Typical" parameters can and do vary in different applications. All operating parameters, including "Typicals" must be validated for each customer application by the customer's technical experts.

The information in this publication has been carefully checked and is believed to be entirely accurate at the time of publication. Samsung assumes no responsibility, however, for possible errors or omissions, or for any consequences resulting from the use of the information contained herein. Samsung products are not designed, intended, or

authorized for use as components in systems intended for surgical implant into the body, for other applications intended to support or sustain life, or for any other application in which the failure of the Samsung product could create a situation where personal injury or death may occur.

Samsung reserves the right to make changes in its products or product specifications with the intent to improve function or design at any time and without notice and is not required to update this documentation to reflect such changes.

Should the Buyer purchase or use a Samsung product for any such unintended or unauthorized application, the Buyer shall indemnify and hold Samsung and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, expenses, and reasonable attorney fees arising out of, either directly or indirectly, any claim of personal injury or death that may be associated with such unintended or unauthorized use, even if such claim alleges that Samsung was negligent regarding the design or manufacture of said product.

This publication does not convey to a purchaser of semiconductor devices described herein any license under the patent rights of Samsung or others.

Samsung makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Samsung assume any liability arising out of the application or use of any product or circuit and specifically disclaims any and all liability, including without limitation any consequential or incidental damages.

S3F84ZB Thermostat Demo System Application Note, Revision 0.00

Copyright 2010 Samsung Electronics Co., Ltd.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electric or mechanical, by photocopying, recording, or otherwise, without the prior written consent of Samsung Electronics.

Samsung Electronics Co., Ltd. San #24 Nongseo-Dong, Giheung-Gu Yongin-City, Gyeonggi-Do, Korea 446-711

TEL: (82)-(31)-209-3865 FAX: (82)-(31)-209-6494

Home Page: http://www.samsungsemi.com

Page 3: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

Revision History

Revision No. Effective Date Description Refer to Author(s)

0.00 May, 2010 - Initial Draft

Page 4: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

Table of Contents

1 OVERVIEW OF THERMOSTAT DEMO SYSTEM ......................................1-1

1.1 Key Features of thermostat...................................................................................................................... 1-2 1.2 Operating Theory ..................................................................................................................................... 1-2 1.3 System Block Diagram............................................................................................................................. 1-3 1.4 State Diagram .......................................................................................................................................... 1-4

2 HARDWARE IMPLEMENTATION...............................................................2-1

2.1 Overview of Hardware Implementation.................................................................................................... 2-1 2.2 Pin Assignment ........................................................................................................................................ 2-2 2.3 Block Instruction in Main Board ............................................................................................................... 2-3

2.3.1 MCU.................................................................................................................................................. 2-3 2.3.2 Power Supply.................................................................................................................................... 2-4 2.3.3 Voltage Reference............................................................................................................................ 2-5 2.3.4 Battery Level Detect ......................................................................................................................... 2-5 2.3.5 AC Loss Detect................................................................................................................................. 2-6 2.3.6 LCD Display...................................................................................................................................... 2-6 2.3.7 Key Matrix......................................................................................................................................... 2-7 2.3.8 Relay Control .................................................................................................................................... 2-7 2.3.9 Open-drain Output ............................................................................................................................ 2-8 2.3.10 Buzzer............................................................................................................................................. 2-8 2.3.11 RS-485 Interface............................................................................................................................. 2-9 2.3.12 Remote Receiver............................................................................................................................ 2-9 2.3.13 Clock and Reset Circuit ................................................................................................................ 2-10 2.3.14 PGM Interface............................................................................................................................... 2-10

2.4 Block Instruction in Sensor Board.......................................................................................................... 2-11 2.4.1 Temperature Sensor....................................................................................................................... 2-11 2.4.2 Humidity Sensor ............................................................................................................................. 2-11 2.4.3 Interface between Main Board and Sensor Board ......................................................................... 2-12

3 SOFTWARE IMPLEMENTATION .............................................................3-13

3.1.1 Source Code Files .......................................................................................................................... 3-13 3.1.2 Software Flow Chart ....................................................................................................................... 3-14 3.1.3 Main Task ....................................................................................................................................... 3-14 3.1.4 Watch Timer ISP............................................................................................................................. 3-15 3.1.5 Key ISP........................................................................................................................................... 3-16 3.1.6 Battery Level Detect ....................................................................................................................... 3-18 3.1.7 AC Loss Detect............................................................................................................................... 3-19 3.1.8 Temperature Detect........................................................................................................................ 3-20 3.1.9 Humidity Detect .............................................................................................................................. 3-21 3.1.10 Fan and Valve Control.................................................................................................................. 3-22 3.1.11 Fan Speed Control........................................................................................................................ 3-23 3.1.12 Timer Function.............................................................................................................................. 3-24 3.1.13 LCD Display.................................................................................................................................. 3-25 3.1.14 Flash Read ................................................................................................................................... 3-26 3.1.15 Flash Write.................................................................................................................................... 3-27

Page 5: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

4 APPENDIX1: THERMOSTAT DEMO SYSTEM ........................................4-28

5 APPENDIX2: SOURCE CODE ....................................................................5-1

Page 6: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

List of Figures

Figure Title Page Number Number Figure 1-1 HVAC Structure Diagram.................................................................................................................. 1-1 Figure 1-2 System Block Diagram ..................................................................................................................... 1-2 Figure 1-3 System Block Diagram ..................................................................................................................... 1-3 Figure 1-4 State Diagram................................................................................................................................... 1-4 Figure 2-1 Microcontroller .................................................................................................................................. 2-3 Figure 2-2 Power Supply.................................................................................................................................... 2-4 Figure 2-3 Voltage Reference Circuit................................................................................................................. 2-5 Figure 2-4 Battery Detection Circuit ................................................................................................................... 2-5 Figure 2-5 AC Loss Detection Circuit................................................................................................................. 2-6 Figure 2-6 LCD Display Circuit........................................................................................................................... 2-6 Figure 2-7 Key Matrix Circuit.............................................................................................................................. 2-7 Figure 2-8 Relay Control Circuit......................................................................................................................... 2-7 Figure 2-9 Open-drain Output Circuit................................................................................................................. 2-8 Figure 2-10 Buzzer Circuit.................................................................................................................................. 2-8 Figure 2-11 RS-485 Interface Circuit ................................................................................................................. 2-9 Figure 2-12 Remote Receiver ............................................................................................................................ 2-9 Figure 2-13 Clock and Reset Circuit ................................................................................................................ 2-10 Figure 2-14 PGM Interface............................................................................................................................... 2-10 Figure 2-15 Temperature Detection Circuit...................................................................................................... 2-11 Figure 2-16 Humidity Detection Circuit ............................................................................................................ 2-11 Figure 2-17 Interface between Main Board and Sensor Board........................................................................ 2-12 Figure 3-1 Main Task Flow Chart..................................................................................................................... 3-14 Figure 3-2 WT ISP Flow Chart ......................................................................................................................... 3-15 Figure 3-3 Key ISP Flow Chart ........................................................................................................................ 3-16 Figure 3-4 BLD Flow Chart............................................................................................................................... 3-18 Figure 3-5 AC Loss Detect Flow Chart ............................................................................................................ 3-19 Figure 3-6 Temperature Detect Flow Chart ..................................................................................................... 3-20 Figure 3-7 Humidity Detect Flow Chart ............................................................................................................ 3-21 Figure 3-8 Fan and Valve Control Flow Chart................................................................................................ 3-22 Figure 3-9 Fan Speed Control Flow Chart ....................................................................................................... 3-23 Figure 3-10 Timer Function Flow Chart ........................................................................................................... 3-24 Figure 3-11 LCD Display Flow Chart ............................................................................................................... 3-25 Figure 3-12 Flash Read Flow Chart ................................................................................................................. 3-26 Figure 3-13 Flash Write Flow Chart ................................................................................................................. 3-27 Figure 4-1 Thermostat Demo System (1)......................................................................................................... 4-28 Figure 4-2 Thermostat Demo System (2)......................................................................................................... 4-29 Figure 4-3 Thermostat Demo Control Board.................................................................................................... 4-30

Page 7: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

List of Tables

Table Title Page Number Number Table 2-1 Pin Assignment .................................................................................................................................. 2-2 Table 3-1 Source Code Files ........................................................................................................................... 3-13 Table 3-2 Key Functions .................................................................................................................................. 3-17 Table 4-1 Current Consumption Contrast ........................................................................................................ 4-30

Page 8: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 1 OVERVIEW OF THERMOSTAT DEMO SYSTEM

1 OVERVIEW OF THERMOSTAT DEMO SYSTEM

A thermostat can operate as a control unit for any heating or cooling system or as a component of any heater or air conditioner. Thermostats can be designed in many ways. They can use a variety of sensors to measure the temperature. The output of sensor controls the heating or cooling system.

The thermostat reference design uses Samsung’s newly developed microcontroller called S3F84ZB. This microcontroller is ideal for use in a wide range of electronic applications and home appliances requiring timer/counter, ADC, LCD display, LVD, UART, watch timer, and key strobe. The LCD controller/driver and 10-bit ADC play an important role for LCD display and temperature detection in the thermostat. Also, embedded full flash can be used as EEPROM for storing user’s data.

Thermostats are widely applied in industry and home appliances. This chapter only focuses on the use of thermostats in home appliances. For a brief overview of thermostats, refer to the central air-conditioner system (HVAC) structure diagram shown below.

Figure 1-1 HVAC Structure Diagram

1-1

Page 9: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 1 OVERVIEW OF THERMOSTAT DEMO SYSTEM

1.1 KEY FEATURES OF THERMOSTAT

The key features of thermostat include:

Automatic temperature control

7-day, 24-hour intelligent temperature program

Four operating modes (Manual, Auto, Program1, and Program2)

Wind speed (optional)

Large LCD display

Humidity detect and display

Infrared remote control

User data holding after power-off

Convenient communication ports such as RS-485

1.2 OPERATING THEORY

A thermostat regulates the temperature of a system, so that the system’s temperature can be maintained close to the desired set point temperature. To achieve this, the thermostat controls the flow of heat energy in or out of the system. In other words, the thermostat switches the heating or cooling devices on or off (as needed) to maintain the correct temperature.

The thermostat compares current temperature with user’s set point temperature, and then decides whether to heat or cool. You can change the set point, operating mode, and wind speed manually. Also, if you program 7-day temperature, the thermostat can operate automatically.

Figure 1-2 System Block Diagram

1-2

Page 10: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 1 OVERVIEW OF THERMOSTAT DEMO SYSTEM

1.3 SYSTEM BLOCK DIAGRAM

Figure 1-3 shows the system structure based on S3F84ZB.

RS485/232

Key Matrix

LCD Display

S3F84ZBADC

LCD

WT

IO

Key Strobe

UART

Timer

TAFull Flash

Voltage ReferenceMAX6007A

LVD Detect

Open-drain Output

AC Loss Detect

Humidity SensorHM1500

Temperature Sensor

MAX6607

SAM88

RAM

AirconSystem

Relay Control

Buzzer

Infrared Remote

Heating/CoolingDevice

Figure 1-3 System Block Diagram

1-3

Page 11: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 1 OVERVIEW OF THERMOSTAT DEMO SYSTEM

1.4 STATE DIAGRAM

Figure 1-4 shows the state diagram of S3F84ZB.

Figure 1-4 State Diagram

In power saving mode, the AC power is turned off and power is supplied to the MCU by a 3V battery. When the power is turned on, the MCU operates in Main-run mode and regulates temperature of the heating or cooling system. It then switches to Sub-idle mode.

In the Sub-idle mode, the peripheral modules (such as LCD, Timer, IO, and so on) keep operating while the CPU stops. However, the heating or cooling continues.

The timer interval interrupt occurs for several seconds before the MCU returns to the Main-run mode. The MCU then compares the current temperature with set point temperature. If both the temperatures are equal, the MCU stops cooling or heating, and checks the user program. Finally, the MCU returns to Sub-idle mode again. The key interrupt can also wake up the MCU. To shut down the system, power-on/off button is used (For more details, refer to Table 3-2, “Key Function”).

1-4

Page 12: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2 HARDWARE IMPLEMENTATION

2.1 OVERVIEW OF HARDWARE IMPLEMENTATION

The thermostat system is divided into two boards, namely, Main board and Sensor board.

The Main board contains 14 blocks, namely, MCU, Power supply, Voltage reference, Battery level detect, AC loss detect, LCD display, Key matrix, Relay control, Open-drain output, Buzzer circuit, RS-485 interface, Remote receiver, Clock and Reset circuit, and PGM interface.

The Sensor board contains 2 blocks, namely, Temperature detection circuit and Humidity detection circuit. It is placed in the test box during normal operation.

2-1

Page 13: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2.2 PIN ASSIGNMENT

Table 2-1 shows the pin assignment of S3F84ZB.

Table 2-1 Pin Assignment

Pin Net Name Function

P7.0~7, P8.0~2,

COM0~7, SEG0~10 11×8 LCD display

P4.3 TEMP0 ADC input for temperature detection

P4.4 5V_DETECT ADC input for DC 5V detection

P4.5 HUMIDITY ADC input for humidity detection

P4.6 BLD ADC input for LVD detection

P9.4~6 COOLER, HEATER, VALVE Output for relay control

P9.0~3 FAN_EN, FAN_HIGH, FAN_MID, FAN_LOW Output for fan control and fan speed control

P1.2~3 TXD0, RXD0 RS-485 interface

P1.2~3 TXD1, RXD1 UART interface

P1.1 RS485_EN RS485 Control signal

P1.6 REMOTE Timer capture input for infrared remote reception

P1.7 REMOTE_LED Output for LED display

P2.0~3, P10.0~4

KINT0~3, KSTR0~4 KINT and key strobe output for key matrix

P3.7 BUZ BUZ for buzzer control

AVREF AVREF ADC reference voltage

P4.0~1 SCLK, SDAT For flash programming

P5.0~3 VLC0~3 Vlc0~3

P5.4~5 CA, CB LCD bias cap

XIN, XOUT, XIN, XOUT, Main oscillator

P5.6~7 XTIN, XTOUT, Sub oscillator

nRESET nRESET RESET pin

VDD VDD Power supply

VSS1, VSS2

GND Ground

2-2

Page 14: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-3

2.3 BLOCK INSTRUCTION IN MAIN BOARD

2.3.1 MCU

CO

M1

C32

0.1uf /50v

CB

SEG8

CO

M2

CA

SEG7

CO

M3

BLD

VLC3

VA

LVE

SEG6

FAN_HIGH

CO

M4

+C30

100pF/25V

KIN

T3

VLC2

P1.11

P1.02

AVSS3

AVREF4

P4.75

P4.66

P4.57

P4.48

P4.39

P4.210

P4.111

VSS114

XIN16

TEST17

P5.718

P5.619

nRESET20

P5.521

P5.422

P5.323

P5.224

P5.125

P4.012

VDD13

XOUT15

P5.

02

6

P0.

72

7

P0.

62

8

P0.

52

9

P0.

43

0

P0.

33

1

P0.

23

2

P0.

13

3

P0.

03

4

P10

.73

5

P10

.63

6

P10

.53

7

P10

.43

8

P10

.33

9

P10

.24

0

P10

.14

1

P10

.04

2

P11

.14

3

P11

.04

4

P9.

74

5

P9.

64

6

P9.

54

7

P9.

44

8

P9.

34

9

P9.

25

0

P9.151P9.052P8.753P8.654P8.555P8.456P8.357P8.258P8.159P8.060P7.761P7.662VSS263IVCREF64P7.565P7.466P7.367P7.268P7.169P7.070P6.771P6.672P6.573P6.474P6.375

P6.

276

P6.

177

P6.

078

P3.

779

P3.

680

P3.

581

P3.

482

P3.

383

P3.

284

P3.

185

P3.

086

P2.

787

P2.

688

P2.

589

P2.

490

P2.

391

P2.

292

P2.

193

P2.

094

P1.

795

P1.

696

P1.

597

P1.

498

P1.

399

P1.

210

0

S3F84ZB

U7

S3F84ZB_TQFP_100

HE

AT

ER

VSS2

CO

M5

TEMP0

KIN

T2

VLC1

CO

OL

ER

IVCREFVDD

CO

M6

KIN

T1

MCU

FA

N_

LOW

SEG5SDAT

CO

M7

KIN

T0

RS485_EN

FA

N_

MID

SEG4

SCLK

+C31

100pF/25V

RE

MO

TE

_LE

D

FAN_EN

SEG3

RE

MO

TE

VSS1

SEG2

TX

D1

XOUT

KS

TR

4

SEG1

RX

D1

VLC

0

XIN

KS

TR

3SEG0

TX

D0

KS

TR

2

AVREF

RX

D0

XTIN+ C33

0.01uF/25V

KS

TR

1

TEST

XTOUT

KS

TR

0

SEG10

CO

M0

nRESET

HUMIDITY

BU

Z

SEG9

5V_DETECT

Figure 2-1 Microcontroller

Page 15: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-4

2.3.2 POWER SUPPLY

+ C1

220uF/50V

VDD

BT2BATTERY

+ C3

10uF/50V

+ C4

0.1uF/50V

DC_5V

GND

DC_12VR9

10

DC_12V

VOUT2VIN3

GND1

U2

LM1117-3.3

R14

0

VDD

+ C16

0.1uF/25V

+ C1510uF/25V

D4

1N5820

DC_3.3V

Power Supply

Power Supply

+ C13

10uF/50V

+ C14

0.1uF/50V

COOLER_GNDCOOLER_12V1

2

J5

DC_12V_CON2

DC_3.3V

BT1

BATTERY

+ C2

10uF/50V+C9

0.1uF/25V

+C6

10uF/25V

VIN1

GND2

VOUT3

U1

KA7805

12

J4

DC_12V_COND6

1N5820

Figure 2-2 Power Supply

The thermostat system can be powered by using AC220V (need external transformer) and DC12V. DC_5V is used for AC_LOSS detection.

When AC220V power is turned off, the thermostat system is powered by two AA batteries (3V). At this point, only temperature detect/key/LCD function is enabled and VDD is approximately 2.8V because there is 0.2V voltage drop at D6 (1N5820). For higher ADC accuracy, analog ground is independent from digital ground. They are connected through a 0-ohm resistor.

Page 16: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-5

2.3.3 VOLTAGE REFERENCE

OUT1

GND2

IC3

U4

MAX6007A

R1720k

+ C21

0.01uF/25V

AVREF

VDD

R20

20 + C19

0.01uF/25V

Voltage Reference

Figure 2-3 Voltage Reference Circuit

Figure 2-3 specifies the voltage reference circuit for AVREF. MAX6007A can generate a stable voltage of 2.048V. Since the battery voltage changes all the time, voltage reference is needed.

2.3.4 BATTERY LEVEL DETECT

R24 100K

VDD

BLD

R25 200k

Battery Detect

R231k

+

C230.1uF/25V

Figure 2-4 Battery Detection Circuit

The system is powered on using the battery. If the battery level is low, it is necessary to shut down the system. The BLD signal is connected to MCU ADC input pin.

Since AVREF is supplied by 2.048V voltage reference, the battery level (maximum 3V) must be divided to 2/3rd of itself before ADC conversion.

Page 17: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-6

2.3.5 AC LOSS DETECT

DC_5V

R33 150k

5V_DETECT

R34 100k

R321k

AC Loss Detect

+

C280.1uF/25V

Figure 2-5 AC Loss Detection Circuit

This circuit is used for AC loss detection. DC_5V specifies the signal after 7805. 5V_DETECT signal is connected to MCU ADC input pin. Since AVREF is supplied by 2.048V voltage reference, DC_5V (maximum 5V) must be divided to 2/5th of itself before ADC conversion.

2.3.6 LCD DISPLAY

CAC240.1uf /50v

VLC3C250.1uf /50v

VLC2C260.1uf /50v

LCD Display

VLC1C270.1uf /50v

COM0

VLC0C290.1uf /50v

CBCOM1COM2COM3COM4COM5COM6COM7

COM01

COM12

COM23

COM34

COM45

COM56

COM67

COM78

SEG09

SEG110

SEG211

SEG312

SEG413

SEG514

SEG615

SEG716

SEG817

SEG918

SEG1019

U5

LCD_JY05682

SEG0SEG1SEG2SEG3SEG4SEG5SEG6SEG7SEG8SEG9SEG10

Figure 2-6 LCD Display Circuit

A 11(segment)×8(COM) LCD panel is used for LCD Display Circuit. The LCD controller integrated is configured in cap-biased mode.

Page 18: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-7

2.3.7 KEY MATRIX

SW2

A

SW12

A

SW7

A

SW17

A

KINT1

SW8

A

SW3

A

SW13

A

SW18

A

SW4

A

SW9

A

SW14

A

SW19

A

KSTR0

KINT3

SW1

A

KSTR2KSTR1

SW6

A

KSTR3

SW11

A

SW16

A

KINT0

SW5

A

SW10

A

SW15

A

SW20

A

KSTR4

Key Strobe Output & KINT

KINT2

Figure 2-7 Key Matrix Circuit

Since S3F84ZB has a KEY STROBE function, it is easy to realize a 4×5 key matrix by using four KINT ports and five key strobe output ports.

2.3.8 RELAY CONTROL

R35 1k

Relay Control

12

J8

Cooler

43

12

RL1

JZC-32F

Q2

9013

COOLER_12V

R36

2k

D101N4148

R38

4.7K

FAN_EN

COOLER_GNDD11POWER

DC_12V

43

12

RL2

JZC-32F

Q3

9013

DC_5V

R41

2kR40

4.7K

VALVE

D121N4148

R39

10

DC_12V

R37

10

Figure 2-8 Relay Control Circuit

This system has a 2-channel relay control output that is used for fan and valve control. You can use a semiconductor cooler for demo.

Page 19: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2.3.9 OPEN-DRAIN OUTPUT

Figure 2-9 Open-drain Output Circuit

FAN_HIGH, FAN_MID, and FAN_LOW signal is used to set the fan speed. On the other hand, HEATER and COOLER signal is used to enable/disable the heater or cooler. The Open-drain output can match external voltage level by pulling-up.

2.3.10 BUZZER

Figure 2-10 Buzzer Circuit

BUZ is used to control the buzzer on or off. It is also used to control the buzzer frequency by software setting.

2-8

Page 20: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2.3.11 RS-485 INTERFACE

Figure 2-11 RS-485 Interface Circuit

This system has an RS-485 interface for communication, and another UART interface for system expansion.

2.3.12 REMOTE RECEIVER

Figure 2-12 Remote Receiver

This system has an infrared remote signal receiver and an LED for display. REMOTE signal is connected to MCU’s TACAP pin.

2-9

Page 21: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2.3.13 CLOCK AND RESET CIRCUIT

Figure 2-13 Clock and Reset Circuit

Main oscillator is 4MHz and Sub oscillator is 32.768 kHz.

2.3.14 PGM INTERFACE

Figure 2-14 PGM Interface

S3F84ZB has a built-in full flash. It needs VPP = 5V for PGM. However, some tools such as SPW2 + can only output VPP = 12.5V, so a variable resistor is needed in the path of VPP/TEST.

2-10

Page 22: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-11

2.4 BLOCK INSTRUCTION IN SENSOR BOARD

2.4.1 TEMPERATURE SENSOR

R42

1k

+C37 0.1uF/50V

OUT1

NC2

A3

VCC4

GND5

U8

MAX6607

+C35

0.1uF/25V

Temperature Sensor

TEMP0_EX

+ C360.1uF/50V

VDD_EX

Figure 2-15 Temperature Detection Circuit

MAX6607 is an integrated temperature sensor chip that has a supply voltage ranging from 1.8V to 3.6V and maximum 15uA supply current over the -20C to + 85C temperature range. Its accuracy is +/- 0.7C from TA = 0C to 70C, and its output voltage is 500mV to 1400mV. TEMP0_EX is connected to MCU ADC input pin. 2.4.2 HUMIDITY SENSOR

GND1VCC2VO3

U9

HM1500

Humidity Sensor

R44 10k R45 10k

HUMIDITY_EX

+

C340.1uF/25VR431k

DC_5V_EX

Figure 2-16 Humidity Detection Circuit

HM1500 is a “relative humidity” module that provides 1 to 4 Volt output for 0 to 100 % RH at 5V DC supply. It can be calibrated within +/- 2% RH @ 55 % RH. It can supply voltage from 3 to 7 Volts, so this module is unavailable when system is powered by the battery. HUMIDITY_EX is connected to the MCU ADC input pin. Since AVREF is supplied by 2.048V voltage reference, HUMUDITY_EX (maximum 4V) must be divided to 1/2 of itself before ADC conversion.

Page 23: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 2 HARDWARE IMPLEMENTATION

2-12

2.4.3 INTERFACE BETWEEN MAIN BOARD AND SENSOR BOARD

DC_5VVDD

123456

J2

CONN PCB 6

Interface to Sensor Board

TEMP0HUMIDITY

TEMP0_EX

Interface to Main Board

123456

J9

CONN PCB 6

DC_5V_EXVDD_EX

HUMIDITY_EX

Figure 2-17 Interface between Main Board and Sensor Board

Main board and sensor board is connected by a 6-pin connector.

Page 24: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3 SOFTWARE IMPLEMENTATION

This section describes the software used in the thermostat reference design. The software is written in C language.

3.1.1 SOURCE CODE FILES

Table 3-1 lists the source code files.

Table 3-1 Source Code Files

File name Description

ioS3F84ZB.h Declarations of S3F84ZB register and interrupt vector.

constant.h Declarations of variables, arrays, and external functions.

Main.c Configuration of peripherals, control functions, interrupt service routine, and main task.

sensor.c Temperature and humidity detection function.

Lcd_disp.c LCD display drive program.

delay.c Collection of delay functions.

3-13

Page 25: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.2 SOFTWARE FLOW CHART

3.1.3 MAIN TASK

Figure 3-1 Main Task Flow Chart

This section describes the main task of system. An area of full flash is used for storing the user data. After power on, this data will be loaded into the RAM, and will be saved when the key is pressed (refer to Table 3-2, “Key Function”). After each implement cycle, the MCU will switch into Sub-idle mode for power saving. It will wake up by watch timer interrupt or key interrupt.

3-14

Page 26: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.4 WATCH TIMER ISP

Figure 3-2 WT ISP Flow Chart

The Watch timer operates all the time and is clocked by the sub-oscillator. It never stops even when the MCU is idle. The MCU wakes up by WT interrupt for several seconds (ignoring the key interrupt). It also acts as a timepiece and reference for other controls.

3-15

Page 27: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.5 KEY ISP

Figure 3-3 Key ISP Flow Chart

There are 20 keys in this system realized by key strobe module. Nine keys are used for basic functions, while other 11 keys for advanced functions. Table 3-2 specifies the detailed key functions.

3-16

Page 28: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

Table 3-2 Key Functions

Key Style Key No Key Name Function

1 ON/OFF Power On/ Off

2 MODE Select Mode (Manual, Auto, Prog1, and Prog2)

Basic Key (Normal mode)

3 TIMER Timer for Power Off

4 FAN Select Fan Speed (High, Mid, and Low)

5 + Increase expected temperature (Maximum 30C)

6 - Decrease expected temperature (Minimum 16C)

7 LOCK Key Lock

8 C/F Select Unit: Centigrade/Fahrenheit

9 PGM Program Switch (Prog1 and Prog2)

10 DAY UP Next Day (Used to set the current date in normal mode)

Advanced Key (Program Mode for system programming)

11 DAY DOWN Previous Day (Used to set the current date in normal mode)

12 TIME Set Node Time

13 TEMP. Set Node Temperature

14 LEFT Left Shift (Used to set the current time in normal mode)

15 RIGHT Right Shift (Used to set the current time in normal mode)

16 UP Increase (Used to set the current time in normal mode)

17 DOWN Decrease (Used to set the current time in normal mode)

18 ON TIME Set Power On Time

19 OFF TIME Set Power Off Time

20 ENTER Enter (Single click to store current node, double click to store Prog1/Prog2 and exit program mode; Used to store the user data to flash in normal mode)

3-17

Page 29: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.6 BATTERY LEVEL DETECT

Figure 3-4 BLD Flow Chart

Figure 3-4 shows Battery level detect (BLD) for low-level protection.

3-18

Page 30: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.7 AC LOSS DETECT

Figure 3-5 AC Loss Detect Flow Chart

Since DC_5V is derived from AC power, it is necessary to check whether AC power loss has taken place. If AC power is lost, some functions such as relay control, humidity detect, buzzer control, and so on will not be implemented, and other functions such as LCD display, temperature detect, key function, and so on will remain active.

3-19

Page 31: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.8 TEMPERATURE DETECT

Figure 3-6 Temperature Detect Flow Chart

Two kinds of temperature are supported, that is, Centigrade temperature (default) and Fahrenheit temperature.

3-20

Page 32: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.9 HUMIDITY DETECT

Figure 3-7 Humidity Detect Flow Chart

Humidity detect result is stable in 10 seconds. The result is available only when AC power is on, since its suitable supply voltage ranges from 3 to 7 Volts.

3-21

Page 33: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.10 FAN AND VALVE CONTROL

Figure 3-8 Fan and Valve Control Flow Chart

Fan and Valve are the main devices for heating or cooling. They are controlled by the relay circuit.

3-22

Page 34: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.11 FAN SPEED CONTROL

Figure 3-9 Fan Speed Control Flow Chart

Using the key, you can choose from three options for fan speed control, that is, high speed, middle speed, and low speed.

3-23

Page 35: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.12 TIMER FUNCTION

Timer Enable?

Start

Power Off

End

N

Y

Time Out?

Y

N

Figure 3-10 Timer Function Flow Chart

Using the key, you can choose from eight options, that is, 15 minutes, 30 minutes, 1 hours, 2 hours, 3 hours, 4 hours, 5 hours, and 6 hours.

3-24

Page 36: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.13 LCD DISPLAY

Normal Display

Programming mode?

Start

End

N

Y

Display Program Interface

Figure 3-11 LCD Display Flow Chart

The LCD Display shows the date, time, temperature, humidity, mode, fan speed, program interface, and so on.

3-25

Page 37: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.14 FLASH READ

Figure 3-12 Flash Read Flow Chart

The Flash Read shows how to read user data from flash to RAM. Since full flash can be read, programmed, and erased online, it can act as an EEPROM. In this case, 32 sectors (from 0xe000 to 0xefff) are used for storing user data, and each time 1 sector is used. Several bytes are used to verify whether this sector is active. The active sector will be found and loaded into the RAM. When the power is on, flash data is read.

3-26

Page 38: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 3 SOFTWARE IMPLEMENTATION

3.1.15 FLASH WRITE

Figure 3-13 Flash Write Flow Chart

The Flash Write shows how to store user data to flash. It is similar to flash read function. This action will be done when the key is pressed (refer to Table 3-2, “Key Function”).

3-27

Page 39: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 4 APPENDIX 1: THERMOSTAT DEMO SYSTEM

4 APPENDIX 1: THERMOSTAT DEMO SYSTEM

The demo system is divided into three parts, namely, Control Board, Test Box, and Power Supply.

Control Board contains the MCU, LCD, Key Matrix, and other control circuit.

Test Box is used for real system simulation that contains an Aircon system. A Sensor Board is located in Test Box, including Temperature Sensor and Humidity Sensor. In normal operation, the Control Board receives sensor signal from Test Box (Sensor Board), and sends control signal to it for cooling or heating. Then the temperature in Test Box approaches the expected value gradually.

The Power Supply converts 220V AC into 2-channel 12V DC to support Control Board and Test Box.

Thermostat can work in Manual mode, Auto mode, PROG1 mode, and PROG2 mode. The latter two are user program modes, where you can program 7-day’s temperature for the thermostat to operate automatically.

Figure 4-1 and Figure 4-2 shows the thermostat demo system.

Figure 4-1 Thermostat Demo System (1)

4-28

Page 40: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 4 APPENDIX 1: THERMOSTAT DEMO SYSTEM

Figure 4-2 Thermostat Demo System (2)

4-29

Page 41: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 4 APPENDIX 1: THERMOSTAT DEMO SYSTEM

Figure 4-3 provides a close look of the thermostat demo control board.

Since the system is supplied by a battery after the AC power is off, the current consumption becomes important. The AA battery used is Duracell MN1500, since S3F84ZB’s minimum operating voltage is 2.0V when Fxx = 4MHz, and diode 1N5820 has about 0.2V voltage drop (refer to Figure 2-2, “Power Supply”). Therefore, the battery level must be at least 2.2V and each MN1500 must be at least 1.1V. In this case, 2-set MN1500 has about 3500mAh capacity. Since a thermostat’s life is more than two years, the target average current consumption must be less than 3500mAh/(24hour×365×2) = 0.1997mA.

The real current consumption can be tested through the voltage drop at a small resistor on VDD path. When battery level is equal to 3V, the average voltage drop between the resistor is 2mV and the resistor value is 10.3Ω. Therefore, the real current consumption is 2mV/10.3Ω = 0.1941mA, inside the range of target value (refer to the Table 4-1, “Current Consumption Contrast”). Note that current consumption will be decreasing during the battery voltage drop.

Table 4-1 Current Consumption Contrast

Item Current Consumption Conclusion

Target Value 0.1997mA. Current consumption meets thermostat application requirement, and can guarantee a two-year life. Real Value 0.1941mA

Figure 4-3 Thermostat Demo Control Board

4-30

Page 42: A cation Note -  · PDF filelication Note 2010 Samsung Electronics Co., ... use of the information contained herein. ... personal injury or death may occur

S3F84ZB_THERMOSTAT DEMO SYSTEM_AN_REV 0.00 5 APPENDIX 2: SOURCE CODE

5 APPENDIX 2: SOURCE CODE

For source code, refer to the Src_Thermostat.rar.

5-1