config_EGearSlave()

描述

电子滚轮可设置为相对于电子滚轮移动轴,使用此功能后,目标设备也可设置为相对于电子滚轮移动轴。

 

用法
machine.config_EGearSlave(target, xRatio, yRatio, zRatio);

 

参数

machine用于 Machine 属性。

target用于 Machine 对象,此目标设备取决于相对于坐轴运动的电子齿轮。

xRatio:对应于 X 轴的电子齿轮比。

yRatio:Y 轴的电子齿轮比。

zRatio:Z 轴的电子齿轮比。

 

回传

bool:

true:两个设备均存在且构建成功。

false:可选设备不存在或创建失败。

 

Slave_machine 将对电子齿齿率(1.5, 0.5, 1.0) 紧随机器进行G代码运动。

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

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

#include "Motion86.h"

#include "SD.h"

 

// 生产设备属性,最大可用机器0~2台3台,每台3轴。

// 在此示例中,我们使用机器 0 和机器 1。

Machine machine(0);

Machine slave_machine(1);

 

// 步进马达 enable pin。

int EnablePin = 4;

 

// 此 gcode 位于 SD 卡中。

char *filename = "auto.gcode";

File gfile;

char buf[256];

int ptr;

bool working;

 

void setup() {

  while (!Serial);

  pinMode(EnablePin, OUTPUT);

 

  // 运动轴上的运动方向可以反转。

  // 在这个例子中,需求是x轴和y轴方向的总和。

  machine.config_ReverseDirection(AXIS_X);

  machine.config_ReverseDirection(AXIS_Y);

 

  // PPU(每单位脉冲)这是一个伪长度,它与同需求不同。

  // 本例中x轴长度设置为80个脉冲,实际设置为1毫米。

  machine.config_PPU(AXIS_X, 80.0);

  machine.config_PPU(AXIS_Y, 80.0);

  machine.config_PPU(AXIS_Z, 1600.0);

 

  // 设置设备动能软体限制。

  machine.config_PosLimit(AXIS_X, 0, 300);

  machine.config_PosLimit(AXIS_Y, 0, 200);

  machine.config_PosLimit(AXIS_Z, 0, 300);

 

  // 用于极限开启点使用的主页设置和密码设置的设置。

  machine.config_HomePins(2, 7, 8);

 

  // 在此示例中,slave_machine 需求沿 y 轴反转。

  slave_machine.config_ReverseDirection(AXIS_Y);

 

  // 设定 slave_machine 的 PPU (pulse per unit)。

  slave_machine.config_PPU(AXIS_X, 80.0);

  slave_machine.config_PPU(AXIS_Y, 80.0);

  slave_machine.config_PPU(AXIS_Z, 3200.0);

 

  // 设置slave_machine 动能软体限制。

  slave_machine.config_PosLimit(AXIS_X, 0, 200);

  slave_machine.config_PosLimit(AXIS_Y, 0, 200);

  slave_machine.config_PosLimit(AXIS_Z, 0, 300);

 

  // 配置slave_machine用于家庭配置,并使用极端开口中的引脚。

  slave_machine.config_HomePins(21, 22, 23);

 

  // 将slave_machine设置为machine的EGearSlave,表示slave_machine的计算与machine的运动并行。

  machine.config_EGearSlave(slave_machine, 1.5, 0.5, 1.0);

 

  // 在束缚之前,它是一种必备装置。

  machine.machineOn();

 

  // 极度柔软的身体运动。

  machine.enableSoftLimit();

 

  // 设置原点前进速率。

  machine.setHomeSpeed(1000, 1000, 200);

  slave_machine.setHomeSpeed(1000, 1000, 100);

 

  // 打开SD卡中间的gcode方案

  if (SD.exists(filename)) {

    gfile = SD.open(filename);

    working = true;

  } else {

    Serial.print("File not exists: ");

    Serial.println(filename);

    while (1);

  }

 

  // 启动步进马达。

  digitalWrite(EnablePin, LOW);

 

  // 限位开度点定义为原点。

  machine.home();

}

 

void loop() {

  // 阅读并行分析 gcode 指南。

  // Slave_machine为缩减版gcode路径,宽x1.5、高x0.5。

  if (working && !machine.isCmdBufferFull()) {

    ptr = 0;

    while (gfile.available()) {

      buf[ptr] = gfile.read();

      if (buf[ptr] == '\n') {

        buf[ptr + 1] = '\0';

        machine.gcode(buf);

        break;

      } else {

        ptr ++;

      }

    }

    if (!gfile.available())

    {

      Serial.println("GCODE FINISH");

      gfile.close();

      working = false;

    }

  }

}


 

函式档案参考页面

86Duino 参考资料的文本采用知识共享署名- Creative Commons Attribution-ShareAlike 3.0 License。参考资料中的代码示例已发布到公共领域。