今回は,いわゆるアナログコントローラから,フライトスティックに見た目が変わっただけでなく,
リモートコントロールVer. 2のつもりで全体の設定を見直しました.
他のコントローラの設定でも役立つはずです.
主な特徴は,
・スロットル軸の送り速度オーバライドへのアナログ設定
・ボタン押しっぱなしでも動作のOn/Offが点滅しないよう"toggle"機能を使用することにした
・「オートモードに入らないと動作しないプログラムスタート指令」への対処
・同時に利用しない複数の機能を1ボタンに集中配置
となっています.
高級なフライトスティックだと,左右のエンジンを独立して制御するためにスロットルが2基あるので,
フィードオーバーライドとスピンドル回転数のPWM制御に割り当てると面白いかも知れません.
…まあ,それ以外の点では,普通のコントローラのほうが操作しやすいというかなんというか.
今回使用したコントローラはこちら:Logitech Extreme 3D Pro;
以下,.halファイル
設定のメモは全てコメントアウトに記載しています.
## LogitechExtreme3DFlightStick.hal
## Config of Analog jog/feed-override and some machine controling with Logitech Extreme 3D USB Flight Stick
## Logitech Extreme 3D での3軸+スロットルのアナログコントロールとスピンドルなどのオンオフ
## Please add "HALFILE = LogitechExtreme3DFlightStick.hal" to "machiname.ini"s [HAL]section, next line of "HALFILE = custom.hal"
## このファイル名を"あなたの機械の名前.ini"ファイル中の、[HAL]セクション、
## "HALFILE = custom.hal"の次の行に "HALFILE = LogitechExtreme3DFlightStick.hal"のように足すと動作する。
##################################################################################
## Basic configure
## デバイスの確認とLinuxCNCへの基本設定
## Searching your joypad by OS terminal command "less /proc/bus/input/devices"
## OS本体の端末コマンド "less /proc/bus/input/devices" の結果から設定したいデバイスを探す
## "less"中はカーソルで行送り、抜けるにはキーボード"q"
## I: Bus=0003 Vendor=046d Product=c215 Version=0110
## N: Name="Logitech Logitech Extreme 3D"
## P: Phys=usb-0000:00:1d.0-2/input0
## S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb2/2-2/2-2:1.0/input/input8
## U: Uniq=
## H: Handlers=event8 js1
## B: EV=1b
## B: KEY=fff 0 0 0 0 0 0 0 0 0
## B: ABS=30063
## B: MSC=10
## Loading the flight stick to LinuxCNC
## スティックの呼び出し
loadusr -W hal_input -KRAL Extreme
## "Extreme"の部分は各自のゲームパッドのN:欄 Name= から,必ずただ一つ識別できるようなキーワードにする.
## 今回は十分にユニークな名前なのでExtremeとした.
## Loading real-time modules
## 使用するリアルタイムモジュールの呼び出し
## count= の値は,利用したい論理が、宣言した個数だけ確保される
loadrt and2 count=12
loadrt not count=6
loadrt toggle count=11
#loadrt mux2
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread
addf and2.6 servo-thread
addf and2.7 servo-thread
addf and2.8 servo-thread
addf and2.9 servo-thread
addf and2.10 servo-thread
addf and2.11 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf not.3 servo-thread
addf not.4 servo-thread
addf not.5 servo-thread
addf toggle.0 servo-thread
addf toggle.1 servo-thread
addf toggle.2 servo-thread
addf toggle.3 servo-thread
addf toggle.4 servo-thread
addf toggle.5 servo-thread
addf toggle.6 servo-thread
addf toggle.7 servo-thread
addf toggle.8 servo-thread
addf toggle.9 servo-thread
addf toggle.10 servo-thread
######################################################################################
## Checked pin's assign
## スティックの登録後LiniuxCNCの機能「HAL Meter」で確認したボタンの名前
## Analog Axes
## FS-analogXaxis input.0.abs-x-
## FS-analogYaxis input.0.abs-y-
## FS-analogZaxis input.0.abs-rz-
## FS-throttle input.0.abs-throttle-
## Digital Buttons
## FS-hat-up input.0.abs-hat0y-is-neg
## FS-hat-down input.0.abs-hat0y-is-pos
## FS-hat-right input.0.abs-hat0x-is-pos
## FS-hat-left input.0.abs-hat0x-is-neg
## FS-trigger input.0.btn-joystick
## FS-btn-2 input.0.btn-thumb
## FS-btn-3 input.0.btn-thumb2
## FS-btn-4 input.0.btn-top
## FS-btn-5 input.0.btn-top2
## FS-btn-6 input.0.btn-pinkie
## FS-btn-7 input.0.btn-base
## FS-btn-8 input.0.btn-base2
## FS-btn-9 input.0.btn-base3
## FS-btn-10 input.0.btn-base4
## FS-btn-11 input.0.btn-base5
## FS-btn-12 input.0.btn-base6
########################################################################################
## Analog stick and throttle parameteres
## アナログ軸に関わるパラメータの設定
## Criterion feed-speed with analog stick [unit*min-1]
## 基準送り速度.ここの値はjoypadでのみ利用される(画面でのjog速度と独立、オーバライド倍率の影響は受ける)単位はmm*min-1
setp halui.jog-speed 1000
## Analog stick neutral-deadband
## スティック中央でのデッドバンド(禁止帯)の設定.あまり小さいと,スティックのニュートラルがずれると機械が停止しなくなる.
## 大きすぎる/未設定の場合,移動速度変化の分解能が少なくなる.
setp halui.jog-deadband 0.020
## フライトスティックは慣性で揺れるので、いつもよりだいぶ多めに設定
## Inversion jog-direction
## y軸がイメージと逆に動くので,以下行を追加した.
## 数値の符号"-"で動作方向が反転.
setp input.0.abs-y-scale -511.0
## Z軸は速度速いと危ないので、scaleの値を使って約30%遅くした(たぶん速度は次式で決定
## {halui.jog-speed(*offset?)/scale [unit*min-1]})
setp input.0.abs-rz-scale 180.0
## Setting stick axes to machine axes
## 入力先ピンの設定.-1から1までの少数値をとる「input.number.abs-axis-position」を設定する.
net analogXaxis input.0.abs-x-position => halui.jog.0.analog
net analogYaxis input.0.abs-y-position => halui.jog.1.analog
net analogZaxis input.0.abs-rz-position => halui.jog.2.analog
## Feed_override by throttle
## 工具送り速度オーバーライドをスロットルに割り当ててみた
## フルスロットル時にinput.0.abs-throttle-countsが0になる、イメージと逆向きの動作だったので、scaleに"-"符号をつけた
## またスロットル位置とオーバーライドの倍率が合わないので、それもscaleで調整した。
## 数値はtry&errorで(たぶん次式の通り
## {(abs-throttle-counts/scale) >= max_override(今回は1.5,少し上下に余裕持たせてある)})
setp halui.feed-override.scale -0.007
net FS-throttle input.0.abs-throttle-counts => halui.feed-override.counts
#####################################################################################
## digital-btn on-off
## デジタルボタンの設定
## Emergency-stop
## 緊急停止 (マシンからコントロールしているすべての補機類がと軸移動が停止するが、
## 減速停止を無視するので復帰時には原点取り直しに)
net FS-btn-11 input.0.btn-base5 => halui.estop.activate
## Abort
## アボート(原点を失わない、軸移動のみ停止。プログラムはリセット)
net FS-btn-2 input.0.btn-thumb => halui.abort
## Reset E-stop /Power-on /Home-All
## 緊急停止の解除/パワーオン/機械原点復帰動作
## 条件分けで1つのボタンに複数機能を振り分ける
## toggleを用いることで複数回ボタンを操作しないと全操作が実行されない
## *階層が深くなると多数の論理を通過することになるので反応が遅くなる恐れがある
## 現在の状態を取得し、and論理に入力。片方はnotで反転させることで条件分岐する
net Logic_E-stop-is-activated halui.estop.is-activated => and2.0.in0
net Logic_E-stop-is-activated halui.estop.is-activated => not.0.in
net Logic_not-E-stop-is-activated not.0.out => and2.1.in0
## and回路にボタン操作を入力
net FS-trigger input.0.btn-joystick => and2.0.in1
net FS-trigger input.0.btn-joystick => and2.1.in1
## 成立したand出力をトグルに入力。ボタン長押しによる異常を防ぐ。トグルから、緊急停止の解除指令へ
net E-stop-release_req and2.0.out => toggle.0.in
net E-stop_release_toggle toggle.0.out => halui.estop.reset
## もう一方の論理を、パワーオン/機械原点復帰の分岐に
net to-machine-on-seq and2.1.out => and2.2.in1
net to-machine-on-seq and2.1.out => and2.3.in1
## パワーオンと原点復帰の条件分岐
net machine-is-on halui.machine.is-on => and2.2.in0
net machine-is-on halui.machine.is-on => not.1.in
net not-machine-is-on not.1.out => and2.3.in0
## 成立した論理にトグルを通してから指令設定することで,押しっぱなしでも1度しか切り替わらない
net home-all_req and2.2.out => toggle.1.in
net home-all_toggle toggle.1.out => halui.home-all
net machine_on_req and2.3.out => toggle.2.in
net machine_on_toggle toggle.2.out => halui.machine.on
##
## optional stop M1 (=[Alt+M 1])
## オン時のみGコード中のM1コードで一時停止してくれる,オプショナルストップのオンオフ
net M1-is-on halui.program.optional-stop.is-on => and2.4.in0
net M1-is-on halui.program.optional-stop.is-on => not.2.in
net not-M1-is-on not.2.out => and2.5.in0
net FS-btn-12 input.0.btn-base6 => and2.4.in1
net FS-btn-12 input.0.btn-base6 => and2.5.in1
net M1_Off_req and2.4.out => toggle.3.in
net M1_Off_toggle toggle.3.out => halui.program.optional-stop.off
net M1_On_req and2.5.out => toggle.4.in
net M1_On_toggle toggle.4.out => halui.program.optional-stop.on
##
##Lube On/Off
net Lube-is-on halui.lube.is-on => and2.6.in0
net Lube-is-on halui.lube.is-on => not.3.in
net not-Lube-is-on not.3.out => and2.7.in0
net FS-btn-8 input.0.btn-base2 => and2.6.in1
net FS-btn-8 input.0.btn-base2 => and2.7.in1
net Lube_Off_req and2.6.out => toggle.5.in
net Lube_Off_toggle toggle.5.out => halui.lube.off
net Lube_On_req and2.7.out => toggle.6.in
net Lube_On_toggle toggle.6.out => halui.lube.on
##
## Mist On/Off
## ミストタイプクーラントOn/Off
net Mist-is-on halui.mist.is-on => and2.8.in0
net Mist-is-on halui.mist.is-on => not.4.in
net not-Mist-is-on not.4.out => and2.9.in0
net FS-btn-5 input.0.btn-top2 => and2.8.in1
net FS-btn-5 input.0.btn-top2 => and2.9.in1
net Mist_Off_req and2.8.out => toggle.7.in
net Mist_Off_toggle toggle.7.out => halui.mist.off
net Mist_On_req and2.9.out => toggle.8.in
net Mist_On_toggle toggle.8.out => halui.mist.on
##
## Flood On/Off
## 液体クーラントOn/Off
net Flood-is-on halui.flood.is-on => and2.10.in0
net Flood-is-on halui.flood.is-on => not.5.in
net not-Flood-is-on not.5.out => and2.11.in0
net FS-btn-6 input.0.btn-pinkie => and2.10.in1
net FS-btn-6 input.0.btn-pinkie => and2.11.in1
net Flood_Off_req and2.10.out => toggle.9.in
net Flood_Off_toggle toggle.9.out => halui.flood.off
net Flood_On_req and2.11.out => toggle.10.in
net Flood_On_toggle toggle.10.out => halui.flood.on
##
## Program pause
## 動作中のGコード一時停止(その場で停止)
net FS-btn-3 input.0.btn-thumb2 => halui.program.pause
net FS-btn-4 input.0.btn-top => halui.program.resume
## Spindle On/Off speed
## 主軸On/Offと回転数変更
net FS-hat_up input.0.abs-hat0y-is-neg => halui.spindle.start
net FS-hat_down input.0.abs-hat0y-is-pos => halui.spindle.stop
net FS-hat-right input.0.abs-hat0x-is-pos => halui.spindle.increase
net FS-hat-left input.0.abs-hat0x-is-neg => halui.spindle.decrease
## Program start
## When programs start, LinuxCNC have to change "auto" mode.
## So, put 2 orders; "halui.mode.auto" "halui.program.run" serially, and remember spacing between orders!
## プログラムスタート
## プログラムスタートには自動加工モードへの遷移が必要なので、1つのボタンで2命令を同時指令。
## "halui.---"(スペース空ける)"halui.---"の形で並べて記述する。
net FS-btn-7 input.0.btn-base => halui.mode.auto halui.program.run