business environment micro environment macro environment.pptx
Computer numerical controlled machine project
1. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
SEMESTER PROJECT
“COMPUTER NUMERICAL CONTROLLED MACHINE”
SUBMITTED BY :
MUHAMMAD ZAIGHUM FAROOQ
SUBMITTED TO: ENGG. MEMOON SAJID
COURSE: EE341L - CONTROL SYSTEMS LAB
Page 1
2. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
ABSTRACT
A computer numerical control (CNC) machine is a collection of automated tools controlled by abstractly
programmed commands on a storage medium, as opposed to manual control via hand wheels or levers.
The machine is operated by stepper motors that move the controls to follow points/co-ordinates fed
into the system by a computer. In our work, we have used µ-controller AT89C51 as the storage medium,
serially receiving co-ordinates from a pc, processing that data and controlling servo motor accordingly to
reach the destination point.
Page 2
3. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
Table of Contents
ABSTRACT...................................................................................................................................................... 2
INTRODUCTION ............................................................................................................................................. 4
LIST OF HARDWARE USED ......................................................................................................................... 5
LIST OF SOFTWARES .................................................................................................................................. 5
STEPPER MOTOR SPECIFICATION ............................................................................................................. 5
MATLAB CODE FOR SENDING SERIAL DATA ................................................................................................. 5
CIRCUIT DIAGRAMS....................................................................................................................................... 6
H-BRIDGE CIRCUIT......................................................................................................................................... 7
FLOW CHART OF OPERATION ....................................................................................................................... 9
CODING TO IMPLEMENT THE ALGORITHM ................................................................................................ 10
UNIT OF INPUT ........................................................................................................................................ 14
MOTOR STEP SIZE ................................................................................................................................... 14
EFFICIENCY .............................................................................................................................................. 14
IMPROVEMENTS ......................................................................................................................................... 14
INPUT MATRIX
&
CUTTING DIRECTIONS ..................................................................................... 15
ACKNOWLEDGEMENTS ............................................................................................................................... 16
BIBLIOGRAPHY ............................................................................................................................................ 17
Page 3
4. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
INTRODUCTION
Computer numerical machines are very commonly used the days . They have
high tendency to replace the manual cutting machines as they are extremely user friendly . They give
user enough free time to be able to control more than 5 machines very easily . This ease combined with
a much greater degree of precision and accuracy sets their scope .
Our main aim of the project was to cut any shape by controlling the machine numerically but as it
was our semester project so we succeeded in cutting all the shapes that have straight edges . This
project does not cut any round shape. A motor with rotating round cutter was turned on during the
cutting process then commands are given for specific coordinates by matlab . Machine reaches that
coordinates by cutting the object in a line with any slope depending on the coordinates at present .
After that again coordinates are given to the controller through matlab and machine repeats its process
. It carries on this way and cuts a closed shape with great degree of accuracy and precision .
Page 4
5. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
LIST OF HARDWARE USED
Following table shows the hardware used :
CONTENT
1. µ-controller trainer with serial cable
2. H-bridge circuit1
3. 12V&5V power supply
SPECIFICATION
QUANTITY
1
2
1,1
LIST OF SOFTWARES
Following table shows the softwares used :
SOFTWARE
1. MATLAB
2. MCU 8051 IDE
PURPOSE
For entering co-ordinates and serially
communicate them
For programming the µ-controller
STEPPER MOTOR SPECIFICATION
Sequence of bits to rotate stepper motor through each consecutive step:
D1 D2 D3 D4
1
0
0
1
1
1
0
0
0
1
1
0
0
0
1
1
Moving from top to bottom will move the motor in clockwise steps. While taking the opposite sequence
will move the motor in anti-clockwise direction.
MATLAB CODE FOR SENDING SERIAL DATA
ss=serial('COM3');
ss.baudrate=9600;
fopen(ss);
ss.Terminator = 'CR';
tx =1;
fprintf(ss,'%s',tx1);
pause(1);
Page 5
7. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
H-BRIDGE CIRCUIT
To operate the stepper motor, we need a motor driving circuit that gives enough current to move the
stepper motor in loaded conditions as present on the real CNC machine.
We used the above H-bridge ic named L298 .
You can also use any other H bridge circuit, commonly of transistors “Tip 122”.
Page 7
8. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
STEPPER MOTOR CONTROL CIRCUITRY
(REPEATED TWICE)
The circuit shown below in the diadram is the main controlling circuitry for controlling the stepper
motors.
Page 8
9. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
FLOW CHART OF OPERATION
Data Input
Data sending by
serial communication
MATLAB
Data received to µcontroller serial
communication
Interpreting data
Giving instruction
to motors
Control Unit
R
U
D
L
Page 9
L
U
R
D
10. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
Computer interfaced with µ-controller using MATLAB.
1. Registers R₆ and R₇ to store the co-ordinate lengths entered through pc. Magnitude of R₆ and R₇
decides the no. of steps the stepper motor will move.
2. Register R₅ to hold the bit to give the direction in which the stepper motors will rotate. There
are four cases which decide the motion of stepper motor as shown in the direction.
3. For 1 unit entered stepper motor will rotate 0.5cm.
4. Each step of stepper motor covers 20µm of length. A loop of 125 cycles, whereby each cycle
consists of 2 steps is used to cover 0.5cm of length.
CODING TO IMPLEMENT THE ALGORITHM
org 00H
mov tmod,#20H
mov th1,#-3
mov scon,#50H
setb tr1
main:nop
her3: jnb ri,her3
lcall delay
mov a,sbuf
lcall delay
dec a
mov r7,a
mov p0,a
clr ri
lcall delay
here4: jnb ri,here4
lcall delay
mov a,sbuf
lcall delay
dec a
mov r6,a
mov p0,a
clr ri
lcall delay
here5: jnb ri,here5
lcall delay
mov a,sbuf
lcall delay
mov r5,a
mov p0,a
clr ri
Page
10
14. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
lcall delay
mov 32h,#1
haha2:
ret
right:
mov a,33h
jz soo3
mov p2,#33H
lcall delay
mov p2,#66H
lcall delay
mov 33h,#0
sjmp haha
soo3:mov p2,#0ccH
lcall delay
mov p2,#99H
lcall delay
mov 33h,#1
haha3:
ret
delay: mov r2,#40
h1:mov r3,#255
h2:djnz r3,H2
djnz r2,h1
ret
end
UNIT OF INPUT
Unit of input is 0.5 cm in the above program and can be changed by changing the number 125 in the
program. For example, if you change the number from 125 to 63 then unit of input will be 0.25cm.
MOTOR STEP SIZE
Motor step size is 500 steps/cm.
EFFICIENCY
In the above program it depends on the inputs.
IMPROVEMENTS
1: Efficiency of the above program can be improved by making more precise sub-control units.
2: Efficiency of the above program can be increased by two folds if we change the motor rotating units.
Page
14
15. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
In the above program every time the motor rotate is called motor takes two steps , by changing it to
take one step efficiency will double as well as program length will decrease . Its very easy. Just take a
rom location save the 66H in it retrieve it in motor rotate routine , rotate left or right according to
routine and then save it back in the same location .
3: Currently we input from matlab the directions and lengths of coordinates, we should improve it to
entering the +,- coordinates and let the computer calculate lengths and direction .
4: Data should be received as ascii characters.
5: It should also be improved to cut the curves of different types .
6: It should also be programed to three directional cutting .
INPUT MATRIX
1
7
7
3
5
3
1
5
3
3
5
3
4
7
1
4
7
1
CUTTING DIRECTIONS
4
1
&
3
Third number in input matrix represents the direction. First two numbers are lengths.
Many others possible, they also depend on connections of motors.
Moreover above lines arrows are not according to scale.
Page
15
16. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
ACKNOWLEDGEMENTS
For this project, we owe our gratitude to Mr. Memoon Sajid who assigned us this project and was a
source of constant help throughout both morally and practically. We would also like to thank our
teacher Mr. Kashif Riaz who with his marvelous teaching skills made assembly language almost innate
for us. We would also like to thank Mr. Nayyar Abbas who diligently taught us the use and programming
of µ-controller. Last but not the least we would like to thank our honorable Dean (FEE) Dr. Nisar who
had been very supportive in the requisition of hardware without which this project would never have
seen the light of day.
Page
16
17. EE332 CONTROL SYSTEMS LAB – CNC MACHINE
SPRING 2013
BIBLIOGRAPHY
Pocketmagic.net (2009) A simple H-Bridge design « PocketMagic. [online] Available at:
http://www.pocketmagic.net/2009/03/a-simple-h-bridge-design/#.UYwLYUrMLuZ [Accessed: 9 May
2013].
Page
17