Pages

Tuesday, March 16, 2010

REMOTE CONTROLLED DIGITAL AUDIO PROCESSOR

INTRODUCTION

These days most audio systems come with remote controllers. However, no such facility is provided for normal audio amplifiers. Such audio controllers are not available even in kit form. This article presents an infrared (IR) remote-controlled digital audio processor. It is based on a microcontroller and can be used with any NEC-compatible fullfunction IR remote control. This audio processor has enhanced features and can be easily customised to meet individual requirements as it is programmable. Its main features are: 1. Full remote control using any NEC-compatible IR remote control handset. 2. Provision for four stereo input channels and one stereo output. 3. Individual gain control for each input channel to handle different sources 4. Bass, midrange, treble, mute and attenuation control 5. 80-step control for volume and 15-step control for bass, midrange and treble 6. Settings displayed on two 7-segment light-emitting diode (LED) displays and eight individual LEDs 7. Stereo VU level indication on 10-LED bar display 8. Full-function keys on-board for audio amplifier control 9. All settings stored on the EEPROM 10. Standby mode for amplifier power control Circuit description


BLODK DIAGRAM FOR REMOTE CONTROLLED DIGITAL AUDIO PROCESSOR



CIRCUIT DIAGRAM FOR REMOTE CONTROLLED DIGITAL AUDIO PROCESSOR



CIRCUIT DESCRIPTION OF REMOTE-CONTROLLED DIGITAL AUDIO PROCESSOR

Fig. 1 shows the block diagram of the remote-controlled digital audio processor. The system comprises Atmel’s AT89C51 microcontroller (IC1),
TDA7439 audio processor from SGSThomson (IC4) and I2C bus compatible MC24C02 EEPROM (IC5). The microcontroller chip is programmed to control all the digital processes of the
system. The audio processor controls all the audio amplifier functions and is compatible with I2C bus. All the commands from the remote control are received through the IR sensor. The audio amplifier can also be
controlled using the on-board keys.
Microcontroller
the function of the microcontroller is to receive commands (through port P3.2) from the remote handset, program audio controls as per the commands and update the EEPROM. A delay in updating the EEPROM is de-liberately provided because normally the listener will change the value of a
parameter continuously until he is satisfied. The 40-pin AT89C51 microcontrollerhas four 8-bit input/output (I/O) ports. Port 0 is used for indicating through LEDs the various functions selected via the remote/on-board keys. Port 1 drives the 7-segment display using 7-segment latch/decoder/driver IC CD4543. Port 2 is pulled up via resistor network RNW1 and used for manual key control. Pins P3.0 and P3.1 of the microcontroller are used as serial data (SDA) and serial clock (SCL) lines for the I2C bus for communicating with the audio processor (TDA7439) and EEPROM (MC24C02). These two lines are connected to pull-up resistors, which are required for I2C bus devices. P3.2 receives the remote commands through the IR receiver module. Pin P3.4 is used for flashing LED9 whenever a remote command is received or any key is pressed. The microcontroller also checks the functioning of the memory (MC24C02) and the audio processor (TDA7439). If it is not communicating with these two ICs on the I2C bus, it flashes the volume level on the 7-segment displays. Memory. IC MC24C02 is an I2C-bus compatible 2k-bit EEPROM organised as 256×8-bit that can retain data for more than ten years. Various parameters can be stored in it. To obviate the loss of latest settings in the case of power failure, the microcontroller stores all the audio settings of the user in the EEPROM. The memory ensures that the microcontroller will read the last saved settings from the EEPROM when power resumes. Using SCL and SDA lines, the microcontroller can read and write data for all the parameters. For more details on I2C bus and memory interface, please refer to the MC24C02 datasheet. Audio parameters can be set using the remote control handset or the on-board keys as per the details given under the ‘remote control’ section. Audio processor. IC TDA7439 is a single-chip I2C-bus compatible audio controller that is used to control all the functions of the audio amplifier. The output from any (up to four) stereo preamplifier is fed to the audio processor (TDA7439). The microcontroller can control volume, treble, bass, attenuation, gain and other functions of each channel separately. All these parameters are programmed by the microcontroller using SCL and SDA lines, which it shares with the memory IC and the audio processor. Data transmission from the microcontroller to the audio processor (IC TDA7439) and the memory (MC24C02) and vice versa takes place through the two-wire I2C-bus interface consisting of SDA and SCL, which are connected to P3.0 (RXD) and P3.1 (TXD) of the microcontroller, respectively. Here, the microcontroller unit acts as the master and the audio processor and the memory act as slave devices. Any of these three devices can act as the transmitter or the receiver under the control of the master. Some of the conditions to communicate through the I2C bus are:
1. Data validity: The data on the SDA line must be stable during the high period of the clock. The high andlow states of the data line can change only when the clock signal on the SCL line is low.
2. Start and Stop: A start condition is a high-to-low transition of the SDA line while SCL is high. The stop condition is a low-to-high transition of the SDA line while SCL is high.
3. Byte format: Every byte transferred on the SDA line must contain eight bits. The most significant bit (MSB) is transferred first.
4. Acknowledge: Each byte must be followed by an acknowledgement bit. The acknowledge clock pulse is generated by the master. The transmitter releases the SDA line (high) during the acknowledge clock pulse. The receiver must pull down the SDA line during the acknowledge clock pulse so that it remains low during the high period of this clock pulse. To program any of the parameters, the following interface protocol is used for sending the data from the microcontroller to TDA7439. The interface protocol comprises:
1. A start condition (S)
2. A chip address byte containing the TDA7439 address (88H) followed by an acknowledgement bit (ACK)
3. A sub-address byte followed by an ACK. The first four bits (LSB) of this byte indicate the function selected (e.g., input select, bass, treble and volume). The fifth bit indicates incremental/ non-incremental bus (1/0) and the sixth, seventh and eighth bits are ‘don’t care’ bits.
4. A sequence of data followed by an ACK. The data pertains to the value for the selected function.
5. A stop condition (P) In the case of non-incremental bus, the data bytes correspond only to the function selected. If the fifth bit is high, the sub-address is automatically incremented with each data byte. This mode is useful for initialising the device. For actual values of data bytes for each function, refer to the datasheet of TDA7439. Similar protocol is followed for sending data to/from the microcontroller to MC24C02 EEPROM by using its chip address as ‘A0H’. Power supply. Fig. 3 shows the power supply circuit for the remotecontrolled digital audio processor. The AC mains is stepped down by transformer X1 to deliver a secondary outputof 9V AC at 1A. The transformer output is rectified by full-wave bridge rectifier BR1 and filtered by capacitor C42. Regulators IC8 and IC9 provide regulated 5V and 9V power supplies, respectively. IC10 acts as the variable power supplyregulator. It is set to provide 3V regulated supply by adjusting preset VR1. Capacitors C39, C40 and C41 bypass any ripple in the regula ted outputs.This supply is not used in the circuit. However, the readers can use the same for powering devices like a Walkman. As capacitors above 10 μF are connected to the outputs of regulator ICs, diodes D3 through D5 provide protection to the regulator ICs, respectively, in case their inputs short to ground. Relay RL1 is normally energised to provide mains to the power amplifier. In standby mode, it is de-energised. Switch S2 is the ‘on’/‘off’ switch.
Software
The software was assembled using Metalink’s ASM51 assembler, which is freely available for download. The source code has been extensively commented for easier understanding. It can be divided into the following segments in the order of listing:
1. Variable and constant definitions
2. Delay routines
3. IR decoding routines
4. Keyboard routines
5. TDA7439 communication
6. MC24C02 communication
7. I2C bus routines
8. Display routines
9. IR and key command processing
10. Timer 1 interrupt handler
11. Main program On reset, the microcontroller executes the main program as follows:
1. Initialise the microcontroller’s registers and random-access memory (RAM) locations.
2. Read Standby and Mute status from the EEPROM and initialise TDA7439 accordingly.
3. Read various audio parameters from the EEPROM and initialise the audio processor.
4. Initialise the display and LED port.
5. Loop infinitely as follows, waiting for events:
• Enable the interrupts.
• Check the monitor input for AC power-off. If the power goes off, jump to the power-off sequence routine.
• Else, if a new key is pressed, call the DO_KEY routine to process the key. For this, check whether the NEW_KEY bit is set. This bit is cleared after the command is processed.
• Else, if a new IR command is received, call the DO_COM routine to process the remote command. For this, check whether the NEW_COM (new IR command available) bit is set. This bit is cleared after the command is processed.
• Jump to the beginning of the loop.6. Power-off sequence. Save all the settings to the EEPROM, and turn off the display and standby relay. Since the output of the IR sensor is connected to pin 12 (INT0) of the microcontroller, an external interrupt occurs whenever a code is received. The algorithm for decoding the IR stream is completely implemented in the ‘external interrupt 0’ handler routine. This routine sets NEW_COM (02H in bit memory) if a new command is available. The decoded command byte is stored in ‘Command’ (location 021H in the internal RAM). The main routine checks for NEW_COM bit continuously in a loop. Timer 0 is exclusively used by this routine to determine the pulse timings. Decoding the IR stream involves the following steps:
1. Since every code is transmitted twice, reject the first by introducing a delay of 85 milliseconds (ms) and start timer 0. The second transmission is detected by checking for no-overflow timer 0. In all other cases, timer 0 will overflow.
2. For second transmission, check the timer 0 count to determine the length of the leader pulse (9 ms). If the pulse length is between 8.1 ms and 9.7 ms, it will be recognised as valid. Skip the following 4.5ms silence.
3. To detect the incoming bits, timer 0 is configured to use the strobe signal such that the counter runs between the interval periods of bits. The value of the counter is then used to determine whether the incoming bit is ‘0’, ‘1’ or ‘Stop.’ This is implemented in the RECEIVE_BIT routine.
4. If the first bit received is ‘Stop,’ repeat the last command by setting the NEW_COM bit.
5. Else, receive the rest seven bits.Compare the received byte with the custom code (C_Code). If these don’t match, return error.
6. Receive the next byte and compare with the custom code. If these don’t match, return error.
7. Receive the next byte and store in ‘Command.’
8. Receive the next byte and check whether it is complement value of ‘Command.’ Else, return error.
9. Receive ‘Stop’ bit.
10. Set NEW_COM and return from interrupt.
Other parts of the source code are relatively straightforward and self-explanatory. Remote control. The micro-controller can accept commands from any IR remote that uses NEC transmission format. These remote controllers are readily available in the market and use μPD6121, PT2221 or a compatible IC. Here, we’ve used Creative’s remote handset. All the functions of the system can be controlled fully using the remote or the on-board keys. By default, the display shows the volume setting and LEDs indicate the channel selected. LED9 glows momentarily whenever a command from the remote is received or any key is pressed. Function adjustments are detailed below:
1. Volume: Use Vol+/Vol- key to increase/decrease the volume. The volume settings are shown on the twodigit, 7-segment display. Steps can be varied between ‘1’ and ‘80.’
2. Mute and Standby: Using ‘Mute’ and ‘Standby’ buttons, you can toggle the mute and standby status, respectively. If ‘Mute’ is pressed, the display will show ‘00.’ In ‘Standby’ mode, the relay de-energises to switch off the main amplifier. All the LEDs and displays, except LED9, turn off to indicate the standby status.
3. Input Select: To select the audio input source, press ‘Channel’ key until the desired channel is selected. The LED corresponding to the selected channel turns on and the input gain setting for that channel is displayed for five seconds. Thereafter, the volume level is displayed on the 7-segment display.
4. Input Gain set: Press ‘Gain’ key. The LED corresponding to the channel will start blinking and the gain value is displayed. Use Vol+/Vol- key to increase/ decrease the gain for that channel. Note that the gain can be varied from ‘1’ to ‘15.’ If you press ‘Gain’ key once more, and no key is pressed for five seconds, it will exit the gain setting mode and the volume level is displayed.
5. Audio: Press ‘Audio Set’ (Menu) key to adjust bass, middle, treble and attenuation one by one. Each time ‘Audio Set’ key is pressed, the LED corresponding to the selected function turns on and the function value is displayed. Once the required function is selected, use Vol+ and Vol- to adjust the setting. Bass, middle and treble can be varied from ‘07’ to ‘7.’ Values ‘0’ through ‘7’ indicate ‘Boost’ and ‘00’ through ‘07’ indicate ‘Cut.’ Attenuation can be varied from ‘0’ to ‘40.’


COMPONENTS REQUIRED FOR REMOTE CONTROLLED DIGITAL AUDIO PROCESSOR


Semiconductors:
IC1 - AT89C51 microcontroller
IC2, IC3 - CD4543 7-segment decoder/
driver
IC4 - TDA7439 audio processor
IC5 - MC24C02 I2C EEPROM
IC6 - KA2281 2-channel level
meter driver
IC7 - TSOP1238 IR receiver
module
IC8 - 7809 9V regulator
IC9 - 7805 5V regulator
IC10 - LM317 variable regulator
T1 - BC558 pnp transistor
T2, T3, T5 - BC547 npn transistor
T4 - BD139 pnp transistor
BR1 - W04M bridge rectifier
D1-D6 - 1N4004 rectifier diode
DIS1, DIS2 - LTS543 7-segment display
DIS3 - 10-LED bargraph display
LED1-LED8 - Red LED
LED9 - Green LED
Resistors (all ¼-watt, ±5% carbon):
R1 - 8.2-kilo-ohm
R2-R24,
R40-R49 - 1-kilo-ohm
R25, R28,
R50, R53 - 10-kilo-ohm
R26, R29,
R30, R34 - 2.7-kilo-ohm
R27 - 100-ohm
R31, R35 - 5.6-kilo-ohm
R32, R33 - 4.7-kilo-ohm
R36-R39 - 22-kilo-ohm
R51 - 220-kilo-ohm
R52 - 2.2-kilo-ohm
Capacitors:
C1, C2 - 33pF ceramic disk
C3, C10 - 10μF, 16V electrolytic
C4-C6,
C39-C41 - 100nF ceramic disk
C7 - 4.7μF, 16V electrolytic
C8, C9 - 2.2μF, 16V electrolytic
C11, C20 - 5.6nF polyester
C12, C19 - 18nF polyester
C13, C18 - 22nF polyester
C14, C17 - 100nF polyester
C21-C28 - 0.47μF polyester
C29-C32 - 4.7μF, 25V electrolytic
C33, C34 - 10μF, 25V electrolytic
C35 - 1000μF, 25V electrolytic
C36 - 4700μF, 25V electrolytic
C37, C38 - 0.33μF ceramic disk
C42 - 470μF, 25V electrolytic
Miscellaneous:
X1 - 230V AC primary to 12V, 1A
secondary transformer
RL1 - 9V, 160Ω, 2 C/O relay
XTAL - 12MHz crystal
S1- S7 - Push-to-on switch
S8 - On/Off switch
Remote - Creative’s remote (NECcompatible
format)


PCB LAYOUT FOR REMOTE CONTROLLED DIGITAL AUDIO PROCESSOR




COMPONENT LAYOUT FOR REMOTE CONTROLLED DIGITAL AUDIO PROCESSOR




CONSTRUCTION

The circuit can be easily assembled on any PCB with IC base. Before you install the microcontroller, memory and audio processor in their sockets and solder the IR receiver module, make sure that the supply voltage is correct. All parts, except the audio processor (TDA7439), require 5V DC supply. The audio processor is powered by 9V DC.

Monday, March 15, 2010

Remotely Programmable RTC-Interfaced Microcontroller for Multiple Device Control





INTRODUCTION

This project based on Atmel AT89C52 and Dallas real-timeclock (RTC) chip DS12887 can be used to control and remotely program the switching operation of 24 electrically operated devices. The devices can be switched on/off at precise times repeatedly every day, every month. The microcontroller can be programmed for device control using a normal Philips TV remote control.

RC5 CODING

Since the circuit makes use of Philips TV remote for device-switching time parameters, you need to know the fundamentals of the coding format used
in these IR remotes.
The Philips IR format makes use of RC5 code, which is also known as ‘bi-phase coding.’ In RC5-coded signals (Fig. 2), each bit has a uniform duration. A transition in the middle of the time interval assigned to each bit
encodes its logical value (‘0’ or ‘1’). A high-to-low transition assigns the bit a logic value of ‘0,’ and a low-to-high transition assigns the bit a logic value of ‘1.’ We need additional transitions at the beginning of each bit if a stream of equal bits is sent. However, there is no need of additional transitions if the
next bit has a different logic value.Table II shows how all the commands of an RC5 remote control are encoded.
The first two bits are ‘start’ bits, which are used to adjust and synchronise the receiver. These bits are used to calculate and analyse the bit length of the other bits.
The third bit is a ‘toggle’ bit, which is toggled every time a button ispressed at the remote control. This bit is used to identify whether the button is really pressed or whether an obstacle came in between the IR path of the remote and the IR receiver.
The five bits (A4 through A0) immediately following the toggle bit are used to identify the device (see Table III). So, a maximum of 32 devices can be identified to and respond individually to the same type of coding without any disturbance, i.e., one among the 64 devices can be identified uniquely. Addresses of some of the remotes are shown in Table III.
The six bits (C5 through C0) immediately following the five address bits are the control/command bits. Therefore a maximum of 64 commands can be equipped in an RC5-type remote. Some of the command codes (decimal equivalents), as used in this project, are shown in Table IV. When any of the command/control buttons on the remote is pressed, the coded signal is received by the IR receiver-demodulator TSOP1738.
The output of the IR demodulator circuit is normally high, but when any of the buttons in the remote is pressed, a stream of low-going demodulated pulses will appear at its output. These pulses are fed to the external active-low interrupt input pin (INT/0) of 89C52. On receipt of the first low-going pulse, the monitor program of 89C52 will get interrupted and jump to the location ‘0003H,’ where the execution is redirected to ‘receive’ sub-routine of the
program. The outputs from the subroutineare:
1. Toggle bit, which toggles (either ‘0’ or ‘1’) each time the button in a remote is pressed.
2. Address byte, whose value is zero for a normal Philips-type TV remote control (see Table III).
3. Control byte, which has a unique value for each button in the remote control (see Table IV).

CIRCUIT DIAGRAM


THE HARDWARE


Microcontroller AT89C52 is interfaced to DS12887 (RTC), a 16x2 LCD mod-ule and an 8255 programmable peripheral interface (PPI). The address-decoding circuitry comprises NAND gates 74LS00 and 3-to-8 line decoder 74LS138 as shown in Fig. 1. The interfacing circuitry for the external electrical appliances comprises Darlington array IC ULN2803. The addressing range of various peripheral devices is shown in Table I. In 89C52 (IC1), port P0 is used for outputing multiplexed address (lower8-bit) and data. The address is latched into 74LS573 (IC2) octal latch and RTC DS12887 (IC3) with the help of ALE (address latch-enable) output from pin 30 of IC1. Only two address lines from IC2 (A0 and A1) have been used for addressing the four registers of 8255 PPI (IC6) in conjunction with the chipselect signal at pin 6 (from IC4) and read/write signals from IC1. Higher-address bits from port P2 of IC1 (A8, A9 and A10 from output pins P2.0, P2.1 and P2.2) are used for generating the chipselect signals from 74LS138 (IC4) cover INg address ranges 000H-0FFH, 100H-1FF and 200- 2FF for RTC, LCD module and PPI chip, respectively. Quad NAND gate 7400 (IC5) in conjunction with read and write signals from IC1 and chip-select signal from pin 14 of IC4 is used for selecting the LCD module both during read and write cycles of IC1. PPI chip 8255 is configured with port A, port B and port C as output ports for controlling up to 24 electrical appliances via relays RL1 through RL24. Relays are energised through high-current octal Darlington arraysconjunction with the chipselect signal at pin 6 (from IC4) and read/write signals from IC1. Higher-address bits from port P2 of IC1 (A8, A9 and A10 from output pins P2.0, P2.1 and P2.2) are used for generating the chipselect signals from 74LS138 (IC4) covering address ranges 000H-0FFH, 100H-1FF and 200- 2FF for RTC, LCD module and PPI chip, respectively. Quad NAND gate 7400 (IC5) in conjunction with read and write signals from IC1 and chip-select signal from pin 14 of IC4 is used for selecting the LCD odule both during read and write cycles of IC1. PPI chip 8255 is configured with Port A, port B and port C as output ports for controlling up to 24 electrical appliances via relays RL1 through RL24. Relays are energised through high-current octal Darlington arrays inside ULN2803 (IC7 through IC9) in accordance with programmed data stored in the non-volatile RAM (NV RAM) of RTC chip DS12887. There is no need of connecting external freewheeling diodes across relays as inbuilt diodes are provided in ULN2803 ICs. All the 24 devices/electrical appliances are considered as 24 bits (threebytes at locations 200H, 201H and 202H) of the three ports (ports A, B and C) of 8255. The LCD is used for displaying real time (year, month, date, day and time in 24-hour mode) obtained from RTC DS12887 as also some other information during time setting, device programming, searching (device- switching programmed data), password entry, etc, as described later. RTC DS12887 is clock-cum-calendar chip with 128 NV RAM (14 bytes used fo its control registers and 114 bytes as general-purpose RAM). It has an inbuilt lithium battery and can retain stored data for over ten years in the absence of external power. Memory map of DS12887 is shown in Table V. Data stored in location 07FH (decimal 127) indicates the address of the last RAM location used.The relay-switching data that is output from ports A, B and C of the PPI is stored as consecutive bits at 00EH, 00FH and 010H locations of the RAM. The relay/device programming timing data is stored at five consecutive locations for each device. This data includes month, date, hour and minute in first four bytes, while the fifth byte contains 5-bit address of the device with MSB indicating ‘on’/‘off’ status of the device. Bits 6 and 7 of this byte are ‘don’t care’ bits. Address locations 123 through 126 are used for storing the 4-byte long password. Thus only 106 locations are available for storing the 5-byte long device data and as such the program for a maximum of only 21 devices out of 24 devices can be stored. The remaining three devices can be switched on/off through remote key operation as explained below. Bit P1.1 output of IC1 is fed to transistor BC547 (T1) through R5. Transistor T1 acts like a switch for LCD backlight. So you can switch the backlight of LCD ‘on’/‘off’ just by setting/resetting the P1.1 bit of 89C52. Power supply (Fig. 3). While most of the circuit requires regulated 5V for its operation, the relays and Darlington drivers IC7 through IC9 (ULN2803) are oper-ated with unregulated 12V DC supply. A step-down transformer rated at 15V AC secondary voltage at 500 mA is used to supply 12V unregulated and 5V regulated power to the circuit. The secondary output is rectified by 1A rated bridge rectifier BR1 and smoothed by 1000μF, 35V capacitor C10. The output from the capacitor isdirectly fed to all the relays and ULN2803 ICs. The same output is used for regulation by 7805 (IC10). The ripple in the regulator output is filtered by capacitor C11. An actual-size, single-side PCB for the re otely-programmable RTC-interfaced microcontroller for multiple device control and power supply circuits (Figs 1 and 3) is shown in Fig. 4 and its component layout in Fig. 5. The connections for relays are to be extended from the 16-pin FRC connectors on the PCB. Each connector is meant for extending connections to eight relays. The author’s prototype is shown in Fig. 6.

Remote key operations

Refer Table IV for details of remote buttons/keys. The functions of these keys follow: Keys ‘0’ through ‘9’, ‘--’ and ‘sfx’. Used to switch on/off the 24 devices manually. Each time you press any of these buttons, the status of the corresponding device will toggle, i.e., its output will be the complement of the previous state. Button ‘--’ is used as ‘10+’ button. When it is pressed, the system waits for around three seconds before the next button (which should be between ‘0’ and ‘9’ to determine the device between ‘10’ and ‘19’) is pressed. Similarly, ‘sfx’ is used as ‘20+’ key. The button following the ‘sfx’ button should be between ‘0’ and ‘3’ (as the project supports only 24 electrical appliances numbering ‘0’ through ‘23’).RCL. Turns the LCD backlight ‘on’/‘off.’ PWR. Used to change the 4-digit password (initial value ‘0000’). When you press this button, the system will ask for the existing password. If the correct password is entered, it will ask for the new password. If a wrong password is entered, ‘invalid’ message will flash on the LCD. Note that the password can be any 4-digit value, which need not be the numbers from ‘0000’ to ‘9999.’ Other buttons representing various codes are also accepted. Timer. Used to change the real time. As the circuit operations depend on the real (set) time, changing the same is password-protected. A valid 4-digit password will let you change/set the time. When you press ‘timer’ button, the top row on the LCD defines the format ‘Hr:Mn:ScWkDyMnYr.’ You need to enter the valid data as follows: Hr: 00 to 23 (24-hour mode) Mn: 00 to 59 minutes Sc: 00 to 59 seconds Wk: 01 to 07 (01 is Sunday) Dy: 01 to 31 dates Mn: 01 to 12 (01 is January) Yr: 00 to 99 (year) Any value out of the range will not be accepted and message ‘invalid value’ will be displayed on the LCD. Store. Enables/disables the child lock function. You can lock the remote keypad by enabling the child lock. When you press this button, the system will prompt the message ‘Lock?’ or ‘UnLock?’ depending on the present status of the child lock. If ‘1’ is pressed, the child lock feature is enabled/disabled. Any button other than ‘1’ will be treated as zero. PP. Takes you to programming of a task. If the NV RAM is full in DS12887, the message ‘prog memory full’ will flash on the LCD. If the memory is not full, a new device program is accepted by displaying a message in the first line of the LCD as ‘Mn Dt Hr:Mn Dv S’ and a blinking cursor will appear on the second line to take the data. ‘Mn’ indicates ‘month’ (‘01’ to ‘12’), ‘Dt’ indicates ‘date’ (‘01’ to ‘31’), ‘Hr’ indicates ‘hours’ (‘00’ to ‘23’), ‘Mn’ indicates ‘minutes’ (‘00’ to ‘59’), ‘Dv’ indicates ‘device number’ (‘00’ to ‘23’) and ‘S’ stands for ‘programmed status’ (‘1’ for ‘on’ or ‘0’ for ‘off’). Enter the desired data in this format, which will get stored in the NV RAM of the RTC. If month (Mn) is entered as ‘00,’ the same task will repeat every month on the same date and time. If date (Dt) is entered as ‘00,’ the same task will repeat every day on the same time. Search. Shows the existing device programs that are stored in the memory starting from location 011H onwards one by one. Each time, you need to press CH+/CH- button to move forward/ backward. In this mode, you may delete the displayed device program data entry simply by pressing ‘Mute’ button. Then the program that is residing next to this task moves to the location of the deleted task and the whole memory is refreshed. See the example shown above for clarity. The pointer value in memory location 007FH of DS12887 changes accordingly. AC. Deletes the entire programmed data in one stroke. So use this key very cautiously.

PCB LAYOUT FOR MULTIDEVICE CONTROL


Cellphone Operated Land Rover




INTRODUCTION

Conventionally, wireless-controlled robots use RF circuits,which have the drawbacks of limited working range, limited frequency range and limited control. Use of a mobile phone for robotic control can overcome these limitations. It provides the advantages of robust control, working range as large as the coverage area of the service provider,no interference with other controllers and up to twelve controls.Although the appearance and capabilities of robots vary vastly, all robots share the features of a mechanical, movable structure under some form of control. The control of robot involves three distinct phases: reception, processing and action. Generally, the preceptors are sensors mounted on the robot, processing is done by the on-board microcontroller or processor, and the task (action) is performed using motors or with some other actuators.


PROJECT OVERVIEW

In this project, the robot is controlled by a mobile phone that makes a call to the mobile phone attached to the robot. In the course of a call, if any button is pressed,a tone corresponding to the button pressed is heard at the other end of the call. This tone is called ‘dual-tone multiple-frequency’ (DTMF) tone. The robot perceives this DTMF tone with the help of the phone stacked in the robot. The received tone is processed by the ATmega16 microcontroller with the help of DTMF decoder MT8870. The decoder decodes the DTMF tone into its equivalent binary digit and this binary number is sent to the microcontroller.The microcontroller is preprogrammed to take a decision for any given input and outputs its decision to motor drivers in order to drive the motors for forward or backward motion or a turn. The mobile that makes a call to the mobile phone stacked in the robot acts as a remote. So this simple robotic project does not require the construction of receiver and transmitter units. DTMF signaling is used fr telephone signaling over the line in the voice-frequency band to the call switching centre. The version of DTMF used for telephone tone dialing is known as ‘Touch-Tone.’DTMF assigns a specific frequency (consisting of two separatetones) to each key so that it can easily be identified by the electronic circuit. The signal generated by the DTMF encoder is a direct algebraic summation, in real time, of the amplitudes of two sine (cosine)waves of different frequencies, i.e., pressing ‘5’ will send a tone made by adding 1336 Hz and 770 Hz to the other end of the line. The tones and assignments in a DTMF system are shown in Table I.


SCEMATIC OF CELLPHONE OPERATED LANDROVER


CIRCUIT DESCRIPTION

Fig. 1 shows the block diagram of the microcontroller-based mobile phoneoperated land rover. The important components of this rover are a DTMF decoder, microcontroller and motor driver. An MT8870 series DTMF decoder is used here. All types of the MT8870 series use digital counting techniques to detect and decode all the 16 DTMF tone pairs into a 4-bit code output. The built-in dial tone rejection circuit eliminates the need for pre-filtering. When the input signal given at pin 2 (IN-) in single-ended input configuration is recognised to be effective, the correct 4-bit decode signal of the DTMF tone is transferred to Q1 (pin 11) through Q4 (pin 14) outputs. Table II shows the DTMF data output table of MT8870. Q1 through Q4 outputs of the DTMF decoder (IC1) are connected to port pins PA0 through PA3 of ATmega16 microcontroller (IC2) after inversion by N1 through N4,respectively. The ATmega16 is a low-power, 8-bit, CMOS microcontroller based on the AVR enhanced RISC architecture. It provides the following features: 16 kB of in-system programmable Flash program memory with read-while-write capabilities, 512 bytes of EEPROM, 1kB SRAM, 32 general-purpose input/output (I/O) lines and 32 general-purpose working registers. All the 32 registers re directly connected to the arithmetic logic unit, allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code-efficient. Outputs from port pins PD0 through PD3 and PD7 of the microcontroller are fed to inputs IN1 through IN4 and enable pins (EN1 and EN2) of motor driver L293D, espectively, to drive two geared DC motors. Switch S1 is used for manual reset. The microcontroller output is not sufficient to drive the DC motors, so current drivers are required for motor rotation. The L293D is a quad, high-current, half-H driver designed to provide bidirectional drive currents of up to 600 mA at voltages from 4.5V to 36V. It makes it easier to drive the DC motors. The L293D consists of four drivers. Pin IN1 through IN4 and OUT1 through OUT4 are input and output pins, respectively, of driver 1 through driver 4. Drivers 1 and 2, and drivers 3 and 4 are enabled by enable pin 1 (EN1) and pin 9 (EN2), respectively. When enable input EN1 (pin 1) is high, drivers 1 and 2 are enabled and the outputs corresponding to their inputs are active. Similarly, enable input EN2 (pin 9) enables drivers 3 and 4. An actual-size, single-side PCB for cellphone-operated land rover is shown in Fig. 4 and its component layout in Fig. 5.

PCB LAYOUT FOR CELLPHONE OPERATED LANDROVER



SOFTWARE DESCRIPTION

The software is written in ‘C’ language and compiled using CodeVision AVR ‘C’ compiler. The source program is ed into hex code by the compiler. Burn this hex code into ATmega16 AVR microcontroller.The source program is well commented and easy to understand. First include the register name defined specifically for ATmega16 and also declare the variable. Set port A as the input and port D as the output. The program
will run forever by using ‘while’ loop. Under ‘while’ loop, read port A and test the received input using ‘switch’ statement. The corresponding data will output at port D after testing of the received data.

WORKING

In order to control the robot, you need to make a call to the cell phone attached to the robot (through head phone) from any phone, which sends DTMF tunes on pressing the numeric buttons. The cell phone in the robot is kept in ‘auto answer’ mode. (If the mobile does not have the auto answering facility, receive the call by ‘OK’ key on the rover-connected mobile and then made it in hands-free mode.) So after a ring, the cellphone accepts the call. Now you may press any button on your mobile to perform actions as listed in Table III. The DTMF tones thus produced are received by the cellphone in the robot. These tones are fed to the circuit by the headset of the
cellphone. The MT8870 decodes the received tone and sends the equivalent binary number to the microcontroller. According to the program in the microcontroller, the robot starts moving.When you press key ‘2’ (binary equivalent 00000010) on your mobile phone, the microcontroller outputs ‘10001001’ binary equivalent. Port pins PD0, PD3 and PD7 are high. The high output at PD7 of the microcontroller drives the motor driver (L293D). Port pins PD0 and PD3 drive motors M1 and M2 in forward direction (as per Table III). Similarly, motors M1 and M2 move for left turn, right turn, backward motion and stop condition as per Table III.

CONSTRUCTION

When constructing any robot, one major mechanical constraint is the number there a two-wheel drive or a four-wheel ive. Though four-wheel drive is more complex than two-wheel drive, it provides more torque and good control. Two-wheel drive, on the other hand, is very easy to construct. Top view of a four-wheel-driven land rover is shown in Fig. 3. The chassis used in this model is a 10×18cm2 sheet made up of parax. Motors are fixed to the bottom of this sheet and the circuit is affixed firmly on top of the sheet. A cellphone is also mounted on the sheet as shown in the picture. In the four-wheel drive system, the two motors on a side are controlled in parallel. So a single L293D driver IC can drive the rover. For this robot, beads affixed with glue act as support wheels.



PROGRAM FOR CELLPHONE OPERATED LANDROVER

Source program:
Robit.c
#include
void main(void)
{
unsigned int k, h;
DDRA=0x00;
DDRD=0XFF;
while (1)
{
k =~PINA;
h=k & 0x0F;
switch (h)
{
case 0x02: //if I/P is 0x02
{
PORTD=0x89;//O/P 0x89 ie Forward
break;
}
case 0x08: //if I/P is 0x08
{
PORTD=0x86; //O/P 0x86 ie Backward
break;
}
case 0x04:
{
PORTD=0x85; // Left turn
break;
case 0x06:
{
PORTD=0x8A; // Right turn
break;
}
case 0x05:
{
PORTD=0x00; // Stop
break;
}
}
}
}

Saturday, March 6, 2010

HOME AUTOMATION CONTROL SYSTEM USING DTMF TELEPHONE LINE





INTRODUCTION


INTRODUCTION OF THE PROJECT

How this project is different from other home automation control system?

Controlling device using switches are common. From a few decades controlling devices using remote control switches like infrared remote control switch, wireless remote control switches, light activated switches are becoming popular. But these technologies have their own limitations. Laser beams are harmful to mankind.

Some technologies like IR remote control are used for short distance applications. In such case if we have system which does not require any radiations or which is not harmful, long remote control switch!! Yes here is the solution. Here I am introducing such a system which does not require any radiations, any laser beam which has no limitation of range, I mean it can be used from any distance from meters to thousands kilometers using a simple telephone line or mobile phone.

Here I am using a telephone as a media, which serves main part of this system, by using home phone as a local phone and another phone, either landline or mobile phone as a remote phone.

The “Home Automation Control System Using DTMF Telephone Line” project is a secure DTMF control system for intelligent houses.

With this implemented system, it is possible to safely control electricity operated domestic devices.


FEATURES

1. We can control up to 8 devices. It may be any electric or electronic appliances or devices with simple to heavy appliance. Each device is given a unique code.
2. It makes accurate switching, any false switching of device are not done so there is no risk for false switching.
3. Our local phone can be used for normal use by using a DPDT switch. So we need not use a separate telephone line for this device controlling.
4. To perform any operations through remote phone line, the user needs to dial to the local telephone then the respective code of the device is dialed.
5. This circuit not require any complex IC, so any one with little knowledge of electronics can construct this circuit, because it does not need any programmable IC’s or programming.
6. This system detects the ringing signal from your exchange with the help of ring detector and automatically switches ON.
7. This device saves our money. This circuit switches OFF after a time of 60 seconds.
8. Before changing the state of the device we can confirm the present status of the device.
9. This circuit gives an acknowledgement tone after switching ON the devices to confirm the status of the device.
10. We can control devices from any local telephone. It can also be controlled by PCO.

TAKING A TOUR OF PROJECT
This system uses Dual Tone Multi Frequency (DTMF) technology of our telephone set. Every telephone set will have this facility. We have two type of dialing facilities in our telephone system (1)pulse dialing mode (2) tone dialing mode. Here this system works on tone dialing mode. The DTMF mode is shortly called as tone dialing mode.
This system is divided into two sections.
1: Remote section
2: Local control section.



What is DTMF?

When you press a button in the telephone set keypad, a connection is made that generates a resultant signal of two tones at the same time.
This two tones are taken from a row frequency and a column frequency. The resultant frequency signal is called a “Dual Tone Multiple Frequency “.
These tones are identical and unique.
A DTMF signal is the algebraic sum of two different audio frequencies, and can be expressed as follows:
f(t) = A0sin(2*?*fa*t)+B0sin(2*?*fb*t)+…--- > (1)
Where fa and fb are two different audio frequencies with A and B as their peak amplitude and f as the resultant DTMF signal.
fa belongs to the low frequency group and fb belongs to the high frequency group.
Each of the low and high frequency groups comprise four frequencies from the various keys present on the telephone keypad; two different frequencies, one from the high frequency group and another from the low frequency group are used to produce a DTMF signal to represent the pressed key.
The amplitudes of the two sine waves should be such that
(0.7<(A\B)<0.9)v> (2)
The frequencies are chooses such that they are not the harmonics of each other. The frequencies associated with various keys on the keypad are shown in figure(A).
When you send this DTMF signals to the telephone exchange through cables, the servers in the telephone exchange identifies these signals and makes the connection to the person you are calling.

CIRCUIT DIAGRAM

RELAY DRIVER CIRCUIT



DESCRIPTION

The brain of the switcher is the Atmel AT89xxx micro controller U3. Incoming ring is detected via C10, D9, R16 and the opto- coupler U6 and connected to pin 12 of the micro controller.

The incoming call is answered by connecting the circuit based around Q1 and R4 (an electronic holding coil) to the line. One output from micro controller (pin 13) is used to output a 325Hz software generated tone into the telephone line via the Q2, This tone is used to signal the user when commands have been completed or of any command errors.

The micro controller examines incoming signals on port 1 (P1.0 - P1.4) and controls the outputs over port 0 (P0.0 - P0.7).

Connection to the telephone network is via RJ11 connector K2. Socket K3 is connected in parallel with socket K2 and allows a telephone to be connected at the same time as the circuit. A voltage-dependent resistor (visitor) is connected across these two sockets, which provides protection against voltages in excess of 130 V.

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM).

The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry- standard MCS-51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer.

By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.


DTMF DECODER INTERFACE


DTMF detection and decoding is provided by U5. This chip, an 8870, is a complete DTMF receiver, which is able to detect and decode all 16 DTMF tone pairs into a 4-bit code. When a valid DTMF digit is detected the 4-bit code is placed on pins 11-14 and a 'data available' output, pin 15, is set to logic high. It is connected to the telephone line via C2 and R9 and R14 a hexadecimal value corresponding to the two tones at its outputs Q1 to Q4.

These outputs are latched and so are only valid when the control output STD is high. For its operation the integrated circuit requires a base of times, generated in this case by the quartz crystal of 3.579545MHz. This crystal is very common in the market since he is the employee for the systems of color of the TV equipment