You are on page 1of 6

cONSTRUcTION

Cellphone-Based device Control with


Voice Acknowledgement
mar
sunil ku
 AzArudeen AnifA the input from push-to-on switches S1
through S8. Pins of Port P1 are pulled

H
ere is a circuit that lets you high via resistor network RNW1. Port
operate your home appli- pins P2.0 through P2.4 are configured voltage greater than threshold of the
ances like lights and water to receive the decoded DTMF signal steering logic VTSt detected at St causes
pump from your office or any other from DTMF receiver MT8870. The the device to register the detected tone
remote place. So if you forgot to switch functions of the corresponding switch- pair. The guard time output resets the
off the lights or other appliances while es (S1 through S8) and cellphone keys external steering time constant, and its
going out, it helps you to turn off the are shown in Table I. state is a function of ESt and the volt-
appliance with your cellphone. Your The DTMF decoder is used for de-
Parts List
cellphone works as the remote control
for your home appliances. You can Table I Semiconductors:
IC1 - AT89C51 microcontroller
control the desired appliance by press- Functions of Switches and IC2 - APR9600 voice recording
ing the corresponding key. The system Mobile Keys and playback device
also gives you voice acknowledgement Switches Mobile Function IC3 - MT8870 DTMF receiver
key IC4 - ULN2003 relay driver
of the appliance status.
IC5 - 7806, 6V regulator
S1 1 Select Device 1; On/Off D1-D5 - 1N4007 diode
Circuit description S2 2 Select Device 2; On/Off LED1-LED3 - 5mm LED
Fig. 1 shows the circuit for cellphone- S3 3 Select Device 3; On/Off Resistors (all ¼-watt, ±5% carbon):
based device control with voice ac- R1-R3 - 10-kilo-ohm
S4 4 Select Device 4; On/Off
R4, R6, R15 - 100-kilo-ohm
knowledgement. It comprises micro- S5 5 Select Device 5; On/Off R5 - 470-kilo-ohm
controller AT89C51, DTMF decoder S6 6 Select Device 6; On/Off R7 - 220-kilo-ohm
MT8870, voice recording/playback S7 * Initialise to inform the R8 - 39-kilo-ohm
device APR9600 and a few discrete R9, R10 - 4.7-kilo-ohm
status of the device
R11 - 1-kilo-ohm
components. S8 # On/off the voice alert R12 - 220-kilo ohm
Microcontroller AT89C51 is at the R13, R14, R16 - 470-ohm
heart of the circuit. It is a low-power, coding the mobile signal. It gets DTMF RNW1, RNW2 - 10-kilo-ohm resistor
high-performance, 8-bit microcontrol- tone from the mobile headset’s speaker network

ler with 4 kB of flash programma- pins and decodes it into 4-bit digital Capacitors:
C1, C2 - 33pF ceramic disk
ble and erasable read-only memory signal. The DTMF decoder is operated C3 - 10µF, 16V electrolytic
(PEROM) used as on-chip program with a 3.579MHz crystal (XTAL2). In C4, C6-C8,
memory, 128 bytes of RAM used as DTMF receiver MT8870 (IC3), capaci- C11, C15 - 0.1µF ceramic disk
C5 - 4.7µF, 16V electrolytic
internal data memory, 32 individu- tor C12 is used to filter the noise and
C9, C10 - 22µF, 50V electrolytic
ally programmable input/output (I/O) resistors R6 and R7 help to amplify C12 - 0.22µF polyster
lines divided into four 8-bit ports, two the input signal using the internal C13, C14 - 0.47µF polyster
16-bit programmable timers/counters, amplifier. C16 - 1000µF, 35V electrolytic
a five-vector two-level interrupt archi- Pin 16 of IC3 connected to resistor Miscellaneous:
S1-S16, S20 - Push-to-on switch
tecture, on-chip oscillator and clock cir- R5 provides the early steering output.
S17, S18 - 2-way DIP switch
cuitry. A 11.0592MHz crystal (XTAL1) is It goes high immediately when the dig- S19 - SPDT switch
used to provide basic clock frequency ital algorithm detects a valid tone pair S21 - On/off switch
for the microcontroller. Capacitor C3 (signal condition). Any momentary XTAL1 - 11.0592MHz crystal
XTAL2 - 3.579MHz crystal
and resistor R3 form the power-on loss of signal condition causes ESt to
RL1-RL6 - 6V, 1C/O relay
reset circuit, while push-to-on switch return to low state. MIC1 - Electret mic
S20 is used for manual reset. Pin 17 of IC3 connected to capacitor LS1 - 1W, 16-ohm speaker
Port pins P1.0 through P1.7 of the C11 is bidirectional, acting as steering CON1 - Mobile phone headset
connector
microcontroller are configured to get input/guard time output (St/GT). A

7 4 • J u n e 2 0 1 0 • e l e c t ro n i c s f o r yo u w w w. e f y m ag . co m
cONSTRUcTION

Fig. 1: Circuit for cellphone-based device control with voice acknowledgement

7 6 • J u n e 2 0 1 0 • e l e c t ro n i c s f o r yo u w w w. e f y m ag . co m
cONSTRUcTION
age at St. R1, respectively. Here, we are using Pin 2.5 of Port P2 is configured to
Port P3 pins P3.6 and P3.7 of IC1 two control sources, switches and mo- show the rest status. That is, if none of
are configured to select the control bile’s key. DIP switches S17 and S18 the control sources is selected by DIP
source for the devices. These are con- select the control sources as shown in switches S17 and S18, LED1 glows.
nected to DIP switches S17 and S18 Table II. Resistor R14 limits the current through
and pulled high via resistors R2 and LED1.
Table II Voice acknowledgement is pro-
Control Source Selection vided by the APR9600 (IC2). It is a
Using DIP Switches single-chip voice recording and play-
S17 S18 Control status back device that can record and play
multiple messages at random or in
0 0 Rest status
sequential mode for 60 seconds. The
0 1 Switches only
user can select sample rates with cor-
1 0 Mobile only
responding-quality recording lengths.
1 1 Switches and mobile
Fig. 2: Pin configuration of mobile headset Microphone amplifier, automatic gain
control (AGC) circuits, internal anti-
aliasing filter, internal output amplifier
and message management are some of
the features of the APR9600.
Here the APR9600 is configured in
random-access mode, which supports
two, four and eight messages of fixed
durations. The length of each message
is the total recording length available
divided by the total number of memo-
ry segments/tracks enabled.
Audio processor APR9600 can store
up to eight voice messages. Port P0
Fig. 3: Power supply circuit pins and P2.7 are configured to com-
municate with IC2. Port P0 pins
trigger selection of the message.
Port pin P2.7 is the input signal to
identify whether the voice message
is playing or not.
Pins P3.0 through P3.5 of Port
P3 control the devices with the
help of relays RL1 through RL6 via
relay driver IC4.
A speaker is connected to IC2
for audio output. The speaker
output drives the mic input of the
mobile for audio acknowledge-
ment. An electret microphone
MIC1 is connected to IC2 to record
the voice in IC2. LED2 flashes to
show the busy status of IC2 dur-
ing recording and playback. The
audio messages to be recorded in
APR9600, by using trigger switch-
es S9 through S16, are shown in
Table III. SPST switch S19 is closed
for recording and switch S19 is
opened for playback.
Fig. 4: A single-side, actual-size PCB layout for cellphone-based device control with voice
acknowledgement Fig. 3 shows the power sup-

w w w. e f y m ag . co m e l e c t ro n i c s f o r yo u • J u n e 2 0 1 0 • 7 7
cONSTRUcTION
ration of mobile headset.

Software
The program (Device_Control.BAS)
for the microcontroller is written
using BASCOM microcontroller
programming software. In the
program, first, initialise the ports
(P0-P3) for corresponding controls.
Thereafter, declare the variables for
the program. After declaration, as-
sign some initial value to variables.
Here, microcontroller ports are
initialised to make all the devices
‘off’ initially.
After that, the main function
checks through ‘Do’ loop which
control source has been enabled by
using DIP switch pins. If you select
switch S17, it searches the input
from the mobile only. If you select
switch S18, it searches the input
Fig. 5: Component layout for the PCB from the switches (S1 through S8)
only. If you enable both switch S17
and switch S18, it searches the inputs
Table III Table IV from switches and mobile. Else, the
Voice Recording Chart DTMF Value of Mobile Keys rest-status LED1 glows. Refer to Table
Switch Trigger of IC Voice Key StD Q3 Q2 Q1 Q0 II to select the control source.
S9 1 Name of Device 1 1 H 0 0 0 1 The mobile signal is decoded into
S10 2 Name of Device 2 2 H 0 0 1 0 the DTMF signal by IC3. The DTMF
S11 3 Name of Device 3 3 H 0 0 1 1 output for each mobile key (used in
S12 4 Name of Device 4 4 H 0 1 0 0 this project) pressed is shown in Table
S13 5 Name of Device 5 5 H 0 1 0 1 IV.
S14 6 Name of Device 6 6 H 0 1 1 0
After getting the input from the
S15 7 “Status On” * H 1 0 1 1
switches or mobile, the program goes
S16 8 “Status Off” to the device_action subroutine and
# H 1 1 0 0
executes the corresponding action
(refer Table I).
ply circuit. The 230V AC mains is shown in Fig. 4 and its component The device_action subroutine
stepped down by transformer X1 to layout in Fig. 5. changes the status of the device and
deliver the secondary output of 9V, calls the voice_alert subroutine. The
500 mA. The transformer output is recording and playback voice_alert subroutine checks the
rectified by a full-wave bridge recti- To record the voice in IC2, follow Table device status and device name from
fier comprising diodes D1 through III. Close SPST switch S19 to make pin the source input and controls the cor-
D4, filtered by capacitor C16 and then 27 of IC2 low. Thereafter, press and responding pins of IC2. First, it selects
regulated by IC 7806 (IC5). Capaci- hold switches S9 through S16 to record the voice signal for the device name.
tor C15 bypasses the ripples present corresponding voice messages. LED2 After playing that, it selects on/off
in the regulated 6V power supply. flashes to indicate audio recording. status of corresponding device as men-
LED3 acts as a power-on indicator For playback of any device status, tioned in Table III.
and resistor R16 limits the current open SPST switch S19 and press the If you press ‘*’ key followed by the
through LED3. corresponding switch (S9 through S16). device number on your mobile hand-
An actual-size, single-side PCB The recorded audio can be heard from set, it will not change the status of that
for cellphone-based device control the speaker connected to pins 14 and device and inform the current device
with voice acknowledgement is 15 of IC2. Fig. 2 shows the pin configu- status. If you press device number

7 8 • J u n e 2 0 1 0 • e l e c t ro n i c s f o r yo u w w w. e f y m ag . co m
cONSTRUcTION
followed by ‘*’ key on your mobile a mute key.
handset, it will change the status of EFY note. The source code of
that device and inform the changed this project has been included in this
device status. ‘#’ key controls the month’s EFY-CD and is also available
voice_control subroutine and acts like on www.efymag.com website.

device_control.bas
$large Aud_1 = 1
$regfile = “89c51cc.DAT” Aud_2 = 1
$crystal = 11059200 Aud_3 = 1
Aud_4 = 1
‘ DECLERATION OF FUNCTIONS Aud_5 = 1
Declare Sub Keypad Aud_6 = 1
Declare Sub Device_action Aud_on = 1
Declare Sub Voice_alert Aud_off = 1
Declare Sub Dtmf_input
‘Aud_rewind = 0
‘ INPUT FROM DTMF DECODER
Dtmf_a Alias P2.4 Device_1_status = 0
Dtmf_b Alias P2.3 Device_2_status = 0
Dtmf_c Alias P2.2 Device_3_status = 0
Dtmf_d Alias P2.1 Device_4_status = 0
Dtmf_ack Alias P2.0 Device_5_status = 0
Device_6_status = 0
‘ INPUT FROM KEYPAD
Key_1 Alias P1.0 Device_1 = 0
Key_2 Alias P1.1 Device_2 = 0
Key_3 Alias P1.2 Device_3 = 0
Key_4 Alias P1.3 Device_4 = 0
Key_5 Alias P1.4 Device_5 = 0
Key_6 Alias P1.5 Device_6 = 0
Key_a Alias P1.6
Key_v Alias P1.7 Voice = 1

‘ OUTPUT TO AUDIO SELECTION Do


Aud_1 Alias P0.0
Aud_2 Alias P0.1 If Device_a = 0 And Device_b = 0 Then
Aud_3 Alias P0.2 P2.5 = 0
Aud_4 Alias P0.3
Aud_5 Alias P0.4 Elseif Device_a = 0 And Device_b = 1
Aud_6 Alias P0.5 Then
Aud_on Alias P0.6 P2.5 = 1
Aud_off Alias P0.7
Call Keypad
‘Aud_rewind Alias P2.6
‘INPUT FROM APR9600 ‘If Keypad_value < 9 Then
Aud_busy Alias P2.7
Call Device_action
‘OUTPUT TO DEVICE
Device_1 Alias P3.0 ‘End If
Device_2 Alias P3.1
Device_3 Alias P3.2 Elseif Device_a = 1 And Device_b = 0
Device_4 Alias P3.3 Then
Device_5 Alias P3.4 P2.5 = 1
Device_6 Alias P3.5 Call Dtmf_input

‘CONTROLLING MODE SELECTION ‘If Keypad_value < 9 Then


Device_a Alias P3.6
Device_b Alias P3.7 Call Device_action

‘ DECLARING VARIABLES ‘End If


Dim Keypad_value As Byte
Dim Device_1_status As Bit Elseif Device_a = 1 And Device_b = 1
Dim Device_2_status As Bit Then
Dim Device_3_status As Bit P2.5 = 1
Dim Device_4_status As Bit
Dim Device_5_status As Bit Call Keypad
Dim Device_6_status As Bit Call Dtmf_input
Dim Common_status As Bit
Dim Voice As Bit ‘If Keypad_value < 9 Then
Dim Status_enable As Bit Call Device_action

‘INTIALIZING VALUES ‘ End If


Keypad_value = 15 End If

w w w. e f y m ag . co m e l e c t ro n i c s f o r yo u • J u n e 2 0 1 0 • 7 9
cONSTRUcTION
If Status_enable = 1 Then Call Voice_alert Keypad_value = 15
While Keypad_value > 7
If Device_b = 1 Then Elseif Keypad_value = 5 Then End If
Call Keypad
End If Device_5_status = Not Device_5_status End If
If Device_a = 1 Then Device_5 = Device_5_status
Call Dtmf_input Call Voice_alert End Sub
End If
Wend Elseif Keypad_value = 6 Then Sub Voice_alert
Call Voice_alert If Voice = 1 And Keypad_value < 7 Then
Status_enable = 0
End If Device_6_status = Not Device_6_status If Keypad_value = 1 Then
Device_6 = Device_6_status
Loop Call Voice_alert Common_status = Device_1_status

Sub Keypad Elseif Keypad_value = 7 Then Aud_1 = 0


If Key_1 = 0 Then Wait 1
Keypad_value = 1 Keypad_value = 15 Aud_1 = 1
Bitwait Key_1 , Set
Status_enable = 1 Elseif Keypad_value = 2 Then
Elseif Key_2 = 0 Then
Keypad_value = 2 Elseif Keypad_value = 8 Then Common_status = Device_2_status
Bitwait Key_2 , Set If Voice = 1 Then Aud_2 = 0
Voice = 0 Wait 1
Elseif Voice = 0 Then Aud_2 = 1
Elseif Key_3 = 0 Then Voice = 1
Keypad_value = 3 End If Elseif Keypad_value = 3 Then
Bitwait Key_3 , Set
End If Common_status = Device_3_status
Elseif Key_4 = 0 Then Aud_3 = 0
Keypad_value = 4 Keypad_value = 15 Wait 1
Bitwait Key_4 , Set Aud_3 = 1
End Sub
Elseif Key_5 = 0 Then Elseif Keypad_value = 4 Then
Keypad_value = 5 Sub Dtmf_input
Bitwait Key_5 , Set Common_status = Device_4_status
If Dtmf_ack = 1 Then Aud_4 = 0
Elseif Key_6 = 0 Then Bitwait Dtmf_ack , Reset Wait 1
Keypad_value = 6 Aud_4 = 1
Bitwait Key_6 , Set If Dtmf_d = 0 And Dtmf_c = 0 And Dtmf_
b = 0 And Dtmf_a = 1 Then Elseif Keypad_value = 5 Then
Elseif Key_a = 0 Then
Keypad_value = 7 Keypad_value = 1 Common_status = Device_5_status
Bitwait Key_a , Set Aud_5 = 0
Elseif Dtmf_d = 0 And Dtmf_c = 0 And Wait 1
Elseif Key_v = 0 Then Dtmf_b = 1 And Dtmf_a = 0 Then Aud_5 = 1
Keypad_value = 8
Bitwait Key_v , Set Keypad_value = 2 Elseif Keypad_value = 6 Then
Else Elseif Dtmf_d = 0 And Dtmf_c = 0 And
Keypad_value = 15 Dtmf_b = 1 And Dtmf_a = 1 Then Common_status = Device_6_status
Aud_6 = 0
End If Keypad_value = 3 Wait 1
Aud_6 = 1
End Sub Elseif Dtmf_d = 0 And Dtmf_c = 1 And
Dtmf_b = 0 And Dtmf_a = 0 Then End If
Sub Device_action
Keypad_value = 4 ‘Bitwait Aud_busy , Set
If Keypad_value = 1 Then Wait 5
Elseif Dtmf_d = 0 And Dtmf_c = 1 And
Device_1_status = Not Device_1_status Dtmf_b = 0 And Dtmf_a = 1 Then If Common_status = 1 Then
Device_1 = Device_1_status
Call Voice_alert Keypad_value = 5 Aud_off = 0
Elseif Keypad_value = 2 Then Wait 1
Elseif Dtmf_d = 0 And Dtmf_c = 1 And Aud_off = 1
Device_2_status = Not Device_2_status Dtmf_b = 1 And Dtmf_a = 0 Then
Device_2 = Device_2_status Elseif Common_status = 0 Then
Call Voice_alert Keypad_value = 6
Aud_on = 0
Elseif Keypad_value = 3 Then Elseif Dtmf_d = 1 And Dtmf_c = 0 And Wait 1
Dtmf_b = 1 And Dtmf_a = 1 Then Aud_on = 1

Device_3_status = Not Device_3_status Keypad_value = 7 End If


Device_3 = Device_3_status
Call Voice_alert Elseif Dtmf_d = 1 And Dtmf_c = 1 And Bitwait Aud_busy , Set
Dtmf_b = 0 And Dtmf_a = 0 Then
Elseif Keypad_value = 4 Then End If
Keypad_value = 8
Device_4_status = Not Device_4_status End Sub
Device_4 = Device_4_status Else 

8 0 • J u n e 2 0 1 0 • e l e c t ro n i c s f o r yo u w w w. e f y m ag . co m

You might also like