Machine.gcode()

[Motion86]

描述

Enter a G-Code to control the Machine.

Motion86 supports the following G-Codes:

請參考 the G-Code reference table.

G-Code描述
G1直線運動
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

語法

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 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール