Professional Documents
Culture Documents
ECNG 2005
Laboratory and Project Design 3
Marlon Boucaud
1
808011031
Group G
Table of Contents
Table of Contents............................................................................................................................iv
List of Figures................................................................................................................................vii
List of Tables................................................................................................................................viii
Abstract...........................................................................................................................................ix
INTRODUCTION.........................................................................................................................10
THEORY.......................................................................................................................................12
DC Motor Operation..................................................................................................................12
Importance of Control................................................................................................................13
Control Schemes that exist for DC Motor.................................................................................15
Requirement Specification.........................................................................................................17
Motor Specifications..............................................................................................................17
Transistor Driver Specifications............................................................................................17
PIC Specifications.................................................................................................................18
Transmitter / Receiver Specifications....................................................................................19
Existing Approaches to the Implementation of Control Algorithm...........................................19
Remote analog communication techniques...............................................................................21
Velocity measurement................................................................................................................22
Block Diagram of System showing Major subsystems.............................................................24
STANDARDS AND PROTOCOLS..............................................................................................25
Laboratory Protocol...................................................................................................................25
Industrial Standard for Safety Protocol.....................................................................................27
General Duties.......................................................................................................................27
Code of Practice.........................................................................................................................29
Risk Assessment........................................................................................................................30
Evaluation the risks....................................................................................................................31
4
APPENDIX 1.................................................................................................................................75
Code for the PI control, Display unit and the speed control......................................................75
Nichibo DC Motor.....................................................................................................................87
Datasheet for Phototransistor Optical Switch..........................................................88
List of Figures
Figure 1:Block Diagram of system being controlled.....................................................................13
Figure 2: Block Diagram of Major Subsystems of Design............................................................23
Figure 3: Shows the General Block Diagram Conceptually Designed..........................................38
Figure 4: Shows a 3-dimensional diagram for real world application...........................................39
Figure 5: Conceptual Design of the Control Algorithm................................................................41
Figure 6: Shows the Mathematical Model of the DC motor.........................................................42
Figure 7: Actual Motor Root Locus...............................................................................................46
Figure 8: Step Response for Actual Motor....................................................................................47
Figure 9: Shows the block diagram for the PI control specifications............................................49
Figure 10: Shows the In depth Block diagram of the PI controller with the motor......................49
Figure 11: Root Locus for Motor with PI control..........................................................................51
Figure 12: Step Response for motor with PI Control....................................................................52
Figure 13: Motor rot locus with proportional on PV Control Topology.......................................53
Figure 14: Motor step response with proportional on PV control topology..................................54
Figure 15: PWM for the PIC 16F877 chip....................................................................................56
Figure 16: Shows the PWM output from any device....................................................................57
Figure 17: Show the diagram of the motor with the controller used for position / speed of the
motor..............................................................................................................................................59
Figure 18: Shows the LED display unit used................................................................................60
List of Tables
Table 1: Shows the required Specification of the Motor...............................................................17
Table 2: Shows the PIC specification of the Design......................................................................18
Table 4: Shows the values characters that could be displayed on the LED display unit...............62
Abstract
The main objective of this design project exercise was to conceptually design, construct,
and test/troubleshoot a remote Proportional Integral (PI) control Direct Current (DC) motor using
a Peripheral Interface Controller (PIC) to meet the design specification. The specified motor to
be used was the Nichibo model PC 280-20215 which has an operating voltage range of 3-9.0 for
maximum operation of the motor and must be driven by a dc voltage from a standard laboratory
power supply. The PI control strategy must be programmed on the PIC16F877 chip. The motor
must be designed to drive a toy car model with wireless communication range of at least 1m so
that it would not interfere with other transmitting and receiving signals from other devices and
the motor must not turn in event of the communication loss. For circuit protection, the circuit
must employ current sensing to limit any current exceeding 1A from passing through the circuit.
The speed of the motor was measured using a Photo transistor Interrupter switch and interrupter
disc and the speed was displayed on the LED seven segments, in such a way as to suppress the
leading zero when displaying values. All circuits were constructed on Multisim7.0 and simulated
to ensure that each of the designed part was functioning as inspected. The design fabricated in
parts and was then mounted together to get the full system. The system was then tested with all
system features fully upgrade from the original specification. The motor operated in the range of
3-12V with a maximum current of 2.48 and when the current breached 1A the current cut off
limited the current. The receiver system outputted a square wave of 8V peak to peak and was
able to establish a wireless communication range of at least 1m. The display unit was tested
without the PIC16F877 chip in the presence of the laboratory technician and each LED bar
lighted up by testing each segment. The number 5 was then demonstrated and multiplexing of the
LEDs was also shown. The PIC16F877 chip was programmed with a combination PI control,
speed control and display code. The entire system was not tested when integrated due to erros as
well as time constraints and work load .Standards and laboratory protocols were followed
10
throughout the design and any discrepancies encountered were elaborated on in the discussion of
this report.
11
INTRODUCTION
This report dealt with the design, and construction of a remote PI controlled DC motor which is
implemented on a PIC16F877. This project incorporates the use of wireless communications of
the transmitter and the receiver, control algorithm of the motor implanted on the PIC16F877
chip, a photo transistor for sampling the position of the shaft to determine the speed, uses
feedback of the controller to determine the error between the set-point and the algorithm is
correct, if correct the PIC manipulates the code and takes the sample speed into consideration in
order to display the speed on the display unit.
Controlling the speed of dc motors with different loads is becoming very important for industrial
companies in Trinidad and Tobago. The technologies that exists for the speed control of a DC
motor are improving every year and field study of speed control for DC motors are becoming
more interesting and applicable to industrial sites. Engineers at universitys all over the world are
now using wireless control for Dc motors as it provides devices such as robots with FOM
(freedom of motion) which is very important in society today.
Also devices which were controlled using analog techniques are now being replaced by digital
system since they tend to offer a much more flexibility and are easier to use than the analog
systems. However for the purposes of this design project we will implement an analog
communication system which will achieve a 1m wireless control range. Depending on the type
of control used the main aim of industrial companies is to ensure that the system is able to
maintain a desired output. There are two types of control system; open loop control system and
closed loop controls such a Proportional control, Proportional-Integral Control, ProportionalIntegral-Derivative control and fuzzy logic control. The rate at which these different methods can
react to changes and precision at which they are able to maintain set point control is beyond the
scope of this project.
12
Circuit protection is necessary when designing any product. Limiting the current and thus the
dissipative power in the circuit protects circuit elements by ensuring that the power dissipated in
the circuit does not exceed the maximum power rating. At the end of this project the design must
be able to:
All the specifications for this design were not indicated, so students were allowed to
choose their own specification for the design taking the load into consideration. For design
purposes, values for determination of the PI controller was selected a 5% overshoot and 2%
setting time of two seconds and based on these values scaling was assessed. The load
specifications of the motor were not provided in this project.
13
THEORY
DC Motor Operation
require less power and they have under-damped speed characteristics which are preferred in most
industries.
There are several types of self excited DC motors which include:
i.) The Series Motor For the series motor, the flux varies directly with an increase in current
and the graph becomes less proportional. This is due mainly to magnetic saturation and current
decreases within the motor. The speed is inversely proportional to the current flowing in this
machine. Therefore, small loads are likely to cause a greater increase in the speed. This is an
undesirable effect, and care must be taken when coupling the load with the motor.
ii.) The Shunt Motor - In this motor the shunt field winding is connected in parallel with the
armature terminals to self-excite the motor. The value of I aRa when the motor is at full load, does
not exceed 5 percentage of the voltage value. The variation of speed with the input current can be
represented as constant horizontal line. For this arrangement of the motor, the flux may cause the
armature current to change by a small value. Since the speed does not vary with applied load,
this motor is most useful where the speed is required to be constant for a wide load range.
iii.) The Compound Motor- This motor is a combination of both a shunt resistor and series
resistor. At no load, the armature current is low and the magnetic motive force (mmf) is
negligible. At this point, the shunt field is fully excited and causes the motor to behave similar to
that of a shunt motor.
Importance of Control
Control systems are very important in both industrial and manufacturing environments.
Control system analysis and design are used to determine how a system is manipulated so that be
behaves in the way we want it to work. According to the control systems engineer at ISPL, a
control system is an interconnection of components connected or related in such a manner as to
command, direct, or regulate itself or another system. As defined in a book, a control system
is a device or set of devices that manage the behaviour of other devices. Surely there are many
definitions of what is a control system, all of which portray the importance of control systems in
15
industry. Some devices or systems are not controllable i.e. they cannot be controlled manually
or automatically. A Controller is used to implement a control strategy on a target system. The role
of the controller can be played by a human or a device. A system that is controlled by a human
operator is said to be under manual control. The diagram below shows a block diagram a system
to be controlled.
16
Long time ago, instead of controlling the pressure values of different substations with
computers, engineers would be on the plant controlling the valves manually. Now that all the
controls can be monitored on computers there is no need to be on the plant. In a matter of a few
minutes they can adjust the valves and have the situation under control without having to leave
the room. Such systems that is controlled by a device is said to be under Automatic control.
Taking into account the environment at the ISPL plant, control is very essential as it:
Monitor the control processes within the company premises
Control the operation of the various plants associated with ISPL
Production of the companys products can be controlled via control stations
Enhance the overall performance of the plant
Makes the workers job at the plant very simple.
Schemes can be varied to operate in the manner which is most efficient to the company
Now that control rooms are made, plant controllers control situation without leaving the
room. They could also use automatic control which is very simple to control.
17
across the armature or altering the flux can cause speed variations within the DC motor. In the
18
torque remains constant regardless of the dc motor speed (since the magnetic flux is constant)
and, therefore, the dc motor has constant torque capability over its speed range.
Advantage:
Speeds increases from zero to infinity
Used to control the speed of equipment such as cranes and trains where motor are
often switched on and off
Disadvantages:
The controller is very costly
Most of the energy which is put into the system is dissipated in the controller
Efficiency of the motor is reduced
Variation of the speed due to variation of the load which causes a change in the
potential difference across the controller which causes a change in the potential
difference across the motor. This property is not wanted in motor systems.
The third method of control is by supplying the motor with an ac supply controlled by
thyristors. This is a rectifier that is non-conducting in both the forward and reverse directions.
This device has an electrode (the gate) that causes it to be fired when a pulse of current is
introduced. A fired conductor means it conducts in the forward direction until the current falls
below a holding value.
Advantage
Fluctuation of currents can be controlled by:
1. Using two thyristors to give full wave rectification for a single phase
system
2. Using a combination of three or even six thyristors when the system is
three phase
Disadvantage: large loads cause the speed of the motor to decrease, thereby allowing
large currents to flow
The final method of speed control involves the connection of a resistor in series with the
armature, called a controller. This resistor is connected in a similar manner to a starter, however
it is designed to differ from the starter in that in can carry the armature current indefinitely
without getting dangerously hot. This controller works in the manner that the higher the resistor
value, the lower the potential across the armature and thus the lower the motor speed.
19
Advantage: The motor configuration can withstand large currents without becoming hot
Disadvantage: Resistors adversely affect the performance of the machine
Requirement Specification
The proposed design for the remote PI controlled DC motor should be able to meet the
specifications of the customer, cost management practices, quality and shell life durability and
OSHA safety protocols. The requirement specifications for the design are determined and stated
in a point format below.
The remote PI control of the DC motor using a PIC16F877 should conform to the following
requirement specifications:
Motor Specifications
Model
PC-280-20125
3.0 - 9.0 V
Nominal Voltage
6.0 V constant
No load Speed
10,000 rpm
No load Current
0.14 A
7560 rpm
0.57 A
21.08 gcm
Maximum Efficiency
48.55%
Stall Current
2.48 A
Stall Torque
117.00 gcm
20
DC - 20 MHz
8K
(14-bit words)
Data Memory (bytes)
368
256
Interrupts
14
I/O Ports
Ports A, B, C, D, E
Timers
TMR
Serial Communication
MSSP, USART
Parallel Communications
8 channel Inputs
Instruction Set
35 Instructions
Bluetooth Module - This is the other end of the Bluetooth wireless connection, it is the
module that will receive the wireless signals from the USB transmitter and send them to
the PIC16F877 chip which has the control unit. It is capable of communication via UART
(serial) communication. The control signals will be received by the receiver via the USB
Bluetooth transmitter and sent to the PIC16F877 microcontroller via TX / RX serial
communication which are pins 10 and 11 on the module.
Provide Wireless Communication range of at least 1m.
22
Must inhibit good interference Rejection This is important so that the receiver does not
detect other unwanted frequencies within its range. It must also have good sensitive
characteristic.
There
are
many
methods
which
exist
with
regards
to
the
of change of the process variable and consequently makes changes to the output variable to
accommodate unusual changes. Combined, these three kinds of actions form the classical PID
controller, which is widely used in industry. Each of the three control functions is governed by a
user-defined parameter. These parameters vary immensely from one control system to another,
and, as such, need to be adjusted to optimize the precision of control.
The other two control algorithms that exists stems out from the PID
control. PI control as PID is a very popular control algorithm. It can give close
to optimal performance for low order systems and fairly good performance
for more complicated systems, provided that the specifications are not too
demanding. PI control strategy demands that there be at least one pole at
the origin in the cascade of the controller and plant or an integrator in the
forward loop. This control algorithm can only provide perfect set point control
if the system is stable. If a stable system is achieved however there is no
guarantee that the system would inhibit a good transient response. P control
however is not as effective as the other two algorithms. This algorithm can
achieve stability of the system and help to improve the transient response of
the system. This is very important in controlling systems but engineers
discovered that system performed better when we integrated the separate
control algorithms together.
Fuzzy logic is used in many different industries for the speed control of a DC motor.
They can determine the rate at which the DC motor can spin. If the motor is spinning to fast
fuzzy logic action is taken from the manual control to adjust the speed of the motor. Therefore
the speed can be decreased to obtain the required value. If the speed of the motor is too slow
fuzzy logic action would taken and based on the value which the motor is programmed to operate
at the manually, the speed can be adjusted to compensated for the decrease in speed.
The other method of control implantation is by the use of Feed-forward or open loop
controller. Open Loop controllers control the motor input in a predetermined fashion based on
the knowledge of the system model i.e. the output has no effect on the control action. In open
24
loop control systems the output is not compared with the reference input. Thus to every reference
input there is a corresponding fixed operating condition and as a result the accuracy of the
system depends on the calibration. In the presence of disturbances, an open loop will not perform
the desired task. Open loop controls can be used in practice only if the relationship between the
input and the output is known and if there are either internal or external disturbances. These
systems are time based systems such as sequential and continuous control.
The main advantage of the closed loop over open loop control system is that for closed
loop control feedback makes the system respond accurately to systems and the fact that they
improve the overall performance of the system. However closed loop systems which implement
P, PI, PID or Fuzzy logic controls is very costly and requires more power consumption than the
open loop system. By combining the two types of controls algorithm we can achieve a good
performance of the motor at a reasonable cost. For design purposes of this project, we used PI
control to control the speed of the DC motor.
25
Proper design of any antenna system could be accounted for by maximum range, selectivity,
good interface rejection and low noise in the system.
Velocity measurement
Angular velocity sensors, or tachometers, are devices that give an output
proportional
to angular velocity. These sensors find wide application in motor-speed
control systems.
They are also used in position systems to improve their performance
(Delmar)
26
Absolute optical encoders use a glass disk marked off with a pattern of
concentric tracks with a separate light source / photo sensors pair for each
track. Hence each photo sensor contributes 1 bit to the output digital word.
The absolute encoder shown in figure 1 above outputs a 4-bit word with the
LSB coming from the outer track. To improve the resolution more track could
be added
Incremental optical encoder has only one track of equally spaced slots,
where each slot represents a known angle. The Position is determined by
counting the number of slots that pass by a photo sensor and the velocity by
measuring the time between pulses generated by the rotation of the slotted
disk.
Velocity =
Velocity data can be derived from an optical rotary encoder by counting the
amount of pulse for a set period time for example if the encoder has 8 slots
and the sample period is for 1 minute then the speed would be
N pulse / minute or N/8 revolution per minute (rpm)
The speed could also be calculated by measuring the time between pulse for
example using the same encoder above but with the time between each
pulse being 1 second
8 slot would correspond to 360/8 = 45 degree
rad / sec
4
1
Velocity =
The absolute encoder has an advantage over the incremental encoder base
on the fact that it out is a digital signal while the incremental encoder
velocity has to be calculated, absolute encoder however requires more
hardware in the form of light source and photo cell.
Another method for measuring the velocity of the motor is the use of a small
motor configured as a generator and connected by gears to the motor
velocity being measured. This method was not practical for this project as
the DC motor used was a small DC motor.
28
29
30
31
Electrical equipment should be minimally used in air conditioned room or any area where
there is condensation taking place. If electrical equipment is used in air conditioned
rooms, all equipment should be mounted to the wall or a vertical panel.
Make sure that all circuits are checked by the laboratory technician before powering up
If any form of liquid falls on electrical circuit, unplug the equipment and then make sure
to mention to the laboratory technician so that he can shut the power at the main switch
and circuit breaker off.
All switches by the work station should be readable and correctly labelled so that there
would be no misinterpretation of the use of the switches on the devices.
The medical kit present in the laboratory should be restocked on a regular basis.
The laboratory technician should ensure that all workspace provided is well kept and not
cluttered. All apparatus which are not used should be stored in an area which does not
obstruct individuals from working. Cupboard and shelves away from workstations should
be used to store this equipment.
A list of the safety standards and the laboratory protocols should be posted up in the
laboratory to make users aware of the rules conduct and safety standards.
In case of emergency students should remain calm and leave the laboratory in an orderly
fashion, to avoid collisions with persons or equipment and injuries.
According to the Occupational Safety and Health Act of Trinidad and Tobago 2004, some of
the standard laboratory protocols were not practiced in the laboratory.
32
1. Workspace area- the workspace area which was assigned to each student was 3.5 feet
from the ground and approximately 30 inches wide. According to the OSHA of Trinidad
and Tobago it is required that
The depth of the workspace should be clear to the floor and the depth should be
3ft, 3.5ft of 4ft depending on the existing conditions.2
2. Emergency exits- The emergency exit door is the same door which is used by all
individuals in and out of the laboratory on a daily basis. The door is approximately 11ft
high and is locked from the inside. OSHA standards require that
An exit door must be able to be readily opened from the inside without keys, tools,
or special knowledge. A device that locks only from the outside, such as a panic
bar, is permitted. The exit door must be free of any device or alarm, if fail could
restrict emergency use of an exit.2
3. Identification of switches in the panels The switches in the sub-panel, service panel and
other electrical equipment were not labelled properly. According to the OSHA of Trinidad
and Tobago standards require that
All switches and circuit breakers should be labelled and trace to appropriate
drawings.2
All switches and circuit breakers be allocated for easy access and permanently
marked to show disconnections.2
33
4. Fire Extinguishers-In the entire laboratory only one fire extinguisher was allocated to the
laboratory. According to the OSHA of Trinidad and Tobago standards require that
The laboratory technician shall assure that portable fire extinguishers are
subjected to an annual maintenance check. Stored pressure extinguishers do not
require an internal examination. The laboratory technician shall record the
annual maintenance date and retain this record for one year after the last entry or
the life of the shell, whichever is less. The record shall be available to the
Assistant Secretary upon request.2
(Occupational Safety and Health Act of Trinidad and Tobago, 2004 Accessed April 19th, 2009).
According to the Occupational Safety and Health Act of Trinidad and Tobago, 2004 it
is stated that an employee is any person who has entered into or works under a contract with
an employer to do any skilled, unskilled, manual, clerical or other work for hire or reward,
whether the contract is expressed or implied, oral or in writing or partly oral and partly in
writing, and includes public officers, the protective services and teachers. The employer is a
person who employs persons for the purpose of carrying out any trade, business, profession,
office, vocation or apprenticeship;
(Occupational Safety and Health Act of Trinidad and Tobago, 2004 Accessed April 19th,
2009).2
General Duties
Part II
34
1. It shall be the duty of every employer to ensure, so far as is reasonably practicable, the
safety, health and welfare at work of all his employees.
2. Without prejudice to the generality of an employers duty under subsection (1), the
matters to which that duty extends include in particular
a) the provision and maintenance of plant and systems of work that are, so far as is
reasonably practicable, safe and without risks to health;
b) the provisions of such information, instruction, training and supervision as is
necessary to ensure, so far as is reasonably practicable, the safety and health at work
of his employees;
c) the provision of adequate and suitable protective clothing or devices of an approved
standard to employees who in the course of employment are likely to be exposed to
the risk of head, eye, ear, hand or foot injury, injury from air contaminant or any
other bodily injury and the provision of adequate instructions in the use of such
protective clothing or devices;
d) so far as is reasonably practicable as regards any place of work under the
employers control, the maintenance of it in a condition that is safe and without risks
to health and the provision and maintenance of means of access to and egress from it
that are safe and without such risks;
e) provision and maintenance of a working environment for his employees that is, so far
as is reasonably practicable, safe, without risks to health, and adequate as regards
amenities and arrangements for their welfare at work;
f) arrangements for ensuring, so far as is reasonably practicable, safety and absence of
risks to health in connection with the use, handling, storage and transport of
equipment, machinery, articles and substances;
(Occupational Safety and Health Act of Trinidad and Tobago, 2004 Accessed April 19th,
2009).2
Safety Protocol is essential in every industrial work place. On industrial sites it is proper
procedure to follow Industrial safety standards and protocols. The main reason for adhering to
these protocols is to ensure that there is minimal injury of any employer or employee on the
industrial site. According to the Occupational Safety and Health Act of Trinidad and Tobago,
2004)2 a critical injury is defined as that which:
35
a)
b)
c)
d)
e)
f)
g)
produces unconsciousness ;
places a persons life at risk ;
Results in substantial loss of blood;
involves the fracture of a leg or arm, but not a finger or toe;
involves the amputation of a leg, arm, hand or foot, but not a finger or toe;
consists of burns to a major portion of the body; or
causes the loss of sight in an eye ;
The employer of every industrial company should adhere to the rules and regulations of the
OSHA Trinidad and Tobago 2004, to seek the best interest of his employer and prevent injuries
where possible. (Copeland 2009)
Code of Practice
According to the ANSI / NEMA ICS 61800-1 standards for Adjustable Speed Electrical Power
Drive Systems 2002 3 the following codes of practice for the design of the remote PI control dc
motor on the PIC 16F877 are:
1. Speed Range - The speed shall be capable of being adjusted over a range of not less than
eight to one by the armature voltage control. This speed range may be extended by the
motor field weakening to a maximum speed depending on the motor rating.
2. Over-current protection devices - the current setting of over current protection devices
shall not exceed the service limit output current rating of the Basic Drive Module.
3. Acceleration control Drives shall be provided with either current limit or timed
acceleration
4. Dynamic braking Dynamic breaking is the addition of dissipative elements to allow
faster electrical breaking of the machine. When dynamic breaking is provided:
a) The converter shall be capable of braking a load at a current of 110%, 125% or
150% of the rate current, depending on the converter rating;
b) The dynamic breaking resistor shall be capable of absorbing two times the
rotational energy of the motor at maximum speed;
c) Drive systems with large variable inertia of the driven equipment shall be capable
of breaking the maximum stored energy;
5. Dynamic Slowdown - when dynamic braking is provided, the resistors shall be capable of
absorbing the total stored rotational energy of the armature and the driven equipment
under two consecutive braking sequences from maximum to minimum speed, with the
resistor initially at ambient temperature.
36
6. Marketing the following shall be supplied on the rating plate of the Basic Driver Motor
a) The manufacturers name
b) Equipment identification (model number, serial number, and year of
manufacture).
c) Input ratings voltage; rated current; frequency; number of phases; minimum
impedance
d) Output ratings rated output voltage; rated continuous current; overload
capability; rated power;
e) Output rating field
7. Storage of Equipment the equipment shall be placed under adequate cover immediately
upon receipt if packing coverings are generally not suitable for outdoor or unprotected
storage.
8. Transportation Equipment shall be capable of transportation in the suppliers standard
package under environmental conditions specified in class 2k3 of IEC 60721-3-2.3
Risk Assessment
A risk assessment of the standard laboratory protocols was done for the microprocessor
laboratory to ensure that the laboratory adhered to safe working conditions and complied with
the practices of the Occupational Safety and Health Act of Trinidad and Tobago 2004. As define
in the dictionary a hazard is anything which can cause harm to an individual e.g. electricity, fires,
chemicals, etc. As defined in the dictionary a risk may be classified as the likelihood of any harm
occurring and the possible severity of the effects. As stated in section 5a of the Occupational
Safety and Health Act ("OSHA") of Trinidad & Tobago employers are required to
provide workplaces free of recognized safety hazards that are likely to cause
death or serious physical harm
tell you if you are working with hazardous materials
give you any special training necessary to do your job safely
keep records of all workplace injuries, deaths and any exposures to toxic or
hazardous materials2
Some of the hazard and risks that were found in the laboratory were:
37
Cluttered area around work station- This applies to any individual/s working at a work
station. Working space around electrical equipment should be adequate for conducting
all design operations safely. The work area should be cleared from all unnecessary
equipment that might be taking up space. Individuals may unconsciously forget the
presence of the machine allocated close to them or machinery not within the persons
scope of view. As a result they may come into contact with such equipment and sustain
some injury.
Laboratory equipment not kept in the appropriate location when unused- Some heavy
machinery and discarded projects were left carelessly by workstations. Individuals may
trip over exposed equipment or even become electrocuted due to high voltage flowing
through the equipment.
Insufficient workstations and laboratory space- The laboratory was found to be too
small to accommodate the total number of individuals present. This congestion creates
the possibility of people colliding with each other and with equipment.
No fire extinguisher- The laboratory under inspection was large and contained a
number of high powered computers and other electrical devices. There was no fire
extinguisher available. In the event of a fire, due to electrical calamities there should be
a number of extinguishers should be available to quickly put out the fire and reduce any
damage and injury possible.
High powered machine left exposed- Heavy machinery which is left the walking path of
individuals creates the possibility of people tripping over the equipment. This could result
in severe injury to the individual and to the equipment itself.
Absence of Safety signs- This prompts individuals to thinking that any attire can be worn
in the laboratory. However proper clothing and other attires are needed to be worn by
any individual who intend to use the lab to ensure safety.
Medical supplies were insufficient- The medical supplies in the laboratory were found to
be inappropriate in that it lacked the supplies needed to take care of medical
emergencies.
38
No equipment to detect possible hazard, alarms etc- In the event that an emergency
occurs; there are no devices to detect or warn lab users of potential danger were found.
Consider for example, in the event of a fire, a smoke detector should have been installed
to warn individuals of a possible fire.5
39
Design Brief
The project entailed the conceptual design; construction and testing/ troubleshooting of a
remote PI control DC motor using a PIC16F877 chip for implementation from discrete electronic
parts. The design was assembled and tested/ troubleshoot using basic laboratory and specification
protocols. The standards that were available to us were provided by the University of the West
Indies. They included both the NEMA 250 (Enclosures for electrical equipment (1000V
maximum)and ANSI / NEMA 61800-1 (Adjustable Speed Electrical Power Drive Systems).
The Occupational Safety and Health Authority standards 2004 were also used for safety
protocols in the design project. These standards were used to design the remote controlled DC
motor since they were most applicable due to several factors which are:
The standards complied with the requirement specifications of the design
The standards accounted for the performance level as well as the quality of the product
being designed.
The standards adhered to the operation of product in environmental conditions
The standards also accounted for the storage conditions of the designed product
The standards adhered to safety standards and laboratory protocols required to reduce
and eliminate risks associated with the design project.
The standards also emphasized the functionalities of the produce to be designed.
The Standards complied with test specifications that were used to test the design. Time
Management Practices
40
Time Duration
parameters
Design and Construction of current sensing
circuit
Design and construction of
motor
Writing of Code
increased current will increase the speed of the motor to a speed of approximately
7560 rpm which is almost the speed of the motor without the load.
Accuracy and Resolution - Accuracy relates the smallest signal to the measured
signal whereas resolution relates the smallest signal to the measured signal. The
design must be able to show values which are in close proximity to the values
calculated. Accuracy is needed so that values do not vary much from the
calculated values.
Inter-connections - Wires were cut short enough to connect all components since
connecting wires posses resistance which can affect the performance of product
being designed. Also if wires are stripped improperly we could get input floating
or even partial connections. Check the breadboard for shorts between
neighbouring tracks. If there are shorts jump wires for maximum connection. For
soldering parts try not to make bad solder joints and make sure you have
connectivity between joints. This will improve the overall performance of the
design.
practices. The must designed according to proper design standard and be constructed to
last at least a life-time under the environmental conditions indicated above. In this case it
could be marketed and meet the customers demand.
Quantity and Quality - If the design produced is successfully implemented, it may be
required that the customer may require a large quantity of the product designed. To
produce on a large scale purpose the cost of the design should be minimized without
affecting the quality of the product being designed and the time should be taken into
consideration also. The quality of the product being designed depends on a few
characteristics which include reliability, availability and maintenance.
designs.
Availability the product must be ready and available by the designer for
Target Cost Cost is a major concern with the implementation of this design project. We
want to develop the Remote PI controlled DC motor on the PIC to achieve good
performance without having to spend excess money. So the best design approach was
used and minimal hardware/ material was used, to achieve the specifications of the design
without any short comings.
44
1. We were required to use the specification sheet of the motor provided to determine the
mathematical model of the motor from the characteristic curves.
2. Measure the mass of the armature and the entire motor to find the motor capacity and
account for the load that the motor could handle.
3. Use the specification sheet for the disc to model the motor for load
4. Determine the control specifications of the model by finding both K i and K p
5. Use PWM for speed control of the motor
6. Program the PIC 16F877 to use PI control using PWM, perform motor control, and
display the change of speed on the LED displays.
7. The motor speed is measured by the phototransistor optical interrupter switch (H21A1)
and an interrupter disc.
8. Provide the design with current sensing strategies for currents exceeding 1A for the
protection of the motor.
9. Use a transmitter and receiver system which was previously built to achieve a wireless
communication range of at least 1 meter.
10. Combine the entire structure and test the design by varying the speed of the motor and
displaying the speed on the 7-segment LED displays. The motor speed is to be displayed
using 7-segment LED displays.
Project Plan
The design structure of the project requires the students of ECNG 2005 to design build
and test a remote PI controlled DC motor using a PIC16F877 chip. This design must take the
load into account and when implemented be able to drive the DC motor at a fixed speed when
different loads within the design is applied to it. The system was thoroughly analysed and the
45
based on the complexity of the design, it was broken down into smaller systems which can be
troubleshoot to examine how each part works and making the necessary adjustments to make that
section of the design work. When all systems are working, the system can be integrated into one
fully functional system. For the purpose of this design, it was essential that each section be
broken down since time management practice was poorly used. There are three major modules
and they include:
Communication Section
a. Building the transmitter
b. Building the receiver
c. Accounting for the wireless communication range of 1m
d. Communication requirements
Set Point from the computer to the Transmitter via the RS232 9pin serial
port
Transferring the square wave output from the receiver via the USART
which makes use of the Hyper-Terminal program to communicate the
signal to the PIC16F877 chip
Analogue Section
a. Motor Assembly
b. Driver Circuit
c. Current Protection of 1A
46
Controller
a. Modelling of the Motor and Controller
b. Pulse Width Modulation calculations
c. PI control Code
d. Speed sensing Code (increase or decrease in speed)
e. Display Module code
f. Programming the PIC16F877 chip
From the project plan devised before we take that into consideration, and conceptually
design the system. The block diagram below shows the conceptual design of the remote PI
controlled DC motor. By stepping through the design we see that the wireless communication
would transmit data from one point to another, which would then be sent to the PI controller
which would control the motor, which would then be sensed by the speed sensing module and
then display the speed on the Display unit.
47
The PI/ Speed control algorithm for the DC motor was required to be programmed on the
PIC16F877 chip. If we were to look at the design from a real world aspect the system would look
similar to that shown in the diagram below.
48
49
(Source: Joshi, Ajay. Introduction to Micro-Processors 1 Course Lecture notes. DECE, 2009.6 )
By following the above principles, we can evaluate the way in which we could
implement the system without over-budgeting and using unnecessary hardware equipment. The
diagram below shows how the algorithm for the speed control of the DC motor could be
implemented.
50
Programme the
error, potentiometer
Speed Control
Algorithm
No
Check the sample
time = Ts
Start the TMR1 to obtain
controller output
interrupter disc
Yes
motor
Back to TMR1
speed
And TMR2
52
J eq =J m +
b
n2
jl
2
53
1
J l= ( m r 2 )
2
Motor Torque = ka x ia
Torque is converted to SI units. To calculate for motor torque constant, the current and torque at
stall test results are used. The current Ia is found by the difference between the current values at
stall test and no load test
ka = Torque / Ia
= (117 x 10-5 x 9.81)/ (2.48 0.14)
= 0.004905 Nm/A
Theoretically, the motor torque constant is the same as the motor voltage constant in magnitude
but not in units.
From Figure 3, Kirchhoffs Voltage and Newtons Laws are coupled to give the flowing
equations
J + b = Ki
L di/dt + Ri = V K
Ka = Kb=0.004905
54
Ra = Va/ Ia
=6/2.48
=2.419
JL = x 0.04kg x 0.0242
= 1.2 x 10 -5
J T = J L / n2 + J M
JT is total inertia
JL is load inertia
JM is mass inertia
From the graph of the motor characteristics, it can be seen that maximum velocity is at 10000
rpm at 0 torque value.
Power conservation Theory states that the output power is equal to the input power minus the
losses
Input power = VT x Ia
Output power = T x w
Power losses = I2 R (due to armature resistance) + frictional and windage losses PB
Efficiency is given by the ratio of the output power to the input power
Efficiency ,n = P out / Pin
= Pout / (Pout +P losses)
Ploss = (Pout / n) - Pout
= 1.64 / 0.4855 - 1.64
=1.74 Watts
Ploss = I2R + PB
PB = Ploss I2R
= 1.74 0.572 x 2.419
= 0.95 Watts
From the torque equation, Jeq w = T - beq w
We assume that angular acceleration is zero at steady state
Therefore T = beq w
Beq = T / w
56
= 0.0002108 / 446.1
= 2.66 x 10-7
Using the information acquired form the specification sheet, the value of the moment of inertia
of the motor, Jm, can be calculated:
J m = m m rm 2
J m =(0.04)(0.00915) 2
J m = 3.35 x 10-6
kg
m2
Jeq= Jm + (1/n2)JL
When the values are substituted into the equation the following transfer function is derived:
K
166.7
s 1 1.26 s 1
TWE(s) =
The system was then inserted into MATLAB and using the rtool function the step response and
the root locus was made.
58
1
0.8
0.6
0.4
Imag Axis
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-3
-2.5
-2
-1.5
Real Axis
-1
-0.5
59
Step Response
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0.5
1.5
2.5
Time (sec)
From the graphs shown it can be deduced that the system with no controller and open loop is
only capable of getting a zero percentage of overshoot as well as 1.3 s of 2% settling time. This
is not the desired system and as such PI control methods must be inplemented in order to get the
desired parameters which are:
5% overshoot
0.2s 2% settling time
Without load conditions the motor performs optimally and can have a speed range from 0 to
9999 rpm. At this speed the motor, is 100% efficient and the power consumed by the circuit is at
a maximum. To reduce the power consumption we need to reduce the current flowing through
the circuit. The transistor driver circuit reduces the collector current, I c so that power is reduced.
With load conditions the motor initially slow down and ramps back up to a speed within the 09999 range. The maximum speed that can be achieved with load is 7560 rpm. This speed the
motor was only 75.6% efficient but was capable of handling the maximum load without any
problems. Power required by the circuit was less than the one with load. Hardware equipment
costs were taken into consideration when designing the motor as well as the code. The system
was built so that at the minimum cost practices we were able to have a good performance of the
motor. Extra hardware such a resistors and transistors was used to drive the motor in a driver
circuit. Values for the motor were taken directly from the specification sheets and the motor
model was derived using these values. As stated in the controls lab, the motor torque constant
was assumed to be equivalent to the back emf i.e. Ka = Kb.
Design Consideration
Control, Measurement and display of the measured speed
PI Control Specifications
The most common approach is to combine both proportional and
integral terms to form a PI Controller. In this algorithm it can achieve optimal
performance for low order system and for complicated systems a reasonable
good performance for more complicated systems only if the specifications
are justifiable. For this type of control strategy there should be an integrator
in the forward loop of the cascaded controller and plant as illustrated in the
diagram below. This ensures perfect regulation and set point control if the
closed loop system is stable. If the system is stable there is no assurance of
a good transient response. The basic forms of these controllers are therefore
augmented with other feedback components to facilitate improvements in
61
the quality of control. The block diagram below shows the PI control structure
of the motor with the integrator in the forward loop.
The system would be used to drive a car in one direction only. In order to get the maximum
overshoot and the desired settling time to be accurate the following controller configuration
specification must be used. The transfer function of the system can be determined by using the
closed loop gain which is given by:
TF=
G (s )
1+ H ( s ) G ( s )
( K + Ks )( J
Ka
eq
La ( s )+ ( J eq Ra + Beq La ) ( s ) + Ra Beq + K a K b
And H(s) = 1
62
Figure 10: Shows the In depth Block diagram of the PI controller with the motor
132(K i + K p s)
s +(132 K p +0.792)s+132. K i
2
Transfer function=
A n2
s2 +2 ns+ n2
Desired Specifications are overshoot peak of 5% and a 2% setting time of 0.2 s which is used to
calculate the characteristic equation:
63
cot
5% Overshoot, therefore
Cot=
M P =e
=0
.05
ln 0.05
=0.953
cos =069
A 5% settling time of 0.12 s is desired since a reasonably past response time is desired
t 2 s=
4
4
4
rad
= n=
=
=29
n
t 2 s 0.69 x 0.2
s
2
So s +40.2 s +841 isthe characteristical equation of the system
Therefore= K i =6.36
132 K p + 0.792=4 0 .2
K p=0.298
64
Recall that C ( s ) =
K i + K p s 6.36+0.298 s
=
s
s
This was placed into MATLAB and the following graphs plotted:
25
20
15
10
Imag Axis
5
0
-5
-10
-15
-20
-25
-45
-40
-35
-30
-25
-20
Real Axis
-15
-10
-5
65
Step Response
1.2
Amplitude
0.8
0.6
0.4
0.2
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
Time (sec)
From these graphs it can be seen that the settling time is within the desired range but the
overshoot is considerably above the specifications and such the proportional on error system
does not work. This is because of the zero that the PI control introduces into the transfer function
and as such cannot be modeled by the previous transfer function:
A n2
Transfer function= 2
s +2 ns+ n2
It has been decided that in order to get the desired specifications the system will have to be
incorporating the proportional on PV control. The values of Kp and Ki will be he same but the
topology used ensures that the transfer function is an all pole one making it suit the model
66
25
20
15
10
Imag Axis
5
0
-5
-10
-15
-20
-25
-40
-35
-30
-25
-20
Real Axis
-15
-10
-5
67
Step Response
1.4
1.2
Amplitude
0.8
0.6
0.4
0.2
0.05
0.1
0.15
0.2
0.25
0.3
Time (sec)
68
PORT E Port E has three pins (RE0/RD/AN5, RE1/WR/AN6, and RE2/CS/AN7) which
can be configured as I/O when the PSPMODE (TRISE<4>) bit is set. PORTE pins can be
multiplexed with analog inputs which are activated by ADCON1).
TMR0 For operation in the counter mode with an internal clock. It has a single
programmable pre-scalar mode which can be can be used to extend the range of
OPTION_REG. TMR0 interrupt is generated when the TMR0 register over-flows from
00 to FF.
TMR2 this timer has both pre-scalar and post-scalar properties and is used in
conjunction with PWM time base to give added flexibility.
A/D converter This peripheral has 8 channels and can be multiplexed with PORT A and
PORT E pins. The 10 bit digital result can be stored in the ADRESH and ADRESL
registers
PWM located on portC and has two PWM outputs. The PWM is set by the PR2 on the
TMR2 module.
USART the USART is one of two serial I/O modules located on the PIC16F877;
configured in two modes to communicate with the transmitter and receiver; use hyper
terminal for communication over the RS232 ; USART is addressable with PORTC
Capture and Compare Mode Has features such as automatic capture of the timer value
when an external input occurs and automatic switching of an external signal when the
timer value matches a pre-set value.
69
Pulse Width Modulation mode (PWM) is a frequency which is used to transmit data as well
as digital to analog conversion practices. The pulse width modulator is used to control speed of
the motor as well as the brightness of the LED display unit in this design project. Therefore it
plays an important role in this design project. The main reason for the use of PWM to control the
DC motor control is so that excessive heat dissipation in the motor in power amplifier can be
avoided. Heat dissipation in the power amplifier results in large heat sinks and forced cooling of
the motor which we want to avoid. The plant to be controlled is a small toy car base assembly,
with a motor inertial load (fan or rotating disc). This is mounted directly onto the armature shaft
so that it would rotate at the armature speed.
70
A simplified block diagram for pulse width modulation on the PIC16F877 chip is shown
above. The output from the port pins is given by a square wave. The voltage of the square wave
is given by the equation:
V =D V max + (1D ) V min=DV max
Where D=
For the PIC16F877 microprocessor, the CCPxx generates up 10- bit resolution PWM
output. The RC2 / CCP1 pin located on port C is multiplexed with port C data latch to clear the
TRISC <2> pin to make port C an output and this pin corresponds to PWM1. The RC2 /
TOCS1 / CCP2 pin is multiplexed with the port C data latch to make it an output and this pin
corresponds to PWM2. The pulse width period can be given by the equation below:
PWM period =
The PWM period can be specified by writing to the PR2 register as observed in the block
diagram above. Since the PWM period is given by this equation the PWM frequency is therefore
(1 / PWM period). PWM is associated with the TMR2 module which is as an eight bit timer with
a pre-scalar as well as a post scalar. The TMR2 module is both readable and writable and can be
cleared on any device by the use of the reset command when programmed o the PIC16F877. In
the PWM mode it is commonly used for Time base of the CCP1 and the CCP2 modules.
71
Resolution =
F osc
F pwn
lg
Given a particular PWM frequency, PWM has resolution which is given by the equation
above. Conceptually, if we want to obtain a low speed range with a large duty cycle the
frequency used will be low and the motor will thus have a reduced life cycle. However if use a
high frequency, we can acquire a high speed durability and the product life cycle is expanded
with an improved performance since the fans on the DC motor requires a high speed rate to
perform at a optimal rate. Taking this into consideration we will require a high resolution so that
72
the full 10 bits of the register is required, therefore from the PIC manual on page 62 we select the
following bits of information:
Therefore=TMR 2 prescalar =1
PR2=0 xFFh
With the use of the Registers CCP1CON 00xx1100, where xx can be either high or low,
we can set the 10 bit resolution using CCP1CON 4bit and CCPR1L 8 bit registers. The MSB of
the 10 bit resolution should be set to the duty cycle. It is important to note the CCP2CON
register will trigger an A/D bit therefore for the purpose of this design it is not used because we
do not want to trigger the A/D module. Let the PIC16F877 be powered up with a 7 Voltage
supply, therefore the maximum duty cycle:
PWM Period =
256411
=0.000025650
40000000
10231
1=0.000025575
4000000
Duty Cycle, D % =
0.000025575
x 100=99.7076
0.000025650
Therefore ,V =11.988 V
1x
1
=0.000000025
40000000
73
D=
0.000000025
x 100=0.0972665
0.000025650
Figure 17: Show the diagram of the motor with the controller used for position / speed of the motor
Originally the output from the programmed PIC and the motor would be the position of
the motor. But cannot measure the position of the motor therefore we needed to convert the
position to the speed of the motor which is achieved by the above diagram. The measurement of
the motor speed is done by measuring the rotational speed of the motor using a photo-transistor
optical interrupter switch and an interrupter disc. The photo transistor optical interrupter switch
is designed to indicate the presence or absence of voltage which has been placed in the emitter to
detector path. The interrupter disc is divided such that one half of the disc is white and the other
half of the disc is black. The disc has eight holes and eight areas of darkness. By rotating the disc
the amount of light passing through the photo-transistor also changes and this results in a change
in the current emitted by the photo-transistor. Under normal conditions, we check to see if the
hole is unblocked by taking the position signal generated and providing positive feedback with a
unity gain of one, and checking the error signal between the set point and the Variable algorithm
to see if they correspond to each other. The PIC manipulates the signal and if the signal is correct
74
the LED will light up, which causes a photo current to be developed in the circuit and the speed
of the motor would be displayed on the LED bars. If however there is a fault in the signal
transmitted, the PIC will indicate to the LED that something is incorrect, the LED would not
light causing the photo transistor switch to be turned off and no speed will be displayed on the
LED unit. This would indicate that no voltage was detected so the hole was closed. Using the
information from figure five of the data sheet, and the 5V allocated for the PIC power
If=
75
at V cc =5 V normalized R=2.5 K
Rl
V cc0.7 50.7
=
=143.333
0.03
0.03
The resistor value determined above was not available in stores. The closest value which
was 150
was selected. To determine the rotation rate of the motor, the micro-controller only
has to count the number of pulses per specific time. The disc used is divided equally into two
sections; eight unblocked holes and eight blocked holes. Therefore we would have approximately
eight pulses per revolution.
The can display speed from 0 to 9999 depending on the load of the motor and the pulse
width modulation of the motor. Under no load conditions the motor rotates at full speed and the
speed being displayed is a maximum. When a load is applied to the motor the speed is reduced
initially and then increases but not to the same speed as previously acquired. By using PWM the
speed of the motor is determined and displayed on the LED segment. The configurations for the
different numbers being displayed from MSB to LSB (RD7 to RD0) is shown in the table below.
Character
01111110
00110000
01101101
01111001
01110011
01011011
01011111
01110000
01111111
76
01110011
10000000
Table 3: Shows the values characters that could be displayed on the LED display unit
77
currents in separately excited, permanent magnet and series connected field wound
motors.
The second method for driving the motor is the use of a bipolar transistor device.
But
I c =1 A
Therefore
R b=
Ic
1
=
=10 mA
100
To find Ra
Recall that V =IR c
Therefore
R c=
V 5
= mA=510
I 10
For current cut off circuitry a 1A fuse was inserted into the circuit to test for current sensing.
Units and the Nature of Set Point
Set point control is widely used in industries to establish perfect steady
state tracking. The main problem however is that it requires that the control
system be designed so that the steady state error to step reference and step
disturbance is zero. In order to achieve perfect steady state tracking of
constant input of a system:
1.
If the "plant" has at least one integrator (i.e. at least one pole at the
origin), then the required controller should at the very least provide for
output that is proportional to the error (Proportional (P) Control) i.e. f =
Kp e(t).
2. If the "plant" has no integrator (i.e. no pole at the origin), then the
required controller should at the very least provide for output that is
proportional to the integral of the error (Integral (I) Control) e.g. f =
Kie (t)dt
79
Source: Copeland, Brian. ECNG Laboratory and Project Design III, lab 2: DC Motor Speed
and Position Control. DECE, 2009.
The Unit of the set point will be the unit of what is being imputed into
the PIC. In our design the signal which was generated from the receiver was
a square wave which outputted a peak to peak voltage. Since the unit of the
signal into the PIC16F877 was voltage the unit of set-point was Voltage, V.
80
Analog Section
Motor
The motor was assembled with great ease and when tested without the driver circuit and
the current limitation circuit the motor which spinned very fast. The driver circuit was used to
drive the motor so that it operated efficiently at the maximum speed possible. At no load speed
the motor operated within the range of 0 9999 RPM and was 100% efficient. At load speed the
motor operated within the range of 0 7560 RPM and was only 75.6 % efficient. The motor
operated within the range of 3 - 12V and could operate up to a maximum current of 2.48A.
Driver Circuit and Current Sensing
The Driver circuit was built with a transistor and some resistor and incorporated current
sensing and cu-off to drive the motor at a considerable power. They achieve a high drive power
by using a high collector current with a low forced gain. The driver circuit worked in
collaboration with the 1A fuse to provide current limitation for currents that exceeded 1A. The
fused cut-of the current at 1A and the fuse blow out making a short circuit so that current
limitation is achieved
81
Display Unit
The display unit was tested without the PIC16F877 chip in the presence of the laboratory
technician and each LED bar lighted up by testing each segment. We tested the ability of the the
LED display to display numbers. The number 5 was asked to be displayed on a single LED bar.
Also the number was multiplexed by passing the wire across the connection of pins 2-5 of the
LED.
Controls
The controls section of the code was implemented by using speed control, PI control and Display
unit code which were included in the appendix. The code was complied together and simulated
on the MPLAB IDE v7.6 and a code walk through was initiated to ensure that the code did what
it was expected to do without downloading it onto the PIC16F877 chip. The code gave some
errors and as such a fully functional system was not realised. The process of trouble-shooting and
debugging still continues.
82
DISCUSSION
The design of the remote PI controlled DC motor using a PIC16F877 was constructed by
building the individual sections of the design, testing each section and the then interfacing the
system to ensure that the system worked according to the design specifications. In order to
understand how the system works we need to thoroughly investigate the operation of the
complete system built. The system can be broken down into atransmitter and receiver, a PIC
16F877 chip which the PI control is programmed on, a DC motor, a driver circuit, load and the
phototransistor/ interrupt Disc. The transmitter circuit used in the design is able to transmit
analog signals as well as digital signals. The transmitter connected via the computer to the
USART module. Basically this the USART module is one of the two Input/output serial which is
located on the PIC chip and it is usually configured as full duplex mode or half duplex mode in
order to communicate with other devices. Taking this into consideration the transmitter is then
connected to a 9 pin RS232. The set-point data of the controller would be transmitted as the input
signal from the 9-pin RS232. Input signals into the computer may be in the form of a square,
sinusoidal wave or a triangular waveform. The computer then utilizes the USART serial
communication device with a programme known as the Hyper Terminal. By doing this the
USART does physical communication via the RS232 pin.
At the other end is the receiver obtains the output from the transmitter, filters out the
signal wanted from the unwanted signal, amplifies the signal to the desired level required and
then demodulate the signal that is desired. The receiver accepts all the different forms of analog
signals that is sent via the transmitter and outputs a square wave. This is most applicable with
digital signal. The receiver is connected to the receiving pin on the PIC16F877 chip. The output
signal will be transmitted via this connection.
Since this is an analog system the system would take in analog values and then transmit it
the controller module which would then use the analog signal. The signal is sent to the
PIC16F877 chip, which is programmed in assembly code for the speed of the motor, the PI
83
control, pulse width modulation, A/D converter system and a display unit. Using the A/D
converter algorithm will accept the signal from the receiver, and attempt to convert the signal
from analog to digital format. The analog value is stored in a capacitor and then the value is
converted to ten bits. The result is then stored in the ADRESH and the ADRESL registers which
are both 8 bits wide. Therefore 16 bits is available to store the data. The ADRESH could store
the first eight bits and the ADRESL could store the other 2 bits or either the ADRESL could store
the first eight bit and ADRESH could store the other two bits. It doesnt matter which of the
address bits store the most amount of bit but however that all the bits are stores in the registers
available. How the bits are stored in the registers can be accounted for by the ADCON0 and the
ADCON1 control bits.
The pulse width modulation technique is then used to convert the digital signal back to
analog without using an A/D converter. The PIC16F877 chip has a PWM module which is
located on port C of the chip. There are two outputs which are PWM1 and PWM2 respectively
and these correspond to the registers CCPR1L and CCPR2L respectively. The period of the
PWM is set by setting the CCPR1L register moving from the banks to set the period and then
switching back to bank zero. The CCP1CON register is used to set the duty cycle of the pulse. In
this part the PWM is achieved by outputting a square wave with a fixed frequency. We can
change the width of the pulse outputted from the PWM module by the number of pulses per
period. This leads to the voltage or duty cycle of the pulse which changes with the width of the
pulse generated.
A square wave is then sent to the motor which is controlled by the Proportional Integral
control which is implemented on the PIC16F877 micro-processor chip. The motor is driven by a
driver circuit which consist of a simple transistor and a resistor element. If the motor speed
increases the Speed Increase routine will determine the number which needs to be stored in the
CCPR1H register and set the PWM duty cycle to account for the increase in speed. If however
the motor speed decreases, the Speed decrease routine will determine the number which needs to
be stored in the CCPR1L register and set the PWM duty cycle to account for this decrease in
speed.
84
Speed of the motor cannot directly be measured at the output of the configuration.
Therefore we include a phototransistor switch and an interrupter disc into the circuit to sample
the position of the shaft in order to determine the speed of the motor. The phototransistor
operates in the presence of light, and the reference voltage is measured by the interrupter disc.
By taking the position signal generated and providing positive feedback with a unity gain of one,
and checking the error signal between the set point and the Variable algorithm to see if they
correspond to each other. The PIC manipulates the signal and if the signal is correct the LED will
light up, which causes a photo current to be developed in the circuit and the speed of the motor
would be displayed on the LED bars. If however there is a fault in the signal transmitted, the PIC
will indicate to the LED that something is incorrect, the LED would not light causing the photo
transistor switch to be turned off and no speed will be displayed on the LED unit.
The transmitter and the receiver circuit worked as expected being able to maintain a
wireless communication range of 1m and provided an output of a perfect square wave from the
receiver to the PIC16F877 chip. The signal that was sent into the transmitter module could have
been square, triangle or sinusoidal waveforms. The wave would then be modulated and amplified
when pass through the circuit. The output wave from the receiver was passed through a Schmitt
trigger to remove any noise present and generate the perfect square wave of 8V peak to peak. At
first trial in the laboratory there were some problem with both the receiver and the transmitter
circuit. The wave being observed on the screen of the oscilloscope was distorted and seemed to
contain a lot of noise. The source of this disturbance could have been due to the air condition unit
system. With the assistance of the TA Mark Lesley, the circuit was trouble shooted and the
system was tweaked until we observed what was expected on the oscilloscope. The receiver was
revised when it was found out that most of the students system didnt work. This circuit was also
trouble shoot and tweaked until the design worked as expected outputting a square wave on the
screen of the oscilloscope.
The analog section with the motor and the driving circuit also worked as expected. The
system was designed in such a way to limit the current of the circuit although the motor is being
driven at a maximum speed. There were a few considerations when designing the system. Firstly
the transistor and the resistor network must be capable of driving the motor to obtain maximum
85
performance. Secondly since the motor would be operating at high speeds, to limit the current of
the circuit when 1A is breached a 1A fuse was inserted into the circuit. Although this didnt
provide current sensing it ensured that the circuit is short circuited when 1A is reached, providing
protection of the motor. However, steps will be taken to implementing a current sensing circuit
before the practical examination.
The Display was built with the four LED in parallel with access to the same resistor pack.
The main purpose of the resistor pack was to limit the current flowing through the LED which
could only handle up to 25mA. The common cathode of the LED bar was connected to the base
of the transistor and the resistor was connected to the collector of the transistor. The reason for
this connection was due to the fact that the PIC16F877 chip could also only handle currents up to
25mA. By placing the LED bars in parallel each of them will acquire the same current and thus
smaller current will pass through the circuit. The system was tested without the PIC16F877 and
the system was checked by the technician before powering up. A diode was placed between the
positive and the negative terminal so that if any high current were to pass through it would hit the
diode before going to the PIC causing the diode to switch off. The Display worked as expected
and we were able to display numbers as well as see each segment on each LED bar light up. By
touching the wire to the cathode connected to the PIC configuration we established multiplexing.
When checked initially there was a few bad connections, which was pointed out. These were
changed before the design was tested.
The PI control, speed control, and the display code was completed and integrated
together. The code when first compiled generated numerous errors. By stepping through the
code, and rebuilding the code on every step the errors were reduced but still were preventing the
system from fully functioning. The code was successfully complied and steps through to see if
the code operated in the way it was designed to do which is where it was realised that there were
some errors in what was actually being done which then required an analysis of the algorithm for
the code. Due to time constraints the code was not downloaded onto the entire system. The code
which was complied is included in the appendix.
Time for completion of this project was inadequate. If more time was given, in
accordance to the work load of the course, we would have completely implemented the full
86
design and generate the required results that was necessary. The project turned out to be both
enjoyable and challenging and unfortunately it has not been completed as yet. Steps will be
taken to counteract all problems still proceeding with the completion of the project. From this
point my plan is to fully integrate the system and have it fully functional by the practical
examination.
87
CONCLUSION
A remote PI controlled DC motor using a PIC16F877 chip designed with current sensing
cut-off circuitry and wireless communication range of 1m was successfully built, integrated and
tested according to the requirement specifications, cost management practices, performance and
standards and safety practices. Students were able to become more competent with soldering
practices, the PIC16F877 micro-chip, the use of MATLAB 7.0.1 and MPLAB IDE v7.60 as this
would be beneficial when doing final project in year. Students were also exposed to PI control as
applied to real world applications such as the DC motor. Due to time constraints and poor time
management practices, results for the entire design were not accumulated. However, tests were
done on the separate sections to determine the extent to which they worked. The motor operated
in the range of 3-12V with a maximum current of 2.48 and when the current breached 1A the
current cut off limited the current. The display unit was tested without the PIC16F877 chip in
the presence of the laboratory technician and each LED bar lighted up by testing each segment.
The number 5 was then demonstrated and multiplexing of the LEDs was also shown. The
PIC16F877 chip was programmed with a combination PI control, speed control and display
code. Although there were many discrepancies, which lead to problems in the design,
justifications for these were discussed and steps will be taken to fix the problem so that the
system can perform as expected for the practical examination. Overall this design project was a
success and skills learnt will prove to be a great asset for future projects.
88
REFERENCES
Books and publications:
Occupational Safety and Health Act of Trinidad and Tobago, 2004. Accessed April 19th, 2009.2
ANSI / NEMA ICS 61800-1 standards for Adjustable Speed Electrical Power Drive Systems
2002 3
Canadian Centre. Occupational Health and Safety Act, 2004 standards. OSHA, Accessed 19th
April, 2009. 4
Sankar, Malissa. Risk Assessment Section of the Design and Construction of a Series Pass
Voltage Regulator project .5 DECE, 2008
Sukumar, Kamalasadan A PID Controller for Real time DC Motor Speed Control Using the
C505C Microcontroller. DECE , West Florida. Accessed 15th April 2009.
Copeland, Brian. ECNG Laboratory and Project Design III, lab 1: DC Motor Static and
Dynamic Characteristics. DECE, 2009.
Copeland, Brian. ECNG Laboratory and Project Design III, lab 2: DC Motor Speed and
Position Control. DECE, 2009.
Adams, Richelle. ECNG laboratory and Project Design III, lab 4: AM Transmitter/ Receiver.
DECE, 2009.
Microchip PIC16F87X Data Sheet, 2001, Microchip Technology Incorporated, Printed in the
U.S.A.
Websites:
http:// www.boondog.com
http:// www.fairchildsemi.com
http:// www.google.com
http:// www.howstuffworks.com
90
http:// www.everlight.com
http:// www.manntel.com
http:// www.robocup.com
http:// www.fira.net
http:// www.microchip.com.motor
http:// www.wikipedia.org
http:// www.datasheets.com
http:// www.national.com
91
APPENDIX 1
Code for the PI control, Display unit and the speed control
LIST p=16f877
INCLUDE
<p16F877.inc>
__config _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF & _LVP_OFF
speed
EQU
0x08
change
EQU
0x01
LED
EQU
0x20
spseed
EQU
0x21
delayCnt
EQU
0x22
proportional_lo
EQU
0x23
proportional_hi
EQU
0x24
integral_hi
EQU
0x27
integral_lo
EQU
0x28
integralsum_hi
EQU
0x29
integralsum_lo
EQU
0x30
volt_hi
EQU
0x31
volt_lo
EQU
0x32
Display0
EQU
0x33
Display1
EQU
0x34
Display2
EQU
0x35
Display3
EQU
0x36
Display_Act
EQU
0x37
go
EQU
0x38
divisionCount
EQU
0x39
divisor
EQU
0x40
dividend_lo
EQU
0x41
dividend_hi
EQU
0x42
RPS
EQU
0x43
spspeed
EQU
0x44
voltage
EQU
0x45
voltage_hi
EQU
0x46
voltage_lo
EQU
0x47
speederr
EQU
0x48
M1
EQU
0x49
RPO
EQU
0x50
mult_hi
EQU
0x51
mult_lo
EQU
0x52
int
EQU
0x53
init
93
ORG
0x04
;Interrupt Vector
ORG
0x20
goto
main
;======================================================
;**************** Initial Process *********************
;======================================================
init
;============================
;*** Port initialization*****
;============================
bsf
STATUS,RPO
; Change to Bank1
movlw
b'00000001'
movwf
TRISA
BANKSEL
TRISB
clrf
TRISC
bcf
;===================================
;*** A/D converter initialization***
;===================================
94
movlw
b'10000001'
movwf
ADCON0
bsf
movlw
b'00001110'
movwf
ADCON1
bcf
;====================================
;*** PWM initialization**********
;====================================
clrf
TMR2
movlw
b'11111111'
movwf
CCPR1L
bsf
movlw
d'255'
;Period=1638.4usec(610Hz)
movwf
PR2
bcf
movlw
b'00000110'
movwf
T2CON
movlw
b'00001100'
movwf
CCP1CON
95
;===========================================
;*** Compare mode initialization*********
;===========================================
clrf
TMR1H
clrf
TMR1L
movlw
h'61'
;H'61A8'=25000
movwf
CCPR2H
movlw
h'a8'
;25000*0.4usec = 10msec
movwf
CCPR2H
movlw
b'00000001'
movwf
T1CON
movlw
b'00001011'
;CCP2M=1011(Compare)
movwf
CCP2CON
;=======================================================
;*** Interruption initialzation****************************
;=======================================================
bsf
movlw
b'00000001'
;CCP2IE=Enable
movwf
PIE2
bcf
movlw
b'11000000'
;GIE=ON PEIE=ON
movwf
INTCON
wait
goto
main_loop
;Interruption wait
;===============================================================
;********** The Display unit Routine***************************
;===============================================================
main
call
cnfg_7segment
call
cnfg_pwm_usart
nop
BANKSEL
Display_Act
clrf
Display_Act
;clears Display_Act
;
=====================================================================
===============
;************Main loop test the load to allow appropriate data to PORTD**************
;
=====================================================================
===============
main_loop
BANKSEL
PORTD
movlw
B'00000000'
97
xorwf
Display_Act,W
btfsc
STATUS,Z
goto
DisplaySet0
movlw
B'00000001'
xorwf
Display_Act,W
btfsc
STATUS,Z
goto
DisplaySet1
movlw
B'00000010'
xorwf
Display_Act,W
btfsc
STATUS,Z
goto
DisplaySet2
movlw
B'00000011'
xorwf
Display_Act,W
btfsc
STATUS,Z
goto
DisplaySet3
;====================================================================
;********************end of tests to load appropriate data*********************
;******* Selection of the Port for controlling the display*********************
;====================================================================
DisplaySet0
movf
Display0,W
goto
DisplaySet1
movf
main_loopRes
Display1,W
98
goto
DisplaySet2
movf
Display2,W
goto
DisplaySet3
main_loopRes
movf
main_loopRes
Display3,W
goto
main_loopRes
;=======================================
;************ main_loop**************
;=======================================
main_loopRes
call
lookup_numbers
movwf
PORTD
BANKSEL
PORTA
movf
Display_Act,W
andlw
b'00000011'
purposes
call
lookup_DisplayUnit ;calls lookup_DisplayUnit to convert
DispActive value to an appropriate value
movwf
PORTA
call
delay5ms
movlw
B'00000011'
xorwf
Display_Act,W
btfsc
STATUS,Z
call
DisplayRes
incf
Display_Act,F
99
goto
main_loop
BANKSEL
TRISD
;selects port D
clrf
TRISD
BANKSEL
TRISA
;selects port A
clrf
TRISA
BANKSEL
Display0
clrf
Display0
clrf
Display1
clrf
Display2
clrf
Display3
cnfg_7segment
return
;
=====================================================================
==========
;*******Configuration of the Pulse width Modulation with the USART routine*****
;
=====================================================================
===========
cnfg_PWM_USART
BANKSEL
TRISC
movlw
B'10000000'
receive, RC6 as transmit and RC2 as PWM output
;selects port C
;sets pattern for RC7 as
100
movwf
TRISC
BANKSEL
CCP1CON
movlw
B'00001100'
movwf
CCP1CON
BANKSEL
PR2
B'00111111'
movwf
PR2
BANKSEL
T2CON
movlw
B'00000100'
movwf
T2CON
BANKSEL
CCPR1L
movlw
resolution with high frequency
register
clrf
CCPR1L
return
cnfg_Speed
BANKSEL
OPTION_REG
OPTION_REG
movlw
B'11100010'
;disable pullups on B, set
interrupt on rising, use external for TMR0, increment on rising, use 1:8
movwf
OPTION_REG
BANKSEL
INTCON
B'10110000'
movlw
overflow interrupt and global interrupt
101
movwf
INTCON
return
DisplayRes
movlw
0xFF
movwf
Display_Act
return
;
=====================================================================
=
;***********convert binary to BCD**************************************
divide_16by8_loop
divide_16by8_quotient
movlw
0x09
movwf
divisionCount
movf
divisor,W
subwf
dividend_hi,F
btfsc
STATUS,C
goto
divide_16by8_quotient
addwf
dividend_hi,F
bcf
STATUS,C
rlf
dividend_lo,F
102
rlf
dividend_hi,F
decfsz
divisionCount,F
goto
divide_16by8_loop
bcf
STATUS,C
rrf
exit
return ;return with quotient in dividend_lo and
remainder in dividend_hi
;===================================================================
;***************************delays used for mux & sampling**********
;===================================================================
delay1ms
BANKSEL
OPTION_REG
movlw
b'00000001'
movwf
OPTION_REG
;sets parameters
bcf
INTCON,T0IF
BANKSEL
TMR0
clrf
TMR0
BANKSEL
OPTION_REG
bcf
bcf
STATUS,RP0
delay1ms_loop
103
btfss
INTCON,T0IF
goto
delay1ms_loop
BANKSEL
OPTION_REG
bsf
bcf
STATUS,RP0
return
delay5ms
movlw
.5
movwf
delayCnt
call
delay1ms
decfsz
delayCnt,F
goto
delay5ms_loop
delay5ms_loop
return
;============================================================
;********************Lookup table for the display unit*****
;=============================================================
lookup_numbers
addwf
PCL,F
retlw
0x3F
retlw
0x06
retlw
0x5B
retlw
0x4F
retlw
0x66
retlw
0x6D
retlw
0x7D
retlw
0x07
retlw
0x7F
retlw
0x6F
addwf
PCL,F
retlw
0x0E
retlw
0x0D
;select digit 1
retlw
0x0B
;select digit 2
retlw
0x07
;select digit 3
lookup_DisplayUnit
;=======================================================
;*************** Interruption Process *****************
;========================================================
int
105
clrf
PIR2
btfsc
goto
ad_check
;No. Again
movfw
ADRESH
sublw
speed
btfsc
STATUS,C
goto
PICntrl
ad_check
;====================================================================
;PICnrtl routine functions to find the proper implementation of PI control
;====================================================================
PICntrl
movf
RPS,W
subwf spspeed,W
btfsc STATUS,C
; negative answer,carry is generated and a
decrease in speed required;positive anwser, no carry generated and an increase in speed is needed
call
SpeedDecr
call
SpeedIncr
decrease in speed
increase in speed
106
;
=====================================================================
======================================================
; The maximum voltage (Hi:lo) will have a value = speederr[2*pi*(Kp) + 2*pi*(Ki)] = 4275
where Kp = 1.038 and Ki = 12.99795
; to full 8 bit register (4275 / 255 = 16.765)
;
=====================================================================
=======================================================
Borrow
Divide_2
clrf
voltage
movlw
.16765
subwf
voltage_lo,F
btfss
STATUS,C
goto
Borrow
goto
Divide_2
movlw
0x01
subwf
voltage_hi,F
btfss
STATUS,C
goto
Borrow
incf
voltage,F
goto
Divide_2
return
;=================================================
;******** SpeedIncr Routine *****************
107
;=================================================
SpeedIncr
movf
speederr,F
call
proportional
call
integral
movf
addwf
movf
integral_hi,W
btfsc
STATUS,C
incf
integralsum_hi,F
addwf
integralsum_hi,F
movwf
volt_hi
movf
integralsum_lo,W
movwf
volt_lo
movf
proportional_lo,W
addwf
volt_lo,F
movf
proportional_hi,W
btfsc
STATUS,C
incf
volt_hi,F
RPS
volt16positive
; W = integral_hi
; integralsum_hi = integralsum_hi +
working register
; volt_lo = volt_lo + W
; W = proportional_hi
108
addwf
volt_hi,F
; volt_hi = volt_hi + W
return
;====================================================================
;******** SpeedDecr Routine *********************************************
;====================================================================
SpeedDecr
movf
spspeed,W
subwf
RPS,W
; W = RPS - spspeed.
call
proportional
call
integral
movf
integral_lo,W
subwf
integralsum_lo,W
movwf
voltage_lo
btfss
STATUS,C
decf
integralsum_hi,F
movf
integral_hi,W
subwf
integralsum_hi,W
movwf
voltage_hi
register
volt16negative
; W = integralsum_lo -
integral_lo
; W = integralsum_hi - integral_hi
109
;===========================================
;******* voltage_(hi:lo) *****
;===========================================
movf
voltage_hi,W
movwf
integralsum_hi
movf
voltage_lo,W
movwf
integralsum_lo
;====================================================================
; *subtraction of the 16-bit number in proportional_hi and proportional_lo, from the 16-bit
number in voltage_lo and voltage_hi****************
; *store result in volt_lo and volt_hi*************************************************
;====================================================================
movf proportional_lo,W
subwf voltage_lo,W
movwf
volt_lo
btfss
STATUS,C
decf
voltage_hi,F
movf
proportional_hi,W
subwf
voltage_hi,W
; W = voltage_lo - proportional_lo
; W = voltage_hi - proportional_hi
110
movwf
volt_hi
return
;====================================================================
;********* Scaling proportional error term***************************
;====================================================================
proportional
movlw
b'10001000'
; use 648 because 2*pi*(Kp=1.0308)
= 6.48, so multiply by 648, which is the term scaled up by 100
movwf
M1
clrf
proportional_hi
clrf
proportional_lo
clrw
Mu8x8
addwf
speederr,W
btfsc
STATUS,C
; if carry set
incf
proportional_hi,F
decfsz
M1,F
goto
Mu8x8
movwf
proportional_lo
return
;===========================================================
111
mult_lo
movlw
b'00000011'
movwf
mult_hi
clrf
integral_hi
clrf
integral_lo
clrw
Loop
call
Add16bit
decfsz
speederr,F
goto
Loop
nop
nop
return
Add16bit
movf
mult_lo,W
addwf
integral_lo,F
movf
mult_hi,W
btfsc
STATUS,C
incfsz
addwf
return
;====================================================================
;************ The PWM routine **********************************************
;====================================================================
PWM
BANKSEL
PR2
movlw
0xFF
movwf
PR2
BANKSEL
T2CON
movlw
b'00000110'
movwf
T2CON
movf
voltage,W
movwf
CCPR1L
return
END
113
Nichibo DC Motor
114
115
116
117
118
119
120
121
122