[Motion86]
描述
Plan the movement in relative increments.
語法
Machine machine(0);
machine.setRelative();
參數
machine
: Machine object.
回傳
無
範例
Use relative movement to draw the square.
#include "Motion86.h" // Generate machine objects, up to machine 0~2 three machines, each machine has three axes. Machine machine(0); // Stepper motor enable pin. int EnablePin = 4; void setup() { while (!Serial); pinMode(EnablePin, OUTPUT); // If necessary, you can reverse the motion direction of the motion axis. machine.config_ReverseDirection(AXIS_X); machine.config_ReverseDirection(AXIS_Y); // PPU (pulse per unit) is a virtual length unit, depending on different requirements. // In this example, the unit length of x-axis is set to 80 pulses, which corresponds to 1 mm in real application. machine.config_PPU(AXIS_X, 80.0); machine.config_PPU(AXIS_Y, 80.0); machine.config_PPU(AXIS_Z, 1600.0); // The machine must be started before control. machine.machineOn(); // Set the default feed rate. machine.setDefaultFeedrate(600); // Start the stepper motor. digitalWrite(EnablePin, LOW); // Use relative incremental value to plan the motion. machine.setRelative(); // Move to the center using the relative incremental value based on the current position. machine.line(0,0,10,400); machine.line(170,100,0,800); machine.line(0,0,-10,400); } void loop() { // Move to the relative position, no feed rate is set here which means the default value is used. machine.line(10,0,0); machine.line(0,10,0); machine.line(-10,0,0); machine.line(0,-10,0); // Wait until the planned movement is completed while (machine.isMoving()); }
參考
函式庫參考主頁面
86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。