GSM REMOTE CONTROL - ElettronicaIn

GSM REMOTE CONTROL - ElettronicaIn GSM REMOTE CONTROL - ElettronicaIn

elettronicain.it
from elettronicain.it More from this publisher
02.04.2013 Views

Hi-tech GSM REMOTE CONTROL MODULAR AND LOW-COST N owadays, creating a remote control is much simpler and safer than it used to be, even if it is to be used from the other side of the world; what made this possible was the advent of cell phones and the availability of low-cost GSM/GPRS modules that could be easily integrated in standalone solutions, capable of handling both calls and A modular solution allowing for the use of a single circuit for numerous functions, such as gate opening, bidirectional telecontrol, and many others. It adopts a newly-conceived low-cost GSM/GPRS module. by BORIS LANDONI SMSs. The use of SMSs allows one to know the exact output of the commands that have been given, since it is enough to set sent messages to confirm a relay commutation in order to be sure that a given command was properly executed. Precisely because of the possibilities offered by a cell-phone based remote control, and encouraged by popular demand, Elettronica In ~ Aprile 2010 51

Hi-tech<br />

<strong>GSM</strong> <strong>REMOTE</strong> <strong>CONTROL</strong><br />

MODULAR AND LOW-COST<br />

N<br />

owadays, creating a remote control is much<br />

simpler and safer than it used to be, even if<br />

it is to be used from the other side of the world;<br />

what made this possible was the advent of cell<br />

phones and the availability of low-cost <strong>GSM</strong>/GPRS<br />

modules that could be easily integrated in standalone<br />

solutions, capable of handling both calls and<br />

A modular solution<br />

allowing for the use<br />

of a single circuit for<br />

numerous functions,<br />

such as gate opening,<br />

bidirectional telecontrol,<br />

and many others. It<br />

adopts a newly-conceived<br />

low-cost <strong>GSM</strong>/GPRS module.<br />

by BORIS LANDONI<br />

SMSs. The use of SMSs allows one to know the<br />

exact output of the commands that have been given,<br />

since it is enough to set sent messages to confirm a<br />

relay commutation in order to be sure that a given<br />

command was properly executed. Precisely because<br />

of the possibilities offered by a cell-phone based<br />

remote control, and encouraged by popular demand,<br />

Elettronica In ~ Aprile 2010 51


[Complete ELECTRIC scheme]<br />

54 Aprile 2010 ~ Elettronica In


identify the bi-tones involved in<br />

the phone selection found within<br />

modern telecommunication<br />

systems –bi-tones which every<br />

phone emits and sends out on<br />

phone lines when its keyboard<br />

keys are pressed. The identifier is<br />

necessary in order for the DTMF<br />

functionality to work.<br />

Having said that, let’s take a<br />

better look at the electric scheme:<br />

power is supplied by continuous<br />

voltage, not always stabilized (applied<br />

to PWR + and -) at a value<br />

between 5 and 32 V; such voltage<br />

is filtered at the bottom by the<br />

diode protecting against polarity<br />

inversion (D1) through condensers<br />

C1 and C2. Fuse F1 enables us<br />

to protect both the circuit and the<br />

power source in case of a short<br />

circuit in the integrated regulator<br />

discussed below, which is necessary<br />

to obtain the 4 volts needed<br />

for the rest of the circuit to work.<br />

The switching regulator is based<br />

on a MC34063 chip, utilized in<br />

the classic configuration of series<br />

PWM regulators charged by<br />

inductance, whose output voltage<br />

depends on the energy stored in<br />

L1; the regulator is stabilized by<br />

the component demoted from<br />

resistive divider R2/R3, which is<br />

needed to set at 4 V the component<br />

leveled at the top of both C4<br />

e C5. The 4 volts at the bottom of<br />

the abovementioned condensers<br />

are sufficiently filtered by other<br />

condensers placed on the power<br />

lines of the microcontroller and of<br />

the <strong>GSM</strong> module; which presents,<br />

during transmission, absorption<br />

peaks compensated for by C7, C8,<br />

C13, C14, C15 e C16, thus avoiding<br />

that an impulsive current<br />

request may cause the microcontroller<br />

to be disturbed.<br />

The microcontroller used to<br />

handle the whole system is a<br />

powerful PIC18F46K20-I/PT by<br />

Microchip, which we use in its<br />

configuration with an internal<br />

clock oscillator; both the scheme<br />

and in the printed circuit are nevertheless<br />

equipped with external<br />

quartz, which we included for<br />

those who may want to modify<br />

the firmware and develop specific<br />

applications requiring an external<br />

oscillator.<br />

Once the I/O lines have been<br />

initialized, the microcontroller<br />

verifies the logical state of the<br />

opto-isolated inputs at voltage<br />

level (RB4 and RB5) as well as<br />

that of lines RC4, RC5, RD0,<br />

RD3, RX, which are needed to<br />

receive the main notifications<br />

from the cellular module; more<br />

specifically, RD3 is used to detect<br />

incoming calls (it interfaces with<br />

RI of the cellular module), while<br />

RC4 controls the <strong>GSM</strong>’s reception<br />

led , whose output (dubbed<br />

STATLED) pulsates at a frequency<br />

of 1 Hz when the module<br />

is searching for the radio-mobile<br />

network, and supplies impulses<br />

at logical zero, lasting 0.5 seconds<br />

and followed by a 2-second pause,<br />

when the module has grasped<br />

the signal. The frequency and<br />

duration of the impulses enable<br />

the PIC to understand the<br />

conditions of the radio-mobile<br />

network range and to behave<br />

accordingly; for example, if the<br />

opto-isolated input goes off and<br />

it needs, therefore, to send SMSs<br />

or make calls, but detects that the<br />

cellular module has no reception,<br />

it waits for the Telit module to get<br />

reconnected to the <strong>GSM</strong>/GPRS<br />

network before making any calls.<br />

The attempt to make calls or send<br />

SMSs is repeated only three times,<br />

after which the device gives up.<br />

The microcontroller contains<br />

a UART accessible via pins 44<br />

(transmission) and 1 (reception)<br />

which it uses in order to communicate<br />

with the cell phone; more<br />

precisely, through the first pin<br />

(TX), it cyclically questions the<br />

module in order to check whether<br />

any SMSs have been received,<br />

whereas both TX and RX are<br />

used to communicate with the<br />

<strong>GSM</strong> module when making calls<br />

and receiving or sending messages.<br />

Regarding the UART, it is<br />

important to note that the following<br />

control signals are used: CTS<br />

(Clear To Send), RTS (Request<br />

To Send) and DCD (Data Carrier<br />

Detect), which correspond to<br />

those of the cellular module being<br />

used. They complete the set of I/<br />

Os destined to the cell phone, the<br />

RC5 and RD0 lines: the former<br />

controls the turning on and off<br />

of the <strong>GSM</strong> (though a transistor<br />

placed in the small board of the<br />

cell phone), while the latter takes<br />

care of resetting the cell phone.<br />

The button for locally handling<br />

this device’s working modality<br />

is read through line RA3, configured<br />

as input and equipped with<br />

an external pull-up resistor (R11) –<br />

and therefore active at a low level.<br />

Inputs are read through lines<br />

RB4 and RB5, both of which are<br />

configured as input and equipped<br />

with an internal pull-up; each one<br />

of them reads the state of the output<br />

transistor of the corresponding<br />

photocoupler (the optos used<br />

here are TLP181). Each of the two<br />

available inputs (IN1 and IN2) is<br />

active when under a voltage between<br />

3 and 30 V. When a 3-volt<br />

voltage (at a minimum) is applied<br />

to input IN1, the photocoupler’s<br />

LED is switched on and the output<br />

phototransitor is in conduction<br />

state; therefore, the collector<br />

(pin 5) is at about zero volt during<br />

I/O configuration, due to the<br />

fall on the resistor of the internal<br />

pull-up that was configured. If<br />

the input is not polarized, the<br />

opto-isolator gets inhibited and<br />

its pin 4 shows a high level.<br />

As for the relays, they are controlled<br />

by the microcontroller’s RC0<br />

and RE2 lines, through two NPN<br />

transistors driven by current am-<br />

Elettronica In ~ Aprile 2010 55


[Base unit: ASSEMBLING]<br />

plifiers; line RE2 controls transistor<br />

T1, while line RC0 controls<br />

transistor T2. A high logical state<br />

causes the transistor to saturate,<br />

thus determining the amount<br />

of current flowing in the coil of<br />

the corresponding relay. Each<br />

instance of activation is signaled<br />

with a LED, powered along with<br />

the coil. In order to protect the<br />

transistors’ collector junction as it<br />

goes from saturation to inhibition,<br />

56 Aprile 2010 ~ Elettronica In<br />

when the relay’s coil inductance<br />

generates peak inverse voltage,<br />

we connected a diode parallel to<br />

the coil, and such diode eliminates<br />

unwanted impulses. The<br />

entire relay exchange is available<br />

so as to allow for the handling<br />

of circuits requiring a normally<br />

closed contact or a normally open<br />

one. Still regarding the relay, we<br />

should note that, although it is a<br />

5-volt-coil type, in our circuit it<br />

Parts List:<br />

R1: 0,1 ohm 1W (1206)<br />

R2: 2,2 kohm (0805)<br />

R3: 1 kohm (0805)<br />

R4: 100 kohm (0805)<br />

R5: 4,7 kohm (0805)<br />

R6: 4,7 kohm (0805)<br />

R7: 330 ohm (0805)<br />

R8: 330 ohm (0805)<br />

R9: 4,7 kohm (0805)<br />

R10: 10 kohm (0805)<br />

R11: 4,7 kohm (0805)<br />

R12: 10 kohm (0805)<br />

R13: 330 ohm (0805)<br />

R14: 330 ohm (0805)<br />

R15: 1,5 kohm (0805)<br />

R16: 1,5 kohm (0805)<br />

R17: 330 ohm (0805)<br />

R18: 4,7 kohm (0805)<br />

R19: 4,7 kohm (0805)<br />

R20: 1 kohm (0805)<br />

R21: 2,2 kohm (0805)<br />

R22: 4,7 kohm (0805)<br />

R23: 330 kohm (0805)<br />

R24: 39 kohm (0805)<br />

R25: 56 kohm (0805)<br />

R26: 100 kohm (0805)<br />

R27: 100 kohm (0805)<br />

C1: 100 nF multilayer (0805)<br />

C2: 1000 µF 25 VL electrolytic<br />

C3: 100 pF ceramic (0805)<br />

C4: 100 nF multilayer (0805)<br />

C5: 100 µF 16 VL electrolytic<br />

C6: 100 nF multilayer (0805)<br />

C7: 100 nF multilayer (0805)<br />

C8: 470 µF 6,3 VL tantalum (CASE-D)<br />

C9: unused<br />

C10: unused<br />

C11: 100 µF 16 VL electrolytic<br />

C12: 100 µF 16 VL electrolytic<br />

C13: 100 nF multilayer (0805)<br />

C14: 470 µF 6,3 VL tantalum (CASE-D)<br />

works on just 4 volts; this is possible<br />

because the model we chose<br />

can prompt relay exchange even<br />

at less than 3.5 volts.<br />

The room temperature is detected<br />

by the microcontroller with the<br />

aid of an extremely accurate<br />

probe DS1820 produced by<br />

Dallas Semiconductor, which is<br />

capable of taking temperatures<br />

in the range of -5÷150 °C with an<br />

accuracy of just ± 0,5 °C (in field


C15: 470 µF 6,3 VL tantalum (CASE-D)<br />

C16: 470 µF 6,3 VL tantalum (CASE-D)<br />

C17: 10 pF ceramic (0805)<br />

C18: 100 nF multilayer (0805)<br />

C19: 10 pF ceramic (0805)<br />

C20: 100 nF multilayer (0805)<br />

Q1: (see text)<br />

Q2: quarzo 3,579545 MHz (HC49/4H SMX)<br />

U1: MC34063AD<br />

U2: DS18B20+<br />

U3: 24FC256-SN<br />

U4: TLP181<br />

U5: TLP181<br />

U6: PIC18F46K20-I/PT (MF857)<br />

U7: MT88L70AS<br />

D1: 1N4007<br />

D2: 1N5819<br />

D3: 1N4007<br />

D4: 1N4007<br />

T1: BC817<br />

T2: BC817<br />

LD1: LED 3 mm red<br />

LD2: LED 3 mm red<br />

LD3: LED 3 mm yellow<br />

LD4: LED 3 mm yellow<br />

LD5: LED 3 mm green<br />

L1: Inductor coil 20 µH<br />

RL1: Relay 5V 1 one way<br />

RL2: Relay 5V 1 one way<br />

P1: Microswitch<br />

F1: Fast fuse 2 A (1206)<br />

Varie:<br />

- Screw connector 2 poles (2 pz.)<br />

- Screw connector 3 poles (2 pz.)<br />

- DC plug<br />

- Male strip 6 poles<br />

- Female strip 3 poles<br />

- Female strip 16 poles<br />

- Female strip 4 poles 90°<br />

- PCB<br />

-10÷85 °C), and then of digitizing<br />

and making them available on a<br />

unidirectional serial line connected<br />

to the microcontroller’s RC0<br />

pin. This probe communicates<br />

using protocol One-wire, which<br />

allows for bidirectional dialogue<br />

on a single thread; for this to be<br />

possible, pull-up R19’s resistance<br />

must be present.<br />

The PIC is programmed in-circuit,<br />

through the ICSP connector,<br />

which is attached to lines /MCLR,<br />

PGU and PGC; the microcontroller’s<br />

power and mass are also<br />

connected to the ICSP. But we<br />

didn’t think that was enough, so<br />

we included a serial communication<br />

interface enabling users to<br />

program data related to the various<br />

functions (e.g., list of phone<br />

numbers, handling of input<br />

levels, text of SMSs sent by the<br />

circuit following commands, etc.)<br />

through a PC: this allows users<br />

to program their remote control<br />

before activating it, thus avoiding<br />

having to send configuration<br />

SMSs, which can be used at any<br />

time, but are best used only once<br />

the system has been installed in<br />

situ. Since the UART is already<br />

busy communicating with the<br />

cellular module, serial communication<br />

occurs via lines RE0 and<br />

RA5, exploited, respectively, as<br />

Elettronica In ~ Aprile 2010 57


iPhone becomes CDMA<br />

The rumor is spreading that Apple is working on a new iPhone<br />

model, for the time being called generically 4G; this phone is<br />

a hybrid UMTS/CDMA which can work with any carrier in the<br />

world. Thanks to a new hybrid chip produced by Qualcomm, it<br />

should compatible not only with networks and dealers based on<br />

protocol CDMA2000 (operators in America, Japan, and Korea)<br />

such as Verizon and Sprint Nextel in the U.S., but also with those<br />

using 3G, common in Europe. Consequently, this new product can<br />

be used worldwide in all those areas covered by either UMTS or<br />

<strong>GSM</strong>, exploiting at a maximum the CDMA (Code Division Multiple<br />

Access) system’s potentialities. This new phone will be produced<br />

by Pegatron Technology, which will release its first samples<br />

in September, just in time to counter its competitors, such as<br />

Symbian, Windows Phone 7 and Android.<br />

TX and RX; AN3, assigned to the<br />

internal A/D converter, is needed<br />

to detect the presence of the 5<br />

volts and therefore the connector<br />

insertion. The serial interface<br />

is at a TTL level and can easily<br />

be connected to a USB converter<br />

USB such as FT232 by FTDI, in<br />

order to interface the microcontroller<br />

with a PC equipped with<br />

USB. For the interface, you can<br />

use FT782M, a small module<br />

produced by Futura Elettronica<br />

(www.futurashop.it), already<br />

58 Aprile 2010 ~ Elettronica In<br />

equipped with a pin-strip connector<br />

at a pitch of 0.10 inches<br />

that can be directly inserted in<br />

our circuit, on the TTL connector,<br />

a female SIL at a pitch of 0.10<br />

inches.<br />

The PC can be programmed<br />

through a specific utility we have<br />

included which was specially<br />

designed for Windows: it is a<br />

simple program that can downloaded<br />

free of charge from our<br />

website www.elettronicain.it and<br />

which, once it has been installed<br />

and launched, provides access to<br />

a control panel from where the<br />

user can enter and modify data<br />

by simply clicking on the various<br />

boxes.<br />

Still regarding the device’s configuration,<br />

it is important to note<br />

that the corresponding data are<br />

not saved in the microcontroller’s<br />

EEPROM, but in an external<br />

memory chip, dubbed 24FC256-<br />

SN; it is a 256- kbit EEPROM<br />

CMOS with serial access, and<br />

with an I²C-Bus interface. In order<br />

to communicate with such chip,<br />

the microcontroller initializes<br />

its I/O lines RD4 and RD5, used,<br />

respectively, as SDA (data line)<br />

and (clock line). Moving the remote<br />

control’s configuration data<br />

into an external memory allows<br />

us to exploit the entire internal<br />

EEPROM to enhance its available<br />

functions. Let’s now take a<br />

look at the section related to the<br />

identification of DTMF bi-tones,<br />

performed with the aid U7, an<br />

MT8870 chip capable of discerning<br />

standard 16 bi-tones thanks to<br />

a complex scheme of active filters<br />

put together through the clock<br />

signal generated by its internal<br />

oscillator, which is connected to<br />

pins 7 and 8 as well as to quartz<br />

Q2. Whenever it identifies a<br />

bi-tone, U7 displays, in binary<br />

format, the bi-tone’s corresponding<br />

number on outputs Q1 (least<br />

important bit) Q2, Q3 e Q4 (most<br />

important bit); all the numbers<br />

from 0 to 9 are represented with<br />

binary combinations from 0000<br />

to 1001, while A, B, C, D, * and #<br />

are expressed with the remaining<br />

combinations, going from 1010<br />

to 1111. The MT8870 chip has an<br />

output latch that helps maintain<br />

the logical combination corresponding<br />

to the last read bi-tone<br />

on Q1÷Q4; in order to avoid that<br />

the device may be deceived in the<br />

event that two like bi-tones are<br />

received consecutively, the chip


is equipped with an STD line (pin<br />

15), which changes from one to<br />

a logical zero when a bi-tone is<br />

identified. Our microcontroller<br />

reads the STD through line RD1<br />

so that it can tell whether like<br />

bi-tones have been received consecutively<br />

and correctly identify<br />

possible codes sent out by the<br />

cell phone. Note that the MT8870<br />

input has been connected to the<br />

<strong>GSM</strong> audio output precisely<br />

because those bi-tones transmitted<br />

from a landline phone or cell<br />

phone travel on phone channels<br />

rather than on the data line.<br />

PRACTICAL REALIZATION<br />

Now that we are familiar with<br />

the structure and functions of the<br />

base circuit, we can look at how<br />

it is built; let us state in advance<br />

that its realization presupposes a<br />

double-faced printed board with<br />

metallic holes –a choice we made<br />

in order to be able to reduce the<br />

overall size of the device. As a<br />

result, you need to have a 20÷25<br />

W solder with a very fine point,<br />

as well as thin alloy thread (max.<br />

0.20 inches in diameter). As for<br />

the printed circuit, you can find<br />

the traces corresponding to the<br />

two faces on our very site www.<br />

elettronicain.it; if you should<br />

be unable to create it on your<br />

own, keep in mind that there are<br />

various companies that can do it<br />

for you at a fairly low cost (e.g.,<br />

MD srl www.mdsrl.it). The first<br />

component to be assembled is the<br />

microcontroller, which should be<br />

placed centrally on relevant pads<br />

and secured by lightly soldering<br />

one electrode on each side; while<br />

soldering, care must be taken in<br />

order not to cause the neighboring<br />

pins to short-circuit (the space<br />

is quite small). Use the same<br />

technique for the other integrated<br />

circuits as well, but only assemble<br />

those you actually need; note that,<br />

unless you intend to use all its<br />

functionalities, this card should<br />

be assembled after you have<br />

read the articles that illustrate its<br />

specific functions. However, keep<br />

in mind that, overall, you need<br />

DS18B20 only if you want to use<br />

the thermostat function , while<br />

8870 is necessary in order to use<br />

the remote control via DTMF bitones<br />

(DTMF key function).<br />

Once all the soldering has been<br />

done and you have made sure no<br />

pads were joined by mistake, you<br />

can take care of the components<br />

to be assembled in a standard<br />

way, that is, rectification diodes<br />

and LEDs, button, pin-strips, and<br />

relays, starting with those with<br />

lower profile and working according<br />

to the polarities indicated<br />

by the assembling drawings<br />

illustrated on these pages. Once<br />

everything has been set up, you<br />

need to insert deep in the relevant<br />

connectors the module containing<br />

the <strong>GSM</strong> cellular (which we will<br />

discuss next month). In order for<br />

the remote control to work, there<br />

must be a power generator able<br />

to supply between 5 and 32 volts<br />

- 800 mA, or a lithium-ion battery<br />

of 800÷1.000 mA/h.<br />

Please stay tuned for the next<br />

issue! g<br />

where to buy<br />

All the components used for this<br />

project can be easily found. However,<br />

in the next few months, it will be possible<br />

to find kits for the various applications.<br />

For the time being, those who<br />

want to create their own systems can<br />

get the “heart” of the device, that is,<br />

the <strong>GSM</strong>/GPRS module SIM900<br />

quadriband (850/900/1800/1900<br />

MHz) for 48 Euro, including VAT. This<br />

module doesn’t need any connectors<br />

and can be soldered to the circuit just<br />

like a standard integrated module in<br />

SMD.<br />

The material can be requested at:<br />

Futura Elettronica, Via Adige 11,<br />

21013 Gallarate (VA)<br />

Tel: 0331-799775 • Fax: 0331-792287<br />

http://www.futurashop.it<br />

Elettronica In ~ Aprile 2010 59

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!