#include "Motion86.h"
// Generate machine objects. You can use up to three machines, machine 0~2, each with three axes.
Machine machine(0);
// Stepper motor enable pin.
int EnablePin = 4;
void setup() {
while (!Serial);
pinMode(EnablePin, OUTPUT);
// If necessary, the direction of the motion axis can be reversed.
machine.config_ReverseDirection(AXIS_X);
machine.config_ReverseDirection(AXIS_Y);
// PPU (pulse per unit) is a virtual length unit, depending on different needs.
// In this example, the unit length of the x-axis is set to 80 pulses, which corresponds to 1 mm in actual application.
machine.config_PPU(AXIS_X, 80.0);
machine.config_PPU(AXIS_Y, 80.0);
machine.config_PPU(AXIS_Z, 1600.0);
// Before controlling, the machine must be turned on.
machine.machineOn();
// Set the preset feed rate.
machine.setDefaultFeedrate(600);
// Start the stepper motor.
digitalWrite(EnablePin, LOW);
// Use the absolute coordinate value to plan the movement based on the home point.
// If no home point is set separately, the home point is the current position when the machine is turned on.
machine.setAbsolute();
// Use absolute coordinate values to move to the center.
machine.line(170,100,10,400);
machine.line(170,100,10,800);
machine.line(170,100,0,400);
}
void loop() {
// Move to this absolute position. No feed rate is set here, which means the preset value is used.
machine.line(170,100,0);
machine.line(180,100,0);
machine.line(180,110,0);
machine.line(170,110,0);
// Wait until the planned movement is completed.
while (machine.isMoving());
}
|