アナログコントローラを使ったジョグ送り機能(バージョン3

アナログコントローラを使ったジョグ送り機能ですが,

えー,どうやら世界的には「joyhandle」機能を利用して実装することが多いらしく,

その部分を反映して書き直してみました.

前回までのものとの機能的な違いですが,

1.中立時のデッドバンドが軸ごとに指定できる

2.スティック倒し量に比例しない速度変化が可能

です.2はpowerという項目の値を変化させることで,スティックが中央付近にいるときはより遅く,

スティックを倒し切るとよりはやく,といった風に,比例関係でない動作をさせることができるようになり,

より微妙な操作と最大ジョグ送り速度の両立がしやすくなります.

以下に設定データを示します.

変化した個所は赤字で示します.(2020.08.12 google sitesの機能更新で全部黒字になってしまいました)

## 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:0 #Vendor=046d #Product=c215 #8

## "Extreme"の部分は各自のゲームパッドのN:欄 Name= から,必ずただ一つ識別できるようなキーワードにする.

## 今回は十分にユニークな名前なのでExtremeとした.

## Loading reat-time modules

## 使用するリアルタイムモジュールの呼び出し

## count= の値は,利用したい論理が、宣言した個数だけ確保される

## joyhandleの呼び出し

loadrt joyhandle count=3

loadrt and2 count=12

loadrt not count=6

loadrt toggle count=11

#loadrt mux2

##機能の追加

addf joyhandle.0 servo-thread

addf joyhandle.1 servo-thread

addf joyhandle.2 servo-thread

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 assigns

## スティックの登録後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

## hat-up input.0.abs-hat0y-is-neg

## hat-down input.0.abs-hat0y-is-pos

## hat-right input.0.abs-hat0x-is-pos

## 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

## アナログ軸に関わるパラメータの設定

## Max feed with analog stick

## 最大送り速度.ここの値はjoypadでのみ利用される(画面でのjog速度と独立、オーバライドの影響は受ける)

setp halui.jog-speed 1000

## Analog stick neutral-deadband

## デッドバンド(禁止帯)の設定.あまり小さいと,スティックのニュートラルがずれると機械が停止しなくなる.

##halui.jog-deadbandの値がjoyhandle.n.deadbandの値を上回ったときは前者の値が適用される

setp halui.jog-deadband 0

setp joyhandle.0.deadband 0.2

setp joyhandle.1.deadband 0.2

setp joyhandle.2.deadband 0.3

## フライトスティックは慣性で揺れるので、多めに設定

##パワー(数字を大きくするほどスティックを倒しこむほど速度の上昇率が大きくなる)の設定

setp joyhandle.0.power 3

setp joyhandle.1.power 3

setp joyhandle.2.power 4

## Inversion jog-direction

## イメージと逆に動く軸にはスケール値を-1とした

setp joyhandle.0.scale 1

setp joyhandle.1.scale -1

setp joyhandle.2.scale 0.2

## Z軸は速度速いと危ないので、scaleの値を使って遅くした

## Setting stick axes to machine axes

## 入力先ピンの設定.-1から1までの小数値をとる「input.number.abs-axis-position」を設定する.

net analogXaxisin input.0.abs-x-position => joyhandle.0.in

net analogYaxisin input.0.abs-y-position => joyhandle.1.in

net analogZaxisin input.0.abs-rz-position => joyhandle.2.in

## 出力先ピンの設定

net Xjoyhandleout joyhandle.0.out => halui.jog.0.analog

net Yjoyhandleout joyhandle.1.out => halui.jog.1.analog

net Zjoyhandleout joyhandle.2.out => 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を用いることで複数回ボタンを操作しないと全操作が実行されない

## *階層が深くなると多数の論理を通過することになるので反応が遅くなる恐れがある

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

net FS-trigger input.0.btn-joystick => and2.0.in1

net FS-trigger input.0.btn-joystick => and2.1.in1

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

#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

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

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

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

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

net FS-btn-7 input.0.btn-base => halui.mode.auto halui.program.run