ST STEVAL-IHM037V1 User manual

September 2012 Doc ID 023229 Rev 1 1/17
UM1546
User manual
STEVAL-IHM037V1 remote fan speed controller
Introduction
The remote fan speed controller is a single channel TRIAC based solution meant to replace
the existing fan speed controllers and provide the IR remote control feature. It is designed to
fit easily inside an enclosure with the dimensions of a single-switch module.
A non-isolated capacitive power supply is used to power the microcontroller and the IR
sensor. The TSOP38438 IR sensor is used to demodulate the 38 kHz IR signal from the IR
transmitter and decoded by the STM8S003 value line microcontroller to perform the various
control functions. IR communication is based on the RC5 protocol standard. A TRIAC is
used as the control element to regulate the power going into the fan by varying its firing
angle for different speed settings. The speed settings can be changed by using the onboard
tactile switches or by using the IR remote controller.
The STM8S003F3 value line 8-bit microcontroller, with its internal data EEPROM, hardware
timers and external interrupts on GPIOs, makes an efficient implementation of the
application possible while keeping the size, cost and external component count to a
minimum.
Figure 1. Remote fan speed controller board STEVAL-IHM037V1
This document explains the different parts of the application.
The key features of the application are:
■Fan speed control using SW1, SW2 keys or IR remote
■Compact and cost effective capacitive power supply
■Example firmware based on RC5 protocol. Can also work with NEC and other IR protocols
■Low cost solution. Can be used for light dimmer applications with software modifications.
www.st.com

Contents UM1546
2/17 Doc ID 023229 Rev 1
Contents
1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1 Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 Safety rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 System setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 System overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1 Hardware design description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.1 STEVAL-IHM037V1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.2 RC5 protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3 RC5 frame reading mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Hardware layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3 Hardware schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1 Bill of material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Appendix A Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

UM1546 List of figures
Doc ID 023229 Rev 1 3/17
List of figures
Figure 1. Remote fan speed controller board STEVAL-IHM037V1 . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Figure 2. Wiring block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 3. RC5 bit representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 4. Example of an RC5 frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 5. RC5 idle time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 6. RC5 frame reception mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 7. Hardware layout: main board - top side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 8. Hardware layout: main board - bottom side . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 9. IR remote transmitter STEVAL-IHM037V1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 10. Remote fan speed controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Getting started UM1546
4/17 Doc ID 023229 Rev 1
1 Getting started
1.1 Package
The remote fan speed controller includes the following items:
●Hardware content:
– Demonstration board: STEVAL-IHM037V1
●Documentation:
– User manual (this document)
– Schematics, Gerber files, BOM
●Firmware:
– Pre-programmed STM8S device soldered on the demonstration board
– Object files are also available for the firmware.
1.2 Safety rules
This board can be connected to mains voltage (240 V). In the case of improper use, wrong
installation or malfunction, there is a danger of serious personal injury and damage to
property. All operations such as transport, installation and commissioning, as well as
maintenance, should be carried out only by skilled technical personnel (regional accident
prevention rules must be observed).
Danger: Due to the risk of electrical shock or death when using this
prototype on mains voltage (240 V), only skilled technical
personnel who are familiar with the installation, mounting,
commissioning and operation of power electronic systems
and have the qualifications needed to perform these
functions, may use this prototype.
Warning: The debugger tool must not be connected to 4-pin header(J3)
for SWIM interface when circuit is running on mains supply.
1.3 System setup
The remote fan speed controller board can be setup as follows:
1. Before proceeding, ensure that the mains power supply switch used during testing is
capable of disconnecting both the live and neutral terminals and it is in the off position.
Always wear safety gloves when working with mains operated circuit.
2. Connect fan/lamp live terminal to J5 of the FSC board.
3. Connect the fan neutral terminal to J7 of the FSC board.

UM1546 Getting started
Doc ID 023229 Rev 1 5/17
4. Connect the two combined neutral black wires to the mains supply neutral and, lastly,
connect J6 from the FSC board to live of the mains supply.
5. Ensure that all parts of the FSC PCB and connection wires are well isolated from any
conducting surfaces such as metal parts, etc. to avoid accidental shock hazard or
damage to the circuit.
6. Once the switch is turned on, ensure that no part of the PCB is touched using bare
hands or metallic objects.
7. The fan speed can now be changed using the IR remote transmitter unit or using the
tactile switches provided onboard. When using the onboard tactile switches, kindly
ensure that no direct body contact is made with the circuit (use safety gloves).
8. The microcontroller can be programmed over the SWIM interface using an ST-Link or
R-Link programming tool. When doing so, the circuit should be completely
disconnected from the mains supply and powered using the +5 V supply from an R-
Link or an external +5 V power supply.

System overview UM1546
6/17 Doc ID 023229 Rev 1
2 System overview
2.1 Hardware design description
Figure 2. Wiring block diagram
2.1.1 STEVAL-IHM037V1
This application uses two timers and two external interrupts, one each for decoding the IR
remote signal and the other pair for detecting the zero crossing and timing the firing angle of
the TRIAC for fan speed control. This application can be easily adapted for remote control of
light dimmers, room heaters, water heaters, window pane/curtain control, home automation
and other similar applications. The TRIAC used in this design is rated at 4 A current. This
may be changed to suit the application requirements while keeping everything else the
same. The same MCU can even control multiple TRIACs depending on the application.
2.1.2 RC5 protocol
RC protocol basics:
The RC5 code is a 14-bit word, it uses bi-phase modulation (also called Manchester coding)
of a 36 kHz IR carrier frequency. All bits have an equal length of 1.778 ms, with half of the bit
time filled with a burst of the 36 kHz carrier and the other half being idle. A logical zero is
represented by a burst in the first half of the bit time. A logical one is represented by a burst
in the second half of the bit time (refer to Figure 1). The duty cycle of the 36 kHz carrier
frequency is 33% or 25%. This reduces power consumption for the IR LED on the
transmitter side and also allows the LED to operate at a higher peak current for a longer
communication range.

UM1546 System overview
Doc ID 023229 Rev 1 7/17
Figure 3. RC5 bit representation
The RC5 frame can generate 2048 (32x64) different commands organized in 32 groups,
each group has 64 different commands. An RC5 frame contains the following fields (an
example of an RC5 frame is shown in Figure 2):
●Start bit (S): 1 bit length, always logic 1.
●Field bit (F): 1 bit length, which denotes whether the command sent is in the lower field
(logic 1 = 0 to 63 decimal) or the upper field (logic 0 = 64 to 127 decimal).
●Control bit or Toggle bit (C): 1 bit length, which toggles each time a button is pressed.
This allows the receiving device to distinguish between two successive button presses
(such as “1”, “1” for “11”).
●Address: 5-bit length that selects one of 32 possible systems.
●Command: 6-bit length, that (in conjunction with the field bit) represents one of the 128
possible RC-5 commands.
Figure 4. Example of an RC5 frame
To avoid frame collisions, an idle time is inserted between two frames with a specific width
(see Figure 3).
The idle time is defined as 50 bits wide. So the periodicity of a frame is 64 x 1 bit width:
64 x 1.778 = 113.792 ms (exactly 113.788 ms).
AM12357v1
Modulated RC5 bit
Demodulated RC5 bit
Logic ‘0’ Logic ‘1’
889 µs889 µs889 µs889 µs
AM12343v1
Address = 4
Command = 39
Field bit = 1 (Command 0-63)
Control bit = 0
SF 5 x Address bits6 x Command bits
11 1 1 1
C

System overview UM1546
8/17 Doc ID 023229 Rev 1
Figure 5. RC5 idle time
2.1.3 RC5 frame reading mechanism
RC5 decoding algorithm features:
●Adaptive timing takes care of variations in transmitter bit period within the standard
range specified in Ta b l e 1 .
●Algorithm synchronizes sampling time after every bit to ensure robust decoding
performance.
●Uses one external interrupt and one hardware timer to efficiently decode received data
on the fly.
The RC5 decoded data has the inherent property of changing its logic state at the middle of
every bit transmitted, as it is Manchester format. This state change can be used to
synchronize the sampling of the RC5 data output line connected to the microcontroller for
robust decoding performance irrespective of timing variations at the receiver, as well as the
transmitter side. Figure 4 highlights the decoding algorithm used in this application.
Table 1. RC5 timings
Description Min. Typical Max. Units
RC5 half bit period 640 899 1140 µs
RC5 full bit period 1340 1778 2220 µs
RC5 message
time 23.644 24.889 26.133 ms
RC5 message
repetition time 108.089 113.778 119.467 ms
Carrier pulse bit
time 27.233 27.778 28.345 µs
AM12344v1
14 bits
Frame 1
14 bits
Frame 2
50 bits
Idle time
64 bits= 113.788 ms

UM1546 System overview
Doc ID 023229 Rev 1 9/17
Figure 6. RC5 frame reception mechanism
The decoding algorithm uses a small finite state machine as follows:
●State 1: Enable EXT interrupt and start timer with ARR value for 3.5 ms overflow time.
Go to State 2 when timer overflow occurs.
●State 2: Wait for first EXT interrupt, when it occurs, initialize and start timer and go to
State 3.
●State 3: Wait for second EXT interrupt. When it occurs, stop timer and validate ½ bit
time period. If valid, use it to calculate ¾ bit time and go to State 4, or else reset state to
State 1.
●State 4: Wait for EXT interrupt. When it occurs (red downward arrow), disable EXT
interrupt and start timer with ARR set to ¾ bit time. Go to State 5.
●State 5: When timer overflow interrupt occurs, sample the data line (green upward
arrow) and push its value into the RC5 data sampling variable. If all 13 bits are sampled
(including the last idle state), give the valid decoded output and go back to State 1 for
the next detection cycle, or else re-enable EXT interrupt and go to State 4.
The algorithm synchronizes the first half midpoint sampling location (green upward arrow) of
each bit with the logic transition point of the previous bit (red downward arrow). The field bit
is not decoded in the existing algorithm but this can be easily incorporated with minor
modifications in the firmware.
2.2 Hardware layout
The STEVAL-IHM037V1 component layout for top and bottom layers is shown below in
Figure 6 and 7respectively. It helps the user to locate different components / sections on the
board.
AM12345v1
SFC01100011001
RC5 frame to
be transmitted
IR remote control
output (IR LED)
EXT Interrupt
Dataline
sampling
¾ bit time delay
from EXT interrupt
Decoded output of
IR receiver module
½ bit time

System overview UM1546
10/17 Doc ID 023229 Rev 1
Figure 7. Hardware layout: main board - top side
Figure 8. Hardware layout: main board - bottom side

UM1546 Hardware schematics
Doc ID 023229 Rev 1 11/17
3 Hardware schematics
Figure 9. IR remote transmitter STEVAL-IHM037V1
!-V
1567
9
6:,0
*1'
9 9
108&3
61
%08/
-
&21
-
&21
6:
6:3$'6
6:
6:3$'6
6:
6:3$'6
6:
6:3$'6
8
670/)3
8
670/)3
%7
&5
%7
&5
&
Q)
&
'
,5/('
'
,5/('
6:
6:3$'6
6:
6:3$'6
4
675
4
675
5
N
5
N
5 (5 (

Hardware schematics UM1546
12/17 Doc ID 023229 Rev 1
Figure 10. Remote fan speed controller
!-V
9
9
9
9
GDWD
NH\
9
9
VZLP
NH\
NH\
VZLP
UHVHW
GDWD
9
NH\
UHVHW
&
Q)
&
Q)
8
6706)3
8
6706)3
3'
3'
3'
3'
3'
3'
1567
26&,1
RVFRXW
966
9&$3
9''
3$
3%
3%
3&
3&
3&
3&
3&
&
Q)
&
Q)
&
S)
&
S)
5. 5.
-
7623
-
7623
5
(
5
(
6:
.H\
6:
.H\
''
&
Q)
&
Q)
-
9(;7
-
9(;7
5
(:
5
(:
6:
6:7$&76367
6:
6:7$&76367
&
X)9
&
X)9
5
RKP
5
RKP
-
/2$'
-
/2$'
&
Q);
&
Q);
-
VZLPFRQQHFWRU
-
VZLPFRQQHFWRU
-
175/
-
175/
5
.
5
.
5
.
5
.
&
Q)
&
Q)
5
.
5
.
-
/,9(
-
/,9(
&
Q)
&
Q)
5
.:
5
.:
'
9
'
9
4
675
4
675
77
75,$&
77
75,$&

UM1546 Hardware schematics
Doc ID 023229 Rev 1 13/17
3.1 Bill of material
Table 2. BOM
Category Reference
designator
Component
description Package Manufacturer
Manufacturer’s
ordering code /
orderable part
number
Supplier Supplier ordering code
Document / project reference: BOM for the AC Fan speed controller/dimmer
ST devices
U1 STM8S003F3 value
line series MCU TSSOP-20 STMicroelectronics STM8S003F3P6
Q1 Logic level TRIAC TO-220AB STMicroelectronics T435-600T
Q2 NPN Transistor SOT-23 STMicroelectronics 2STR1160
Other
devices
TSOP IR receiver 38 kHZ,
DOME AXIAL TSOP 2.54 mm Vishay TSOP34838 Digi-Key 751-1386-5-ND
D1 Zener diode 5.6 V/
0.5 W SOD123 Any DDZ5V6B-7 Digi-Key DDZ5V6BDICT-ND
D2 LL4148 SOD80 Any LLN4148 Digi-Key LL4148FSCT-ND
Capacitors
C1 470 µF/16 V
Electrolytic
Radial 8 mm
diameter /
3.5 mm Pitch
Any Digi-Key P5141-ND
C2, C6,C7,C8 100 nF ceramic SMD0805 Any
C4(1) 330 nF or 680 nF/X2
rated film capacitor 22.5 mm Pitch Vishay BFC238312334 or
BFC233920684 Digi-Key 2222 383 12334-ND or
BC2591-ND
C5 100 pF ceramic SMD0805 Any
C9 470 nF ceramic SMD0805 Any
Resistors R1,R5 100 ΩSMD0805 Any
R2 82, 2 W Leaded Yageo RSF200JB-82R Digi-Key 82W-2-ND

Hardware schematics UM1546
14/17 Doc ID 023229 Rev 1
Resistors
R3 330 kΩ/0.5 W Leaded Any Digi-Key PPC330KW-1CT-ND
R4,R6 4.7 kΩSMD0805 Any
R7 100 kΩSMD0805 Any
R8 2.7 kΩSMD0805 Any
Switches SW1, SW2 Push button switch
right angle
Switch tactile
SPST-NO 0.05
A 12 V
TT Electronics SWT6-R6K Digi-Key 987-1385-ND
Document / project reference: BOM for the IR remote transmitter
ST devices U1 STM8L101 8-bit low
power MCU TSSOP-20 STMicroelectronics STM8L101F2P6
Q1 PNP transistor SOT-23 STMicroelectronics 2STR2260
Other
devices
IRLED 940 nm IR LED 3 mm through
hole Vishay TSAL4400 Digi-Key 751-1201-ND
BT1 3 V CR2032 battery
retainer
Memory protection
devices BK-833 Digi-Key BHSD-2032-SMCT-ND
Capacitors C1 100 nF ceramic SMD0805 Any
Resistors R1 22 ΩSMD0805 Any
Switches SW1, SW2,
SW3(2)
Carbon contact push
button switch on PCB
ENIG gold
plated carbon
contact switch
(PCB)
3
Enclosure N/A BOSS 3 button key
FOB enclosure Enclosure Boss Enclosures 2955-20R-3 Farnell 1264656
1. C4 X2 rating is important for reliable operation. A DC rated capacitor (even rated at 1000V DC) will fail over time as it is not designed to withstand the stress conditions
present on AC supply lines. Use 330 nF for 230 V AC nominal supply voltage and increase to 680 nF for 110V AC supply.
2. SW1, SW2, SW3 are carbon contact footprints on PCB while the actual carbon contact is integrated into the enclosure. Alternately 2 pin tactile SMD switch from
MULTICOMP part no. DTSM-32S-B can be used on the same footprint.
Table 2. BOM (continued)
Category Reference
designator
Component
description Package Manufacturer
Manufacturer’s
ordering code /
orderable part
number
Supplier Supplier ordering code

UM1546 Definitions
Doc ID 023229 Rev 1 15/17
Appendix A Definitions
Table 3. Acronym definitions
Acronym Definition
FSC Fan speed controller
ARR Auto reload register
MCU Microcontroller unit

Revision history UM1546
16/17 Doc ID 023229 Rev 1
Revision history
Table 4. Document revision history
Date Revision Changes
12-Sep-2012 1 Initial release.

UM1546
Doc ID 023229 Rev 1 17/17
Please Read Carefully:
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY TWO AUTHORIZED ST REPRESENTATIVES, ST PRODUCTS ARE NOT
RECOMMENDED, AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING
APPLICATIONS, NOR IN PRODUCTS OR SYSTEMS WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY,
DEATH, OR SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE. ST PRODUCTS WHICH ARE NOT SPECIFIED AS "AUTOMOTIVE
GRADE" MAY ONLY BE USED IN AUTOMOTIVE APPLICATIONS AT USER’S OWN RISK.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.
© 2012 STMicroelectronics - All rights reserved
STMicroelectronics group of companies
Australia - Belgium - Brazil - Canada - China - Czech Republic - Finland - France - Germany - Hong Kong - India - Israel - Italy - Japan -
Malaysia - Malta - Morocco - Philippines - Singapore - Spain - Sweden - Switzerland - United Kingdom - United States of America
www.st.com
Table of contents
Other ST Controllers manuals
Popular Controllers manuals by other brands

Emerson
Emerson Bettis EHO Installation and operation manual

Danfoss
Danfoss EKC 347 manual

Mitsubishi Electric
Mitsubishi Electric QJ71C24N user manual

MERRICK
MERRICK MC3 Hardware manual

LOVATO ELECTRIC
LOVATO ELECTRIC RGK800SA instruction manual

Jäger Direkt
Jäger Direkt OPUS-FUNK plus Installation and operating instructions