Top Banner
Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology
41

Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Mar 29, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining & G-code

Dept. of Mechanical Engineering

The Hong Kong University of science and Technology

Page 2: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Outline• Introduction of virtual CNC machining system User interface Interactive operation Controller operation Example• Introduction of G-code Terminology Address character Suggestions Examples

Page 3: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Part1: Virtual CNC machining

Machine tool Controller

NC codes

Coordinates

System parameters

Control panel

Page 4: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Interactive operation

• Hold the left button: move left and right/ zoom in and zoom out• Hold the middle button: move up and down• Hold the right button: rotate

Set transparency

View option

Safety door can be open

Page 5: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Interactive operation

• Press “L”, switch on/off the “light”• Press ”S”, show/hide the “coolant pipe”

Coolant pipe

Page 6: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Controller operation

Hand wheel

Home return light

Emergency stop knob

Over travel alarm

Single block switch

Default operation modes

Page 7: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

1. MEM: To cycle start the NC codes simulation2. MDI: Manual Data Input that could be used to enter some NC

blocks3. Zero RTN: To return to machine HOME positions of X, Y, and Z

axes4. JOG: To move X, Y, Z axes individually5. Handle: To operate the virtual machine tool by the wheel of

mouse6. Rapid: To rapidly move X, Y, Z axes individually 7. Step: To move X, Y, Z axes stepwise

Virtual CNC machining: Controller operation

Page 8: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Zero return:

Virtual CNC machining: Controller operation

Why Z-axis should be zero returned first??

1. Click the “zero RTN” operation mode

2. Choose the “Z” axis in XYZ option

3. Click “zero return” button to initiate the Z-axis zero return

4. Next, zero return X-axis and Y-axis respectively

Page 9: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Jog: move x, y, z axes individually

Virtual CNC machining: Controller operation

1. Click the “JOG” operation mode

2. Choose the axis

3. Select the jog speed 4. Select the direction and jog

Page 10: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Handle : move x, y, z axes by rolling the wheel

Virtual CNC machining: Controller operation

1. Click the “Handle” operation mode

2. Choose the axis

3. Select the multiple

4. Roll the wheel of mouse to “handle” the axis

Page 11: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Rapid: To rapidly move X, Y, Z axes individually

Virtual CNC machining: Controller operation

1. Click the “Rapid” operation mode

3. Select the movement speed

2. Choose the axis

4. Select the direction and move rapidly

Page 12: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Step: To move X, Y, Z axes stepwise

Virtual CNC machining: Controller operation

1. Click the “Step” operation mode

2. Select the direction and move stepwise

Page 13: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

MDI: Input NC blocks and execute in MDI mode

Virtual CNC machining: Controller operation

1. Click the “MDI” operation mode

0. Zero return Z-axis first!

2. Input your NC blocks here

3. Cycle start to execute NC blocks

Page 14: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

MEM: Automatic execution mode

Virtual CNC machining: Controller operation

1. Click the “MDI” operation mode

2. Select the NC file

3. The NC code will be read and shown in the screen

4. Cycle start to execute NC blocks

Page 15: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Controller operation

Emergency stop

• Click this button for emergency stop.

• The execution will be stopped.

• Release the button to enable the controller again.

Page 16: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Spindle speed control:The rotation speed of spindle can be controlled by these six buttons, and also by S code (will be discussed in the following slides)

Virtual CNC machining: Controller operation

• CW: Clockwise• STOP: Stop rotating• CCW: Counter-Clockwise• Inc: Increase Speed• Nor: Normal Speed• Dec: Decrease Speed

Page 17: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Tool exchange

There are 10 built-in milling cutters in the tool magazine. The related cutter dimensions and descriptions can be shown by selecting the “Tools” menu under the “Config” menu.

Page 18: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Tool exchange

3. Input tool exchange command, for example “M6 T10”

2. Choose MDI mode

4. Click Cycle Start to execute tool exchange

1. Zero return Z-axis first for too exchange

Page 19: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

1. Zero return Z-axis.2. Load the workpiece 1 (if not).3. Change to the cutter T3.4. Choose “Auto edge finding” function.5. The “Auto edge finding” window will be prompted.6. Use JOG and Handle mode to Move the T3 cutter to the

location “X015.792”, “Y098.630, and Z004.171, near the edge of workpiece.

7. Rotate the spindle by clicking CW.8. Select “X”, click “+” to drive the cutter automatically to find

the edge.9. The cutter will stop moving when it sticks onto the edge.

Virtual CNC machining: Automatic edge-finding

Page 20: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Virtual CNC machining: Automatic edge-finding

1

23 4

5 6

8

9

7

Page 21: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

1. Zero return Z-axis.2. Load the workpiece 1 (if not).3. Change to the cutter T5.4. Use JOG and Handle mode to Move the T5 cutter to the edge

of the workpiece.5. The alarm on T5 will turn red as soon as it reaches the edge.

Virtual CNC machining: Manual edge-finding

Page 22: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

The over-travel alarm will be shown when any one of the axes is moved out of its range. This alarm could be released by changing to JOG mode and move back to the permissible range.

Virtual CNC machining: Over-travel alarm

Page 23: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Dimension and profile of this workpiece

Virtual CNC machining: Example

Page 24: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

1. Load the workpiece 1.2. Read the NC file “ex1.nc”.3. The G-code will be displayed onto the screen.4. Choose the MEM mode, and click “Cycle Start”.5. The tool path will be traced and shown onto the workpiece.

Virtual CNC machining: Example

Page 25: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

G91 G28 Z0G91 G28 X0 Y0T10 M6G90G92 X-450.000 Y250.000 Z375.000G0 X0. Y10. Z10.M08M03 S1000G1Z-4. F910.X43.X51. Y23.856Y39.X68.Y18.X90.Y90.X40.X18. Y68.Y47.X30.Y35.X10.X24.434 Y10.Z20.M09M05M30

Virtual CNC machining: Example

G-Code of this example:

WE WLLL DISCUSS THE DETAILS IN THE NEXT CHAPTER!!

Page 26: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Part2: Introduction of G-codeG-code is a common name for the most widely used numerical control (NC) programming language, it is a language in which people tell computerized machine tools what to do and how to do it.

1. Which function is activated in machine?

2. Where to move to?3. How fast to move?4. Through what path to move?

Operate CNC machines Begin in the form of punch tape Develop into computer chips in

the 1970s

Page 27: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Introduction of G-code

N1 M06 T1 ; Change to tool #1

Block Sequence #Miscellaneous code: Tool change

Tool Number

Comment

Comment separator

Sample Program Block

Page 28: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Introduction of G-codeSample Program Block

N02 M03 S1500; Turn spindle on at 1500 rpm

Line Number

Miscellaneous code: Turn spindle on

Spindle Speed: 1500 rpm

Page 29: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

• Block – A single line of code in an NC part program• Word – The programming expression formed when a letter (address

character) is combined with a number• Address Character – A letter used in G & M code programming to

designate a class of functions• Parameter – Attribute of a feature for geometrical information, such as a

dimension, that can be modified

Introduction of G-codeTerminology

N00 G90 G01 X.5 Y.5 Z0 F1

Page 30: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

• N – Sequence or line number• G – Preparatory function• M – Miscellaneous function• F – Feed rate (inches per minute or millimeters per minute)• S – Spindle speed (rpm – revolutions per minute)• T – Tool number• X, Y, Z – Distance (Relative Coordinates) or position (Absolute

Coordinates) in X, Y, Z direction• I, J ,K – Circular cutting reference for X, Y, Z axis, respectively

Introduction of G-codeAddress character

Page 31: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

1. G90 : Absolute Coordinates2. G91 : Relative Coordinates3. G92: Programming of absolute zero point.4. G28: Move to Origin 5. G00 : Rapid Traverse (non-cutting move)6. G01 : Straight Line Interpolation (cutting move)7. G02 : Circular Interpolation (clockwise)8. G03 : Circular Interpolation (counter-clockwise)9. G04 : Dwell (wait)10. G05 : Pause – Wait for user intervention

Introduction of G-codePreparatory: G Codes

Page 32: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Introduction of G-codePreparatory: G Codes

Absolute coordinatesExample

N001 G90 ; Absolute coordinatesN002 G01 X1 Y2 ; startN003 G02 X2 Y1 R1; Circular Interpolation X2Y1

X1Y2

R1

dy

X1Y2

R1

Relative coordinatesExample

N001 G91; Relative coordinatesN002 G01 X1 Y2 ; startN003 G02 dx dy R1 ; Circular Interpolation dx

Page 33: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

1. M00 : Pause 2. M01 : Sleep3. M03 /M04: Spindle on (CW/CCW).4. M05 : Spindle off5. M06 : Tool change6. M08 / M09 : Coolant on / off7. M10 / M11 : Vacuum on / off (Dust collection vacuum

system turned on/off)8. M30 : Program end and reset

Introduction of G-codeMiscellaneous: M Codes

Page 34: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

• Same code is not required to be repeated every block, machine will use same code until changed

• Tab remarks away from code to facilitate troubleshooting program

• Specify absolute or relative coordinates and inch or metric modes at beginning of program

• Move tool to safe position away from material before tool change command; change tool if necessary

• Indicate spindle speed each time turned on

Introduction of G-codeSuggestions

Page 35: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

• Move tool to start position in two lines– First line moves in X-Y plane, then moves in Z axis (WHY?)

• Raise tool up to position out of the stock at end of program• Always move table to safe unload position and turn spindle off

at end of program• Use M30 command to end program

Introduction of G-codeSuggestions

Page 36: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Introduction of G-codeExample 1- Absolute coordinates

LABEL X YA 0.5 0.5B 0.5 1.5C 0.875 1D 1.25 1.5E 1.25 0.5F 1.75 1.5H 1.75 0.5I 1.75 1

Absolute coordinates

Page 37: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

N0 G90 G20 ; ABSOLUTE COORD & INCH MODEN5 M06 T1 ; TOOL CHANGE – LOAD TOOL 1N10 M03 S3000 ; TURN SPINDLE ON CW TO 3000 RPMN15 G00 X.5 Y.5 ; RAPID TO POINT AN20 G00 Z.1 ; RAPID TO .1 ABOVE PARTN25 G01 Z-.0625 F9 ; PLUNGE 1/16 AT 9 IN./MINN30 G01 X.5 Y1.5 F18 ; STRAIGHT LINE INTERP TO BN35 G01 X.875 Y1 ; STRAIGNT LINE INTERP TO CN40 G01 X1.25 Y1.5 ; STRAIGHT LINE INTERP TO DN45 G01 X1.25 Y.5 ; STRAIGHT LINE INTERP TO EN50 G01 Z.1 ; RETRACT CUTTING TOOLN55 G00 X1.75 Y1.5 ; RAPID TO POINT FN60 G01 Z-.0625 F9 ; PLUNGE AT 9 IN./MINN65 G01 X1.75 Y.5 F18 ; STRAIGHT LINE INTERP TO HN70 G03 X1.75 Y1.5 I1.75 J1 ; CCW CIRCLE INTERPOLATIONN75 G01 Z.1 ; RETRACT CUTTING TOOLN80 M05 ; TURN OFF SPINDLEN85 G00 Z2 ; RAPID Z TO SAFE POSITIONN90 G00 X4 Y3 ; MOVE TABLE TO UNLOAD POSITIONN95 M30 ; END OF PROGRAM

Introduction of G-codeExample 1- Absolute coordinates

Page 38: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Introduction of G-codeExample 1 - Relative coordinates

LABEL X YA 0.5 0.5B 0 1C 0.375 -0.5D 0.375 0.5E 0 -1F 0 1H 0 -1I 0 0.5

Relative coordinates

Page 39: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

N00 G90 G20 ; ABSOLUTE COORD & INCH MODEN5 M06 T1 ; TOOL CAHNGE – LOAD TOOL 1 N10 M03 S3000 ; TURN SPINDLE ON CW TO 3000 RPMN15 G00 X.5 Y.5 ; RAPID TO POINT AN20 G00 Z.1 ; RAPID TO .1 ABOVE POINT AN25 G91 ; INCREMENTAL COORD & INCH MODEN30 G01 Z-.1625 F9 ; PLUNGE 1/16 AT 9 IN./MINN35 G01 X0 Y1 F16 ; STRAIGHT LINE INTERP TO BN40 G01 X.375 Y-.5 ; STRAIGHT LINE INTERP TO CN45 G01 X.375 Y.5 ; STRAIGHT LINE INTERP TO DN50 G01 X0 Y-1 ; STRAIGHT LINE INTERP TO EN55 G01 Z.1625 ; RETRACT CUTTING TOOLN60 G00 X.5 Y1 ; RAPID TO POINT FN65 G01 Z-.1625 F9 ; PLUNGE AT 9 IN./MINN70 G01 X0 Y-1 F16 ; STRAIGHT LINE INTERP TO HN75 G03 X0 Y1 I0 J.5 ; CCW CIRCLE INTERPN80 G01 Z.1625 ; RETRACT CUTTING TOOLN85 M05 ; TURN OFF SPINDLEN90 G90 ; CHANGE TO ABSOLUTE COORD N95 G00 Z2 ; RAPID Z TO SAFE POSITIONN100 G00 X4 Y3 ; MOVE TABLE TO UNLOAD POSITIONN105 M30 ; END OF PROGRAM

Introduction of G-codeExample 1 - Relative coordinates

Page 40: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

Introduction of G-codeExample 2 – The previous example

G91 G28 Z0G91 G28 X0 Y0M6 T10G90G92 X-450.000 Y250.000 Z375.000G0 X0. Y10. Z10.M08M03 S1000G1 Z-4. F910.X43.X51. Y23.856Y39.X68.Y18.X90.Y90.X40.X18. Y68.Y47.X30.Y35.X10.X24.434 Y10.Z20.M09M05M30

Ellipsis: Use the previous parameters

Can you explain the code in red?

http://reprap.org/wiki/G-code

Page 41: Virtual CNC machining & G-code Dept. of Mechanical Engineering The Hong Kong University of science and Technology.

End of tutorial

Thank you!