0% found this document useful (0 votes)
4 views4 pages

Remote Controlled Switch

The document describes a 9-channel relay switcher board designed for local and remote control of multiple devices, utilizing a microcontroller (PIC18F45K22) to manage the relays. It outlines the circuit design, components used, and programming details, emphasizing the ease of use and functionality provided by modern integrated circuits. The project includes a keypad for manual control and supports USB communication for remote operation, making it suitable for various automation applications.

Uploaded by

howied231
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Remote Controlled Switch

The document describes a 9-channel relay switcher board designed for local and remote control of multiple devices, utilizing a microcontroller (PIC18F45K22) to manage the relays. It outlines the circuit design, components used, and programming details, emphasizing the ease of use and functionality provided by modern integrated circuits. The project includes a keypad for manual control and supports USB communication for remote operation, making it suitable for various automation applications.

Uploaded by

howied231
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

LABS PROJECT

9 -Channel Relay
Switcher Board
with local and remote control

By Sunil Malekar (India)


and Clemens Valens (Elektor Labs)

Many situations require switching on or off multiple devices individually from


a central place like a control room. Installing a switch for every individual device on a control desk looks like an
easy solution but does not allow for remote- or computer control. The circuit presented here adds these features.

Relays are excellent devices for automa- sistors. Microcontrollers are program- Simplest schematic
tion of switching operations. Controlled mable and have everything on board The schematic of the project is shown
by an external voltage they can switch to talk to other devices like computers in Figure 1. As you may have guessed,
all sorts of loads in much same way as and networks. That’s about all that is the microcontroller is the large rectangle
a mechanical switch. required to get our project going; add labelled IC2. It is a type PIC18F45K22
Relays are easily controlled with a micro- bells and whistles like a keypad and a which was mainly chosen for its impres-
controller and the help of driver tran- display to taste. sive number of I/O port lines (a whopping

80 May & June 2019 [Link]


+VE IC1 +5V +VE

+5V +5V MC7805 K3


K2 Re1 1
D1 R1
1 RN1 6 x 10k 2
2 R6 3

330
+5V C7 C8 1N4007
3 K1
C1 C2 C3 C4
10

4 LED1
100n 100n K4
5 220 100n 100n 100 Re2 1
6 50V 50V 2
11 32 12V
3
2
1 RA0/AN0
MCLR/VPP 3
RA1/AN1 K5
IC2 4 1
RA2/AN2/VREF- Re3
40 5 2
RB7/PGD RA3/AN3/VREF+
39 6 3
RB6/PGC RA4/T0CKI
38 7
RB5 RA5/AN4/SS
37 14
RB4 RA6/OSC2 K6
36 13 Re4 1
RB3/PGM RA7/OSC1
35 2
RB2 8 1 18
S9 S6 S3 34 RE0/RD/AN5 I1 O1 3
RB1 9 2 17
33 RE1/WR/AN6 I2 O2
RB0/INT 10 3 16
RE2/CS/AN7 I3 O3
4 IC3 15 K7
S8 S5 S2 PIC18F45K22-E/P I4 O4 1
Re5
30 15 5 14
RD7/PSP7 RC0/T1OSO/T1CKI I5 O5 2
29 16 6 ULN2803 13
RD6/PSP6 RC1/T1OSI/CCP2 I6 O6 3
28 17 7 12
S7 S4 S1 RD5/PSP5 RC2/CCP1 I7 O7
27 18 8 11
RD4/PSP4 RC3/SCK/SCL I8 O8
22 23 9 10 K8
RD3/PSP3 RC4/SDI/SDA GND CD+ Re6 1
21 24
RD2/PSP2 RC5/SDO 2
20 25
+5V RD1/PSP1 RC6/TX/CK 3
19 26
D2 RD0/PSP0 RC7/RX/DT
USB
K9
1 18 BAT43 Re7 1
CBUS4 +5V 12 31
2 17 2
CBUS3 VCCIO C5
3 16 3
CBUS2 MOD1 +3V3
4 15
CBUS1 GND 100n R5 T1
5 14 R2
CBUS0 CTS K10
4 7
6 13 4k7 Re8 1
RESET RI
7 12 R3 2
DCD RXD 1k BC547
8
DSR
BOB-FT232R TXD 11 R4 +5V 3
1k
9 10
DTR RTS
+5V
VCCIO

K11
GND
CTS

4 5 6 7 8 9 10 11 12 13 14 15 16
RX
TX

D3 Re9 1
+5V
R/W

D0
D1
D2
D3
D4
D5
D6
D7
RS

A
K
E

2 2
19 20 21 22 23
VDD

C6 1N4007 3
P1 LCD1 4 x 20
10k T2
100n R7
3 1
VO 4k7
VSS

BC547
190027-003

Figure 1: Thanks to the power and functionality of modern integrated circuits, microcontrollers in particular, relatively few parts are needed to create a
useful device.

project information
36) not forgetting low cost and 40-pin single sided (!). Nine relays can be con-
PIC18F45K22
DIP (!) package. The fact that it sports trolled with nine pushbuttons arranged
many powerful capabilities we have no in a square 3 × 3 matrix. It looks nice, remote control
need for here is, ermm, the fate of many and it's another good reason to have switching
of today’s microcontrollers. Not unlike nine relays.
humans, they use only a good 10% of The relays are driven by transistors. Æ entry level
their brain's capacities. Commonly used relay driver ICs like intermediate level
IC3 have eight transistors inside. That's expert level
Huh, nine channels? good for eight relays Re1-Re8, and so we
The MCU controls nine relays, an unusual added one transistor, T2, to control Re9.
number in our power-of-two driven soci- Diode D3 protects T2 by eliminating the 2 hours approx.
ety. The reason is mainly practical. As back emf produced by Re9’s coil when
you can see from the schematic and the it is switched off. IC3 includes similar
PCB layout, the way the MCU is con- diodes for every output, which is why soldering iron,
nected simplifies PCB routing. The relays they are not visible in the schematic. PIC programmer
and display are connected to one side of Oops, almost forgot, the relays used here
the MCU, while the keypad and PC inter- are specified for switching resistive loads
face are connected to the other. Nine I/O up to 1,200 watts AC (240 watts DC).
ports remained available for controlling When using a non-resistive load like a £45 / €50 / $55 approx.
relays, and so we used them all, also motor, check your relay's datasheets to
resulting in a PCB that could be kept see if it is suitable.

[Link] May & June 2019 81


normally-open (NO) and normally-closed
(NC) contacts (Figure 2), loads that are
supposed to be active 50% of the time
or more should be connected to NC con-
tacts to save a bit of energy.
IC1 lowers the 12-volt input voltage to
5 V for the rest of the circuit. IC1 has
to cope with a voltage drop of almost
7 volts and because of that it may get
quite warm. This is why heatsinking it is
recommended.
LED1 is a power-on indicator.

In-circuit serial programming


Last but not least is K2, needed to pro-
gram the firmware into the MCU. This
connector follows the standard Micro-
Figure 2: Each of the nine relays has a normally-open (NO) and a normally-closed (NC) contact chip ICSP pinout so connecting a PIC
made accessible through a 3-pin terminal. compatible programmer (PICkit/ICD)
should work.

Software
Display footprint, making them easy and comfy A simple device like this relay board
Display device LCD1 is a standard to push. requires simple software to make it work.
alphanumerical type with four lines of The software was written in plain C and
20 characters each (commonly known USB serial port can be compiled with Microchip’s free
as type “4x20”). It has a backlight LED Since the circuit is built using through- MPLAB X. Porting the code to other com-
built in. driven by T1 here because hole technology (THT) parts only, we pilers should not be too difficult.
the MCU cannot provide the required used a USB-to-serial converter mod- The MCU runs at 16 MHz from its internal
amount of current. ule as communication interface. This oscillator and that explains the absence
The LCD is controlled in simplified 4-bit avoids having to solder tiny SMT parts. of a quartz crystal in the schematic).
write-only mode, which saves on pins The USB module is a veteran [1] hav- After initialization of the relays (all Off)
and PCB traces. As a downside, the MCU ing proved its usefulness many times. and the display, a timer is started and the
then has no way to find out if the display Remember that this module has a serial port is fired up. Then the program
is doing what it is supposed to do. How- jumper (JP1) to set the signal level (5 V starts waiting for something to happen
ever, as long as the display is allowed or 3.3 V). Make sure to hard-wire it in — either a key press or the a command
enough time to process the commands the ‘5V’ position using a drop of solder. coming in on the serial port. As soon as
sent to it, this is harmless. Diode D2 prevents connecting the USB a command is received on the serial port
When powering the board for the first port’s 5 V line to the circuit’s 5 V power or through a key press, the MCU starts
time, do not forget to adjust the LCD supply. The other way around does to execute the command.
contrast on preset P1. If you do forget work, hence the USB power pin can be Keyboard scanning works as follows. Only
to do this, the text on the display may left unconnected if convenient. In that one row (as drawn in Figure 1) is Low at
not be visible. case the circuit will not load the host’s a time. The MCU reads the level of the
USB port. columns and if any one of them is Low
3-by-3 Keypad the corresponding action is taken. This
Pushbuttons are available to control the Power supply means that when row 1 is pulled Low,
relays individually and in a convenient Because the relays are 12-volt types, only keys S1, S4 and S7 will be read.
way. With the switches arranged in a the input voltage — to be connected to Row 2 enables keys S2, S5 and S8, and
3 × 3 matrix, only six wires are needed K1 — is forcibly 12 VDC. The maximum row 3 is for S3, S6 and S9.
to hook them up to the MCU. Resistor current (all relays on, backlight on, MCU
network RN1 provides pull-up resistors running full throttle) is about 500 mA, $RLYxO[N|F]…&
so idle levels are well defined. meaning that a 12 V, 6 VA AC-to-DC … is the syntax of serial port relay com-
Note that the pushbuttons used are of 'wallwart' should be enough to power mands the MCU can handle. This cryp-
the robust type with a 12 × 12 mm PCB the board. Because the relays provide tic code means that a message to the

Weblinks
[1] FT232R USB/serial bridge: [Link]/110553
[2] Project page at Elektor Labs: [Link]/1778

82 May & June 2019 [Link]


board should start with the character ‘$’
and end with an ‘&’. The part ‘RLYxO’
in the above syntax indicates the relay component list
to switch, where ‘x’ is a number in the
range 1 to 9. Here we discover yet
another advantage of having no more
than nine relays: the length of the useful
part of the message is always the same.
The relay state is encoded as either ‘N’
(On) or ‘F’ (Off). Examples:

• $RLY3ON& — switch on relay #3


• $RLY7OF& — switch off relay #7
• $RLY4OFF& — switch off relay #4

Note the superfluous ‘F’ in the last exam-


ple. It is optional only serves to make
the command easier to understand for
humans.
Reception of a relay control command
is acknowledged with a status mes-
sage about the actual state of the relay
(RELAYx SWITCHED [ON|OFF]). When the
returned actual state does not corre-
spond to the requested state, there may
be a problem to fix…
To request the states of all relays in one
go, issue the command $STATE&.

Help!
When the MCU receives the command
$H& it will return the help screen with a
list of all the available commands.

Construction
Building the relay board is rather easy
as there are not too many parts. Highly
developed soldering skills are not BoB1 to ground control respond to the commands you type in the
required. Start by mounting 2-terminal Plug BoB1 on the board, and connect it terminal. If it does, you are all set; if it
parts like resistors and diodes and then to a free USB port on a PC. The latter doesn’t, you have some debugging to do.
continue with increasingly taller parts. should detect it as a serial port. Launch Happy switching!
Do observe the polarity of polarized parts a terminal emulator program and config-
like diodes and electrolytic capacitors. ure it for 9600 baud, eight data bits, no
Before plugging in the ICs, connect the parity and one stop bit (9600n81). When
12 V input voltage and check with a volt- the relay board is powered, it should now
meter that the 5 V power supply line is
indeed at 5 V.

Disconnect the power to the board and @ [Link]


mount the remaining ICs (note orienta-
ª9-Channel Relay Switcher Board - kit of parts
tion!). Connect a compatible ICSP pro-
[Link]/relay-board-kit
grammer and power up the board. Now
you should be able to load the HEX file ª9-Channel Relay Switcher Board - bare PCB
[Link]/relay-board-pcb
(to be downloaded from [1]) into the
MCU. When done successfully, switch off ª9-Channel Relay Switcher Board - preprogrammed microcontroller (130549-41)
[Link]/relay-board-mc
the power and mount the LCD. Switching
the board back on again should result in ªLCD 4x20 characters blue backlight
[Link]/lcd-blue
a welcome message on the display. You
may have to adjust P1 to make it visible. ªFT232R USB/Serial Bridge/BoB
Pressing pushbuttons should make the [Link]/usb-serial
corresponding relays click.

[Link] May & June 2019 83

You might also like