I want to find...

Search

Shares

Table of Content

Machine.gcode()

[Motion86]

Description

Enter a G-Code to control the Machine.

Motion86 supports the following G-Codes:

Please refer to the G-Code reference table.

G-CodeDescription
G1Linear motion
G2Clockwise circular motion
G3Counterclockwise circular motion
G4Pause command
G17Select XY plane for circular motion
G18Select XZ plane for circular motion
G19Select YZ plane for circular motion
G90Absolute position mode
G91Relative position mode
G90.1Absolute position mode at the center of the arc
G91.1Arc center relative position mode
G92Coordinate System Offset

Syntax

machine.gcode(cmd);

Parameters

  • machine: Machine object.
  • cmd: The G-Code string to be sent.

Returns

bool:

  • true: The machine exists and was created successfully.
  • false: The machine does not exist or failed to create.

Example

#include "Motion86.h"
 
// Produce machine parts, up to machine 0~2 three machines, three axes per machine. 
Machine machine(0);
 
// Stepper motor enable pin.
int EnablePin = 4;
 
void setup() {
  while (!Serial);
  pinMode(EnablePin, OUTPUT);
 
  // If necessary, the direction of motion of the motion axis can be reversed.
  // In this example, it is necessary to reverse the direction of the x-axis and y-axis.
  machine.config-ReverseDirection(AXIS-X);
  machine.config-ReverseDirection(AXIS-Y);
 
  // PPU (pulse per unit) is a virtual length unit, depending on the requirements.
  // The unit length of the x-axis is set to 80 pulses, which corresponds to 1 mm for actual application.
  machine.config-PPU(AXIS-X, 80.0);
  machine.config-PPU(AXIS-Y, 80.0);
  machine.config-PPU(AXIS-Z, 1600.0);
 
  // Before control, the machine must be started.
  machine.machineOn();
 
  // Start the stepper motor.
  digitalWrite(EnablePin, LOW);
}
 
void loop() {
  // Move left to (-10, 0).
  machine.gcode("G1 X-10 Y0 F400");
 
  // Move 90 degrees clockwise by radius 10 to (0, 10).
  machine.gcode("G2 X0 Y10 R10 F400");
 
  // Move down to (0, -10).
  machine.gcode("G1 X0 Y-10 F400");
 
  // Move 90 degrees counterclockwise at radius 10 to (10, 0).
  machine.gcode("G3 X10 Y0 R10 F400");
 
  // Move left to (0, 0).
  machine.gcode("G1 X0 Y0 F400");
 
  // Wait until the planned campaign is completed.
  while (machine.isMoving());
}

Libraries Reference Home

The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Leave a Comment

Scroll to Top