stop()

描述

使 Machine 緊急停止,並將會清除所有控制與規劃。

語法


machine.stop();

參數

machine:為 Machine物件。

無參數。

回傳

無回傳值。

範例

設定機器的基本參數,並將機器移動一秒後進入緊急停止。

 
#include "Motion86.h"

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

// 步進馬達 enable pin。
int EnablePin = 4;

void setup() {
  while (!Serial);
  pinMode(EnablePin, OUTPUT);

  // 若有需要,可以反轉運動軸的運動方向。
  // 在此範例中,需要反轉 x 軸和 y 軸的方向。
  machine.config_ReverseDirection(AXIS_X);
  machine.config_ReverseDirection(AXIS_Y);

  // 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, 1600.0);

  // 控制之前,必須啟動機器。
  machine.machineOn();
  machine.setDefaultFeedrate(400);

  // 啟動步進馬達。
  digitalWrite(EnablePin, LOW);
}

void loop() {
  // 向左移到 (-10, 0)。
  machine.line(-10, 0, 0);

  // 以半徑 10 順時針移動 90 度到 (0, 10)。
  machine.arcXY(10, 0, 10, true);

  // 向下移到 (0, -10)。
  machine.line(0, -10, 0);

  // 以半徑 10 逆時針移動 90 度到 (10, 0)。
  machine.arcXY(10, 10, 0, false);

  // 向左移到 (0, 0)。
  machine.line(0, 0, 0);

  // 運動將於 1 秒後停止。
  delay(1000);
  machine.stop();
}

See also


函式庫參考主頁面

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.