machineOn()
描述
將 Machine 物件切換為 MachineOn 的模式。
使用任何運動控制相關方法前必須先進入 MachineOn 模式後才能使用,進入 MachineOn 模式後即不能組態 config 相關方法,若想要在 MachineOn 後使用 config 相關方法就必須先進入 MachineOff 模式後才能組態。
語法
machine.machineOn();
參數
machine
:為 Machine
物件。
無參數。
回傳
無回傳值。
範例
設定機器的基本參數,MachineOn 後移動,接著 MachineOff再次組態設定。
#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
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.