beginJog()

Describe

Enable Jog mode. In this mode, the Machine cannot perform other motion control. It can only use the pull-down switch connected outside the specified pin to perform control.
In Jog mode, the following two control behaviors are distinguished:
Jog Mode – After pressing the switch (pull down), starts moving until it stops after pulling up.
incJog Mode – Click the switch to move a unit distance, and you can set the distance using setJogOffset().

Grammar

machine.beginJog(pX, mX, pY, mY, pZ, mZ);
machine.beginJog(pX, mX, pY, mY, pZ, mZ, incJog);

Parameter

machine: It is an object of Machine

pX: Pin foot position corresponding to the positive direction of the X-axis (plus). 

mX: Pin foot position corresponding to the negative direction of the X-axis (minus). 

pY: Pin foot position corresponding to the positive direction of the Y axis (plus). 

mY: Pin foot position corresponding to the negative direction of the Y axis (minus). 

pZ: Pin foot position corresponding to the positive direction of the Z axis (plus). 

mZ: Pin foot position corresponding to the negative direction of the Z axis (minus). 

incJog: Whether to enable incJog mode, preset to false. .

Return

No return value.

Example

Sets the basic parameters of the machine and enables Jog mode to move when the button is triggered.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

#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 motion of the axis can be reversed.

  // In this example, you need to reverse the direction of the x-axis and the y-axis.

  machine.config_ReverseDirection(AXIS_X);

  machine.config_ReverseDirection(AXIS_Y);

 

  // PPU (pulse per unit) is a virtual unit of length, 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 started.

  machine.machineOn();

 

  // Set the Machine to jog mode and trigger it with the button it is connected to.

  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 each click moves.

  // machine.beginJog(27, 28, 32, 3, 16, 17, true);

  // machine.setJogOffset(1.0);

 

  // Feedrate in Jog mode.

  machine.setJogSpeed(600);

 

  // Start the stepper 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

endJog()
setJogSpeed()
setJogOffset()
getJogPos()


Function library reference

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.