19
EE332 CONTROL SYSTEMS LAB – CNC MACHINE SPRING 2013 SEMESTER PROJECT “COMPUTER NUMERICAL CONTROLLED MACHINE” SUBMITTED BY : MUHAMMAD ZAIGHUM FAROOQ Page 1

Computer numerical controlled machine project

Embed Size (px)

Citation preview

Page 1: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

SEMESTER PROJECT

“COMPUTER NUMERICAL CONTROLLED MACHINE”

SUBMITTED BY :

MUHAMMAD ZAIGHUM FAROOQ

SUBMITTED TO: ENGG. MEMOON SAJID

COURSE: EE341L - CONTROL SYSTEMS LAB

Page 1

Page 2: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

ABSTRACTA 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

Page 3: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

Table of ContentsABSTRACT....................................................................................................................................................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

Page 4: Computer numerical controlled machine project

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

Page 5: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

LIST OF HARDWARE USED

Following table shows the hardware used :

CONTENT SPECIFICATION QUANTITY1. µ-controller trainer with serial cable 12. H-bridge circuit1 23. 12V&5V power supply 1,1

LIST OF SOFTWARES

Following table shows the softwares used :

SOFTWARE PURPOSE1. MATLAB For entering co-ordinates and serially

communicate them2. MCU 8051 IDE For programming the µ-controller

STEPPER MOTOR SPECIFICATION

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

D1 D2 D3 D41 0 0 11 1 0 00 1 1 00 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);1

Page 5

Page 6: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

CIRCUIT DIAGRAMS

Page 6

Page 7: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

H-BRIDGE CIRCUITTo 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

Page 8: Computer numerical controlled machine project

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

Page 9: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

FLOW CHART OF OPERATION

Data Input MATLAB Data sending by serial communication

Data received to µ-controller serial communication

Giving instruction to motors

Control Unit

Interpreting data

R U D L L U R D

Page 9

Page 10: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 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,#20Hmov th1,#-3mov scon,#50Hsetb tr1

main:nopher3: jnb ri,her3lcall delaymov a,sbuflcall delaydec amov r7,amov p0,aclr rilcall delayhere4: jnb ri,here4lcall delaymov a,sbuflcall delaydec amov r6,amov p0,aclr rilcall delayhere5: jnb ri,here5lcall delaymov a,sbuflcall delaymov r5,amov p0,aclr ri

Page 10

Page 11: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

lcall delay

tri:mov a,r5cjne a,#0,oversjmp $

mov a,r5over:cjne a,#1,over1mov r4,#125back6:mov a,r7mov r1,amov a,r6mov r0,aback5:djnz r4,here2sjmp main

mov a,r5over1:cjne a,#2,over2mov r4,#125back67:mov a,r7mov r1,amov a,r6mov r0,aback57:djnz r4,here27sjmp main

mov a,r5over2:cjne a,#3,over3mov r4,#125back68:mov a,r7mov r1,amov a,r6mov r0,aback58:djnz r4,here28sjmp main

mov a,r5over3:cjne a,#4,over4mov r4,#125back69:mov a,r7mov r1,amov a,r6mov r0,aback59:djnz r4,here29over4:sjmp main

Page 11

Page 12: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

here2:mov a,r1jz tooloo:acall downacall delaydjnz r1,lootoo:mov a,r0jz back6acall leftacall delaydjnz r0,toosjmp back6

here27:mov a,r1jz tooolooo:acall upacall delaydjnz r1,loootooo:mov a,r0jz back67acall rightacall delaydjnz r0,tooosjmp back67

here28:mov a,r1jz tooooloooo:acall upacall delaydjnz r1,looootoooo:mov a,r0jz back68acall leftacall delaydjnz r0,toooosjmp back68

here29:mov a,r1jz tolo:acall downacall delaydjnz r1,loto:mov a,r0jz back69acall rightacall delaysjmp back69

Page 12

Page 13: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

down:mov a,30hjz soomov p1,#99Hlcall delaymov p1,#0ccHlcall delaymov 30h,#0sjmp hahasoo:mov p1,#66Hlcall delaymov p1,#33Hlcall delaymov 30h,#1haha:ret

up:mov a,31hjz soo1mov p1,#33Hlcall delaymov p1,#66Hlcall delaymov 31h,#0sjmp hahasoo1:mov p1,#0ccHlcall delaymov p1,#99Hlcall delaymov 31h,#1haha1:ret

left:mov a,32hjz soo2mov p2,#99Hlcall delaymov p2,#0ccHlcall delaymov 32h,#0sjmp hahasoo2:mov p2,#66Hlcall delaymov p2,#33H

Page 13

Page 14: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 2013

lcall delaymov 32h,#1haha2:ret

right:mov a,33hjz soo3mov p2,#33Hlcall delaymov p2,#66Hlcall delaymov 33h,#0sjmp hahasoo3:mov p2,#0ccHlcall delaymov p2,#99Hlcall delaymov 33h,#1haha3:ret

delay: mov r2,#40h1:mov r3,#255h2:djnz r3,H2djnz r2,h1ret

end

UNIT OF INPUTUnit 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 SIZEMotor step size is 500 steps/cm.

EFFICIENCYIn the above program it depends on the inputs.

IMPROVEMENTS1: 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

Page 15: Computer numerical controlled machine project

EE332 CONTROL SYSTEMS LAB – CNC MACHINESPRING 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 & CUTTING DIRECTIONS1 7 4

1 7 3

5 3 1

5 3 3

5 3 4

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 15

Page 16: Computer numerical controlled machine project

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

Page 17: Computer numerical controlled machine project

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