37
CNC Machine 2D Plotter Supervisor D.R\ Eman Shaban T.A\ Mahmoud Fayez

2D Plotter Presentation

Embed Size (px)

Citation preview

Page 1: 2D Plotter Presentation

CNC Machine 2D Plotter

Supervisor D.R\ Eman Shaban T.A\ Mahmoud Fayez

Page 2: 2D Plotter Presentation

Hassan Awad Abd El-Aziz Mahmoud Mohamed Hussein Mahmoud Salah Salam Marwan Ezz El-Deen Mohamed Momen Gamal El-Deen

Team Members….

Page 3: 2D Plotter Presentation

• Introduction

• History

• System Features

• System Architecture Software subsystem Mechanical subsystem Electronic subsystem

• Mode of Operation

• Algorithms

• Testing and Simulations

Agenda….

Page 4: 2D Plotter Presentation

Introduction,,,,

Page 5: 2D Plotter Presentation

Introduction

Computer numerical control (CNC) machines are automated milling machines that make industrial components without human assistance. This is possible because CNC machines are fed a series of instructions that are delivered to an internal computer controller. These instructions are in the form of codes that belong to the numerical control programming language.

The code used to program CNC machines is generically called G-code. However, G-code instructions are only part of the programming language. Specifically, G-codes give CNC machines the coordinates .

CNC Machine

Page 6: 2D Plotter Presentation

• Automation of 3 Motors to control the coordinates (X,Y,Z)of a pen with flexible head can be used as Plotter.

IntroductionProject Idea

Page 7: 2D Plotter Presentation

History The first commercial NC

machines were built in the 1950's, and ran from punched tape.

CNC, and later CNC, allowed for tremendous increases in productivity for machine tools because the machines could be run automatically without requiring constant attention from their operator.

The first commercial NCwww.cnccookbook.com

Page 8: 2D Plotter Presentation

System Features…

Page 9: 2D Plotter Presentation

• Rapid speed positioning using G00• Plot line using G01• Plot Circles using G02,G03 clockwise or

anti-clock wise.• Manual Mode control the position of the

Plotter using Keyboard• Programming Mode write full program

includes moving plotter, Arithmetic operation and decisions instructions

System Features

Page 10: 2D Plotter Presentation

System Architecture

Page 11: 2D Plotter Presentation

System Architecture

Page 12: 2D Plotter Presentation

User Interface Terminal App

Interpreter

GeometryKernel

Timers

Send G-Code Programs, Control Instruction

Configure Timers

Motors

Software Subsystem

Move Motors

invoke

Page 13: 2D Plotter Presentation

Software Subsystem

There are 6 Main Software Modules

• MotorLib.h : Configure, Monitor and Move Motors.

• TimersLib.h : Configure periodic task.

• Interperter.h : Parse G-line program separate tokens and execute instruction

– [simple Arithmetic instructions ADD MUL].

– [Motor Instructions Operation G00,G01,G02,G03].

– [Decision instruction JEQ,JNE].

System Architecture cont

Page 14: 2D Plotter Presentation

Software Subsystem cont.

• UART.h

– Serial communication port driver to send the G-code program and control instruction to the machine

• BresenhamLineDrawing.h

• MidPointCircleDrawing.h

System Architecture cont.

Page 15: 2D Plotter Presentation

3 Motors each one attached to AXIS (X,Y,Z) Stepper Motor with the following Description

Step angle 1.8° Holding Torque: 3.9 Kg.cm (40 N.cm) Current 2 A leads: 6 wires (4 per coils 2 COM)

System ArchitectureMechanical Subsystem

Page 16: 2D Plotter Presentation

System Architecture contCNC Machine Mechanical Design:

Figure-1 Different views of Our CNC Machine

Page 17: 2D Plotter Presentation

It consists of 8 bit At mega 328P microcontroller and stepper motor control drivers BAL 35 for controlling all the three stepper motors. Microcontroller generates necessary STEP and DIRECTION signals for each stepper motor controller to achieve desired speed and rotation. A RS 232 is used for communicating data between PC and microcontroller.

System Architecture contElectronic Subsystem

Page 18: 2D Plotter Presentation

Control Modes

• We have three types of control mode:

-Calibration Mode (CL).

-Load Mode (LD).

-Execution Mode (EXE).

Page 19: 2D Plotter Presentation

Control Mode instruction

Command Description

CL Manual Mode

LD Program Mode

START Executed the program stored on RAM

EXE Read G_Line from serial and executed it immediately and acknowledge the next instruction

RESET Reset the machine to the initial X_co,Y_co_Z_co coordinates

SETBX Set border of our board on X-axis

SETBY Set border of our board on Y-axis

SETBZ Set border of our board on Z-axis

Page 20: 2D Plotter Presentation

State Chart

State chart illustrates how to switch between modes

Page 21: 2D Plotter Presentation

Machine Language Program instruction

Command Description

G00 Rapid speed X,Y,Z Vector.

G01 linear interpolation between 2 points Bresenham line drawing.

G02 Clockwise circular interpolation.

G03 Anti Clockwise circular interpolation.

ADD ADD operand [2] and operand [3] then put result set on Operand [1].

MUL MUL operand [2] and operand [3] then put result on Operand [1].

JEQ Jump if flag is set.

JNE Jump if flag is reset.

CMP Compare operand [1] and operand [2] and set Equal flag.

EOP End of program.

Page 22: 2D Plotter Presentation

Syntax Language Program

• G00

<Operation> {X [R|I] #} {Y [R|I] #} {Z [R|I] #}

EX: G00 XI1000 YI1000 ZI1000

• G01

<Operation> {X [R|I] #} {Y [R|I] #}

EX: G01 XI1000 YI500

Page 23: 2D Plotter Presentation

Syntax Language Program cont.

• G02 and G03

<Operation> {R [R|I] #} {Q [R|I] #} {C [R|I] #}

EX: G02 RI4000 QI0

• ADD and MUL

<Operation> {R [R|I] n}, operand1, operand2

EX: ADD RR1,RR2,II100 ; RR1=RR2+100

Page 24: 2D Plotter Presentation

Example of G-Code programs

Hello CNC

CNC>Controll$

LD ;the following program describe of “CNC” text with G-code

G02 RI5000 QI2 CI2 ;draw "C"

G00 ZI1500 ;Lift Plotter

G00 XI1500 YI-10000 ;space between char

G00 ZI-1500 ;down Plotter

G00 YI10000 ;draw "|"

G01 XI5000 YI-10000 ;draw "\"

G00 YI10000 ;draw "|"

G00 ZI1500 ;Lift Plotter

G00 XI6500 YI-10000 ;space between char

G00 ZI-1500 ;down Plotter

G02 RI5000 QI2 CI2 ; draw "C”

EOP

START

Page 25: 2D Plotter Presentation

Algorithms…

Page 26: 2D Plotter Presentation

Bresenham Line DrawingG01 Implementation

• Algorithm which determines which points in an n-dimensional raster should be plotted in order to form a close approximation to a straight line between two given points. It is commonly used to draw lines on a computer screen, as it uses only integer addition, subtraction and bit shifting, all of which are very cheap operations in standard computer architectures.

Page 27: 2D Plotter Presentation

Similarities between computer screen and Our board

Figure-2 Sub-pixel display http://en.wikipedia.org/wiki/Pixel

• Computer screen is divided into very small units called pixels and out board is divided into small movements called steps and we replaced the function of put pixel(X,Y); with step(Motor);

Page 28: 2D Plotter Presentation

Example

Code written for screen Code written for Out machine

Put _pixel(X+1,Y+1) Set_Direction(MotorX,Positive);Set_Direction(MotroY,Positive);parallerStep(MotorX,MotorY);

put_pixel(X+1,Y) Set_Direction(MotorX,Positive);Step(&MotorX);

put_pixel(X,Y+1) Set_Direction(MotorY,Positive);Step(&MotorY);

Put_pixel(X-1,Y) Set_Direction(MotorX,Negative);Step(&MotorX);

Page 29: 2D Plotter Presentation

Example of Bresenham Line Drawing

Bresenham for drawing Line

60° 45°30°7°

Figure 3 our Implementation of Bresenham line drawing on Console Screen Different slope

Page 30: 2D Plotter Presentation

Midpoint AlgorithmG02,G03 Implementation

•  the Midpoint circle algorithm is an algorithm used to determine the points needed for drawing a circle actually drawing one octant but we draw the other using mirroring. The algorithm is a variant of Bresenham's line algorithm, and is thus sometimes known as Bresenham's circle algorithm.

Page 31: 2D Plotter Presentation

Midpoint Algorithm Example Bresenham's Circle algorithm

Figure-3 Rasterisation of a circle by the Bresenham algorithmhttp://en.wikipedia.org/wiki/Midpoint_circle_algorithm

Page 32: 2D Plotter Presentation

G00 Implementation

• Implementation phases– Enable Interrupt handler of Each Timer[0,1,2]– Configure Timer to trigger event

(On_TimerOverFlow)(void**); when Timer overflow

• The foreground program is free to do useful work as it is occasionally interrupted output operations.

Page 33: 2D Plotter Presentation

Context switching between Motors on G00 command

Step MotoY

Foreground processForeground process

Step MotoZ

Step MotoXTime

Figure-4 Context switching between Step(&MotorX),Step(&MotorY) and Step(&MotorZ)

Page 34: 2D Plotter Presentation

Testing and Simulations…

Page 35: 2D Plotter Presentation

• We simulate the behavior of motors [#of performed step, frequency of the pulses] using PROTEUS simulator. It enables us to test and debug faster than the physical level.

• DEMO OF PROTEUS

Testing and Simulations… (PROTEUS)

Page 36: 2D Plotter Presentation

Testing and Simulations… (Final Demo)

Start

Page 37: 2D Plotter Presentation

THANKS