Introduction CNC MachineComputer 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 .
Introduction Project Idea• Automation of 3 Motors to control the coordinates (X,Y,Z)of a pen with flexible head can be used as Plotter.
History The first commercial NC machines were built in the 1950s, 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 withoutThe first commercial NC requiring constantwww.cnccookbook.com attention from their operator.
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 Architecture cont Software SubsystemThere 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 Mechanical Subsystem 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 Architecture cont CNC Machine Mechanical Design: Figure-1 Different views of Our CNC Machine
System Architecture cont Electronic Subsystem 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.
Control Modes• We have three types of control mode: -Calibration Mode (CL). -Load Mode (LD). -Execution Mode (EXE).
Control Mode instructionCommand DescriptionCL Manual ModeLD Program ModeSTART Executed the program stored on RAMEXE Read G_Line from serial and executed it immediately and acknowledge the next instructionRESET Reset the machine to the initial X_co,Y_co_Z_co coordinatesSETBX Set border of our board on X-axisSETBY Set border of our board on Y-axisSETBZ Set border of our board on Z-axis
State ChartState 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  and operand  then put result set on Operand . MUL MUL operand  and operand  then put result on Operand . JEQ Jump if flag is set. JNE Jump if flag is reset. CMP Compare operand  and operand  and set Equal flag. EOP End of program.
Bresenham Line Drawing G01 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 • 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);Figure-2 Sub-pixel displayhttp://en.wikipedia.org/wiki/Pixel
ExampleCode 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 7° 60° 30° 45° Figure 3 our Implementation of Bresenham line drawing on Console Screen Different slope
Midpoint Algorithm G02,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 Bresenhams line algorithm, and is thus sometimes known as Bresenhams circle algorithm.
Midpoint Algorithm Example Bresenhams Circle algorithmFigure-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 Foreground Foreground Step Step Step Time process process MotoX MotoZ MotoYFigure-4Context switching betweenStep(&MotorX),Step(&MotorY) andStep(&MotorZ)
Testing and Simulations… (PROTEUS) • 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