config_PPU()

Description

Set Pulses per Unit (PPU). This unit determines the unit moving distance of the machine.
That is, how many pulses need to be output for each unit distance. For example, 80 pulses/mm.

Syntax

machine.config_PPU(axis, pulses_per_mm);

Parameters

machine: Machine object.

axis: The axis to be set, which can be AXIS_X, AXIS_Y or AXIS_Z.

pulses_per_mm: Set the unit moving distance of the axis, how many pulses need to be output, in this example it is defined as pulses/mm.

Return

true: Setting is successful.
false: Setting error, which means the machine does not exist or the setting is made after the machine is started.
Please make sure the machine exists and make sure to set the machine before starting the machine.

Example

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

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

#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);

  // Set the software limit of the machine movement.

  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 by the limit switch to set the home point.

  machine.config_HomePins(2, 7, 8);

  // Before controlling, the machine must be turned on.

  machine.machineOn();

  // Set the default feed rate.

  machine.setDefaultFeedrate(400);

  // Start software limits.

  machine.enableSoftLimit();

  // Set the feed rate to return to the home point.

  machine.setHomeSpeed(1000, 1000, 200);

  // Start the stepper motor.

  digitalWrite(EnablePin, LOW);

  // Return to the home point defined by the limit switch.

  machine.home();

 

}

 

void loop() {

  //Motion control code...

}

See also

computePPU_Belt()
computePPU_LeadScrew()
config_ReverseDirection()


Library Reference

The text of the 86Duino reference material is licensed under the Creative Commons Attribution-Share Alike 3.0 License. The code examples in the reference material have been released into the public domain.