[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-Code | Description |
G1 | Linear motion |
G2 | Clockwise circular motion |
G3 | Counterclockwise circular motion |
G4 | Pause command |
G17 | Select XY plane for circular motion |
G18 | Select XZ plane for circular motion |
G19 | Select YZ plane for circular motion |
G90 | Absolute position mode |
G91 | Relative position mode |
G90.1 | Absolute position mode at the center of the arc |
G91.1 | Arc center relative position mode |
G92 | Coordinate 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.