machineOff()

描述

將 Machine 物件切換為 MachineOff 的模式。
使用任何運動控制相關方法前必須先進入 MachineOn 模式後才能使用,進入 MachineOn 模式後即不能組態 config 相關方法,若想要在 MachineOn 後使用 config 相關方法就必須先進入 MachineOff 模式後才能組態。

語法

macine.machineOff();

參數

machine:為 Machine物件。

無參數。

回傳

無回傳值。

範例

設定機器的基本參數,MachineOn 後移動,接著 MachineOff再次組態設定。

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

#include "Motion86.h"

 

// 產生機器物件,最多可使用 machine 0~2 三台機器,每台機器三軸。

Machine machine(0);

 

// 步進馬達 enable pin。

int EnablePin = 4;

 

void setup() {

  while (!Serial);

  pinMode(EnablePin, OUTPUT);

 

 

  // PPU (pulse per unit) 是一虛擬長度單位,依照不同需求而定。

  // 此例 x 軸的單位長度設定為 80 pulses,對應到實際應用為 1 mm。

  machine.config_PPU(AXIS_X, 80.0);

  machine.config_PPU(AXIS_Y, 80.0);

  machine.config_PPU(AXIS_Z, 3200.0);

   

  // 控制之前,必須啟動機器。

  machine.machineOn();

  machine.setDefaultFeedrate(400);

   

  // 啟動步進馬達。

  digitalWrite(EnablePin, LOW);

   

  machine.line(10, 10, 0);

   

  // We should turn off the machine before config it.

  machine.machineOff();

   

  // 若有需要,可以反轉運動軸的運動方向。

  // 在此範例中,需要反轉 x 軸和 y 軸的方向。

  machine.config_ReverseDirection(AXIS_X);

  machine.config_ReverseDirection(AXIS_Y);

 

  // 控制之前,必須啟動機器。

  machine.machineOn();

   

  machine.line(20, 20, 0);

}

 

void loop() {

 

}

See also

machineOn()


函式庫參考主頁面

86Duino 參考資料的文字遵循知識共享署名-Creative Commons Attribution-ShareAlike 3.0 License。參考資料中的程式碼範例已發佈到公共領域。