Machine.config_PPU()

[Motion86]

描述

Set Pulses per Unit (PPU), this unit determines the distance the machine moves per unit of movement, i.e., how many pulses per unit of movement are required. For example, 80 pulses/mm.

語法

machine.config_PPU(axis, pulses_per_mm);

參數

  • machine: the machine object.
  • axis: the axis of motion you want to set, can be AXIS_X, AXIS_Y or AXIS_Z.
  • pulses_per_mm: the number of pulses to be output for the single motion distance of the axis, which is defined as pulses/mm.

回傳

  • true: The setting was successful.
  • false: The setting error means that the machine does not exist or was set up after the machine was started.

Please make sure that the machine exists and make sure that the machine is set up before starting the machine.

範例

Set the basic parameters of the machine and move the machine to the Home point.

#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);
  // Set the software limit for the machine motion.
  machine.config_PosLimit(AXIS_X, 0, 300);
  machine.config_PosLimit(AXIS_Y, 0, 200);
  machine.config_PosLimit(AXIS_Z, 0, 300);
  // Set the pin used to set the limit switch for the home point.
  machine.config_HomePins(2, 7, 8);
  // Before controlling, the machine must be started.
  machine.machineOn();
  // Set the default feed rate.
  machine.setDefaultFeedrate(400);
  // Start the software limit.
  machine.enableSoftLimit();
  // Set the feed rate to return to home.
  machine.setHomeSpeed(1000, 1000, 200);
  // Start the stepper motor.
  digitalWrite(EnablePin, LOW);
  // Return to the home point defined by the limit switch.
  machine.home();
 
home(); }
 
void loop() {
  // Motion control code...
}

參考


函式庫參考主頁面

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

發表評論

上部へスクロール