Mini ProjecAndroid Controlled SwitchBoard
Mini ProjecAndroid Controlled SwitchBoard
Introduction
While we were hunting ideas for the mini project, the most
important thing we had in mind was that whatever we build should have
immediate practical applications. We wanted our project to solve a
common problem faced by the society. Since switchboards were present
everywhere and since they needed to be operated manually, we decided to
automate the system. Doing so would increase the convenience for people
and would be of immense importance to elderly people and people
suffering from disabilities.
The three elements of design are: Function
Aesthetics
Ergonomics
We have designed the product by keeping in mind all the above factors.
We believe that this system will make a huge difference in our current
and future lives. We are also excited about the future aspects and possible
expansions of our project.
2.Block Diagram
Department of Instrumentation, CUSATPage 2
Switchboard
Add-on
Bluetooth
Circuit
Communicat
ion
Android
Application
Switches
Microcontro
ller
HC 05
Serial Comm.
Bluetooth
Module
Android Application
Relays
ASCII
Bluetooth
Client
1 Byte Data
Bluetooth
Modem
low-power,
high-performance
CMOS8-bit
pole, double throw): An SPDT switch routes one input circuit to one of
two output circuits.
Relays
A relay is an electrically operated switch. Many relays use an
electromagnet to mechanically operate a switch, but other operating
principles are also used, such as solid-state relays. 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 as amplifiers: they repeated the
signal coming in from one circuit and re-transmitted it on another circuit.
Relays were used extensively in telephone exchanges and early
computers to perform logical operations.
Bluetooth Module
The device that we use for communication with the android phone is a
Bluetooth to serial module called HC 05. The HC 05 receives and
transmits serial data as ASCII data i.e. 1 Byte data. The device uses TTL
logic levels and has a default baud rate of 9600bps.
The GUI
4. Circuit Diagram
The circuit diagram for the Switch board side circuit is as shown below:-
5. Dc Power Supply
The following units form the backbone of any modern day power supply
Full wave bridge rectifier
Filter circuit
Voltage regulator
In the case if modern power supplies, the required power is derived from
the AC mains. For this at first the 230V/50 Hz is step down using a step
down transformer. Then The AC voltage is converted to DC using a
rectifier circuit. The bridge rectifier is considered the apt choice since it
avoids the center-tapped transformer. The ripples from the rectifiers
output are removed by filtering. The filter can be any of the following:
1. L filter
2. C filter
3. LC filter
4. CRC filter
And we use capacitive filtering.
The function of the voltage regulator is to provide a stable DC voltage for
powering other electronic circuits. The voltage regulator must be capable
of providing substantial output current. They must provide a constant
voltage regardless of changes in load current, temperature, and AC line
voltage. Although voltage regulators can be designed using opamps, it is
quicker and easier to use IC Voltage regulators. Furthermore, IC voltage
Department of Instrumentation, CUSATPage 10
regulators are versatile and relatively inexpensive and are available with
features such as programmable output, current / voltage boosting, internal
short circuit current limiting, thermal shut down, and floating operation
for high voltage applications. Voltage regulator may be classified as:
Series Regulator
Switching Regulator
Series regulators use a power transistor connected in series between the
unregulated DC input and the load. The output voltage is controlled by
the continuous voltage drop-taking place across the series pass transistor.
Since the transistor conducts in the active or the linear region, these
regulators are also called linear regulators. Linear regulators may have
fixed or variable output voltages and could be positive or negative.
Voltage regulators such as the 78XX series and the IC 723 are commonly
used. Switching regulators operate the power transistor as a HF on/off
switch, so that the power transistor does not conduct current continuously.
This gives an improve efficiency over the series regulator. The IC 723 can
be used as a switching regulator too.
With the advent of microelectronics, it is now possible to
incorporate the complete circuit of a voltage regulator on a single
monolithic silicon chip. These provide for high reliability, low cost,
reduced size and excellent performance. The 78XX, 79XX families and
IC723 are good examples of monolithic general-purpose regulators. Here
we use the positive voltage regulators 78XX series.
78xx Series
The 78XX series of regulators are 3 terminal, positive fixed voltage
regulators. There are 7 voltage options available like: 5V, 6V, 8V, 12V,
15V, 18V and 24V. The 79XX series are negative fixed voltage
regulators. These regulators are available in two types of packages:
1. Metal Package (TO-3)
2. Plastic Package (TO-220)
6. Microcontroller
The microcontroller is programmed to read the serial data coming out of
the HC 05 and turn the relays on or off according to the received data.
The AT89S52 is a typical 8051 microcontroller manufactured by
Atmel.89S52 has 4 different ports, each one having 8 Input/output lines
providing a total of 32 I/O lines. Those ports can be used to output DATA
and orders do other devices, or to read the state of a sensor, or a switch.
Most of the ports of the 89S52 have 'dual function' meaning that they can
be used for two different functions: the fist one is to perform input/output
operations and the second one is used to implement special features of the
microcontroller like counting external pulses, interrupting the execution
of the program according to external events, performing serial data
transfer or connecting the chip to a computer to update the software.
Port 1 :Port 1 is an 8-bit quasi-traditional I/O port. It also emits the loworder address byte during programming and verification. Port 1 can
sink/source one TTL Load.
Port 2 :Port 2 is an 8-bit quasi-bi-directional I/O port. It also emits the
high order address byte when accessing external memory. It is used for
the high-order address and the control signals during programming and
verification. Port 2 can sink/source one TTL load.
Port 3 :Port 3 is an 8-bit quasi bi-directional I/O port. It also contains the
interrupt, timer, serial port and RD and WR pins that are used by various
options. The output batch corresponding to a secondary function must be
programmed to a one (1) for that function to operate. Port 3 can
sink/source one TTL load. The secondary functions are assigned to the
pins of port 3, as follows.
RXD/data (P3.0):Serial Ports receiver data input (asynchronous) or data
input/output (synchronous).
TXD/Clock (P3.1) - Serial ports transmitts data output (asynchronous) or
clock output (synchronous).
INTO (P3.2):Interrupt O input or gate control input for counter 0.
INTI (P3.3) :Interrupt 1 input or gate control input for counter 1.
T0 (P3.4):Input to counter 0.
Department of Instrumentation, CUSATPage 16
T1 (P3.5):Input to counter 1.
WR (P3.6):The write control signal batches the data byte from port 0 into
the External Data Memory to port 0.
RST/VPD :A low to high transition on this pin (at approximately 3V)
resets the 8051. If VPD is held within its space (approximately +5V),
while Vcc drops below spec, VPD will provide stand by power to the
RAM. When VPD is low, the RAMs current is drawn from Vcc. A small
internal resistor permits power on reset using only a capacitor connected
to Vcc.
ALE/PROG:Provides Address Latch Enable output used for latching the
address into external memory during normal operation. Receives the
program pulse input during EPROM programming.
PSEN: The program store enable output is a control signal that enables
the external program memory to the bus during normal fetch operations.
EA/VDD: When held at a TTL high level, the 8051 executes instructions
from the internal ROM/EPROM when the PC is less than 4096. When
held at a TTL low level, the 8051 fetches all instructions from external
program memory. The pin also receives the 21V EPROM programming
supply voltage.
APPLICATIONS OF MICROCONTROLLER
1) Hand-held instruments
a) Pagers
b) Electronic plan meter
c) Level meter
d) IC Tester
2) Peripheral Devices
a) Keyboard controller
b) Modem
c) Printer buffer
3) Stand-Alone devices
a) Color copier
b) Electronic typewriter
c) Cable TV terminal
4) Instrumental Sub-Functions
a) Digital oscilloscope
b) Dedicated front panel
c) Microwave computer
5)Automotive application
7. ULN2003A
The microcontroller cannot directly drive a relay. A relay need high
current to turn on/off. To provide that high current we use a Darlington
pair array.
The ULx200xA devices 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.
drivers (LED and gas discharge), line drivers, and logic buffers. For 100V (otherwise interchangeable) versions of the ULx2003A devices, see the
SLRS023 data sheet for the SN75468 and SN75469 devices. The
ULN2002A device 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 ULx2003A devices
have a 2.7-k series base resistor for each Darlington pair for operation
directly with TTL or 5-V CMOS devices.
8. HC 05 Bluetooth Module
It is a Bluetooth module that is widely used with Microcontroller to
enable Bluetooth communication. This module cam be interfaced using
the UART in 8051 microcontroller where the data are transmitted in the
form of packets. The pins TX and RX pin of the HC 05 form the path for
data transmission and reception. These TX pin of HC05 must be
connected to the RX pin of 8051 and vice versa.
PIO control
Software Features
Default Baud rate: 38400, Data bits:8, Stop bit:1,Parity:No parity, Data control: has.
Supported baud rate: 9600,19200,38400,57600,115200,230400,460800.
PIO10 and PIO11 can be connected to red and blue led separately. When master and slave
are paired, red and blue led blinks 1time/2s in interval, while disconnected only blue led blinks 2times/s.
Programming Tools
The program was written and simulated using MikroC,
which is a complete IDE. It consists of a text editor, C
compiler and a simulator to simulate our code. The MikroC
PRO for PIC is a powerful, feature- rich development tool
for PIC microcontrollers. It is designed to provide the
programmer with the easiest possible solution to develop
applications
for
embedded
systems,
without
10 PCB Design
The PCB design starts right from the selection of the laminates .The two
main types of base laminate are epoxy glass and phenolic paper laminates
are generally used for simple circuits. Though it is very cheap and can
easily be drilled, phenolic paper has poor electrical characteristics and it
absorbs more moisture than epoxy glass. Epoxy glass has higher
mechanical strength.
The important properties that have to be considered for selecting the PCB
substrate are the dielectric strength, insulation resistance, water
absorption property, coefficient of thermal expansion, shear strength,
hardness, dimensional stability etc.
Manufacturing Process
The steps involved in manufacture are
Department of Instrumentation, CUSATPage 26
a)
b)
c)
d)
e)
f)
Artwork preparation.
Resist preparation.
Resist application an fixing.
Acid etches.
Cleaning and inspection.
Resist removal.
PCB Fabrication
a)
b)
c)
d)
Drilling
Drills for PCB use usually come with either a set of collects of
various sizes or a 3-Jaw chuck. For accuracy however 3-jaw chunks
arent brilliant and small drill below 1 mm from grooves in the jaws
preventing good grips.
Soldering
Begin the construction by soldering the resistors followed by the
capacitors and the LEDs diodes and IC sockets. Dont try soldering an
IC directly unless you trust your skill in soldering. All components
should be soldered as shown in the figure. Now connect the switch and
then solder/screw if on the PCB using multiple washers or spaces.
Department of Instrumentation, CUSATPage 28
Soldering it directly will only reduce its height above other components
and hamper in its easy fixation in the cabinet. Now connect the battery
lead.
Assembling
The circuit can be enclosed in any kind of cabinet. Before fitting
the PCB suitable holes must be drilled in the cabinet for the switch,
LED and Switches. Note that a rotary switch can be used instead of a
slide type.
11 PCB Layout
The Different Pcb layouts are as shown below: Top copper layer:-
12 The Program
-----------------------------------------------------------------------------------------------Department of Instrumentation, CUSATPage 30
#include<regx51.h>
#define mode P1_7
// global variables
unsigned char con,ipt,as;
unsigned int nb;
void modify();
void toggles(unsigned char d);
void serialcomm();
void toggle(unsigned char s);
// main
void main(){
unsigned char a,b;
nb=0;
P1=0xff;
P0=0xff;
TH1=0xfd;
TMOD=0x20;
TI=0;
TR1=1;
SM0=0;
SM1=1;
EA=1;
ES=1;
REN=1;
P0_7=0;
a=P1&0x1f;
Department of Instrumentation, CUSATPage 31
b=P0&0xe0;
P0=a|b;
as=P1;
ipt=P1&0x1f;
while(1){
if(mode==0){
a=P1&0x1f;
b=P0&0xe0;
P0=a|b;
}else{
modify();
nb=0;
toggle(con);
}else{
if(ipt!=(P1&0x1f)){
as=P1;
toggles(P1);
}
ipt=as&0x1f;
return;
}
void toggle(unsigned char s){
switch(s){
case '0': P0_0=~P0_0;
break;
case '1': P0_1=~P0_1;
break;
case '2': P0_2=~P0_2;
break;
case '3': P0_3=~P0_3;
break;
case '4': P0_4=~P0_4;
break;
default : P0_7=~P0_7;
}
Department of Instrumentation, CUSATPage 33
return;
}
void toggles(unsigned char d){
unsigned char a,b,c;
a=d^ipt;
b=P1&0xe0;
c=~a;
c=c&P1;
a=a&P1;
a=a|c;
a=0x1f&a;
P0=a|b;
return;
}
// End of Program
---------------------------------------------------------------------------------------------------------------
The app allows us to do the following: Connect the android device to the switchboard
Control the switches using the on Screen Buttons
Control the switches using Gestures.
14 Applications
The system designed as part of this Mini Project can be used for the
following applications:1.
2.
3.
4.
16 Future Scope
The future scope of a system like this is a thousand times more exciting
than the current design. With the inevitable advent of the Internet of
Things (IoT), a connected switchboard could be controlled from
anywhere in the world. The complete control of the devices at our homes
can be done from an internet enabled device, placed anywhere in the
world.
The further developments that can be done are:1. Replace Bluetooth with Wi-Fi to get better range and
functionality.
2. Connect to the internet to enable IoT.
3. Network a number of switchboards to make a complete
home automation system.
4. Improve the functionality of the android app to turn devices
on/off at specific times of the day with no user input etc..
17 Conclusion
The project was designed and implemented successfully and has proved
to be of immense practical applications. The system enables a person to
control the appliances connected to a switchboard using an Android
Phone. The system can be very useful to old and physically challenged
people. The future scope of the system is awe-inspiring and can be the
subject of a larger project.
18 References
[2] Kirk Zurell, C programming for embedded systems , R and D Books, First Edition,
ISBN 1-929629-04-4
Web
[1] 16F877A,http://ww1.microchip.com/downloads/en/devicedoc/39582b.pdf
[2] PIC Mid Range Reference Manual,
ww1.microchip.com/downloads/en/devicedoc/33023a.pdf
[3] Express tutorial,http://referencedesigner.com/tutorials/express/express_01.php
[4] Datasheets, http://www.datasheetsarchive.com
[5] http://ai2.appinventor.mit.edu/
[6] http://wiki.iteadstudio.com/Serial_Port_Bluetooth_Module_(Master/Slave)_:_
HC-05
A.1
AT89S52
Features
Watchdog Timer
Power-off Flag
DoE, CE Cherthala
Page 47
DoE, CE Cherthala
Page 48
Pin Description
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 0 also receives the code bytes during Flash programming and outputs
the code bytes during program verification. External pull-ups are required
during program verification.
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 1 also receives the low-order address
bytes during Flash programming and verification.
Port Pin
P1.0
P1.1
P1.5
P1.6
P1.7
Alternate Functions
T2(external count input to Timer/Counter2), clock-out
T2EX(Timer/Counter 2 capture/reload trigger and direction
control)
MOSI(used for In-System Programming)
MISO(used for In-System Programming)
SCK(used for In-System Programming)
Page 49
source current (IIL) because of the internal pull-ups. Port 2 emits the highorder address byte during fetches from external program memory and
during accesses to external data memory that uses 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 8bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special
Function Register. Port 2 also receives the high-order address bits and
some control signals during Flash programming and verification.
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, 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 and verification. Port 3 also serves the
functions of various special features of the AT89S52, as shown in the
following table.
Port Pin
Alternate Functions
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7
DoE, CE Cherthala
Page 50
can be used to disable this feature. In the default state of bit DISRTO, the
RESET HIGH out feature is enabled.
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/VPP
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
clock
operating circuit.
DoE, CE Cherthala
Page 51
XTAL2
XTAL2 is the output from the inverting oscillator amplifier.
DoE, CE Cherthala
Page 52
Architecture of AT89S52
DoE, CE Cherthala
Page 53
Different Modes
Idle Mode
In idle mode, the CPU puts itself to sleep while all the on-chip peripherals
remain active. The mode is invoked by software. The content of the onchip RAM and all the special functions registers remain unchanged during
this mode. The idle mode can be terminated by any enabled interrupt or
by a hardware reset. Note that when idle mode is terminated by a
hardware reset, the device normally resumes program execution from
where it left off, up to two machine cycles before the internal reset
algorithm takes control. On-chip hardware inhibits access to internal RAM
in this event, but access to the port pins is not inhibited. To eliminate the
possibility of an unexpected write to a port pin when idle mode is
terminated by a reset, the instruction following the one that invokes idle
mode should not write to a port pin or to external memory.
Power-down Mode
In the Power-down mode, the oscillator is stopped, and the instruction that
invokes Power-down is the last instruction executed. The on-chip RAM and
Special Function Registers retain their values until the Power-down mode is
terminated. Exit from Power-down mode can be initiated either by a
hardware reset or by an enabled external interrupt. Reset redefines the
SFRs but does not change the on-chip RAM. The reset should not be
activated before VCC is restored to its normal operating level and must be
held active long enough to allow the oscillator to restart and stabilize.
DoE, CE Cherthala
Page 54
A.2
AT89c2051
Features
Compatible with MCS-51Products
2K Bytes of Reprogrammable Flash
Memory
Endurance: 10,000 Write/Erase Cycles
2.7V to 6V Operating Range
Fully Static Operation: 0 Hz to 24 MHz
Two-level Program Memory Lock
128 x 8-bit Internal RAM
DoE, CE Cherthala
Page 55
2015
Description
The AT89C2051 is a low-voltage, high-performance CMOS 8-bit microcomputer with
2K bytes of Flash programmable and erasable read-only memory (PEROM). The device is
manufactured using Atmels high-density nonvolatile memory technology and is compatible
with the industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the Atmel AT89C2051 is a powerful microcomputer which
provides a highly-flexible and cost-effective solution to many embedded control applications.
The AT89C2051 provides the following standard features: 2K bytes of Flash, 128 bytes of
RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a
full duplex serial port, a precision analog comparator, on-chip oscillator and clock circuitry.
In addition, the AT89C2051 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 contents but freezes the oscillator
disabling all other chip functions until the next hardware reset.
2015
2015
2015