me3m02_expt_p3

Embed Size (px)

Citation preview

  • 7/28/2019 me3m02_expt_p3

    1/13

    P3-1

    EXPERIMENT P3

    CNC MACHINING

    Objective:This experiment is designed to introduce the student to a typical Computer Numerical

    Control (CNC) machine tool. The advantages of such systems are discussed, as well as the

    basic control functions and machine codes.

    Background:

    The concept of computer numerically controlled (CNC) machines dates to the 1950s.

    Standards were established to allow interchange of CNC programs amongst different machine

    tools. The basic operation of such a machine tool is described below.

    Figure 1: CNC/CMM system schematic.

    A 500 MHz Pentium III based Window NT workstation, with 256 MB RAM and 20 GB

    of disk space, is at the heart. EdgeCAM is used as the CAD/CAM and Post Processor software.

    A custom written Microsoft Visual C++ program is used to parse the CL-DATA and/or G-code

    files. A pipe based interface to the Spatial Technology Inc. ACIS solid modeler is used for CNC

    geometric verification. The stepper motor based machine tool is controlled in real time, in a

    separate thread, using the Windows NT multimedia timer. A National Instruments PCI-6503

    digital I/O card provides the interface to the stepper motor amplifiers, limit switches, and CMM

    touch trigger probe system. A variable speed Dremill tool is used as the CNC motor, spindle

    and chuck. Off the shelf carbide cutters are used for machining. The touch trigger probe systemis a Renishaw PH1/TP2. An analog game joystick is used for manual positioning. The working

    volume of the machine is 100 mm by 100mm by 50 mm. A photograph of the system is shown

    in Figure 2.

  • 7/28/2019 me3m02_expt_p3

    2/13

    P3-2

    Figure 2: CNC/CMM system.

    Machine Code

    Typically, the machine code is generated from CAD/CAM software such as EdgeCAM

    that writes the machine control codes into an intermediate cutter location data (CL-DATA)

    format. A post processor, translate to the specific machine capabilities, then converts the

    CLDATA format to the language understood by the machine tool controller. G-Code is the

    most common machine code using for the machine tool controller.

    CNC Command Lines

    Computer Numerical Controllers (CNCs) accept program input line by line. Each lineconsists of a sequence of pairs. Comments are enclosed in

    parenthesis. For example (This is a comment.)

    Program number

    Every CNC program begins with the O address letter, which specifies the program

    number. Usually program numbers are restricted to the range 1-1999. No other address letter

    can appear on the same line as the program number. The physical end of the program is

    denoted by a line containing only the % (percent) character. For example, a complete CNC

    program (that accomplishes nothing), number 43, would be written

    O43(This is a program 43.)

    %

    Line Number

    Optionally, each command line can begin with a number, prefixed with the Naddress

    letter.

  • 7/28/2019 me3m02_expt_p3

    3/13

    P3-3

    Spindle SpeedMachine tools are usually equipped with a rotating spindle which turns the cutting tool

    (milling) or turns the part (lathe). To specify the rotational speed in revolutions per minute, use

    the S address letter. For example, to specify 2300 rpm, code S2300. Note that the S addressletter only specifies the spindle speed. To begin actual rotation, anMaddress letter must be

    specified. For clockwise rotation, specify M3. For counterclockwise rotation, specify M4. Tostop rotation, specify M5. To stop the spindle at a repeatable orientation, specifty M19. TheM19 code is used to orient the spindle in preparation for an automatic tool change, when using

    boring bars, and when using touch trigger probes. For safety, never specify the S address letter

    while the spindle is rotating.

    TheMcodes are widely used for Programmable Logic Control (PLC) functions such asspindle rotation, tool changing, opening and closing of access doors, pallet changing, coolant on

    and off, etc.

    Tool Specification

    Many machine tools support automatic exchange of cutting tool using the T addressletter. This indexes the carousel (milling) to the correct position in preparation for tool

    exchange. The actual tool exchange occurs when theM6code is encountered.

    Cutting Fluid (coolant)Cutting fluid or coolant is widely used. This is controlled usingMcodes. To obtain

    flood coolant, codeM7. To obtain mist coolant, codeM8. To shut off coolant, codeM9.

    Program End

    Each program should end with the M30 code. This instructs the CNC to completeexecution and return to the first line of the program.

    For example, the following program loads tool number 7 into the spindle, begins spindle

    rotation at 500 rpm (clockwise), begins flood coolant, stops coolant, stops and orients the

    spindle, and ends execution:

    O43

    (This is program 43.)

    T7M6

    S500M3

    M7

    M9

    M19

    M30

    %

    UnitsCNCs generally accept length input in either inch (G70) or millimeter (G71) mode.

    This is specified at the very beginning of the program.

  • 7/28/2019 me3m02_expt_p3

    4/13

    P3-4

    Axis Letters

    For 3-axis linear, orthogonal axis machines, the axis are labelledX, Y andZ. A right

    hand rule coordinate system is always used. Units are as previously specified using the G70 or

    G71 code. The resulting motion depends on which G address letters are in effect (see below).

    To avoid ambiguity, a decimal point should always be specified, even for integer values. For

    example, to specify an X value of 21, codeX21. (period) rather thanX21.

    Absolute/incremental mode

    Axis motion can be specified either in absolute coordinate (G90) or incrementally with

    respect to the current position (G91). The absolute mode is more commonly used. Incremental

    mode most often is used with subroutines, which are not covered in this brief introductory

    document.

    Point to Point (rapid) motion

    Points to point motion (sometimes referred to as rapid) motion is specified using the G0

    code. This causes the specified axes to move from the current position to the specified new

    position (G90 mode), or incrementally with respect to the current position (G91 mode).Assume, for example, that the machine is currently located at position (X,Y,Z) = (12.0, 14.3,

    8.4). To move from this position to (X,Y,Z)=(15.0, 14.3, 10.0), code G90G0X15.Z10. or

    G91G0X3.Z1.6Note that the motion is not interpolated. That is, the path from the current to

    the new position is not guaranteed to be a straight line. The speed of motion (feed rate) is

    determined by parameters permanently stored within the CNC memory. To obtain interpolated

    straight line motion at a specified feed rate, use the G1 code andF address letter (see below).

    Returning to machine home position

    Every machine has a primary reference or home position. To program a return to home

    position, code G28. The home position is normally where tool exchanges occur, and hence it is

    common to codeG28T7M6

    Resetting the coordinate system

    At power up, the machine zero position is identical to the machine home position. This

    is inconvenient for part programming with EdgeCAM, since it will not be known in advance

    where a part will be located on the machine. To resolve this, the G92 code can be used to reset

    the coordinate system registers. The typical procedure is to:

    1. 1. Power up and home the machine.

    2. 2. Set inch G70 or millimeterG71 mode.3. 3. Execute G92X0.Y0.Z0.4. 4. Move the machine to where the part coordinate system origin is to be located.Record the current machine coordinates as (mpx, mpy, mpz).

    5. 5. Return the machine to the home position using G286. 6. Execute G92X-mpxY-mpyZ-mpz. Note that the negative of the recorded coordinatesare used at this step. The remainder of the CNC program can now be written in part

    coordinates.

  • 7/28/2019 me3m02_expt_p3

    5/13

    P3-5

    Drill canned cycle

    Drilling holes is the most common machining operation, both for metal parts, and

    applications such as printed circuit boards. The CNC code for drilling is G81. The complete

    command line is of the form G80XxvalYyvalZzvalRrvalFfvalTtval. The machine will move in

    point to point (rapid) motion from the current position to the position (xval, yval, rval). It then

    feeds along the z-axis from the position (xval, yval, rval) to the position (xval, yval, zval) at feedratefval. For inch (G70) mode, the feed rate is specified in inches per minute. For millimeter

    (G71) mode, the feed rate is specified in millimeters per minute. When the position (xval, yval,

    zval) is reached, motion stops for a dwell period of tval seconds. Rapid motion back to the

    position (xval, yval, zval) then occurs. Omitted address letters cause the previously specified

    value to be used. The default dwell is zero seconds. This sequence is repeated each time a new

    line containing an axis letter is encountered, until the G80 (end of canned cycle) code is

    encountered.

    At this point, a complete drilling example program can be coded. A description of each

    line is given in comments on the following line.

    O43(specifies the beginning of program number 43)

    N1G71

    (specifies millimeter units)

    N2G90

    (specifies absolute mode)

    N3G28

    (returns to home position)

    N4G92X345.Y280.Z450.

    (resets coordinate system for part programming)

    M5T1M6

    (loads tool 1 into the spindle)N6S2000M3(begins clockwise spindle rotation at 2000 rpm)

    N7M7

    (flood coolant on)

    N8G0X50.8Y25.4Z1.0

    (moves tool to position (50.8, 25.4, 1.0) at rapid rate)

    N9G81X50.8Y25.4Z-40.0R1.F200.T1.

    (drills at feed rate 200 mm/min to Z=-40.0, dwells 1 s, retracts to Z=1.)

    N10G80Z10.

    (cancels drilling cycle, moves to Z=10.)

    N11X101.6(moves tool to (101.6, 25.4, 10.0) at rapid rate)

    N12G81Z-20.R1.T0.

    (drills at feed rate 200 mm/min to (101.6, 25.4, -20), zero dwell, retracts to (101,6, 25.4,1.0))

    N14M9

    (coolant off)

    N15M5

  • 7/28/2019 me3m02_expt_p3

    6/13

    P3-6

    (spindle stop)

    N16G28

    (returns to home position)

    N17M30

    (marks end of program)

    %

    Linear Interpolation

    The ability to simultaneously move more than one axis in coordinated motion is the

    principal benefit of numerical control. Next to drilling, the most common CNC operation is

    milling along a straight line, at a specified feed rate. This is accomplished using the G01 code.

    A typical command line is G01XxvalYyvalZzvalFfval. In G90 (absolute mode), the machine

    moves from its current position to (xval, yval, zval) at feed ratefval. In G91 (incremental mode),

    the machine moves from its current position by a delta amount (xval, yval, zval). The feed rate

    units are inches per minute (G70) mode or millimeters per minute (G71) mode. For example, if

    the machine is currently located at position (200., 300., 430.) then the absolute mode command

    lines to move to position (240., 280., 430.) at a feed rate of 350 millimeters per minute areG71

    G90

    G01X240.Y300.F350.

    The equivalent incremental mode command lines are

    G71

    G91

    G01X40.Y-20.F350.

    Note that, in either case, because the coordinates do not change, the Z address letter is not

    required.

    Circular Interpolation

    Although a circular motion can always be approximated by a sequence of short linear

    moves, the frequency with which holes, fillets, etc. are machined led CNC designers to also

    includes circular interpolation in controllers. Within an individual command line, many

    controllers are restricted to motion within a single circle quadrant. This will be assumed in the

    following discussion.

    Circular interpolation must occur within one of the principal planes. To specify the XY

    plane, code G17. To specify the ZX plane, code G18. To specify the YZ plane, code G19.

    Clockwise motion (from the positive Y axis towards the positive X axis in the XY plane) isspecified using G02.

    Counterclockwise motion is specified using G03. The centre of the circle is specified

    relative to the current position. Use the Iaddress letter for the X axis, the Jaddress letter for

    the Y axis, and the K address letter for the Z axis. For example, to machine along a

    counterclockwise arc in the XY plane centred at position (10., 15., 5.) beginning at (20., 15., 5.)

    ending at (10., 25., 5.) code G91G17G03X10.Y25.I-10.J0.. To machine along a clockwise arc

  • 7/28/2019 me3m02_expt_p3

    7/13

    P3-7

    centred at (10., 15., 5.) beginning at (17.071, 22.071, 5.) and ending at (20., 15., 5.) code

    G91G17G02X20.Y15.I-7.071J-7.071. Feed rates can be specified using Ffval described for

    linear interpolation.

    Cutter length and radius compensation

    For highest part accuracy, it is desirable to delay specification of the exact cutterdimensions until just before execution of the NC program. The G codes G40, G41, G42, G43,

    G44, and G49 are used for this purpose. These advanced features are not covered in this lab.

    Theory:

    Stepper motor driven implementations achieve coordinated motion using the Digital

    Differential Analyzer (DDA) or reference pulse method. The linear interpolation DDA

    algorithm is schematically represented in Figure 3.

    (a) (b)

    Figure 3. Linear DDA Algorithm: (a) Path Variables; (b) Algorithm Schematic

    For our laboratory system, the stepper motor resolution is 400 steps per revolution, and

    the lead screw advances 2 mm per revolution. The linear resolution is therefore d= 200 steps

    per millimeter, and hence each motor step advances the corresponding axis by 5 micrometers.

    For a user specified feed rate ofFmillimeters per minute, the timer callback frequency isf= dF

    /60 Hz, and the callback period is T=60/dFseconds.

    Illustrating with theXYplane, a path ofL steps is separated into components ofa steps

    along the X axis, and b steps along the Y axis. Note that a and b are absolute values. Thestepper motor direction is set by a separate electronic signal. The constant value a is loaded into

    the px register, and the constant value b is loaded into the py register. Both the qx and qy

    registers are initialized to zero.

    During each callback function execution, the value of the px register is added to the qx

    register. The qx register overflows when its value exceeds22 baL += . When this occurs, a

    pulse is sent to advance the Xaxis stepper motor by one step, andL is subtracted from qx. This

  • 7/28/2019 me3m02_expt_p3

    8/13

    P3-8

    architecture achieves an effectiveXaxis step rate offa /L Hz. The Yaxis is handled similarly,

    achieving an effective Yaxis step rate offb /L . The total effective step rate is therefore the

    desired 22 baf + /L =f Hz. Extension to add aZaxis involves expressing the path length as

    222 cbaL ++= wherec is theZaxis component, and includingpz

    andqz

    registers.

    (a) (b)

    Figure 4: Circular DDA Algorithm: (a) Path Variables; (b) Algorithm Schematic

    A schematic representation of the circular DDA algorithm is shown in Figure 4. Again

    theXYplane is used for illustration. As before, the qx

    andqy

    registers are initialized to zero.

    Overflow occurs when the register value exceeds the arc radius 22 jiR += , where i is theX

    component from the start of the arc to the arc center, andj is the Ycomponent from the start ofthe arc to the arc center. The difference from the linear interpolation case is that the p register

    values change. For example, consider a clockwise arc from the 9 o'clock to the 12 o'clock

    position. For this case, the initial values to load are px = j andpy= i. Each time a step is issued

    in the Xdirection, the py

    register is decremented by one. Each time a step is issued in the Y

    direction, thepx

    register is incremented by one. Similar situations hold for the other quadrants,

    and for counterclockwise motion. For arcs in the YZorZXplane, kis theZcomponent from the

    start of the arc to the arc center.

  • 7/28/2019 me3m02_expt_p3

    9/13

    P3-9

    Example: Linear Interpolation

    Let (iniX iniY iniZ) and (finZ,finY, finZ) be initial and final position, respectively. Let

    incX , incYand incZare steps counter. For each command line, DDA performs the following

    procedures.

    1) Initialize: incX, incY, incZ, qx, qy, andqz = 0.2) Compute:

    a. iniXfinXpx =

    b. iniYfinYpy =

    c. iniZfinZpz =

    d. 222 pzpypxL ++=

    3) Compute the timer period:

    Period (ms) =100**

    60

    Dd

    Where dis the step per millimeter (d= 200 steps/mm for our system)4) Execute time callback function, which it involves the following calculations:

    a. qx = qx + pxb. if (incX < px) and (qx >= L), then:

    i. qx = qx L;ii. incX= inc X+1/d;

    iii. the motor in the x-direction takes one step.c. Perform the same calculations in a. and b. forYandZ-axis platformd. Repeat step a. to c. until the condition of the statement can no longer be

    satisfy.

    The following table demonstrates how DDA achieves motion from points (0,0) to (0.015, 0.02).It is equivalent take 3 steps for X axis and 4 steps for Y axis.

    ClockPulse

    Px py qx qy X motorpulse

    Y motorpulse

    1 3 4 3 4 0 0

    2 3 4 6 8 1 1

    3 3 4 4 7 0 1

    4 3 4 7 6 1 1

    5 3 4 5 5 1 1

  • 7/28/2019 me3m02_expt_p3

    10/13

    P3-10

    Experimental Procedure:

    The lab experiment will be demonstrated by a T.A.

    a) Turn On the computer, press Ctrl+Alt+Delete keys and fill in the Username: and

    Password

    c) Go to menu bar, click Mode and select Graphics to enable the

    graphical simulator.

    d) Go to the menu bar, click CNC and select Run Program. The following dialog will be

    displayed:

  • 7/28/2019 me3m02_expt_p3

    11/13

    P3-11

    Go to the tp directory and select roselin.tp file. This file is in text file format so it can

    read by any editor software. When Run Program is excuted, the G-Code command linewill be readed and excuted from beginning to the end of tp file. To run the tp file line by

    line. The users can choose Step Program, and excute the signle comman line by

    pressing key F2 or click on the Single Step that under CNC menu. By clicking Resume,

    the program is switched to continous mode from single step mode. For each G-Code

    comman line, it can be read from excute bar.

    e) To stop the program, the user can select Stop which under CNC menu.

    f) After the tool path is verified. Now, the users can put the part (blank plastic board) on the

    machine table.

    g) Next, turn on the switches in the electronic box.

    h) Set the software as Graphics and Motors mode.

    i) Move the tool tips to the origin of machine part coordinate. This could be done by go to

    CNC, Calibrate and select the axis you would like to move.

    j) When everything has been set up, the users can start to run the program again.

  • 7/28/2019 me3m02_expt_p3

    12/13

    P3-12

    Lab Report:

    Each student is required to submit his or her individual lab report. This report must include G-

    Code command line for the experiment demonstration. T.A. will assign the data points for thecircular interpolation exercise.

    References:

    1. Y. Koren, Computer Control of Manufacturing Systems, McGraw-Hill, TS176.K6515 1983.

    2. I. Zeid, CAD/CAM Theory and Practice, McGraw-Hill, TS155.6.Z45 1991.

    3. R. Olexa, The Father of the Second Industrial Revolution, SME Manufacturing Engineering,August 2001.

  • 7/28/2019 me3m02_expt_p3

    13/13

    P3-13

    Appendix:

    Examples of G-code/M-code commands:

    G code/M code Function

    G00 Rapid positioningG01 Linear interpolation

    G02 Circular interpolation clockwise

    G03 Circular interpolation counterclockwise

    G04 Dwell

    G17 XY plane selection

    G18 ZX plane selection

    G19 YZ plane selection

    G28 Return to reference point (home position)

    G29 Return from reference point

    G70 Inches input

    G71 Metric inputG80 Canned cycle cancel

    G81 Drilling cycle

    G90 Absolute programming

    G91 Incremental programming

    G92 Setting of program zero point

    M00 Program stop

    M01 Optional stop

    M02 End of program

    M03 Spindle start forward (clockwise)

    M04 Spindle start reverse (counterclockwise)

    M05 Spindle stop

    M06 Tool change

    M07 Flood coolant ON

    M08 Mist coolant ON

    M09 Coolant OFF

    M19 Spindle orientation

    M98 Transfer to subprogram

    M99 Transfer to main program (subprogram ends)