2D Plotter Presentation

Preview:

Citation preview

CNC Machine 2D Plotter

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

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

Team Members….

• Introduction

• History

• System Features

• System Architecture Software subsystem Mechanical subsystem Electronic subsystem

• Mode of Operation

• Algorithms

• Testing and Simulations

Agenda….

Introduction,,,,

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

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

IntroductionProject Idea

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

System Features…

• 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

System Architecture

System Architecture

User Interface Terminal App

Interpreter

GeometryKernel

Timers

Send G-Code Programs, Control Instruction

Configure Timers

Motors

Software Subsystem

Move Motors

invoke

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

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.

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

System Architecture contCNC Machine Mechanical Design:

Figure-1 Different views of Our CNC Machine

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

Control Modes

• We have three types of control mode:

-Calibration Mode (CL).

-Load Mode (LD).

-Execution Mode (EXE).

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

State Chart

State chart illustrates how to switch between modes

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.

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

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

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

Algorithms…

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.

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);

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);

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

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.

Midpoint Algorithm Example Bresenham's Circle algorithm

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

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.

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)

Testing and Simulations…

• 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)

Testing and Simulations… (Final Demo)

Start

THANKS