Professional Documents
Culture Documents
Hardware Description
[5.1] Block Diagram
[5.2] Discription
5.2.1 Microcontroller
5.2.2 Android phone
5.2.3 Bluetooth module
5.2.4 LEDs
5.2.5 DC motor
5.2.6 Adaptor (12v)
5.2.7 Db-25 (Parallel port interface)
5.2.8 Transistor (For switching)
5.2.9 Bridge
5.2.10 7805 Ragulator
5.2.11 Power supply
to control or process all the activities and devices. It is connected to power supply,
Buzzer, led lights, motor driver, Motor and socket as well.
Android phone: We can use any android mobile phone but here project we use the
android mobile model is xolo q1010i.we use inbuilt mobile android application.
Bluetooth module: Here we use the hco5 Bluetooth module. It is receive the singal from
android application. it has range up to 10 meter.
Led: Here we use the two led light which are connected with the micro-controller.led
light is operated by the android application.
Dc motor driver: Here the dc motor driver connected with the micro-controller. dc
motor is connected with dc motor driver.dc motor driver operated at 12v.we can also
called as chopper circuit.
5.2 DESCRIPTION:
5.2.2 MICROCONTROLLER (P89V51RD2):
GENERAL DESCRIPTION:
The microcontroller is the heart of the system. The P89V51RD2 is an 80C51
microcontroller with 64 KB Flash and 1024 bytes of data RAM.
A key feature of the P89V51RD2 is its X2 mode option. The design engineer can choose
to run the application with the conventional 80C51 clock rate (12 clocks per machine cycle) or
select the X2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same
clock frequency.
The Flash program memory supports both parallel programming and in serial In-System
Programming (ISP). Parallel programming mode offers gang-programming at high speed,
reducing programming costs and time to market. ISP allows a device to be reprogrammed in the
end product under software control. The capability to field/update the application firmware
makes a wide range of applications possible. The P89V51RD2 is also In-Application
Programmable (IAP), allowing the Flash program memory to be reconfigured even while the
application is running.
FEATURES:
Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each)
BLOCK DIAGRAM:
PSW
Arithmetic and Logic Unit
SFR
RAM
To Port 1 &
Port 3
B
ROM
PC
To Port 0
&
Port 2
PIN DIAGRAM:
PIN DESCRIPTION:
P89V51RD2 is a 40 pin microcontroller as shown in figure 5.3. Each pin has some
specific function. Description of each pin is given below.
Port 0(0.1-0.7) Pins 39-32: Port 0 is an 8-bit open drain bi-directional I/O port. Port 0
pins that have 1 are written to them float, and in this state can be used as high-impedance inputs.
Port 0 is also the multiplexed low-order address and data bus during accesses to external code
and data memory. In this application, it uses strong internal pull-ups when transitioning to 1s.
Port 0 also receives the code bytes during the external host mode programming, and outputs the
code bytes during the external host mode verification. External pull-ups are required during
program verification or as a general purpose I/O port.
Port 1(1.0-1.7) Pins 1-8: Port 1 is an 8-bit bi-directional I/O port with internal pull-ups.
The Port 1 pins are pulled high by the internal pull-ups when 1s are written to them and can be
used as inputs in this state. As inputs, Port 1 pins that are externally pulled LOW will source
current (IIL) because of the internal pull-ups. P1.5, P1.6, P1.7 have high current drive of 16 mA.
Port 1 also receives the low-order address bytes during the external host mode programming and
verification.
T2: External count input to Timer/Counter 2 or Clock-out from Timer/Counter 2. Pin 1.0.
Port 2(2.0-2.7) Pins 21-28: Port 2 is an 8-bit bi-directional I/O port with internal pullups. Port 2 pins are pulled HIGH by the internal pull-ups when 1s are written to them and can
be used as inputs in this state. As inputs, Port 2 pins that are externally pulled LOW will source
current (IIL) because of the internal pull-ups. Port 2 sends the high-order address byte during
fetches from external program memory and during accesses to external Data Memory that use
16-bit address (MOVX @DPTR). In this application, it uses strong internal pull-ups when
transitioning to 1s. Port 2 also receives some control signals and a partial of high-order address
bits during the external host mode programming and verification.
Port 3(3.0-3.7) Pins 10-17: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups.
Port 3 pins are pulled HIGH by the internal pull-ups when 1s are written to them and can be
used as inputs in this state. As inputs, Port 3 pins that are externally pulled LOW will source
current (IIL) because of the internal pull-ups. Port 3 also receives some control signals and a
partial of high-order address bits during the external host mode programming and verification.
Signal related to the port 1 are explained below.
T0
T1
RD
PSEN (Program Store Enable) Active Low Pin 29: PSEN is the read strobe for
external program memory. When the device is executing from internal program memory, PSEN
is inactive (HIGH). When the device 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. A forced HIGH-to-LOW input transition on the PSEN pin while
the RST input is continually held HIGH for more than 10 machine cycles will cause the device to
enter external host mode programming.
Reset Pin 9: While the oscillator is running, a HIGH logic state on this pin for two
machine cycles will reset the device. If the PSEN pin is driven by a HIGH-to-LOW input
transition while the RST input pin is held HIGH, the device will enter the external host mode;
otherwise the device will enter the normal operation mode.
EA (External Access Enable) Active Low Pin 31: EA must be connected to VSS in
order to enable the device to fetch code from the external program memory. EA must be strapped
to VDD for internal program execution. However, Security lock level 4 will disable EA, and
program execution is only possible from internal program memory. The EA pin can tolerate a
high voltage of 12 V.
ALE (Address Latch Enable) Pin 30: ALE is the output signal for latching the low byte
of the address during an access to external memory.
Crystal 1 Pin 19: Input to the inverting oscillator amplifier and input to the internal
clock generator circuits.
Crystal 2 Pin 18: Output from the inverting oscillator amplifier.
MEMORY ORGANIZATION:
The device has separate address spaces for program and data memory.
The two 16-bit Timer/Counter registers: Timer 0 and Timer 1 can be configured to
operate either as timers or event counters in the Timer function, the register is incremented
every machine cycle. Thus, one can think of it as counting machine cycles. Since a machine
cycle consists of six oscillator periods, the count rate is 1/6 of the oscillator frequency. In the
Counter function, the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin, T0 or T1. In this function, the external input is sampled once
every machine cycle.
The Timer or Counter function is selected by control bits C/T in the Special Function
Register TMOD. These two Timer/Counters have four operating modes, which are selected by
bit-pairs (M1, M0) in TMOD. Modes 0, 1, and 2 are the same for both Timers/Counters. Mode 3
is different. The four operating modes are described in the following text.
TMOD Register:
Table 5.1
TCON Register:
Table 5.2
Mode 0
Putting either Timer into Mode 0 makes it look like an 8048 Timer, which is an 8-bit
Counter with a fixed divide-by-32 prescaler. Figure 5.5 shows Mode 0 operation.
In this mode, the Timer register is configured as a 13-bit register. As the count rolls over
from all 1s to all 0s, it sets the Timer interrupt flag TFn. The count input is enabled to the Timer
when TRn = 1 and either GATE = 0 or INTn = 1. (Setting GATE =1 allows the Timer to be
controlled by external input INTn, to facilitate pulse width measurements). TRn is a control bit in
the Special Function Register TCON. The GATE bit is in the TMOD register.
Mode 1
Mode 1 is the same as Mode 0, except that all 16 bits of the timer register (THn and TLn)
are used. See figure 5.6.
Mode 2
Mode 2 configures the Timer register as an 8-bit Counter (TLn) with automatic reloads,
as shown in figure 5.7. Overflow from TLn not only sets TFn, but also reloads TLn with the
contents of THn, which must be preset by software. The reload leaves THn unchanged. Mode 2
operation is the same for Timer 0 and Timer 1.
Mode 3
When timer 1 is in Mode 3 it is stopped (holds its count). The effect is the same as setting
TR1 = 0. Timer 0 in Mode 3 establishes TL0 and TH0 as two separate 8-bit counters. The logic
for Mode 3 and Timer 0 is shown in figure 5.8. TL0 uses the Timer 0 control bits: T0C/T,
T0GATE, TR0, INT0, and TF0. TH0 is locked into a timer function (counting machine cycles)
and takes over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the Timer 1
interrupt. Mode 3 is provided for applications that require an extra 8-bit timer. With Timer 0 in
Mode 3, the P89V51RD2 can look like it has an additional Timer.
Note: When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching it into and out
of its own Mode 3. It can still be used by the serial port as a baud rate generator, or in any
application not requiring an interrupt.
RESET:
A system reset initializes the MCU and begins program execution at program memory
location 0000H. The reset input for the device is the RST pin. In order to reset the device, a logic
level high must be applied to the RST pin for at least two machine cycles (24 clocks), after the
oscillator becomes stable. ALE, PSEN are weakly pulled high during reset. During reset, ALE
and PSEN output a high level in order to perform a proper reset. This level must not be affected
by external element. A system reset will not affect the 1 Kbytes of on-chip RAM while the
device is running; however, the contents of the on-chip RAM during power up are indeterminate.
Power-on Reset:
At initial power up, the port pins will be in a random state until the oscillator has started
and the internal reset algorithm has weakly pulled all pins HIGH. Powering up the device
without a valid reset could cause the MCU to start executing instructions from an indeterminate
location. Such undefined states may inadvertently corrupt the code in the flash.
When power is applied to the device, the RST pin must be held HIGH long enough for
the oscillator to start up (usually several milliseconds for a low frequency crystal), in addition to
two machine cycles for a valid power-on reset. An example of a method to extend the RST signal
is to implement a RC circuit by connecting the RST pin VDD through a 10 mF capacitor and to
VSS through an 8.2 kW resistor as shown in figure 5.9
.
Software reset
The software reset is executed by changing FCF[1] (SWR) from 0 to 1. A software
reset will reset the program counter to address 0000H. All SFR registers will be set to their reset
values, except FCF[1] (SWR), WDTC[2] (WDTS), and RAM data will not be altered.
SECURITY BIT:
The Security Bit protects against software piracy and prevents the contents of the flash
from being read by unauthorized parties in Parallel Programmer Mode. It also protects against
code corruption resulting from accidental erasing and programming to the internal flash memory.
5.2.2 Bluetooth Module:
Hardware details:
Coverage up to 30 ft / 10 m
Built in antenna
Can set the module control parameters and control commands via AT commands
The maximum serial baud rate: 1382400 bps, support for hardware flow control transfer
HC-07 Hardware
HC-07 modules are replacements for the HC-06 using different hardware chips. The HC-07 uses
a CSR 41C6 chip with internal 8 Mbit flash. There is no external 8Mbit flash chip.
HC-08 Hardware
The HC-08 module firmware working voltage is 2V-3.6V. The range of this module is 8 to 10m.
The module is an ultra low power Bluetooth protocol v4.0 module which cane operate as either
a master or a slave device.
HC-08 Current Consumption
When module is
Master current
Slave current
consumption
consumption
8.9mA
8.9mA
9.3mA
9.3mA
20.2mA
8.9mA
HC-09 Hardware
The HC-09 modules are replacements for the HC-06 and HC-07 modules.
HC-09 Current Consumption
When module is
Current consumption
25mA
27mA
15mA
The serial output is at TTL voltage levels (3.3V to 5V) and not the higher RS232 voltage levels
(12V+). Do not connect the module directly to your computer serial port unless the module is
mounted on a board that is doing TTL to RS232 conversion. You can also use a TTL to RS232
adapter to connect the module to your computer serial port. You do not need to use any
conversion if you are connecting the module to your microcontroller serial port which has 5VDC
tolerant pins.
The Firmware
The hardware for all firmware versions is the same and the firmware may be freely changed with
the right tools.
Pin 31 (PIO8) connects LED cathode via a 470 ohm series resistor to ground. It is used to indicate
the module state. After power on, flashing intervals differ in different states.
Pin 32 (PIO9) is used to control LED indicating pairing. It will be steady on when pairing is
successful.
Pin 34 (PIO11), module state switching pin. HIGH -> responds to AT commands via the wired
TTL serial connection; LOW or floating -> regular work status.
Open Hyperterminal or other communications tool, set the baud rate to 38400, 8 data bits, 1 stop
bit, no parity bit, no flow control (or 9600; firmware dependent).
Via TTL serial port, send characters "AT + ROLE = 1 r n",if successful, return "OK r n", where r
n is carriage return.
Set PIO11 LOW, re-power, then in Master state, automatically search for slave module and
connect.
HC-05 AT commands
AT responds OK.
AT+NAMEname where name 20 or fewer characters. Responds OKname. Retained across power
offs.
AT+ROLE? responds with 0=slave, 1=master, 2=slave-loop (loopback: receives master device
data and sends back to master).
AT+CLASS? responds with device type (32 bit indicating device type and what is supported).
AT+UART=x, y, z where x is 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800,
921600, 1382400 for baud rate, where y is 0=1 bit, 1=2 bits stop bit, where z is 0=none, 1=odd,
2=even parity). Deafult is 9600,0,0.
AT+STATUS? responds with the module status (+STATE:initialised, ready, pairable, paired,
inquiring, connecting, connected, disconnected).
AT+PAIR=x,y sets the remote Bluetooth device address with which to pair where x is the address
(eg 12:34:56:ab:cd:ef) and y is the limited time of the connection in seconds.
5.2.3
Motor driver:
L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act as current
amplifiers since they take a low-current control signal and provide a higher-current signal. This
higher
current
signal
is
used
to
drive
the
motors.
L293D contains two inbuilt H-bridge driver circuits. In its common mode of operation, two DC
motors can be driven simultaneously, both in forward and reverse direction. The motor
operations of two motors can be controlled by input logic at pins 2 & 7 and 10 & 15. Input logic
00 or 11 will stop the corresponding motor. Logic 01 and 10 will rotate it in clockwise and
anticlockwise
directions,
respectively.
Enable pins 1 and 9 (corresponding to the two motors) must be high for motors to start operating.
When an enable input is high, the associated driver gets enabled. As a result, the outputs become
active and work in phase with their inputs. Similarly, when the enable input is low, that driver is
disabled, and their outputs are off and in the high-impedance state
Pin Description:
Pin No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Function
Enable pin for Motor 1; active high
Input 1 for Motor 1
Output 1 for Motor 1
Ground (0V)
Ground (0V)
Output 2 for Motor 1
Input 2 for Motor 1
Supply voltage for Motors; 9-12V (up to 36V)
Enable pin for Motor 2; active high
Input 1 for Motor 1
Output 1 for Motor 1
Ground (0V)
Ground (0V)
Output 2 for Motor 1
Input2 for Motor 1
Supply voltage; 5V (up to 36V)
Name
Enable 1,2
Input 1
Output 1
Ground
Ground
Output 2
Input 2
Vcc 2
Enable 3,4
Input 3
Output 3
Ground
Ground
Output 4
Input 4
Vcc 1