Pages

Monday, October 29, 2012

Cellphone-Based Device Control With Voice Acknowledgement

Here 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.
Circuit description
Fig.1 shows the circuit for cellphone based device control with voice acknowledgement. It comprises microcontroller AT89C51, DTMF decoder MT8870, voice recording/playback device APR9600 and a few discrete components.

fig1
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 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 decoding 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), 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  steering logic VTStdetected 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 voltage 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 mobile’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 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 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 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. 
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 configuration 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 port (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 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.