Machine.getJogPos()

[Motion86]

説明

Get the target position of the machine in JOG / MPG mode.

Syntax

machine.getJogPos(axis);
machine.getJogPos(x, y, z);

Parameters

  • machine: the machine object.
  • axis: the motion axis to get the position, it can be AXIS_X, AXIS_Y or AXIS_Z.
  • x: the target position of X-axis.
  • y: The target position of Y-axis.
  • z: The target position of Z-axis.

Returns

  • getActualPos(axis): double:Return the position of the motion axis.
  • getActualPos(x, y, z): No return value, directly use the reference to get the X, Y, Z axis position.

Example

Set the basic parameters of the machine and enable the Jog mode to move when the button is triggered.

#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, the motion direction of the motion axis can be reversed.
  // In this example, the direction of x-axis and y-axis should be reversed.
  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 machine to jog mode and trigger it with the connected button.
  machine.beginJog(27, 28, 32, 3, 16, 17, false);
 
  // If the Machine is set to Inc Jog mode, the offset should be configured to set how many millimeters to move with each click.
  // machine.beginJog(27, 28, 32, 3, 16, 17, true);
  // machine.setJogOffset(1.0);
 
  // Feed speed in Jog mode.
  machine.setJogSpeed(600);
 
  // Start the stepping motor.
  digitalWrite(EnablePin, LOW);
}
 
void loop() {
  Serial.print("Jog position = ");
  Serial.print(machine.getJogPos(AXIS_X));
  Serial.print(", ");
  Serial.print(machine.getJogPos(AXIS_Y));
  Serial.print(", ");
  Serial.println(machine.getJogPos(AXIS_Z));
  delay(500);
}

See also


Libraries Reference Home

86Duino のリファレンスのテキストは Arduino レファレンス を編集したもので、 Creative Commons Attribution-ShareAlike 3.0 License下でライセンスされています。リファレンス内のコードサンプルはパブリックドメインとして公開されています。

コメントする

上部へスクロール