G-code is a language used to control CNC (Computer Numerical Control) machines. G91 and G28 are specific G-codes that play crucial roles in machine operations. G91 sets the machine to incremental positioning, while G28 is used to return the machine to its home position. Understanding these codes is essential for precise and efficient CNC machining.
What is G91 G-code?
G91 G-code is used to set a CNC machine to incremental positioning. In this mode, all movements are made relative to the current position. This is different from absolute positioning (G90), where movements are based on a fixed origin point. Incremental positioning is useful for repetitive tasks where each movement is relative to the last.
How Does G91 Work?
- Incremental Movement: Each command moves the tool relative to its current position.
- Repetitive Tasks: Ideal for tasks that require the same movement pattern repeatedly.
- Flexibility: Allows for complex machining paths without resetting the origin.
Example of G91 in Use
Consider a scenario where a CNC machine needs to drill holes at regular intervals along a line. Using G91, you can program the machine to move a specific distance from its current position for each hole, simplifying the process.
G91
G01 X10 Y0 ; Move 10 units in the X direction
G01 X10 Y0 ; Move another 10 units in the X direction
What is G28 G-code?
G28 G-code is used to return the CNC machine to its home position. This is a predefined location, often used as a reference point for starting or ending operations. G28 ensures that the machine is in a known position, which is crucial for maintaining accuracy and consistency.
How Does G28 Work?
- Home Position: Moves the tool to a predefined origin point.
- Safety: Ensures the machine is in a safe position before starting or after completing tasks.
- Consistency: Helps maintain accuracy across multiple operations.
Example of G28 in Use
After completing a machining task, you might want to return the tool to its home position to prepare for the next operation or to safely shut down the machine.
G28 X0 Y0 ; Return to home position in X and Y axes
Benefits of Using G91 and G28
- Efficiency: Streamlines repetitive tasks and reduces setup time.
- Precision: Ensures accurate positioning and movement.
- Safety: Minimizes the risk of errors and damage to the machine or workpiece.
Comparison of G91 and G28
| Feature | G91 | G28 |
|---|---|---|
| Positioning Type | Incremental | Absolute (Home Position) |
| Primary Use | Relative movements | Returning to home position |
| Ideal For | Repetitive tasks | Starting/ending operations |
| Safety | Medium | High |
People Also Ask
What is the difference between G90 and G91?
G90 sets the machine to absolute positioning, where all movements are based on a fixed origin point. In contrast, G91 uses incremental positioning, where movements are relative to the current position. This distinction is crucial for programming CNC machines for different types of tasks.
How do I set a home position using G28?
To set a home position using G28, you first need to define the coordinates of the home position in the machine’s control system. Once set, you can use the G28 command to return the machine to this position at any time, ensuring a consistent starting or ending point for operations.
Can G28 be used with G91?
Yes, G28 can be used with G91. In practice, you might use G91 for incremental movements during a task and then issue a G28 command to return the tool to its home position afterward. This combination allows for flexible and efficient machining operations.
Why is G28 important for CNC safety?
G28 is important for CNC safety because it ensures the machine returns to a known, safe position. This prevents collisions and reduces the risk of errors when starting new operations or shutting down the machine. It also facilitates maintenance and tool changes.
How do I switch between G90 and G91?
To switch between G90 and G91, simply issue the corresponding G-code command. For example, use G90 to switch to absolute positioning and G91 to switch to incremental positioning. This flexibility allows you to adapt the machine’s programming to different tasks as needed.
Conclusion
Understanding the roles of G91 and G28 G-codes is essential for anyone working with CNC machines. These codes offer flexibility and precision, enabling efficient and accurate machining operations. By mastering their use, operators can enhance productivity and maintain high safety standards. For further insights into CNC programming, consider exploring related topics such as G-code basics and CNC machine maintenance.





