You are on page 1of 6

cONSTRUcTION

Cellphone-Based device Control with Voice Acknowledgement

AzArudeen AnifA

ere is a circuit that lets you operate your home appliances like lights and water pump from your office or any other remote place. So if you forgot to switch off the lights or other appliances while going out, it helps you to turn off the appliance with your cellphone. Your cellphone works as the remote control for your home appliances. You can control the desired appliance by pressing the corresponding key. The system also gives you voice acknowledgement of the appliance status.

the input from push-to-on switches S1 through S8. Pins of Port P1 are pulled high via resistor network RNW1. Port pins P2.0 through P2.4 are configured to receive the decoded DTMF signal from DTMF receiver MT8870. The functions of the corresponding switches (S1 through S8) and cellphone keys are shown in Table I. The DTMF decoder is used for de-

sunil ku

mar

voltage greater than threshold of the steering logic VTSt detected at St causes the device to register the detected tone pair. The guard time output resets the external steering time constant, and its state is a function of ESt and the voltParts List
Semiconductors: IC1 - AT89C51 microcontroller IC2 - APR9600 voice recording and playback device IC3 - MT8870 DTMF receiver IC4 - ULN2003 relay driver IC5 - 7806, 6V regulator D1-D5 - 1N4007 diode LED1-LED3 - 5mm LED Resistors (all -watt, 5% carbon): R1-R3 - 10-kilo-ohm R4, R6, R15 - 100-kilo-ohm R5 - 470-kilo-ohm R7 - 220-kilo-ohm R8 - 39-kilo-ohm R9, R10 - 4.7-kilo-ohm R11 - 1-kilo-ohm R12 - 220-kilo ohm R13, R14, R16 - 470-ohm RNW1, RNW2 - 10-kilo-ohm resistor network Capacitors: C1, C2 C3 C4, C6-C8, C11, C15 C5 C9, C10 C12 C13, C14 C16 Miscellaneous: S1-S16, S20 S17, S18 S19 S21 XTAL1 XTAL2 RL1-RL6 MIC1 LS1 CON1 - 33pF ceramic disk - 10F, 16V electrolytic 0.1F ceramic disk 4.7F, 16V electrolytic 22F, 50V electrolytic 0.22F polyster 0.47F polyster 1000F, 35V electrolytic Push-to-on switch 2-way DIP switch SPDT switch On/off switch 11.0592MHz crystal 3.579MHz crystal 6V, 1C/O relay Electret mic 1W, 16-ohm speaker Mobile phone headset connector

Functions of Switches and Mobile Keys


Switches Mobile key S1 S2 S3 S4 S5 S6 S7 S8 1 2 3 4 5 6 * # Function Select Device 1; On/Off Select Device 2; On/Off Select Device 3; On/Off Select Device 4; On/Off Select Device 5; On/Off Select Device 6; On/Off Initialise to inform the status of the device On/off the voice alert

Table I

Circuit description
Fig. 1 shows the circuit for cellphonebased device control with voice acknowledgement. It comprises microcontroller AT89C51, DTMF decoder MT8870, voice recording/playback device APR9600 and a few discrete components. Microcontroller AT89C51 is at the heart of the circuit. It is a low-power, high-performance, 8-bit microcontroller with 4 kB of flash programmable and erasable read-only memory (PEROM) used as on-chip program memory, 128 bytes of RAM used as internal data memory, 32 individually programmable input/output (I/O) lines divided into four 8-bit ports, two 16-bit programmable timers/counters, a five-vector two-level interrupt architecture, on-chip oscillator and clock circuitry. A 11.0592MHz crystal (XTAL1) is used to provide basic clock frequency for the microcontroller. Capacitor C3 and resistor R3 form the power-on reset circuit, while push-to-on switch S20 is used for manual reset. Port pins P1.0 through P1.7 of the microcontroller are configured to get
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

coding the mobile signal. It gets DTMF tone from the mobile headsets speaker pins and decodes it into 4-bit digital signal. The DTMF decoder is operated with a 3.579MHz crystal (XTAL2). In DTMF receiver MT8870 (IC3), capacitor C12 is used to filter the noise and resistors R6 and R7 help to amplify the input signal using the internal amplifier. Pin 16 of IC3 connected to resistor R5 provides the early steering output. It goes high immediately when the digital algorithm detects a valid tone pair (signal condition). Any momentary loss of signal condition causes ESt to return to low state. Pin 17 of IC3 connected to capacitor C11 is bidirectional, acting as steering input/guard time output (St/GT). A

w w w. e f y m ag . co m

cONSTRUcTION

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

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

cONSTRUcTION
age at St. Port P3 pins P3.6 and P3.7 of IC1 are configured to select the control source for the devices. These are connected to DIP switches S17 and S18 and pulled high via resistors R2 and R1, respectively. Here, we are using two control sources, switches and mobiles key. DIP switches S17 and S18 select the control sources as shown in Table II. Pin 2.5 of Port P2 is configured to show the rest status. That is, if none of the control sources is selected by DIP switches S17 and S18, LED1 glows. Resistor R14 limits the current through LED1. Voice acknowledgement is provided by the APR9600 (IC2). It is a single-chip voice recording and playback device that can record and play multiple messages at random or in sequential mode for 60 seconds. The user can select sample rates with corresponding-quality recording lengths. Microphone amplifier, automatic gain control (AGC) circuits, internal antialiasing 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 memory segments/tracks enabled. Audio processor APR9600 can store up to eight voice messages. Port P0 pins and P2.7 are configured to communicate 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 acknowledgement. An electret microphone MIC1 is connected to IC2 to record the voice in IC2. LED2 flashes to show the busy status of IC2 during recording and playback. The audio messages to be recorded in APR9600, by using trigger switches S9 through S16, are shown in Table III. SPST switch S19 is closed for recording and switch S19 is opened for playback. Fig. 3 shows the power supe l e c t ro n i c s f o r yo u J u n e 2 0 1 0 7 7

Control Source Selection Using DIP Switches


S17 0 0 1
Fig. 2: Pin configuration of mobile headset

Table II

S18 0 1 0 1

Control status Rest status Switches only Mobile only Switches and mobile

Fig. 3: Power supply circuit

Fig. 4: A single-side, actual-size PCB layout for cellphone-based device control with voice acknowledgement w w w. e f y m ag . co m

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, assign 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 from the switches (S1 through S8) only. If you enable both switch S17 and switch S18, it searches the inputs from switches and mobile. Else, the rest-status LED1 glows. Refer to Table II to select the control source. The mobile signal is decoded into the DTMF signal by IC3. The DTMF output for each mobile key (used in this project) pressed is shown in Table IV. After getting the input from the switches or mobile, the program goes to the device_action subroutine and executes the corresponding action (refer Table I). The device_action subroutine changes the status of the device and calls the voice_alert subroutine. The voice_alert subroutine checks the device status and device name from the source input and controls the corresponding pins of IC2. First, it selects the voice signal for the device name. After playing that, it selects on/off status of corresponding device as mentioned in Table III. If you press * key followed by the device number on your mobile handset, it will not change the status of that device and inform the current device status. If you press device number
w w w. e f y m ag . co m

Fig. 5: Component layout for the PCB

Voice Recording Chart


Switch S9 S10 S11 S12 S13 S14 S15 S16 Trigger of IC 1 2 3 4 5 6 7 8 Voice Name of Device 1 Name of Device 2 Name of Device 3 Name of Device 4 Name of Device 5 Name of Device 6 Status On Status Off

Table III

DTMF Value of Mobile Keys


Key 1 2 3 4 5 6 * # StD H H H H H H H H Q3 0 0 0 0 0 0 1 1 Q2 0 0 0 1 1 1 0 1 Q1 0 1 1 0 0 1 1 0 Q0 1 0 1 0 1 0 1 0

Table IV

ply circuit. The 230V AC mains is stepped down by transformer X1 to deliver the secondary output of 9V, 500 mA. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D1 through D4, filtered by capacitor C16 and then regulated by IC 7806 (IC5). Capacitor C15 bypasses the ripples present in the regulated 6V power supply. LED3 acts as a power-on indicator and resistor R16 limits the current through LED3. An actual-size, single-side PCB for cellphone-based device control with voice acknowledgement is
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

shown in Fig. 4 and its component layout in Fig. 5.

recording and playback


To record the voice in IC2, follow Table III. Close SPST switch S19 to make pin 27 of IC2 low. Thereafter, press and hold switches S9 through S16 to record corresponding voice messages. LED2 flashes to indicate audio recording. For playback of any device status, open SPST switch S19 and press the corresponding switch (S9 through S16). The recorded audio can be heard from the speaker connected to pins 14 and 15 of IC2. Fig. 2 shows the pin configu-

cONSTRUcTION
followed by * key on your mobile handset, it will change the status of that device and inform the changed device status. # key controls the voice_control subroutine and acts like a mute key. EFY note. The source code of this project has been included in this months EFY-CD and is also available on www.efymag.com website.

device_control.bas
$large $regfile = 89c51cc.DAT $crystal = 11059200 DECLERATION OF FUNCTIONS Declare Sub Keypad Declare Sub Device_action Declare Sub Voice_alert Declare Sub Dtmf_input INPUT FROM DTMF DECODER Dtmf_a Alias P2.4 Dtmf_b Alias P2.3 Dtmf_c Alias P2.2 Dtmf_d Alias P2.1 Dtmf_ack Alias P2.0 INPUT FROM KEYPAD Key_1 Alias P1.0 Key_2 Alias P1.1 Key_3 Alias P1.2 Key_4 Alias P1.3 Key_5 Alias P1.4 Key_6 Alias P1.5 Key_a Alias P1.6 Key_v Alias P1.7 OUTPUT TO AUDIO SELECTION Aud_1 Alias P0.0 Aud_2 Alias P0.1 Aud_3 Alias P0.2 Aud_4 Alias P0.3 Aud_5 Alias P0.4 Aud_6 Alias P0.5 Aud_on Alias P0.6 Aud_off Alias P0.7 Aud_rewind Alias P2.6 INPUT FROM APR9600 Aud_busy Alias P2.7 OUTPUT TO DEVICE Device_1 Alias P3.0 Device_2 Alias P3.1 Device_3 Alias P3.2 Device_4 Alias P3.3 Device_5 Alias P3.4 Device_6 Alias P3.5 CONTROLLING MODE SELECTION Device_a Alias P3.6 Device_b Alias P3.7 DECLARING VARIABLES Dim Keypad_value As Byte Dim Device_1_status As Bit Dim Device_2_status As Bit Dim Device_3_status As Bit Dim Device_4_status As Bit Dim Device_5_status As Bit Dim Device_6_status As Bit Dim Common_status As Bit Dim Voice As Bit Dim Status_enable As Bit INTIALIZING VALUES Keypad_value = 15 Aud_1 = 1 Aud_2 = 1 Aud_3 = 1 Aud_4 = 1 Aud_5 = 1 Aud_6 = 1 Aud_on = 1 Aud_off = 1 Aud_rewind = 0 Device_1_status Device_2_status Device_3_status Device_4_status Device_5_status Device_6_status Device_1 Device_2 Device_3 Device_4 Device_5 Device_6 Voice = 1 Do If Device_a = 0 And Device_b = 0 Then P2.5 = 0 Elseif Device_a = 0 And Device_b = 1 Then P2.5 = 1 Call Keypad If Keypad_value < 9 Then Call Device_action End If Elseif Device_a = 1 And Device_b = 0 Then P2.5 = 1 Call Dtmf_input If Keypad_value < 9 Then Call Device_action End If Elseif Device_a = 1 And Device_b = 1 Then P2.5 = 1 Call Keypad Call Dtmf_input If Keypad_value < 9 Then Call Device_action End If End If = = = = = = 0 0 0 0 0 0 = = = = = = 0 0 0 0 0 0

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 While Keypad_value > 7 If Device_b = 1 Then Call Keypad End If If Device_a = 1 Then Call Dtmf_input End If Wend Call Voice_alert Status_enable = 0 End If Loop Sub Keypad If Key_1 = 0 Then Keypad_value = 1 Bitwait Key_1 , Set Elseif Key_2 = 0 Then Keypad_value = 2 Bitwait Key_2 , Set Elseif Key_3 = 0 Then Keypad_value = 3 Bitwait Key_3 , Set Elseif Key_4 = 0 Then Keypad_value = 4 Bitwait Key_4 , Set Elseif Key_5 = 0 Then Keypad_value = 5 Bitwait Key_5 , Set Elseif Key_6 = 0 Then Keypad_value = 6 Bitwait Key_6 , Set Elseif Key_a = 0 Then Keypad_value = 7 Bitwait Key_a , Set Elseif Key_v = 0 Then Keypad_value = 8 Bitwait Key_v , Set Else Keypad_value = 15 End If End Sub Sub Device_action If Keypad_value = 1 Then Device_1_status = Not Device_1_status Device_1 = Device_1_status Call Voice_alert Elseif Keypad_value = 2 Then Device_2_status = Not Device_2_status Device_2 = Device_2_status Call Voice_alert Elseif Keypad_value = 3 Then Device_3_status = Not Device_3_status Device_3 = Device_3_status Call Voice_alert Elseif Keypad_value = 4 Then Device_4_status = Not Device_4_status Device_4 = Device_4_status Call Voice_alert Elseif Keypad_value = 5 Then Device_5_status = Not Device_5_status Device_5 = Device_5_status Call Voice_alert Elseif Keypad_value = 6 Then Device_6_status = Not Device_6_status Device_6 = Device_6_status Call Voice_alert Elseif Keypad_value = 7 Then Keypad_value = 15 Status_enable = 1 Elseif Keypad_value = 8 Then If Voice = 1 Then Voice = 0 Elseif Voice = 0 Then Voice = 1 End If End If Keypad_value = 15 End Sub Sub Dtmf_input If Dtmf_ack = 1 Then Bitwait Dtmf_ack , Reset If Dtmf_d = 0 And Dtmf_c = 0 And Dtmf_ b = 0 And Dtmf_a = 1 Then Keypad_value = 1 Elseif Dtmf_d = 0 And Dtmf_c = 0 And Dtmf_b = 1 And Dtmf_a = 0 Then Keypad_value = 2 Elseif Dtmf_d = 0 And Dtmf_c = 0 And Dtmf_b = 1 And Dtmf_a = 1 Then Keypad_value = 3 Elseif Dtmf_d = 0 And Dtmf_c = 1 And Dtmf_b = 0 And Dtmf_a = 0 Then Keypad_value = 4 Elseif Dtmf_d = 0 And Dtmf_c = 1 And Dtmf_b = 0 And Dtmf_a = 1 Then Keypad_value = 5 Elseif Dtmf_d = 0 And Dtmf_c = 1 And Dtmf_b = 1 And Dtmf_a = 0 Then Keypad_value = 6 Elseif Dtmf_d = 1 And Dtmf_c = 0 And Dtmf_b = 1 And Dtmf_a = 1 Then Keypad_value = 7 Elseif Dtmf_d = 1 And Dtmf_c = 1 And Dtmf_b = 0 And Dtmf_a = 0 Then Keypad_value = 8 Else Keypad_value = 15 End If End If End Sub Sub Voice_alert If Voice = 1 And Keypad_value < 7 Then If Keypad_value = 1 Then Common_status = Device_1_status Aud_1 = 0 Wait 1 Aud_1 = 1 Elseif Keypad_value = 2 Then Common_status = Device_2_status Aud_2 = 0 Wait 1 Aud_2 = 1 Elseif Keypad_value = 3 Then Common_status = Device_3_status Aud_3 = 0 Wait 1 Aud_3 = 1 Elseif Keypad_value = 4 Then Common_status = Device_4_status Aud_4 = 0 Wait 1 Aud_4 = 1 Elseif Keypad_value = 5 Then Common_status = Device_5_status Aud_5 = 0 Wait 1 Aud_5 = 1 Elseif Keypad_value = 6 Then Common_status = Device_6_status Aud_6 = 0 Wait 1 Aud_6 = 1 End If Bitwait Aud_busy , Set Wait 5 If Common_status = 1 Then Aud_off = 0 Wait 1 Aud_off = 1 Elseif Common_status = 0 Then Aud_on = 0 Wait 1 Aud_on = 1 End If Bitwait Aud_busy , Set End If End Sub

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