. Cut to Length Controller ___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 1 Scenario and Progress of Industry Automation Overview of the System Operation Overview and Problem Definitions 1. Introduction . . .
135
Embed
Final Report on Cut to length controller using P89LPC932
a report on Cut to length controller, using uc P89LPC932 for servo drive and servo motor(excluding the source code).this device is a kind of CNC low cost machine and can be used in place of Micro processor for controlling the servos.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 1
Scenario and Progress of Industry
Automation
Overview of the System
Operation Overview and Problem
Definitions
3. S
tudy
Of
Exi
stin
g Sy
stem
. . .
1
. In
trod
uctio
n . .
.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 2
1.1
The foundations of the industrial automation need to be traced to the
development of quantum mechanics, classical mechanics, electronics and the
essential one, process theory, which describes the behavior of output variables as
a function of adjustable and non adjustable variables and time. Also the inventions
such as the vacuum tube , the transistor, the integrated circuit and the
microprocessor, which led to the emergence of the microelectronics, and a wide
variety of new sensing devices are essential to the revolution of the industrial
automation. Process control theory has provided knowledge on the principles of
control, on the ways of implementing these principles, and on the mathematical
SCENARIO & PROGRESS OF INDUSTRIAL AUTOMATION
During the eighties emerged a profuse literature pointing at a number of
potential advantages of recent microelectronics-based industrial automation for
developing countries. It is claimed that industrial automation is leading to
fundamental changes in production organizations , optimal scales of output and
economic scope , vertical integration and the relationship between large and small
firms that would generally be favorable to any country.
A new phase in the replacement of human effort by machines began to
emerge around the early twentieth century with the development of industrial
automation. Unlike mechanization industrial automation not only involves the
replacement of physical effort by machines but entails the displacement of some
of the decision making capabilities of the operator. It is based on the concept of
feedback control which consists of a procedure of measuring and inspecting or
‘sensing’ the evaluation and processing of this information in relation to theory or
algorithm of the process, and an output of instructions as a response if required.
Feed back control allows for the development of more flexible machines and
production processes.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 3
models to represent processes. Microelectronics, i.e. electronic using very small
solid state components, provided devices for storing, processing and computing
information that are notably smaller and diminishing in size, of an exceedingly
high and increasing speed and reliability, and , of very low and decreasing costs.
The introduction of digital computers in the 1960s offered the possibility
of breaking away from previous unreliable electromechanical controls and move
into faster, reliable and more accurate devices, capable of data storing and
processing and of performing a series of complex mathematical operations. But ,
by and large, early computers were a failure because of constant breakdowns due
to their sensitivity to the external environment leading to expensive back-up
measures and difficulties in developing models and writing programs that took all
intervening variables into account. This situation changed drastically the advent of
microelectronics. Since 1975, devices such as programmable logic controllers,
micro and process computers have been developed. Together with appropriate
software and novel measuring instrumentation, also microelectronics based , the
new control devices are simultaneously capable of data gathering, processing and
storing, computing ,regulating controlling, interfacing with the operator and
communicating with other devices and outside the system with or without human
intervention.
Because of the emphasis on advance and high tech equipments with
feedback control as the defining factor, industrial automation includes a wide
variety of self-regulating equipment which is in almost any industry, It also
includes any combination of machines which are jointly controlled from a
computer. And, it possibly consists of parts of plants or even whole factories
which are completely unmanned and computer controlled, although ‘factories of
the future’ still seem to be a long way away.
The diffusion of industrial automation since the advent of microelectronics
has proceeded at a very fast rate. In continuous process industries more powerful
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 4
and sophisticated process control units and sensors were developed ,while in
batch industries, particularly in mechanical engineering , new process equipment
such as numerically and computer controlled machine tools, computer-aided
design and flexible manufacturing systems emerged.
1.2
Automatic continuous cutting along a straight line required the combined
accurate positioning of the tool and work piece along a length. This involves a
complex set of movements the commands for which, it is believed at the real time,
can be conveyed to the motor of the machines tool through a device or
‘servomechanism’ which has created digital signals corresponding to numbers.
These signals were then compared with signals arising from the actual position of
the tool and work piece prompting corrective action if necessary.
Perhaps the best way to start with is the analysis of the system objectives. In
as much as automated equipment requires automatic control, data on the use of
industrial control and instrumentation, should provide an idea of the real time
implementation.
Here first we are going to see the purpose of the system and then we come
to know how we have derived the system objectives along with the application
background.
1.2.1 Purpose of the system :
The purpose of designing such system is to provide a cost effective and precise
control over a servo drive for a dedicated application and enhanced functionality
of servo drive MP-controller.
OVERVIEW OF THE SYSTEM (C2L)
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 5
( Here dedicated application is in terms of controlling servo device in such way,
that the servo motor connected, rotates for a derived number of pulses and gives
the exact desired length of the sheet without any damage. )
1.2.2 Objectives of the system :
The system have the following objectives such that it is reliable enough to apply
for an industrial application.
The objectives are :
1) The system must have the basic functionality of servo drive controlling MP,
such that system can completely replace the MP unit.
2) The system must be able to provide pulse train in frequency range of 1 to 70
KHz for the pulse potion mode of the servo drive.
3) The system must be able to sense the mechanical assembly failure such that it
will resume the functionality with the previous parameters fed.
4) The mechanical assembly should be controlled such a way that desired length
of the sheet can be achieved without any damage and the length must be in
mm.
5) The system must be able to communicate human interfaces like LCD or HMI.
6) The system should be very cost effective and highly efficient.
7) The parameters listed below can be easily inserted through any media to the
system:
1. Length of the desired sheet in mm.
2. Diameter of the roller
3. Gear ratio
4. cutter on/off duration
5. Calibration
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 6
1.2.3 Application Background :
The following diagram shown is the application diagram
Figure 1.1 Application Background
Here as shown in the diagram the system has to control the right side belt
assembly by controlling the rollers such that rotation of the rollers provide the
forward motion of belt and hence the sheet. Here the rotation of the roller is such
that it provides the exact desired length of the sheet. Such controlling action of the
rollers and hence the entire right sided belt assembly is achieved by a servo motor
and servo drive with C2L unit. Here the C2L unit provides the derived pulse train
as per the user requirement to the servo drive. Here the servo drive is set to the
pulse position mode, such it gives the signal to servo motor in accordance with the
number of pulses in pulse train. Here the belt assembly on the right side, moves
with the constant speed along with the take up drum.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 7
1.3
Now from the application background we come to know the handling of system
components. But there are many difficulties associated with the system, which
must be considered and also the provision of such difficulty must be provided as a
controlling action of system itself.
1.3.1 Operation Overview with possible arrangement : The entire system can be controlled by providing proximity switches as shown in
the figure. There can be mainly three proximity switches, one for starting the
cutting operation called start proximity, and rest two are the stop proximity
switches in the case of any failure. Here the proximity switches actually senses
the position of the dancing roller and hence controlling the cutting action.
OPERATION OVERVIEW AND PROBLEM DEFINITIONS
Figure 1.2 Operation Level With Possible Arrangement Here the operation starts with sensing of start proximity switch as the dancing
roller reaches the start level. The C2L unit generates the no. of pulses derived
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 8
according the calculation of the parameters and hence the servo motor rotates.
Here the dancing roller is having vertical motion under the gravitational force and
it also provides little tension to the sheet for avoiding the wrinkles in the sheet
which helps to maintain the exact length(**1).
1.3.2 Consideration for the Length of sheet : The following diagram shows how the measurement of the length of the sheet is
carried out.
Figure 1.3 Measurement Of The Length Of The Sheet
Here as shown in the figure the length of the sheet is to be measured from the
cutting edge. Here the cutter distance is varying for the different type of the cutter
assembly, which should be feasible for mechanical alignment. Each time the
system is turned on ,one has to take care about this cutter distance because it
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 9
simply turns out in the waste piece. So, if the cutter distance is negligible then
there is nothing to consider about the waste piece. This condition arises once at
the time of the system start up only. More details is given in the later chapter.
1.3.3 Problem Definitions & possible provisions :
How ever there are such possibilities for the wreaking up the sheet during the
running operation due to mechanical failure.. Such possibilities and their
provisions are listed below.
Case 1: Meanwhile the running condition, if the dancing roller reaches at the stop
level or say having displacement more than the clearance distance (**2). Such
condition occurs if the failure of the take up drum assembly ( or left side belt
assembly) takes place.
Provision : Such failure can be easily flag marked by providing the stop
proximity switch-1 at the stop level or at clearance distance as shown in the figure
1.2 . As soon as the stop proximity switch-1 has sensed ,the operation is halted till
the dancing roller reaches again to start level. Now as the dancing roller reaches to
the start level or say start proximity switch has sensed , the cutting operation
resumes with the remaining length to be cut.
Case 2: Meanwhile the running condition, if the dancing roller crosses the dead
end level. Such condition occurs if the sheet coming from the take up drum is
broken or the take up drum is empty. In this condition, if the roller is at the mid of
clearance level and the broken sheet comes, the roller falls down the ground,
giving signal to the start proximity switch. In such condition if there is no any
provision then the unit again starts giving the pulses and hence starts the cutting
sequence.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 10
Provision : Such condition can be avoided by providing the stop proximity
switch-2 at the dead end level (**2) as shown in figure 1.2 . As soon as the roller
passes across the dead end level or stop proximity switch-2 has sensed, the
operation is halted. The system is halted till the new sheet material fed along with
the dancing roller as shown in the figure1.2 and waits for the start proximity
switch to sense.
Case 3: Consider a condition in which the cutter assembly which is also being
controlled by the C2L unit, fails during the operation.
Provision: In such condition, there is a provision of indicating whether the cutter
relay or solenoid is giving the output through the LED or some alarm. If the cutter
LED is glowing or the alarm is sounding after the rotation of the servo
mechanism, indicating the unit is working properly but the cutter assembly has
some mechanical failure . Hence we come to know also about the failure of cutter
assembly.
Hence the unit is able to sense the every possible mechanical failure. The
proximity switches are the backbone of the controlling of the entire system.
Hence the essential system is achieved logically. But only knowing the possible
failure and the possible solution it is worth saying that achieved the objective to
sense the mechanical failure. The corresponding hardware and the software must
have to assign for real time application. The hardware and the software portion for
the system are discussed in the following chapters.
(**1) Here the dancing roller is having only on vertical motion axis as in the actual application there is a guiding vane which provides the dancing roller only one vertical direction, although it is under the gravitational force only. (**2) Here the clearance distance and the distance between dead end level and the start level are absolutely depending upon the arrangement of the take up drum and conveyor belt assembly. Also the height of the conveyor belt assembly from the ground level must be considered. It is recommended to keep the clearance distance twice of the distance between the start and dead end level.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 11
System Model
Hardware Description
Utilizations & calculations for uC
Circuit Diagrams & Trouble Shooting
3. S
tudy
Of
Exi
stin
g Sy
stem
. . .
2
. Sys
tem
Mod
el &
Har
dwar
e Des
crip
tion
. . .
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 12
2.1 SYSTEM MODEL
Figure 2.1 System Block Diagram
Figure 2.2 System With Controlling Peripherals
As shown in the figure 2.1 the proximity switches are connected to the Opto-
isolation board. Here the proximity switches as well as the pulses and the cutter
relay are not connected directly to the controller for providing electrical isolation.
Here the LCD and the keyboard are directly connected to the controller.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 13
2.1.1 System components :
• Transducers :Proximity switches ( M8 DC NPN Inductive Proximity
switch )
• Opto-couplers ( MCT2E )
• Microcontroller ( P89LPC932A1)
• Liquid Crystal Display ( XIAMEN GDM1602K )
• Key Board ( 3x 2 matrix )
• Relay ( operating at 5 v DC ) or solenoid
• Devices controlled
1) AC servo drive ( Yaskava G7 single phase )
2) AC servo motor ( Yaskava SGDM200H )
Transducers : Proximity switches
As discussed in the operation overview the proximity switches are the backbone
of the system. The total controlling action depends on the sensing of the
proximity switches. Even they are utilized in such a way that they can also sense
the mechanical failure.
Opto-couplers:
Opto-couplers are utilized for providing electrical isolation to microcontroller
from external peripherals, as microcontroller is very sensible to external noise.
Hence the Opto-couplers are the isolating medium through which the external
peripherals are connected to the microcontroller.
Microcontroller:
The microcontroller is the Heart of the proposed automation system. It
constantly monitors the digitized outputs of the proximity switches and takes the
predefined corresponding actions at that instant of time. In case such a situation
arises it activates the other peripherals to perform the controlled operation.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 14
Display Unit:
A simple 2x16 Liquid Crystal Display is used to indicate the present status of the
parameters and respective values. The information is to be display in menu format
with corresponding action of the keyboard.
Key Board :
A simple 3x2 matrix keyboard is interfaced with the controller. The key board is
designed such that it generates the keyboard interrupt for respective key pressed.
Relay or Solenoid :
A simple low voltage relay or solenoid can be used to turn on the cutter assembly
as a part of controlling action.
2.1.2 Step followed in designing the system : Here three general steps can be followed to appropriately design such control
system.
Servo Drive controlling parameters
Step #1: Identify the controlling parameters important to production
It is very important to identify the parameters that are going to affect the operation
of the entire system.
Table 2.1 Importance Of Various Parameters
Sr no. Parameter to be considered Importance of the parameter
1. Servo parameter multiplier Indicates a single pulse to the servo motor is equal to
no of pulses from the C2L unit which is being
converted by servo drive. ( max 33 )
2 Precision pulses (bits) in
terms of 2^x
Indicates no of precision bits of the servo motor
encoder, required for feedback to drive (max 17)
3. Frequency The frequency of the pulse train outputted to servo
drive from the C2L unit, decides the speed of
operation. Range (1-70 KHz)
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 15
Mechanical parameters
Sr no. Parameter to be considered Importance of the parameter
4 Gear ratio From servo shaft to roller gear for length calculation
( max 10 )
5 Feed roller Diameter Outer diameter of roller surface for length calculation
( max 9999 mm )
6 Length Length of the sheet to be cut (max 9999 mm )
7 O/P time On/Off time duration of cutter ( max 9999 ms)
Calculative Parameters
Sr no. Parameter to be considered Importance of the parameter
8 Pulse count value No of pulses in a pulse train, which has to be fed to
the servo drive, derived form the above parameters
9 Offset length in um Required for the calibration, added or subtracted
from the actual length ( max 9999 um )
The above mentioned parameters must be followed by designed system with
accuracy and reliability .
• On sensing the start proximity switch the system must have to feed the
derived no of pulses to the drive, that rotates the servomotor resulting the
desired length.
Step #2 : Investigate the Control strategies
An important element in considering a control system is the control strategy that
is to be followed. Knowing the system objectives, application background and
operation overview and system parameters, we decide the controlling action to be
taken by the unit for the desired result.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 16
• On sensing the stop proximity switch the system must have to hold the
entire operation with some indication, and again sensing on the start
proximity switch the remaining operation must have to complete.
• The system parameters can be easily changed according to user
requirement. The controlling action must be carried out according the
parameters, each time they are changed.
• Expand the number of measured variable and controlled devices so
that growth and changing needs of the production operation can be
satisfied in the future.
Step #3: Identify the software and the hardware to be used
It is very important that system functions are specified before deciding what
software and hardware system to purchase. The model chosen must have the
ability to:
• Provide a flexible and easy interface.
• It must ensure high precision measurement and must have the ability
to resist noise.
Hardware must always follow the selection of software, with the hardware
required being supported by the software selected. In addition to functional
capabilities , the selection of the hardware should include factors such as
reliability, support, previous experiences with equipment ( successes and failures),
and cost.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 17
2.2
The following section gives the features of the hardware components with
functional descriptions.
HARDWARE DESCRIPTION
2.2.1 Transducers / proximity switches A transducer is a device which measures the real time physical quantity and
converts it into a signal which can be read by an observer or by an instrument/
Monitoring controlling of this system involves sensing the change in the position
of dancing roller which influence the cutting action of the desired length sheet.
The sensors used in this system are the proximity switches.
Figure 2.3 M8 DC inductive Proximity Switch
2.2.1.1 Features
• The Katlax M8 DC NPN inductive switch uses 10 to 30V DC supply with
sensing distance 8x8x2 mm. It has only three terminals +V, O/P, 0.
• It gives the output triggering signal on sensing the object with maximum
of 3 KHz sensing frequency.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 18
2.2.1.2 Functional Description
• The inductive proximity switch works on the principle of changes in
resonant circuit caused by eddy current losses in the inductive material.
• The inductive proximity switch has four main components; The coil,
oscillator, detection circuit and output circuit.
• The oscillator generates a fluctuating magnetic field the shape of
doughnut around the winding of the coil that locates in the device’s
sensing face as shown in the following figure.
• When a metal object moves into the inductive field of detection, eddy
circuit builds up in the metallic object, magnetically push back, and
finally reduce the oscillation field. The sensor’s detection circuit
monitors the oscillator strength and trigger’s an output from the output
circuitry when a oscillator becomes reduced to a sufficient level. • As there are total three proximity switches are utilized and as they are
electrically isolated from controller , the output triggering signal are
given to the Opto-couplers , which give the signals to the controller.
• Two of them are connected parallel named stop proximity1 and 2.The
start proximity resumes the cutting operation each it senses, and on
detection of stop proximity switches the cutting operation is halted until
start proximity has sensed again.
Figure 2.4 Block Diagram Of Inductive Proximity Switch
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 19
2.2.2 The Opto-coupler The opto-coupler simply consists a diode and a phototransistor, whose base is
open and the conduction of the transistor depends on the light intensity falling on
the base junction ; provides electrical isolation between two devices. Hence they
are widely used in the industry for isolation purpose.
Figure 2.5 Opto-coupler MCT2E
2.2.2.1 Features
• The opto-coupler MCT2E from Texas Instruments, is simply a Gallium
Arsenide Diode infrared source optically coupled to a silicon npn
phototransistor.
• Base lead provided for conventional transistor biasing with high direct-
current transfer ratio.
• High voltage electrical isolation up to 1.5 KV with high speed switching.
2.2.2.2 Functional Description
• All the external peripherals are isolated through the opto coupler to the
microcontroller..
• Such isolation provides the immune to the noise as well as short circuit
protection and high voltage fluctuations from the peripheral devices.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 20
• The output from the controller is connected to the anode of the diode and the
peripherals like cutter relay and the pulse train to servo drive are connected
to the collector of the transistor.
• The output from the proximity switch is connected to the anode and the
collector is biased through a resistor with 3.3V. The collector also connected
to interrupt pin of microcontroller. On triggering the proximity switch
output the transistor starts conducting pulling the biasing voltage to ground
and generating low level interrupt signal to the micro controller. As shown
in the following figure.
Figure 2.6 Connections Through Opto-coupler
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 21
2.2.3 The Microcontroller P89LPC932A1
2.2.3.1 Criteria For Choosing A Microcontroller
The basic criteria for choosing a microcontroller suitable for the application are:
1) The first and foremost criterion is that it must meet the task at hand efficiently
and cost effectively. IN analyzing the needs of a microcontroller-based
project, it is seen whether an 8-bit, 16-bit or 32 bit can best handle the
computing needs of the task most effectively. Among the other considerations
in this category are:
• Speed
•
: The highest speed that the microcontroller supports.
Packaging
•
: It may be a 40 pin DIP (dual inline package ) or a QFP
(quad flat package), or some other packaging format like TSSOP (thin
shrink small outline package ). This is important in terms of space,
assembling, and prototyping the end project.
Power consumption
•
: This is specially critical for application purpose
or rather say available power sources.
Cost per unit
• The number of I/O pins and the features of the controller.
: This is important in terms of the final cost of the product
in which a microcontroller is used.
• How easy it is to upgrade to higher performance or lower consumption
versions.
2) The second criterion in choosing a microcontroller is how easy it is to develop
products around it. Key considerations include the availability of an
assembler, debugger, compiler, technical support.
3) The third criterion in choosing a microcontroller is its ready availability in
needed quantities both now and in the future. Currently of the leading 8-bit
microcontrollers, the 8051 family has the largest number if diversified
suppliers. By supplier is meant a producer besides the originator of the
microcontroller. IN the case of the 8051, this has originated by Intel, several
companies also currently producing 8051 based microcontrollers.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 22
Thus the microcontroller P89LPC932A1 by Philips semiconductors, satisfying the
criterion necessary for the proposed application is chosen for the task.
Figure2.7 Pin Diagram Of Microcontroller P89LPC932A1
The P89LPC932A1 is a single chip microcontroller , available in low cost
packages, based on a high performance processor architecture that executes
instructions in two to four clocks, six times he rate of standard 80C51 devices.
Many system level functions have been incorporated into the P89LPC932A1 in
order to reduce component count ,board space, and system cost.
2.2.3.2 Key Features Of P89LPC932A1:
• 8 Kb byte-erasable flash code memory organised into 1 Kb sectors and 64
byte pages.
• 256 byte RAM data memory, 512 byte auxiliary on chip RAM
• 512 byte EEPROM on chip allows serialization of devices, storage of set up
parameters, etc.
• Two analog comparators with selectable inputs and reference sources.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 23
• Two 16 bit counter/ timers ( each may be configured to toggle a port output
upon a timer overflow or to become a PWM output ) and a 23 bit system
communication port and SPI ( Serial Peripheral Interface ) communication
port.
• Capture/Compare unit ( CCU ) provides PWM (Pulse Width Modulation ) ,
input capture and output compare functions.
• High accuracy internal RC oscillator option allows operation without
external oscillator components.
• 2.3 V to 3.6 V VDD operating range. I/O pins are 5 v tolerant.
• Serial flash In-Circuit Programming ( ICP ) allows simple production coding
with commercial EPROM programmers.
• Serial flash In-System Programming ( ISP ) allows coding while the device
is mounted in the end application.
• In-Application programming ( IAP ) of the flash code memory. This allows
changing the code in running application.
• Watchdog timer with separate on chip oscillator , requiring no external
components.
• Programmable port output configuration options: quasi bidirectional , open
drain, push-pull, input only.
• Eight keypad interrupt inputs. Plus two additional external interrupt inputs.
• Two data pointers
• Only +VDD ( power ) and –VSS ( ground ) connections are required to
operate the P89LPC932A1 when internal reset option is selected.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 24
2.2.3.3 Block Diagram of P89LPC932A1 :
Figure 2.8 Block Diagram Of Microcontroller P89LPC932A1
The detailed functional description of different unit of microcontroller
P89LPC932A1 along with the schematic of the proposed system are given later in
this chapter.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 25
2.2.4 Liquid Crystal Display (GDM1602K)
A liquid crystal display ( LCD) is a thin, flat display device made up of any
number of color or monochrome pixels arrayed in front of a light source or
reflector. Each pixels consists of a column of liquid crystal molecules suspended
between two transparent electrodes, and two polarizing filters, the axes of
polarity of which are perpendicular to each other. Without the liquid crystals
between them, light passing through one would be blocked by the other. The
liquid crystal twists the polarization of light entering one filter to allow it to pass
through the other.
Many microcontroller devices use ‘smart LCD’ displays to output visual
information. LCD displays designed around KS0066U MPU, are inexpensive,
easy to use, and it is even possible to produce a readout using 8x80 pixels of the
display. It has a standard ASCII set of characters and mathematical symbols.
For an 8-bit data bus, the display requires a +5V supply plus 11 I/0 lines . for a
4-bit data bus it only requires the supply lines plus seven extra lines. When the
LCD display is not enabled, data lines are in tri-state and they do not interfere
with the operation of the microcontroller.
Data can be placed at any location on the LCD. For 16x2 LCD, the address
locations are:
Table 2.2 Locations For Characters For LCD
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 26
• BKL to be driven by pin1,pin2, or pin 15, pin16 or A,K
• KS0066U function set instructions ( set display methods, set data length,
etc.)
• Inbuilt line segment driver for LCD
• Address set instructions to internal RAM
• Data transfer Instructions with internal RAM
Figure 2.9 Pin Diagram Of LCD
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 27
Table 2.3 Pin Description Of LCD
Pin no. Symbol External
connection Function
1 Vss
Power supply
Signal ground for LCM
2 Vdd Power supply for logic (+5V) for LCM
3 Vo Contrast adjust
4 RS MPU Register select signal
5 R/W MPU Read/ write select signal
6 E MPU Operation (data read/ write) enable signal
7~10 DB0~DB3 MPU
Four low order bi-directional three state data
bus line. Used for data transfer between the
MPU and LCM. These four are not used
during 4 bit operation.
11~14 DB4~DB7 MPU
Four high order bi-directional three-state data
bus lines. Used for data transfer between the
MPU
15 LED+ LED BKL power
supply
Power supply for BKL “A” (+ 4.2 V )
16 LED- Power supply for BKL “K” ( GND )
2.2.4.2 Functional Description
• The LCD display module is built in a LSI controller, the controller has two 8-
bit registers, an instruction register ( IR) and a data register ( DR )
• The IR stores the instruction codes, such as display clear and cursor shift, and
address information for display data RAM ( DDRAM ) and character
generator RAM (CGRAM). The IR can only be written from the MPU.
• The DR temporarily stores data to be written or read from DDRAM or
CGRAM. When address information is written into the IR, then data is stored
into the DR from DDRAM or CGRAM.
• By the register selector ( RS ) signal, these two registers can be selected.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 28
Table 2.4 Register Selection For LCD
• When the busy flag is 1, the controller LSI is in the internal operation mode
and the next instruction will not be accepted. When RS=0 and R/W=1, the
busy flag is output to DB7. The next instruction must be written after ensuring
that the busy flag is 0.
• Address counter (AC) assigns addresses to both CGRAM and DDRAM.
• DDRAM is used to store the display data represented in 8-bit or 4+4 bit
character code. Its extended capacity is 80x8 bits or 80 characters.
• The CGRAM generate 5x8 dot or 5x10 dot character patterns from 8-bit
character codes, and the user can rewrite character by program. For 5x8 dots,
eight character patterns can be written, and for 5x10 dots, four character
patterns can be written.
• Here for the proposed system the LCD is used in the four bit-mode as per the
application requirement. Here only higher data bits DB4~DB7 lines are
connected to the controller , and all the instructions as well as 8-bit data are
being sent through higher and lower nibble.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 29
Table 2.5 Instruction Table For LCD
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 30
2.2.5 Keyboard
The predominant interface between humans and controller is the keyboard.
Keyboards range in complexity from the “up-down” buttons used for elevators to
the personal computer QWERTY layout, with the addition of function keys and
numeric keypads. The one constant in all keyboard applications is the need to
accommodate the human user. Human beings can be irritable. They have little
tolerance fro machine failure ; watch what happens when the product isn’t ejected
from the vending machine. Sometimes they are bored by routine, or even hostile
towards the machine . The hardware designer has to select keys that will survive
in the intended environment. The programmer must write code that will
anticipate and defeat inadvertent and also deliberate attempts by the human to
confuse the program.
It is very important to give instant feedback to the user that a the key hit has been
acknowledged by the program. The user must know that the key has been
recognized through any indicator.
2.2.5.1 Key switch Factors
The keyboard application program must guard against the following possibilities:
• More than one key pressed ( simultaneously or released in any sequence )
• Key pressed and held
• Rapid key press and release
All of these situations can be addressed by hardware or software means; soft ware
, which is the most cost effective, is emphasized here.
The universal key characteristic is the ability to bounce: the key contacts vibrate
open and closed for a number of milliseconds when the key is hit and often when
it is released. These rapid pulses are not discernible to the human, but they last a
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 31
relative eternity in the microsecond- dominated life of the microcontroller. Keys
may be purchased that do not bounce, or keys may be debounced with RS flip-
flops or debounced in software with time delays.
2.2.5.2 The Schematic and functional description
Figure 2.10 Schematic Of Keyboard
Functional description :
• The keyboard shown in the above schematic is a 3x2 matrix keyboard.
• Initial value to the port pin is high for all the port pins (P0.1 to P0.5)
• If any key is pressed the corresponding row and column is pulled down to the
GND and here the keyboard interrupt is generated
• Here the keyboard SFRs are utilized such a way that only row can generate the
keyboard interrupt
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 32
• The pattern on the keyboard is to be compared and then the corresponding key is
identified from the status of that input pattern
• The SFRs used for handling the key-board are KBMASK (Key Board Masking),
KBMASK is set to 0E h for generating interrupt, allowing only P0.1, P0.2
and P0.3 to generate Keyboard interrupt
KBPATN is set to 0E h for allowing all inputted pattern from keyboard
except 0E h
KBCON is set to 00 h for clearing the KBI flag and pattern selecting bit
(NOT equal to the value which has been set in KBPATN register ).
• The corresponding action is to be taken as a key is pressed with debounce delay of
30 msec after each press. The same will be repeated if the key is held for a while.
(For more details on Keyboard interrupt handling refer the data sheet of
P89LPC932A1 attached.)
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 33
2.2.6 Relay
A relay is an electrical switch that opens and closes under the control of another
electrical circuit. In the original form, the switch is operated by an electromagnet
to open or close one or many sets of contacts. Because a relay is able to control an
output circuit of higher power than the input circuit, it can be considered to be, in
a broad sense ,a form of an electrical amplifier.
Figure 2.11 A Relay
Despite the speed of technological developments, some products proved useful to
many designers who needed to switch up to 10A, whilst using relatively little
PCB area.
2.2.6.1 Relay contacts and types of relay :
Since relays are switches, the terminology applied to switches is also applied to
relays. A relay will switch one or more poles, each of whose contacts can be
thrown by energizing the coil in one of three ways:
1. Normally open (NO) contacts connect the circuit when the relays is activated;
the circuit is disconnected when the relay is inactive. It is also called FORM-
A contact or “make” contact.
2. Normally closed (NC) contacts disconnect the circuit when the relay is
activated ; the circuit is connected when relay is inactive. It is also called
FORM-B contact or “Break” contact.
3. Change over or double throw contacts control two circuits; one normally
open contact and one normally closed contact with a common terminal. It is
also called a FORM-C or “transfer “ contact.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 34
Figure 2.12 Types Of Relay
2.2.6.2 Factors to be considered for selecting a relay
You need to consider several features when choosing a relay :
1. Physical size and pin arrangement : If you are choosing a relay for an existing
PCB you will need to ensure that its dimensions and pin arrangement are suitable.
You should find this information in the supplier's catalogue.
2. Coil voltage : The relay's coil voltage rating and resistance must suit the circuit
powering the relay coil. Many relays have a coil rated for a 12V supply but 5V
and 24V relays are also readily available. Some relays operate perfectly well with
a supply voltage which is a little lower than their rated value.
3. Coil Resistance : The circuit must be able to supply the current required by the
relay coil. You can use Ohm's law to calculate the current:
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 35
For example: A 12V supply relay with a coil resistance of 400 passes a current
of 30mA. This is OK for a 555 timer IC (maximum output current200mA), but it
is too much for most ICs and they will require a transistor to amplify the current.
4. Switch ratings (voltage and current) :The relay's switch contacts must be
suitable for the circuit they are to control. You will need to check the voltage and
current ratings. Note that the voltage rating is usually higher for AC, for example:
"5A at 24V DC or 125V AC".
5. Switch contact arrangement (SPDT, DPDT etc): Most relays are SPDT or
DPDT which are often described as "single pole changeover" (SPCO) or "double
pole changeover" (DPCO).
2.2.6.3 Need of protection diode
Transistors and ICs (chips) must be protected from the brief high voltage 'spike'
produced when the relay coil is switched off. The diagram shows how a signal
diode (e.g. 1N4148) is connected across the relay coil to provide this protection.
Note that the diode is connected 'backwards' so that it will normally not conduct.
Conduction only occurs when the relay coil is switched off, at this moment
current tries to continue flowing through the coil and it is harmlessly diverted
through the diode. Without the diode no current could flow and the coil would
produce a damaging high voltage 'spike' in its attempt to keep the current flowing.
2.2.6.4 Functional description
• The output from micro controller is connected to the base of the transistor BC548
through a resistor.
• The relay coil is connected between the +5V supply and the collector of the
transistor as shown in the figure.
• Before the output from controller triggers the transistor; it is in a cutoff level and
there is no charge across the relay coil as the circuit does not complete. Hence
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 36
• Now as the controller pin goes high the transistor triggered and completes the
circuit and hence the charge across coil exists , switching the relay in on state.
• The relay remains in on state as long as the microcontroller pin is held high.
• On the other end the cutter assembly is connected between NO and COM pins,
controlling the on/off control of the cutter.
• As the relay turns on consequently it switches the cutter and the cutting of the
sheet takes place.
• Here the relay switch only controls the on/off state of cutter assembly, and the
on/off time duration depends on the type of cutter assembly, as well as cutting
duration. This can be variable for different cutter assembly , can be changed as
per the requirement.
Figure 2.13 Relay Connection With Protection Diode
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 37
2.3
2.3.1 The main equation : The main objective of the proposed system is to derive the number of pulses in
accordance with parameters as given in table 2.1. Here the number of pulses is
such that it brings the exact rotation of the servo motor for desired length to cut.
The exact no of pulse is calculated by the following :
Servo parameter multiplier : _ _ ( max of 33 )
Precision pulses (bits) in terms of 2^X : _ _ ( max of 17 )
Feed roller diameter : _ _ _ _ in mm ( max of 9999 mm)
Required Length of the sheet : _ _ _ _ in mm ( max of 9999 mm )
Offset length : _ _ _ _ in um ( max of 9999 um )
Gear ratio : _ _ ( max of 10 )
Now, from above parameters we can find displacement length per revolution for
feed roller (DLR) :
UTILIZATIONS & CLCULATIONS FOR µC
The servo motor has the position encoder. This encoder has the precision bits in
terms of 2^ (X+1). This encoder is connected to the servo drive, gives the
position status of the motor shaft. One has to give the pulses to the motor such
that rotation of motor occurs in a multiple of this precision bits. This work is
actually carried out by the MP controller (refer system objectives 1.2.2). Hence
we are multiplying the precision pulses (bits) for having the virtual management
of that MP controller for our proposed unit. Also the servo parameter multiplier is
a feature of that MP controller which informs the servo drive; a single pulse to
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 38
the servo motor should equal to no of pulses from the MP unit. Hence we also
use this feature for deriving final pulses per revolution.
So, the calculation for the servo parameters is carried out by following equation:
Now, number of pulses required per revolution of servo motor is given by the
following equation :
Apart from this , additional offset is required as the above equation only meets
the truncated figure. So the offset value in the length is added in terms of
micrometer for more precise value.
So the actual pulse count is now carried out from the following equation :
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 39
2.3.2 The Clock management and frequency calculation :
Figure 2.14 Block Diagram Of Oscillator Control Of uC P89LPC932A1
The microcontroller uses an enhanced 80C51 CPU which runs at 6 times the
speed of standard 80C51 devices. A machine cycle consists of two CPU clock
cycles, and most instructions execute in one or two machine cycles. The device
has several internal clocks as shown in the above figure.
• OSCCLK – Oscillator Clock - input to the DIVM ( Division by Magnitude )
clock divider. OSCCLK is selected from one of four clock resources and can also
be optionally divided to a slower frequency ( see section “ CPU clock (CCLK)
modification: DIVM register in the attached datasheet of uC .)
Note: OSCCLK is denoted by fosc.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 40
• CCLK- CPU Clock- output of the DIVM clock divider. There are two CCLK
cycles per machine cycle, and most instructions are executed in one to two
machine cycles ( two or four CCLK cycles).
• RCCLK – the internal 7.373 MHz RC oscillator output.
• PCLK- Peripheral Clock – clock for the various peripheral devices and is
CCLK/2.
Here we are using only internal RC oscillator using default factory settings, hence
RCCLK = 7.3728 MHz +/- 2 %. Now as we are not utilizing any other clock
source except RCCLK, the OSCCLK is equal to the RCCLK.
RCCLK = OSCCLK = fosc = 7.3728 MHz = 0.135 us per cycle
The OSCCLK frequency can be divided down ,by an integer , up to 510 times by
configuring a dividing register , DIVM, to provide CCLK. This produces the
CCLK frequency using following formula :
CCLK frequency = fosc / (2 N ) where: N is the value of DIVM
Since N ranges from 1 to 255 , the CCLK frequency can be in the range of fosc to
fosc / 510. For N = 0, CCLK = fosc.
Now fro the DIVM, the value of N is set to default zero i.e. N=0, and hence the
CCLK is also equal to RCLK.
So CCLK= fosc = 7.3728 MHz
Now PCLK = CCLK / 2
= 7.3728 / 2 MHz
= 3.6864 MHz
= 0.271 us per cycle.
( For more details on clock management please refer the user manual of
P89LPC932 attached.)
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 41
2.3.3 The CCU and the calculation of Pulse train output frequency :
CCU – Capture Compare unit
Here the dominant objective is to generate a pulse train of the desired frequency
range. Now the CCU unit of uC provides asymmetrical or symmetrical PWM
which can be utilized to generate the desired pulse train as it can provide the
toggling of output port pin.
To utilize the CCU for such application we must understand the timing sequence
and control of CCU timers along with timer frequency.
Figure 2.15 Capture Compare Unit Block Diagram
Here only output compare unit is enabled. The output compare channel A (OCA)
is enable. Whereas the other three channels OCB,OCD,OCC are disable. So PWM
output is carried out on pin OCA (P2.6). The input capture unit is disabled.
The output capture unit is initialized in symmetrical PWM and with desired
frequency count value for CCU timers.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 42
The CCU runs on the CCUCLK , which can be either PCLK in basic timer mode
or the output of a PLL as shown in figure 2.14. The PLL is designed to use a
clock source between 0.5 MHz to 1 MHz that is multiplied by 32 to produce a
CCUCLK between 16 to 32 MHz in PWM mode . The PLL contains a 4-bit
divider to help divide PCLK into a frequency between 0.5 to 1 MHz.
PLL freq. = PCLK / N+1 where, N= pre-scalar value
= 3.6864 / 4+1 here ,setting 4 bit divider to value to 4 d
= 0.737280 MHz
CCUCLK freq . = 32 x PLL freq.
= 32 x 0.737280 MHz
= 23.592960 MHz
= 42.38 ns per cycle
Here only output compare unit is enabled. The output compare channel A (OCA)
is enable. Whereas the other three channels OCB,OCD,OCC are disable. So PWM
output is carried out on pin OCA (P2.6).The input capture unit is disabled. The
output capture unit is initialized in symmetrical PWM and with desired frequency
count value for CCU timers.
Figure 2.16 CCU PWM Symmetrical Mode
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 43
Here the CCU timer needs only one CCUCLK cycle for increment or decrement.
But as we are utilizing symmetrical PWM, the output pin OCA will toggle on the
each compare fro both incrementing and decrementing direction as shown in the
figure 2.15. So here we are using two CCUCLK cycle or doubling the required
freq. virtually and finding the timer count value for resetting on overflow or
underflow. But the toggling occurs at the half the timer overflow value i.e. having
the desired frequency pulse on each compare.
So two CCUCLK cycle tc = 2 x 42.38 ns = 84.77 ns
Foe example, let the desired freq. of pulse train is fd = 1KHz
then pulse duration = 1 / fd = td = 1 ms
Now count value for timer = td / tc
= 1 ms / 84.77 ns
= 11796 decimal
= 2E14 Hex
so the timer reset value on overflow or under flow is = 2E14 Hex
and the compare value is exactly half the timer reset value = 170A Hex
So we can derive the count value for timers for desired freq. of pulse train as
shown in above method. The following table shows the timer value derived for
desired frequency in hex for the entire frequency range.
Table 2.6 CCU Timer Value For Different Frequency
Frequency
KHz
Timer count value
Decimal Equivalent Hex value
1 11796 2E14
2 5898 170A
3 3932 0F5C
4 2949 0B85
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 44
Frequency
KHz
Timer count value
Decimal Equivalent Hex value
5 2359 0937
6 1966 07AE
7 1685 0695
8 1475 05C3
9 1310 051E
10 1180 049C
11 1072 0430
12 0983 03D7
13 0908 038C
14 0842 034A
15 0786 0312
16 0737 02E1
17 0693 02B5
18 0655 028F
19 0620 026C
20 0590 024E
21 0562 0232
22 0532 0218
23 0512 0200
24 0492 01EC
25 0472 01D8
30 0393 0189
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 45
Frequency
KHz
Timer count value
Decimal Equivalent Hex value
40 0294 0126
50 0236 00EC
60 0196 00C4
70 0168 00A8
This frequency is actually frequency of pulse train, whose no of pulses are derived
through the parameters considered. This frequency is actually converted to the
speed per revolution for servo motor. This conversion is done by servo drive in
pulse position mode.
( For more details on clock management please refer the user manual of
P89LPC932 attached.)
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 46
2.3.4 The RTC and the calculation of cutter on/off time duration :
RTC – Real Time Clock
The Real Time Clock is used to generate an interrupt on each msec delay as the
timer of the RTC is configured , until the cutter on/off duration time is over.
Hence provides the exact duration for cutting action of the sheet.
Figure 2.17 Block Diagram Of RTC Unit
As the timer underflows each time the RTC interrupt is generated and
corresponding interrupt routine is being called.
Here the value of RTC timer is selected such that it decrements and reloaded with
the same value after 1 msec.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 47
Now the calculation for timer is carried out as following :
The RTC unit contains a 23 bit timer/counter , including a 7-bit pre-scalar whose
reset value is 1111111 binary. Hence the timer value is combination of
RTCH,RTCL,1111111 binary.
RTC clock source = CCLK = 7.3728 MHz
So one CCLK cycle time tcclk = 0.136 us
Now for one msec delay counter value = 1 ms / 0.136 us
= 7372.8 d
~ = 7373 d
But the nearest possible value less than the derived one is 7295 d = 001C7F H
Since every time the timer underflows its prescalar value always set to the default
value ‘111 1111’ binary. Hence last seven digits of the timer are always.
So, Timer higher byte TH2 = 00 H
Timer lower byte TL2 = 39 H
So, actual timer value = 00 H + 38 H + 111 1111 B = 7295 d
Suppose the cutter on/off duration is 1000 msec, then after every 1 msec the
timer underflows and the RTC interrupt is generated, incrementing a counter
variable by one till 1000 reached. By this duration the cutter assembly is held on
and after it is switched to off and the counter variable again set to zero. Hence the
exact time duration is achieved for cutter assembly.
Note: The RTC timer is set to on only after the pulse train transmission is over.
( For more details on clock management please refer the user manual of
P89LPC932 attached.)
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 48
2.4
2.4.1 Supply Board Before going to see all the system main board, first we are going to see the power
supply board, which is very essential for the system. The supply must be stable
under the operation conditions as well as application environment. The input to
the supply board is 230V AC, 50 Hz only ,and must able to give output of 3.3 V,
5 V, and 24 V DC with suitable load current capacity. The following diagram
shown is of the supply board :
CIRCUIT DIAGRAMS & TROUBLE SHOOTING
Figure 2.18 Circuit Diagram Of Supply Board
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 49
2.4.1.1 Circuit Functionality :
• The power supply section consists of step down transformers of 230V 50 Hz
primary to 12-0-12V secondary. The stepped down voltage is then rectifier by two
separate bridges made of diodes 1N4007. The upper one rectifies 12-12 V AC to
24 V DC, and the lower one rectifies 12-0 V AC to 12 V DC from which 3.3 V
and 5 V DC are generated.
• The high value capacitors to the input of voltage regulators charge at a slow rate
as the time constant is low, and once capacitors charged there is no resistive path
for discharge. This gives a constant value of DC voltage.
• IC 7805 is used for regulated supply of +5 V , IC 7824 is used for regulated
supply of + 24 V, and LM317 is used for regulated supply of +3.3 V; in order to
prevent any fluctuations. As shown in the figure 2.17 the filter capacitors
connected after these ICs filters the high frequency spikes. The capacitors are
connected in parallel with supply and common so that spikes filter to common,
gives stability to the supply circuit.
• Here the connector J1 is actually provided for LEDs for the indication whether the
supply line is working or not, and LEDs are actually connected to the front face of
the system through six lines cables.
• This board supplies 24 V for external use for servo motor, 3.3 V for controller,
and 5 V for LCD and the external relay board with maximum of 1 A current for
load .
• The voltage controller ICs are used with heat sinks for increasing heat radiation
area , hence avoiding overheat problems.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 50
2.4.1.2 Trouble shooting :
If you are not getting desired output DC voltages u need to diagnose the actual
problem. You should go with the following steps :
Step I : Very first step is to check the circuit as per the circuit diagram shown
in the figure 2.17.
Step II : Starting with the Transformer first, check with DMM at secondary
terminals whether you are getting the known 12-0-12 AC voltages.
Step III : Check DC voltages at the output of each bridge rectifier. For the
bridge rectifier 1 it should be more than 24 V DC and for bridge rectifier 2 it
should be more than 12 V DC. If it is not then check the connections again.
Still if you are not getting then check each diode using the DMM ( applying
forward and reverse bias).
Step IV : Check the voltages across the input capacitors, they must be same as
at the rectifier ends, otherwise it indicates that the capacitor is weak, need to
replace.
Step V: Now check the pins of the voltage regulator ICs. If any two pins of
any IC is short circuited then need to replace that IC.
Step VI : Now check the voltages across the output capacitors, should be
same as the desired ones, otherwise need to replace that capacitor.
Step VII : Check whether the voltage regulator is overheated or not, if so then
immediately switch off the supply and replace the output capacitor with higher
value capacitor (voltage capacity of that capacitor should be higher than that
desired voltage level ).
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 51
2.4.2 Main Board
Now the most essential part of the system is the microcontroller , hence its
connection to peripheral devices. The board must be as compact as possible; easy
to detach the components as well as the board , for maintenance and repairing
purpose. The board should be designed such that replacement of the external
peripherals can be possible, or rather say it can be used as the general purpose
board with the microcontroller. The board should be designed such that
programming of the microcontroller can easily be done.
Figure 2.19 Main Board With uC P89LPC932A1
** here in actual case the LCD is connected through the 16 pin cable to the controller, which is not shown in the figure, to understand the exact connections of LCD.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 52
2.4.2.1 Circuit Functionality :
The figure shows the connection to the port pins of microcontroller. Actually the
microcontroller is having TSSOP package, hence the size of the controller shown
is different than the actual one but the connections remain same.
• Port configurations :
All but three I/O port pins on the P89LPC932A1 may be configured by software
to the one of four types on a pin-by-pin basis, as shown in table 2.7. These are :
quasi-bidirectional , push-pull, open drain, and input only. Two configuration
registers for each port select the output type for each port pin.
P1.5 (RST- low active) can only be an input and cannot be configured.
P1.2 (SCL/T0) and P1.3 (SDA/ INT0 low active) may only be configured to be
Quasi-bidirectional : This can be used both as an input and output without the
need to reconfigure the port. This is possible because when the port outputs a
logic high, it is weakly driven, allowing an external device to pull the pin low.
When the pin is driven low it is driven strongly and able to sink a large current.
There are three pull-up transistors in the quasi-bidirectional output that serve these
different purposes.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 53
Open drain : The open drain output configuration turns off all pull-ups and only
drives the pull-down transistor of the port pin when the port latch contains a logic
0. To be used as logic output, a port configured in this manner must have external
pull-up, typically a resistor tied to VDD. The pull-down for this mode is the same
as for the quasi-bidirectional mode.
Input only: The input only configuration has only a Schmitt-trigger with a glitch
suppression circuit.
Push-pull: The push-pull output configuration has the same pull-down structure
as both the open drain and the quasi-bidirectional output modes, but provides a
continuous strong pull-up when a port latch contains a logic 1. The push-pull
mode nay be used when more source current is needed from a port output.
Now according to the requirement we can configure the each port pin. The
following table shows the port pin configuration along with peripherals
connected.
Table 2.8 Port Output Configuration
PxM1.y PxM2.y Mode Port pin
Physical pin Peripheral
Port 0 configuration X (0) X (0) X (QB) P0.0 03 ----------
1 0 IN P0.1 26 Keyboard (row-0) 1 0 IN P0.2 25 Keyboard (row-1) 1 0 IN P0.3 24 Keyboard (row-2) 1 0 IN P0.4 23 Keyboard (column-0) 1 0 IN P0.5 22 Keyboard (column-1) 1 0 IN P0.6 20 Control bit / stop proximity
X (0) X (0) X (QB) P0.7 19 ----------- P0M1
= 7E H P0M2 = 00 H
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 54
PxM1.y PxM2.y Mode Port pin
Physical pin Peripheral
Port 1 configuration 0 0 QB P1.0 18 TxD 1 0 IN P1.1 17 RxD
X (1) X (0) X ( IN ) P1.2 12 ----------- 1 0 IN P1.3 11 EXTI0- stop proximity 1 0 IN P1.4 10 EXTI1-start proximity 1 0 IN P1.5 06 Reset switch 0 0 QB P1.6 05 LCD- RW 0 0 QB P1.7 04 LCD- RS
P1M1 = 3E H
P1M2 = 00 H
Port 3 configuration X (1) X(0) X (IN) P3.0 09 EXT CRYSTAL ** X (1) X(0) X (IN) P3.1 08 EXT CRYSTAL** P3M1 |= 03 H
** here in this system we are using the internal RC oscillator, so we don’t need to connect a crystal externally, but the default values for P3M1 = 01 H and P3M2 = FC H , although we are not using the crystal. So we are keeping the default status although using internal RC oscillator.
• Here as shown in the figure 2.16, the peripherals are connected through
connectors only.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 55
• The potentiometer of the 5 kΩ at the LCD pins is provided for the intensity of the
pixels. You can vary the intensity as one can read the content properly.
• The transistor 2N2369 is a very high speed switching transistor ,gives the pulled
up out put from the pulses outputted by pin P2.6 to the servo motor.
• The programming ports are provided for ICP programming, where programming
port 1 is used for programming data to the controller and programming port 2 is
used for triggering the microcontroller in the programming mode using precise
sequence of reset pulses along with supply and ground. ( For more information on
ICP programming please read the manual attached fro P89LPC932A1.)
• The external board connector is actually used to connect the external board which
is an isolating board, through which the proximity switches and cutter relay is
connected. It will be more clear when we see the circuit diagram of external
board.
2.4.2.2 Circuit Trouble shooting :
If you are not getting desired output or functionality with the main board then
have to diagnose the actual problem. You should go with following steps :
Step I : First of all u have to check whether the microcontroller is working properly
or not. For that u have to give the supply (+ Vdd and GND ) and check the status of
port pins P0.6, P2.5, P2.7 ;must be at logic ‘0’. Another way to identify this is to
check whether the program loader is able to identify the device (microcontroller )
itself and properly able to load the program. If not so you have to replace the
microcontroller.
Step II : After that check the connectivity of all the connections with the help of
DMM as shown in the figure 2.18. particularly check the connectivity of controller
pins to the connector pins.
Step III : If you are not getting the pulse output at the connector, check the pin P2.6
using CRO, if pulse is there then you have to check transistor 2N2369. Still if you are
not getting the pulse you have to replace that transistor.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 56
2.4.3 Key Board
Key board is a interface through which, human can communicate to the machine.
Here for the proposed system key board should be a X-Y matrix type. The matrix
is most efficient when arranged as a square so that N leads for X and N leads for
Y can be used to sense as many as N x N keys. Matrices are the most cost
effective for a large number of keys. Here we need total 6 no of keys to integrate
the desired action with microcontroller with maximum of 5 port pins.
Figure 2.20 Keyboard Circuit Diagram
** here the key board also consists the three power indicating LEDs not shown in the figure.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 57
2.4.3.1 Circuit Functionality :
• Here the circuit actually consists of a logical 3x2 matrix. Here the diodes are used
for providing the initial all the pins high as they are not conducting when the
switch is not pressed.
• The key is a 4 pin push to on type switch for which two pins are short circuited
as shown in the figure. A two pin push to on switch can also be used, with a small
change; have to remove the short circuiting path.
• Initially diode is not conducting or say in a free wheeling mode hence all rows
and columns are initially at high level. Now whenever the key is pressed the
diodes start conducting as the cathode is now connected to the ground and pulls
down the corresponding row and column to zero ( neglecting drop voltage of 0.57
V ). This triggers the port pin and according to that pulled down row and column ,
the pressed key is detected and corresponding action is to be taken by micro
controller.
• Here only the corresponding row and column is pulled down to zero because the
connections of diodes as shown in the figure 2.19 prevents a path to the ground,
hence not affecting other rows and columns keeping them to the high level (+3.3
V).
• Here the drop out voltage of 0.6 V of diode is neglected as the low level threshold
voltage for the controller pin is VTH(LH) = 0.3 VDD = 0.3 x 3.3 = 0.99 V which is
grater than the 0.6 V so the drop voltage is negligible to interpret the logic low
level ( ~ 0 V ).
• Here the supply for the key board is carried out from the main board.
• The corresponding action is to be taken as the key is pressed as shown on the
above figure with row and column downs to zero; in accordance with the Key
board interrupt SFRs.
• The resistors provided for each row and columns are actually for current limiting
as the input current sink capacity of the controller pin is low as well as the same
source is used for the microcontroller. The key board hardly draws the current of
5 mA.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 58
2.4.2.2 Circuit Trouble shooting :
If you are not getting desired output or the defined action is not being executed
after pressing the key from the keyboard and the main board is working properly
then need to diagnose the actual problem with the keyboard. You should go with
the following steps :
Step I : First disconnect the key board from the main board.
Step II : Check all connections and apply +3.3 V and GND to the corresponding pins
as shown in the figure 2.19.
Step III : Now check the status of all pins for rows and columns. Initially they must
be at high level. You can do this by checking the voltage level between that particular
pin and GND using DMM.
Step IV : Now press all the keys one by one. The corresponding row or column pin
must pulled down at logic ‘0’ or the voltage between that pin and GND should be zero
( neglecting the dropout voltage of 0.6 V ). If you are not finding such status change,
then check the diodes of that row or column pins using DMM .
Step V : If diodes are working properly and still you are not getting the exact output ,
then check the connectivity between GND pin and pin 2 of the key. If they are found
short circuited without pressing the key then the switch is damaged you have to
replace that switch. Again check the conductivity between pin 1 and 2 (or 3 and 4) of
the key. It should not conducting if the key is not pressed otherwise replace the
switch.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 59
2.4.4 External Board
The external board is divided in two part the first part consists the opto-isolation of
proximity switches, and the second unit consist the isolation of cutter relay. The
provision behind this is the switching of cutter relay at higher voltage and current value
can damage the proximity switches if the connections to the connector are not made
properly.
2.4.4.1 External Board 1 :
Figure 2.21 Circuit Diagram Of External Board-1
2.4.4.1.1 Circuit Functionality:
• Here the proximity switches are connected to the 3 pin connectors as shown in the
figure. Here two stop proximity switches are connected parallel to the same part.
• The three terminals are provided (+24 V, O/P, GND ) fro proximity switches and
the O/P terminal is connected to the anode of the opto-coupler MCT2E through a
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 60
10 kΩ resistor. The 3.3 kΩ resistor is provided for proper biasing of the collector
of the opto-coupler transistor .
• Initially collector output of the proximity switch is high. Whenever the proximity
senses it triggers the diode of the opto-coupler and , will conduct the transistor
leading the supply to the ground switching to the low level, which will trigger the
interrupt pin of the microcontroller.
• The supply for opto-coupler transistor is carried out from the main board through
the connector as shown in the figure 2.20 .
• The 24 V supply is directly provided so that no other external supply is required
for proximity switches.
• This 5 pin connector is connected to the first five pins of 10-pin buck strip male
connector of the main board.
• This board provides an opto-electrical isolation for microcontroller and also
suppress the noise coming from external environment through high voltage
proximity switches.
2.4.4.1.2 Circuit Trouble shooting :
For trouble shooting of the external board1 you should go with following steps :
Step I : As this board is connected to the external peripherals and if you are
finding some problem, first of all you have to check whether the proximity
switches are working properly or not. For that provide the supply to the proximity
switches, take a metal sheet and bring it near the proximity switch, the output
terminal should go high.
Step II : Now check all connection as shown in the figure 2.20.
Step III : At the connector pins the now check the status . Initially they must be
at high level. You can do this by checking the voltage level between that
particular pin and GND using DMM.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 61
Step IV : The CNTRL, stop proxi and start-proxi pin are high (+3.3 V) till the
proximity switch has not sensed. Once the switch has sensed, the level should be
pulled down to the GND (0 V between that pin and GND pin).
Step V : Now for the opto-coupler, apply the +24 V and GND to anode and
cathode respectively ( pin 1 and 2 ) . Now using DMM check the voltage level
across collector and emitter it should be 0.6 V or less ( forward drop out voltage ).
Now remove the supply from anode or cathode, the LED will turn off and the
voltage level across collector and emitter should be 3.3 V. If it is not so then you
have to change the Opto-coupler IC.
2.4.4.2 External Board 2 :
Figure 2.22 Circuit Diagram Of External Board 2.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 62
2.4.4.2.1 Circuit Operation :
• The last pin of 10-pin buck strip male connector , a cutter output triggers the two
transistors BC548. The transistor Q1 is used to trigger the cutter relay an
transistor Q2 is used to trigger the opto coupler. Here u can directly connect the
LED which is for the cutter relay on/off indication without using the opto-coupler.
• Here transistors Q1 and Q2 are provided because the load current capacity or say
driving capacity of the microcontroller pin output is low. Hence we require to
pull up the driving capacity through the transistors.
• Here the relay coil is connected between +5 V and the collector of transistor
Q1.The freewheeling or protection diode is connected across the relay coil to
provide the discharge path.
• The capacitors at the supply connector are provided to reduce the flickering or
ripples while relay switching.
• Now initially the supply path for charging the relay coil as well as the path for
opt0-coupler LED is not completed , as the transistors Q1 and Q2 are not
conducting
• When the cutter output pin goes high at the end of pulse train, both the transistors
Q1 and Q1 triggers simultaneously, completing the path- triggers the relay coil to
charge and switching in the on state. At the same time the LED also on when the
transistor Q2 is conducting.
• The relay and the LED remains on till the cutter output is high according to the
time delay is set.
2.4.4.2.2 Trouble shooting :
for trouble shooting of the external board2 you should go with the following
steps:
Step I : check all the connection as shown in the diagram 2.21.
Step II: Now check the transistors BC548 , the voltage across collector and
emitter should be 5 V.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 63
Step III : Now for the opto-coupler, apply the +5 V and GND to anode and
cathode respectively ( pin 1 and 2 ) . Initially the LED of opto-coupler is off, if the
cutter pin goes high , it triggers both the transistors Q1,Q2. Now using DMM
check the voltage level across collector and emitter it should be 0.6 V or less (
forward drop out voltage ). Now remove the supply from anode or cathode, the
LED will turn off and the voltage level across collector and emitter should be 5 V.
If it is not so then you have to change the Opto-coupler IC.
Step IV : If the relay is not triggering, first apply the 5 V across the coil of the
relay, you will immediately hear a knocking voice of the relay and the output
terminals are now short circuited; if it is not then change the relay.
Step V: Now still the relay is not switching then, check the protection diode
across the coil terminals. Now check the voltage level across collector and emitter
of the transistor Q1 it should be 5 V when no triggering occurs if it is not then
replace the transistor.
Step VI : Now if the cutter Led is not glowing while switching then check the
polarity of the LED again, still it is not glowing then check the LED using DMM.
Then follow the step 3 again for opto-coupler.
Step VII : The voltage across the capacitors must be equal to + 5V. If it is not
then it means the capacitor is sinking a current hence it is weak need to replace
it.
So here in this chapter we have seen different units of entire system hardware
with discrete functionality. The functionality of the hardware should be same as
described, if it is not then refer the trouble shooting for each circuit. The
initializations of these unit through the software routines and the flow charts are
given in the next chapter.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 64
System flowcharts
Introduction to µVision 3 Keil Software
The microcontroller device programmer
Smart ICP 1.2 – The Programmer software
Testing result
3. S
tudy
Of
Exi
stin
g Sy
stem
. . .
3. S
oftw
are.
. .
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 65
3.1
SYSTEM FLOWCHARTS :
3.1.1 Flowchart representing the working of the system :
INITIALIZATION OF MICROCONTROLLER AND SYSTEM PERIPHERALS
( PORT PINS,LCD,CCU ,RTC ,KEYBOARD )
READ THE PARAMETERS FROM THE EEPROM AND ASSIGN TEMPORARY VARIABLES
( PREVIOUSLY RUNNING PARAMETERS )
DISPLAY WELCOME MESSAGES
RUN MODE – DISPLAY LENGTH AND FREQUENCY, CALCULATE THE PULSE COUNT FROM TEMPORARY
VARIABLES, WRITE THEM AGAIN TO THE EEPROM
IF KEY IS PRESSED
?
KEY DEBOUNCE DELAY
IDENTIFY THE KEY, TAKE CORRESPONDING ACTION AND DISPLAY THE SAME THROUGH LCD
SET THE REQUIRED PARAMETERS THROUGH KEYBOARD
END
START
YES
NO
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 66
3.1.2 Flowchart for LCD initialization :
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 67
3.1.3 Flowchart for CCU initialization :
START
CHECK THE VALUE OF VARIABLE ‘ freq’WHICH CONTAINS OUTPUT FREQUENCY
(1 TO 70 kHz , PREVIOUSLY RUNNING FREQUENCY)
DISABLE ALL CAPTURE COMPARE CHANNEL EXCEPT ‘A’
ENABLE OUTPUT COMPARE CHANNEL ‘A’ INTERRUPT
LOAD HALF VALUE OF TIMER OVERFLOW RELOAD REGISTERS
TO OUTPUT COMPARE REGISTERS ‘OCRAH, OCARL’
SET CHANNEL ’ A’ TO NON INVERTING SYMMETRICAL ‘PWM’ MODE
LOAD PREDEFINED VALUE TO TIMER OVERFLOW RELOAD REGISTERS ‘TOR2H, TOR2L’
AS PER THE VALUE OF VARIABLE ‘freq’
END OF INITIALIZATION
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 68
3.1.4 Flowchart for RTC initialization :
START
SET RELOAD VALUE TO RTC TIMERS (AS DERIVED IN SECTION 2.3.4)
SELECT CCU CLOCK AS A RTC CLOCK SOURCEAND
ENABLE RTC UNIT
ENABLE WATCH DOG / RTC INTERRUPT
END OF INITIALIZATION
3.1.5 Flowchart for Keyboard initialization :
START
SET ALL PORT PINS HIGH OF PORT P0 EXCEPT P0.6
ALLOW P0.1,P0.2,P0.3 PINS TO GENERATE KEYBOARD INTERRUPT USING ‘KBMASK’ REGISTER’
SET THE INPUT PATTERN THAT SHOULD NOT BE ALLOWED USING ‘KBPATN’ REGISTER
ENABLE KEYBOARD INTERRUPT
END OF INITIALIZATION
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 69
3.1.6 Flowcharts for Interrupt Service Routines : 3.1.6.1 External Hardware interrupt 0 – Stop Proximity Switch ISR :
ON SENSING THE NEGATIVE LEVEL ON PIN P1.3 (EXT0)THE INTERRUPT ROUTINE IS EXECUTED FOR STOP PROXIMITY SWITCH
DISABLE ALL EXTERNAL INTERRUPT TEMPORARYDISABLE KEYBOARD INTERRUPT TEMPORARY
DISABLE WATCHDOG/ RTC INTERRUPT TEMPOARARY
CLEAR PIN P2.5 PULSE LED STATUS PINCLEAR PIN P2.7 CUTTER ON/OFF PIN – STOP CUTTER ASSEMBLY
SET HLTRN BIT OF REGISTER TCR20 TO FORCE AN IMMEDIATE HALTED PWM OF CCU
STORE CURRENT VALUE OF CCU TIMERS TEMPORARYAND STOP CCU TIMERS
STORE CURRENT VALUE OF ACTUAL PULSE COUNT VALUE TEMPORARY
SET THE ‘ tstop’ VARIABLE AS AN INDICATION OF STOP PROXIMITY SWITCH HAS SENSED
DISPLAY FAILURE MESSAGEENABLE EXTERNAL INTERRUPTS
END OF INTERRUPT SERVICE ROUTINE FOR STOP PROXIMITY SWITCH
START PROXIMITY SWITCH HAS SENSED
?
NO
YES
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 70
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 71
B
ENABLE OUTPUT COMPARE CHANNEL A ( OCA )
SET ‘ccu_flag’ VARIABLE AS A BEGINNING OF CCU OPERATION
SET THE ‘pulsled’ AS AN INDICATION OF START OF PULSE TRAIN
CLEAR ‘HLTRN’ BIT OF ‘TCR20' RGISTER OF CCU TO RESTART PWM
ENABLE CCU INTERRUPT
START CCU TIMERS
END OF INTERRUPT SERVICE ROUTINE FORSTART PROXIMITY SWITCH
A
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 72
3.1.6.3 Software interrupt – Real Time Clock ( RTC ) ISR :
ON SETTING WATCHDOG/ RTC INTERRUPT BITTHE RTC ISR IS EXECUTED
IS INTERRUPT CAUSED BY RTC
?
IS INTERRUPT CAUSED BY
WATCHDOG TIMER?
CLEAR WATCHDOG TIMER INTERRUPT FLAG
CLEAR ‘pulsled’ AS AN INDICATION OF PULSE TRAIN IS OVER
SET ‘cutter’ AS SWITCHING ON CUTTER ASSEMBLY
THROUGH RELAY
DISABLE EXTERNAL INTERRUPT 1
INCREMENT ‘rtccnt’ BY ONE AS APPROACHING TOTAL ON TIME DURATION
FOR CUTTER ASSEMBLY
CLEAR RTC INTERRUPT FLAG
IS rtccnt < time
?
NO
C
D
NO
YES
YES
NO
YES
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 73
END OF INTERRUPT SERVICE ROUTINE FORRTC AS A CUTTER ASSEMBLY ON DURATION
D
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 74
3.1.6.4 Software interrupt – Key Board ISR :
ON PRESSING ANY KEY OF THE KEYBOARD THE KEYBOARD INTERRUPT FLAG BIT IS SET AND THE KEYBOARD INTERRUPT ROUTINE IS
EXECUTED
DISABLE KEYBOARD INTERRUPT TEMPORARY
DEBOUNCE DELAY OF 30 msec
FIND THE ROW AND COLUMN BY OBSERVING THE STATUS OF PORT 0 PINS
IF P0.1= 0THEN ROW=0
IF P0.2=0THEN ROW=1
IF P0.3=0THEN ROW=2
IS P0.4=0AND
P0.5=1?
COLUMN=0
COLUMN=1
DELAY FOR 2 msec
SET ‘flag’ VARIABLE BIT
YES
NO
RESET KEYBOARD INTERRUPT FLAG
END OF INTERRUPT SERVICE ROUTINE FOR KEYBOARD INTERRUPT
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 75
3.1.5.5 Software interrupt – CCU ISR :
ON EVERY COMPARE EVENT OF CCU TIMER THE CCU TIMER INTERRUPT FLAG IS SET AND THE CCU INTERRUPT ROUTINE IS EXECUTED
DISABLE CCU TIMER INTERRUPT FLAG
CLEAR CARRY FLAG OF PROGRAM STATUS WORD
CLEAR THE ACCUMULATOR ‘A’
INCREMENT THE ACCUMULATOR BY ONE
IS ‘A’ < ACTUAL PULSE COUNT
?
STOP THE CCU TIMER
DISABLE CCU INTERRUPT FLAG
DISABLE OUTPUT COMPARE CHANNEL ‘A’
SET THE ‘cnt_flag’ FOR RESUMING THE RTC TIMER AT THE END
END OF INTERRUPT SERVICE ROUTINEFOR CCU INTERRUPT
YES
NO
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 76
3.2
3.2.1 What is µVision3 ?
INTRODUCTION TO µVISION3 KEIL SOFTWARE :
Keil micro vision is an integrated development environment used to create
software to be run on embedded systems ( like a microcontroller). It allows for
such software to be written either in assembly or C programming languages and
for that software to be simulated on a computer before being loaded onto the
microcontroller.
µVision3 is an IDE ( Integrated Development Environment) which is a window
based software development platform that combines a robust editor, project
manager and make facility. µVision3 integrates all tools including the C compiler
, macro assembler, linker/locator, and a hex file generator. µVision3 helps
expedite the development process of your embedded applications by providing the
following:
Full-featured source code editor
Device database for configuring the development tool setting
Project manager for creating and maintaining projects
Integrated make facility for assembling, compiling and linking your embedded
applications
Dialogs for all development toll settings
True integrated source level debugger with high speed CPU and peripheral
simulator
Advanced GDI interface for software debugging in the target hardware and for
connection to Keil ULINK
Flash programming utility fro downloading the application program into flash
ROM
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 77
3.2.2 Step followed in creating an application in µVision3 : To create a new project in µVision3
1. Select project new project
2. select a directory and enter the name of the project file.
3. Select project Select device and select a device from Device database.
4. create source files to add to the projects.
5. Select project Targets, groups , and files. Add/Files, select source
group1, and add the source files to the project.
6. Select project options and set the toll options. Note that when the target
device is selected form the device database all special options are set
automatically. Default memory model settings are optimal for most
applications.
7. Select project- rebuild all target files or build target
To create a new project, simply start Micro vision and select “ Project” “ New
Project” from the pull-down menus. In the file dialog that appears, choose a name
and base directory for the project. It is recommended that a new directory be
created for each project, as several files will be generated. Once the project has
been named, the dialog shown in the figure below will appear, prompting the user
to select a target device. In this lab, the chip being used is the “ P89LPC932A1”,
which is listed under the heading “NXP ( founded by Philips)”. This procedure for
selecting a device is shown in the following figure.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 78
Figure 3.1(a) Selecting a Device Vendor Name
Figure 3.1 (b) Selecting a Device Figure 3.1 Widows For Selecting Target Device
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 79
Next , µVision3 must be instructed to generate a HEX file upon a program
compilation. A HEX file is a standard file format for storing executable code that
is to be loaded onto the microcontroller.
In the “Project Workspace” pane at the left, right click on “Target 1” and select “
options for ‘ Target 1’. Under the “Output” tab of the resulting options dialog,
ensure that both “ Create Executable” and “ Create HEX file” options are
checked. Then click “OK” as shown in figure below.
Figure 3.2 Project Option Dialog Window
Next a file must be added to the project that will contain the project code. To do
this, expand “Target 1” heading, right click on the “Source Group1” folder, and
select “Add files…” Create a new blank file ( the file name should end in “.asm”
or “.C ” ), select it, and click “Add”. The new file should now appear in the
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 80
“Project Workspace” pane under the “Source Group1” folder. Double click on the
newly created file to open it in the editor. All code fro this lab will go in this file.
To compile the program, first save all source files by clicking “Save All” button,
and then click on the “Rebuild All Target Files” to compile the programs as
shown on the figure below. If any errors or warnings occur during compilation,
they will be displayed in the output window at the bottom screen. All errors and
warning will reference the line and column number in which they occur along
with a description of the problem so that they can be easily located. Note that
only errors indicate that the compilation failed, warnings do not ( though it is
generally a good idea to look into them anyway).
Figure 3.3 “ Save all” And “ Build All Target Files” Options
When the program has been successfully compiled, it can be simulated using the
integrated debugger in Keil µVision3. To start the debugger, select “ Debug”
“Start/ Stop Debug Session” from the pull down menus.
At the left side of the debugger window, a table is displayed containing several
key parameters about the simulated microcontroller, most notably the elapsed
time ( circled in the figure below). Just above that , these are several buttons that
control code execution. The “Run” button will cause the program to run
continuously until a breakpoint is reached, whereas the “Step Into” button will
execute the next line of code and then pause (the current position in the program
is indicated by a yellow arrow to the left of the code).
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 81
Figure 3.4 µvison3 Debugger Window
Breakpoints can be set by double–clicking on the grey bar on the left edge of the
window containing the program code. A breakpoint is indicated by a red box next
to the line of code.
The current state of the pins on each I/O port on the simulated microcontroller can
also be displayed. To view the state of a port, select “Peripherals” “I/O Ports”
“Port n” from the pull–down menus, where n is the port number. A checked
box in the port window indicates a high (1) pin, and an empty box indicates a low
(0) pin. Both the I/O port data and the data at the left side of the screen are
updated whenever the program is paused.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 82
Figure 3.5 ‘Reset’, ‘Run’ and ‘Step into’ options for Debugging Window
The debugger will help eliminate many programming errors, however the
simulation is not perfect and code that executes properly in simulation may not
always work on the actual microcontroller.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 83
3.2.3 Device Database
A unique feature of the Keil µVision3 IDE is the Device Database, which
contains information about more than 400 supported microcontrollers. When you
create a new µVision3 project and select the target chip from the database,
µVision3 sets all assembler, compiler, linker, and debugger options for you. The
only option you must configure is the memory map.
3.2.4 Peripheral Simulation
The µVision3 Debugger provides complete simulation for the CPU and on-chip
peripherals of most embedded devices. To discover which peripherals of a device
are supported, in µVision3 select the Simulated Peripherals item from the Help
menu. You may also use the web-based Device Database. We are constantly
adding new devices and simulation support for on-chip peripherals so be sure to
check Device Database often.
3.3 THE MICROCONTROLLER DEVICE PROGRAMMER
The programmer used is a powerful programmer for the Philips NXP 89C51
series of microcontrollers that includes P89LPC 9XX, P89V51RXX,
P89CV51RXX ,P89LV51RXX, P89V52X2,LPC2000 and all the NXP controllers
which have the facility of ICP or ISP programming.
It is simple to use & low cost, yet powerful flash microcontroller programmer for
the NXP 89C51 series. It will Program, Read and Verify Code Data, Write Lock
Bits, Erase and Blank Check. All fuse and lock bits are programmable. This
programmer has intelligent onboard firmware and connects to the USB port. It can
be used with any type of computer and requires a special hardware. All that is
needed is a USB communication port which all computers have.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 84
All devices also have a number of lock bits to provide various levels of software
and programming protection. These lock bits are fully programmable using this
programmer. Lock bits are useful to protect the program to be read back from
microcontroller only allowing erase to reprogram the microcontroller.
Major parts of this programmer are USB port, Power Supply, and a special
hardware Board provided with the Firmware.
All the programming ‘intelligence’ is built into the programmer and all the data is
sent or received through the USB. Programmer comes with window based
software for easy programming of the devices.
Figure 3.6 The Smart ISP Programmer
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 85
3.4
• For the programming the microcontroller , first discard all the connections
of the main board including the supply itself.
SMART ICP 1. 2 – THE PROGRAMMER SOFTWARE
‘Smart ICP 1.2’ is a software working as a user friendly interface for programmer
board from ‘Potent embedded solutions’. ‘Smart ICP 1.2’ gets its name from
“Program Loader” term, because that is what it is supposed to do. It takes in
compiled HEX file and loads it to the hardware.
Any compiler can be used with it, Assembly or C, as all of them generate
compiled HEX files. ‘Smart ICP 1.2’ accepts the Intel HEX format file generated
from compiler to be sent to target microcontroller. It auto detects the hardware
connected to the USB port. It also auto detects the chip inserted and bytes used.
The software requires no overhead of any external DLL.
The programmer connects to the computer’s USB port with a standard USB to
mini USB cable. No PC Card Required.
After making the necessary selections, the ‘Program’ button is clicked as shown
in the figure below which burns the selected hex file onto the microcontroller.
Steps for programming :
• Now the three pin connector ( Reset, Vdd , GND ) from the programmer
hardware is to be connected to the programming port 2 as shown in the
figure 2.18, and the two pin connector ( PCA , PCD) to the programming
port 1 ( as shown in the figure 2.18 )
• Now connect the USB cable from the programmer Board to the USB port
of the PC.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 86
• Open the ‘Smart ICP 1.2’ software window and click on the search device
button two or more times. It will automatically identify the controller
Device
Figure 3.7 ICP Programming Window
• Now click on the ‘select hex file’ button, browse the hex file to upload ,
and click download button .
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 87
Figure 3.8 device select window with hex file
• Now click on the ‘ update configuration’ button and then click on the ‘start
programming’ button.
• The programmer will automatically erase and blank Checks the flash
memory and verify code data, write Lock Bits. After getting “Verify Ok”
, disconnect the board from the USB also discard the connectors, re-
assemble the main board.
• Now the micro controller is programmed perfectly and ready to run the
system hardware.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 88
Figure 3.9 Device Programming Window
So, the above steps are very helpful for programming the microcontroller device.
For that you do not need to detach the microcontroller from the system board, just
simply connecting the two connectors and using the above software tool we can
easily program the microcontroller.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 89
3.5
Let,
Servo parameter multiplier : 0
TESTING RESULT :
1
Precision pulses (bits) in terms of 2^ X : 1 1 ( as per standard value )
Feed roller diameter : 0 0 8 0 mm
Required Length of the sheet : 0 2 5 1 mm
Offset length : 3 2 7 2 um
Gear ratio : 0 1
So, displacement length of the feed roller
DLR = 3.14159 x 80 / 0 1
= 251.3272 mm
Calculation for servo parameters
ANS = 2 x 2^ 11 / 0 1
= 4096
Actual length = 0 2 5 1 (mm) + 3 7 2 7 (um)
= 251.3272 mm
So Actual Pulse Count = 251.3272 x 4096 / 251.3272
= 4096
RESULT:
On sensing the start proximity switch the pulse train is generated and fed to the
servo drive. The drive is connected to motor and motor shaft is directly connected
to the feed roller, which completes exact one rotation
Here the pulse frequency only decides rotation speed; higher the frequency ,
higher the speed towards completing the task.
for desired length
independent of the pulse frequency.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 90
So, in this chapter we come to know about the flowcharts of different units as a
consequence of developing the software routines. Also we come to know about a
very powerful software developing tool Keil µvision3. Also we have the testing
result which tells , how the precise system has been built.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 91
Hardware installation manual
Pulse position mode setup for servo drive
Setting common basic functions for servo drive
Display layouts with parameter feeding
Final prototype
3. S
tudy
Of
Exi
stin
g Sy
stem
. . .
4. U
ser g
uide
. . .
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 92
4.1 First of all we are going to see the hardware installation for the unit. The following figure
shows the actual hardware connection.
HARDWARE INSTALLATION MANUAL :
Figure 4.1 System Connection To Peripherals
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 93
As connection done as shown in the above figure now go through following steps.
The following steps are mandatory:
Step I: The pin connections are to be made very carefully for CN1 as given in
the following section.
Step-II : Check all the connections very carefully.
Step-III : Do not connect the servo motor directly to the belt assembly without
testing.
Step-IV : Switch on the power supply of C2L first, and wait till the welcome
messages are over.
Step-V : Now switch on the power supply of servo drive.
Step-VI: Set the parameters for pulse position mode for the servo drive as given
in the following section.
Step-VII: On completing step-V switch off the drive supply and again switch on
the drive supply.
Step-VIII : Feed the parameters through the keyboard as given in section 3.5
Testing Result. If you are getting the same result by feeding those parameters then
the motor can be now connected to the belt assembly.
Note: In case of switching off the entire unit, first of all switch off the servo
assembly first and then & then switch off the C2L unit.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 94
4.2
Setting Parameters:
Set the following parameters for position control using pulse train.
PULSE POSITION MODE SETUP FOR SERVO DRIVE :
1) Control Mode selection
2) Setting a reference Pulse Form
Set the input form for the SERVOPACK using parameter Pn2000.0 according to
the host controller specifications.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 95
3) Clear signal Form Selection
The internal processing of the SERVOPACK for the clear signal can be set to
either of four types by parameter Pn200.1. Select according to the specifications
of the machines or host controller.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 96
4) Clear Operation Selection
This parameter determines when the error pulse should be cleared according to
the condition of the SERVOPACK, in addition to the clearing operation of the
clear signal(CLR). Either of three clearing modes can be selected with Pn200.2.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 97
4.3 SETTING COMMON BASIC FUNCTIONS FOR SERVO DRIVE
1) Servo ON signal (/S ON)
4.3.1 Setting the ON Signal
This sets the servo ON signal (/S ON) that determines whether the servomotor
power is ON or OFF.
2) Enabling/Disabling the Servo ON signal
A parameter can be always used to set a parameter servo ON. This eliminates the
need to write /S-ON, but care must be taken because the SERVOPACK can
operate as soon as the power is turned ON.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 98
4.3.2 Switching the servomotor Rotation Direction The rotation of direction of the servo motor can be switched without changing the
reference pulse to the SERVOPACK or the reference voltage polarity.
This cause the travel direction(+,-) of the shaft reverse. The output signal polarity
such as encoder pulse output and analog monitor signal from the SERVOPACK
does not change.
The standard setting for ”forward rotation” is counterclockwise as viewed from
the drive end.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 99
4.4 DISPLAY LAYOUTS WITH PARAMETER FEEDING :
figure 4.2 ‘C2L- Cut To Length Controller’
Now we’ll see different layouts of and handling of the parameters using keyboard
As we switch on the supply for the system, u can see the welcome messages
through the LCD. After that the running mode will be displayed.
Display Layout 1:
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 100
Display Layout 2:
Display Layout 3:
Display Layout 4:
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 101
Display Layout 5:
Display Layout 6 :
Display Layout 7:
Now again pressing the enter key , it comes to the display layout1 by recalculating
the desired count and rewriting all parameters to the EEPROM again.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 102
4.5 FINAL PROTOTYPE
Figure 4.3 Final Prototype
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 103
CONCLUSION
A step by step approach in designing the microcontroller based system for cutting
the desired length of the sheet and control for essential parameters for SERVO
PACK and belt assembly. The result obtained from the calculation have shown
that the system performance is quite reliable and accurate.
The system has successfully overcome quite a few shortcomings of the existing
systems by reducing the power consumption, maintenance and complexity, at the
same time providing a flexible and precise form of maintaining the requirement.
The continuously decreasing costs of hardware and software, the wider
acceptance of electronic systems in Industry, and an emerging Automation control
system in several areas, will result in reliable control systems that will address
several aspects of quality and quantity of production. Further improvement will be
made as less expensive and more reliable sensors are developed for Automation.
Although the enhancements for the system, the required technology and
components are available, many much systems have been independently
developed, or are at least tested at a prototype level. Also, integration of all these
technologies is not a daunting task and can be successfully carried out.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 104
FUTURE SCOPE
The performance of the system can be further improved in terms of the operating
speed, memory capacity, instruction cycle period of the microcontroller by using
other advanced microcontrollers.
The device can be made to perform better by providing the power supply with the
help of battery source which can be rechargeable or solar powered, to reduce the
requirement of main AC power.
A multi controller system can be developed that will enable a master controller
along with its slave controllers to automate multiple conveyor belt assembly
simultaneously.
With further modifications for the software and hardware we can automate the
multi dimensional cutting with higher precision without the need of MP machine
controller. The same system can be used in metal industry for metal sheet cutting
with the further modifications.
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 105
REFERENCES White Papers
[1] Ludovico Alcorta, ‘the impact of industrial Automation On Industrial
Organization: Implications fro developing Countries Competitiveness’; The
United Nations University ,INTECH Institute for New Technologies, discussion
paper series # 9508.
[2] Turnell, D.J de Fatime, Q.V., G.S. Freire, An integrated, modular industrial
automation system, Proceedings of IEEE International Conference On Systems,
Man, and Cybernetics, Vol.2 , Oct 1998.
Books
[1] Muhammad Ali Mazidi, Janice Gillispie Mazidi, ROlin D. MC Knlay, The 8051
Microcontroller & Embedded Systems, Pearson Education Inc. 2nd Edition, 2008.
[2] Myke Predko,Programming & Customizing the 8051 Microcontroller,TMH,1999.
[3] Ramakant Gayakwad, Operational Ampilfiers Linear Integrated Circuits, Prentice
Hall of India , 3rd Edition.
[4] E Balagurusamy, Programming in ANSI C , TMH, 3rd
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 106
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 107
ANNEXURE-I
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 108
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 109
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 110
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 111
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 112
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 113
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 114
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 115
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 116
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 117
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 118
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 119
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 120
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 121
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 122
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 123
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 124
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 125
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 126
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 127
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 128
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 129
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 130
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 131
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 132
ANNEXURE-II
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 133
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 134
. Cut to Length Controller
___________________________________________________________________________________________ V.T Patel Department Of Electronics & Communication Engineering 135