SlideShare ist ein Scribd-Unternehmen logo
1 von 62
MECHATRONICS
Theoretical and Practical Mechatronic Investigations
A10938
1
Contents
Introduction…………………………………………………………………………………p2
Part 1
Fixed Speed Bi-directional Control of a 12V DC Motor…………………………………….p4
Part 2
Speed Control of Electric Motors…………………………………………………………...p17
Part 3
Investigation of PWM Control of DC Motor (Pulse Width Modulation)…………………..p30
Part 4
Mechatronics and Embedded Systems (2 Problems)……………………………………….p36
Part 5
Mechatronics Case Studies (Neoprene tube cutting system)……………………………….p42
Conclusion………………………………………………………………………………….p51
Appendices
Appendix 1………………………………………………………………………………….p52
Appendix 2………………………………………………………………………………….p55
Appendix 3………………………………………………………………………………….p59
References………………………………………………………………………………….p60
2
Introduction
Mechatronics is a fusion of mechanical, electronic, electrical and computer engineering to
create a more efficient, cost effective, and simplified system. Mechatronics was first
conceived in 1969 by Tetsuro Mori from Japan and is today a major part of engineering used
throughout industry. Originally mechatronics was conceived with just mechanical and
electronic engineering in mind, however with the development of computers and
microcontrollers the field grew to combine more systems together. Nowadays mechatronics is
vital as it has many applications that are used in varying sectors within industry.
“Mechatronics combines electronics engineering and computer technology within multi-
disciplinary applications pertaining to the control of mechanical systems and processes.
These systems might include complex mechanisms, dynamical elements, thermal and
chemical processes, flexible manufacturing operations or any combination of these. This
invariably means that mechatronics is very diverse in its applications.”
(Fraser et al, 1994, p2)
As various sectors needed mechatronics for problems with processes, these sectors became
interlinked and created simplified systems to solve the problems. One of the best examples is
within the automotive industry, as there are robots working on the production line to aid with
efficiency and these were created by mechanical means but controlled by electronic systems.
Below is a picture of a graphical representation of the integration of some of the various
sectors and sub-systems that is within mechatronics.
Graphical Representation of Mechatronics
(The Ron Dearing UTC Limited, 2015, accessed 2016)
3
As we can see from the picture on the previous page how mechatronics inter links the various
sectors and sub-systems within engineering. It also represents how important each sub-system
is to each other and how the synergistic nature of mechatronics is beneficial to each sub-
system to create a better overall system.
“A mechatronic system is not just a marriage of electrical and mechanical systems and is
more than just a control system; it is a complete integration of all of them.”
(Bolton, 2003, p1)
For this report I was tasked with the investigation of various aspects of mechatronics mainly
about control of a d.c. motor. Throughout the semester I built and tested various systems to
overcome the problems presented to me in the lab and recorded the results to analyse the data
collected to confirm the circuit was working as expected. These problems involved building
systems incorporating programmable logic controllers as well as PIC microcontrollers
namely a PIC16F84 microcontroller and pulse width modulation for the control sub-systems.
I also had to investigate two mechatronic problems where I had to devise concepts of systems
to find solutions so the systems would operate correctly.
This report has been created to document the various stages of my investigations and were
carried out by either practically building the circuits in the lab or conceptually in the form of
mini reports.
4
Part 1
Fixed Speed Bi-directional Control of a 12V D.C. Motor
Throughout industry many systems require bi-directional motor control and it is used in
pumps, compressors, fans, wheels etc. For this part of my investigations I was tasked with
creating a similar system. Using 2 LJ Trainer units I had to configure a system to control a
small 12V d.c. motor at a fixed speed in both clockwise and anti-clockwise directions. The LJ
Trainer I used, was the DIGIAC 1750 unit as seen in the picture below.
The LJ Trainer Digiac 1750 Unit
(LJ Create, 2007, accessed 2016)
The DIGIAC 1750 unit is an excellent bit of kit and can be used to build various systems for
experiment purposes. Within the unit is input sensors, output actuators, display devices and
signal conditioning circuits. It also has various power supplies, light sources and compressed
air supplies to experiment with. Also with the unit, it is possible to build and test closed loop
systems for rotary speed and position.
For my investigations the system needed to be controlled by first a Programmable Logic
Controller(PLC) and then a PIC16F84 Microcontroller. First I drew up the block diagram for
the system which can be seen on the next page.
5
Part 1 Overall System Block Diagram
From the block diagram I needed to then devise a schematic diagram for the system as shown
in the picture below.
Detailed Circuit Schematic Diagram
From the schematic, when a PLC or PIC16F84 transmits a signal at the base of either NPN
transistors via terminals A or B, the transistor becomes closed circuit and this means 0V is
connected to the bottom of the relay via the collector. As the relay has 12V permanently
connected to the top of the relay, this will create a path to earth through the load in the coil
and this then pulls the switch towards the normally open contact. Therefore, when one of the
relays has a contact normally closed and the other one has a contact normally open, the motor
should run in one direction. The diodes in the schematic are there to aid with the reduction of
back EMF on the relay. The relay layout and circuit schematic diagram from the 1750 unit
can be seen in the pictures on the next page.
6
1750 Unit Relay Layout
(LJ Create, 2007, accessed 2016)
1750 Unit Relay Circuit Schematic Diagram
(LJ Create, 2007, accessed 2016)
The d.c. motor I used was the same as one that was in the 1750 unit and below is a picture of
the d.c motor layout.
1750 Unit D.C. Motor Layout
(LJ Create, 2007, accessed 2016)
With the d.c. motor in the 1750 unit, current is supplied to the coils via brushes and
commutator and this causes forces to be exerted on the rotor which makes it spin. Also as
seen in the schematic diagram on the next page, motor current passes through R45 and
creates a voltage across it which is proportional to the torque loading.
7
1750 Unit D.C. Motor Circuit Schematic Diagram
(LJ Create, 2007, accessed 2016)
Usually with normal d.c motors, their rotation is determined by the applied voltage and
polarity of such voltage. Also their speed is determined by the current that flows through the
windings.
“A d.c motor has two terminals, and when d.c. flows in one terminal (the other being
grounded), the motor spins in one direction. When current flows in the other terminal (and
the first is grounded), the motor spins in the opposite direction. That is, by switching the
polarity of the terminals, the direction of the motor is reversed. The motor’s speed is
controlled by varying the current supplied.”
(Onwubolu, 2005, p320)
Next I had to derive a truth table for the desired operation of the circuit and this can be seen
in the picture below.
Circuit Truth Table
A B Motor
0 0 OFF
0 1 ON (Clockwise)
1 0 ON (Anti-Clockwise)
1 1 OFF
After completing the truth table, it became apparent that it was identical to the truth table for
an XOR Gate. This can be seen in the picture on the next page.
8
XOR Truth Table
(Electronics Hub, 2015, accessed 2016)
The truth table above as well as on the previous page shows that there will only be an output
when only 1 input is at logic 1 and the other input is at logic 0. This can also be expressed by
the Boolean equation;
As I mentioned earlier the system was to be first controlled by a PLC. A Programmable
Logic Controller or PLC is a digital computer that has multiple inputs and outputs. A PLC is
used for the automation of various electromechanical processes within industry. They are
designed to withstand varying temperature ranges, electrical noise, moister, vibration and
impact. Because of these factors, PLCs are extremely reliable and therefore used substantially
around the world.
“Programmable logic controllers (PLCs) have been an integral part of factory automation and
industrial process control for decades. PLCs control a wide array of applications from simple
lighting functions to environmental systems to chemical processing plants.”
(Wright, 2010, accessed 2016)
PLCs were first introduced in the late 1960s by inventor Richard Morley to supply systems
with the same functions as relay logic systems because relay systems at the time tended to
fail. This created delays and PLCs were implemented into industry to replace the relay logic
circuits which were unreliable and took too long to re-wire if a company chose to change
their production process.
PLCs analyse the inputs and control the outputs depending on what the PLC is programmed
to do. Therefore, the inputs are scanned and the outputs are operated in relation to the
information programmed into the PLC. Programs to control machine operation are typically
stored in battery-backed-up or non-volatile memory. PLCs are easy to program and don’t
need any special training. Once a code is programmed into the PLC, the machine would work
autonomously, therefore removing people from doing boring repetitive work like on a factory
line. PLCs can also make calculations quickly and as a result it speeded up certain processes,
increasing efficiency.
The PLC I used in my investigations was a Mitsubishi F1 and on the next page is a photo of
the PLC I used.
9
Mitsubishi F1 PLC
The Mitsibushi F1 PLC has various inputs. outputs, timers and counters as outlined below;
Inputs 400  413
Outputs 430  Typically 437
Timers 50  57
Counters 60  67
The outputs I used in my investigations were 430 and 431 and below is a picture of the
desired PLC output I was trying to achieve.
Desired PLC Output
Next I had to devise a ladder logic to create the program that was to be entered into the PLC
for the system to operate correctly. For this to work I first investigated the ladder logic for a
one shot timer and this can be seen in the picture below.
One Shot Timer Ladder Logic
From the ladder logic above, I could then derive the code that would be inputted into the PLC
and can be seen in the picture on the next page.
10
One Shot Timer PLC Programming Code
However, as this is not sufficient for the system I was investigating, I needed to try and
expand on the idea of a one shot timer. Therefore, by overlapping 2 one shot timers, this
would give us the correct code to program the PLC for the system to operate correctly. Below
is a picture of the output I was aiming for.
Two Overlapping One Shot Timers Output
From all the information I have gathered so far I could derive a ladder logic for the circuit
which can be seen in the picture below.
Final System Ladder Logic
11
From the ladder logic on the previous page I could then derive the code that would be
inputted into the PLC and this can be seen in the picture below.
Final PLC Programming Code
I then tested this programming code by inputting it into the PLC whilst it was not connected
to the LJ Trainer/d.c. motor circuit and ran the program. Whilst it was running I could
observe that the output LEDs for 430 & 431 outputs were switching on and off at the correct
intervals. I then connected the PLC to the LJ Trainers and d.c. motor which can be seen in the
photos below as well as on the next page.
Part 1 PLC and DC Motor
12
Part 1 DIGIAC 1750 LJ Trainer Unit
Part 1 PLC Overall System
I then ran the program and when doing this I observed the motor reacting the way I wanted it
to. First there was a delay of 5 seconds and then the motor spun in a clockwise direction for 5
seconds. Next the motor stopped for 5 seconds before it spun anti-clockwise for 5 seconds
and then finally the motor stopped.
13
Next the system had to be controlled by a PIC Microcontroller. Microcontrollers are a single
integrated circuit which has a CPU, memory and input/output interfaces within it. It is like a
microcomputer system in one small chip. It is suitable for various applications because of
versatile input/output capabilities and with it being a single integrated circuit the power
requirements are low for a system. A microcontroller is an excellent bit of kit as you can
connect it to a PC via a development board to program it with C programming language and
reprogram it with little effort other than altering some code.
"The great thing about a microcontroller is that you can simply alter a few lines of code or
reprogram it completely to change what it does; you don't need to swap out wires, resistors
and other components in order to get this flexible IC to take on a new personality"
(Ross et al, 2010, p161).
The microcontroller I used was the PIC16F84 which is manufactured by Microchip Corp and
is a very basic, widely used microcontroller. Another good reason to focus on the PIC16F84
is that many other PIC microcontrollers are upward and pin compatible with the PIC16F84 so
everything learned can be applied to other PIC microcontrollers. The PIC16F84 comes in an
18 pin direct in line package and it has a CPU, bi-directional I/O ports, data memory,
program memory and timer/counters. Below is a picture of the pin layout diagram of the
PIC16F84.
PIC16F84 Pin Layout Diagram
(Microchip Technology Incorporated, 2005, accessed 2016)
The PIC16F84 incorporates Harvard architecture rather than Von-Neuman, so it uses separate
buses for data and program memory which allows simultaneous access to both memories and
increases speed within the microcontroller.
“It uses the Harvard architecture since its program memory and data memory are accessed
from different memories. This offers an improvement over the von Neumann
architecture in which the program and data are accessed simultaneously
from the same memory (accessed over the same bus).”
(Onwubolu, 2005, p210)
When designing a system to be controlled by a micro controller it is good practice to create a
flow chart of how you want the system to operate and the flow chart helps when compiling
the code. A picture of my flow chart for the system in part 1 can be seen on the next page.
14
Part 1 System Flow Chart
As seen in my flow chart, first I needed to set up the registers and I/O ports so that the
controller knows which ports are designated inputs and outputs. Then I needed to set the
system to switch the motor on clockwise for a set time and then switch the motor off for a set
time delay. Next I had to set the system to make the motor spin anti-clockwise for a set time
before switching the motor off for a set time delay and then the whole process would repeat
again. To create a delay on the PIC16F84 I had to create loops for the program to run through
until it is called to carry out another task. Each operation on the PIC takes 20 microseconds
so these loops are made up of hundreds or thousands of single operations to create a delay of
only a few seconds. When I was happy with the flow chart so that the system would operate
correctly, I could begin with compiling the code that was required.
An assembly language program is a text file which has a specific format and each instruction
is represented by a line of code, which is divided into 4 fields. These are called label,
operation, operand and comment fields. The label field is optional and the operation field is
an instruction which is represented by a mnemonic code. The operand field may or may not
be needed as this depends on the instruction and the comment field is optional, however it is
good programming practice to include comments. All fields must be separated by at least one
space which is called a separator and all comments must be proceeded by a semi-colon which
nulls the comment from the line of code.
First I was given a code for a basic traffic light system that I could adapt to make the motor
spin clockwise and then anti-clockwise. My final code can be seen in Appendix 1.
15
As we can see from the code in Appendix 1, before compiling the main program I mentioned
which PIC I am using as well as a title and a brief description of the process I am trying to
achieve.
Then as mentioned earlier in my flow chart, first I wrote code to set up the registers and I/O
ports. As we can see there were 3 file registers allocated for STATUS, PORTA and TRISA.
There were also 3 general purpose registers for R0, R1 and R2 which are used to create the
delays in the code. RPO is allocated for bit 5 of STATUS and Count 1 & 2 have been defined
to create the outer delay of a value of 133 as well as an inner delay of a value of 250.
Within the main code I only used operation, operand and comment fields as I discarded the
label field, because this field was not needed. At the beginning of the main code I initialized
PORTA as all outputs. Then as I was trying to replicate the same function as an XOR logic
gate and was only using the first 2 bits of an 8-bit binary code, I stated the initial starting
point be a binary input of 00000000. This would replicate the bit pattern for terminals A=0
and B=0. Next I would output this binary input to the motor via PORTA and this would be
the starting point of the process and the motor would be off. I then created a delay of 2
seconds so that the motor would remain off for the duration of the delay.
Next there was a binary input of 00000001. This would replicate the bit pattern for terminals
A=0 and B=1, which would be outputted to the motor via PORTA and this would start the
motor rotating in a clockwise direction. Once again I created a delay of 2 seconds so that the
motor would rotate clockwise for the duration of the delay.
Then there was a binary input of 00000011. This would replicate the bit pattern for terminals
A=1 and B=1, which would be outputted to the motor via PORTA and this would stop the
motor rotating. As the same as before I created a delay of 2 seconds so that the motor would
remain off for the duration of the delay.
Next there was a binary input of 00000010. This would replicate the bit pattern for terminals
A=1 and B=0, which would be outputted to the motor via PORTA and this would start the
motor rotating in an anti-clockwise direction. Just as before I then created a delay of 2
seconds so that the motor would rotate clockwise for the duration of the delay. Then the
program would go to the beginning of the code, therefore repeating the whole process and
would keep on doing this while power was supplied or until the program was overwritten.
Finally, the delay subroutine needed to be defined so that the system operated correctly where
the value passed to the routine in the working register is a time delay multiplied by 0.1
seconds. So the value for the working register would be allocated into R0 and would be a
value of 10 per, a second delay. Therefore, for a 2 second delay this figure would be 20 (20 x
0.1) and as we can see from my code the value for each delay I inputted was 20. Next the
inner and outer delays needed to be placed in R1 & R2 and these along with R0 would
decrement the delays repeatedly until it reaches zero. Then the code returns back to the main
program.
After I had compiled the code in notepad I could transfer it to MPLAB and this created an
hex.file which was then entered into PPP. Next I made sure the watchdog timer was disabled
and the correct clock configuration was applied. I then uploaded the PPP code onto the
PIC16F84 from a PC via a development board. The development board can be seen in the
photo on the next page.
16
PIC Development Board
After I had transferred the code to the PIC16F84 and applied some power I observed the
motor initially did not rotate for 2 seconds then it spun in a clockwise direction for 2 seconds.
Next it stopped rotating for 2 seconds before it rotated in an anti-clockwise direction for 2
seconds. Then the motor stopped rotating for 2 seconds before repeating the whole process
again and would keep repeating the whole process as long as there was power supplied.
Below is a photo of the PIC16F84 overall system.
Part 1 PIC16F84 Overall System
This system was quite easy to construct and I was able to complete my investigations
successfully. With both the PLC and PIC16F84, the motor reacted the way I was expecting.
This proved that the PLC and PIC were programmed correctly as well as the overall system
was correctly configured. Also the development board is a good bit of kit when testing the
code that was uploaded onto the PIC16F84.
17
Part 2
Speed Control of Electric Motors
For this part of my investigations I was tasked with investigating variable speed control of a
bipolar d.c. motor and many mechatronic systems require specific motor velocity profiles.
One that is particularly widely used is the trapezoidal velocity profile as seen in the picture
below.
Trapezoidal Velocity Profile
From this profile we can see that the motor accelerates or ramps up to its maximum speed
rotating clockwise before holding that speed for a set amount of time. It then decelerates or
ramps back down to zero, before accelerating in an anti-clockwise rotation to its maximum
speed, holding that speed for a set amount of time and then it decelerates back to zero speed.
As I mentioned in part 1 the speed of a d.c. motor is proportional to the applied voltage.
Therefore, the motor needs a trapezoidal velocity profile and this can be created using a PIC
microcontroller with a digital to analogue converter (DAC). With electronic systems like the
one I was investigating, the information needs to be converted between analogue and digital
states and to do this, analogue to digital converters (ADC) and digital to analogue converters
(DAC) are used.
“Circuitry is, therefore, required that is able to interface between the
analogue world outside the system and the digital system itself. The two interface circuits that
are necessary are the ADC and the DAC.”
(Green, 1999, p329).
With a PIC-DAC combination, the acceleration stage (ramp up) can be achieved using a PIC
to output a continuously increasing binary number to the DAC which then converts such
binary numbers into an analogue voltage to power the motor. The process for deceleration is
the same, however the PIC will output a continuously decreasing binary number to the DAC.
18
A key aspect of the trapezoidal velocity profile is bi-directional motion (clockwise and anti-
clockwise) and speed. Therefore, the PIC-DAC combination must be capable of both positive
and negative voltages to the motor. The DAC I used in my investigations is the DAC0800
and this was chosen because it has a feature that facilitates this. Below is a picture of the pin
layout diagram of the DAC0800.
DAC0800 Pin Layout Diagram
(Texas Instruments Incorporated, 2013, accessed 2016)
This DAC is based around an R-2R resistor ladder and the output is dependent on the binary
input on each input switch.
DAC0800 R2R Ladder Block Diagram
(Texas Instruments Incorporated, 2013, accessed 2016)
19
Next I devised the ideal operating circuit for the DAC0800 and this can be seen below.
DAC0800 Ideal Operating Circuit
As we can see in the picture above, the output of the DAC0800 comprises of two analogue
currents, Iout (pin4) and /Iout (pin2) and the range of values for these two currents is
determined by the value of the reference current (IRef) into pin 14. This is set by the resistor
R14 and the supply voltage. The output at Iout is proportional to the value of the byte (8 bit-
word) of information provided at the binary inputs. Therefore, this can be calculated with the
equation seen below.
/Iout = IRef – Iout
As I mentioned earlier the DAC0800 uses an R-2R ladder circuit to give an output current
Iout which is a fraction of IRef and that is determined by the binary input value.
Iout = IRef x n/256
/Iout = IRef – Iout
Therefore, Iout + /Iout is always equal to IRef and as the binary input increases from zero,
Iout increases from zero and /Iout decreases from IRef. So for example when the binary input
is zero, Iout = 0 and /Iout is equal to IRef. Then if the binary input is 255, Iout is equal to
IRef and /Iout = 0.
20
As mentioned earlier a bipolar output voltage is needed and this is achieved by using an op-
amp which has both of the DAC inputs, Iout (pin4) and /Iout (pin2) as its inputs. The op-amp
I used in my investigations was the 741 op-amp. Below is a picture of the pin layout diagram
and typical application for the 741 op-amp.
741 Op-amp Pin Layout Diagram
(Texas Instruments Incorporated, 2015, Accessed 2016)
Typical Application for a 741 Op-amp
(Texas Instruments Incorporated, 2015, Accessed 2016)
The 741 Op-amp is a differential amplifier with a very high input impedance and low output
impedance therefore no current flows in the input terminals. It has an extremely high gain
which would cause the chip to saturate without any control over this gain. The gain of a 741
Op-amp is controlled by using external components which are an input resistor and a
feedback resistor. The ratio between these resistances set the gain just like a voltage divider
circuit. Also the point where the input and feedback resistors meet is known as a virtual earth
and can be thought of as 0 Volts.
“The operational amplifier is a high gain d.c. amplifier, the gain typically being of the order
of 100 000 or more, that is supplied as an integrated circuit on a silicon chip. It has two
inputs, known as the inverting input (-) and the non-inverting input (+). The output depends
on the connections made to these inputs.”
(Bolton, 2003, p58)
The 741 Op-amp is widely used and even though faster more precise Op-amps are available,
it is still the most popular due to its ease of use and wide variety of applications.
On the next page is a block diagram of the overall system which incorporates the PIC-DAC
combination connected to a 741 op-amp, which is then connected to a DIGIAC 1750 unit for
an amplifier, power amplifier and DC motor.
21
Part 2 Overall System Block Diagram
From the block diagram I needed to then devise a circuit wiring diagram for the system as
shown in the picture below.
Final Circuit Wiring Diagram
From the picture above, by using an op-amp which has both of the DAC outputs, Iout (pin4)
and /Iout (pin2) as its inputs allows the circuit to achieve a bipolar output voltage.
Therefore, with an input of;
000000002 (010) then I1 = Iout = 0
and
I2 = /Iout = IRef
Then at the op-amp;
V+ = -IRef x R Volts
V- = -IRef x R Volts
Therefore;
Vo = -IRef x R
22
Also with an input of;
100000002 (12810) then I1 = Iout = ½ IRef
and
I2 = /Iout = ½ IRef
Then at the op-amp;
V+ = - ½ IRef x R Volts
V- = - ½ IRef x R Volts
So;
Vo = V- + (I1 x R)
= - ½ IRef x R + ½ IRef x R
Hence;
Vo = 0V
Finally, with an input of;
111111112 (25510) then I1 = Iout = IRef
and
I2 = /Iout = 0
Then at the op-amp;
V+ = 0V
V- = 0V
Hence;
Vo = +IREF x R
Thus, the circuit has a symmetrical bipolar output voltage range as required for the motor
drive for the system I was trying to create as seen in the table below.
Symmetrical Bipolar Output Voltage Range Table
Binary Input Output (V)
00000000 - IRef x R
10000000 0
11111111 +IRef x R
From the table above we can calculate what binary inputs are needed for clockwise and anti-
clockwise rotation of the d.c. motor. For zero speed the PIC should output the binary number
10000000 to the DAC. To achieve clockwise rotation, the PIC should output a binary number
greater than 10000000 and to achieve an anti-clockwise rotation, the PIC should output a
binary number less than 10000000.
23
Next I had to calculate the circuit resistance values for Rref. So from the DAC data sheet and
assuming a VCC of 5V, Iout is proportional to the binary input.
Hence,
Iout maximum = VRef/Rref
with a maximum value of,
IRef = 2mA
Although a convenient figure for IRef is 0.5mA so using,
Vcc/Rref = IRef
Then using Ohms law to transpose it to,
Vcc/ IRef = Rref
5V/0.5mA = 10KΩ
RRef = 10KΩ
As we can see from the above calculations and in my final circuit wiring diagram I used
10KΩ resistors for RRef on pins 14 and 15 on the DAC.
Then I had to calculate the circuit resistance values for R, which are the input and feedback
resistors for the 741 Op-amp. From previous analyses, the output range is,
A convenient voltage range, for the motor we are using before it is amplified is around,
So when using IRef = 0.5mA this gives,
R = 5KΩ
However, I could not use a 5KΩ resistor as I did not have one and neither did the store room
in college so I used the nearest preferred value which was 4.7KΩ. As we can see from the
above calculations and in my final circuit wiring diagram I used 4.7KΩ resistors for R, for
the input and feedback resistors on the 741 Op-amp. Therefore, for the circuit I was
investigating the output voltage from the 741 Op-amp would be,
Vout(+) = 0.5mA x 4.7KΩ = + 2.35V
Vout(-) = 0.5mA x 4.7KΩ = - 2.35V
For the purposes of my investigations and with the 741 Op-amp output being only + or –
2.35V, this voltage needed to be amplified. Therefore, I connected the output of the 741 Op-
amp to an amplifier on the 1750 unit. On the next page is a schematic diagram for the
amplifier in the 1750 unit.
24
1750 Unit Amplifier Schematic Diagram
(LJ Create, 2007, accessed 2016)
This is an amplifier with a fully variable gain from 0.1 to 100 and an offset from -5V to +5V.
IC12a is a unity gain inverter, with offset control and its output feeds the fine gain control.
The gain is selected by S6, which switches in various combinations of feedback resisters. To
avoid the need for excessively high values, the feedback is taken from the junction of R113
and R114. These attenuate the output signal by a factor of 100 and thus allows the same
reduction in the feedback resisters. For my investigations the gain on this amplifier was set to
5 as this would amplify the 741 Op-amp output voltage to + or – 11.75V which is more of a
suitable output voltage range for the motors to operate correctly for my investigations.
At the output of the amplifier on the 1750 unit, there is a power amplifier connected and this
is there to increase the amperes at the 741 op-amps output. Below is a schematic diagram for
it.
1750 Unit Power Amplifier Schematic Diagram
(LJ Create, 2007, accessed 2016)
The IC11 is a power op-amp and is configured as a unity gain buffer and will provide a gain
of 1. This is important as there is very little current been drawn into the circuit because the
741 Op-amp has a high impedance and the amplifier will not affect the original circuit.
Therefore, it provides the same voltage at the output that was inputted into the circuit, thus
protecting the signal.
“This is the reason unity gain buffers are used. They draw very little current, not disturbing
the original circuit, and give the same voltage signal as output. They act as isolation buffers,
isolating a circuit so that the power of a circuit is disturbed very little.”
(Learn About Electronics, 2015, accessed 2016)
25
For this part of my investigations I was tasked with creating a system to control a d.c. motor
where there is acceleration to maximum speed in a clockwise direction and after a time span
of continuous speed, deceleration to zero speed. Then acceleration to maximum speed in an
anti-clockwise direction and after a time span of continuous speed, deceleration to zero
speed. At the start of this chapter, I mentioned for speed control of a d.c. motor the
trapezoidal velocity profile is used and below is a picture of the ideal profile required for my
system to operate correctly.
Ideal System Trapezoidal Velocity Profile
From the picture above we can see the different stages of the profile with reference to the
binary inputs. Zero speed is achieved with a binary input of 10000000 (128) and for the
motor to accelerate to maximum speed the output needs to be incremented up 100 steps to a
binary input of 11100100 (228). For 100 steps in 2 seconds, for the motor to ramp up to
maximum speed, the time delay between each steps is 20msecs and this is calculated by
dividing 2 seconds by 100 steps. Then the motor should hold the maximum speed for 5
seconds before decelerating back to zero and then accelerating to maximum speed in an
anticlockwise direction. The maximum anti-clockwise speed is achieved by decrementing the
output down 200 steps from the binary input 11100100 (228) to a binary input of 00011100
(28). Next the motor should hold this maximum anti-clockwise speed for 5 seconds before
decelerating back to zero speed and to achieve this the output would be incremented 100
steps up from 00011100 (28) back up to 10000000 (128). The overall time for the motor to
react to these instructions should be 18 seconds.
Once again I created a flow chart of how I wanted the system to operate. A picture of my
flow chart for how I want the system to operate in part 2 can be seen on the next page.
26
Part 2 System Flow Chart
As seen in my flow chart, for my system I needed to first set up the registers and I/O ports so
that the controller knows which ports are designated inputs and outputs. Then I needed to set
the system with an initial binary output of 10000000. This is the motors zero speed which is
the starting point of my code and this would delay the motor from rotating for a period of 5
seconds. After that I wanted to increment the drive(R3) up 100 steps from 10000000 to
11100100 and this would accelerate the motor to the required maximum speed in a clockwise
direction. Next the system would check if the maximum speed was achieved. If it had not, it
would repeat the previous stage and if the maximum speed was reached, it would rotate in a
clockwise direction for 5 seconds. After 5 seconds the drive(R3) would decrement 200 steps
from 11100100 to 00011100 back to zero speed and then accelerate into reverse or an
anticlockwise direction before checking if the reverse maximum speed had been achieved. If
it had not, it would repeat the previous stage and if the maximum speed was reached it would
rotate in an anti-clockwise direction for 5 seconds. Finally, the drive(R3) would be
incremented up 100 steps from 00011100 to 10000000 back to zero speed and if zero speed
had not been achieved the previous stage would be repeated. If zero speed had been achieved
the motor would not rotate in any direction for a period of 5 seconds and then the whole
process would repeat from the beginning again. When I was happy with the flow chart so that
the system would operate correctly, I could begin with compiling the code that was required.
First I was given part of a code that I could adapt and my final code can be seen in Appendix
2.
27
As we can see from the code in Appendix 2, before compiling the main program I mentioned
which PIC I am using as well as a title and a brief description of the process I am trying to
achieve.
Then as mentioned earlier in my flow chart, first I wrote code to set up the registers and I/O
ports. As we can see there were 3 file registers allocated for STATUS, PORTB and TRISB.
There were also 3 general purpose registers for R0, R1 and R2 which are used to create the
delays in the code. Then I changed the name of drive to R3 for simplicity and this is a register
for the output to the motor which is a variable value. R4 is implemented as a loop counter for
acceleration and deceleration. RPO is allocated for bit 5 of STATUS and Z for bit 2 of
STATUS. Count 1 & 2 have been defined to create the outer delay of a value of 133 as well
as an inner delay of a value of 50.
Within the main code I only used operation, operand and comment fields as I discarded the
label field, because this field was not needed. At the beginning of the main code I initialized
PORTB as all outputs and I stated the initial starting point be a binary input of 10000000
which represents zero speed. This would output that binary input from R3 to the motor on the
1750 unit via PORTB on the PIC that is connected to the DAC and 741 Op-amp. This would
be the starting point of the process where the motor would be off. I then created a delay of 5
seconds (250 x 20msecs) so that the motor would remain at zero speed for the duration of the
delay.
Next the binary input of 10000000 would be incremented up 100 steps. R4 is then
implemented which would make the motor accelerate and then with R3 incremented up to a
bit pattern of 11100100, this instruction is then outputted to PORTB then to the motor. Next
an instruction is implemented where a 20msec delay is inputted into the working register
before R4 is decremented causing the motor to slow its acceleration so that the designated
maximum clockwise speed is continuous. Then if the maximum speed was not achieved the
loop would be repeated. I then created a delay of 5 seconds (250 x 20msecs) so that the motor
would remain at maximum clockwise speed for the duration of the delay.
Then the binary input of 11100100 would be decremented down 200 steps. R4 is then
implemented which would make the motor decelerate back to zero speed and then accelerate
in an anticlockwise direction. Next with R3 decremented down to a bit pattern of 00011100,
this instruction is then outputted to PORTB then to the motor. As before an instruction is
implemented where a 20msec delay is inputted into the working register before R4 is
decremented causing the motor to slow its acceleration so that the designated maximum anti-
clockwise speed is continuous. Then if the maximum speed was not achieved the loop would
be repeated. I then created a delay of 5 seconds (250 x 20msecs) so that the motor would
remain at maximum anti-clockwise speed for the duration of the delay.
Next the binary input of 00011100 would be incremented back up 100 steps. R4 is then
implemented again which would make the motor accelerate and then R3 is incremented back
up to a bit pattern of 10000000 which is zero speed. This instruction is then outputted to
PORTB then to the motor. Again an instruction is implemented where a 20msec delay is
inputted into the working register before R4 is decremented causing the motor to slow its
acceleration so that zero speed is achieved. Then if zero speed is not achieved the loop would
be repeated. I then created a delay of 5 seconds (250 x 20msecs) so that the motor would
remain at zero speed for the duration of the delay.
28
Finally, the delay subroutine needed to be defined so that the system operated correctly where
the value passed to the routine in the working register is a time delay multiplied by 20 micro
seconds. So the value for the working register would be allocated into R0 and would be a
value of 50 per, a second delay. Therefore, for a 5 second delay this figure would be 250 (50
x 5) and as we can see from my code the value for each delay I inputted was 250. Next the
inner and outer delays needed to be placed in R1 & R2 and these along with R0 would
decrement the delays repeatedly until it reaches zero. Then the code returns back to the main
program.
After I had compiled the code in notepad I could transfer it to MPLAB and this created an
hex.file which was then entered into PPP. Next I made sure the watchdog timer was disabled
and the correct clock configuration was applied. I then uploaded the PPP code onto the
PIC16F84 from a PC via a development board. The development board and DAC circuit
along with the 741 Op-amp can be seen in the photo below.
Part 2 PIC-DAC Combination with 741 Op-amp
On the next page is a photo of the 1750 unit showing the wiring from the DAC to the
amplifier, power amplifier and DC motor.
29
Part 2 DIGIAC 1750 LJ Trainer Unit
After connecting the full system together, I then applied some power and began to observe
the motor. Initially the motor did not rotate, then after 5 seconds the motor slowly ramped up
to the maximum speed in a clockwise direction and it held this maximum speed for 5
seconds. Then the speed ramped down to zero speed before accelerating in an anti-clockwise
direction until it reached the maximum anti-clockwise speed and it held this speed for 5
seconds. Finally, after 5 seconds the motor decelerated until it reached zero speed and then
the whole process began to repeat again. This would continue to happen as long as power was
supplied to the system. Also one of the outputs from the amplifier on the 1750 unit was
connected to the moving coil meter, which is an analogue voltage meter and the movement of
this meter represented the negative and positive voltages being applied to the circuit.
Therefore, after 5 seconds when the motor accelerated and spun in a clockwise direction, I
could see the dial moving through the positive voltage range up to near 12V where it held this
value while the motor spun clockwise at its maximum speed. Then as the motor decelerated
and then accelerated in an anti-clockwise direction the dial moved down through the positive
voltage range, through 0V, then through the negative voltage range down towards near -12V.
It then held this voltage while the motor spun anti-clockwise at its maximum speed. Finally,
as the motor decelerated to a full stop the dial moved up through the negative voltage range
until stopping at 0V before repeating the whole process.
This system was quite easy to construct and I was able to complete my investigations
successfully. The motor reacted the way I was expecting and this proved that the PIC was
programmed correctly as well as the overall system was correctly configured.
30
Part 3
Investigation of PWM Control of DC Motor (Pulse Width Modulation)
Pulse width modulation (PWM) is a form of signal modulation used in control applications
and it is especially useful for loads that have inertia to break in order to start them moving
such as electric motors. PWM operates by switching the voltage on an off at very high speeds
using a power transistor such as a MOSFET and the speed of the motor can be altered by
varying the pulse width. Therefore, when the pulse is wider this means the signal is on more
and the speed of the motor will increase as there is more power available. This is called the
duty cycle and corresponds to the amount of signal on time in a cycle compared to the
amount of time off. The lower the duty cycle the lower the power is available to the system.
“As the duty cycle grows larger, the average current grows larger and the motor speed
increases.”
(Alciatore et al, 2012, p448)
Below is a picture of varying duty cycles.
Varying Duty Cycles
As we can see from the picture above, T represents the overall period of PWM signal, which
is made up of the sum of t on and t off. When the signal is on this is represented by t on and
when the signal is off this is represented by t off, therefore, t on + t off = T.
With PWM, the amplitude and frequency are constant for a PWM signal so the duty cycle
can be calculated with the following formulas;
Duty Cycle = t on / (t off + t on) = t on / T
Duty Cycle = t on / T = t on x f
Therefore, as we can see in the picture above the duty cycle is defined by the ratio between
the signals on time and the time period of the rectangular waveform. This is specified as a
percentage and can be calculated by the formula;
Duty Cycle = T / t on x 100
31
So to control the speed of a motor with PWM, the duty cycle is altered where the average
current delivered to the motor changes and this causes a change in speed as well as torque at
the output. It is the duty cycle of the PWM and not the value of the supply voltage, that is
used for the speed of the motor to be controlled. Essentially the supply voltage to the motor is
interrupted and this controls the motors speed.
“In such cases the technique known as pulse width modulation (PWM) is generally used.
This basically involves taking a constant d.c. supply voltage and chopping it so that the
average value is varied”
(Bolton, 2003, p172)
PWM is widely used within industry for low speed applications and power saving. It is highly
efficient as it results in very low power loss because when the signal is off, there is practically
no current and when the signal is on, there is almost no volt drop within the system. Also
PWM can control a motor at lower speeds as it breaks the inertia of the motor by vibrating it
until it starts to rotate and this is excellent for the purpose of my investigations.
For this part of my investigations I was tasked with investigating variable speed control of a
motor with PWM. I had to use LabVIEW or another suitable system with PWM output and
develop a software/hardware based system to control the 12V d.c. motor on the 1750 unit.
Below is a block diagram of the system I configured.
Part 3 Overall System Block Diagram
As we can see from the picture above I used a function generator to create a PWM output and
I used a T-bar to connect the output to a power amplifier (which would increase the current as
the function generator only provides voltage) on the 1750 unit to an oscilloscope to monitor
the width of the pulse so I could adjust the duty cycle correctly. This output from the power
amplifier was then connected to the motor on the 1750 unit and the motor has a sensor at its
output which was connected to the rev counter display on the 1750 unit so I could monitor
the effect of the larger duty cycles on the revolutions per second (RPS). This system was built
and can be seen in the photos on the next page.
32
Part 3 Function Generator and LJ Trainer System(A)
Part 3 Function Generator and LJ Trainer System(B)
33
After building the circuit that is shown in the photos on the previous page I set the frequency
to around 100Hz on the function generator which is the ideal frequency for this experiment.
A frequency that differs is insufficient as the motor would not rotate smoothly but would jerk
as it rotated, similar to a stepper motor and 1 full cycle is equal to 10ms at 100Hz. Next I
started to increase the duty cycle from 0 to 100% and observed the motor rotate. As the
motors output was connected to the rev counter display on the 1750 unit, I could observe the
revolutions per second(RPS) and I recorded the results in the table below.
Part 3 Investigation of PWM Control of DC Motor Results Table
Speed ofShaft(RPS) Speed ofShaft(RPM) Duty Cycle Time(ms) Duty Cycle (%)
0 0 0 0%
<1 -71 0.5 5%
0.2 12 1.0 10%
5 300 1.5 15%
6 360 2 20%
10 600 3 30%
14 840 6 40%
18 1080 5 50%
22 1320 4 60%
26 1560 7 70%
32 1920 8 80%
36 2160 9 90%
38 2280 10 100%
As the counter on the 1750 unit only outputs readings for RPS, I also wanted results for
revolutions per minute(RPM) so I multiplied the RPS results by sixty to calculate the RPM
and recorded the calculations in the table as well. From these results I could plot a graph on
excel of the duty cycle against the speed of the motor in RPM where the motor would rotate
at 2400 RPM when 12V is applied to the motor therefore 200 RPM is equal to 1V and the
graph can be seen below;
PWM Control of a DC Motor Test Results Graph (PWM Against Duty Cycle)
I then plotted a graph on excel of the RPM against the RPS and this can on the next page.
34
PWM Control of a DC Motor Test Results Graph (RPM Against RPS)
With the graphs that I plotted I could determine the PWM duty cycle required to provide a
speed of 50 RPM. The results that were plotted on excel produced figures of the line of best
fit and I could use these figures to calculate the duty cycle percentage that is required to
produce a motor speed of 50 RPM. Below is the calculation for the duty cycle that was
required;
12% = 50 RPM (1.2ms) graph y = 0.04 x 50 + 6.1386
0.04 x 50 + 6.1386 = 8.13%
Therefore, 50 RPM = 8.13%
Also with an analogue input of +5V connected to a variable amplifier, the motor overcame
inertia at 2 RPS.
For this part of my investigations I also needed to provide a suitable design to show how the
PWM technique could be used to provide speed control in both directions of rotation.
Therefore, I would implement an H-Bridge within the system to control the polarity of the
input voltage and below is a diagram of how an H-Bridge operates.
H-Bridge Explanation Diagram
As we can see from the picture on the previous page, if S1 and S4 switches are closed as well
as the other two switches are open, then the voltage can flow to ground (highlighted in red).
This would make the motor rotate in a clockwise direction because the voltage would be
flowing through the positive to the negative terminals on the motor before reaching ground.
35
Similarly, when S2 and S3 switches are closed as well as the other two switches are open,
then the voltage would flow to ground (highlighted in blue). The motor would now be
rotating in an anticlockwise direction as the polarity of the motor has been reversed, where
the voltage is now flowing through the negative to the positive terminals before reaching
ground. Metal Oxide Semiconductor Field Effect Transistor (MOSFET) switches would be
ideal to use but instead of building the H-Bridge with individual components, there is the
TPIC0107B PWM Control Intelligent H Bridge IC that is designed specifically for d.c. motor
applications and below is the pin layout diagram.
TPIC0107B Pin Layout Diagram
(Texas Instruments Incorporated, 2002, accessed 2016)
As we can see from the picture above, there is a dedicated PWM input port at pin 8 and the
IC is optimized for reversible operation of motors, which is achieved by the designated
direction port at pin 3. To implement this IC, I would have to substitute the function
generator with a microcontroller, such as any from the PIC range that has a PWM function.
From the TPIC0107B data sheet we can derive the typical application circuit and below is a
picture of that circuit that I would implement to show how the PWM technique could be used
to provide speed control in both directions of rotation.
TPIC0107B Typical Application Circuit
(Texas Instruments Incorporated, 2002, accessed 2016)
This system was quite easy to construct and I was able to complete my investigations
successfully. The motor reacted the way I was expecting and this proved that the overall
system was correctly configured.
36
Part 4
Mechatronics and Embedded Systems (Solar Panel Tracking System)
For this part of my investigations I was tasked with solving one of two problems and the
problem I chose to tackle was designing a sun-tracking solar panel system, to be used to
optimise solar electrical generation in small-scale installations and the panel must follow the
position of the sun as it moves across the sky from east to west every day. A solar tracker is
much more efficient than a static system and can increase the panels output by around 20 to
30%, which increases the power that is generated. The sun travels from east to west through
the sky but over the day its position is degrees different through north to south as it rises and
sets. Therefore, as the solar panel needs to be perpendicular to the sun so the efficiency of
generating power is optimized, the tracker system needs to be able to track both x and y axis,
so a dual axis tracking system is required.
The system that I had to design had to incorporate the PIC18F2420 microcontroller into the
system and below is a picture of the pin layout diagram.
PIC18F2420 Pin Layout Diagram
(Microchip Technology Incorporated, 2008, accessed 2016)
The PIC18F2420 is similar to the PIC16F84A microcontroller I used in part 1 and 2 but is
packed with more features. It has ten analogue inputs with a 10-bit ADC, three 8 bit
bidirectional ports, two PWM outputs, brown out reset and is low on power consumption
with sleep mode etc.
The tracking system I had to design needed to be positioned by 2 bipolar d.c. motors with
inputs from 3 light dependant resistors (LDRs) as sensors that track the sun. Also there
should be 3 status LEDs as well as 4 limit switches and be powered by a 12V battery. On the
next page is a simple mechanical design as well as the circuit diagram for the solar tracking
system I designed and a clearer full size circuit diagram is in Appendix 3.
37
Solar Tracking System Circuit Diagram
Solar Tracking System Mechanical Design and LDR Position Diagram
First, after consulting the PIC18F2420 data sheet I researched voltage regulators for the
power supply sub system and came across the LM7805 IC which is a 12V to 5V voltage
regulator. This is perfect for my overall system as when consulting the data sheet, the
PIC18F2420 accommodates an operating VDD range of 4.2V to 5.5V, so 5V is an ideal
output from the LM7805 for the microcontroller to operate correctly. On the next page is a
picture of the pin layout diagram for the LM7805.
38
LM7805 Pin Layout Diagram
(Texas Instruments Incorporated, 2003, accessed 2016)
As we can see in the systems circuit diagram the LM7805 needed some components to
operate correctly such as capacitors and after consulting the data sheet for the LM7805 I used
a 0.33uf capacitor on the input and a 0.1uf capacitor at the output. The 0.33uf capacitor is
there to reduce voltage transients on the input of the LM7805 and this also improves the
stability of the output voltage. The 0.1uf capacitor reduces fluctuations of transient voltage on
the output caused by quick changes in load current. Therefore, they are decoupling capacitors
at the input and output, which are needed to suppress noise. The 1N4007 diode that is
connected in series with the 12V battery and the LM7805 is there to protect the regulator in
case the battery is connected the wrong way round. There is also a status LED in the power
supply side of the circuit and this will illuminate when power is being supplied to the
microcontroller. The calculations for the resistor is explained on the next page along with the
ones used on the LDRs. Finally, there is a 100nf capacitor connected between VDD and VSS
because there is noise that is shunted through the capacitor therefore it reduces the effect on
the rest of the circuit. As the LM7805 will produce a lot of heat due to high currents I would
connect the tab on the regulator to a heat sink.
For timing purposes there is a 4 MHz crystal oscillator connected to pins 9 and 10. The
decoupling capacitor values that are there to reduce noise, were derived from the oscillator
configuration in the PIC18F2420s data sheet and it is recommended that 30pf capacitors
should be connected on pin 9 as well as pin 10 when using a 4MHz crystal oscillator.
The master clear pin which is pin 1 is connected in series to a 10KΩ resistor and then to the
5V from the output of the LM7805 regulator. This is to hold MCLR high while in use
because if MCLR is in any way low the PIC18F2420 will reset.
The LDRs within the system are variable resistors where the resistance within them decreases
when the light intensity that falls upon the device increases. Then for example, when there is
sunlight the LDR could have a resistance of 1KΩ and when it is dark the resistance could be
100KΩ. As they are passive transducers, in my system they are configured as potential
dividers by connecting them in series with 75KΩ resisters. Therefore, any change in light
density is proportional to the change in voltage across the LDRs. The LDRs I was thinking
about using in the system were from the VT900 series such as the VT90N1 and the Electro-
Optical Characteristics table from the data sheet can be seen on the next page.
39
VT900 Series Electro-Optical Characteristics Table
(PerkinElmer Optoelectronics, 2001, accessed 2016)
From this table I could see that the LDRs resistance is 12KΩ when it is in the light and
200KΩ when it is in the dark. Therefore, with these figures I could calculate which is the best
resistor to use to create a potential divider to provide a suitable response and below is the
formula I used.
Vout = (R2 / (R1 + R2)) x Vin
In my circuit I am proposing 75KΩ resistors which would be the value of R2 and when the
LDR is receiving light its resistance would be 12KΩ, this is the value of R1.
(75KΩ / (12KΩ + 75KΩ)) x 5V = 4.3V
When the LDR is in the dark the resistance would increase to 200KΩ and now this is the
value of R1.
(75KΩ / (200KΩ + 75KΩ)) x 5V = 1.36V
This is the perfect response for my system and that is the reason I used the LDR as R1 instead
of R2, which would reverse the values of the output. The reason I used a 75KΩ resistor as R2
was to give me a voltage at PORTA pins 2,3 and 4 that was within the recommended values
in the data sheet. There are three status LEDs connected before pins 2,3 and 4 to show that an
LDR is being activated. Below are my calculations for the status LEDs resistors.
(5 – 1.5) = 6x10-3
x (70 + R)
R = 463Ω
NPV = 470Ω
The LDRs are connected to pins 2,3 and 4, as these are analogue input pins and the
PIC18F2420 has an inbuilt 10 bit ADC to convert the signal into a binary code for the output
to the motors. I will discuss this later when I am describing the operation of the solar tracking
system with the use of the LDRs.
40
Next I researched ways to drive the motors and decided to use the L293D which has two H-
Bridges within it and can control two d.c. motors independently. I could use two TPIC1070B
ICs as described in part 3 and use PWM to control the motors but I have decided the L293D
simplifies the circuit by only having 4 inputs from the PIC18F2420, therefore leaving pins
available for future use. It also will use less components and the cost would be reduced.
Below are pictures of the L293D pin layout diagram and pin functions table.
L293D Pin Layout Diagram
(Texas Instruments Incorporated, 2016, accessed 2016)
L293D Pin Functions Table
(Texas Instruments Incorporated, 2016, accessed 2016)
From the pin functions diagram I could then derive the typical application for the L293D and
design the motor sub system as seen in my system circuit diagram. As you can see there are
only four inputs from the PIC18F2420 which would leave some output pins available for
future improvements. Vcc1 is connected to 5V for internal logic translation and Vcc2 is also
connected to 5V for the power to drive the motors. As I would use 12V bidirectional d.c
motors I chose 5V instead of tapping 12V off of the battery as a means to control the speed of
the motor and with using 5V the motors would only have a maximum speed of 1000 RPM
instead of a possible 2400RPM. Also pins 1 and 9 are connected to 5V to enable both sets of
input and output pins. Pins 4,5,12 and 13 would be all be grounded. The motors are
connected to pins 3,6,11 and 14 with decoupling capacitors connected in parallel with the
motor to help to compensate noises produced by motor as well as to prolong the life of the
motor.
41
Where the operation of the system is concerned within my mechanical design LDR 3 is
positioned inside an inverted enclosure and this is so the light will only hit it when it is
directly facing the sun. When the sun moves this would increase the resistance in LDR3 and
would change the output voltage that is fed into pin 4 on the PIC18F2420 away from the set
reference voltage, therefore the output pins of PORTA would be activated and the motors
would move accordingly to track the sun.
At sunset or if it is a cloudy day the tracker does not aimlessly scan the sky for the sun
because of LDR2. This LDR is mounted flush to the mechanism so it can see the whole sky
that it is facing. Therefore, at sunset or on a cloudy day, the lack of light will increase the
resistance, altering the output voltage that is fed into pin 3 on the PIC18F2420 away from the
set reference voltage and because of this it would activate its sleep mode. After the system
has shut at sunset it should be pointing to the west and as the sun rises in the east, this is
where LDR1 comes into play. As LDR1 is mounted on the back facing in the opposite
direction to the other LDRs, in the morning LDR1 is pointing to the east and when it senses
the sun is rising the resistance will decrease altering the voltage to pin 2 on the PIC18F2420.
This wakes the system from sleep mode, then it activates the motors to turn the solar panel
towards the sun until LDR2 first sends a voltage to pin 3 and then LDR3 sends the correct
voltage to pin 4. By positioning the LDRs and using them in this way I believe I do not need
the limit switches as the motors would not rotate when the LDRs are not transmitting a
voltage to the inputs on the PIC18F2420.
As far as the software configuration of the various ports on the PIC18F2420, PORTA would
be configured as an input port and PORTB would be configured as an output port. PORTC
does not need to be configured in my system and would be available for future improvements
to the system.
This system was interesting to research and I know my design is not perfect but through my
research it became apparent that there are different ways to operate a solar tracking system
using. However, I believe my design is one of the simplest and cost effective designs as it
uses one IC to drive the motors instead of one per motor. The important part would be the
code that is inputted into the PIC18F2420, where the signals that are inputted from the LDRs
are interpreted correctly to give a suitable output response to rotate the motors and keep the
panel perpendicular to the sun. I also believe that this system could be up scaled for bigger
installations with some alterations.
42
Part 5
Mechatronics Case Study (Neoprene tube cutting system)
For this part of my investigations I was tasked with solving one of two problems and the
problem I chose to tackle was for a neoprene tube cutting system. Below is a picture of the
system.
Neoprene tube cutting system
(Ward, 2016, accessed 2016)
As we can see from the picture above there is an extruded neoprene tube(A) that is fed to a
cutter(B) and this cutter will be positioned by an electric motor(C) to cut rings of the tube to
become seals. These seals are then fed by a chute(D) to a conveyor belt which passes the seal
between pinch rollers(E) where the seals dimensions are measured and any seals that are out
of specification are ejected from the system by a device(F). If any seal does not meet the
specification that is required, then the position of the cutter would be adjusted accordingly.
For my investigations I was tasked with;
Finding a suitable transducer for measuring the displacement of the pinch rollers.
Finding a suitable device to be used to physically reject the inadequate seals as well as
finding a suitable motor to position and reposition the cutter.
Sketch a block diagram showing the layout and interfacing elements that are necessary for the
system to operate correctly.
Develop a programming flow chart for the system and suggest a suitable programming
language.
43
A transducer is the collective term used for both, sensors which can be used to sense a wide
range of different energy forms and actuators which can be used to switch voltages or
currents. Therefore, transducers are used to convert energy of one kind into energy of another
kind.
Firstly, there were many transducers to choose from and they are classed as input or output,
as well as contact and non-contact transducers. The contact transducers vary from linear
variable differential transformer (LVDT) and linear variable capacitors, to potentiometers and
strain gauges. The non-contact transducers are laser(optical) triangulation, ultrasound, GPS
and radar etc. However, for the system in question I would be measuring displacement of the
pinch rollers and I believe one of the contact transducers would be more suitable for the
system to operate efficiently. Therefore, I have chosen a linear variable differential
transformer (LVDT) as the ideal transducer to measure the displacement of the pinch rollers.
An LVDT is in its basic form similar to a transformer with a moveable iron core where three
coils are used, one on the input (primary) and two on the output (secondary) with the ratio
between the two output coils making it possible to determine the direction of the movement
of the iron core. For the LVDT to operate correctly an a.c. signal is connected to the primary
core and this a.c. signal is of a high frequency that is easily removed with a low pass filter.
The two windings on the secondary side of the LVDT have the same amount of windings and
are wound in series but are wound in different directions. Therefore, they are connected in
anti-phase but a phase sensitive rectifier is used to nullify this problem and this makes it
possible for the position of the iron core to be calculated. LVDTs have many applications
because it does not suffer from mechanical wear as well as being extremely accurate and can
be used for example in cash machines to count notes as the resolution goes down to µm.
“LVDT transducers are essentially immune to friction and wear problems, they have infinite
resolution and are highly linear and accurate.”
(Fraser et al, 1994, p123)
Below is a schematic diagram of an LVDT showing the operation of the moveable core,
LVDT Schematic and Operational Diagram
(Macrosensors.com, 2014, accessed 2016)
The picture above is a schematic representation of an LVDT and shows the iron core passing
through the coils. Whichever coil has the most amount of core passing through it will have a
higher voltage induced into it.
44
However, if the core is in the middle the two induced voltages should cancel each other out
giving zero output voltage. When voltage from an a.c. supply is sent through the primary coil,
it causes a voltage to be induced and generated through the secondary coils. The secondary
coils have the same number turns and are connected in series opposing, so the output voltage
is the difference between the voltages induced in the coils. When the iron core is in the
middle in the picture on the previous page the voltages induced in coils S1 & S2 would be
exactly the same (like a normal transformer) and the output voltage would be near zero. For
example if we sent a 10V a.c. signal through the primary, the induced voltage at the
secondary would be 10V and have an output of 0V. We can check this by using this equation;
Vout = (S1 – S2)
Vout = (10V – 10V)
Vout = 0V
When the iron core is positioned to the left as shown on the last page, the induced voltage of
coil S1 will be bigger than that induced in coil S2. This will create an output voltage Vout =
(S1 – S2) and for example if we sent a 10v AC signal through the primary coil, the induced
voltage at coil S1 would be something like 7V so in coil S2 should be 3V. We can work out
what the output voltage should be by using the equation;
Vout = (S1 – S2)
Vout = (7V – 3V)
Vout = 4V
When the core is positioned to the right as shown on the previous page, the induced voltage
of coil S1 will be smaller that the induced voltage in coil S2. This will create an output
voltage of Vout = (S1 – S2). So by moving the iron core from its neutral position it produces
an output voltage and this voltage increases the further from the neutral position. Therefore,
where the pinch rollers on the system is concerned I would have a set voltage that the LVDT
would output to indicate when a seal has been cut to the correct specification and when the
LVDT has an output that differs from this set voltage this would let the system know the seal
is inadequate and it should be rejected. Also because the LVDT outputs an analogue signal
this needs to be converted to a digital signal with an ADC for the neoprene tube cutting
system. As for the dynamic response, it should be quick as the production line will not stop
and the next seal would be just behind the proceeding one. This means that the LVDT needs
to be reset back to the original set point voltage ready to analyse the next seal. This is
important so the quality of the seal is not compromised and meets the specification required.
45
A suitable device that is to be used to physically reject the inadequate seals after receiving an
output signal from the LVDT that differs from the set voltage could be a few things. They are
a solenoid that is activated to push the rejected seal down the reject shoot, compressed air to
physically blow the seal down the reject shoot or a flap mechanism controlled by a solenoid
which activates a lever and diverts the seal down the reject shoot. For the system in question I
opted to utilise a solenoid activated lever system as this is not only the most reliable way but
one the simplest options as it does not require an extra sensor to sense when a defective seal
is present that needs to be rejected. Below is a diagram of how a solenoid is constructed.
Solenoid Construction Diagram
(Shipway et al, 2008, accessed 2016)
A solenoid is a transducer that transforms electrical energy into linear motion. It has an iron
core with a coil of wire wrapped around it and when the coil has a voltage across it the
magnetic flux drives the core forward. The coil is wrapped around the core so that
the armature can be moved in and out of the centre. This process alters the coils inductance
causing it to become an electromagnet and it is the armature which is used to provide a
mechanical force. When the solenoid is de-energised the magnetic field collapses quickly and
a back emf is generated within the coil. These induced voltages can be extremely high so a
diode is connected in parallel with the coil.
After the solenoid has been activated it resets with the aid of a spring ready for the next
LVDT reading. Solenoids are only effective over short distances but have very quick reaction
times due to the simplicity of the circuitry needed to operate them. Electromechanical
solenoids are commonly seen in electronic pinball machines, dot matrix printers and fuel
injectors.
46
For this system the end of the armature of the solenoid is connected via a pivot bracket to the
flap mechanism, close to the hinge that attaches the flap to the chute. As the pivot bracket is
attached close to the hinge this helps with the mechanical movement of the flap to ensure it
fully opens and diverts the rejected seals. Below are graphical representations of the flap
mechanism I am proposing in closed and open states.
Closed Flap Mechanism Graphical Representation
As we can see from the picture above that when the LVDT outputs a signal that is exactly the
same as the set voltage which represents the size of the seal that is required, the flap
mechanism will stay closed. Therefore, the seal will drop down the chute and carry on down
the production line.
Open Flap Mechanism Graphical Representation
The picture above shows that when the LVDT outputs a signal that differs from the set
voltage point then the coil in the solenoid is energised to create a magnetic flux set up within
the coil. This field then provides the magnetic force to drive the core as well as the armature
forward to physically open the flap and divert a miss-sized seal down the reject shoot.
47
Within the system, at the start of the process or when the LVDT outputs a different signal to
the set voltage, the cutter needs to be positioned or repositioned by a motor. One of the best
motors for positioning used throughout industry is a stepper motor and it is a device that
converts d.c. voltage pulses into a proportional mechanical rotation of its shaft.
Stepper Motor
(Engineers Garage, 2012, accessed 2016)
Stepper motors are d.c. motors that move in discrete steps and have multiple coils that are
organized in groups called phases. Stepper motors are usually paired with a motor drive
which translates pulses into appropriate patterns of current sent to phases at the stator
therefore driving the motor. So when each phase is energised in sequence the motor will
rotate, one step at a time and with a form of control such as a PC, microcontroller or PLC the
stepper motor can achieve very precise positioning. Stepper motors move in precise
repeatable steps so they excel in applications requiring precise positioning such as 3D
printers, CNC, Camera platforms etc. Also stepper motors have high torque at low speeds
which would be good for the neoprene cutting system as the cutter would only need to be
repositioned slightly every time and they have excellent holding torque which would be
beneficial for the cutter to make a clean straight cut.
There are unipolar and bipolar stepper motors, however for the system in question a bipolar
stepper motor is more suitable. This is because it can rotate in both directions which is vital
as the rejected seals could be either too big or too small. So when repositioning the cutter, the
motor needs to be able to rotate both ways depending on the size of the rejected seal.
48
If the system is to be monitored and controlled by a PC, there needs to be a product to
interface between the PC and the neoprene cutting system. Such a product is an external I/O
card like one from national instruments and below is picture of the product.
National Instruments External I/O Card
(Haugen, 2008, accessed 2016)
The national instruments external I/O card is an excellent bit of kit and can be operated with
various pieces of software like C, Visual Studio or LabVIEW. It is also suitable for the
platforms windows, mac and Linux. For the neoprene cutting system I would implement
LabVIEW as this is quite easy to use and would be ideal for the system in partnership with
the external I/O card connected to a PC. Below is a block diagram which shows how the
whole system should be configured.
Neoprene Cutting System Block Diagram
49
In the picture on the previous page it shows the optimal configuration for the control and
monitoring of the system. Using LabVIEW, the data can be entered via the PC for the cutting
parameters and could be inputted with the use of a keyboard and mouse. Power transistors,
such as Mosfets could be used to interface between the 5V output from the PC via the
external I/O card and the 12v motor as well as the solenoid. The 12V would be supplied from
a battery or the external I/O card after its output of 5V had been amplified. As the LVDT
outputs an analogue signal this needs to be converted to a digital signal by an analogue to
digital converter(ADC) for the LVDT to interface with the PC. Also the motor could have an
analogue position converted to a digital signal by the ADC and this digital signal would be
inputted to the PC via the external I/O card.
Finally, I had to develop a flowchart for the neoprene cutting system and below is a picture of
my flowchart.
Neoprene Cutting System Flowchart
50
As we can see from the flowchart on the previous page, first the I/O ports needs to be set up
and then the conveyor is switched on. Next the stepper motor is moved to alter the cutters
position and this position is checked. Then the neoprene tube is checked it is in the correct
position and the lever system is checked that it is closed so correctly sized seals do not go
down the reject chute. At this point a seal is cut off of the neoprene tube, then fed with a
conveyor through the roller and the LVDT output signal voltage is read. Next this output
voltage is compared against the specification of the desired size of seal, which for the
purposes of this explanation is assumed to be 2V and a question is asked whether it is greater
or less than 2V? If the answer is no this means the LVDT output signal equals 2V which is
the correct specification, so then the process can repeat from just before check neoprene tubes
position and the lever system is closed.
If the answer to the question was yes, then the LVDT output signal was greater or less than
2V. This reading would activate the solenoid where the lever would open across the chute
therefore rejecting the miss-sized seal down the reject chute. Next the question, was the
LVDT output signal greater than 2V was asked. If the answer was no, then the LVDT output
signal was less than 2V and this would instruct the stepper motor to rotate clockwise so the
motor positions the cutter to cut a bigger seal to receive an increased LVDT output so it
equals 2V. Next the solenoid would be deactivated thus closing the lever and then the process
would repeat from point A, where the stepper motor would reposition the cutter until the
desired LVDT output is achieved. If the output from the LVDT was greater than 2V, this
would instruct the stepper motor to rotate anti-clockwise till the LVDTs output is decreased
so it equals 2V and this would position the cutter to cut a smaller seal. Next the solenoid
would be deactivated thus closing the lever and then the process would repeat from point A,
where the stepper motor would reposition the cutter until the desired LVDT output is
achieved. The part of the flowchart that is highlighted in blue writing is the variable part of
the code and this is altered depending on what size seal is desired.
There are a few programming languages that would be suitable for the neoprene cutting
system such as C++, Flowcode and even ladder logic using a PLC. I would choose Flowcode
as it is probably the simplest to implement. With Flowcode you create a flowchart like the
one seen above and Flowcode converts the chart into code. One of the benefits of this
software is that you can simulate the circuit within Flowcode to check that the code works
correctly and it is easier to use Flowcode rather than a generic C compiler program.
This system was interesting to research and I believe my system would work correctly.
However, I would try improve it by implementing a PIC16F84 into the system because it has
a built in feature for high torque micro stepping by using the ECCP module with a few
external components and this will allow the stepper motor to be driven at a frequency of
around 31KHz. This frequency will eliminate any unwanted noise that is generated by the
motor at lower frequencies. Also by implementing a PIC16F84 it would remove the need for
a PC and instead the reference level for the LVDT could be selected by a digital keypad or
toggle switch for say 10mm, 20mm, 30mm etc. Obviously some code would need to be
written to program the PIC16F84 for the system to operate correctly and I am confident I
could do that.
51
Conclusion
To conclude these investigations went well and I learned a lot. Mechatronics is all around us
and an important part of the modern world. This report introduced various ways to control
mechatronics systems such as a PLC or PIC microcontroller and these were excellent for the
purpose of my investigations. The PIC microcontrollers were not too hard to program and
with the development board quite easy to implement into the system. The PIC16F84 was an
ideal microcontroller for low cost motor control and as mentioned earlier I would try use it in
the neoprene cutting system. I have seen how with the use of a DAC, a motor can be made to
steadily ramp up and ramp down in acceleration, as well as change its direction. This is
because I wrote a program which increased the binary output from the PIC16F84 in a linearly
response to increase the magnitude of the analogue signal to the motor.
I also learned that PWM is a good tool to use where motor control is concerned and with the
use of a H Bridge the motor could be controlled in both directions. Also with the
implementation of the TPIC0107, the circuit would be very efficient and cost effective.
The final two problems were interesting and I believe my designs were feasible. The solar
tracker system problem was quite tasking with designing the whole circuit with regards to the
power supply sub system, LDR input sub system and the motor output sub system. However,
through my research I learned that there are various ways to achieve a system that works and
I believe my design would operate correctly.
As far as the neoprene tube cutting system is concerned I believe my system would operate
correctly and my choice of components, as well as the way it would be configured is
adequate for the purpose of the system. All together I have learned a lot this semester and it
should hold me in good stead throughout what I hope to be a long career, because
mechatronics is embedded throughout industry.
52
Appendix 1 Part 1 PIC16F84 Code (A)
LIST P=16F84,R=DEC
TITLE "Part1.ASM"
; This program controls the speed and direction of a DC motor:
; SET1 DURATION (assumes a 4MHz crystal
clock)
; Motor OFF 2 seconds
; Motor ON Clockwise 2 seconds
; Motor OFF 2 seconds
; Motor ON Anti-Clockwise 2 seconds
;
; *** PROGRAM EQUATES ***
STATUS EQU 3 ;STATUS is file register 03h
PORTA EQU 5 ;PORTA is file register 05h
TRISA EQU 5 ;TRISA is file register 85h
R0 EQU H'C' ;1st General Purpose Register
R1 EQU H'D' ;2nd General Purpose Register
R2 EQU H'E' ;3rd General Purpose Register
RP0 EQU 5 ;Bit 5 of STATUS
COUNT1 EQU 133 ;Value for outer delay count
COUNT2 EQU 250 ;Value for inner delay count
;
; *** MAIN PROGRAM ***
ORG 0
BSF STATUS,RP0 ;Select register bank 1
MOVLW 0
MOVWF TRISA ;Make PORTA all output
BCF STATUS,RP0 ;Select register bank 0
;
BEGIN MOVLW B'00000000' ;Motor OFF
MOVWF PORTA ;and output to Motor
MOVLW 20 ;Value for 2 second delay
CALL DELAY
;
53
MOVLW B'00000001' ;Motor runs Clockwise
MOVWF PORTA ;and output to Motor
MOVLW 20 ;Value for 2 second delay
CALL DELAY
;
MOVLW B'00000011' ;Motor OFF
MOVWF PORTA ;and output to Motor
MOVLW 20 ;Value for 2 second delay
CALL DELAY
;
MOVLW B'00000010' ;Motor runs Anti-Clockwise
MOVWF PORTA ;and output to Motor
MOVLW 20 ;Value for 2 second delay
CALL DELAY
;
GOTO BEGIN
;
; ***Delay Subroutine - value passed to routine in W is time delay times 0.1 seconds.***
DELAY MOVWF R0 ;Place W value into R0 (10 per second delay)
DELAY1 MOVLW COUNT1 ;Place COUNT1 (133) into R1
MOVWF R1
DELAY2 MOVLW COUNT2 ;Place COUNT2 (250) into R2
MOVWF R2
DELAY3 DECFSZ R2 ;Decrement R2 repeatedly
GOTO DELAY3 ;until it equals 0
DECFSZ R1 ;Decrement R1 repeatedly
GOTO DELAY2 ;until it equals 0
DECFSZ R0 ;Decrement R0 repeatedly
GOTO DELAY1 ;until it equals 0
RETURN ;Done, return to main program
;
END
54
Part 1 PIC16F84 Code (B)
55
Appendix 2 Part 2 PIC16F84 Code (A)
LIST P=16F84,R=DEC
TITLE "Part2.ASM"
;
; *** PROGRAM EQUATES ***
;
STATUS EQU 3 ;STATUS is file register 03h
PORTB EQU 6 ;PORTB is file register 06h
TRISB EQU 6 ;TRISB is file register 86h
R0 EQU H'C' ;1st General Purpose Register (time delay routine)
R1 EQU H'D' ;2nd General Purpose Register (time delay routine)
R2 EQU H'E' ;3rd General Purpose Register (time delay routine)
R3 EQU H'F' ;Register for VALUE OUTPUT TO MOTOR (variable)
R4 EQU H'10' ;Loop Counter for Acceleration & Deceleration
RP0 EQU 5 ;Bit 5 of STATUS
Z EQU 2 ;Bit 2 of STATUS
COUNT1 EQU 133 ;Value for outer delay count
COUNT2 EQU 50 ;Value for inner delay count
;
; *** MAIN PROGRAM ***
;
ORG 0
;
; ***Port initialisation***
;
MAIN BSF STATUS,RP0 ;Select register bank 1
MOVLW 0
MOVWF TRISB ;Make PORTB all output
BCF STATUS,RP0 ;Select register bank 0
;
; ***Initial zero speed stage for 5 seconds***
BEGIN MOVLW B'10000000' ;Initial Bit pattern for zero speed (motor off)
MOVWF R3
MOVWF PORTB ;Output R3 to PORTB and DAC the zero speed
MOVLW 250 ;5 sec at zero speed initially, using DELAY (250 x
20msecs)
CALL DELAY
56
;
; ***Increment from zero speed stage(100 STEPS)***
MOVLW 100 ;REPEAT THIS SEQUENCE (LOOP) until Full Speed reached.
100 steps up from 10000000
MOVLF R4 ;Motor acceleration
FORWARD INCF R3 ;Increment binary bit pattern to 11100100
MOVF R3,0
MOVWF PORTB ;Output R3 to PORTB and DAC the maximum clockwise
speed value
MOVLW 1 ;Set W for a 20msec delay
CALL DELAY
DECFSZ R4 ;Stop/slow motor acceleration
GOTO FORWARD ;Repeat loop till at maximum clockwise speed
;
; ***Constant forward speed stage for 5 secs***
MOVLW 250 ;Motor runs clockwise at maximum speed for 5secs
(250 x 20msecs)
CALL DELAY
;
; ***Decrement stage to zero for 2 secs, then reverse for 2 secs (4secs total and 200
steps)***
MOVLW 200 ;REPEAT THIS SEQUENCE (LOOP) until Full Speed
reached. 200 steps down from 11100100
MOVWF R4 ;Motor deceleration then acceleration in reverse
FORWARD2 DECF R3 ;Decrement binary bit pattern to 00011100
MOVF R3,0
MOVLF PORTB ;Output R3 to PORTB and DAC maximum anti-clockwise
speed value
MOVLW 1 ;Set W for a 20msec delay
CALL DELAY
DECFSC R4 ;Stop/slow motor acceleration
GOTO FORWARD2 ;Repeat loop till at maximum anti-clockwise speed
;
; ***Constant reverse speed stage for 5 seconds***
MOVLW 250 ;Motor runs anti-clockwise at maximum speed for 5secs
(250 x 20msecs)
CALL DELAY
;
57
; ***Increment back to zero speed stage (100 steps)***
MOVLW 100 ;REPEAT THIS SEQUENCE (LOOP) until zero speed
reached. 100 steps up from 00011100
MOVWF R4 ;Motor acceleration
REVERSE INCF R3 ;Increment binary bit pattern to 10000000 (zero
speed value)
MOVF R3,0
MOVWF PORTB ;Output R3 to PORTB and DAC the zero speed
MOVLW 1 ;Set W for a 20msec delay
CALL DELAY
DECFSZ R4 ;Stop/slow motor acceleration
GOTO REVERSE ;Repeat loop till at zero speed
;
; ***SUBROUTINES***
; ***DELAY subroutine - gives a time delay***
; - time delay equals 20 ms times value in W.
;
DELAY MOVWF R0 ;Value in W at subroutine call.
DELAY1 MOVLW COUNT1 ;Place COUNT1 (133) into R1
MOVWF R1
DELAY2 MOVLW COUNT2 ;Place COUNT2 (50) into R2
MOVWF R2
DELAY3 DECFSZ R2 ;Decrement R2 repeatedly
GOTO DELAY3 ;until it equals 0
DECFSZ R1 ;Decrement R1 repeatedly
GOTO DELAY2 ;until it equals 0
DECFSZ R0 ;Decrement R0 repeatedly
GOTO DELAY1 ;until it equals 0
RETURN ;Done, return to main program
;
; ***End of delay subroutine***
;
END
58
Part 2 PIC16F84 Code (A)
59
60
References
Alciatore, D.G., Histand, M.B. (2012) Introduction to Mechatronics and Measurement
Systems. 4th ed., New York: McGraw-Hill Companies, Inc.
Bolton, W. (2003) Mechatronics: Electronic Control Systems in Mechanical and
Electrical Engineering. 3rd ed., Harlow: Pearson Education Limited.
Electronics Hub. (2015) Exclusive OR Gate(XOR-Gate). [Internet], Available from:
<http://www.electronicshub.org/exclusive-or-gatexor-gate> [Accessed 20th March 2016].
Engineers Garage. (2012) Stepper Motors or Step Motors. [Internet], Available from:
<http://www.engineersgarage.com/articles/stepper-motors> [Accessed 15th April 2016].
Fraser, C., Milne, J. (1994) Integrated Electrical and Electronic Engineering for
Mechanical Engineers. Cambridge: McGraw-Hill International (UK) Limited.
Haugen, F. (2008) A quick guide to National Instruments USB-6009 and USB-6008
multifunction I/O devices. [Internet], Available from:<http://techteach.no/tekdok/usb6009/>
[Accessed 15th April 2016].
Learn About Electronics. (2015) What is a Unity Gain Buffer? [Internet], Available from:
<http://www.learningaboutelectronics.com/Articles/Unity-gain-buffer> [Accessed 25th March
2016].
LJ Create. (2007) Digiac 1750 Transducers and Instrumentation Trainer Technical
Manual PDF. [Internet], Available from: <Moodle> [Accessed 20th March 2016].
Macrosensors.com. (2014) LVDT Basics: What is an LVDT? [Internet], Available from
<http://www.macrosensors.com/lvdt_tutorial.html> [Accessed 15th April 2016].
Microchip Technology Incorporated. (2001) PIC16F84A Data Sheet. [Internet], Available
from:<http://ww1.microchip.com/downloads/en/DeviceDoc/35007b.pdf > [Accessed 20th
March 2016].
Microchip Technology Incorporated. (2008) PIC18F2420 Data Sheet. [Internet], Available
from:<http://ww1.microchip.com/downloads/en/DeviceDoc/39631E.pdf> [Accessed 10th
April 2016].
Onwubolu, G.C. (2005) Mechatronics Principles and Applications. Oxford: Elsevier
Butterworth-Heinemann.
PerkinElmer Optoelectronics. (2001) Photoconductive Cells and Analog Optoisolators
(Vactrols®). [Internet], Available from:
<http://pdf1.alldatasheet.com/datasheet-pdf/view/84374/PERKINELMER/VT900.html>
[Accessed 23rd April 2016].
61
Ross, D., Shamieh, C., McComb, G. (2010) Electronics for Dummies. Chichester: John
Wiley & sons Ltd.
Shipway, A., Shipway, S. (2008) Solenoid properties: Inductance and magnetic B-field.
[Internet], Available from:<http://www.calctool.org/CALC/phys/electromagnetism/solenoid>
[Accessed 15th April 2016].
Texas Instruments Incorporated. (2002) TPIC0107B PWM control intelligent H-bridge.
[Internet], Available from:<http://www.ti.com.cn/cn/lit/ds/symlink/tpic0107b.pdf> [Accessed
23rd April 2016].
Texas Instruments Incorporated. (2003) µA7800 Series Positive-Voltage Regulators.
[Internet], Available from:<https://www.sparkfun.com/datasheets/Components/LM7805.pdf>
[Accessed 23rd April 2016].
Texas Instruments Incorporated. (2013) DAC0800/DAC0802 8-Bit Digital-to-Analog
Converters. [Internet], Available from: <http://www.ti.com/lit/ds/symlink/dac0800.pdf>
[Accessed 22nd March 2016].
Texas Instruments Incorporated. (2015) µA741 General-Purpose Operational Amplifiers.
[Internet], Available from: <http://www.ti.com/lit/ds/symlink/ua741.pdf> [Accessed 25th
March 2016].
Texas Instruments Incorporated. (2016) L293x Quadruple Half-H Drivers. [Internet],
Available from: <http://www.ti.com/lit/ds/symlink/l293.pdf> [Accessed 23rd April 2016].
The Ron Dearing UTC Limited. (2015) What is Mechatronics? [Internet], Available from
<http://www.rondearingutc.com/about/what-is-mechatronics> [Accessed 20th March 2016].
Ward, R.L., (2016) Mechatronics: Module Handbook. [Internet], Available from:
<Moodle> [Accessed 20th March 2016].
Wright, H. (2001) Introduction to Programmable Logic Controllers (PLCs) and the
Operational Function of Main System Modules. [Internet], Available from:
<https://www.maximintegrated.com/en/app-notes/index.mvp/id/4701> [Accessed 20th March
2016].

Weitere ähnliche Inhalte

Was ist angesagt?

24 cnc machine feedback devices
24 cnc machine feedback devices24 cnc machine feedback devices
24 cnc machine feedback devices
Jupira Silva
 
Electric Actuator
Electric ActuatorElectric Actuator
Electric Actuator
diego5wh
 

Was ist angesagt? (20)

CNC & 3D Printing Lab Manual
CNC & 3D Printing Lab ManualCNC & 3D Printing Lab Manual
CNC & 3D Printing Lab Manual
 
1 introduction of mechatronics
1 introduction of mechatronics1 introduction of mechatronics
1 introduction of mechatronics
 
Stepper motor
Stepper motorStepper motor
Stepper motor
 
Working principle of dc motor
Working principle of dc motorWorking principle of dc motor
Working principle of dc motor
 
Fractional calculus and applications
Fractional calculus and applicationsFractional calculus and applications
Fractional calculus and applications
 
7.velocity analysis
7.velocity analysis7.velocity analysis
7.velocity analysis
 
Hydraulic actuators
Hydraulic actuatorsHydraulic actuators
Hydraulic actuators
 
Pe 3231 week 15 18 plc
Pe 3231 week 15 18  plcPe 3231 week 15 18  plc
Pe 3231 week 15 18 plc
 
Unit 4 Automated system
Unit 4 Automated systemUnit 4 Automated system
Unit 4 Automated system
 
1.me8791 mechatronics
1.me8791 mechatronics1.me8791 mechatronics
1.me8791 mechatronics
 
Motors
MotorsMotors
Motors
 
24 cnc machine feedback devices
24 cnc machine feedback devices24 cnc machine feedback devices
24 cnc machine feedback devices
 
Electric Actuator
Electric ActuatorElectric Actuator
Electric Actuator
 
Robotics position and orientation
Robotics position and orientationRobotics position and orientation
Robotics position and orientation
 
Heat and Mass Transfer Data Book_6th edition_by C.P. Kothandaraman & S. Subra...
Heat and Mass Transfer Data Book_6th edition_by C.P. Kothandaraman & S. Subra...Heat and Mass Transfer Data Book_6th edition_by C.P. Kothandaraman & S. Subra...
Heat and Mass Transfer Data Book_6th edition_by C.P. Kothandaraman & S. Subra...
 
Internship Report (MEchanical Engg) by kalpesh pawar
Internship Report (MEchanical Engg) by kalpesh pawarInternship Report (MEchanical Engg) by kalpesh pawar
Internship Report (MEchanical Engg) by kalpesh pawar
 
2 example of mechatronic systems
2 example of mechatronic systems2 example of mechatronic systems
2 example of mechatronic systems
 
automatic plant irrigation using aurdino and gsm technology
automatic plant irrigation using aurdino and gsm technologyautomatic plant irrigation using aurdino and gsm technology
automatic plant irrigation using aurdino and gsm technology
 
Introduction to mechatronics
Introduction to mechatronicsIntroduction to mechatronics
Introduction to mechatronics
 
Stepper Motor Types, Advantages And Applications
 Stepper Motor Types, Advantages And Applications Stepper Motor Types, Advantages And Applications
Stepper Motor Types, Advantages And Applications
 

Ähnlich wie mechatronics report

A REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODS
A REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODSA REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODS
A REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODS
Journal For Research
 
LIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATION
LIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATIONLIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATION
LIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATION
ijujournal
 
Speed Control of PMBLDC Motor using LPC 2148 – A Practical Approach
Speed Control of PMBLDC Motor using  LPC 2148 – A Practical Approach  Speed Control of PMBLDC Motor using  LPC 2148 – A Practical Approach
Speed Control of PMBLDC Motor using LPC 2148 – A Practical Approach
IJEEE
 
TORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHM
TORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHMTORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHM
TORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHM
ijics
 
Speed control of motor usinng matlab
Speed control of motor usinng  matlabSpeed control of motor usinng  matlab
Speed control of motor usinng matlab
shadabshaikh102
 
Comparison of dc motor speed control performance using fuzzy logic and model ...
Comparison of dc motor speed control performance using fuzzy logic and model ...Comparison of dc motor speed control performance using fuzzy logic and model ...
Comparison of dc motor speed control performance using fuzzy logic and model ...
Mustefa Jibril
 
FOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLER
FOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLERFOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLER
FOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLER
Journal For Research
 

Ähnlich wie mechatronics report (20)

Presentation200 (1).ppt
Presentation200 (1).pptPresentation200 (1).ppt
Presentation200 (1).ppt
 
Comparison of different controllers for the improvement of Dynamic response o...
Comparison of different controllers for the improvement of Dynamic response o...Comparison of different controllers for the improvement of Dynamic response o...
Comparison of different controllers for the improvement of Dynamic response o...
 
Mm project
Mm projectMm project
Mm project
 
Mm project
Mm projectMm project
Mm project
 
A REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODS
A REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODSA REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODS
A REVIEW :MODELLING OF BRUSHED DC MOTOR AND VARIOUS TYPE OF CONTROL METHODS
 
Closed loop performance investigation
Closed loop performance investigationClosed loop performance investigation
Closed loop performance investigation
 
An investigation on switching
An investigation on switchingAn investigation on switching
An investigation on switching
 
LIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATION
LIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATIONLIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATION
LIGHTWEIGHT MOBILE WEB SERVICE PROVISIONING FOR THE INTERNET OF THINGS MEDIATION
 
SPEED AND TORQUE CONTROL OF AN INDUCTION MOTOR WITH ANN BASED DTC
SPEED AND TORQUE CONTROL OF AN INDUCTION MOTOR WITH ANN BASED DTCSPEED AND TORQUE CONTROL OF AN INDUCTION MOTOR WITH ANN BASED DTC
SPEED AND TORQUE CONTROL OF AN INDUCTION MOTOR WITH ANN BASED DTC
 
Speed Control of Dc Motor using Adaptive PID with SMC Scheme
Speed Control of Dc Motor using Adaptive PID with SMC SchemeSpeed Control of Dc Motor using Adaptive PID with SMC Scheme
Speed Control of Dc Motor using Adaptive PID with SMC Scheme
 
C010511620
C010511620C010511620
C010511620
 
Rotor Resistance Adaptation Scheme Using Neural Learning Algorithm for a Fuzz...
Rotor Resistance Adaptation Scheme Using Neural Learning Algorithm for a Fuzz...Rotor Resistance Adaptation Scheme Using Neural Learning Algorithm for a Fuzz...
Rotor Resistance Adaptation Scheme Using Neural Learning Algorithm for a Fuzz...
 
Speed Control of PMBLDC Motor using LPC 2148 – A Practical Approach
Speed Control of PMBLDC Motor using  LPC 2148 – A Practical Approach  Speed Control of PMBLDC Motor using  LPC 2148 – A Practical Approach
Speed Control of PMBLDC Motor using LPC 2148 – A Practical Approach
 
TORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHM
TORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHMTORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHM
TORQUE CONTROL OF AC MOTOR WITH FOPID CONTROLLER BASED ON FUZZY NEURAL ALGORITHM
 
Speed control of motor usinng matlab
Speed control of motor usinng  matlabSpeed control of motor usinng  matlab
Speed control of motor usinng matlab
 
Matlab simulation on chopper based speed control of dc motor: A Review
Matlab simulation on chopper based speed control of dc motor: A ReviewMatlab simulation on chopper based speed control of dc motor: A Review
Matlab simulation on chopper based speed control of dc motor: A Review
 
Comparison of dc motor speed control performance using fuzzy logic and model ...
Comparison of dc motor speed control performance using fuzzy logic and model ...Comparison of dc motor speed control performance using fuzzy logic and model ...
Comparison of dc motor speed control performance using fuzzy logic and model ...
 
FOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLER
FOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLERFOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLER
FOUR QUADRANT SPEED CONTROL OF DC MOTOR USING AT89S52 MICROCONTROLLER
 
Batch 05.pptx
Batch 05.pptxBatch 05.pptx
Batch 05.pptx
 
Design and implementation speed control system of DC Motor based on PID contr...
Design and implementation speed control system of DC Motor based on PID contr...Design and implementation speed control system of DC Motor based on PID contr...
Design and implementation speed control system of DC Motor based on PID contr...
 

mechatronics report

  • 1. MECHATRONICS Theoretical and Practical Mechatronic Investigations A10938
  • 2. 1 Contents Introduction…………………………………………………………………………………p2 Part 1 Fixed Speed Bi-directional Control of a 12V DC Motor…………………………………….p4 Part 2 Speed Control of Electric Motors…………………………………………………………...p17 Part 3 Investigation of PWM Control of DC Motor (Pulse Width Modulation)…………………..p30 Part 4 Mechatronics and Embedded Systems (2 Problems)……………………………………….p36 Part 5 Mechatronics Case Studies (Neoprene tube cutting system)……………………………….p42 Conclusion………………………………………………………………………………….p51 Appendices Appendix 1………………………………………………………………………………….p52 Appendix 2………………………………………………………………………………….p55 Appendix 3………………………………………………………………………………….p59 References………………………………………………………………………………….p60
  • 3. 2 Introduction Mechatronics is a fusion of mechanical, electronic, electrical and computer engineering to create a more efficient, cost effective, and simplified system. Mechatronics was first conceived in 1969 by Tetsuro Mori from Japan and is today a major part of engineering used throughout industry. Originally mechatronics was conceived with just mechanical and electronic engineering in mind, however with the development of computers and microcontrollers the field grew to combine more systems together. Nowadays mechatronics is vital as it has many applications that are used in varying sectors within industry. “Mechatronics combines electronics engineering and computer technology within multi- disciplinary applications pertaining to the control of mechanical systems and processes. These systems might include complex mechanisms, dynamical elements, thermal and chemical processes, flexible manufacturing operations or any combination of these. This invariably means that mechatronics is very diverse in its applications.” (Fraser et al, 1994, p2) As various sectors needed mechatronics for problems with processes, these sectors became interlinked and created simplified systems to solve the problems. One of the best examples is within the automotive industry, as there are robots working on the production line to aid with efficiency and these were created by mechanical means but controlled by electronic systems. Below is a picture of a graphical representation of the integration of some of the various sectors and sub-systems that is within mechatronics. Graphical Representation of Mechatronics (The Ron Dearing UTC Limited, 2015, accessed 2016)
  • 4. 3 As we can see from the picture on the previous page how mechatronics inter links the various sectors and sub-systems within engineering. It also represents how important each sub-system is to each other and how the synergistic nature of mechatronics is beneficial to each sub- system to create a better overall system. “A mechatronic system is not just a marriage of electrical and mechanical systems and is more than just a control system; it is a complete integration of all of them.” (Bolton, 2003, p1) For this report I was tasked with the investigation of various aspects of mechatronics mainly about control of a d.c. motor. Throughout the semester I built and tested various systems to overcome the problems presented to me in the lab and recorded the results to analyse the data collected to confirm the circuit was working as expected. These problems involved building systems incorporating programmable logic controllers as well as PIC microcontrollers namely a PIC16F84 microcontroller and pulse width modulation for the control sub-systems. I also had to investigate two mechatronic problems where I had to devise concepts of systems to find solutions so the systems would operate correctly. This report has been created to document the various stages of my investigations and were carried out by either practically building the circuits in the lab or conceptually in the form of mini reports.
  • 5. 4 Part 1 Fixed Speed Bi-directional Control of a 12V D.C. Motor Throughout industry many systems require bi-directional motor control and it is used in pumps, compressors, fans, wheels etc. For this part of my investigations I was tasked with creating a similar system. Using 2 LJ Trainer units I had to configure a system to control a small 12V d.c. motor at a fixed speed in both clockwise and anti-clockwise directions. The LJ Trainer I used, was the DIGIAC 1750 unit as seen in the picture below. The LJ Trainer Digiac 1750 Unit (LJ Create, 2007, accessed 2016) The DIGIAC 1750 unit is an excellent bit of kit and can be used to build various systems for experiment purposes. Within the unit is input sensors, output actuators, display devices and signal conditioning circuits. It also has various power supplies, light sources and compressed air supplies to experiment with. Also with the unit, it is possible to build and test closed loop systems for rotary speed and position. For my investigations the system needed to be controlled by first a Programmable Logic Controller(PLC) and then a PIC16F84 Microcontroller. First I drew up the block diagram for the system which can be seen on the next page.
  • 6. 5 Part 1 Overall System Block Diagram From the block diagram I needed to then devise a schematic diagram for the system as shown in the picture below. Detailed Circuit Schematic Diagram From the schematic, when a PLC or PIC16F84 transmits a signal at the base of either NPN transistors via terminals A or B, the transistor becomes closed circuit and this means 0V is connected to the bottom of the relay via the collector. As the relay has 12V permanently connected to the top of the relay, this will create a path to earth through the load in the coil and this then pulls the switch towards the normally open contact. Therefore, when one of the relays has a contact normally closed and the other one has a contact normally open, the motor should run in one direction. The diodes in the schematic are there to aid with the reduction of back EMF on the relay. The relay layout and circuit schematic diagram from the 1750 unit can be seen in the pictures on the next page.
  • 7. 6 1750 Unit Relay Layout (LJ Create, 2007, accessed 2016) 1750 Unit Relay Circuit Schematic Diagram (LJ Create, 2007, accessed 2016) The d.c. motor I used was the same as one that was in the 1750 unit and below is a picture of the d.c motor layout. 1750 Unit D.C. Motor Layout (LJ Create, 2007, accessed 2016) With the d.c. motor in the 1750 unit, current is supplied to the coils via brushes and commutator and this causes forces to be exerted on the rotor which makes it spin. Also as seen in the schematic diagram on the next page, motor current passes through R45 and creates a voltage across it which is proportional to the torque loading.
  • 8. 7 1750 Unit D.C. Motor Circuit Schematic Diagram (LJ Create, 2007, accessed 2016) Usually with normal d.c motors, their rotation is determined by the applied voltage and polarity of such voltage. Also their speed is determined by the current that flows through the windings. “A d.c motor has two terminals, and when d.c. flows in one terminal (the other being grounded), the motor spins in one direction. When current flows in the other terminal (and the first is grounded), the motor spins in the opposite direction. That is, by switching the polarity of the terminals, the direction of the motor is reversed. The motor’s speed is controlled by varying the current supplied.” (Onwubolu, 2005, p320) Next I had to derive a truth table for the desired operation of the circuit and this can be seen in the picture below. Circuit Truth Table A B Motor 0 0 OFF 0 1 ON (Clockwise) 1 0 ON (Anti-Clockwise) 1 1 OFF After completing the truth table, it became apparent that it was identical to the truth table for an XOR Gate. This can be seen in the picture on the next page.
  • 9. 8 XOR Truth Table (Electronics Hub, 2015, accessed 2016) The truth table above as well as on the previous page shows that there will only be an output when only 1 input is at logic 1 and the other input is at logic 0. This can also be expressed by the Boolean equation; As I mentioned earlier the system was to be first controlled by a PLC. A Programmable Logic Controller or PLC is a digital computer that has multiple inputs and outputs. A PLC is used for the automation of various electromechanical processes within industry. They are designed to withstand varying temperature ranges, electrical noise, moister, vibration and impact. Because of these factors, PLCs are extremely reliable and therefore used substantially around the world. “Programmable logic controllers (PLCs) have been an integral part of factory automation and industrial process control for decades. PLCs control a wide array of applications from simple lighting functions to environmental systems to chemical processing plants.” (Wright, 2010, accessed 2016) PLCs were first introduced in the late 1960s by inventor Richard Morley to supply systems with the same functions as relay logic systems because relay systems at the time tended to fail. This created delays and PLCs were implemented into industry to replace the relay logic circuits which were unreliable and took too long to re-wire if a company chose to change their production process. PLCs analyse the inputs and control the outputs depending on what the PLC is programmed to do. Therefore, the inputs are scanned and the outputs are operated in relation to the information programmed into the PLC. Programs to control machine operation are typically stored in battery-backed-up or non-volatile memory. PLCs are easy to program and don’t need any special training. Once a code is programmed into the PLC, the machine would work autonomously, therefore removing people from doing boring repetitive work like on a factory line. PLCs can also make calculations quickly and as a result it speeded up certain processes, increasing efficiency. The PLC I used in my investigations was a Mitsubishi F1 and on the next page is a photo of the PLC I used.
  • 10. 9 Mitsubishi F1 PLC The Mitsibushi F1 PLC has various inputs. outputs, timers and counters as outlined below; Inputs 400  413 Outputs 430  Typically 437 Timers 50  57 Counters 60  67 The outputs I used in my investigations were 430 and 431 and below is a picture of the desired PLC output I was trying to achieve. Desired PLC Output Next I had to devise a ladder logic to create the program that was to be entered into the PLC for the system to operate correctly. For this to work I first investigated the ladder logic for a one shot timer and this can be seen in the picture below. One Shot Timer Ladder Logic From the ladder logic above, I could then derive the code that would be inputted into the PLC and can be seen in the picture on the next page.
  • 11. 10 One Shot Timer PLC Programming Code However, as this is not sufficient for the system I was investigating, I needed to try and expand on the idea of a one shot timer. Therefore, by overlapping 2 one shot timers, this would give us the correct code to program the PLC for the system to operate correctly. Below is a picture of the output I was aiming for. Two Overlapping One Shot Timers Output From all the information I have gathered so far I could derive a ladder logic for the circuit which can be seen in the picture below. Final System Ladder Logic
  • 12. 11 From the ladder logic on the previous page I could then derive the code that would be inputted into the PLC and this can be seen in the picture below. Final PLC Programming Code I then tested this programming code by inputting it into the PLC whilst it was not connected to the LJ Trainer/d.c. motor circuit and ran the program. Whilst it was running I could observe that the output LEDs for 430 & 431 outputs were switching on and off at the correct intervals. I then connected the PLC to the LJ Trainers and d.c. motor which can be seen in the photos below as well as on the next page. Part 1 PLC and DC Motor
  • 13. 12 Part 1 DIGIAC 1750 LJ Trainer Unit Part 1 PLC Overall System I then ran the program and when doing this I observed the motor reacting the way I wanted it to. First there was a delay of 5 seconds and then the motor spun in a clockwise direction for 5 seconds. Next the motor stopped for 5 seconds before it spun anti-clockwise for 5 seconds and then finally the motor stopped.
  • 14. 13 Next the system had to be controlled by a PIC Microcontroller. Microcontrollers are a single integrated circuit which has a CPU, memory and input/output interfaces within it. It is like a microcomputer system in one small chip. It is suitable for various applications because of versatile input/output capabilities and with it being a single integrated circuit the power requirements are low for a system. A microcontroller is an excellent bit of kit as you can connect it to a PC via a development board to program it with C programming language and reprogram it with little effort other than altering some code. "The great thing about a microcontroller is that you can simply alter a few lines of code or reprogram it completely to change what it does; you don't need to swap out wires, resistors and other components in order to get this flexible IC to take on a new personality" (Ross et al, 2010, p161). The microcontroller I used was the PIC16F84 which is manufactured by Microchip Corp and is a very basic, widely used microcontroller. Another good reason to focus on the PIC16F84 is that many other PIC microcontrollers are upward and pin compatible with the PIC16F84 so everything learned can be applied to other PIC microcontrollers. The PIC16F84 comes in an 18 pin direct in line package and it has a CPU, bi-directional I/O ports, data memory, program memory and timer/counters. Below is a picture of the pin layout diagram of the PIC16F84. PIC16F84 Pin Layout Diagram (Microchip Technology Incorporated, 2005, accessed 2016) The PIC16F84 incorporates Harvard architecture rather than Von-Neuman, so it uses separate buses for data and program memory which allows simultaneous access to both memories and increases speed within the microcontroller. “It uses the Harvard architecture since its program memory and data memory are accessed from different memories. This offers an improvement over the von Neumann architecture in which the program and data are accessed simultaneously from the same memory (accessed over the same bus).” (Onwubolu, 2005, p210) When designing a system to be controlled by a micro controller it is good practice to create a flow chart of how you want the system to operate and the flow chart helps when compiling the code. A picture of my flow chart for the system in part 1 can be seen on the next page.
  • 15. 14 Part 1 System Flow Chart As seen in my flow chart, first I needed to set up the registers and I/O ports so that the controller knows which ports are designated inputs and outputs. Then I needed to set the system to switch the motor on clockwise for a set time and then switch the motor off for a set time delay. Next I had to set the system to make the motor spin anti-clockwise for a set time before switching the motor off for a set time delay and then the whole process would repeat again. To create a delay on the PIC16F84 I had to create loops for the program to run through until it is called to carry out another task. Each operation on the PIC takes 20 microseconds so these loops are made up of hundreds or thousands of single operations to create a delay of only a few seconds. When I was happy with the flow chart so that the system would operate correctly, I could begin with compiling the code that was required. An assembly language program is a text file which has a specific format and each instruction is represented by a line of code, which is divided into 4 fields. These are called label, operation, operand and comment fields. The label field is optional and the operation field is an instruction which is represented by a mnemonic code. The operand field may or may not be needed as this depends on the instruction and the comment field is optional, however it is good programming practice to include comments. All fields must be separated by at least one space which is called a separator and all comments must be proceeded by a semi-colon which nulls the comment from the line of code. First I was given a code for a basic traffic light system that I could adapt to make the motor spin clockwise and then anti-clockwise. My final code can be seen in Appendix 1.
  • 16. 15 As we can see from the code in Appendix 1, before compiling the main program I mentioned which PIC I am using as well as a title and a brief description of the process I am trying to achieve. Then as mentioned earlier in my flow chart, first I wrote code to set up the registers and I/O ports. As we can see there were 3 file registers allocated for STATUS, PORTA and TRISA. There were also 3 general purpose registers for R0, R1 and R2 which are used to create the delays in the code. RPO is allocated for bit 5 of STATUS and Count 1 & 2 have been defined to create the outer delay of a value of 133 as well as an inner delay of a value of 250. Within the main code I only used operation, operand and comment fields as I discarded the label field, because this field was not needed. At the beginning of the main code I initialized PORTA as all outputs. Then as I was trying to replicate the same function as an XOR logic gate and was only using the first 2 bits of an 8-bit binary code, I stated the initial starting point be a binary input of 00000000. This would replicate the bit pattern for terminals A=0 and B=0. Next I would output this binary input to the motor via PORTA and this would be the starting point of the process and the motor would be off. I then created a delay of 2 seconds so that the motor would remain off for the duration of the delay. Next there was a binary input of 00000001. This would replicate the bit pattern for terminals A=0 and B=1, which would be outputted to the motor via PORTA and this would start the motor rotating in a clockwise direction. Once again I created a delay of 2 seconds so that the motor would rotate clockwise for the duration of the delay. Then there was a binary input of 00000011. This would replicate the bit pattern for terminals A=1 and B=1, which would be outputted to the motor via PORTA and this would stop the motor rotating. As the same as before I created a delay of 2 seconds so that the motor would remain off for the duration of the delay. Next there was a binary input of 00000010. This would replicate the bit pattern for terminals A=1 and B=0, which would be outputted to the motor via PORTA and this would start the motor rotating in an anti-clockwise direction. Just as before I then created a delay of 2 seconds so that the motor would rotate clockwise for the duration of the delay. Then the program would go to the beginning of the code, therefore repeating the whole process and would keep on doing this while power was supplied or until the program was overwritten. Finally, the delay subroutine needed to be defined so that the system operated correctly where the value passed to the routine in the working register is a time delay multiplied by 0.1 seconds. So the value for the working register would be allocated into R0 and would be a value of 10 per, a second delay. Therefore, for a 2 second delay this figure would be 20 (20 x 0.1) and as we can see from my code the value for each delay I inputted was 20. Next the inner and outer delays needed to be placed in R1 & R2 and these along with R0 would decrement the delays repeatedly until it reaches zero. Then the code returns back to the main program. After I had compiled the code in notepad I could transfer it to MPLAB and this created an hex.file which was then entered into PPP. Next I made sure the watchdog timer was disabled and the correct clock configuration was applied. I then uploaded the PPP code onto the PIC16F84 from a PC via a development board. The development board can be seen in the photo on the next page.
  • 17. 16 PIC Development Board After I had transferred the code to the PIC16F84 and applied some power I observed the motor initially did not rotate for 2 seconds then it spun in a clockwise direction for 2 seconds. Next it stopped rotating for 2 seconds before it rotated in an anti-clockwise direction for 2 seconds. Then the motor stopped rotating for 2 seconds before repeating the whole process again and would keep repeating the whole process as long as there was power supplied. Below is a photo of the PIC16F84 overall system. Part 1 PIC16F84 Overall System This system was quite easy to construct and I was able to complete my investigations successfully. With both the PLC and PIC16F84, the motor reacted the way I was expecting. This proved that the PLC and PIC were programmed correctly as well as the overall system was correctly configured. Also the development board is a good bit of kit when testing the code that was uploaded onto the PIC16F84.
  • 18. 17 Part 2 Speed Control of Electric Motors For this part of my investigations I was tasked with investigating variable speed control of a bipolar d.c. motor and many mechatronic systems require specific motor velocity profiles. One that is particularly widely used is the trapezoidal velocity profile as seen in the picture below. Trapezoidal Velocity Profile From this profile we can see that the motor accelerates or ramps up to its maximum speed rotating clockwise before holding that speed for a set amount of time. It then decelerates or ramps back down to zero, before accelerating in an anti-clockwise rotation to its maximum speed, holding that speed for a set amount of time and then it decelerates back to zero speed. As I mentioned in part 1 the speed of a d.c. motor is proportional to the applied voltage. Therefore, the motor needs a trapezoidal velocity profile and this can be created using a PIC microcontroller with a digital to analogue converter (DAC). With electronic systems like the one I was investigating, the information needs to be converted between analogue and digital states and to do this, analogue to digital converters (ADC) and digital to analogue converters (DAC) are used. “Circuitry is, therefore, required that is able to interface between the analogue world outside the system and the digital system itself. The two interface circuits that are necessary are the ADC and the DAC.” (Green, 1999, p329). With a PIC-DAC combination, the acceleration stage (ramp up) can be achieved using a PIC to output a continuously increasing binary number to the DAC which then converts such binary numbers into an analogue voltage to power the motor. The process for deceleration is the same, however the PIC will output a continuously decreasing binary number to the DAC.
  • 19. 18 A key aspect of the trapezoidal velocity profile is bi-directional motion (clockwise and anti- clockwise) and speed. Therefore, the PIC-DAC combination must be capable of both positive and negative voltages to the motor. The DAC I used in my investigations is the DAC0800 and this was chosen because it has a feature that facilitates this. Below is a picture of the pin layout diagram of the DAC0800. DAC0800 Pin Layout Diagram (Texas Instruments Incorporated, 2013, accessed 2016) This DAC is based around an R-2R resistor ladder and the output is dependent on the binary input on each input switch. DAC0800 R2R Ladder Block Diagram (Texas Instruments Incorporated, 2013, accessed 2016)
  • 20. 19 Next I devised the ideal operating circuit for the DAC0800 and this can be seen below. DAC0800 Ideal Operating Circuit As we can see in the picture above, the output of the DAC0800 comprises of two analogue currents, Iout (pin4) and /Iout (pin2) and the range of values for these two currents is determined by the value of the reference current (IRef) into pin 14. This is set by the resistor R14 and the supply voltage. The output at Iout is proportional to the value of the byte (8 bit- word) of information provided at the binary inputs. Therefore, this can be calculated with the equation seen below. /Iout = IRef – Iout As I mentioned earlier the DAC0800 uses an R-2R ladder circuit to give an output current Iout which is a fraction of IRef and that is determined by the binary input value. Iout = IRef x n/256 /Iout = IRef – Iout Therefore, Iout + /Iout is always equal to IRef and as the binary input increases from zero, Iout increases from zero and /Iout decreases from IRef. So for example when the binary input is zero, Iout = 0 and /Iout is equal to IRef. Then if the binary input is 255, Iout is equal to IRef and /Iout = 0.
  • 21. 20 As mentioned earlier a bipolar output voltage is needed and this is achieved by using an op- amp which has both of the DAC inputs, Iout (pin4) and /Iout (pin2) as its inputs. The op-amp I used in my investigations was the 741 op-amp. Below is a picture of the pin layout diagram and typical application for the 741 op-amp. 741 Op-amp Pin Layout Diagram (Texas Instruments Incorporated, 2015, Accessed 2016) Typical Application for a 741 Op-amp (Texas Instruments Incorporated, 2015, Accessed 2016) The 741 Op-amp is a differential amplifier with a very high input impedance and low output impedance therefore no current flows in the input terminals. It has an extremely high gain which would cause the chip to saturate without any control over this gain. The gain of a 741 Op-amp is controlled by using external components which are an input resistor and a feedback resistor. The ratio between these resistances set the gain just like a voltage divider circuit. Also the point where the input and feedback resistors meet is known as a virtual earth and can be thought of as 0 Volts. “The operational amplifier is a high gain d.c. amplifier, the gain typically being of the order of 100 000 or more, that is supplied as an integrated circuit on a silicon chip. It has two inputs, known as the inverting input (-) and the non-inverting input (+). The output depends on the connections made to these inputs.” (Bolton, 2003, p58) The 741 Op-amp is widely used and even though faster more precise Op-amps are available, it is still the most popular due to its ease of use and wide variety of applications. On the next page is a block diagram of the overall system which incorporates the PIC-DAC combination connected to a 741 op-amp, which is then connected to a DIGIAC 1750 unit for an amplifier, power amplifier and DC motor.
  • 22. 21 Part 2 Overall System Block Diagram From the block diagram I needed to then devise a circuit wiring diagram for the system as shown in the picture below. Final Circuit Wiring Diagram From the picture above, by using an op-amp which has both of the DAC outputs, Iout (pin4) and /Iout (pin2) as its inputs allows the circuit to achieve a bipolar output voltage. Therefore, with an input of; 000000002 (010) then I1 = Iout = 0 and I2 = /Iout = IRef Then at the op-amp; V+ = -IRef x R Volts V- = -IRef x R Volts Therefore; Vo = -IRef x R
  • 23. 22 Also with an input of; 100000002 (12810) then I1 = Iout = ½ IRef and I2 = /Iout = ½ IRef Then at the op-amp; V+ = - ½ IRef x R Volts V- = - ½ IRef x R Volts So; Vo = V- + (I1 x R) = - ½ IRef x R + ½ IRef x R Hence; Vo = 0V Finally, with an input of; 111111112 (25510) then I1 = Iout = IRef and I2 = /Iout = 0 Then at the op-amp; V+ = 0V V- = 0V Hence; Vo = +IREF x R Thus, the circuit has a symmetrical bipolar output voltage range as required for the motor drive for the system I was trying to create as seen in the table below. Symmetrical Bipolar Output Voltage Range Table Binary Input Output (V) 00000000 - IRef x R 10000000 0 11111111 +IRef x R From the table above we can calculate what binary inputs are needed for clockwise and anti- clockwise rotation of the d.c. motor. For zero speed the PIC should output the binary number 10000000 to the DAC. To achieve clockwise rotation, the PIC should output a binary number greater than 10000000 and to achieve an anti-clockwise rotation, the PIC should output a binary number less than 10000000.
  • 24. 23 Next I had to calculate the circuit resistance values for Rref. So from the DAC data sheet and assuming a VCC of 5V, Iout is proportional to the binary input. Hence, Iout maximum = VRef/Rref with a maximum value of, IRef = 2mA Although a convenient figure for IRef is 0.5mA so using, Vcc/Rref = IRef Then using Ohms law to transpose it to, Vcc/ IRef = Rref 5V/0.5mA = 10KΩ RRef = 10KΩ As we can see from the above calculations and in my final circuit wiring diagram I used 10KΩ resistors for RRef on pins 14 and 15 on the DAC. Then I had to calculate the circuit resistance values for R, which are the input and feedback resistors for the 741 Op-amp. From previous analyses, the output range is, A convenient voltage range, for the motor we are using before it is amplified is around, So when using IRef = 0.5mA this gives, R = 5KΩ However, I could not use a 5KΩ resistor as I did not have one and neither did the store room in college so I used the nearest preferred value which was 4.7KΩ. As we can see from the above calculations and in my final circuit wiring diagram I used 4.7KΩ resistors for R, for the input and feedback resistors on the 741 Op-amp. Therefore, for the circuit I was investigating the output voltage from the 741 Op-amp would be, Vout(+) = 0.5mA x 4.7KΩ = + 2.35V Vout(-) = 0.5mA x 4.7KΩ = - 2.35V For the purposes of my investigations and with the 741 Op-amp output being only + or – 2.35V, this voltage needed to be amplified. Therefore, I connected the output of the 741 Op- amp to an amplifier on the 1750 unit. On the next page is a schematic diagram for the amplifier in the 1750 unit.
  • 25. 24 1750 Unit Amplifier Schematic Diagram (LJ Create, 2007, accessed 2016) This is an amplifier with a fully variable gain from 0.1 to 100 and an offset from -5V to +5V. IC12a is a unity gain inverter, with offset control and its output feeds the fine gain control. The gain is selected by S6, which switches in various combinations of feedback resisters. To avoid the need for excessively high values, the feedback is taken from the junction of R113 and R114. These attenuate the output signal by a factor of 100 and thus allows the same reduction in the feedback resisters. For my investigations the gain on this amplifier was set to 5 as this would amplify the 741 Op-amp output voltage to + or – 11.75V which is more of a suitable output voltage range for the motors to operate correctly for my investigations. At the output of the amplifier on the 1750 unit, there is a power amplifier connected and this is there to increase the amperes at the 741 op-amps output. Below is a schematic diagram for it. 1750 Unit Power Amplifier Schematic Diagram (LJ Create, 2007, accessed 2016) The IC11 is a power op-amp and is configured as a unity gain buffer and will provide a gain of 1. This is important as there is very little current been drawn into the circuit because the 741 Op-amp has a high impedance and the amplifier will not affect the original circuit. Therefore, it provides the same voltage at the output that was inputted into the circuit, thus protecting the signal. “This is the reason unity gain buffers are used. They draw very little current, not disturbing the original circuit, and give the same voltage signal as output. They act as isolation buffers, isolating a circuit so that the power of a circuit is disturbed very little.” (Learn About Electronics, 2015, accessed 2016)
  • 26. 25 For this part of my investigations I was tasked with creating a system to control a d.c. motor where there is acceleration to maximum speed in a clockwise direction and after a time span of continuous speed, deceleration to zero speed. Then acceleration to maximum speed in an anti-clockwise direction and after a time span of continuous speed, deceleration to zero speed. At the start of this chapter, I mentioned for speed control of a d.c. motor the trapezoidal velocity profile is used and below is a picture of the ideal profile required for my system to operate correctly. Ideal System Trapezoidal Velocity Profile From the picture above we can see the different stages of the profile with reference to the binary inputs. Zero speed is achieved with a binary input of 10000000 (128) and for the motor to accelerate to maximum speed the output needs to be incremented up 100 steps to a binary input of 11100100 (228). For 100 steps in 2 seconds, for the motor to ramp up to maximum speed, the time delay between each steps is 20msecs and this is calculated by dividing 2 seconds by 100 steps. Then the motor should hold the maximum speed for 5 seconds before decelerating back to zero and then accelerating to maximum speed in an anticlockwise direction. The maximum anti-clockwise speed is achieved by decrementing the output down 200 steps from the binary input 11100100 (228) to a binary input of 00011100 (28). Next the motor should hold this maximum anti-clockwise speed for 5 seconds before decelerating back to zero speed and to achieve this the output would be incremented 100 steps up from 00011100 (28) back up to 10000000 (128). The overall time for the motor to react to these instructions should be 18 seconds. Once again I created a flow chart of how I wanted the system to operate. A picture of my flow chart for how I want the system to operate in part 2 can be seen on the next page.
  • 27. 26 Part 2 System Flow Chart As seen in my flow chart, for my system I needed to first set up the registers and I/O ports so that the controller knows which ports are designated inputs and outputs. Then I needed to set the system with an initial binary output of 10000000. This is the motors zero speed which is the starting point of my code and this would delay the motor from rotating for a period of 5 seconds. After that I wanted to increment the drive(R3) up 100 steps from 10000000 to 11100100 and this would accelerate the motor to the required maximum speed in a clockwise direction. Next the system would check if the maximum speed was achieved. If it had not, it would repeat the previous stage and if the maximum speed was reached, it would rotate in a clockwise direction for 5 seconds. After 5 seconds the drive(R3) would decrement 200 steps from 11100100 to 00011100 back to zero speed and then accelerate into reverse or an anticlockwise direction before checking if the reverse maximum speed had been achieved. If it had not, it would repeat the previous stage and if the maximum speed was reached it would rotate in an anti-clockwise direction for 5 seconds. Finally, the drive(R3) would be incremented up 100 steps from 00011100 to 10000000 back to zero speed and if zero speed had not been achieved the previous stage would be repeated. If zero speed had been achieved the motor would not rotate in any direction for a period of 5 seconds and then the whole process would repeat from the beginning again. When I was happy with the flow chart so that the system would operate correctly, I could begin with compiling the code that was required. First I was given part of a code that I could adapt and my final code can be seen in Appendix 2.
  • 28. 27 As we can see from the code in Appendix 2, before compiling the main program I mentioned which PIC I am using as well as a title and a brief description of the process I am trying to achieve. Then as mentioned earlier in my flow chart, first I wrote code to set up the registers and I/O ports. As we can see there were 3 file registers allocated for STATUS, PORTB and TRISB. There were also 3 general purpose registers for R0, R1 and R2 which are used to create the delays in the code. Then I changed the name of drive to R3 for simplicity and this is a register for the output to the motor which is a variable value. R4 is implemented as a loop counter for acceleration and deceleration. RPO is allocated for bit 5 of STATUS and Z for bit 2 of STATUS. Count 1 & 2 have been defined to create the outer delay of a value of 133 as well as an inner delay of a value of 50. Within the main code I only used operation, operand and comment fields as I discarded the label field, because this field was not needed. At the beginning of the main code I initialized PORTB as all outputs and I stated the initial starting point be a binary input of 10000000 which represents zero speed. This would output that binary input from R3 to the motor on the 1750 unit via PORTB on the PIC that is connected to the DAC and 741 Op-amp. This would be the starting point of the process where the motor would be off. I then created a delay of 5 seconds (250 x 20msecs) so that the motor would remain at zero speed for the duration of the delay. Next the binary input of 10000000 would be incremented up 100 steps. R4 is then implemented which would make the motor accelerate and then with R3 incremented up to a bit pattern of 11100100, this instruction is then outputted to PORTB then to the motor. Next an instruction is implemented where a 20msec delay is inputted into the working register before R4 is decremented causing the motor to slow its acceleration so that the designated maximum clockwise speed is continuous. Then if the maximum speed was not achieved the loop would be repeated. I then created a delay of 5 seconds (250 x 20msecs) so that the motor would remain at maximum clockwise speed for the duration of the delay. Then the binary input of 11100100 would be decremented down 200 steps. R4 is then implemented which would make the motor decelerate back to zero speed and then accelerate in an anticlockwise direction. Next with R3 decremented down to a bit pattern of 00011100, this instruction is then outputted to PORTB then to the motor. As before an instruction is implemented where a 20msec delay is inputted into the working register before R4 is decremented causing the motor to slow its acceleration so that the designated maximum anti- clockwise speed is continuous. Then if the maximum speed was not achieved the loop would be repeated. I then created a delay of 5 seconds (250 x 20msecs) so that the motor would remain at maximum anti-clockwise speed for the duration of the delay. Next the binary input of 00011100 would be incremented back up 100 steps. R4 is then implemented again which would make the motor accelerate and then R3 is incremented back up to a bit pattern of 10000000 which is zero speed. This instruction is then outputted to PORTB then to the motor. Again an instruction is implemented where a 20msec delay is inputted into the working register before R4 is decremented causing the motor to slow its acceleration so that zero speed is achieved. Then if zero speed is not achieved the loop would be repeated. I then created a delay of 5 seconds (250 x 20msecs) so that the motor would remain at zero speed for the duration of the delay.
  • 29. 28 Finally, the delay subroutine needed to be defined so that the system operated correctly where the value passed to the routine in the working register is a time delay multiplied by 20 micro seconds. So the value for the working register would be allocated into R0 and would be a value of 50 per, a second delay. Therefore, for a 5 second delay this figure would be 250 (50 x 5) and as we can see from my code the value for each delay I inputted was 250. Next the inner and outer delays needed to be placed in R1 & R2 and these along with R0 would decrement the delays repeatedly until it reaches zero. Then the code returns back to the main program. After I had compiled the code in notepad I could transfer it to MPLAB and this created an hex.file which was then entered into PPP. Next I made sure the watchdog timer was disabled and the correct clock configuration was applied. I then uploaded the PPP code onto the PIC16F84 from a PC via a development board. The development board and DAC circuit along with the 741 Op-amp can be seen in the photo below. Part 2 PIC-DAC Combination with 741 Op-amp On the next page is a photo of the 1750 unit showing the wiring from the DAC to the amplifier, power amplifier and DC motor.
  • 30. 29 Part 2 DIGIAC 1750 LJ Trainer Unit After connecting the full system together, I then applied some power and began to observe the motor. Initially the motor did not rotate, then after 5 seconds the motor slowly ramped up to the maximum speed in a clockwise direction and it held this maximum speed for 5 seconds. Then the speed ramped down to zero speed before accelerating in an anti-clockwise direction until it reached the maximum anti-clockwise speed and it held this speed for 5 seconds. Finally, after 5 seconds the motor decelerated until it reached zero speed and then the whole process began to repeat again. This would continue to happen as long as power was supplied to the system. Also one of the outputs from the amplifier on the 1750 unit was connected to the moving coil meter, which is an analogue voltage meter and the movement of this meter represented the negative and positive voltages being applied to the circuit. Therefore, after 5 seconds when the motor accelerated and spun in a clockwise direction, I could see the dial moving through the positive voltage range up to near 12V where it held this value while the motor spun clockwise at its maximum speed. Then as the motor decelerated and then accelerated in an anti-clockwise direction the dial moved down through the positive voltage range, through 0V, then through the negative voltage range down towards near -12V. It then held this voltage while the motor spun anti-clockwise at its maximum speed. Finally, as the motor decelerated to a full stop the dial moved up through the negative voltage range until stopping at 0V before repeating the whole process. This system was quite easy to construct and I was able to complete my investigations successfully. The motor reacted the way I was expecting and this proved that the PIC was programmed correctly as well as the overall system was correctly configured.
  • 31. 30 Part 3 Investigation of PWM Control of DC Motor (Pulse Width Modulation) Pulse width modulation (PWM) is a form of signal modulation used in control applications and it is especially useful for loads that have inertia to break in order to start them moving such as electric motors. PWM operates by switching the voltage on an off at very high speeds using a power transistor such as a MOSFET and the speed of the motor can be altered by varying the pulse width. Therefore, when the pulse is wider this means the signal is on more and the speed of the motor will increase as there is more power available. This is called the duty cycle and corresponds to the amount of signal on time in a cycle compared to the amount of time off. The lower the duty cycle the lower the power is available to the system. “As the duty cycle grows larger, the average current grows larger and the motor speed increases.” (Alciatore et al, 2012, p448) Below is a picture of varying duty cycles. Varying Duty Cycles As we can see from the picture above, T represents the overall period of PWM signal, which is made up of the sum of t on and t off. When the signal is on this is represented by t on and when the signal is off this is represented by t off, therefore, t on + t off = T. With PWM, the amplitude and frequency are constant for a PWM signal so the duty cycle can be calculated with the following formulas; Duty Cycle = t on / (t off + t on) = t on / T Duty Cycle = t on / T = t on x f Therefore, as we can see in the picture above the duty cycle is defined by the ratio between the signals on time and the time period of the rectangular waveform. This is specified as a percentage and can be calculated by the formula; Duty Cycle = T / t on x 100
  • 32. 31 So to control the speed of a motor with PWM, the duty cycle is altered where the average current delivered to the motor changes and this causes a change in speed as well as torque at the output. It is the duty cycle of the PWM and not the value of the supply voltage, that is used for the speed of the motor to be controlled. Essentially the supply voltage to the motor is interrupted and this controls the motors speed. “In such cases the technique known as pulse width modulation (PWM) is generally used. This basically involves taking a constant d.c. supply voltage and chopping it so that the average value is varied” (Bolton, 2003, p172) PWM is widely used within industry for low speed applications and power saving. It is highly efficient as it results in very low power loss because when the signal is off, there is practically no current and when the signal is on, there is almost no volt drop within the system. Also PWM can control a motor at lower speeds as it breaks the inertia of the motor by vibrating it until it starts to rotate and this is excellent for the purpose of my investigations. For this part of my investigations I was tasked with investigating variable speed control of a motor with PWM. I had to use LabVIEW or another suitable system with PWM output and develop a software/hardware based system to control the 12V d.c. motor on the 1750 unit. Below is a block diagram of the system I configured. Part 3 Overall System Block Diagram As we can see from the picture above I used a function generator to create a PWM output and I used a T-bar to connect the output to a power amplifier (which would increase the current as the function generator only provides voltage) on the 1750 unit to an oscilloscope to monitor the width of the pulse so I could adjust the duty cycle correctly. This output from the power amplifier was then connected to the motor on the 1750 unit and the motor has a sensor at its output which was connected to the rev counter display on the 1750 unit so I could monitor the effect of the larger duty cycles on the revolutions per second (RPS). This system was built and can be seen in the photos on the next page.
  • 33. 32 Part 3 Function Generator and LJ Trainer System(A) Part 3 Function Generator and LJ Trainer System(B)
  • 34. 33 After building the circuit that is shown in the photos on the previous page I set the frequency to around 100Hz on the function generator which is the ideal frequency for this experiment. A frequency that differs is insufficient as the motor would not rotate smoothly but would jerk as it rotated, similar to a stepper motor and 1 full cycle is equal to 10ms at 100Hz. Next I started to increase the duty cycle from 0 to 100% and observed the motor rotate. As the motors output was connected to the rev counter display on the 1750 unit, I could observe the revolutions per second(RPS) and I recorded the results in the table below. Part 3 Investigation of PWM Control of DC Motor Results Table Speed ofShaft(RPS) Speed ofShaft(RPM) Duty Cycle Time(ms) Duty Cycle (%) 0 0 0 0% <1 -71 0.5 5% 0.2 12 1.0 10% 5 300 1.5 15% 6 360 2 20% 10 600 3 30% 14 840 6 40% 18 1080 5 50% 22 1320 4 60% 26 1560 7 70% 32 1920 8 80% 36 2160 9 90% 38 2280 10 100% As the counter on the 1750 unit only outputs readings for RPS, I also wanted results for revolutions per minute(RPM) so I multiplied the RPS results by sixty to calculate the RPM and recorded the calculations in the table as well. From these results I could plot a graph on excel of the duty cycle against the speed of the motor in RPM where the motor would rotate at 2400 RPM when 12V is applied to the motor therefore 200 RPM is equal to 1V and the graph can be seen below; PWM Control of a DC Motor Test Results Graph (PWM Against Duty Cycle) I then plotted a graph on excel of the RPM against the RPS and this can on the next page.
  • 35. 34 PWM Control of a DC Motor Test Results Graph (RPM Against RPS) With the graphs that I plotted I could determine the PWM duty cycle required to provide a speed of 50 RPM. The results that were plotted on excel produced figures of the line of best fit and I could use these figures to calculate the duty cycle percentage that is required to produce a motor speed of 50 RPM. Below is the calculation for the duty cycle that was required; 12% = 50 RPM (1.2ms) graph y = 0.04 x 50 + 6.1386 0.04 x 50 + 6.1386 = 8.13% Therefore, 50 RPM = 8.13% Also with an analogue input of +5V connected to a variable amplifier, the motor overcame inertia at 2 RPS. For this part of my investigations I also needed to provide a suitable design to show how the PWM technique could be used to provide speed control in both directions of rotation. Therefore, I would implement an H-Bridge within the system to control the polarity of the input voltage and below is a diagram of how an H-Bridge operates. H-Bridge Explanation Diagram As we can see from the picture on the previous page, if S1 and S4 switches are closed as well as the other two switches are open, then the voltage can flow to ground (highlighted in red). This would make the motor rotate in a clockwise direction because the voltage would be flowing through the positive to the negative terminals on the motor before reaching ground.
  • 36. 35 Similarly, when S2 and S3 switches are closed as well as the other two switches are open, then the voltage would flow to ground (highlighted in blue). The motor would now be rotating in an anticlockwise direction as the polarity of the motor has been reversed, where the voltage is now flowing through the negative to the positive terminals before reaching ground. Metal Oxide Semiconductor Field Effect Transistor (MOSFET) switches would be ideal to use but instead of building the H-Bridge with individual components, there is the TPIC0107B PWM Control Intelligent H Bridge IC that is designed specifically for d.c. motor applications and below is the pin layout diagram. TPIC0107B Pin Layout Diagram (Texas Instruments Incorporated, 2002, accessed 2016) As we can see from the picture above, there is a dedicated PWM input port at pin 8 and the IC is optimized for reversible operation of motors, which is achieved by the designated direction port at pin 3. To implement this IC, I would have to substitute the function generator with a microcontroller, such as any from the PIC range that has a PWM function. From the TPIC0107B data sheet we can derive the typical application circuit and below is a picture of that circuit that I would implement to show how the PWM technique could be used to provide speed control in both directions of rotation. TPIC0107B Typical Application Circuit (Texas Instruments Incorporated, 2002, accessed 2016) This system was quite easy to construct and I was able to complete my investigations successfully. The motor reacted the way I was expecting and this proved that the overall system was correctly configured.
  • 37. 36 Part 4 Mechatronics and Embedded Systems (Solar Panel Tracking System) For this part of my investigations I was tasked with solving one of two problems and the problem I chose to tackle was designing a sun-tracking solar panel system, to be used to optimise solar electrical generation in small-scale installations and the panel must follow the position of the sun as it moves across the sky from east to west every day. A solar tracker is much more efficient than a static system and can increase the panels output by around 20 to 30%, which increases the power that is generated. The sun travels from east to west through the sky but over the day its position is degrees different through north to south as it rises and sets. Therefore, as the solar panel needs to be perpendicular to the sun so the efficiency of generating power is optimized, the tracker system needs to be able to track both x and y axis, so a dual axis tracking system is required. The system that I had to design had to incorporate the PIC18F2420 microcontroller into the system and below is a picture of the pin layout diagram. PIC18F2420 Pin Layout Diagram (Microchip Technology Incorporated, 2008, accessed 2016) The PIC18F2420 is similar to the PIC16F84A microcontroller I used in part 1 and 2 but is packed with more features. It has ten analogue inputs with a 10-bit ADC, three 8 bit bidirectional ports, two PWM outputs, brown out reset and is low on power consumption with sleep mode etc. The tracking system I had to design needed to be positioned by 2 bipolar d.c. motors with inputs from 3 light dependant resistors (LDRs) as sensors that track the sun. Also there should be 3 status LEDs as well as 4 limit switches and be powered by a 12V battery. On the next page is a simple mechanical design as well as the circuit diagram for the solar tracking system I designed and a clearer full size circuit diagram is in Appendix 3.
  • 38. 37 Solar Tracking System Circuit Diagram Solar Tracking System Mechanical Design and LDR Position Diagram First, after consulting the PIC18F2420 data sheet I researched voltage regulators for the power supply sub system and came across the LM7805 IC which is a 12V to 5V voltage regulator. This is perfect for my overall system as when consulting the data sheet, the PIC18F2420 accommodates an operating VDD range of 4.2V to 5.5V, so 5V is an ideal output from the LM7805 for the microcontroller to operate correctly. On the next page is a picture of the pin layout diagram for the LM7805.
  • 39. 38 LM7805 Pin Layout Diagram (Texas Instruments Incorporated, 2003, accessed 2016) As we can see in the systems circuit diagram the LM7805 needed some components to operate correctly such as capacitors and after consulting the data sheet for the LM7805 I used a 0.33uf capacitor on the input and a 0.1uf capacitor at the output. The 0.33uf capacitor is there to reduce voltage transients on the input of the LM7805 and this also improves the stability of the output voltage. The 0.1uf capacitor reduces fluctuations of transient voltage on the output caused by quick changes in load current. Therefore, they are decoupling capacitors at the input and output, which are needed to suppress noise. The 1N4007 diode that is connected in series with the 12V battery and the LM7805 is there to protect the regulator in case the battery is connected the wrong way round. There is also a status LED in the power supply side of the circuit and this will illuminate when power is being supplied to the microcontroller. The calculations for the resistor is explained on the next page along with the ones used on the LDRs. Finally, there is a 100nf capacitor connected between VDD and VSS because there is noise that is shunted through the capacitor therefore it reduces the effect on the rest of the circuit. As the LM7805 will produce a lot of heat due to high currents I would connect the tab on the regulator to a heat sink. For timing purposes there is a 4 MHz crystal oscillator connected to pins 9 and 10. The decoupling capacitor values that are there to reduce noise, were derived from the oscillator configuration in the PIC18F2420s data sheet and it is recommended that 30pf capacitors should be connected on pin 9 as well as pin 10 when using a 4MHz crystal oscillator. The master clear pin which is pin 1 is connected in series to a 10KΩ resistor and then to the 5V from the output of the LM7805 regulator. This is to hold MCLR high while in use because if MCLR is in any way low the PIC18F2420 will reset. The LDRs within the system are variable resistors where the resistance within them decreases when the light intensity that falls upon the device increases. Then for example, when there is sunlight the LDR could have a resistance of 1KΩ and when it is dark the resistance could be 100KΩ. As they are passive transducers, in my system they are configured as potential dividers by connecting them in series with 75KΩ resisters. Therefore, any change in light density is proportional to the change in voltage across the LDRs. The LDRs I was thinking about using in the system were from the VT900 series such as the VT90N1 and the Electro- Optical Characteristics table from the data sheet can be seen on the next page.
  • 40. 39 VT900 Series Electro-Optical Characteristics Table (PerkinElmer Optoelectronics, 2001, accessed 2016) From this table I could see that the LDRs resistance is 12KΩ when it is in the light and 200KΩ when it is in the dark. Therefore, with these figures I could calculate which is the best resistor to use to create a potential divider to provide a suitable response and below is the formula I used. Vout = (R2 / (R1 + R2)) x Vin In my circuit I am proposing 75KΩ resistors which would be the value of R2 and when the LDR is receiving light its resistance would be 12KΩ, this is the value of R1. (75KΩ / (12KΩ + 75KΩ)) x 5V = 4.3V When the LDR is in the dark the resistance would increase to 200KΩ and now this is the value of R1. (75KΩ / (200KΩ + 75KΩ)) x 5V = 1.36V This is the perfect response for my system and that is the reason I used the LDR as R1 instead of R2, which would reverse the values of the output. The reason I used a 75KΩ resistor as R2 was to give me a voltage at PORTA pins 2,3 and 4 that was within the recommended values in the data sheet. There are three status LEDs connected before pins 2,3 and 4 to show that an LDR is being activated. Below are my calculations for the status LEDs resistors. (5 – 1.5) = 6x10-3 x (70 + R) R = 463Ω NPV = 470Ω The LDRs are connected to pins 2,3 and 4, as these are analogue input pins and the PIC18F2420 has an inbuilt 10 bit ADC to convert the signal into a binary code for the output to the motors. I will discuss this later when I am describing the operation of the solar tracking system with the use of the LDRs.
  • 41. 40 Next I researched ways to drive the motors and decided to use the L293D which has two H- Bridges within it and can control two d.c. motors independently. I could use two TPIC1070B ICs as described in part 3 and use PWM to control the motors but I have decided the L293D simplifies the circuit by only having 4 inputs from the PIC18F2420, therefore leaving pins available for future use. It also will use less components and the cost would be reduced. Below are pictures of the L293D pin layout diagram and pin functions table. L293D Pin Layout Diagram (Texas Instruments Incorporated, 2016, accessed 2016) L293D Pin Functions Table (Texas Instruments Incorporated, 2016, accessed 2016) From the pin functions diagram I could then derive the typical application for the L293D and design the motor sub system as seen in my system circuit diagram. As you can see there are only four inputs from the PIC18F2420 which would leave some output pins available for future improvements. Vcc1 is connected to 5V for internal logic translation and Vcc2 is also connected to 5V for the power to drive the motors. As I would use 12V bidirectional d.c motors I chose 5V instead of tapping 12V off of the battery as a means to control the speed of the motor and with using 5V the motors would only have a maximum speed of 1000 RPM instead of a possible 2400RPM. Also pins 1 and 9 are connected to 5V to enable both sets of input and output pins. Pins 4,5,12 and 13 would be all be grounded. The motors are connected to pins 3,6,11 and 14 with decoupling capacitors connected in parallel with the motor to help to compensate noises produced by motor as well as to prolong the life of the motor.
  • 42. 41 Where the operation of the system is concerned within my mechanical design LDR 3 is positioned inside an inverted enclosure and this is so the light will only hit it when it is directly facing the sun. When the sun moves this would increase the resistance in LDR3 and would change the output voltage that is fed into pin 4 on the PIC18F2420 away from the set reference voltage, therefore the output pins of PORTA would be activated and the motors would move accordingly to track the sun. At sunset or if it is a cloudy day the tracker does not aimlessly scan the sky for the sun because of LDR2. This LDR is mounted flush to the mechanism so it can see the whole sky that it is facing. Therefore, at sunset or on a cloudy day, the lack of light will increase the resistance, altering the output voltage that is fed into pin 3 on the PIC18F2420 away from the set reference voltage and because of this it would activate its sleep mode. After the system has shut at sunset it should be pointing to the west and as the sun rises in the east, this is where LDR1 comes into play. As LDR1 is mounted on the back facing in the opposite direction to the other LDRs, in the morning LDR1 is pointing to the east and when it senses the sun is rising the resistance will decrease altering the voltage to pin 2 on the PIC18F2420. This wakes the system from sleep mode, then it activates the motors to turn the solar panel towards the sun until LDR2 first sends a voltage to pin 3 and then LDR3 sends the correct voltage to pin 4. By positioning the LDRs and using them in this way I believe I do not need the limit switches as the motors would not rotate when the LDRs are not transmitting a voltage to the inputs on the PIC18F2420. As far as the software configuration of the various ports on the PIC18F2420, PORTA would be configured as an input port and PORTB would be configured as an output port. PORTC does not need to be configured in my system and would be available for future improvements to the system. This system was interesting to research and I know my design is not perfect but through my research it became apparent that there are different ways to operate a solar tracking system using. However, I believe my design is one of the simplest and cost effective designs as it uses one IC to drive the motors instead of one per motor. The important part would be the code that is inputted into the PIC18F2420, where the signals that are inputted from the LDRs are interpreted correctly to give a suitable output response to rotate the motors and keep the panel perpendicular to the sun. I also believe that this system could be up scaled for bigger installations with some alterations.
  • 43. 42 Part 5 Mechatronics Case Study (Neoprene tube cutting system) For this part of my investigations I was tasked with solving one of two problems and the problem I chose to tackle was for a neoprene tube cutting system. Below is a picture of the system. Neoprene tube cutting system (Ward, 2016, accessed 2016) As we can see from the picture above there is an extruded neoprene tube(A) that is fed to a cutter(B) and this cutter will be positioned by an electric motor(C) to cut rings of the tube to become seals. These seals are then fed by a chute(D) to a conveyor belt which passes the seal between pinch rollers(E) where the seals dimensions are measured and any seals that are out of specification are ejected from the system by a device(F). If any seal does not meet the specification that is required, then the position of the cutter would be adjusted accordingly. For my investigations I was tasked with; Finding a suitable transducer for measuring the displacement of the pinch rollers. Finding a suitable device to be used to physically reject the inadequate seals as well as finding a suitable motor to position and reposition the cutter. Sketch a block diagram showing the layout and interfacing elements that are necessary for the system to operate correctly. Develop a programming flow chart for the system and suggest a suitable programming language.
  • 44. 43 A transducer is the collective term used for both, sensors which can be used to sense a wide range of different energy forms and actuators which can be used to switch voltages or currents. Therefore, transducers are used to convert energy of one kind into energy of another kind. Firstly, there were many transducers to choose from and they are classed as input or output, as well as contact and non-contact transducers. The contact transducers vary from linear variable differential transformer (LVDT) and linear variable capacitors, to potentiometers and strain gauges. The non-contact transducers are laser(optical) triangulation, ultrasound, GPS and radar etc. However, for the system in question I would be measuring displacement of the pinch rollers and I believe one of the contact transducers would be more suitable for the system to operate efficiently. Therefore, I have chosen a linear variable differential transformer (LVDT) as the ideal transducer to measure the displacement of the pinch rollers. An LVDT is in its basic form similar to a transformer with a moveable iron core where three coils are used, one on the input (primary) and two on the output (secondary) with the ratio between the two output coils making it possible to determine the direction of the movement of the iron core. For the LVDT to operate correctly an a.c. signal is connected to the primary core and this a.c. signal is of a high frequency that is easily removed with a low pass filter. The two windings on the secondary side of the LVDT have the same amount of windings and are wound in series but are wound in different directions. Therefore, they are connected in anti-phase but a phase sensitive rectifier is used to nullify this problem and this makes it possible for the position of the iron core to be calculated. LVDTs have many applications because it does not suffer from mechanical wear as well as being extremely accurate and can be used for example in cash machines to count notes as the resolution goes down to µm. “LVDT transducers are essentially immune to friction and wear problems, they have infinite resolution and are highly linear and accurate.” (Fraser et al, 1994, p123) Below is a schematic diagram of an LVDT showing the operation of the moveable core, LVDT Schematic and Operational Diagram (Macrosensors.com, 2014, accessed 2016) The picture above is a schematic representation of an LVDT and shows the iron core passing through the coils. Whichever coil has the most amount of core passing through it will have a higher voltage induced into it.
  • 45. 44 However, if the core is in the middle the two induced voltages should cancel each other out giving zero output voltage. When voltage from an a.c. supply is sent through the primary coil, it causes a voltage to be induced and generated through the secondary coils. The secondary coils have the same number turns and are connected in series opposing, so the output voltage is the difference between the voltages induced in the coils. When the iron core is in the middle in the picture on the previous page the voltages induced in coils S1 & S2 would be exactly the same (like a normal transformer) and the output voltage would be near zero. For example if we sent a 10V a.c. signal through the primary, the induced voltage at the secondary would be 10V and have an output of 0V. We can check this by using this equation; Vout = (S1 – S2) Vout = (10V – 10V) Vout = 0V When the iron core is positioned to the left as shown on the last page, the induced voltage of coil S1 will be bigger than that induced in coil S2. This will create an output voltage Vout = (S1 – S2) and for example if we sent a 10v AC signal through the primary coil, the induced voltage at coil S1 would be something like 7V so in coil S2 should be 3V. We can work out what the output voltage should be by using the equation; Vout = (S1 – S2) Vout = (7V – 3V) Vout = 4V When the core is positioned to the right as shown on the previous page, the induced voltage of coil S1 will be smaller that the induced voltage in coil S2. This will create an output voltage of Vout = (S1 – S2). So by moving the iron core from its neutral position it produces an output voltage and this voltage increases the further from the neutral position. Therefore, where the pinch rollers on the system is concerned I would have a set voltage that the LVDT would output to indicate when a seal has been cut to the correct specification and when the LVDT has an output that differs from this set voltage this would let the system know the seal is inadequate and it should be rejected. Also because the LVDT outputs an analogue signal this needs to be converted to a digital signal with an ADC for the neoprene tube cutting system. As for the dynamic response, it should be quick as the production line will not stop and the next seal would be just behind the proceeding one. This means that the LVDT needs to be reset back to the original set point voltage ready to analyse the next seal. This is important so the quality of the seal is not compromised and meets the specification required.
  • 46. 45 A suitable device that is to be used to physically reject the inadequate seals after receiving an output signal from the LVDT that differs from the set voltage could be a few things. They are a solenoid that is activated to push the rejected seal down the reject shoot, compressed air to physically blow the seal down the reject shoot or a flap mechanism controlled by a solenoid which activates a lever and diverts the seal down the reject shoot. For the system in question I opted to utilise a solenoid activated lever system as this is not only the most reliable way but one the simplest options as it does not require an extra sensor to sense when a defective seal is present that needs to be rejected. Below is a diagram of how a solenoid is constructed. Solenoid Construction Diagram (Shipway et al, 2008, accessed 2016) A solenoid is a transducer that transforms electrical energy into linear motion. It has an iron core with a coil of wire wrapped around it and when the coil has a voltage across it the magnetic flux drives the core forward. The coil is wrapped around the core so that the armature can be moved in and out of the centre. This process alters the coils inductance causing it to become an electromagnet and it is the armature which is used to provide a mechanical force. When the solenoid is de-energised the magnetic field collapses quickly and a back emf is generated within the coil. These induced voltages can be extremely high so a diode is connected in parallel with the coil. After the solenoid has been activated it resets with the aid of a spring ready for the next LVDT reading. Solenoids are only effective over short distances but have very quick reaction times due to the simplicity of the circuitry needed to operate them. Electromechanical solenoids are commonly seen in electronic pinball machines, dot matrix printers and fuel injectors.
  • 47. 46 For this system the end of the armature of the solenoid is connected via a pivot bracket to the flap mechanism, close to the hinge that attaches the flap to the chute. As the pivot bracket is attached close to the hinge this helps with the mechanical movement of the flap to ensure it fully opens and diverts the rejected seals. Below are graphical representations of the flap mechanism I am proposing in closed and open states. Closed Flap Mechanism Graphical Representation As we can see from the picture above that when the LVDT outputs a signal that is exactly the same as the set voltage which represents the size of the seal that is required, the flap mechanism will stay closed. Therefore, the seal will drop down the chute and carry on down the production line. Open Flap Mechanism Graphical Representation The picture above shows that when the LVDT outputs a signal that differs from the set voltage point then the coil in the solenoid is energised to create a magnetic flux set up within the coil. This field then provides the magnetic force to drive the core as well as the armature forward to physically open the flap and divert a miss-sized seal down the reject shoot.
  • 48. 47 Within the system, at the start of the process or when the LVDT outputs a different signal to the set voltage, the cutter needs to be positioned or repositioned by a motor. One of the best motors for positioning used throughout industry is a stepper motor and it is a device that converts d.c. voltage pulses into a proportional mechanical rotation of its shaft. Stepper Motor (Engineers Garage, 2012, accessed 2016) Stepper motors are d.c. motors that move in discrete steps and have multiple coils that are organized in groups called phases. Stepper motors are usually paired with a motor drive which translates pulses into appropriate patterns of current sent to phases at the stator therefore driving the motor. So when each phase is energised in sequence the motor will rotate, one step at a time and with a form of control such as a PC, microcontroller or PLC the stepper motor can achieve very precise positioning. Stepper motors move in precise repeatable steps so they excel in applications requiring precise positioning such as 3D printers, CNC, Camera platforms etc. Also stepper motors have high torque at low speeds which would be good for the neoprene cutting system as the cutter would only need to be repositioned slightly every time and they have excellent holding torque which would be beneficial for the cutter to make a clean straight cut. There are unipolar and bipolar stepper motors, however for the system in question a bipolar stepper motor is more suitable. This is because it can rotate in both directions which is vital as the rejected seals could be either too big or too small. So when repositioning the cutter, the motor needs to be able to rotate both ways depending on the size of the rejected seal.
  • 49. 48 If the system is to be monitored and controlled by a PC, there needs to be a product to interface between the PC and the neoprene cutting system. Such a product is an external I/O card like one from national instruments and below is picture of the product. National Instruments External I/O Card (Haugen, 2008, accessed 2016) The national instruments external I/O card is an excellent bit of kit and can be operated with various pieces of software like C, Visual Studio or LabVIEW. It is also suitable for the platforms windows, mac and Linux. For the neoprene cutting system I would implement LabVIEW as this is quite easy to use and would be ideal for the system in partnership with the external I/O card connected to a PC. Below is a block diagram which shows how the whole system should be configured. Neoprene Cutting System Block Diagram
  • 50. 49 In the picture on the previous page it shows the optimal configuration for the control and monitoring of the system. Using LabVIEW, the data can be entered via the PC for the cutting parameters and could be inputted with the use of a keyboard and mouse. Power transistors, such as Mosfets could be used to interface between the 5V output from the PC via the external I/O card and the 12v motor as well as the solenoid. The 12V would be supplied from a battery or the external I/O card after its output of 5V had been amplified. As the LVDT outputs an analogue signal this needs to be converted to a digital signal by an analogue to digital converter(ADC) for the LVDT to interface with the PC. Also the motor could have an analogue position converted to a digital signal by the ADC and this digital signal would be inputted to the PC via the external I/O card. Finally, I had to develop a flowchart for the neoprene cutting system and below is a picture of my flowchart. Neoprene Cutting System Flowchart
  • 51. 50 As we can see from the flowchart on the previous page, first the I/O ports needs to be set up and then the conveyor is switched on. Next the stepper motor is moved to alter the cutters position and this position is checked. Then the neoprene tube is checked it is in the correct position and the lever system is checked that it is closed so correctly sized seals do not go down the reject chute. At this point a seal is cut off of the neoprene tube, then fed with a conveyor through the roller and the LVDT output signal voltage is read. Next this output voltage is compared against the specification of the desired size of seal, which for the purposes of this explanation is assumed to be 2V and a question is asked whether it is greater or less than 2V? If the answer is no this means the LVDT output signal equals 2V which is the correct specification, so then the process can repeat from just before check neoprene tubes position and the lever system is closed. If the answer to the question was yes, then the LVDT output signal was greater or less than 2V. This reading would activate the solenoid where the lever would open across the chute therefore rejecting the miss-sized seal down the reject chute. Next the question, was the LVDT output signal greater than 2V was asked. If the answer was no, then the LVDT output signal was less than 2V and this would instruct the stepper motor to rotate clockwise so the motor positions the cutter to cut a bigger seal to receive an increased LVDT output so it equals 2V. Next the solenoid would be deactivated thus closing the lever and then the process would repeat from point A, where the stepper motor would reposition the cutter until the desired LVDT output is achieved. If the output from the LVDT was greater than 2V, this would instruct the stepper motor to rotate anti-clockwise till the LVDTs output is decreased so it equals 2V and this would position the cutter to cut a smaller seal. Next the solenoid would be deactivated thus closing the lever and then the process would repeat from point A, where the stepper motor would reposition the cutter until the desired LVDT output is achieved. The part of the flowchart that is highlighted in blue writing is the variable part of the code and this is altered depending on what size seal is desired. There are a few programming languages that would be suitable for the neoprene cutting system such as C++, Flowcode and even ladder logic using a PLC. I would choose Flowcode as it is probably the simplest to implement. With Flowcode you create a flowchart like the one seen above and Flowcode converts the chart into code. One of the benefits of this software is that you can simulate the circuit within Flowcode to check that the code works correctly and it is easier to use Flowcode rather than a generic C compiler program. This system was interesting to research and I believe my system would work correctly. However, I would try improve it by implementing a PIC16F84 into the system because it has a built in feature for high torque micro stepping by using the ECCP module with a few external components and this will allow the stepper motor to be driven at a frequency of around 31KHz. This frequency will eliminate any unwanted noise that is generated by the motor at lower frequencies. Also by implementing a PIC16F84 it would remove the need for a PC and instead the reference level for the LVDT could be selected by a digital keypad or toggle switch for say 10mm, 20mm, 30mm etc. Obviously some code would need to be written to program the PIC16F84 for the system to operate correctly and I am confident I could do that.
  • 52. 51 Conclusion To conclude these investigations went well and I learned a lot. Mechatronics is all around us and an important part of the modern world. This report introduced various ways to control mechatronics systems such as a PLC or PIC microcontroller and these were excellent for the purpose of my investigations. The PIC microcontrollers were not too hard to program and with the development board quite easy to implement into the system. The PIC16F84 was an ideal microcontroller for low cost motor control and as mentioned earlier I would try use it in the neoprene cutting system. I have seen how with the use of a DAC, a motor can be made to steadily ramp up and ramp down in acceleration, as well as change its direction. This is because I wrote a program which increased the binary output from the PIC16F84 in a linearly response to increase the magnitude of the analogue signal to the motor. I also learned that PWM is a good tool to use where motor control is concerned and with the use of a H Bridge the motor could be controlled in both directions. Also with the implementation of the TPIC0107, the circuit would be very efficient and cost effective. The final two problems were interesting and I believe my designs were feasible. The solar tracker system problem was quite tasking with designing the whole circuit with regards to the power supply sub system, LDR input sub system and the motor output sub system. However, through my research I learned that there are various ways to achieve a system that works and I believe my design would operate correctly. As far as the neoprene tube cutting system is concerned I believe my system would operate correctly and my choice of components, as well as the way it would be configured is adequate for the purpose of the system. All together I have learned a lot this semester and it should hold me in good stead throughout what I hope to be a long career, because mechatronics is embedded throughout industry.
  • 53. 52 Appendix 1 Part 1 PIC16F84 Code (A) LIST P=16F84,R=DEC TITLE "Part1.ASM" ; This program controls the speed and direction of a DC motor: ; SET1 DURATION (assumes a 4MHz crystal clock) ; Motor OFF 2 seconds ; Motor ON Clockwise 2 seconds ; Motor OFF 2 seconds ; Motor ON Anti-Clockwise 2 seconds ; ; *** PROGRAM EQUATES *** STATUS EQU 3 ;STATUS is file register 03h PORTA EQU 5 ;PORTA is file register 05h TRISA EQU 5 ;TRISA is file register 85h R0 EQU H'C' ;1st General Purpose Register R1 EQU H'D' ;2nd General Purpose Register R2 EQU H'E' ;3rd General Purpose Register RP0 EQU 5 ;Bit 5 of STATUS COUNT1 EQU 133 ;Value for outer delay count COUNT2 EQU 250 ;Value for inner delay count ; ; *** MAIN PROGRAM *** ORG 0 BSF STATUS,RP0 ;Select register bank 1 MOVLW 0 MOVWF TRISA ;Make PORTA all output BCF STATUS,RP0 ;Select register bank 0 ; BEGIN MOVLW B'00000000' ;Motor OFF MOVWF PORTA ;and output to Motor MOVLW 20 ;Value for 2 second delay CALL DELAY ;
  • 54. 53 MOVLW B'00000001' ;Motor runs Clockwise MOVWF PORTA ;and output to Motor MOVLW 20 ;Value for 2 second delay CALL DELAY ; MOVLW B'00000011' ;Motor OFF MOVWF PORTA ;and output to Motor MOVLW 20 ;Value for 2 second delay CALL DELAY ; MOVLW B'00000010' ;Motor runs Anti-Clockwise MOVWF PORTA ;and output to Motor MOVLW 20 ;Value for 2 second delay CALL DELAY ; GOTO BEGIN ; ; ***Delay Subroutine - value passed to routine in W is time delay times 0.1 seconds.*** DELAY MOVWF R0 ;Place W value into R0 (10 per second delay) DELAY1 MOVLW COUNT1 ;Place COUNT1 (133) into R1 MOVWF R1 DELAY2 MOVLW COUNT2 ;Place COUNT2 (250) into R2 MOVWF R2 DELAY3 DECFSZ R2 ;Decrement R2 repeatedly GOTO DELAY3 ;until it equals 0 DECFSZ R1 ;Decrement R1 repeatedly GOTO DELAY2 ;until it equals 0 DECFSZ R0 ;Decrement R0 repeatedly GOTO DELAY1 ;until it equals 0 RETURN ;Done, return to main program ; END
  • 55. 54 Part 1 PIC16F84 Code (B)
  • 56. 55 Appendix 2 Part 2 PIC16F84 Code (A) LIST P=16F84,R=DEC TITLE "Part2.ASM" ; ; *** PROGRAM EQUATES *** ; STATUS EQU 3 ;STATUS is file register 03h PORTB EQU 6 ;PORTB is file register 06h TRISB EQU 6 ;TRISB is file register 86h R0 EQU H'C' ;1st General Purpose Register (time delay routine) R1 EQU H'D' ;2nd General Purpose Register (time delay routine) R2 EQU H'E' ;3rd General Purpose Register (time delay routine) R3 EQU H'F' ;Register for VALUE OUTPUT TO MOTOR (variable) R4 EQU H'10' ;Loop Counter for Acceleration & Deceleration RP0 EQU 5 ;Bit 5 of STATUS Z EQU 2 ;Bit 2 of STATUS COUNT1 EQU 133 ;Value for outer delay count COUNT2 EQU 50 ;Value for inner delay count ; ; *** MAIN PROGRAM *** ; ORG 0 ; ; ***Port initialisation*** ; MAIN BSF STATUS,RP0 ;Select register bank 1 MOVLW 0 MOVWF TRISB ;Make PORTB all output BCF STATUS,RP0 ;Select register bank 0 ; ; ***Initial zero speed stage for 5 seconds*** BEGIN MOVLW B'10000000' ;Initial Bit pattern for zero speed (motor off) MOVWF R3 MOVWF PORTB ;Output R3 to PORTB and DAC the zero speed MOVLW 250 ;5 sec at zero speed initially, using DELAY (250 x 20msecs) CALL DELAY
  • 57. 56 ; ; ***Increment from zero speed stage(100 STEPS)*** MOVLW 100 ;REPEAT THIS SEQUENCE (LOOP) until Full Speed reached. 100 steps up from 10000000 MOVLF R4 ;Motor acceleration FORWARD INCF R3 ;Increment binary bit pattern to 11100100 MOVF R3,0 MOVWF PORTB ;Output R3 to PORTB and DAC the maximum clockwise speed value MOVLW 1 ;Set W for a 20msec delay CALL DELAY DECFSZ R4 ;Stop/slow motor acceleration GOTO FORWARD ;Repeat loop till at maximum clockwise speed ; ; ***Constant forward speed stage for 5 secs*** MOVLW 250 ;Motor runs clockwise at maximum speed for 5secs (250 x 20msecs) CALL DELAY ; ; ***Decrement stage to zero for 2 secs, then reverse for 2 secs (4secs total and 200 steps)*** MOVLW 200 ;REPEAT THIS SEQUENCE (LOOP) until Full Speed reached. 200 steps down from 11100100 MOVWF R4 ;Motor deceleration then acceleration in reverse FORWARD2 DECF R3 ;Decrement binary bit pattern to 00011100 MOVF R3,0 MOVLF PORTB ;Output R3 to PORTB and DAC maximum anti-clockwise speed value MOVLW 1 ;Set W for a 20msec delay CALL DELAY DECFSC R4 ;Stop/slow motor acceleration GOTO FORWARD2 ;Repeat loop till at maximum anti-clockwise speed ; ; ***Constant reverse speed stage for 5 seconds*** MOVLW 250 ;Motor runs anti-clockwise at maximum speed for 5secs (250 x 20msecs) CALL DELAY ;
  • 58. 57 ; ***Increment back to zero speed stage (100 steps)*** MOVLW 100 ;REPEAT THIS SEQUENCE (LOOP) until zero speed reached. 100 steps up from 00011100 MOVWF R4 ;Motor acceleration REVERSE INCF R3 ;Increment binary bit pattern to 10000000 (zero speed value) MOVF R3,0 MOVWF PORTB ;Output R3 to PORTB and DAC the zero speed MOVLW 1 ;Set W for a 20msec delay CALL DELAY DECFSZ R4 ;Stop/slow motor acceleration GOTO REVERSE ;Repeat loop till at zero speed ; ; ***SUBROUTINES*** ; ***DELAY subroutine - gives a time delay*** ; - time delay equals 20 ms times value in W. ; DELAY MOVWF R0 ;Value in W at subroutine call. DELAY1 MOVLW COUNT1 ;Place COUNT1 (133) into R1 MOVWF R1 DELAY2 MOVLW COUNT2 ;Place COUNT2 (50) into R2 MOVWF R2 DELAY3 DECFSZ R2 ;Decrement R2 repeatedly GOTO DELAY3 ;until it equals 0 DECFSZ R1 ;Decrement R1 repeatedly GOTO DELAY2 ;until it equals 0 DECFSZ R0 ;Decrement R0 repeatedly GOTO DELAY1 ;until it equals 0 RETURN ;Done, return to main program ; ; ***End of delay subroutine*** ; END
  • 59. 58 Part 2 PIC16F84 Code (A)
  • 60. 59
  • 61. 60 References Alciatore, D.G., Histand, M.B. (2012) Introduction to Mechatronics and Measurement Systems. 4th ed., New York: McGraw-Hill Companies, Inc. Bolton, W. (2003) Mechatronics: Electronic Control Systems in Mechanical and Electrical Engineering. 3rd ed., Harlow: Pearson Education Limited. Electronics Hub. (2015) Exclusive OR Gate(XOR-Gate). [Internet], Available from: <http://www.electronicshub.org/exclusive-or-gatexor-gate> [Accessed 20th March 2016]. Engineers Garage. (2012) Stepper Motors or Step Motors. [Internet], Available from: <http://www.engineersgarage.com/articles/stepper-motors> [Accessed 15th April 2016]. Fraser, C., Milne, J. (1994) Integrated Electrical and Electronic Engineering for Mechanical Engineers. Cambridge: McGraw-Hill International (UK) Limited. Haugen, F. (2008) A quick guide to National Instruments USB-6009 and USB-6008 multifunction I/O devices. [Internet], Available from:<http://techteach.no/tekdok/usb6009/> [Accessed 15th April 2016]. Learn About Electronics. (2015) What is a Unity Gain Buffer? [Internet], Available from: <http://www.learningaboutelectronics.com/Articles/Unity-gain-buffer> [Accessed 25th March 2016]. LJ Create. (2007) Digiac 1750 Transducers and Instrumentation Trainer Technical Manual PDF. [Internet], Available from: <Moodle> [Accessed 20th March 2016]. Macrosensors.com. (2014) LVDT Basics: What is an LVDT? [Internet], Available from <http://www.macrosensors.com/lvdt_tutorial.html> [Accessed 15th April 2016]. Microchip Technology Incorporated. (2001) PIC16F84A Data Sheet. [Internet], Available from:<http://ww1.microchip.com/downloads/en/DeviceDoc/35007b.pdf > [Accessed 20th March 2016]. Microchip Technology Incorporated. (2008) PIC18F2420 Data Sheet. [Internet], Available from:<http://ww1.microchip.com/downloads/en/DeviceDoc/39631E.pdf> [Accessed 10th April 2016]. Onwubolu, G.C. (2005) Mechatronics Principles and Applications. Oxford: Elsevier Butterworth-Heinemann. PerkinElmer Optoelectronics. (2001) Photoconductive Cells and Analog Optoisolators (Vactrols®). [Internet], Available from: <http://pdf1.alldatasheet.com/datasheet-pdf/view/84374/PERKINELMER/VT900.html> [Accessed 23rd April 2016].
  • 62. 61 Ross, D., Shamieh, C., McComb, G. (2010) Electronics for Dummies. Chichester: John Wiley & sons Ltd. Shipway, A., Shipway, S. (2008) Solenoid properties: Inductance and magnetic B-field. [Internet], Available from:<http://www.calctool.org/CALC/phys/electromagnetism/solenoid> [Accessed 15th April 2016]. Texas Instruments Incorporated. (2002) TPIC0107B PWM control intelligent H-bridge. [Internet], Available from:<http://www.ti.com.cn/cn/lit/ds/symlink/tpic0107b.pdf> [Accessed 23rd April 2016]. Texas Instruments Incorporated. (2003) µA7800 Series Positive-Voltage Regulators. [Internet], Available from:<https://www.sparkfun.com/datasheets/Components/LM7805.pdf> [Accessed 23rd April 2016]. Texas Instruments Incorporated. (2013) DAC0800/DAC0802 8-Bit Digital-to-Analog Converters. [Internet], Available from: <http://www.ti.com/lit/ds/symlink/dac0800.pdf> [Accessed 22nd March 2016]. Texas Instruments Incorporated. (2015) µA741 General-Purpose Operational Amplifiers. [Internet], Available from: <http://www.ti.com/lit/ds/symlink/ua741.pdf> [Accessed 25th March 2016]. Texas Instruments Incorporated. (2016) L293x Quadruple Half-H Drivers. [Internet], Available from: <http://www.ti.com/lit/ds/symlink/l293.pdf> [Accessed 23rd April 2016]. The Ron Dearing UTC Limited. (2015) What is Mechatronics? [Internet], Available from <http://www.rondearingutc.com/about/what-is-mechatronics> [Accessed 20th March 2016]. Ward, R.L., (2016) Mechatronics: Module Handbook. [Internet], Available from: <Moodle> [Accessed 20th March 2016]. Wright, H. (2001) Introduction to Programmable Logic Controllers (PLCs) and the Operational Function of Main System Modules. [Internet], Available from: <https://www.maximintegrated.com/en/app-notes/index.mvp/id/4701> [Accessed 20th March 2016].