6

Click here to load reader

voice acknowledgement

Embed Size (px)

Citation preview

Page 1: voice acknowledgement

cONSTRUcTION

74 • June 2010 • electronics for you w w w . e f y m a g . c o m

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 switch-es (S1 through S8) and cellphone keys are shown in Table I.

The DTMF decoder is used for de-

coding the mobile signal. It gets DTMF tone from the mobile headset’s 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), capaci-tor 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 dig-ital 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

AzArudeen AnifA

Cellphone-Based device Control with Voice Acknowledgement

sunil kumar

Here is a circuit that lets you operate your home appli-ances 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 press-ing the corresponding key. The system also gives you voice acknowledgement of the appliance status.

Circuit descriptionFig. 1 shows the circuit for cellphone-based device control with voice ac-knowledgement. It comprises micro-controller 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 microcontrol-ler with 4 kB of flash programma-ble and erasable read-only memory (PEROM) used as on-chip program memory, 128 bytes of RAM used as internal data memory, 32 individu-ally programmable input/output (I/O) lines divided into four 8-bit ports, two 16-bit programmable timers/counters, a five-vector two-level interrupt archi-tecture, on-chip oscillator and clock cir-cuitry. 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

Parts ListSemiconductors:IC1 - AT89C51 microcontrollerIC2 - APR9600 voice recording

and playback deviceIC3 - MT8870 DTMF receiverIC4 - ULN2003 relay driver IC5 - 7806, 6V regulator D1-D5 - 1N4007 diodeLED1-LED3 - 5mm LEDResistors (all ¼-watt, ±5% carbon):R1-R3 - 10-kilo-ohmR4, R6, R15 - 100-kilo-ohmR5 - 470-kilo-ohmR7 - 220-kilo-ohmR8 - 39-kilo-ohmR9, R10 - 4.7-kilo-ohmR11 - 1-kilo-ohmR12 - 220-kilo ohm R13, R14, R16 - 470-ohmRNW1, RNW2 - 10-kilo-ohm resistor

networkCapacitors:C1, C2 - 33pF ceramic diskC3 - 10µF, 16V electrolyticC4, C6-C8, C11, C15 - 0.1µF ceramic diskC5 - 4.7µF, 16V electrolyticC9, C10 - 22µF, 50V electrolyticC12 - 0.22µF polysterC13, C14 - 0.47µF polysterC16 - 1000µF, 35V electrolyticMiscellaneous:S1-S16, S20 - Push-to-on switchS17, S18 - 2-way DIP switchS19 - SPDT switchS21 - On/off switch XTAL1 - 11.0592MHz crystalXTAL2 - 3.579MHz crystalRL1-RL6 - 6V, 1C/O relayMIC1 - Electret micLS1 - 1W, 16-ohm speakerCON1 - Mobile phone headset

connector

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 volt-

Table I Functions of Switches and

Mobile KeysSwitches Mobile Function key

S1 1 SelectDevice1;On/Off

S2 2 SelectDevice2;On/Off

S3 3 SelectDevice3;On/Off

S4 4 SelectDevice4;On/Off

S5 5 SelectDevice5;On/Off

S6 6 SelectDevice6;On/Off

S7 * Initialisetoinformthe statusofthedevice

S8 # On/offthevoicealert

Page 2: voice acknowledgement

cONSTRUcTION

76 • June 2010 • electronics for you w w w . e f y m a g . c o m

Fig.

1: C

ircui

t for

cel

lpho

ne-b

ased

dev

ice

cont

rol w

ith v

oice

ack

now

ledg

emen

t

Page 3: voice acknowledgement

cONSTRUcTION

electronics for you • June 2010 • 77w w w . e f y m a g . c o m

R1, respectively. Here, we are using two control sources, switches and mo-bile’s 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 pro-vided by the APR9600 (IC2). It is a single-chip voice recording and play-back device that can record and play multiple messages at random or in sequential mode for 60 seconds. The user can select sample rates with cor-responding-quality recording lengths. 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 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. 3 shows the power sup-

Table II Control Source Selection

Using DIP SwitchesS17 S18 Control status

0 0 Reststatus

0 1 Switchesonly

1 0 Mobileonly

1 1 Switchesandmobile

Fig. 3: Power supply circuit

Fig. 2: Pin configuration of mobile headset

Fig. 4: A single-side, actual-size PCB layout for cellphone-based device control with voice acknowledgement

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 con-nected to DIP switches S17 and S18 and pulled high via resistors R2 and

Page 4: voice acknowledgement

cONSTRUcTION

78 • June 2010 • electronics for you w w w . e f y m a g . c o m

Table III Voice Recording Chart

Switch Trigger of IC Voice

S9 1 NameofDevice1

S10 2 NameofDevice2

S11 3 NameofDevice3

S12 4 NameofDevice4

S13 5 NameofDevice5

S14 6 NameofDevice6

S15 7 “StatusOn”

S16 8 “StatusOff”

Table IV DTMF Value of Mobile Keys

Key StD Q3 Q2 Q1 Q0

1 H 0 0 0 1

2 H 0 0 1 0

3 H 0 0 1 1

4 H 0 1 0 0

5 H 0 1 0 1

6 H 0 1 1 0

* H 1 0 1 1

# H 1 1 0 0

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 recti-fier comprising diodes D1 through D4, filtered by capacitor C16 and then regulated by IC 7806 (IC5). Capaci-tor 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

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

recording and playbackTo 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-

ration of mobile headset.

SoftwareThe 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 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 cor-responding 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 men-tioned in Table III.

If you press ‘*’ key followed by the device number on your mobile hand-set, it will not change the status of that device and inform the current device status. If you press device number

Fig. 5: Component layout for the PCB

Page 5: voice acknowledgement

cONSTRUcTION

electronics for you • June 2010 • 79w w w . e f y m a g . c o m

device_control.bas$large$regfile = “89c51cc.DAT”$crystal = 11059200

‘ DECLERATION OF FUNCTIONSDeclare Sub KeypadDeclare Sub Device_actionDeclare Sub Voice_alertDeclare Sub Dtmf_input

‘ INPUT FROM DTMF DECODERDtmf_a Alias P2.4Dtmf_b Alias P2.3Dtmf_c Alias P2.2Dtmf_d Alias P2.1Dtmf_ack Alias P2.0

‘ INPUT FROM KEYPADKey_1 Alias P1.0Key_2 Alias P1.1Key_3 Alias P1.2Key_4 Alias P1.3Key_5 Alias P1.4Key_6 Alias P1.5Key_a Alias P1.6Key_v Alias P1.7

‘ OUTPUT TO AUDIO SELECTIONAud_1 Alias P0.0Aud_2 Alias P0.1Aud_3 Alias P0.2Aud_4 Alias P0.3Aud_5 Alias P0.4Aud_6 Alias P0.5Aud_on Alias P0.6Aud_off Alias P0.7

‘Aud_rewind Alias P2.6‘INPUT FROM APR9600Aud_busy Alias P2.7

‘OUTPUT TO DEVICEDevice_1 Alias P3.0Device_2 Alias P3.1Device_3 Alias P3.2Device_4 Alias P3.3Device_5 Alias P3.4Device_6 Alias P3.5

‘CONTROLLING MODE SELECTIONDevice_a Alias P3.6Device_b Alias P3.7

‘ DECLARING VARIABLESDim Keypad_value As ByteDim Device_1_status As BitDim Device_2_status As BitDim Device_3_status As BitDim Device_4_status As BitDim Device_5_status As BitDim Device_6_status As BitDim Common_status As BitDim Voice As BitDim Status_enable As Bit

‘INTIALIZING VALUESKeypad_value = 15

Aud_1 = 1Aud_2 = 1Aud_3 = 1Aud_4 = 1Aud_5 = 1Aud_6 = 1Aud_on = 1Aud_off = 1

‘Aud_rewind = 0

Device_1_status = 0Device_2_status = 0Device_3_status = 0Device_4_status = 0Device_5_status = 0Device_6_status = 0

Device_1 = 0Device_2 = 0Device_3 = 0Device_4 = 0Device_5 = 0Device_6 = 0

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 IfEnd If

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 month’s EFY-CD and is also available on www.efymag.com website.

Page 6: voice acknowledgement

cONSTRUcTION

80 • June 2010 • electronics for you w w w . e f y m a g . c o m

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_alertStatus_enable = 0End 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_alertIf 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