Вы находитесь на странице: 1из 19

EE332 CONTROL SYSTEMS LAB CNC MACHINE

SEMESTER PROJECT

COMPUTER NUMERICAL CONTROLLED MACHINE

SUBMITTED BY :

MUHAMMAD ZAIGHUM FAROOQ

SUBMITTED TO: ENGG. MEMOON SAJID

Page
1
EE332 CONTROL SYSTEMS LAB CNC MACHINE

COURSE: EE341L - CONTROL SYSTEMS LAB

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
EE332 CONTROL SYSTEMS LAB CNC MACHINE

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
EE332 CONTROL SYSTEMS LAB CNC MACHINE

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
EE332 CONTROL SYSTEMS LAB CNC MACHINE

LIST OF HARDWARE USED

Following table shows the hardware used :

CONTENT SPECIFICA QUANTI


TION TY
1 -controller trainer with serial 1
. cable
2 H-bridge circuit1 2
.
3 12V&5V power supply 1,1
.

LIST OF SOFTWARES

Following table shows the softwares used :

SOFTWAR PURPOSE
E
1 MATLAB For entering co-ordinates and serially
. communicate them
2 MCU 8051 For programming the -controller
. IDE

STEPPER MOTOR SPECIFICATION

Sequence of bits to rotate stepper motor through each consecutive step:

D D D D
1 2 3 4
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');

Page
5
EE332 CONTROL SYSTEMS LAB CNC MACHINE

ss.baudrate=9600;

fopen(ss);

ss.Terminator = 'CR';

tx =1;

fprintf(ss,'%s',tx1);

pause(1);

CIRCUIT DIAGRAMS

Page
6
EE332 CONTROL SYSTEMS LAB CNC MACHINE

H-BRIDGE CIRCUIT

Page
7
EE332 CONTROL SYSTEMS LAB CNC MACHINE

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.

STEPPER MOTOR CONTROL CIRCUITRY


Page
8
EE332 CONTROL SYSTEMS LAB CNC MACHINE

(REPEATED TWICE)
The circuit shown below in the diadram is the main controlling circuitry for controlling the
stepper motors.

Page
9
EE332 CONTROL SYSTEMS LAB CNC MACHINE

FLOW CHART OF OPERATION

Page
10
EE332 CONTROL SYSTEMS LAB CNC MACHINE

Computer interfaced with -controller using


Data MATLAB.
sending by
Data MATLA
Input
1. serial lengths entered through pc. Magnitude
B to store the co-ordinate
Registers R and R
communication
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. Data received to
3. For 1 unit entered stepper motor will rotate 0.5cm.
-controller
4. Each step of stepper motor covers 20m of length. A loop of 125 cycles, whereby
serial
each cycle consists of 2 steps is used to cover
communication 0.5cm of length.

CODING TO IMPLEMENT THE ALGORITHM


Interpreting
data
org 00H

mov tmod,#20H
mov th1,#-3 Giving
mov scon,#50H instruction to
setb tr1 motors

main:nop Control
her3: jnb ri,her3 Unit
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 R U D L L U R D
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
Page
11
EE332 CONTROL SYSTEMS LAB CNC MACHINE

mov p0,a
clr ri
lcall delay

tri:
mov a,r5
cjne a,#0,over
sjmp $

mov a,r5
over:cjne a,#1,over1
mov r4,#125
back6:mov a,r7
mov r1,a
mov a,r6
mov r0,a
back5:djnz r4,here2
sjmp main

mov a,r5
over1:cjne a,#2,over2
mov r4,#125
back67:mov a,r7
mov r1,a
mov a,r6
mov r0,a
back57:djnz r4,here27
sjmp main

mov a,r5
over2:cjne a,#3,over3
mov r4,#125
back68:mov a,r7
mov r1,a
mov a,r6
mov r0,a
back58:djnz r4,here28
sjmp main

mov a,r5
over3:cjne a,#4,over4
mov r4,#125
back69:mov a,r7
mov r1,a
mov a,r6
mov r0,a
Page
12
EE332 CONTROL SYSTEMS LAB CNC MACHINE

back59:djnz r4,here29
over4:sjmp main

here2:mov a,r1
jz too
loo:acall down
acall delay
djnz r1,loo
too:mov a,r0
jz back6
acall left
acall delay
djnz r0,too
sjmp back6

here27:mov a,r1
jz tooo
looo:acall up
acall delay
djnz r1,looo
tooo:mov a,r0
jz back67
acall right
acall delay
djnz r0,tooo
sjmp back67

here28:mov a,r1
jz toooo
loooo:acall up
acall delay
djnz r1,loooo
toooo:mov a,r0
jz back68
acall left
acall delay
djnz r0,toooo
sjmp back68

here29:mov a,r1
jz to
lo:acall down
acall delay
djnz r1,lo
Page
13
EE332 CONTROL SYSTEMS LAB CNC MACHINE

to:mov a,r0
jz back69
acall right
acall delaysjmp back69

down:
mov a,30h
jz soo
mov p1,#99H
lcall delay
mov p1,#0ccH
lcall delay
mov 30h,#0
sjmp haha
soo:mov p1,#66H
lcall delay
mov p1,#33H
lcall delay
mov 30h,#1
haha:
ret

up:
mov a,31h
jz soo1
mov p1,#33H
lcall delay
mov p1,#66H
lcall delay
mov 31h,#0
sjmp haha
soo1:mov p1,#0ccH
lcall delay
mov p1,#99H
lcall delay
mov 31h,#1
haha1:
ret

left:
mov a,32h
jz soo2
mov p2,#99H
lcall delay
mov p2,#0ccH
lcall delay
Page
14
EE332 CONTROL SYSTEMS LAB CNC MACHINE

mov 32h,#0
sjmp haha
soo2:mov p2,#66H
lcall delay
mov p2,#33H
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.

Page
15
EE332 CONTROL SYSTEMS LAB CNC MACHINE

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.

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 & CUTTING DIRECTIONS


1 7 4

1 7 3

5 3 1

5 3 3

5 3 4

Page
16
EE332 CONTROL SYSTEMS LAB CNC MACHINE

7 1 4

7 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
17
EE332 CONTROL SYSTEMS LAB CNC MACHINE

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
18
EE332 CONTROL SYSTEMS LAB CNC MACHINE

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
19

Вам также может понравиться