Vous êtes sur la page 1sur 45

BLOCK DIAGRAM

WEARABLE EUIPMENT

ANTENNA

Accelero Wireless
meter MCU Transmitt
er

Fig 2.1 Wearable Equipment Block Diagram

DRIVER UNIT

ANTENNA

Wireless Receiver

ULN200
Voice Device
MCU 3 Relay
Controller Relays
Drivers

SPEAKER
Fig 2.2 Driver Unit Block Diagram

EIE DEPARTMENT 1 KMEA ENGINEERING COLLEGE


2. BLOCK DIAGRAM DESCRIPTION

2.1 Accelerometer Description


An accelerometer is a device that measures proper acceleration.
The proper acceleration measured by an accelerometer is not
necessarily the coordinate acceleration (rate of change of velocity).
For example, an accelerometer at rest of the surface of the earth will
measure an acceleration g = 9.81 m/s2 straight upwards, due to its
weight. By contrast, accelerometers in free fall or at rest in outer
space will measure zero. Another term for the type of acceleration
that accelerometers can measure is g-force acceleration.

Accelerometers have multiple applications in industry and


science. Highly sensitive accelerometers are components of inertial
navigation systems for aircraft and missiles. Accelerometers are used
to detect and monitor vibration in rotating machinery. Accelerometers
are used in tablet computers and digital cameras so that images on
screens are always displayed upright.

Single- and multi-axis models of accelerometer are available to


detect magnitude and direction of the proper acceleration (or g-force),
as a vector quantity, and can be used to sense orientation (because
direction of weight changes), coordinate acceleration (so long as it

EIE DEPARTMENT 2 KMEA ENGINEERING COLLEGE


produces g-force or a change in g-force), vibration, shock, and falling
in a resistive medium (a case where the proper acceleration changes,
since it starts at zero, then increases). Micromachined accelerometers
are increasingly present in portable electronic devices and video game
controllers, to detect the position of the device or provide for game
input.

Pairs of accelerometers extended over a region of space can be


used to detect differences (gradients) in the proper accelerations of
frames of references associated with those points. These devices are
called gravity gradiometers, as they measure gradients in the
gravitational field. Such pairs of accelerometers in theory may also be
able to detect gravitational waves.

2.2 Microcontroller
A microcontroller is a microprocessor system which contains
data and program memory, serial and parallel I/O, timers, and external
and internal interrupts—all integrated into a single chip that can be
purchased for as little as two dollars. About 40 percent of all
microcontroller applications are found in office equipment, such as
PCs, laser printers, fax machines, and intelligent telephones. About
one third of all microcontrollers are found in consumer electronic
goods. Products like CD players, hi-fi equipment, video games,
washing machines, and cookers fall into this category. The
communications market, the automotive market, and the military
share the rest of the applications.
EIE DEPARTMENT 3 KMEA ENGINEERING COLLEGE
A microcontroller is a single-chip computer. Micro suggests that the
device is small, and controller suggests that it is used in control
applications. Another term for microcontroller is embedded
controller, since most of the microcontrollers are built into (or
embedded in) the devices they control.
A microprocessor differs from a microcontroller in a number of
ways. The main distinction is that a microprocessor requires several
other components for its operation, such as program memory and data
memory, input-output devices, and an external clock circuit. A
microcontroller, on the other hand, has all the support chips
incorporated inside its single chip. All microcontrollers operate on a
set of instructions (or the user program) stored in their memory. A
microcontroller fetches the instructions from its program memory one
by one, decodes these instructions, and then carries out the required
operations. Microcontrollers have traditionally been programmed
using the assembly language of the target device. Although the
assembly language is fast, it has several disadvantages. An assembly
program consists of mnemonics, which makes learning and
maintaining a program written using the assembly language difficult.
Also, microcontrollers manufactured by different firms have different
assembly languages, so the user must learn a new language with every
new microcontroller he or she uses.
Microcontrollers can also be programmed using a high-level
language, such as BASIC, PASCAL, or C. High-level languages are

EIE DEPARTMENT 4 KMEA ENGINEERING COLLEGE


much easier to learn than assembly languages. They also facilitate the
development of large and complex programs.
In theory, a single chip is sufficient to have a running
microcontroller system. In practical applications, however, additional
components may be required so the microcomputer can interface with
its environment. With the advent of the PIC family of
microcontrollers the development time of an electronic project has
been reduced to several hours. Basically, a microcomputer executes a
user program which is loaded in its program memory. Under the
control of this program, data is received from external devices
(inputs), manipulated, and then sent to external devices (outputs). For
example, in a microcontroller-based oven temperature control system
the microcomputer reads the temperature using a temperature sensor
and then operates a heater or a fan to keep the temperature at the
required value.

2.3 Wireless Decoder and encoder


The HT 12E Encoder ICs are series of CMOS LSIs for Remote
Control system applications. They are capable of Encoding 12 bit of
information which consists of N address bits and 12-N data bits. Each
address/data input is externally trinary programmable if bonded out.

The HT 12D ICs are series Decoder of CMOS LSIs for remote
control system applications. These ICs are paired with each other. For
proper operation a pair of encoder/decoder with the same number of
address and data format should be selected. The Decoder receive the

EIE DEPARTMENT 5 KMEA ENGINEERING COLLEGE


serial address and data from its corresponding decoder, transmitted by
a carrier using an RF transmission medium and gives output to the
output pins after processing the data.

Fig 2.3.1 Wireless Encoder

Fig 2.3.2 Wireless Decorder

EIE DEPARTMENT 6 KMEA ENGINEERING COLLEGE


Features

Encoder

1. 18 PIN DIP
2. Operating Voltage : 2.4V ~ 12V
3. Low Power and High Noise Immunity CMOS Technology
4. Low Standby Current and Minimum Transmission Word
5. Built-in Oscillator needs only 5% Resistor
6. Easy Interface with and RF or an Infrared transmission medium
7. Minimal External Components

Decoder

1. 18 PIN DIP, Operating Voltage : 2.4V ~ 12.0V


2. Low Power and High Noise Immunity, CMOS Technology
3. Low Stand by Current, Trinary address setting
4. Capable of Decoding 12 bits of Information
5. 8 ~ 12 Address Pins and 0 ~ 4 Data Pins
6. Received Data are checked 2 times, Built in Oscillator needs only 5% resistor
7. VT goes high during a valid transmission
8. Easy Interface with an RF of IR transmission medium
9. Minimal External Components

Applications

1. Burglar Alarm, Smoke Alarm, Fire Alarm, Car Alarm, Security System
2. Garage Door and Car Door Controllers
3. Cordless telephone
4. Other Remote Control System

EIE DEPARTMENT 7 KMEA ENGINEERING COLLEGE


2.4 Wireless Receiver

Fig 2.4.1 Wireless Receiver

General Description:

 The OS-RX02-ASK is an ASK Hybrid receiver module.


 It is an effective low cost solution for using at 315/433.92 MHZ.
 The circuit shape of OS-RX02-ASK is L/C.
 Receiver Frequency: 315 / 433.92 MHZ
 Typical sensitivity: -105dBm
 Supply Current: 3.5mA
 IF Frequency: 1MHz

Features:

 Low power consumption.


 Easy for application.
 Operation temperature range : -10℃~+60℃
 Operation voltage: 5 Volts.
 Available frequency at: 315/434 MHz

EIE DEPARTMENT 8 KMEA ENGINEERING COLLEGE


Applications

 Car security system


 Wireless security systems
 Sensor reporting
 Automation system
 Remote Keyless entry

EIE DEPARTMENT 9 KMEA ENGINEERING COLLEGE


2.5Wireless Transmitter

Fig 2.5.1 Wireless Transmitter

Description

@433.92/315MHz Remote Keyless-Entry Transmitter.

@SAW RESONATOR

@ASK

Applications

 Car security system


 Remote keyless entry
 Garage door controller
 Home security
 Wireless mouse
 Automation system

EIE DEPARTMENT 10 KMEA ENGINEERING COLLEGE


The MO-SAWR is an ASK transmitter module .The result is excellent
performance in a simple-to-use .The MO-SAWR is designed specifically for
remote-control , wireless mouse and car alarm system operating at 433.92 in the
USA under FCC Part 15 regulation.

PinOut

Device
Fig 2.5.2
Unit Transmitter
Flow Pin Diagram
STAR
T

SHIFT Y IF
LED E MO
RIGHT VE
RIG

N
O

SHIFT Y IF
LED LEFT E MO
AND VE
LEF

N
O
EIE DEPARTMENT 11 KMEA ENGINEERING COLLEGE

IF N
DO O
EIE DEPARTMENT 12 KMEA ENGINEERING COLLEGE
Head Unit Flow Chart
START

TRANSMIT YES
RIGHT = 1 IF X AXIS <
LEFT = 0 135
DOWN = 0

NO

TRANSMIT
RIGHT = 0 YES IF Y AXIS >
LEFT = 1 184
DOWN = 0

NO

TRANSMIT
RIGHT = 0 YES IF Y AXIS <
LEFT = 0 145
DOWN = 1

NO

TRANSMIT
RIGHT = 0
LEFT = 0
DOWN = 0

EIE DEPARTMENT 13 KMEA ENGINEERING COLLEGE


EIE DEPARTMENT 14 KMEA ENGINEERING COLLEGE
Fig: Device unit section

EIE DEPARTMENT 15 KMEA ENGINEERING COLLEGE


Fig : Wearable equipment section

EIE DEPARTMENT 16 KMEA ENGINEERING COLLEGE


Fig : Wireless decoder section

EIE DEPARTMENT 17 KMEA ENGINEERING COLLEGE


Fig : Wireless transmitter section

EIE DEPARTMENT 18 KMEA ENGINEERING COLLEGE


CIRCUIT DESCRIPTION

Wearable Equipment Unit

The total circuit is powered from 9V battery. Diode D5 protects from the
supply voltage reversal. C17 and C18 filter the DC supply. The IC3 7805 is a
5V voltage regulator. It regulates the input voltage to fixed 5V which is used for
microcontroller and the accelerometer. The 5V is further filtered by the C19 and
C20.

The accelerometer is interfaced to the connecter J1 which consists of 5V,


ground, and three axis input. The accelerometer analog voltage is filtered by the
CRC (Capacitor, Resistor, and Capacitor) filter. The CRC filter for x axis is
C12, C4, R2, C5 and C6. For y axis is C11, C1, R1, C2 and C3 and for z axis is
C10, C7, R3, C8 and C9. The filtered output of each axis is given to the analog
input of the controller IC2 which is the ADC input of the controller. Pin 5 of the
controller is the voltage reference input. The reference input is directly
connected to the 5V fixed voltage reference. The fixed voltage reference is
realized with zener D1. The voltage reference circuit consists of C15, R4, D1,
C16, C21 where C15, C16 and C21 is for input and output voltage filtering. The
J3 is wireless connection with the transmitter. J6 is the ICSP connector for
programming and debugging connector for the controller.

Device Unit

12-0-12V AC transformer is used for the power supply. A full wave


rectifier is realized with the D1, D2, C19, C20 where C19 and C20 is for input
voltage filtering. The rectifier output will be 12VDC. Since we need 5VDC for
microcontroller and 3.3VDC for Voice controller we have included IC5 7805
and IC2 LM317. C8, C13, C14, C15 are for filtering the 5VDC supply and C9,

EIE DEPARTMENT 19 KMEA ENGINEERING COLLEGE


C18 is for 3.3V supply filtering. LM317 is an adjustable voltage regulator. Pin 1
of the LM317 is the adjust pin. The potential divider circuit composed of R11,
R12, R13, R14 sets the output voltage to 3.3V.

The Voice controller circuit works on 3.3V Pin 8 and 9 is the supply pins.
The command to the controller is shifted through Clock and data pins by the
MCU. Additionally reset and busy lines are also fed to the MCU. Reset pin is
for resetting the voice controller and busy line is for knowing whether the voice
controller is currently playing sound or not. Audio output is taken from the Pin
14 it is for connecting external amplifier. External amplifier is connected on J2.
Transistor Q1 and Q2 mutes the amplifier when the voice controller is not
playing sounds. C1, R1, C2 converts the PWM output from the controller to
analog sound signals.

IC3 ULN2003 is a NPN transistor array of 7 Darlington pair is used for


switching the 12V relays. The output from the MCU is only 5V for driving the
relay so we use ULN IC for boosting the supply. The output of the ULN directly
drives the Relay coils. When the relay coils are energized the corresponding
device is switched on. J6 connector is the LED output for providing indication
for the user visually. In our circuit we provide visual and audible indications.

J4 is the ICSP connector for programming and debugging connector for


the microcontroller.

EIE DEPARTMENT 20 KMEA ENGINEERING COLLEGE


COMPONENT DESCRIPTION

MMA7361L

The MMA7361L is a low power, low profile capacitive micromachined


accelerometer featuring signal conditioning, a 1-pole low pass filter,
temperature compensation, self test, 0g-Detect which detects linear freefall, and
g-Select which allows for the selection between 2 sensitivities. Zero-g offset
and sensitivity are factory set and require no external devices. The MMA7361L
includes a Sleep Mode that makes it ideal for handheld battery powered
electronics.

Features
• 3mm x 5mm x 1.0mm LGA-14 Package
• Low Current Consumption: 400 μA
• Sleep Mode: 3 μA
• Low Voltage Operation: 2.2 V – 3.6 V
• High Sensitivity (800 mV/g @ 1.5g)
• Selectable Sensitivity (±1.5g, ±6g)

EIE DEPARTMENT 21 KMEA ENGINEERING COLLEGE


• Fast Turn On Time (0.5 ms Enable Response Time)
• Self Test for Freefall Detect Diagnosis
• 0g-Detect for Freefall Protection
• Signal Conditioning with Low Pass Filter
• Robust Design, High Shocks Survivability
• RoHS Compliant
• Environmentally Preferred Product
• Low Cost

Typical Applications
• 3D Gaming: Tilt and Motion Sensing, Event Recorder
• HDD MP3 Player: Freefall Detection
• Laptop PC: Freefall Detection, Anti-Theft
• Cell Phone: Image Stability, Text Scroll, Motion Dialing, E-Compass
• Pedometer: Motion Sensing
• PDA: Text Scroll
• Navigation and Dead Reckoning: E-Compass Tilt Compensation
• Robotics: Motion Sensing

ULN2003

EIE DEPARTMENT 22 KMEA ENGINEERING COLLEGE


DESCRIPTION

The ULN2002A, ULN2003A, ULN2003AI, ULN2004A, ULQ2003A, and


ULQ2004A are high-voltage high-current Darlington transistor arrays. Each
consists of seven npn Darlington pairs that feature high-voltage outputs with
common-cathode clamp diodes for switching inductive loads. The collector-
current rating of a single Darlington pair is 500 mA. The Darlington pairs can
be paralleled for higher current capability. Applications include relay drivers,
hammer drivers, lamp drivers, display drivers (LED and gas discharge), line
drivers, and logic buffers. The ULN2002A is designed specifically for use with
14-V to 25-V PMOS devices. Each input of this device has a Zener diode and
resistor in series to control the input current to a safe limit. The ULN2003A and
ULQ2003A have a 2.7-kΩ series base resistor for each Darlington pair for
operation directly with TTL or 5-V CMOS devices. The ULN2004A and
ULQ2004A have a 10.5-kΩ series base resistor to allow operation directly from
CMOS devices that use supply voltages of 6 V to 15 V. The required input
current of the ULN/ULQ2004A is below that of the ULN/ULQ2003A, and the
required voltage is less than that required by the ULN2002A

FEATURES

• 500-mA-Rated Collector Current (Single Output)

• High-Voltage Outputs: 50 V
EIE DEPARTMENT 23 KMEA ENGINEERING COLLEGE
• Output Clamp Diodes

• Inputs Compatible with Various Types of Logic

• Relay-Driver Applications

7805

Description

The LM78XX series of three-terminal positive regulators is available in the TO-


220 package and with several fixed output voltages, making them useful in a
wide range of applications. Each type employs internal current limiting, thermal
shut-down, and safe operating area protection. If adequate heat sinking is
provided, they can deliver over 1 A output current. Although designed primarily
as fixed voltage regulators, these devices can be used with external components
for adjustable voltages and currents.

Features

• Output Current up to 1 A

• Output Voltages: 5, 6, 8, 9, 10, 12, 15, 18, 24 V

• Thermal Overload Protection

EIE DEPARTMENT 24 KMEA ENGINEERING COLLEGE


• Short-Circuit Protection

• Output Transistor Safe Operating Area Protection

LM317

Features

• Output-Current In Excess of 1.5 A

• Output-Adjustable Between 1.2 V and 37 V

• Internal Thermal Overload Protection

• Internal Short-Circuit Current Limiting

• Output-Transistor Safe Operating Area Compensation

• TO-220 Package

Description

This monolithic integrated circuit is an adjustable 3-terminal positive-voltage


regulator designed to supply more than 1.5 A of load current with an output
voltage adjustable over a 1.2 V to 37 V range. It employs internal current
limiting, thermal shutdown, and safe area compensation.

EIE DEPARTMENT 25 KMEA ENGINEERING COLLEGE


Application Circuit

EIE DEPARTMENT 26 KMEA ENGINEERING COLLEGE


Relay
A relay is an electrically operated switch. Many relays use an
electromagnet to operate a switching mechanism mechanically, but other
operating principles are also used. Relays are used where it is necessary to
control a circuit by a low-power signal (with complete electrical isolation
between control and controlled circuits), or where several circuits must be
controlled by one signal. The first relays were used in long distance telegraph
circuits, repeating the signal coming in from one circuit and re-transmitting it to
another. Relays were used extensively in telephone exchanges and early
computers to perform logical operations.

A type of relay that can handle the high power required to directly control
an electric motor or other loads is called a contactor. Solid-state relays control
power circuits with no moving parts, instead using a semiconductor device to
perform switching. Relays with calibrated operating characteristics and
sometimes multiple operating coils are used to protect electrical circuits from
overload or faults; in modern electric power systems these functions are
performed by digital instruments still called "protective relays".

EIE DEPARTMENT 27 KMEA ENGINEERING COLLEGE


Basic design and operation

A simple electromagnetic relay consists of a coil of wire wrapped around a soft


iron core, an iron yoke which provides a low reluctance path for magnetic flux,
a movable iron armature, and one or more sets of contacts (there are two in the
relay pictured). The armature is hinged to the yoke and mechanically linked to
one or more sets of moving contacts. It is held in place by a spring so that when
the relay is de-energized there is an air gap in the magnetic circuit. In this
condition, one of the two sets of contacts in the relay is closed, and the other set
is open. Other relays may have more or fewer sets of contacts depending on
their function. The relay in the picture also has a wire connecting the armature
to the yoke. This ensures continuity of the circuit between the moving contacts
on the armature, and the circuit track on the printed circuit board (PCB) via the
yoke, which is soldered to the PCB.

When an electric current is passed through the coil it generates a


magnetic field that activates the armature, and the consequent movement of the
movable contact(s) either makes or breaks (depending upon construction) a

EIE DEPARTMENT 28 KMEA ENGINEERING COLLEGE


connection with a fixed contact. If the set of contacts was closed when the relay
was de-energized, then the movement opens the contacts and breaks the
connection, and vice versa if the contacts were open. When the current to the
coil is switched off, the armature is returned by a force, approximately half as
strong as the magnetic force, to its relaxed position. Usually this force is
provided by a spring, but gravity is also used commonly in industrial motor
starters. Most relays are manufactured to operate quickly. In a low-voltage
application this reduces noise; in a high voltage or current application it reduces
arcing.

When the coil is energized with direct current, a diode is often placed
across the coil to dissipate the energy from the collapsing magnetic field at
deactivation, which would otherwise generate a voltage spike dangerous to
semiconductor circuit components. Some automotive relays include a diode
inside the relay case. Alternatively, a contact protection network consisting of a
capacitor and resistor in series (snubber circuit) may absorb the surge. If the coil
is designed to be energized with alternating current (AC), a small copper
"shading ring" can be crimped to the end of the solenoid, creating a small out-
of-phase current which increases the minimum pull on the armature during the
AC cycle.

A solid-state relay uses a thyristor or other solid-state switching device,


activated by the control signal, to switch the controlled load, instead of a
solenoid. An optocoupler (a light-emitting diode (LED) coupled with a photo
transistor) can be used to isolate control and controlled circuits.

EIE DEPARTMENT 29 KMEA ENGINEERING COLLEGE


Programs

Wearable unit

#include <Head Unit.h>

#define X_Axis 0

#define Y_Axis 1

#define Z_Axis 2

int8 ADC_Convert(int8 Axis);

void main()

int8 X_Value, Y_Value, Z_Value;

setup_adc_ports(AN0_AN1_AN2_AN4_VSS_VREF);

setup_adc (ADC_CLOCK_DIV_64);

while(TRUE)

X_Value = ADC_Convert(X_Axis);

Y_Value = ADC_Convert(Y_Axis);

EIE DEPARTMENT 30 KMEA ENGINEERING COLLEGE


Z_Value = ADC_Convert(Z_Axis);

if(X_Value < 135)

output_high(TX_Right);

output_low(TX_Left);

output_low(TX_Down);

else if(X_Value > 184)

output_low(TX_Right);

output_high(TX_Left);

output_low(TX_Down);

else if(Y_Value < 145)

output_low(TX_Right);

output_low(TX_Left);

output_high(TX_Down);

EIE DEPARTMENT 31 KMEA ENGINEERING COLLEGE


else

output_low(TX_Right);

output_low(TX_Left);

output_low(TX_Down);

int8 ADC_Convert(int8 Axis)

int16 Result;

set_adc_channel(Axis);

delay_ms(1);

Result = read_adc() >> 2;

return(Result);

EIE DEPARTMENT 32 KMEA ENGINEERING COLLEGE


Device Unit

#include <Device Unit.h>

void Shift_Dev_LEDs(int8 Bit_no);

void Blink_Dev_Led(int8 Bit_no);

void On_Off_Device(int8 Bit_no);

void send_command(int16 command);

void Turn_Relay_On_Off(int8 Input);

int8 relay_output;

void main()

int8 Select_Bit,i;

output_b(0);

delay_ms(1000);

setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); //104 ms
overflow

enable_interrupts(INT_TIMER1);

enable_interrupts(GLOBAL);

Select_Bit = 0;

output_a(0b11111110);

EIE DEPARTMENT 33 KMEA ENGINEERING COLLEGE


delay_ms(500);

output_high(Voice_Reset);

delay_ms(500);

output_low(Voice_Reset);

delay_ms(500);

send_command(20);

send_command(0);

if(read_eeprom(0) == 0xFF)

write_eeprom(0,0);

relay_output = read_eeprom(0);

Turn_Relay_On_Off(relay_output);

while(TRUE)

if(input(RX_Right))

Select_Bit--;

if(Select_Bit == 255)

Select_Bit = 5;

EIE DEPARTMENT 34 KMEA ENGINEERING COLLEGE


Shift_Dev_LEDs(Select_Bit);

if(input(RX_Left))

Select_Bit++;

if(Select_Bit == 6)

Select_Bit = 0;

Shift_Dev_LEDs(Select_Bit);

if(input(RX_Down))

On_Off_Device(Select_Bit);

Blink_Dev_Led(Select_Bit);

void Turn_Relay_On_Off(int8 Input)

if(bit_test(Input,0))

output_high(Dev_1);

else

output_low(Dev_1);

EIE DEPARTMENT 35 KMEA ENGINEERING COLLEGE


delay_ms(250);

if(bit_test(Input,1))

output_high(Dev_2);

else

output_low(Dev_2);

delay_ms(250);

if(bit_test(Input,2))

output_high(Dev_3);

else

output_low(Dev_3);

delay_ms(250);

if(bit_test(Input,3))

output_high(Dev_4);

else

output_low(Dev_4);

delay_ms(250);

EIE DEPARTMENT 36 KMEA ENGINEERING COLLEGE


if(bit_test(Input,4))

output_high(Dev_5);

else

output_low(Dev_5);

delay_ms(250);

if(bit_test(Input,5))

output_high(Dev_6);

else

output_low(Dev_6);

void send_command(int16 command)

int8 i;

int16 Temp;

Temp = command;

again:

output_low(Voice_Clk);

delay_ms(3);

for(i=0;i<16;i++)

EIE DEPARTMENT 37 KMEA ENGINEERING COLLEGE


delay_ms(1);

output_low(Voice_Clk);

delay_ms(1);

if((command & 0x8000) == 0x8000)

output_low(Voice_Data);

else

output_high(Voice_Data);

command<<=1;

output_high(Voice_Clk);

command = Temp;

delay_ms(50);

if(input(Voice_Busy)==0)

delay_ms(500);

output_high(Voice_Reset);

delay_ms(50);

output_low(Voice_Reset);

delay_ms(500);

goto again;

while(input(Voice_Busy));

EIE DEPARTMENT 38 KMEA ENGINEERING COLLEGE


delay_ms(50);

void On_Off_Device(int8 Bit_no)

switch(Bit_no)

case 0:

if(bit_test(relay_output,0))

bit_clear(relay_output,0);

output_low(Dev_1);

send_command(13);

else

bit_set(relay_output,0);

output_high(Dev_1);

send_command(7);

break;

EIE DEPARTMENT 39 KMEA ENGINEERING COLLEGE


case 1:

if(bit_test(relay_output,1))

bit_clear(relay_output,1);

output_low(Dev_2);

send_command(14);

else

bit_set(relay_output,1);

output_high(Dev_2);

send_command(8);

break;

case 2:

if(bit_test(relay_output,2))

bit_clear(relay_output,2);

output_low(Dev_3);

send_command(15);

EIE DEPARTMENT 40 KMEA ENGINEERING COLLEGE


}

else

bit_set(relay_output,2);

output_high(Dev_3);

send_command(9);

break;

case 3:

if(bit_test(relay_output,3))

bit_clear(relay_output,3);

output_low(Dev_4);

send_command(16);

else

bit_set(relay_output,3);

output_high(Dev_4);

send_command(10);

EIE DEPARTMENT 41 KMEA ENGINEERING COLLEGE


break;

case 4:

if(bit_test(relay_output,4))

bit_clear(relay_output,4);

output_low(Dev_5);

send_command(17);

else

bit_set(relay_output,4);

output_high(Dev_5);

send_command(11);

break;

case 5:

if(bit_test(relay_output,5))

EIE DEPARTMENT 42 KMEA ENGINEERING COLLEGE


bit_clear(relay_output,5);

output_low(Dev_6);

send_command(18);

else

bit_set(relay_output,5);

output_high(Dev_6);

send_command(12);

break;

write_eeprom(0,relay_output);

void Blink_Dev_Led(int8 Bit_no)

int8 Shift,i;

for(i=0;i<4;i++)

Shift = 0b11111111;

output_a(Shift);

EIE DEPARTMENT 43 KMEA ENGINEERING COLLEGE


delay_ms(250);

Shift = 0b11111111;

bit_clear(Shift, Bit_no);

output_a(Shift);

delay_ms(250);

while(TRUE)

if(input(RX_Left) == 0 && input(RX_Right) == 0 &&


input(RX_Down) == 0)

break;

delay_ms(50);

void Shift_Dev_LEDs(int8 Bit_no)

int8 Shift;

Shift = 0b11111111;

bit_clear(Shift, Bit_no);

output_a(Shift);

send_command(Bit_no+1);

while(TRUE)

EIE DEPARTMENT 44 KMEA ENGINEERING COLLEGE


if(input(RX_Left) == 0 && input(RX_Right) == 0 &&
input(RX_Down) == 0)

break;

delay_ms(50);

#int_TIMER1

void TIMER1_isr(void)

EIE DEPARTMENT 45 KMEA ENGINEERING COLLEGE

Vous aimerez peut-être aussi