1

1. INTRODUCTION

PCB stands for Printed Circuit Board. A Printed Circuit Board is a
thin board made of an insulating material such as a fiber glass or a similar material that
bears all the electronic components of a circuit connected together by very thin copper
tracks. The components of a PCB are held in their respective position by drilling holes at
required places on the board and soldering them.

Drilling operation is one of the important mechanical processes in
manufacture of printed circuited boards. The purpose of this drilling is twofold:
(i) To provide component lead mounting precisely and with
structural integrity.
(ii) To establish electrical connection between top, bottom, and
sometimes intermediate conductor pathways.

Drilling of holes at the required places on the circuit board, so that it
can bear the required components of the circuit at required positions is a significant step in
the manufacturing of Printed Circuit Boards. For manufacture of PCBs in small quantities
drilling of holes is usually done by manual drilling with either an electric or pneumatic
drill, while production of PCBs in large quantity involves the use of Computer Numerical
Controlled (CNC) drilling machines.

A common problem experienced by these smaller manufacturers of
PCBs is that the total turnaround time is impeded by the time spent for the drilling of
PCBs. Moreover the small industries cannot afford the expensive and sophisticated
Computer Numerical Controlled (CNC) Drilling machine.

The ideal solution for this problem is to develop a low cost reliable
Computer Numerical Control (CNC) drilling machine that possesses the capabilities and
versatility of expensive Computer Numerical Control (CNC) drilling machines available.



2



1.1 Mechanical operations in fabrication of Printed Circuit Boards:


 Shearing:
Shearing is the first mechanical operation carried out on PCBs to
give them proper shape or contour. It is basically a cutting method applicable to all kinds
of base materials, generally of less than 2 mm thickness.

 Sawing:

In the PCB industry, mostly circular sawing machines of the moving
table type are preferred. The saw blade speed is adjustable between 2000-6000 rpm. This
method is preferred as it gives a smother edge finish and clean cut, though the dimensional
tolerances are similar (0.3-0.5 mm) to that of shearing.

 Blanking:

When PCBs are designed to have shapes other than rectangular or
have an odd contour, the use of a blanking die is a faster and more economical method.
Blanking basically consists of a clean cutting operation done with a punching tool rather
than with a saw or a shearing machine. Blanking helps to achieve PCB dimensions within a
tolerance of ± (0.1 – 0.2 mm).

 Milling:

Milling is a commonly used operation which can be applied for the
clean cutting of PCBs and for obtaining good edge finish and overall dimensions with a
high degree of accuracy. The generally used cutting speeds are in the range of 1000-3000
rpm. They usually employ straight or spiral tooth HSS (high speed steel) milling cutters.


3




 Routing:

For obtaining superior edge finish and higher dimensional accuracy
than that obtainable from shearing or sawing routing is adopted. Especially for PCBs with
odd contours, routing becomes a better choice. The dimensional tolerances within ± (0.1-
0.2) mm can be achieved with a much lower cost than blanking. There are three basic
routing systems available. They are:
a) Pin routing
b) Tracer or stylus routing and
c) NC routing
 Drilling:

Drilling operation is one of the important mechanical processes in
the manufacture of printed circuit boards. After the drilling process, the drilled circuit
board undergoes various processes like plating, aging, etching and solder plating.
Therefore, care is needed to obtain a good surface on the drilled hole and hence its quality
assumes great significance.


Fig. 1.1 The important steps in the drilling process
4

1.2 General characteristics of PCB drilling machine:

 A spindle that holds the drill or cutting tools and revolves in a fixed position in a
sleeve. In most drilling machines, the spindle is vertical and the work is supported on a
horizontal table.

 The sleeve or quill assembly does not revolve but may slide in its bearing in a
direction parallel to its axis. When the sleeve carrying the spindle with a cutting
tool is lowered, the cutting tool is fed into the work: and when it is moved upward,
the cutting tool is withdrawn from the work. Feed pressure applied to the sleeve by
hand or power causes the revolving drill to cut its way into the work a few
thousandths of an inch per revolution.


 The column of most drill presses is circular and built rugged and solid. The column
supports the head and the sleeve or quill assembly.

 The head of the drill press is composed of the sleeve, spindle, electric motor, and
feed mechanism. The head is bolted to the column.

 The worktable can be may be moved along the X and Y directions to align the work
at the required position under the drilling bit.

 The base of the drilling machine supports the entire machine and when bolted to the
floor, provides for vibration-free operation and best machining accuracy. The top of
the base is similar to a worktable and maybe equipped with T-slots for mounting
work too large for the table.






5

1.3 Drill bits for PCB drilling:

Normally, most PCBs are drilled with carbide bits rather than high-
speed steel (HSS). Carbide bits have good resistance to heat and high hardness. The quality
of cutting edges or drill points of the drill bit are very important. Drill bits should not be
pressed against metallic or hard surfaces to avoid damage to the bit geometry. The drill bit
surface should be cleaned by 1 per cent tri-sodium phosphate in water for 20 to 30 seconds.
This removes the oils and debris from their surface.

The standard PCB drills for holes of 0.024" (0.6 mm) and larger is
composed of wear-resistant cemented tungsten carbide crystals. Their composition, i.e. 94
per cent tungsten carbide (WC) and 6 per cent cobalt (co) provides maximum drilling
speed and tool life for years. For holes with diameters of 0.018" (0.45 mm) or smaller,
several PCB drilling problems are encountered. These include a higher frequency of drill
breakage upon retract, an increase of hole location scrap, and a decrease in output due to a
reduction in the PCB stack height.

1.4 Drill bit geometry:

Drills used for making holes in PCBs are usually made of High
Speed Steel (HSS) and tungsten carbide (mostly). These drill bits are generally available in
two basic forms:

(i) Common shank
(ii) Straight shank
The function of drill bit in PCB drilling is to cut and remove the
base material and copper. Most of the drill bits used for PCB drilling are of common shank
design. This allows a drill machine to use many bit diameters with only one collet. The
point angle determines the ability of the tool to cut the laminate material and it usually
varies in the range of 90° to 130°.
6



Fig. 1.2 Common shank and straight shank drill bits

Fig. 1.3 The geometry of a drill bit.


7

2. THE OUTLOOK OF THE PROTOTYPE OF THE
PCB DRILLING MACHINE



8

2.1 Mechanical components used:

 Stepper Motors:
A stepper motor is a widely used device that translates electrical
pulses into mechanical movement. The stepper motor is used for position control in
applications such as disk drivers, dot matrix printers, and robotics, etc. Every stepper
motor has a permanent magnet rotor (also called the shaft) surrounded by a stator.

In our project stepping motors are used to achieve precise positioning of
the table of the drilling machine via digital control. The motor operates by accurately
synchronizing with the pulse signal output from the microcontroller, to the driver circuit.
Stepping motors, with their ability to produce high torque at a low speed while
minimizing vibration, are ideal for applications requiring quick positioning over a short
distance.

Stepping motors enable accurate positioning with ease. They are used in
various types of equipment for accurate rotation angle and speed control using pulse
signals. Stepping motors generate high torque with a compact body, and are ideal for
quick acceleration and response. Stepping motors also hold their position at stop, due to
their mechanical design. Stepping motor functioning consist of a driver (takes pulse
signals in and converts them to motor motion) and a stepping motor.

The stepper motor used to in this project for the positioning of the table is a
VEXTA STEPPING MOTOR, model no. PH266-01.


Fig. 2.1 The VEXTA stepper motor PH266-01
9

The specifications of this stepping motor are as follows:

 Phase: 2 phase
 Input Voltage: 6V
 Amperes: 1.2A
 Step Angle: 1.8°
 Casing Size: NEMA 23

Mechanism of a stepper motor:
Stepper motors consist of a permanent magnet rotating shaft, called
the rotor, and electromagnets on the stationary portion that surrounds the motor, called the
stator. The following figure illustrates one complete rotation of a stepper motor. At
position 1, we can see that the rotor is beginning at the upper electromagnet, which is
currently active (has voltage applied to it). To move the rotor clockwise, the upper
electromagnet is deactivated and the right electromagnet is activated, causing the rotor to
move 90 degrees clockwise, aligning itself with the active magnet. This process is repeated
in the same manner at the south and west electromagnets until we once again reach the
starting position.


Fig. 2.2 Working of a stepper motor.
10

In the above example, a motor with a resolution of 90 degrees is illustrated for
demonstration purpose. The resolution (the amount of degrees of rotor’s rotation for a
single pulse) of VEXTA stepping motor used is much lower than this. This motor has a
resolution of 1.8 degrees, that is, the motor would move its rotor 1.8 degrees per step,
thereby requiring 200 pulses (steps) to complete a full 360 degree rotation.

Accurate Positioning in Fine Steps:

Fig. 2.3 Step angle of a stepper motor.

A stepping motor rotates with a fixed step angle, just like the second hand
of a clock. This angle is called "basic step angle". The stepping motor used is with a basic
step angle 1.8°.

Easy Control with Pulse Signals:

The system configuration for high accuracy positioning is shown below.
The rotation angle and speed of the stepping motor can be controlled with precise
accuracy by using pulse signals from the controller.

Fig. 2.3 Controlling of a stepper motor using pulse signal.
11

What is a Pulse Signal?

Fig. 2.4 Pulse signal to a stepper motor.

A pulse signal is an electrical signal whose voltage level changes
repeatedly between ON and OFF. Each ON/OFF cycle is counted as one pulse. A
command with one pulse causes the motor output shaft to turn by one step. The signal
levels corresponding to voltage ON and OFF conditions are referred to as "H" and "L"
respectively.


The Amount of Rotation is Proportional to the Number of Pulses:


Fig. 2.5 Angle of rotation for different pulse inputs.

The amount the stepping motor rotates is proportional to the number of
pulse signals (pulse number) given to the driver. The relationship of the stepping motor's
12

rotation (rotation angle of the motor output shaft) and pulse number is expressed as
follows:
The Speed is Proportional to the Pulse Speed:
The speed of the stepping motor is proportional to the speed of pulse
signals (pulse frequency) given to the driver. The relationship of the pulse speed [Hz] and
motor speed [r/min] is expressed as follows:

Fig. 2.6 Angle of rotation for different pulse inputs.

Generating High Torque with a Compact Body
Stepping motors generate high torque with a compact body. These features
give them excellent acceleration and response, which in turn makes these motors well-
suited for torque-demanding applications where the motor must start and stop frequently.
To meet the need for greater torque at low speed, Vexta Stepper motors are manufactured
as geared motors combining compact design and high torque.


Fig. 2.2 General Speed Vs Torque characteristics of a stepper motor..

13


Fig. 2.7 Step movement of the rotor of the stepper motor.

The Motor Holds Itself at a Stopped Positioning
Stepping motors continue to generate holding torque even at
standstill. This means that the motor can be held at a stopped position without using a
mechanical brake. Once the power is cut off, the self-holding torque of the motor is lost
and the motor can no longer be held at the stopped position in vertical operations or when
an external force is applied. In lift and similar applications, use an electromagnetic brake
type.

Fig. 2.8 Horizontal and vertical implementation of a stepper motor.


14

 Lead Screw mechanism for table movement:
The movement of the table of the PCB drilling machine to required
position is achieved by the lead screw mechanism. Lead screw is a general term for a
threaded rod that translates rotary motion to linear motion. The rod is connected to the
shaft of the Stepper motor. Situated along the length of the rod is a nut which is connected
to some platform or a carriage. When the motor’s shaft rotates, the rod also rotates, and the
nut travels forward or backward depending on the direction of rotation of motor and the
rod. The table which is joined to this nut will move accordingly along with the nut to come
to the required position. The two ends of the threaded rod are held in roller bearings to
constrain any linear movement of it and hence the only resulting motion is the linear travel
of the nut along the threaded rod.


Fig. 2.9 Lead screw mechanism.



Fig. 2.10 Implementation of a lead screw mechanism.
15

 Spur Gears:
The spur gears are used for transmitting the power from the stepper motors
to the threaded rod of the lead screw mechanism. There are a total of 6 gear wheels
employed for transmission, two for each stepper motor and lead screw combination.


Fig. 2.11 Spur gears used in lead screw mechanism.


 Ball bearings:
The threaded rods of the lead screw are supported by two ball bearings, one
on each side of the threaded rod. So there are totally six bearings supporting the three
threaded rods in each direction of X, Y, Z.


Fig. 2.12 Ball bearings used to support the threaded rod.






16

 Hand drilling machine:

The hand drilling machine is mounted in the configuration of a pillar
drilling machine on the vertical threaded rod of lead screw mechanism. This is held in its
position on the support of threaded rod with the help of a clamp. The drilling machine is
moved down and up during drilling process for a single hole on the PCB. The following
are the specifications of the hand drilling machine:

 Input: 220 V, 50 Hz
 Speed: 1700 rpm
 Drill bit range: 1.5 to 10 mm
 Make ; Jainpai Electronic drill
 Model no.: FY-007


Fig. 2.13 Hand drilling machine.

17

3.INTRODUCTION TO EMBEDDED SYSTEM

Embedded systems are systems with self contained programs that are
embedded within a piece of hardware. While a regular computer has many different
applications and software that are related to various tasks, embedded systems are usually
set to a specific task that cannot be altered without physically manipulating the circuit. An
embedded system may be considered as a computer system that is created with optimal
efficiency, thereby allowing it to complete specific functions as quickly as possible.

Embedded system literally means that a system in which the
processor is embedded into the required application. An embedded product uses a
microprocessor or microcontroller to do one specific task only. In an embedded system,
there is only one application software that is typically burned into ROM.

An embedded system may have a controller in two forms, either as a
microprocessor or as a microcontroller. A microprocessor a single chip in the electronic
circuit that contains the Central Processing Unit for a system or it is more like a micro-
computer for that system while a microcontroller is a single chip in a circuit used to control
other devices in an electronic circuit.

Microcontroller differs from a microprocessor in many ways. First
and the most important is its functionality. In order for a microprocessor to be used, other
components such as memory, or components for receiving and sending data must be added
to it. In short that means that microprocessor is the very heart of the computer.

On the other hand, microcontroller is designed to be all of that in
one. No other external components are needed for its application because all necessary
peripherals are already built into it. Thus, we save the time and space needed to construct
devices.




18

3.1 Microprocessor Vs Microcontroller:

 Microprocessor:
 CPU is stand-alone, RAM, ROM, I/O, timer are separate
 Designer can decide on the amount of ROM, RAM and I/O ports.
 expensive
 versatility general-purpose

 Microcontroller:
 CPU, RAM, ROM, I/O and timer are all on a single chip
 Fixed amount of on-chip ROM, RAM, I/O ports
 for applications in which cost, power and space are critical
 single-purpose

3.2 What is a microcontroller?

Microcontrollers as the name suggests can be thought of as small
controllers for a system. They may be thought of as single chip computers that are
embedded into other systems to function as processing or controlling units. For example
the remote control of a television has microcontrollers inside it, that perform decoding and
other controlling functions. They are also used in automobiles, washing machines,
microwave ovens, toys etc, where automation of the system is required.

Microcontrollers are useful to the extent that they communicate with
other devices, such as sensors, motors, switches, keypads, displays, memory and even
other microcontrollers. Many interface methods have been developed over the years to
solve the complex problem of balancing circuit design criteria such as features, cost, size,
weight, power consumption, reliability, availability, manufacturability. Many
microcontroller designs typically mix multiple interfacing methods. In a very simplistic
form, a micro-controller system can be viewed as a system that reads from (monitors)
inputs, performs processing and writes to (controls) outputs.

19

3.3 General features of 8051 microcontroller:

 4KB ROM
 128 bytes internal RA
 4 register banks of 8 bytes each (R0-R7)
 16 bytes of bit-addressable area
 80 bytes of general purpose memory
 Four 8-bit I/O ports (P0-P3)
 Two 16-bit timers (Timer0 & Timer1)
 One serial receiver-transmitter interface
 Five interrupt sources (2 external & 3 internal)
 One oscillator (generates clock signal)

3.4 Architecture of a microcontroller 8051

The features of studying the internal hardware design, and to
determine the type, number, size of registers is called Architecture of a device (8051).


Fig. 3.1 Architecture of 8051 microcontroller.
20

 Central Processing Unit (CPU):
The Central Processing Unit is the main unit that receives data,
manipulates the data and processes it and sends it out. It takes a program as an input for
processing of data. This program is written in permanent memory storage, Read Only
Memory (ROM).
The 8051 contains 34 general purpose or working registers.
Registers A and B comprise the mathematical core of 8051 central processing unit (CPU).
The other 32 are arranged as part of internal RAM in four banks,
The A (Accumulator) register is the most versatile of the two CPU
registers and is used for many operations. The A register is also used for all data transfers
between the 8051 and external memory.

 Internal ROM:
The 8051 is organized so that data memory and program code
memory can be in two entirely different physical memory entities. Each has same address
ranges.

The corresponding block of internal program code, contained in an
internal ROM, occupies code address space 0000h to 0FFFh. Hence the memory unit in
which, the program that defines the manipulations done in the central processing unit, is
called Read Only Memory (ROM).

Generally the ROM is a permanent storage (i.e) anything written in
it cannot be modified. But the recent advancement is an EPROM- Erasable and
Programmable Read Only Memory, in which the written data can be modified as many
times as required.

 Input and Output Port:
The Input and output ports are the components of an 8051
microcontroller that connect it to the external world. There are a total of 40 pins for an
8051 microcontroller, but out of these only 32 are used for Input/output purpose. These 32
pins are grouped into 4 ports P0, P1, P2, and P3 with each port having a set of 8 pins. Out
of these 24 pins can be used for dual purpose. They can be used for input and output
purposes or as a control line or as a part of address or date bus. The function that a pin
21

performs depends firstly upon, what it is physically connected to and then upon what
software commands are used to program the pin.
Given this pin flexibility the 8051 may be simply applied as a
component for input and output purposes or it may be expanded to include additional
memory, parallel ports, and serial communication of data by using alternate pin
assignments.

 Bus Control:
A Bus is component of 8051 micro controller that controls the
transmission of data from CPU to other components and vice-versa. The general bus
control has two sections:
Data bus : The CPU either gets data from the device or sends data to it
Control bus: Provides read or write signals to the device to indicate if the
CPU is asking for information from it or sending it
information.

 The 8051 Oscillator and Clock:
The heart of 8051 is the circuitry that generates clock pulses by
which all the internal operations are synchronized. Pins XTAL1 and XTAL2 are used for
connecting the network to a resonating crystal to form an oscillator. A quartz crystal and a
capacitor are employed for this purpose. The crystal frequency is basic internal clock
frequency of microcontroller. The designs of 8051 microcontroller that are available are
such that they can run at a maximum and minimum frequency, generally the frequency
range is from 1 MHz to 16 MHz. Minimum frequencies imply that some internal memories
are dynamic and must always operate above minimum frequency, or data will be lost.

 Serial Port:
The microcontroller 8051 has a serial data communication that uses
SBUF register to hold data. Register SCON controls data communication, register PCON
controls data rates and pins RXD (P3.0) and TXD (P3.1) are used for the purpose of serial
communication. The SBUF register is indeed two re3gisters, one is to hold data to be
transmitted out of 8051 through TXD while the other is to read data from external sources
through RXD. Both mutually exclusive registers use address 99H.

22

 Timers:
The basic 8051 has two on-chip timers (Timer 0, Timer 1) that can
be used for timing durations or for counting external events. Interval timing allows the
programmer to perform operations at specific instants in time. For example, in an LED
flashing program the LED was turned on for a specific length of time and then turned off
for a specific length of time.


 External Interrupts:
An interrupt is the occurrence of an event (Like timer overflow
setting the TF0 or TF1 flags to 1) that causes a temporary suspension of a program while
the event is serviced by a section of code known as the interrupt service routine. The 8051
has five interrupt sources:
 Two external interrupts are provided through pins INTO-bar and INT1-bar, which
are the alternate functions of port 3 pin 2 and port 3 pin 3, respectively.
 Two internal interrupts are generated by timer 0 overflow and by timer 1 overflow.
 The serial port on the 8051 can generate an interrupt when a byte has been
transmitted or when a byte is received.

Interrupt Flag
Location in
Registers
External 0 IE0 TCON.1
External 1 IE1 TCON.3
Timer 0 TF0 TCON.5
Timer 1 TF1 TCON.7
Serial Port Receive RI SCON.0
Serial Port Transmit TI SCON.1
Table 3.1 Interrupts in microcontroller 8051



23

When an interrupt occurs the following happens:
 The current instruction completes execution.
 The Program Counter is saved on the stack (That is, the address of the next
instruction).
 The address of the ISR for the interrupt is loaded into the Program Counter.
Interrupt Vectors: When an interrupt occurs, the address of the interrupt service routine is
loaded into the PC. This address is known as the interrupt vector.


Interrupt Flag Vector
System reset RST 0000H
External interrupt 0 IE0 0003H
Timer 0 TF0 000BH
External interrupt 1 IE1 0013H
Timer 1 TF1 001BH
Serial port RI or TI 0023H
Table 3.2 Interrupt flags and vectors.

3.5 Pin Configuration of 8051 microcontroller:

Pins 1-8: Port 1 Each of these pins can be configured as an input or an output.
Pin 9: RST A logic one on this pin disables the microcontroller and clears the contents of
most registers. In other words, the positive voltage on this pin resets the microcontroller.
By applying logic zero to this pin, the program starts execution from the beginning.
Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output.
Besides, all of them have alternative functions:
Pin 10: RXD Serial asynchronous communication input or Serial synchronous
communication output.
Pin 11: TXD Serial asynchronous communication output or Serial synchronous
communication clock output.
Pin 12: INT0 Interrupt 0 input.
Pin 13: INT1 Interrupt 1 input.
24

Pin 14: T0 Counter 0 clock input.
Pin 15: T1 Counter 1 clock input.
Pin 16: WR Write to external (additional) RAM.
Pin 17: RD Read from external RAM.
Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies
operating frequency is usually connected to these pins. Instead of it, miniature ceramics
resonators can also be used for frequency stability. Later versions of microcontrollers
operate at a frequency of 0 Hz up to over 50 Hz.
Pin 20: GND Ground pin, it is connected to the ground in the circuit.
Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are
configured as general inputs/outputs. In case external memory is used, the higher address
byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of
64Kb is not used, which means that not all eight port bits are used for its addressing, the
rest of them are not available as inputs/outputs.
Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears
on it every time the microcontroller reads a byte from memory.
Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower
address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the
ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes
the state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is
returned its previous logic state and P0 is now used as a Data Bus. As seen, port data
multiplexing is performed by means of only one additional (and cheap) integrated circuit.
In other words, this port is used for both data and address transmission.
Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means that even
there is a program written to the microcontroller, it will not be executed. Instead, the
program written to external ROM will be executed. By applying logic one to the EA pin,
the microcontroller will use both memories, first internal then external (if exists).
Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as
general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the
ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low
(0).
Pin 40: VCC +5V power supply.

25


Fig. 3.2 Pin configuration of 8051

3.6 Registers of 8051 Microcontroller:

Basic Registers:

 The Accumulator:
The Accumulator, as its name suggests, is used as a
general register to accumulate the results of a large number of instructions. It can
hold an 8-bit (1-byte) value and is the most versatile register the 8051 has due to
the sheer number of instructions that make use of the accumulator. More than half
of the 8051’s 255 instructions manipulate or use the accumulator in some way. This
is one of the two registers in CPU of 8051.

26

 The “B” Register:
The "B" register is very similar to the Accumulator in the sense that
it may hold an 8-bit (1-byte) value. The "B" register is only used by two 8051 instructions:
MUL AB and DIV AB. Thus, if you want to quickly and easily multiply or divide A by
another number, you may store the other number in "B" and make use of these two
instructions. Aside from the MUL and DIV instructions, the “B” register are often
used as yet another temporary storage register much like a ninth "R" register.

 The Program Counter (PC):
The Program Counter (PC) is a 2-byte address which tells the 8051
where the next instruction to execute is found in memory. When the 8051 is initialized PC
always starts at 0000h and is incremented each time an instruction is executed. It is
important to note that PC is not always incremented by one. Since some instructions
require 2 or 3 bytes the PC will be incremented by 2 or 3 in these cases. The Program
Counter is special in that there is no way to directly modify its value. That is an instruction,
PC=2430h is not a valid one. On the other hand, an instruction of LJMP 2430h can be
effectively accomplished to do the same thing.

 The "R" registers:
The "R" registers are a set of eight registers that are named R0, R1,
etc. up to and including R7.These registers are used as auxiliary registers in many
operations.

 The Data Pointer (DPTR):
The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit
(2-byte) register. The Accumulator, "R" registers, and "B" register are all 1-byte values.
DPTR, as the name suggests, is used to point to data. It is used by a number of commands
which allow the 8051 to access external memory. When the 8051 accesses external
memory it will access external memory at the address indicated by DPTR. While DPTR is
most often used to point to data in external memory, an advantage that it is the only true
16-bit register available is very helpful in programming. It is often used to store 2-byte
values which have nothing to do with memory locations.
27

The Stack Pointer (SP): The Stack Pointer, like all registers except
DPTR and PC, may hold an 8-bit (1-byte) value. The Stack Pointer is used to indicate
where the next value to be removed from the stack should be taken from. When you push a
value onto the stack, the 8051 first increments the value of SP and then stores the value at
the resulting memory location. When you pop a value off the stack, the 8051 returns the
value from the memory location indicated by SP and then decrements the value of SP. This
order of operation is important. When the 8051 is initialized SP will be initialized to 07h. If
you immediately push a value onto the stack, the value will be stored in Internal RAM
address 08h. First the 8051 will increment the value of SP (from 07h to 08h) and then will
store the pushed value at that memory address (08h).SP is modified directly by the 8051 by
six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI. It is also used
intrinsically whenever an interrupt is triggered.

 Special Function Registers:
The 8051 is a flexible microcontroller with a relatively large number
of modes of operations. The program may inspect and/or change the operating mode of the
8051 by manipulating the values of the 8051's Special Function Registers (SFRs).SFRs are
accessed as if they were normal Internal RAM. The only difference is that Internal RAM is
from address 00h through 7Fh whereas SFR registers exist in the address range of 80h
through FFh. Each SFR has an address (80h through FFh) and a name. The following chart
provides a graphical presentation of the 8051's SFRs, their names, and their address.


Fig. 3.3 Special function Registers in 8051.
28

Although the address range of 80h through FFh offers 128 possible
addresses, there are only 21 SFRs in a standard 8051. All other addresses in the SFR range
(80h through FFh) are considered invalid. Writing to or reading from these registers may
produce undefined values or behaviour.
It is recommended that you not read or write to SFR addresses that
have not been assigned to an SFR. Doing so may provoke undefined behaviour and may
cause your program to be incompatible with other 8051-derivatives that use the given SFR
for some other purpose.

 SFR Types:
As mentioned in the chart itself, the SFRs that have a blue
background are SFRs related to the I/O ports. The 8051 has four I/O ports of 8 bits, for a
total of 32 I/O lines. Whether a given I/O line is high or low and the value read from the
line are controlled by the SFRs in green. The SFRs with yellow backgrounds are SFRs
which in some way control the operation or the configuration of some aspect of the 8051.
For example, TCON controls the timers, SCON controls the serial port. The remaining
SFRs, with green backgrounds, are "other SFRs." These SFRs can be thought of as
auxiliary SFRs in the sense that they don't directly configure the 8051 but obviously the
8051 cannot operate without them. For example, once the serial port has been configured
using SCON, the program may read or write to the serial port using the SBUF register.
The SFRs whose names appear in red in the chart above are SFRs
that may be accessed via bit operations (i.e., using the SETB and CLR instructions). The
other SFRs cannot be accessed using bit operations. As you can see, all SFRs that whose
addresses are divisible by 8 can be accessed with bit operations.

 SFR Descriptions:
P0 (Port 0, Address 80h, Bit-Addressable):
This is input/output port 0. Each bit of this SFR corresponds to one
of the pins on the microcontroller. For example, bit 0 of port 0 is pin P0.0, bit 7 is pin P0.7.
Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to a low level.
29

8051 has four I/O port (P0, P1, P2, and P3), if your hardware uses
external RAM or external code memory (i.e., your program is stored in an external ROM
or EPROM chip or if you are using external RAM chips) you may not use P0 or P2. This is
because the 8051 uses ports P0 and P2 to address the external memory. Thus if you are
using external RAM or code memory you may only use ports P1 and P3 for your own use.

 SP (Stack Pointer, Address 81h):
This is the stack pointer of the microcontroller. This SFR indicates
where the next value to be taken from the stack will be read from in Internal RAM. If you
push a value onto the stack, the value will be written to the address of SP + 1. That is to
say, if SP holds the value 07h, a PUSH instruction will push the value onto the stack at
address 08h. This SFR is modified by all instructions which modify the stack, such as
PUSH, POP, LCALL, RET, RETI, and whenever interrupts are provoked by the
microcontroller.

 DPL/DPH (Data Pointer Low/High, Addresses 82h/83h):
The SFRs DPL and DPH work together to represent a 16-bit value
called the Data Pointer. The data pointer is used in operations regarding external RAM and
some instructions involving code memory. Since it is an unsigned two-byte integer value, it
can represent values from 0000h to FFFFh (0 through 65,535 decimal).
DPTR is really DPH and DPL taken together as a 16-bit value. In
reality, you almost always have to deal with DPTR one byte at a time. For example, to push
DPTR onto the stack you must first push DPL and then DPH. You can't simply plush
DPTR onto the stack. Additionally, there is an instruction to "increment DPTR." When you
execute this instruction, the two bytes are operated upon as a 16-bit value. However, there
is no instruction those decrements DPTR. If you wish to decrement the value of DPTR, you
must write your own code to do so.
PCON (Power Control, Addresses 87h):
The Power Control SFR is used to control the 8051's power control
modes. Certain operation modes of the 8051 allow the 8051 to go into a type of "sleep"
mode which requires much less power. These modes of operation are controlled through
PCON. Additionally, one of the bits in PCON is used to double the effective baud rate of
the 8051's serial port.
30

 TMOD (Timer Mode, Addresses 89h):
The Timer Mode SFR is used to configure the mode of operation of
each of the two timers. Using this SFR your program may configure each timer to be a 16-
bit timer, an 8-bit auto reload timer, a 13-bit timer, or two separate timers. Additionally,
you may configure the timers to only count when an external pin is activated or to count
"events" that are indicated on an external pin.

Fig. 3.4 TMOD Register in 8051 microcontroller.

 TCON (Timer Control, Addresses 88h, Bit-Addressable):
The Timer Control SFR is used to configure and modify the way in
which the 8051's two timers operate. This SFR controls whether each of the two timers is
running or stopped and contains a flag to indicate that each timer has overflowed.
Additionally, some non-timer related bits are located in the TCON SFR. These bits are
used to configure the way in which the external interrupts are activated and also contain the
external interrupt flags which are set when an external interrupt has occurred.

Fig. 3.5 TCON Register in 8051 microcontroller.


 TL0/TH0 (Timer 0 Low/High, Addresses 8Ah/8Ch):
These two SFRs, taken together, represent timer 0. Their exact
behavior depends on how the timer is configured in the TMOD SFR; however, these timers
always count up. What is configurable is how and when they increment in value.

Fig. 3.6 TL0/TH0 Registers for timer control in 8051.
31


Fig. 3.7 TL1/TH1 Registers for timer control in 8051.

 TL1/TH1 (Timer 1 Low/High, Addresses 8Bh/8Dh):
These two SFRs, taken together, represent timer 1. Their exact
behavior depends on how the timer is configured in the TMOD SFR; however, these timers
always count up. What is configurable is how and when they increment in value.

 P1 (Port 1, Address 90h, Bit-Addressable):
This is input/output port 1. Each bit of this SFR corresponds to one
of the pins on the microcontroller. For example, bit 0 of port 1 is pin P1.0, bit 7 is pin P1.7.
Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to a low level.

 SCON (Serial Control, Addresses 98h, Bit-Addressable):
The Serial Control SFR is used to configure the behavior of the
8051's on-board serial port. This SFR controls the baud rate of the serial port, whether the
serial port is activated to receive data, and also contains flags that are set when a byte is
successfully sent or received.
To use the 8051's on-board serial port, it is generally
necessary to initialize the following SFRs: SCON, TCON, and TMOD. This is
because SCON controls the serial port. However, in most cases the program will
wish to use one of the timers to establish the serial port's baud rate. In this case, it is
necessary to configure timer 1 by initializing TCON and TMOD.

Fig. 3.8 SCON Register in 8051 microcontroller.

32

 SBUF (Serial Control, Addresses 99h):
The Serial Buffer SFR is used to send and receive data via the on-
board serial port. Any value written to SBUF will be sent out the serial port's TXD pin.
Likewise, any value which the 8051 receives via the serial port's RXD pin will be delivered
to the user program via SBUF. In other words, SBUF serves as the output port when
written to and as an input port when read from.

 P2 (Port 2, Address A0h, Bit-Addressable):
This is input/output port 2. Each bit of this SFR corresponds to one
of the pins on the microcontroller. For example, bit 0 of port 2 is pin P2.0, bit 7 is pin P2.7.
Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to a low level.
IE (Interrupt Enable, Addresses A8h):
The Interrupt Enable SFR is used to enable and disable specific
interrupts. The low 7 bits of the SFR are used to enable/disable the specific interrupts,
where as the highest bit is used to enable or disable ALL interrupts. Thus, if the high bit of
IE is 0 all interrupts are disabled regardless of whether an individual interrupt is enabled by
setting a lower bit.
 P3 (Port 3, Address B0h, Bit-Addressable):
This is input/output port 3. Each bit of this SFR corresponds to one
of the pins on the microcontroller. For example, bit 0 of port 3 is pin P3.0, bit 7 is pin P3.7.
Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin
whereas a value of 0 will bring it to a low level.
 IP (Interrupt Priority, Addresses B8h, Bit-Addressable):
The Interrupt Priority SFR is used to specify the relative priority of
each interrupt. On the 8051, an interrupt may either be of low (0) priority or high (1)
priority. An interrupt may only interrupt interrupts of lower priority. For example, if we
configure the 8051 so that all interrupts are of low priority except the serial interrupt, the
serial interrupt will always be able to interrupt the system, even if another interrupt is
currently executing. However, if a serial interrupt is executing no other interrupt will be
33

able to interrupt the serial interrupt routine since the serial interrupt routine has the highest
priority.
 Other SFRs:
The chart above is a summary of all the SFRs that exist in a standard
8051. All derivative microcontrollers of the 8051 must support these basic SFRs in order to
maintain compatibility with the underlying MSCS51 standard. A common practice when
semiconductor firms wish to develop a new 8051 derivative is to add additional SFRs to
support new functions that exist in the new chip. For example, the Dallas Semiconductor
DS80C320 is upwards compatible with the 8051. This means that any program that runs on
a standard 8051 should run without modification on the DS80C320. This means that all the
SFRs defined above also apply to the Dallas component. However, since the DS80C320
provides many new features that the standard 8051 does not, there must be some way to
control and configure these new features. This is accomplished by adding additional SFRs
to those listed here. For example, since the DS80C320 supports two serial ports (as
opposed to just one on the 8051), the SFRs SBUF2 and SCON2 have been added. In
addition to all the SFRs listed above, the DS80C320 also recognizes these two new SFRs
as valid and uses their values to determine the mode of operation of the secondary serial
port. Obviously, these new SFRs have been assigned to SFR addresses that were unused in
the original 8051. In this manner, new 8051 derivative chips may be developed which will
run existing 8051 programs.

 The Program Status Word (PSW)
Every microcontroller contains flags that may be used for testing the
outcome of an instruction's execution. For example, the carry flag may be used to test the
outcome of an 8-bit addition to see if the result is greater than 255. Some microcontrollers
use a special bit to indicate whether the contents of the accumulator are zero or not (the
PIC microcontroller, for example). This flag is usually called the zero or Z flag and
conditional jump† instructions that test its value can be used to branch (jump to another
location in code memory) if the accumulator is zero or if the accumulator is not zero (if Z
is set, the accumulator contains zero, if Z is clear the accumulator contains a number other
than zero). The 8051 does not have such a bit. To test the status of the accumulator the
instructions JZ rel (jump if (A) = 0) and JNZ rel (jump if (A) <> 0) are used. However, the
8051 contains a number of flags, in the special function register called the Program Status
34

Word (PSW). These flags can be tested by conditional jumps. Before we go into the
functions of these flags, it would first be useful to understand how positive and negative
numbers are stored in binary.


Fig. 3.9 PSW Register in 8051 microcontroller.

 Functions of the PSW:


Bit Symbol Address Description
PSW.7 CY D7H Carry flag
PSW.6 AC D6H Auxiliary carry flag
PSW.5 F0 D5H Flag 0
PSW.4 RS1 D4H Register bank select 1
PSW.3 RS0 D3H Register bank select 0
PSW.2 OV D2H Overflow flag
PSW.1 -- D1H Reserved
PSW.0 P D0H Even parity flag

Table 3.3 Functions of PSW Register in 8051.

 Carry Flag:
The carry flag has two functions. Firstly, it is used as the carry-out in
8-bit addition/subtraction. For example, if the accumulator contains FDH and we add 3 to
the contents of the accumulator (ADD A, #3), the accumulator will then contain zero and
the carry flag will be set. It is also set if a subtraction causes a borrow into bit 7. In other
words, if a number is subtracted from another number smaller than it, the carry flag will be
set. For example, if A contains 3DH and R3 contains 4BH, the instruction SUBB A, R3
will result in the carry bit being set (4BH is greater than 3DH).
The carry flag is also used during Boolean operations. For
example, we could AND the contents of bit 3DH with the carry flag, the result being
placed in the carry flag - ANL C, 3DH
35

 Auxiliary Carry Flag (AC):
The auxiliary carry flag is set or cleared after an add instruction
(ADD A, operand or ADDC A, operand) only. The condition that result in AC being is: If a
carry was generated out of bit 3 into bit 4 of the accumulator. In other words, if there is a
carry out from the lower nibble. This flag may be tested after an addition to see if the value
in the accumulator is outside the BCD range. If it is, the instruction DA A (decimal
adjust A) can be used to change the HEX code in A to BCD.
The above code adds 8 to 9, leaving 17 in the accumulator. 17
10
=
11H. This is outside the BCD range. The lower nibble is not between AH and FH, however
if you perform this addition in binary you will see there is a carry from bit 3 into bit 4.
Therefore AC will be set and the following instruction (DA A) will change A from 11 to 17.

 Flag 0:
Flag 0 is a general-purpose flag available to the programmer.


 Register Bank Select Bits:
Bits 3 and 4 of the PSW are used for selecting the register bank.
Since there are four register banks, two bits are required for selecting a bank, as detailed
below.









Table 3.4 Bank selection in 8051.




PSW.4 PSW.3
Register
Bank
Address of Register
Bank
0 0 0 00H to 07H
0 1 1 08H to 0FH
1 0 2 10H to 17H
1 1 3 18H to 1FH
36

 Overflow Flag (OV):
The overflow flag is bit 2 of the PSW. This flag is set after an
addition or subtraction operation if the result in the accumulator is outside the signed 8-bit
range (-128 to 127). In other words, if the addition or subtraction of two numbers results in
a number less than -128 or greater than 127, the OV flag is set. When signed numbers are
added or subtracted, software can check this flag to see if the result is in the range -128 to
127.

 Parity Bit:
The parity bit is automatically set or cleared every machine cycle to
ensure even parity with the accumulator. The number of 1-bits in the accumulator plus the
parity bit is always even. In other words, if the number of 1s in the accumulator is odd then
the parity bit is set to make the overall number of bits even. If the number of 1s in the
accumulator is even then the parity bit is cleared to make the overall number of bits even.
For example, if the accumulator holds the number 05H, this is 0000 0101 in binary => the
accumulator has an even number of 1s, therefore the parity bit is cleared. If the
accumulator holds the number F2H, this is 1111 0010 => the accumulator has an odd
number of 1s, therefore the parity bit is set to make the overall number of 1s even. Parity
bit is most often used for detecting errors in transmitted data.















37

4. CIRCUIT OF THE PCB DRILLING MACHINE


Fig. 4.1 Circuit of PCB drilling machine.

4.1 Parts of the circuit:

 Transformer:
The transformer is a step down transformer. The Primary side of it
has an input voltage of 220 V AC and the secondary side of the transformer gives an output
voltage of 9V AC. It steps down the voltage from 220V to 9V. Then this 9v AC signal is
converted into 9V dc by a bridge rectifier.

 Regulator Circuit:
The regulator circuit has four resistances to control the voltage and
current out from the secondary side of the secondary side of the transformer. The
resistances are followed by Capacitor to store charge to maintain the voltage at the required
level (about 9v). The capacitor is followed by a regulator that controls the voltage to a 5V
38

signal which is the required voltage input for the microcontroller. Before the voltage signal
reaches the microcontroller some of the current flows through a set of another 4 resistors
and to an LED that indicates the power input and then to a filter circuit (Capacitors) that
reduces any disturbances in the 5V signal.


Fig. 4.2 Regulator circuit.

 The main microcontroller AT89C51 (8051):
The microcontroller 8051 acts as the main controller of the entire
circuit and hence gives signals to the Key board, LCD unit, three secondary
microcontrollers (that give signals to the driver circuit to run the three stepper motors that
control the table movement and drilling machine movement via driver circuit).
39


Fig. 4.3 Schema of main 8051 microcontroller.

Fig. 4.4 Key board pin connections from main 8051 microcontroller.

The pins of the main microcontroller are used as follows:
 The regulated supply of 5 V is given to the VCC (40
th
pin).
 The entire Port 0 (pin 32 (0.0) to 39 (0.7)) is connected as the data lines to the LCD
data input pins I(D0 to D7)
 Pins 2.5, 2.6, 2.7 are connected to the three control pins of the LCD unit, RS, R/W,
Enable respectively.
 The pins 2.1, 2.2, 2.3, 2.4, are connected to the four keys on the keyboard namely
Select, Increment, Decrement, Run respectively.
 The pins 18 and 19 namely XTAL2 and XTAL1 respectively are connected to
oscillator for clock control of the timers of the 8051 microcontroller.
 The pin 20 is connected to the ground.
 The pins P1.0 and P1.1 are connected to 20 pin microcontroller for X direction
stepper motor. Similarly P1.2, P1.3 and P1.4, 1.5 are connected to the other two
secondary (20 pin) microcontrollers.

40

 Secondary microcontroller AT89C2051:

Fig. 4.5Secondary microcontroller.

Apart from the main microcontroller 8051 which has the main
control of the circuit, there are three more microcontrollers, each of them a 20 pin
microcontrollers (AT89C2051). They can be thought of as 20 pin 20 pin 8051s. The pin
connections discussed above shows that there are only 12 more pins free to be used in the
main microcontroller, but the three stepper motors need six pins each to give the driving
signal. This necessitates the requirement of three 20 pin microcontrollers, one for each
stepper motor. The signaling will be done to the Stepper Motor driving circuit by the main
microcontroller via respective secondary microcontrollers.

 The Driver Circuit:


Fig. 4.6 Driver circuit for stepper motors.
41


The driver circuit gets the pulse signals from the secondary
microcontrollers to run the three stepper motors that execute the table movement and the
drilling machine upward and downward movement. The driver circuit is comprised of
optocouplers, transistors SL100 and TIP 122 and LEDs.

 The components of the driver circuit and their role:
(i) Optocoupler:

Fig. 4.7 Optocoupler.

There are many situations where signals and data need to be
transferred from one subsystem to another within a piece of electronics equipment, or from
one piece of equipment to another, without making a direct ohmic electrical connection.
Often this is because the source and destination are (or may be at times) at very different
voltage levels. In this case the microcontroller is operating from 5V DC but being used to
control a Stepper motor which is getting a 12V DC input from the SMPS. In this situation
the link between the two must be an isolated one, to protect the microcontroller from
overvoltage damage. Relays can provide this kind of isolation, but even small relays tend
to be fairly bulky compared with ICs and many of other miniature circuit components.
42

Because they are electro-mechanical, relays are also not as reliable and only capable of
relatively low speed operation. Where small size, higher speed and greater reliability are
important, a much better alternative is to use an Optocoupler. These use a beam of light to
transmit the signals or data across an electrical barrier, and achieve excellent isolation.

Optocouplers typically come in a small 6-pin or 8-pin IC package,
but are essentially a combination of two distinct devices: an optical transmitter, typically a
gallium arsenide LED (light-emitting diode) and an optical receiver such as a
phototransistor. The two are separated by a transparent barrier which blocks any electrical
current flow between the two, but does allow the passage of light. The basic idea is shown
in diagram, along with the usual circuit symbol for an optocoupler. Usually the electrical
connections to the LED section are brought out to the pins on one side of the package and
those for the phototransistor to the other side, to physically separate them as much as
possible. This usually allows optocouplers to withstand voltages of anywhere between
500V and 7500V between input and output. Optocouplers are essentially digital or
switching devices, so they.re best for transferring on-off control signals. Analog signals
can be transferred by means of frequency or pulse-width modulation.

(ii) Transistors:
The voltage signal transmitted from the secondary microcontrollers
to the drivers circuit via optocoupler is boosted by two transistors, namely SL 100 and TIP
122.

Fig. 4.8 SL 100. Fig. 4.9 TIP122.

43

Amplification is the process of increasing the strength of a SIGNAL.
A signal is just a general term used to refer to any particular current, voltage, or power in a
circuit. An amplifier is the device that provides amplification (the increase in current,
voltage, or power of a signal) without appreciably altering the original signal. The final
output after amplification is around 12 V.
Each of the three stepper motors used are connected to a set of four
TIP122 transistors, four SL100 transistors, four Optocouplers. So, the total number of
Optocouplers, Transistors SL100 and TIP 122 as 12 of each kind. Three are also four LEDs
for each stepper motors indicating the functioning of a particular stepper motor at a
particular instant.

(iii) Switched Mode Power Supply (SMPS):
The power required for the operation of the Stepper motors is
supplied through a Switched Mode Power Supply. Switched-mode power supply is an
electronic power supply that incorporates a switching regulator in order to be highly
efficient in the conversion of electrical power. An SMPS transfers power from a source
like the electrical power grid to a load while converting voltage and current characteristics.
An SMPS is usually employed to efficiently provide a regulated output voltage, typically at
a level different from the input voltage.

Unlike a linear power supply, the pass transistor of a switching
mode supply switches very quickly (typically between 50 kHz and 1 MHz) between full-on
and full-off states, which minimizes wasted energy. Voltage regulation is provided by
varying the ratio of on to off time. In contrast, a linear power supply must dissipate the
excess voltage to regulate the output. This higher efficiency is the chief advantage of a
switch-mode power supply.

44


Fig. 4.10 SMPS Circuit.


























45

4.2 Schematic diagrams of the circuit:

Fig. 4.11 Schematic part-1, Main microcontroller.







46



Fig. 4.12 Schematic part-2, Stepper motor for X axis travel.

47


Fig. 4.13 Schematic part-3, Stepper motor for Y axis travel.









48





Fig. 4.14 Schematic part-4, Stepper motor for X axis travel.





49

5. INSTRUCTION SET TO PROGRAM 8051 MC IN
ASSEMBLY LANGUAGE
There are a number of useful instructions in assembly language that
enable us to program the 8051 microcontroller to perform the required task. The most
widely used and important of those instructions are as follows:

5.1 MOV Instructions:

 MOV: MOV copies the value of operand2 into operand1. The value
of operand2 is not affected. Both operand1 and operand2 must be in Internal RAM. No
flags are affected unless the instruction is moving the value of a bit into the carry bit in
which case the carry bit is affected or unless the instruction is moving a value into the PSW
register (which contains all the program flags).
Instructions Op Code Bytes
MOV @R0,#data 0x76 2
MOV @R1,#data 0x77 2
MOV @R0,A 0xF6 1
MOV @R1,A 0xF7 1
MOV @R0,iram addr 0xA6 2
MOV @R1,iram addr 0xA7 2
MOV A,#data 0x74 2
MOV A,@R0 0xE6 1
MOV A,@R1 0xE7 1
MOV A,R0 0xE8 1
MOV A,R1 0xE9 1
MOV A,R2 0xEA 1
MOV A,R3 0xEB 1
MOV A,R4 0xEC 1
MOV A,R5 0xED 1
MOV A,R6 0xEE 1
MOV A,R7 0xEF 1
50

MOV C,bit addr 0xA2 2
MOV DPTR,#data16 0x90 3
MOV R0,#data 0x78 2
MOV R1,#data 0x79 2
MOV R2,#data 0x7A 2
MOV R3,#data 0x7B 2
MOV R4,#data 0x7C 2
MOV R5,#data 0x7D 2
MOV R6,#data 0x7E 2
MOV R7,#data 0x7F 2
MOV R0,A 0xF8 1
MOV R1,A 0xF9 1
MOV R2,A 0xFA 1
MOV R3,A 0xFB 1
MOV R4,A 0xFC 1
MOV R5,A 0xFD 1
MOV R6,A 0xFE 1
MOV R7,A 0xFF 1
Table 5.1 MOV instruction.

 MOVC: MOVC moves a byte from Code Memory into the Accumulator. The
Code Memory address from which the byte will be moved is calculated by summing the
value of the Accumulator with either DPTR or the Program Counter (PC). In the case of
the Program Counter, PC is first incremented by 1 before being summed with the
Accumulator.


51

Instructions Op Code Bytes
MOVC A,@A+DPTR 0x93 1
MOVC A,@A+PC 0x83 1
Table 5.2 MOVC instruction.

 MOVX: MOVX moves a byte to or from External Memory into or from the
Accumulator.
If operand1 is @DPTR, the Accumulator is moved to the 16-bit External Memory
address indicated by DPTR. This instruction uses both P0 (port 0) and P2 (port 2) to output
the 16-bit address and data. If operand2 is DPTR then the byte is moved from External
Memory into the Accumulator.
If operand1 is @R0 or @R1, the Accumulator is moved to the 8-bit External Memory
address indicated by the specified Register. This instruction uses only P0 (port 0) to output
the 8-bit address and data. P2 (port 2) is not affected. If operand2 is @R0 or @R1 then the
byte is moved from External Memory into the Accumulator.
Instructions Op Code Bytes
MOVX @DPTR,A 0xF0 1
MOVX @R0,A 0xF2 1
MOVX @R1,A 0xF3 1
MOVX A,@DPTR 0xE0 1
MOVX A,@R0 0xE2 1
MOVX A,@R1 0xE3 1
Table 5.3 MOVX instruction.

5.2 The Accumulator as a Shift and a Rotate Register:
As we shall see, the ability to use the accumulator as a shift register
is very useful in assembly programming. Almost all microcontrollers allow the
programmer to use some register in this fashion. The 8051 has a number of instructions,
known as the rotate instructions that rotate the bits around the accumulator.

52

 RR A:
This instruction is rotate right the accumulator. Its operation
is illustrated below:

Fig. 5.4 Rotate right instruction.
Each bit is shifted one location to the right, with bit 0 going to bit 7.

 RL A:
This instruction is rotate right the accumulator. Its operation
is illustrated below:

Fig. 5.5 Rotate left instruction.

Each bit is shifted one location to the left, with bit 7 going to bit 0.

 Rotating through the Carry:
There are two instructions that, in effect, create a 9-bit rotate
register.

RRC A:
Rotate right through the carry.

Fig. 5.6 Rotate right through carry instruction.

53

Each bit is shifted one location to the right, with bit 0 going into the carry bit in
the PSW, while the carry was at goes into bit 7 (i.e. if the carry was set prior to
the execution of RRC A, then bit 7 of the accumulator will contain 1 after
execution of RRC A. Similarly, if the carry was clear prior to execution of RRC
A, then bit 7 of the accumulator will contain 0 after execution of RRC A).


RLC A:
Rotate left through the carry.

Fig. 5.7 Rotate left through carry instruction.

Each bit is shifted one location to the left, with bit 7 going into the carry bit in
the PSW, while the carry goes into bit 0.

5.3 Arithmetic instructions:

 ADD:
ADD and ADDC both add the value operand to the value of the
Accumulator, leaving the resulting value in the Accumulator. The value operand is not
affected. ADD and ADDC function identically except that ADDC adds the value of
operand as well as the value of the Carry flag whereas ADD does not add the Carry flag to
the result.

Instructions Op Code Bytes
ADD A,#data 0x24 2
ADD A,@R0 0x26 1
ADD A,@R1 0x27 1
ADD A,R0 0x28 1
54

ADD A,R1 0x29 1
ADD A,R2 0x2A 1
ADD A,R3 0x2B 1
ADD A,R4 0x2C 1
ADD A,R5 0x2D 1
ADD A,R6 0x2E 1
ADD A,R7 0x2F 1
ADDC A,#data 0x34 2
ADDC A,@R0 0x36 1
ADDC A,@R1 0x37 1
ADDC A,R0 0x38 1
ADDC A,R1 0x39 1
ADDC A,R2 0x3A 1
ADDC A,R3 0x3B 1
ADDC A,R4 0x3C 1
ADDC A,R5 0x3D 1
ADDC A,R6 0x3E 1
ADDC A,R7 0x3F 1
Table 5.4 Add instruction.

 SUB:
SUBB subtract the value of operand from the value of the
Accumulator, leaving the resulting value in the Accumulator. The value operand is not
affected.
Instructions Op Code Bytes
SUBB A,#data 0x94 2
SUBB A,@R0 0x96 1
SUBB A,@R1 0x97 1
SUBB A,R0 0x98 1
SUBB A,R1 0x99 1
SUBB A,R2 0x9A 1
SUBB A,R3 0x9B 1
55

SUBB A,R4 0x9C 1
SUBB A,R5 0x9D 1
SUBB A,R6 0x9E 1
SUBB A,R7 0x9F 1
Table 5.5 Subtract instruction.

 MUL:
Multiples the unsigned values of the Accumulator by the unsigned
value of the “B” register. The least significant byte of the result is placed in the
Accumulator and the most-significant-byte is placed in the "B" register.

Instructions Op Code Bytes
MUL AB 0xA4 1
Table 5.6 Multiply instruction.



 DIV:
Divides the unsigned value of the Accumulator by the unsigned
value of the "B" register. The resulting quotient is placed in the Accumulator and the
remainder is placed in the "B" register.
Instructions Op Code Bytes
DIV AB 0x84 1
Table 5.8 Division instruction.

5.4 Increment and Decrement:

 INC:
INC increments the value of register by 1. If the initial value
of register is 255 (0xFF Hex), incrementing the value will cause it to reset to 0. Note: The
Carry Flag is NOT set when the value "rolls over" from 255 to 0.
56

In the case of "INC DPTR", the value two-byte unsigned integer value of DPTR is
incremented. If the initial value of DPTR is 65535 (0xFFFF Hex), incrementing the value
will cause it to reset to 0. Again, the Carry Flag is NOT set when the value of DPTR "rolls
over" from 65535 to 0.
Instructions Op Code Bytes
INC A 0x04 1
INC @R0 0x06 1
INC @R1 0x07 1
INC R0 0x08 1
INC R1 0x09 1
INC R2 0x0A 1
INC R3 0x0B 1
INC R4 0x0C 1
INC R5 0x0D 1
INC R6 0x0E 1
INC R7 0x0F 1
INC DPTR 0xA3 1
Table 5.9 Increment instruction.


 DEC:
DEC decrements the value of register by 1. If the initial value
of register is 0, decrementing the value will cause it to reset to 255 (0xFF Hex). Note: The
Carry Flag is NOT set when the value "rolls over" from 0 to 255.
Instructions Op Code Bytes
DEC A 0x14 1
DEC iram addr 0x15 2
DEC @R0 0x16 1
DEC @R1 0x17 1
DEC R0 0x18 1
DEC R1 0x19 1
DEC R2 0x1A 1
57

DEC R3 0x1B 1
DEC R4 0x1C 1
DEC R5 0x1D 1
DEC R6 0x1E 1
DEC R7 0x1F 1
Table 5.10 Decrement instruction.


5.5 SETB, CLR and CPL:

 SETB:
Sets the specified bit to 1.

Instructions Op Code Bytes
SETB C 0xD3 1
SETB bit address 0xD2 2
Table 5.11 Setbit instruction.

 CLR:
CLR clears (sets to 0) all the bit(s) of the indicated register. If the
register is a bit (including the carry bit), only the specified bit is affected. Clearing the
Accumulator sets the Accumulator’s value to 0.

Instructions Op Code Bytes
CLR bit address 0xC2 2
CLR C 0xC3 1
CLR A 0xE4 1
Table 5.12 Clear instruction.

 CPL:
CPL complements (1 is set to zero and 0 is set to 1) operand, leaving
the result in operand. If operand is a single bit then the state of the bit will be reversed.
58

If operand is the Accumulator then all the bits in the Accumulator will be reversed. This
can be thought of as "Accumulator Logical Exclusive OR 255" or as "255-Accumulator."
If the operand refers to a bit of an output Port, the value that will be complemented is based
on the last value written to that bit, not the last value read from it.

Instructions Op Code Bytes
CPL A 0xF4 1
CPL C 0xB3 1
CPL bit address 0xB2 2
Table 5.13 Compliment instruction.

5.6 JUMPS and CALLS:

 JMP:
JMP jumps unconditionally to the address represented by the sum of
the value of DPTR and the value of the Accumulator.

Instructions Op Code Bytes
JMP @A+DPTR 0x73 1
Table 5.14 Jump instruction.

 SJMP:
SJMP jumps unconditionally to the address specified related
address. Related address must be within -128 or +127 bytes of the instruction that follows
the SJMP instruction.

Instructions Op Code Bytes
SJMP related address 0x80 2
Table 5.15 Short Jump instruction.

 LJMP:
LJMP jumps unconditionally to the specified code and address.
59


Instructions Op Code Bytes
LJMP code address 0x02 3
. Table 5.16 Long Jump instruction.

 AJMP:
AJMP unconditionally jumps to the indicated code address. The new
value for the Program Counter is calculated by replacing the least-significant-byte of the
Program Counter with the second byte of the AJMP instruction, and replacing bits 0-2 of
the most-significant-byte of the Program Counter with 3 bits that indicate the page of the
byte following the AJMP instruction. Bits 3-7 of the most-significant-byte of the Program
Counter remain unchanged.
Instructions Op Code Bytes
AJMP page0 0x01 2
AJMP page1 0x21 2
AJMP page2 0x41 2
AJMP page3 0x61 2
AJMP page4 0x81 2
AJMP page5 0xA1 2
AJMP page6 0xC1 2
AJMP page7 0xE1 2
Table 5.17AJump instruction.

 JZ:
JZ branches to the address indicated by related address, if the
Accumulator contains the value 0. If the value of the Accumulator is non-zero program
execution continues with the instruction following the JZ instruction.

Instructions Op Code Bytes
JZ related address 0x60 2
Table 5.18 Jump Zero instruction.

60

 JNZ:
JNZ will branch to the address indicated by related address if the
Accumulator contains any value except 0. If the value of the Accumulator is zero program
execution continues with the instruction following the JNZ instruction.

Instructions Op Code Bytes
JNZ related address 0x70 2
Table 5.19 Jump Not Zero instruction.

 JB:
JB branches to the address indicated by related address if the bit
indicated by bit address is set. If the bit is not set program execution continues with the
instruction following the JB instruction.

Instructions Op Code Bytes
JB bit address, related address 0x20 3
Table 5.20 Jump Bit instruction.

 JNB:
JNB will branch to the address indicated by related address if the
indicated bit is not set. If the bit is set program execution continues with the instruction
following the JNB instruction.

Instructions Op Code Bytes
JNB bit address, related address 0x30 3
Table 5.21 Jump Not Bit instruction.

 JC:

JC will branch to the address indicated by related address if the
Carry Bit is set. If the Carry Bit is not set program execution continues with the instruction
following the JC instruction.

61

Instructions Op Code Bytes
JC related address 0x40 2
Table 5.22 Jump Carry instruction.

 JNC:

JNC branches to the address indicated by related address if the carry
bit is not set. If the carry bit is set program execution continues with the instruction
following the JNB instruction.

Instructions Op Code Bytes
JNC related address 0x50 2
Table 5.23 Jump Not Carry instruction.


 JBC:
JBC will branch to the address indicated by related address if the bit
indicated by bit address is set. Before branching to related address the instruction will
clear the indicated bit. If the bit is not set program execution continues with the instruction
following the JBC instruction.

Instructions Op Code Bytes
JBC bit address, related address 0x10 3
Table 5.24 Jump Bit Carry instruction.

 CJNE:
CJNE compares the value of operand1 and operand2 and branches
to the indicated relative address if operand1 and operand2 are not equal. If the two
operands are equal program flow continues with the instruction following the CJNE
instruction.


62

Instructions Op Code Bytes
CJNE A,#data, related address 0xB4 3
CJNE @R0,#data,related address 0xB6 3
CJNE @R1,#data,related address 0xB7 3
CJNE R0,#data,related address 0xB8 3
CJNE R1,#data,related address 0xB9 3
CJNE R2,#data,related address 0xBA 3
CJNE R3,#data,related address 0xBB 3
CJNE R4,#data,related address 0xBC 3
CJNE R5,#data,related address 0xBD 3
CJNE R6,#data,related address 0xBE 3
CJNE R7,#data,related address 0xBF 3
Table 5.25 Conditional Jump.



 ACALL:
LCALL calls a program subroutine. LCALL increments the program
counter by 3 (to point to the instruction following LCALL) and pushes that value onto the
stack (low byte first, high byte second). The Program Counter is then set to the 16-bit value
which follows the LCALL op code, causing program execution to continue at that address.

Instructions Op Code Bytes
LCALL code address 0x12 3
Table 5.26 Acall instruction.


 LCALL:
LCALL calls a program subroutine. LCALL increments the program
counter by 3 (to point to the instruction following LCALL) and pushes that value onto the
63

stack (low byte first, high byte second). The Program Counter is then set to the 16-bit value
which follows the LCALL op code, causing program execution to continue at that address.

Instructions Op Code Bytes
LCALL code address 0x12 3
Table 5.27 Long Call instruction.


 RET:
ET is used to return from a subroutine previously called by LCALL
or ACALL. Program execution continues at the address that is calculated by popping the
topmost 2 bytes off the stack. The most-significant-byte is popped off the stack first,
followed by the least-significant-byte.

Instructions Op Code Bytes
RET 0x22 1
Table 5.28 Return instruction.



Stack related Instructions:

 PUSH:
PUSH "pushes" the value of the specified internal ram address onto
the stack. PUSH first increments the value of the Stack Pointer by 1, then takes the value
stored in internal ram address and stores it in Internal RAM at the location pointed to by
the incremented Stack Pointer.

Instructions Op Code Bytes Cycles Flags
PUSH internal ram address 0xC0 2 2 None
Table 5.29 Push instruction.

64

 POP:
POP "pops" the last value placed on the stack into the internal ram
address specified. In other words, POP will load internal ram address with the value of the
Internal RAM address pointed to by the current Stack Pointer. The stack pointer is then
decremented by 1.

Instructions Op Code Bytes Cycles Flags
POP internal ram address 0xD0 2 2 None
Table 5.30 Pop instruction.






























65

6. INTERFACING THE MICROCONTROLLER TO A
LCD UNIT AND A KEYBOARD

Using the Assembly language a four key keyboard and an LCD
screen are interfaced to the microcontroller 8051. The keyboard is used to select the time
for which each stepper motor is to be run to bring the work table to a required position
such that a hole can be made at the required location on the PCB. The LCD display guides
the user about which stepper motor’s time is the user is setting and to how much value, the
time is it being set.

6.1 Four keys on keyboard:

 Select key:
Select key is used to select the data that is to be fed into the memory
of the microcontroller (Time of running for each stepper motor) or to select the
stepper motor for which the data is to be set.

 Increment Key:
Increment key is used to increase the value of time of running of the
selected stepper motor.

 Decrement key:
Decrement key is used to decrease the value of time of running of
the selected stepper motor.

 Run key:
Run key is used to finally execute the program with the data that is
given as input and to drill a hole at a desired point on the PCB.
The input to the keyboard is always guided in the LCD display by
showing what data is being fed as input to the microcontroller at a particular time.


66

7. OPERATION OF THE PCB DRILLING MACHINE

7.1 Operation steps:
1. Place the prototype of the PCB drilling machine on a table with sufficient space and
of reasonable height.
2. Give the connections of the circuit to the three stepper motors using RS 232 cables.
3. Connect the plugs of the main Circuit, SMPS and Hand drilling machine to the 220
V power supply.
4. Switch on the switch of the main circuit and observe that the LED that indicates the
power supply to the circuit is glowing. The Display screen reads as PROJECT_.
5. Press the SELECT button on the keyboard and holding it press the RUN button
wait for 5 seconds and leave the run button first and then leave the Select button.
6. Then it proceeds to a screen reading PROJECT 1 010_, the cursor at the end will
be blinking.
7. Set the first motor (controlling X direction of the table) running time to a value
above or below the 10 using the INCREMENT or DECREMENT keys and press
the select button.
8. Then it proceeds to a screen reading PROJECT 2 010_, the cursor at the end will
be blinking.
9. Set the second motor (controlling Y direction of the table) running time to a value
above or below the 10 using the INCREMENT or DECREMENT keys and press
the select button.
10. Then it proceeds to a screen reading PROJECT 3 010_, the cursor at the end will
be blinking.
11. Set the second motor (controlling Z direction of the drilling machine) running time
to a value above or below the 10 using the INCREMENT or DECREMENT keys
and press the select button.
12. Press SELECT button to complete the drilling project. Now the cursor stops
blinking.
13. Switch ON the 220 V supply to the SMPS. All the LEDs of the Driver Circuit will
glow.
14. On the hand drilling machine and keep it in hold position.
67

15. Press start the process by pressing RUN button to start the table movement and
finally drilling of the hole is done. Then, the stepper motors operate in reverse
direction and the table reaches the initial position.
16. Repeat the process with different motor timings to drill at a different location.





























68

8. PROGRAM FOR MICROCONTROLLER OF
PCB DRILLING MACHINE

8.1 PROGRAM:
TICK DATA 7FH
DIGIT1 DATA 7EH
DIGIT2 DATA 7DH
DIGIT3 DATA 7CH
DIGIT4 DATA 7BH
SEC DATA 7AH
PERIOD1 DATA 79H
PERIOD2 DATA 78H
PERIOD3 DATA 77H

FLAG1 BIT 01
;--------------------------------------
M1_FOR BIT P1.0
M1_REV BIT P1.1
M2_FOR BIT P1.2
M2_REV BIT P1.3
M3_FOR BIT P1.4
M3_REV BIT P1.5
;--------------------------------------
ENTER BIT P2.0
UP_BTTN BIT P2.1
DOWN_BTTN BIT P2.2
RUN BIT P2.3
;--------------------------------------
; ***LCD CONTROL***
DAT EQU P0
RS BIT P2.5; LCD REGISTER SELECT LINE
RW BIT P2.6; LCD READ / WRITE LINE
EN BIT P2.7; LCD ENABLE LINE
69

;-------------------------------------------------------
ORG 00H
JMP START
;-------------------------------
ORG 01BH
JMP ISR1
;-------------------------------
ORG 030H
START:
MOV SP,#30H; POSITION STACK ABOVE BUFFER
MOV P1,#0FFH
MOV TMOD,#10H
MOV TICK,#20
MOV TH1,#0C5H
MOV TL1,#0BDH
MOV PERIOD1,#10
MOV PERIOD2,#10
MOV PERIOD3,#10
SETB UP_BTTN; INIT as input pin
SETB DOWN_BTTN; INIT as input pin
SETB ENTER; INIT as input pin
SETB RUN; INIT as input pin
SETB EA
SETB ET1
CLR TR1
CALL INIT_LCD
MOV DPTR,#MSG1
CALL DISP
CHECK_KEY:
JNB RUN,CHECK
CALL DEBOUNCE
JMP CHECK_KEY
;------------------------------
CHECK:
70

JB ENTER,BEGIN
JMP SET_PERIOD1
;--------------------------------

BEGIN:
MOV DPTR,#MSG2
CALL DISP

CLR M1_FOR; m1 forward run
MOV SEC,PERIOD1
SETB FLAG1
SETB TR1
JB FLAG1,$

SETB M1_FOR; m1 stop

CLR M2_FOR; m2 forward run

MOV SEC,PERIOD2
SETB FLAG1
SETB TR1
JB FLAG1,$

SETB M2_FOR; m2 stop

CLR M3_FOR; m3 forward run

MOV SEC,PERIOD3
SETB FLAG1
SETB TR1
JB FLAG1,$

SETB M3_FOR; m3 stop
;-------------------------------------------------
71

CLR M3_REV; m3 reverse run

MOV SEC,PERIOD3
SETB FLAG1
SETB TR1
JB FLAG1,$
SETB M3_REV; m3 stop



CLR M1_REV; m1 reverse run
MOV SEC,PERIOD1
SETB FLAG1
SETB TR1
JB FLAG1,$

SETB M1_REV; stop m1

CLR M2_REV; m2 reverse run

MOV SEC,PERIOD2
SETB FLAG1
SETB TR1
JB FLAG1,$

SETB M2_REV; m2 stop


JMP CHECK_KEY
;-------------------------------------------
;-------
;-------------------------------------------
SET_PERIOD1:
JNB ENTER,SET_PERIOD1
72

CALL DEBOUNCE
MOV B,#1
CALL PLACECUR2
CALL PRTLCD4
DB 'PERIOD-1>',0
WAIT_PER1:
JNB UP_BTTN,UP_PER1
JNB DOWN_BTTN,DOWN_PER1
JNB ENTER,DURATION_PER1
MOV SEC,PERIOD1
CALL UPDATE1
JMP WAIT_PER1
UP_PER1:
JNB UP_BTTN,UP_PER1
INC PERIOD1
JMP WAIT_PER1
DOWN_PER1:
JNB DOWN_BTTN,DOWN_PER1
DEC PERIOD1
JMP WAIT_PER1
DURATION_PER1:
JNB ENTER,DURATION_PER1
CALL DEBOUNCE
MOV SEC,PERIOD1
; JMP BEGIN
;---------------------------------------
;---------------------------------------
SET_PERIOD2:
JNB ENTER,SET_PERIOD2
MOV B,#1
CALL PLACECUR2
CALL PRTLCD4
DB 'PERIOD-2>',0
WAIT_PER2:
73

JNB UP_BTTN,UP_PER2
JNB DOWN_BTTN,DOWN_PER2
JNB ENTER,DURATION_PER2
MOV SEC,PERIOD2
CALL UPDATE1
JMP WAIT_PER2
UP_PER2:
JNB UP_BTTN,UP_PER2
INC PERIOD2
JMP WAIT_PER2
DOWN_PER2:
JNB DOWN_BTTN,DOWN_PER2
DEC PERIOD2
JMP WAIT_PER2
DURATION_PER2:
JNB ENTER,DURATION_PER2
CALL DEBOUNCE
MOV SEC,PERIOD2
;---------------------------------------
SET_PERIOD3:
JNB ENTER,SET_PERIOD3
MOV B,#1
CALL PLACECUR2
CALL PRTLCD4
DB 'PERIOD-3>',0
WAIT_PER3:
JNB UP_BTTN,UP_PER3
JNB DOWN_BTTN,DOWN_PER3
JNB ENTER,DURATION_PER3
MOV SEC,PERIOD3
CALL UPDATE1
JMP WAIT_PER3
UP_PER3:
JNB UP_BTTN,UP_PER3
74

INC PERIOD3
JMP WAIT_PER3
DOWN_PER3:
JNB DOWN_BTTN,DOWN_PER3
DEC PERIOD3
JMP WAIT_PER3
DURATION_PER3:
JNB ENTER,DURATION_PER3
CALL DEBOUNCE
MOV SEC,PERIOD3
JMP CHECK_KEY
;-------------------------------
;----------SUBROUTINES
;-------------------------------
; LOOKUP TABLE USED BY WRITE_BCD.
;-------------------------------
UPDATE1:
MOV A,SEC
MOV B,#100
DIV AB
MOV DIGIT1,A ;100S INDIGIT1
MOV A,B
MOV B,#10
DIV AB
MOV DIGIT2,A ;10S in digit2
MOV DIGIT3,B ;1s in digit3

MOV B,#10
CALL PLACECUR2
MOV A,DIGIT1
CALL FIND

MOV B,#11
CALL PLACECUR2
75

MOV A,DIGIT2
CALL FIND

MOV B,#12
CALL PLACECUR2
MOV A,DIGIT3
CALL FIND
RET
;--------------------------------------
FIND:
SJMP LOOK_UP
ST:
RET
LOOK_UP:
CJNE A,#0000000B,m1
LCALL PRTLCD4
DB '0',0
LJMP ST
m1:
CJNE A,#00000001B,m2
LCALL PRTLCD4
DB '1',0
LJMP ST
m2:
CJNE A,#00000010B,m3
LCALL PRTLCD4
DB '2',0
LJMP ST
m3:
CJNE A,#00000011B,m4
LCALL PRTLCD4
DB '3',0
LJMP ST
m4:
76

CJNE A,#00000100B,m5
LCALL PRTLCD4
DB '4',0
LJMP ST
m5:
CJNE A,#00000101B,m6
LCALL PRTLCD4
DB '5',0
LJMP ST
m6:
CJNE A,#00000110B,m7
LCALL PRTLCD4
DB '6',0
LJMP ST
m7:
CJNE A,#00000111B,m8
LCALL PRTLCD4
DB '7',0
LJMP ST
m8:
CJNE A,#00001000B,m9
LCALL PRTLCD4
DB '8',0
LJMP ST
m9:
CJNE A,#00001001B,m10
LCALL PRTLCD4
DB '9',0
LJMP ST
m10:
LJMP ST
;---------------------------------------------
;---SUB for string printing
;---------------------------------------------
77

PRTLCD4:
POP DPH
POP DPL
PRTNEXT:
CLR A
MOVC A,@A+DPTR
CJNE A,#0,CHROK
SJMP RETPRTLCD
CHROK:
CALL WRITE_TEXT
INC DPTR
JMP PRTNEXT
RETPRTLCD:
MOV A,#1
JMP @A+DPTR
;---------------------------------------------------------
;------ INITIALIZE THE LCD
;---------------------------------------------------------
INIT_LCD:
SETB EN ;enable lcd
CLR RS ;It is a command
MOV DAT ,#32H ;8 Bit data,2line
CLR EN
LCALL WAIT_LCD

SETB EN ;enable lcd
CLR RS ;It is a command
MOV DAT ,#38H ;8 Bit data,2line
CLR EN
LCALL WAIT_LCD
;--------------------------------------------------------
SETB EN
CLR RS
MOV DAT ,#0EH ;LCD ON -CURSOR ON
78

CLR EN
LCALL WAIT_LCD
;---------------------------------------------------------
SETB EN
CLR RS
MOV DAT ,#06H ;Auto increment cursor
CLR EN
LCALL WAIT_LCD
RET
;----------------------------------------------------------
;----------CUR_OFF:
;----------------------------------------------------------
CUR_OFF:
SETB EN
CLR RS
MOV DAT ,#0CH
CLR EN
LCALL WAIT_LCD
RET
;----------------------------------------------------------
CLEAR_LCD:
SETB EN
CLR RS
MOV DAT,#01
CLR EN
LCALL WAIT_LCD
RET
;----------------------------------------------------------
WRITE_TEXT:
SETB EN
SETB RS
MOV DAT,A
CLR EN
LCALL WAIT_LCD
79

RET
;----------------------------------------------------------
WAIT_LCD:
SETB EN
CLR RS
SETB RW
MOV DAT ,#0FFH
MOV A,DAT
JB ACC.7 ,WAIT_LCD
CLR EN
CLR RW
RET
;-----------------------------------------------------------
; SUB SETS THE CURSOR POSITION.
;--LINE 1
;-----------------------------------------------------------
PLACECUR:
MOV A, B
ADD A,#080H; CONSTRUCT CONTROL WORD FOR LINE 1
SETCUR:
SETB EN
CLR RS
CLR RW
MOV DAT ,A
CLR EN
CALL WAIT_LCD
RET
;-----------------------------------------------------------
;--CURSOR POSITION LINE2
;----------------------------------------------------------
PLACECUR2:
MOV A,B
ADD A,#0C0H
SETCUR2:
80

SETB EN
CLR RS
CLR RW
MOV DAT,A
CLR EN
CALL WAIT_LCD
RET
;---------------------------------
;--DISP sub to display string
;---------------------------------
DISP:
CALL CLEAR_LCD
MOV B,#00
CALL PLACECUR
MOV R1, #16
J210:
CLR A
MOVC A, @A+DPTR
CALL WRITE_TEXT
INC DPTR
DJNZ R1,J210

MOV B,#00
CALL PLACECUR2
MOV R1,#16
J211:
CLR A
MOVC A, @A+DPTR
CALL WRITE_TEXT
INC DPTR
DJNZ R1,J211
RET
;--------------------------
ISR1:
81

CLR TR1
MOV TH1,#0C5H
MOV TL1,#0BDH
SETB TR1
DJNZ TICK,EXIT
MOV TICK,#20
DJNZ SEC,EXIT
CLR FLAG1
CLR TR1
EXIT:
RETI
;----------------------------------
DELAY:
MOV R6,#0FFH
J02:
NOP
MOV R5,#0FFH
DJNZ R5,$
DJNZ R6,J02
RET
;-----------------------------------
DEBOUNCE:
MOV R6,#80H
J01:
NOP
MOV R5,#0FFH
DJNZ R5,$
DJNZ R6,J01
RET
;----------------------------------------------------------------
MSG1: DB 'DRILLING M/C ',' PERIOD 000 ',0
MSG2: DB 'DRILLING M/C ',' PROJECT ',0
END

82

9. FUTURE SCOPE OF DEVELOPMENT

9.1 The conceptual improvements:

 The CNC Drill could be used as a Milling Machine which could be interfaced to a
mechanical engineering type of Computer Aided Design (CAD) package, for
example, AutoCAD. If this feature is combined with the teach/learn option, the
CNC Drill could become a versatile engraver. Added to this interfacing with a
computer to show the working point of drilling machine will give a new dimension
to the PCB drilling machine prototype.

 We can improve the circuitry and power supply. The system is still currently
implemented as a prototype with all circuitry on a board and separate power
supplies for the different voltage and current levels. This could be improved by
creating a single printed circuit board for all of the system’s components and
creating a power supply circuit which is capable of accepting a single power input
and providing all of the separate power supplies required.

 This prototype can be aided by sensors and vision devices to improve the accuracy
of the system. This improves the accuracy of the system.

 A further improvement which could possibly be developed, is that of the user
interface and graphics being in colour as opposed to monochrome. The error
messages could then be displayed in, for example red text, while the PCB
information could be in blue text, and the PCB layout in green with the white
background. Although this improvement is not essential, it would make the user
interface more aesthetically pleasing and user friendly.

If the recommendations which are proposed above are implemented,
the CNC Drill will be transformed into an extremely versatile machine, which would out
class most of its competitors. This CNC Drill will be beneficial to the small PCB
manufacturers who chose to incorporate this development in their production line.

83

10. CONCLUSION

In this project, specifications of a simple prototyping machine are
achieved by drilling one hole by giving the inputs in the form of time of operation of three
stepper motors controlling table movements (X, Y directions) and the hand drilling
machine movement (Z direction).

This prototype eliminates most of disadvantages of manual drilling
machine. The positioning of the PCB under the drilling bit is automatically achieved.
Repeatability is another advantage of this prototype over manual drilling of PCBs.

This project is a prototype of a CNC PCB drilling machine which
comes as a midway between a CNC PCB drilling machine and a manually operated PCB
drilling machine. This prototype working project can be converted into a practical PCB
drilling machine which exhibits the useful features CNC PCB drilling machine.

Enhancements conceptualised which would further improve the
system and increase both the versatility and capabilities of the CNC machine. It is
suggested that these options should be investigated and implemented at a later stage.

The recommended future developments can be implemented in this
prototype to make a real model of this prototype. It will be very useful and efficient for the
manufacturing of Printed Circuit Boards for small scale production.










84

11. BIBLOGRAPHY

 WWW.GOOGLE.COM
 WWW.EDSIM51.COM
 EN.WIKIBOOKS.ORG
 WWW.MIKROE.COM
 WWW.ORIENTALMOTOR.COM
 PRINTED CIRCUIT BOARDS BY R.S. KHANDPUR
 THE 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS USING
ASSEMBLY AND C BY MUHAMMAD ALI MAZIDI, JANICE GILLISPIE
MAZIDI, ROLIN D. MCKINLAY
 THE 8051 MICROCONTROLLER BY AYALA