• No results found

Remote-controlled Real-time Clock With Device Controller

N/A
N/A
Protected

Academic year: 2021

Share "Remote-controlled Real-time Clock With Device Controller"

Copied!
80
0
0

Loading.... (view fulltext now)

Full text

(1)

REMOTE-CONTROLLED REAL-TIME CLOCK WITH DEVICE CONTROLLER\

ABSRACT :-

This project makes use of a TV remote control. Using RC5 coding, a real-time clock chip is

set to control five different alarm settings. These settings can also be used to switch on an

external device. Up to eight devices can be controlled with this project. The circuit is based

on ATMEL ATmega16 microcontroller and Maxim‘s DS1307 real-time clock chip. An LCD

module allows for user interface.

(2)

CIRCUIT DESCRIPTION

Fig. 1 shows the block diagram of the remote-controlled real-time clock with device

controller. It comprises six sections, namely, IR detector remote control sensing and

decoding unit, realtime clock, LCD interface, device switching unit, microcontroller and

power supply unit The microcontroller unit integrates all the sub-systems and system

software the circuit of the device controller.

REMOTE CONTROL SECTION.

This circuit makes use of a Philips TV remote for device switching and RTC parameter

setting. It uses RC5 coding format, which is also known as ‗biphase coding.‘ In RC5-coded

signal, each bit has a uniform duration. Table I shows how all the commands of RC5 remote

control are encoded. The first two bits designated ‗S‘ are ‗start‘ bits, which are used to adjust

and synchronise the receiver. These bits are used to calculate and analyse the bit length of

other bits. The third bit is a ‗toggle‘ bit (T), which toggles every time a button is pressed at

the remote control. This bit is used to identify whether the button is really pressed or whether

(3)

an obstacle came in between the path of the IR remote and IR receiver. Bits A4 down to A0

are used to identify the device. So a maximum of 32 devices can be interrogated to respond

individually to the same type of coding without any disturbance. Bits C5 down to C0 are

control/command bits. Therefore a maximum of 64 commands can be equipped in an RC5

type remote. Decimal equivalent of a few command codes used in this project are listed at

Table II. Pressing any command/ control button on the remote generates code signal, which

is received by IR receiver-demodulator (TSOP1738). The output of the IR demodulator is

normally high, which changes to low when any of the buttons on the remote is pressed. It is

fed to PD3 through the I/O interface line of the microcontroller. The microcontroller decodes

the incoming RC5 data stream and subsequent actions are taken based on the this

information.

LCD UNIT. The LCD module (16- character×2-line) is interfaced with the microcontroller.

Data pins 7 through 14 of the LCD module are connected to port A (PA0 through PA7) of the

microcontroller. Register-select (RS) pin 4 and enable pin (pin 6) of the LCD are interfaced

with PC1 and PC2 of the microcontroller, respectively. R/W pin of the LCD (pin 5) is pulled

low permanently and thus is always in writing mode. Back light of the LCD is controlled by

PD0 line of the microcontroller with the help of transistor T1. All the information is

displayed on the LCD, which forms the basic user interface unit.

Real-time clock. IC DS1307 (IC2) from Maxim (Dallas Semiconductor) is a serial RTC chip

with calendar function. This chip also incorporates 56 bytes of NV RAM. Data and address

are transferred serially through I2C bidirectional bus, which obviates the need for a large

number of interface lines. The bidirectional data is read and written with the help of just two

I/O interface lines. In this chip, the clock operates in either 24- or 12-hour format with

AM/PM indicator. In calendar mode, end of the month is automatically adjusted for the

months with less than 31 days and leap year compensation is valid up to year 2100. The

memory map of DS1307 (also referred toas ‗time keeper register map‘) is shown in Table III.

For setting the clock and calendar at power- ‘on,‘ the data is first written to the designated

memory location of the RTC chip and, during the normal operation. It is read back from each

specific memory location during the clock and calendar display functions. The alarm settings

are stored in NV RAM; these can be deleted and altered at any given point of the operation.

All this is achieved with the help of the system software. In the project, only five alarms have

been allowed but the same can be changed as per requirement; only the alarm limits have to

be changed. Clock pulse to the RTC is provided by a 32.768kHz crystal. As per the

convention of I2C interface communication, the device address while writing into DS1307

chip is 0xD0 (in binary format 11010000) and while reading the data from DS1307 the

device address is 0xD1 (in binary format 11010001). Due to this unique device addressing

technique, a number of I2Cinterfaced chips can be attached on SCL and SDA interface lines

of RTC. Thus, at a given time, only one I2C device will respond to the data on the I/ O

interface lines.

DEVICE CONTROL. Devices are connected to contacts of the relay and relays are

controlled through the outputs of IC4. Port B of IC1 (PB0 through PB7) is interfaced with

pin 8 down to pin 1 of IC4 (ULN2803) to control relays RL1 through RL8, respectively. Five

out of eight devices (device 1 through 5) switch on with their respective alarm settings and

the remaining three devices switch on directly. Whenever an alarm is activated for a

particular setting, the respective de vice is switched on. The device can be switched off only

by pressing the respective key number on the remote control.

CONTROLLER. The controller unit is based on ATmega16 low-power, 8-bit CMOS

micro-controller with AVR enhanced RISC architecture. This micromicro-controller has 16 kB of

in-system programmable flash memory, 512 bytes on EEPROM, 1 kB of SRAM, two 8-bit

timers, one 16-bit timer, 32 general-purpose I/O lines and 32 general-purpose working

registers. It integrates all the subsystems to form a complete unit. Although this

(4)

microcontroller already has an RTC counter and I2C lines, we have used a separate RTC chip

and special I2C software to show the functionality with the dedicated RTC chip, which is

much easier to control and manage in terms of time keeping as well as achieving calendar

functions. Regarding I2C, we wanted to show how the same can be achieved with the help of

the software without alarm limits have to be changed. Clock pulse to the RTC is provided by

a 32.768kHz crystal. As per the convention of I2C interface communication, the device

address while writing into DS1307 chip is 0xD0 (in binary format 11010000) and while

reading the data from DS1307 the device address is 0xD1 (in binary format 11010001). Due

to this unique device ddressing technique, a number of I2Cinterfaced chips can be attached

on SCL and SDA interface lines of RTC. Thus, at a given time, only one I2C device will

respond to the data on the I/O interface lines.

DEVICE CONTROL. Devices are connected

to contacts of the relay and relays are controlled through the outputs of IC4. Port B of IC1

(PB0 through PB7) is interfaced with pin 8 down to pin 1 of IC4 (ULN2803) to control

relays RL1 through RL8, respectively. Five out of eight devices (device 1 through 5) switch

on with their respective alarm settings and the remaining three devices switch on directly.

Whenever an alarm is activated for a particular setting, the respective dethe use of any

specialised hardware functionality of the microcontroller; and also help the user to implement

the same on any other microcontroller that does not have the dedicated facility of I2C

interface. This controller unit first uses serial data received from the IR detector to get the

information regarding the pressed key and then takes the appropriate action, and also updates

the information on the LCD side-by-side. When in operational mode, the microcontroller

reads the data from the RTC chip every one second (achieved through timer

interrupts-compare mode). During this 1-second interrupt, it checks for the alarm setting, controls the

snooze, and also updates the time/ date information on the LCD. In between, it checks the

data from the IR detector and takes action accordingly.

POWER SUPPLY. Fig. 3 shows the

power supply circuit. The 230V, 50HzAC mains power supply is stepped down by

transformer X1 to deliver a secondary output of 15V at 500 mA.The transformer output is

rectified by a full-wave bridge rectifier BR1, filtered by capacitor C6, and regulated by IC5

and IC6. IC5 and IC6 output is 5V and 12V, respectively. The regulated 12V is used for

relay-driver IC4 and the rest of the circuit operates with 5V. Capacitors C7 and C8 bypass

any ripple present in the regulated power supply. An actual-size, single-side PCB pattern for

the remote-controlled real-tim clock with device controller (Fig. 2 and Fig. 3) is shown in

Fig. 8 and its component layout in Fig. 9.

(5)

Circuit of remote-controlled real-time clock with device controller

Power supply

(6)

Actual-size, single-side PCB for the remote-controlled real-time clock with device

controller

(7)

(8)

The system software is used to achieve integration and functionality. The software for this

project is written in ‗C‘ language and compiled using WINAVR. WINAVR is available free

of cost for Windows and Linux operating systems. It is capable of handling all the AVR

functionalities like UART, timer, ADC, interrupts, etc and offers the facility of writing the

program in C.‘ The finally obtained Intel hex code file was burnt into AVR‘s flash memory

using a suitable programmer. The microcontroller uses a 4MHz internally generated clock.

To activate, fuse bytes have to be programmed as follows: Fuse low byte = D3 Fuse high

byte = 99 The software for the entire project was written in modules in accordance with the

functionality of each subsystem. The files used in this project are shown in Table IV. The

ds1307.c file contains the codefor controlling the functions related to serial DS1307 RTC.

The chip uses I2C interface, which essentially uses only two I/O interface lines—SDA and

SCL—for bidirectional address and data communication. This file essentially uses

sub-routines, which have been indicated in the I2Cmaster.h header file. Subroutines i2c_write( )

and i2c_read( ) are used for writing and reading the data to and from the RTC chip through

DS1307_write( ) and DS1307_read( ), respectively. The Assembly code for the complete I2C

operations and communication is written in the I2Cmaster.S file, which has been written for

4.00MHz operation, and for this reason, the microcontroller‘s fuses have been set to use the

internal 4.00MHz clock. The data stored in the RTC chip is in BCD format. The BCD data is

changed into binary format for normal processing and displaying. For this purpose, the

BCD2bin( ) subroutine is used. Similarly, the user data is first converted into BCD format

with bin2BCD( ) sub-routine and then written into the RTC chip. This file contains all the

sub-routines that are used in rclock.c file modules. I2C-interfaced chips are initiated in a

particular sequence for their proper functioning, and this has been taken care of during

initialisation and reading/ writing data from/to DS1307. The user alarm settings are stored in

the NV RAM of DS1307 in two fields, namely, hours and minutes. In this project, a

maximum of five alarm settings have been allowed but this number can be increased by

changing the variable MAX_ALARM value (in lcd.h file). Whenever the alarm setting data

is to be viewed, altered, deleted or added, the program checks the user SRAM area, and

based on the value stored in the ALARM_COUNT_RGST

memory location, further action is permitted. While clock is functioning, the data from this

SRAM area, which has now been allocated to an array, is checked and the desired action is

taken when the alarm setting data matches the current time.

I2CMASTER.S AND I2CMASTER.H. These files are related to control of the I2C interface

communication. The details of the SCL and SDA pins and I/O interface line are defined in

the i2cmaster.s file and the Assembly code file is compiled along with other code files; the

parameter to be used in ‗makefile‘ for this file is ASRC. Lcd.C This file contains the code for

control of functioning of the attached LCD module. The code controls the initialisation of the

LCD, data writing on the LCD, and also the movement, characteristics and location of the

cursor. It offers the facility to write data on the LCD character-by-character or string-wise.

The command set used in the software is based on the command set used in the LCD based

on Hitachi HD44780 ICs. Lcd.H This header file contains all the constant variable values and

names of the subroutines used by various files used in the software. It clearly indicates

which variable can be used as a global variable and which of the subroutines can be used

across the software files.

RCLOCK.C This file contains the code that integrates all the subunits together. It contains

the code that will call the initialisation routines to initialise I2C chip, LCD, microcontroller

ports, set timer and its IRQ, check data from the IR detector, extract information regarding

the key pressed, etc. Depending upon the key pressed, the file initiates the change in RTC

data like year, month, day, date, hours and minutes and also in viewing, deleting and adding

new alarm settings. It takes control of the devices attached to the unit and controls their status

depending upon the alarm settings. All the above-mentioned functions are implemented in

this file by means of specific implementation of sub-routines and global variables wherever

required. All the sub routines used in the various files are clearly marked and commented for

their functionalities with codes explained. The entire project software was compiled and

(9)

debugged with WINAVR development environment, which is based on avr-gcc 3.3.1

(WinAVR-20030913).

REMOTE CONTROL OPERATION

The entire device operation is controlled through keys of the Philips remote control. The

remote keys are used as shown in Table II. The functions of these keys are given below. Key

0 is used to change the setting of the RTC. When the RTC is functioning normally, it can be

switched to setting mode by pressing the ‗0‘ key and immediately the cursor will blink on the

hour field, indicating that this value can be changed through ‗volume up‘ and ‗volume down‘

keys to a desired value. Keys 1 through 8 are used, during normal operation, to control the

state of the external devices. Key 1 is used to control Device 1 and so on. Devices 1 through

5 are switched on according to the alarm timing also; however, these can be switched off by

pressing the respective key on the remote control itself. Keys 1 through 3 are also used in the

Alarm menu. Key 1 is used to add a new alarm value to the alarm table. Key 2 is used to

delete the alarm setting for the table (by changing Yes/ No field with volume up/down key).

Key 3 is used to scroll through the alarm settings by use of channel up and down keys. Power

key is used for deactivating the alarm and also returning one setup back in the Alarm menu.

Whenever you want to return from the Alarm‘s sub-menu (like New, Del and See), press this

key. Also, this key is used to return from the Alarm menu to display screen. Mute key is used

to change the field (from hour to minute to day of the week to day of the month to month of

the year and, finally, the year and back to hour and so on and so forth). Volume Up and

Down keys are used to change the value of a given field when setting the clock data or the

alarm data. TV/AV key starts the RTC functioning once the desired settings have been made.

This remote control key acts as ‗Enter‘ key (confirmation key). Timer key takes the user to

alarm setting menu.

CLOCK MODE SETTING

When the RTC is switched on, the screen display is as shown in Fig. 4. The second field

value shows 40 seconds. These indicated initial values have been set in subroutine

i2c_initialisation( ). If some other values are required, the desired values can be written. The

cursor blinking on the hour field indicates that value can be changed through volume up and

down key—which will now change the hour value from ‗0‘ to ‗23‘ hours and back to ‗0‘

again Once the desired value of the hour has been achieved, you can change to minute field

by pressing ‗Mute‘ key. The change of field is indicated by cursor blinking on the

appropriate field (here minute field). Value of minutes can be changed from ‗0‘ to ‗59‘ and

again to ‗0.‘ Again, after the desired value has been achieved, the field can be changed to

week day by pressing ‗Mute‘ key. Now week days can be changed by pressing volume up

and down keys. Next field-change data is related to day of the month (the date can be

changed from ‗1‘ to ‗31‘) and after this, the month of the year can be changed (from January

to December). The year can be changed from ‗00‘ to ‗99‘. Take care when setting the month

and the days in that particular month. The process remains the same when setting the alarm

value also, where only hour and minute fields are available for setting. Once the setting has

been made as per the requirement, TV/AV key can be set and now the clock will start

functioning with the desired settings. The functioning of the clock can be observed by

change in the second field.

ALARM SETTING

As explained earlier, the given design allows five alarm settings with snooze facility and

control of five devices only. You can enter the alarm menu by pressing ‗Timer‘ key. The

screen at this point of operation is shown in Fig. 5. Through this menu, you can set new

alarm (1New), delete alarm setting (2Del) and view alarm settings (3See). The respective

menu can be activated by pressing key 1, 2 or 3. In new setting mode, if five alarm settings

have been made, the same is indicated by a ‗Full‘ sign. In case new setting has to be made, an

already exisiting alarm setting has to be deleted and then only new alarm setting will be

(10)

allowed. To return from ‗New‘ mode to ‗Alarm‘ menu, press ‗Power‘ key. If space is

available for new alarm setting, you can change hour-field data and minute-field data by

using ‗Volume Up,‘ ‗Volume Down‘ and ‗Field‘ keys, i.e., ‗Mute‘ key. Once the desired

settings have been made, pressing the ‗TV/AV‘ key stores the alarm settings in the NV RAM

of the DS1307 chip. To delete an alarm setting, first press key ‗2.‘ The display will be as

shown in Fig. 6.The alarm settings/values can be scrolled with the help of ‗Channel Up‘ and

‗Channel Down‘ keys. For a setting that is to be deleted, change the status of the indicator

from ‗No‘ to ‗Yes‘ by ‗Volume Up‘ and ‗Volume Down‘ keys. Then delete data by pressing

‗TV/ AV‘ key and immediately the message ‗Deleting Data‘ is displayed, indicating that one

alarm setting has been deleted. To view the alarm setting data, you

can use key ‗3‘ in ‗Alarm‘ menu. The screen at this point will be as shown in Fig. 7, which

indicates the total number of alarm settings in the memory (Tot:) and data being viewed. You

can scroll through the data with the help of Channel Up/Down key. As you scroll though the

data, the field ‗Data:‘ indicates the alarm setting as per the programmed sequence. The

device-control field number will be the same as ‗Data:‘ field number. (If ‗Data:5,‘ the device

to be controlled will be ‗5,‘ and if ‗Data:1‘ device 1 is attatched with this data field.) If no

alarm data is found in the memory, ‗No Alarm Data‘ is shown on the LCD. In ‗New‘ and

‗Del‘ sub-menus of ‗Alarm‘ menu, ‗TV/AV‘ key is used to confirm the desired

setting/action. To cancel settings/actions, press ‗Power‘ key at any time of the operation. By

default, all the five alarm settings have been made initially through the software. These

values can be

changed in sub-routine dummy( ) found in the ds1307.c file. As soon as the alarm is

activated, the LCD backlight glows periodically along with the buzzer sound. Deactivate the

alarm with ‗Power‘ key; however, the respective-controlled device will continue to be ‗on.‘

The alarm can be put into snooze mode by pressing any key on the remote control. In snooze

mode, the buzzer will not sound but LCD backlight will glow. The snooze delay can be

changed by setting the constant snooze_delay variable (in the lcd.h file) to a desired value.

No doubt the alarm time can be set in any sequence; the external device will switch on in a

sorted time sequence. For example, if the alarm time is ‘01:21' at location-3 and ‘01:10' at

location-5, device-5 will switch on at ‘01:10' and device-3 will switch on only at ‘01:21,‘

even though in the alarm sequence the location of device- 3 is before device-5. When the

clock is switched on, all the controlled external devices are in switched-off condition. In

snooze mode, the alarm can be de-activated by pressing ‗Power‘ key. All the external devices

can be switched off simultaneously by pressing S1. This will work only in normal

functioning of the device and not during the alarm mode. The project was assembled on a

general-purpose PCB.

(11)
(12)

CKT DIAGRAM

4 17 7 13 R12 2.2k Y 1 CRY STAL 23 Q2 SL100 U4 ATmega16 9 18 19 20 31 40 23 24 10 11 14 15 17 1 2 3 4 5 6 7 8 39 38 37 36 35 34 33 22 R ESET pd4 pd5 Pd6 31 pa0 PC1(sda) PC2(tck) vcc 11 pd0 pd1 17 PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 pa1 pa2 pa3 pa4 pa5 pa6 pa7 PC0 R10 50 R3 10k R4 2.2k R5 220 5v 16 5v R6 10k 3 + C1 1u/16v J2 I RX TSOP1738 1 2 3 R1 10k R2 10k SW1 SW TACT-SPST 1 2 U8 DS1307 4 5 1 2 6 3 8 GND SDA X1 X2 SCLK VBAT VC C 12 R9 10k 6 5v 5v Q1 SL100 J3 buzzer 1 2 24 2 15 1 C5 20uF/25v 11 5v 5 18 8 14 lcd

<Doc> <Rev Code> <Title>

A

1 1

Friday , March 28, 2008 Title

Size Document Number Rev

Date: Sheet of

R11 120

(13)

2

5

8

<Doc> <Rev Code>

<Title>

A

1 1

Friday , March 28, 2008 Title

Size Document Number Rev

Date: Sheet of lcd 4 1 7 5v 23 J1 CON16 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 3 R8 POT 1 3 2 6 24

(14)

U10 LM7812/TO 1 2 3 VIN GN D VOUT J6 CON2 1 2 12v D3 DIODE C3 0.1u 1 2 D2 LED 5v R14 100 J4 CON2 1 2 12v

<Doc> <Rev Code> <Title>

A

1 1

Friday , March 28, 2008 Title

Size Document Number Rev

Date: Sheet of U9 LM7805/TO 1 2 3 VIN GN D VOUT

(15)

INTERFACING

SECTION

(16)

MICROCONTROLLER (AT89S52):-

CRITERIA FOR CHOOSING A MICROCONTROLLER

The basic criteria for choosing a microcontroller suitable for the application are:

1) The first and foremost criterion is that it must meet the task at hand efficiently and cost

effectively. In analyzing the needs of a microcontroller-based project, it is seen whether an 8-

bit, 16-bit or 32-bit microcontroller can best handle the computing needs of the task most

effectively. Among the other considerations in this category are:

(a) Speed: The highest speed that the microcontroller supports.

(b) Packaging: It may be a 40-pin DIP (dual inline package) or a QFP (quad flat

package), or some other packaging format. This is important in terms of space,

assembling, and prototyping the end product.

(c) Power consumption: This is especially critical for battery-powered products.

(d) The number of I/O pins and the timer on the chip.

(f) How easy it is to upgrade to higher –performance or lower consumption versions.

(g) Cost per unit: This is important in terms of the final cost of the product in which

a microcontroller is used.

2) The second criterion in choosing a microcontroller is how easy it is to develop products

around it. Key considerations include the availability of an assembler, debugger, compiler,

technical support.

3) The third criterion in choosing a microcontroller is its ready availability in needed

quantities both now and in the future. Currently of the leading 8-bit microcontrollers, the

8051 family has the largest number of diversified suppliers. By supplier is meant a producer

besides the originator of the microcontroller. In the case of the 8051, this has originated by

Intel several companies also currently producing the 8051.

Thus the microcontroller AT89S52, satisfying the criterion necessary for the proposed

application is chosen for the task.

DESCRIPTION:

The 8051 family of microcontrollers is based on an architecture which is highly

optimized for embedded control systems. It is used in a wide variety of applications from

(17)

military equipment to automobiles to the keyboard. Second only to the Motorola 68HC11 in

eight bit processors sales, the 8051 family of microcontrollers is available in a wide array of

variations from manufacturers such as Intel, Philips, and Siemens. These manufacturers have

added numerous features and peripherals to the 8051 such as I2C interfaces, analog to digital

converters, watchdog timers, and pulse width modulated outputs. Variations of the 8051 with

clock speeds up to 40MHz and voltage requirements down to 1.5 volts are available. This

wide range of parts based on one core makes the 8051 family an excellent choice as the base

architecture for a company's entire line of products since it can perform many functions and

developers will only have to learn this one platform.

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with

8K bytes of in-system programmable Flash memory. The device is manufactured using

Atmel‘s high-density nonvolatile memory technology and is compatible with the industry-

standard 80C51 instruction set and pinout. 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 in-system programmable Flash on a monolithic chip,

the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-

effective solution to many embedded control applications. In addition, the AT89S52 is

designed with static logic for operation down to zero frequency and supports two software

selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,

timer/counters, serial port, and interrupt system to continue functioning. The Power-down

mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions

until the next interrupt or hardware reset.

FEATURES:

The basic architecture of AT89C51 consists of the following features:

• Compatible with MCS-51 Products

• 8K Bytes of In-System Programmable (ISP) Flash Memory

• 4.0V to 5.5V Operating Range

• Fully Static Operation: 0 Hz to 33 MHz

• 256 x 8-bit Internal RAM

• 32 Programmable I/O Lines

(18)

• Three 16-bit Timer/Counters

• Eight Interrupt Sources

• Full Duplex UART Serial Channel

• Low-power Idle and Power-down Modes

• Interrupt Recovery from Power-down Mode

• Watchdog Timer

• Fast Programming Time

• Flexible ISP Programming (Byte and Page Mode)

PIN CONFIGURATION

Fig. 4.16 Pin diagram of AT89S52

(19)

BLOCK DIAGRAM

Block diagram of the microcontroller

(20)

PIN DESCRIPTION

• VCC: Supply voltage.

• GND: Ground.

• Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin

can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as

high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order

address/data bus during accesses to external program and data memory. In this mode,

P0 has internal pull-ups.

• Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1

output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins,

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

1 pins that are externally being pulled low will source current (IIL) because of the

internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter

2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX),

respectively, as shown in the following table.

• Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2

output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins,

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

2 pins that are externally being pulled low will source current (IIL) because of the

internal pull-ups. Port 2 emits the high-order address byte during fetches from

external program memory and during accesses to external data memory that use 16-

bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pull-

ups when emitting 1s. During accesses to external data memory that uses 8-bit

addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function

register.

• Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3

output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins,

they are pulled high by the internal pull-ups and can be used as inputs. As inputs, they

are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port

3 pins that are externally being pulled low will source current (IIL) because of the

pull-ups. Port 3 receives some control signals for Flash programming an verification

(21)

Port 3 also serves the functions of various special features of the AT89S52, as shown in

the following table.

Alternate functions of Port 3:

Table 4.2 Alternate functions of Port 3

• RST: Reset input. A high on this pin for two machine cycles while the oscillator

is running resets the device. This pin drives high for 98 oscillator periods after the

watchdog times out.

(22)

Power-On Reset circuit

Power-on reset circuit

(23)

In order for the RESET input to be effective, it must have a minimum duration of two machine

cycles.

• ALE/PROG: Address Latch Enable (ALE) is an output pulse for latching the

low byte of the address during accesses to external memory. This pin is also the

program pulse input (PROG) during Flash programming. In normal operation,

ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used

for external timing or clocking purposes. Note, however, that one ALE pulse is

skipped during each access to external data memory. If desired, ALE operation

can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is

active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly

pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in

external execution mode.

• PSEN: Program Store Enable (PSEN) is the read strobe to external program

memory. When the AT89S52 is executing code from external program memory,

PSEN is activated twice each machine cycle, except that two PSEN activations

are skipped during each access to external data memory.

• EA: External Access Enable. EA must be strapped to GND in order to enable the

device to fetch code from external program memory locations starting at 0000H

up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be

internally latched on reset. EA should be strapped to VCC for internal program

executions. This pin also receives the 12-volt programming enable voltage (VPP)

during Flash programming.

• XTAL1: Input to the inverting oscillator amplifier and input to the internal clock

operating circuit.

• XTAL2: Output from the inverting oscillator amplifier.

4.4.6.2 The AT89S52 oscillator clock circuit

• It uses a quartz crystal oscillator.

• We can observe the frequency on the XTAL2 pin.

(24)

C2 30pF C1 30pF XTAL2 XTAL1 GN D

Fig 4.19 The AT89S52 oscillator clock circuit

• The crystal frequency is the basic internal frequency of the microcontroller.

• The internal counters must divide the basic clock rate to yield standard

communication bit per second (baud) rates.

• An 11.0592 megahertz crystal, although seemingly an odd value, yields a crystal

frequency of 921.6 kilohertz, which can be divided evenly by the standard

communication baud rates of 19200, 9600, 4800, 2400, 1200, and 300 hertz.

SPECIAL FUNCTION REGISTERS

The Special Function Registers (SFRs) contain memory locations that are used for

special tasks. Each SFR occupies internal RAM from 0x80 to 0xFF.They are 8-bits wide.

• The A (accumulator) register or accumulator is used for most ALU operations and

Boolean Bit manipulations.

• Register B is used for multiplication & division and can also be used for general

purpose storage.

• PSW (Program Status Word) is a bit addressable register

• PC or program counter is a special 16-bit register. It is not part of SFR. Program

instruction bytes are fetched from locations in memory that are addressed by the

PC.

(25)

• Stack Pointer (SP) register is eight bits wide. It is incremented before data is

stored during PUSH and CALL executions. While the stack may reside anywhere

in on-chip RAM, the Stack Pointer is initialized to 07H after a reset. This causes

the stack to begin at location 08H.

• DPTR or data pointer is a special 16-bit register that is accessible as two 8- bit

registers: DPL and DPH, which are used to used to furnish memory addresses for

internal and external code access and external data access.

• Control Registers: Special Function Registers IP, IE, TMOD, TCON, SCON, and

PCON contain control and status bits for the interrupt system, the

Timer/Counters, and the serial port.

• Timer Registers: Register pairs (TH0, TL0) and (TH1, TL1) are the 16-bit

Counter registers for Timer/Counters 0 and 1, respectively.

4.4.8 MEMORY ORGANIZATION

MCS-51 devices have a separate address space for Program and Data Memory. Up to

64K bytes each of external Program and Data Memory can be addressed.

• Program Memory: If the EA pin is connected to GND, all program fetches are

directed to external memory. On the AT89S52, if EA is connected to VCC,

program fetches to addresses 0000H through 1FFFH are directed to internal

memory and fetches to addresses 2000H through FFFFH are to external memory.

• Data Memory: The AT89S52 implements 256 bytes of on-chip RAM. The upper

128 bytes occupy a parallel address space to the Special Function Registers. This

means that the upper 128 bytes have the same addresses as the SFR space but are

physically separate from SFR space. When an instruction accesses an internal

location above address 7FH, the address mode used in the instruction specifies

whether the CPU accesses the upper 128 bytes of RAM or the SFR space.

Instructions which use direct addressing access the SFR space. The lower 128

bytes of RAM can be divided into three segments:

1. Register Banks 0-3: locations 00H through 1FH (32 bytes). The device after reset

defaults to register bank 0. To use the other register banks, the user must select them

in software. Each register bank contains eight 1-byte registers R0-R7. Reset initializes

the stack point to location 07H, and is incremented once to start from 08H, which is

(26)

the first register of the second register bank.

2. Bit Addressable Area: 16 bytes have been assigned for this segment 20H-2FH.

Each one of the 128 bits of this segment can be directly addressed (0-7FH). Each of

the 16 bytes in this segment can also be addressed as a byte.

3. Scratch Pad Area: 30H-7FH are available to the user as data RAM. However, if

the data pointer has been initialized to this area, enough bytes should be left aside to

prevent SP data destruction.

Fig. 4.20 Internal memory block

WATCHDOG TIMER (One-time Enabled with Reset-out)

The WDT is intended as a recovery method in situations where the CPU may be

subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog Timer

(27)

Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the

WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location

0A6H). When the WDT is enabled, it will increment every machine cycle while the oscillator

is running. The WDT timeout period is dependent on the external clock frequency. There is

no way to disable the WDT except through reset (either hardware reset or WDT overflow

reset). When WDT over-flows, it will drive an output RESET HIGH pulse at the RST pin.

4.4.10 TIMERS AND COUNTERS

Many microcontroller applications require the counting of external events such as the

frequency of a pulse train, or the generation of precise internal time delays between computer

actions. Both of these tasks can be accomplished using software techniques, but software

loops for counting or timing keep the processor occupied so that, other perhaps more

important, functions are not done. Hence the better option is to use interrupts & the two 16-

bit count- up timers. The microcontroller can programmed for either of the following:

1. Count internal - acting as timer

2. Count external - acting as counter

All counter action is controlled by the TMOD (Timer Mode) and the TCON

(Timer/Counter Control) registers. TCON Timer control SFR contains timer 1& 2 overflow

flags, external interrupt flags, timer control bits, falling edge/low level selector bit etc.

TMOD timer mode SFR comprises two four-bit registers (timer #1, timer #0) used to specify

the timer/counter mode and operation.

The timer may operate in any one of four modes that are determined by modes bits

M1 and M0 in the TMOD register:

TIMER MODE-0: Setting timer mode bits to 00b in the TMOD register results in using the

TH register as an 8-bit counter and TL as a 5-bit counter. Therefore mode0 is a 13-bit

counter.

TIMER MODE-1: Mode-1 is similar to mode-0 except TL is configured as a full 8-bit

counter when the mode bits are set to 01b in TMOD.

TIMER MODE-2: Setting the mode bits to 10b in TMOD configures the timer to use only

the TL counter as an 8-bit counter. TH is used to hold a value that is loaded into TL every

time TL overflows from FFh to 00h. The timer flag is also set when TL overflows.

(28)

TIMER MODE-3: In mode-3, timer-1 simply hold its count, where as timer 0 registers TL0

and TH0 are used as two separate 8-bit counters. TL0 uses the Timer-0 control bits. TH0

counts machine cycles and takes over the use of TR1 and TF1 from Timer-1.

INTERRUPTS

A computer has only two ways to determine the conditions that exist in internal and

external circuits. One method uses software instructions that jump to subroutines on the

states of flags and port pins. The second method responds to hardware signals, called

interrupts that force the program to call a subroutine.

The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and

INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. Each of these

interrupt sources can be individually enabled or disabled by setting or clearing a bit in

Special Function Register IE. IE also contains a global disable bit, EA, which disables all

interrupts at once.

Each interrupt forces the processor to jump at the interrupt location in the memory.

The interrupted program must resume operation at the instruction where the interrupt took

place. Program resumption is done by storing the interrupted PC address on to stack.

RETI instruction at the end of ISR will restore the PC address.

p

i

n

d

e

t

a

i

l

s

(29)

POWER SUPPLY

SECTION

(30)

POWER SUPPLY SECTION:-

The power supply section consists of step down transformers of 230V primary to

9V and 12V secondary voltages for the +5V and +12V power supplies respectively. The

stepped down voltage is then rectified by 4 1N4007 diodes. The high value of capacitor

1000 µF charges at a slow rate as the time constant is low, and once the capacitor charges

there is no resistor for capacitor to discharge. This gives a constant value of DC. IC 7805

is used for regulated supply of +5 volts and IC 7812 is used to provide a regulated supply

of +12 volts in order to prevent the circuit ahead from any fluctuations. The filter

capacitors connected after this IC filters the high frequency spikes. These capacitors

are connected in parallel with supply and common so that spikes filter to the common.

These give stability to the power supply circuit.

As can be seen from the above circuit diagrams, the rectified voltage from the

4 diodes is given to pin 1 of the respective regulators. Pin 2 of the regulators is connected

to ground and pin 3 to Vcc. With adequate heat sinking the regulator can deliver 1A

output current. If internal power dissipation becomes too high for the heat sinking

provided, the

(31)

+5V Power supply circuit

1 Vin 7805 Vout GND 2 230V, 50Hz 1000uf 10uf 1uf

(32)

+12V Power supply Circuit

(33)

A liquid crystal display (LCD) is a thin, flat display device made up of any number of

color or monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a

column of liquid crystal molecules suspended between two transparent electrodes, and two

polarizing filters, the axes of polarity of which are perpendicular to each other. Without the

liquid crystals between them, light passing through one would be blocked by the other. The

liquid crystal twists the polarization of light entering one filter to allow it to pass through the other.

Many microcontroller devices use 'smart LCD' displays to output visual information. LCD

displays designed around Hitachi's LCD HD44780 module, are inexpensive, easy to use, and

it is even possible to produce a readout using the 8x80 pixels of the display. They have a

standard ASCII set of characters and mathematical symbols.

For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-bit data

bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled,

data lines are tri-state and they do not interfere with the operation of the microcontroller.

Data can be placed at any location on the LCD. For 16×2 LCD, the address locations

are:

First line 80 81 82 83 84 85 86 through 8F

Second line C0 C1 C2 C3 C4 C5 C6 through CF

Address locations for a 2x16 line LCD

SIGNALS TO THE LCD

The LCD also requires 3 control lines from the microcontroller:

1) Enable (E)

This line allows access to the display through R/W and RS lines. When this line

is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is

high, the LCD checks the state of the two control lines and responds accordingly.

2) Read/Write (R/W)

(34)

When it is low, data is written to the LCD. When it is high, data is read from the

LCD.

3) Register select (RS)

With the help of this line, the LCD interprets the type of data on data lines. When it is

low, an instruction is being written to the LCD. When it is high, a character is being written

to the LCD.

Logic status on control lines:

• E - 0 Access to LCD disabled

- 1 Access to LCD enabled

• R/W - 0 Writing data to LCD

- 1 Reading data from LCD

• RS - 0 Instruction

.

Writing and reading the data from the LCD:

Writing data to the LCD is done in several steps:

1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Read data from data lines (if it is reading):

1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

(35)

PIN DESCRIPTION

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins

(two pins are extra in both for back-light LED connections).

.

Pin diagram of 2x16 line LCD

(36)

SOFTWARE SECTION

INTRODUCTION TO KEIL SOFTWARE:-

Keil MicroVision is an integrated development environment used to create software

to be run on embedded systems (like a microcontroller). It allows for such software to be

written either in assembly or C programming languages and for that software to be simulated

on a computer before being loaded onto the microcontroller.

WHAT IS µVision3?

µVision3 is an IDE (Integrated Development Environment) that helps write, compile,

and debug embedded programs. It encapsulates the following components:

¾ A project manager.

¾ A make facility.

¾ Tool configuration.

¾ Editor.

¾

A powerful debugger

.

STEPS FOLLOWED IN CREATING AN APPLICATION IN uVision3:

To create a new project in uVision3:

1. Select Project - New Project.

2. Select a directory and enter the name of the project file.

3. Select Project –Select Device and select a device from Device Database.

4. Create source files to add to the project

5. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add

the source files to the project.

6. Select Project - Options and set the tool options. Note that when the target device is

selected from the Device Database™ all-special options are set automatically. Default

memory model settings are optimal for most applications.

7. Select Project - Rebuild all target files or Build target

To create a new project, simply start MicroVision and select ―Project‖=>‖New

Project‖ from the pull–down menus. In the file dialog that appears, choose a name and base

(37)

directory for the project. It is recommended that a new directory be created for each project,

as several files will be generated. Once the project has been named, the dialog shown in the

figure below will appear, prompting the user to select a target device. In this lab, the chip

being used is the ―AT89S52,‖ which is listed under the heading ―Atmel‖.

Window for choosing the target device

Next, MicroVision must be instructed to generate a HEX file upon program

compilation. A HEX file is a standard file format for storing executable code that is to be

loaded onto the microcontroller.

In the ―Project Workspace‖ pane at the left, right–click on ―Target 1‖ and select

―Options for ‗Target 1‘ ‖.Under the ―Output‖ tab of the resulting options dialog, ensure that

both the ―Create Executable‖ and ―Create HEX File‖ options are checked. Then click ―OK‖

as shown in the two figures below.

(38)

Project Workspace Pane

Project Options Dialog

Next, a file must be added to the project that will contain the project code. To do this,

expand the ―Target 1‖ heading, right–click on the ―Source Group 1‖ folder, and select ―Add

files…‖ Create a new blank file (the file name should end in ―.asm‖), select it, and click

―Add.‖ The new file should now appear in the ―Project Workspace‖ pane under the ―Source

Group 1‖ folder. Double-click on the newly created file to open it in the editor. All code for

this lab will go in this file. To compile the program, first save all source files by clicking on

the ―Save All‖ button, and then click on the ―Rebuild All Target Files‖ to compile the

program as shown in the figure below. If any errors or warnings occur during compilation,

they will be displayed in the output window at the bottom of the screen. All errors and

warnings will reference the line and column number in which they occur along with a

description of the problem so that they can be easily located. Note that only errors indicate

that the compilation failed, warnings do not (though it is generally a good idea to look into

them anyway).

(39)

When the program has been successfully compiled, it can be simulated using the

integrated debugger in Keil MicroVision. To start the debugger, select ―Debug‖=>‖Start/Stop

Debug Session‖ from the pull–down menus.

At the left side of the debugger window, a table is displayed containing several key

parameters about the simulated microcontroller, most notably the elapsed time (circled in the

figure below). Just above that, there are several buttons that control code execution. The

―Run‖ button will cause the program to run continuously until a breakpoint is reached,

whereas the ―Step Into‖ button will execute the next line of code and then pause (the current

position in the program is indicated by a yellow arrow to the left of the code).

(40)

Breakpoints can be set by double–clicking on the grey bar on the left edge of the

window containing the program code. A breakpoint is indicated by a red box next to the line

of code.

„Reset‟, „Run‟ and „Step into‟ options

The current state of the pins on each I/O port on the simulated microcontroller can

also be displayed. To view the state of a port, select ―Peripherals‖=>‖I/O Ports‖=>‖Port n‖

from the pull–down menus, where n is the port number. A checked box in the port window

indicates a high (1) pin, and an empty box indicates a low (0) pin. Both the I/O port data and

the data at the left side of the screen are updated whenever the program is paused.

The debugger will help eliminate many programming errors, however the simulation

is not perfect and code that executes properly in simulation may not always work on the

actual microcontroller.

(41)

DEVICE DATABASE

A unique feature of the Keil µVision3 IDE is the Device Database, which contains

information about more than 400 supported microcontrollers. When you create a new

µVision3 project and select the target chip from the database, µVision3 sets all assembler,

compiler, linker, and debugger options for you. The only option you must configure is the

memory map.

PERIPHERAL SIMULATION

The µVision3 Debugger provides complete simulation for the CPU and on-chip

peripherals of most embedded devices. To discover which peripherals of a device are

supported, in µVision3 select the Simulated Peripherals item from the Help menu. You may

also use the web-based Device Database. We are constantly adding new devices and

simulation support for on-chip peripherals so be sure to check Device Database often.

PROGRAMMER

The programmer used is a powerful programmer for the Atmel 89 series of

microcontrollers that includes 89C51/52/55, 89S51/52/55 and many more.

It is simple to use & low cost, yet powerful flash microcontroller programmer for the

Atmel 89 series. It will Program, Read and Verify Code Data, Write Lock Bits, Erase and

Blank Check. All fuse and lock bits are programmable. This programmer has intelligent

onboard firmware and connects to the serial port. It can be used with any type of computer

and requires no special hardware. All that is needed is a serial communication port which all

computers have.

All devices also have a number of lock bits to provide various levels of software and

programming protection. These lock bits are fully programmable using this programmer.

Lock bits are useful to protect the progam to be read back from microcontroller only

allowing erase to reprogram the microcontroller.

Major parts of this programmer are Serial Port, Power Supply and Firmware

microcontroller. Serial data is sent and received from 9 pin connector and converted to/from

(42)

TTL logic/RS232 signal levels by MAX232 chip. A Male to Female serial port cable,

connects to the 9 pin connector of hardware and another side connects to back of computer.

All the programming ‗intelligence‘ is built into the programmer so you do not need

any special hardware to run it. Programmer comes with window based software for easy

programming of the devices.

ProLoad PROGRAMMING SOFTWARE

‗ProLoad‘ is a software working as a user friendly interface for programmer boards

from Sunrom Technologies. Proload gets its name from ―Program Loader‖ term, because

that is what it is supposed to do. It takes in compiled HEX file and loads it to the hardware.

Any compiler can be used with it, Assembly or C, as all of them generate compiled HEX

files. ProLoad accepts the Intel HEX format file generated from compiler to be sent to target

microcontroller. It auto detects the hardware connected to the serial port. It also auto detects

the chip inserted and bytes used. The software is developed in Delphi and requires no

overhead of any external DLL.

The programmer connects to the computer‘s serial port (Comm 1, 2, 3 or 4) with a

standard DB9 Male to DB9 Female cable. Baud Rate - 57600, COMx Automatically selected

by window software. No PC Card Required.

After making the necessary selections, the ‗Auto Program‘ button is clicked as shown

in the figure below which burns the selected hex file onto the microcontroller.

(43)
(44)

MAIN PROGRAM

/********************************************************************/ /******************** Main File for the Project*********************/

/* D.S.oberoi & Harinder Dhingra */ /********************************************************************/ #include <avr/signal.h> #include <inttypes.h> #include <avr/interrupt.h> #include "lcd.h" // Function declarations

unsigned int rc5decode( void ); // Remote RC5 decoding void remoteSelection(unsigned int remote_val); // remote selection routine void change_year(unsigned int remote_value); // change the year routine void change_month(unsigned int remote_value); // change the month routine void change_day(unsigned int remote_value); // change the day routine void change_date(unsigned int remote_value); // change the date routine void change_min(unsigned int remote_value); // change the minutes routine void change_hour(unsigned int remote_value); // change the hour routine void alarmSetting(void); // Check and set the alarm routine char viewAlarmSetting(unsigned int remote_value ); // View alarm settings void addAlarmSetting(unsigned int remote_value); // Add alarm setting routine void init(void); // Initialization routine

void device1_control(void); // Device 1 to 8 control routine

void device2_control(void); // first 5 attached to their respctive time setting void device3_control(void); void device4_control(void); void device5_control(void); void device6_control(void); void device7_control(void); void device8_control(void);

void deleteAlarmSetting(unsigned int remote_value); /* module global variables */

static volatile uint8_t timerflag;

char previous_min, snooze, alarm, mode , next_field, ir_disable; unsigned int snooze_tick, previous_sec;

unsigned int rc5data, rc5c; char device_status=0; char key_status=0;

/************* MAIN STARTS HERE *********************/ int main(void)

{

// Start the initialization process mode = SETTING_MODE; next_field= 0; // next field device_status= 0;

(45)

ir_disable = 0; snooze= 0; snooze_tick= 0;

outp(device_status, PORTB); // all external devices switched OFF init();

cbi(BUZZER_PORT,BUZZER_PIN); // disable alarm cbi(BACK_LITE_PORT, BACK_LITE_PIN); // disable backlight // I2C intialization i2c_initialization(); // LCD Initialization process lcd_init(); lcdCmdWrite(0x01);

// Start the display of clock - details at proper locations hour = display_hour(4, 1); min = display_min(7, 1); sec = display_sec(10, 1); day = display_day(0, 2); date = display_date(6, 2); month = display_month(9, 2); year = display_year(13, 2); readAlarmValues();

for(;;) // loop forever- main routine starts here {

if (mode == 1 && next_field== 0) {

lcd_gotoxy(5,1); // Setting on Power ON cursorBlinkOn();

}

// CHECK for the REMOTE operation here

while ( RC5BitHigh() ) // wait until RC5 code received {

;

if(alarm ==0 && mode == DISPLAY) {

outp(0xF0, DDRD); delay(100);

cbi(PORTD, PIND0); delay(100);

// check here if the Push Button is pressed and then // de-activate the device control signal

key_status = inp(PIND) & 0x02; if (key_status == 2 )

{

outp(0x00, PORTB); // disable all the PORTB device Device 1 to 8 device_status = 0 ; lcdcls(); delay(600); lcd_gotoxy(0,1); cli(); lcd_puts("Devices Disabled");

for(char op=0; op<=20; op++) // delay for viewing delay(60000);

lcdcls(); sei();

(46)

} key_status =0; }

}

rc5data = rc5decode(); // separate the address and the command- in RC5 code if ( rc5data & 0x2000 ) { rc5c = rc5data & 0x003f; remoteSelection(rc5c); } } } /*****************************--END HERE-********************************************/ /*****************************************************************************************/ /****************************** Device Control section starts here ***********************/

/*****************************************************************************************/ // Device 1 control routine here

void device1_control() { if ( mode == DISPLAY) { switch(device_status & 0x01) {

// if OFF then change to ON

case 0: sbi(DEVICE1_PORT, DEVICE1_PIN); device_status = device_status | 0x01; break;

// if ON then change to OFF

case 1: cbi(DEVICE1_PORT, DEVICE1_PIN); device_status = device_status & 0xFE; }

} }

// Device 2 control routine here void device2_control() { if ( mode == DISPLAY) { switch(device_status & 0x02 ) {

// if OFF then change to ON

case 0: sbi(DEVICE2_PORT, DEVICE2_PIN); device_status = device_status | 0x02; break;

// if ON then change to OFF

case 2: cbi(DEVICE2_PORT, DEVICE2_PIN); device_status = device_status & 0xFD; }

} }

// Device 3 control routine here void device3_control()

{

(47)

{

switch(device_status & 0x04 ) {

// if OFF then change to ON

case 0: sbi(DEVICE3_PORT, DEVICE3_PIN); device_status = device_status | 0x04; break;

// if ON then change to OFF

case 0x04: cbi(DEVICE3_PORT, DEVICE3_PIN); device_status = device_status & 0xFB; }

} }

// Device 4 control routine here void device4_control() { if ( mode == DISPLAY) { switch(device_status & 0x08 ) {

// if OFF then change to ON

case 0: sbi(DEVICE4_PORT, DEVICE4_PIN); device_status = device_status | 0x08; break;

// if ON then change to OFF

case 0x08: cbi(DEVICE4_PORT, DEVICE4_PIN); device_status = device_status & 0xF7; }

} }

// Device 5 control routine here void device5_control() { if ( mode == DISPLAY) { switch(device_status & 0x10 ) {

// if OFF then change to ON

case 0: sbi(DEVICE5_PORT, DEVICE5_PIN); device_status = device_status | 0x10; break;

// if ON then change to OFF

case 0x10: cbi(DEVICE5_PORT, DEVICE5_PIN); device_status = device_status & 0xEF; }

} }

// Device 6 control routine here void device6_control() { if ( mode == DISPLAY) { switch(device_status & 0x20 ) {

// if OFF then change to ON

case 0: sbi(DEVICE6_PORT, DEVICE6_PIN); device_status = device_status | 0x20; break;

References

Related documents

• Switching and control functions are possible with the switching/ remote controller SFC 602-… • A secondary signal unit NS 711-… is possible in parallel with an in-

This white paper describes a data protection and disaster recovery solution for virtualized Oracle Database 11 g R2 OLTP environments, enabled by RecoverPoint, Symmetrix VMAXe

A mixed formulation for a thin rigid scatterer which combines CBIE and HBIE (hypersingular BIE) is motivated by examining the discretized form of the integral equations, and

In a sample of older people living in London, South Asians were more likely to be frail than all other ethnic groups, with people of Black ethnicity least likely to be frail..

It is like any normal clock in which the time is specified by hour and minute using the remote control

The main unit shows the indoors temperature, calendar clock and temperatures collected and transmitted by the remote unit.. The main unit is capable of keeping track of the maximum

The student will be able to identify and describe the history of and development of photography equipment and changes in pictorial content and its usage.. The student will be able

FoxAir units supplied with IR Remote Control functionality utilize an electronic control module that memorizes the last setting of the unit when switching the unit OFF via the