[Motion86]
描述
Enter a G-Code to control the Machine.
Motion86 supports the following G-Codes:
請參考 the G-Code reference table.
| G-Code | 描述 |
| G1 | 直線運動 |
| 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 |
語法
machine.gcode(cmd);
參數
machine: Machine object.cmd: The G-Code string to be sent.
回傳
bool:
- true: The machine exists and was created successfully.
- false: The machine does not exist or failed to create.
範例
#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());
}函式庫參考主頁面
86Duino 參考的文本是根據 知識共享署名-相同方式分享 3.0 許可證,部分文本是從 Arduino 參考 修改的。 參考中的代碼示例已發佈到公共領域。