Warning: Declaration of bdyssh_menu_titles::start_el(&$output, $item, $depth, $args) should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in /var/www/jopka/data/www/bdyssh.ru/wp-content/themes/bdyssh/functions.php on line 57
Bdyssh! // Бдыщщь!

Если руки золотые, то не важно откуда они растут, %username%.

Использование второй мыши в LinuxCNC / Interesting way to use 2nd mouse in LinuxCNC


This is almost production-quality article. But subject to update.

Важно: Стык USB или беспроводная связь, которыми часто снабжены бытовые устройства, неприемлемы для промышленного применения. Необходимо найти проводную RS232 или PS/2 мышь для предсказуемого результата использования в цеху.
Warning: USB and wireless devices not intended for industrial or production environment. I recommend use this only for demonstration / home use / tests. Use serial wired mouse for production. I use USB Wireless mouse here only as an example.


Этот пример показывает, как использовать дополнительную мышь для управления шпинделем (кареткой) станка ЧПУ под управлением LinuxCNC. (А также в который раз показывает, что в LinuxCNC уже изначально предусмотрено небывалое количество возможностей, и они правильно работают). Используется чистая инсталляция в режиме симуляции, миллиметры.

This example howto tries to using 2nd mouse as controller (move as X, Y control and scroll wheel as Z control) for Axis GUI of LinuxCNC. It based on clean install of LinuxCNC running in simulation mode, mm units. I write it during some tests, while it is not what i looking for at that time.

And of course, if you are novice, it is not intended for actual milling. Use 2nd mouse, as any other pendant, for touch-off (aiming at relative zero coordinate of your material piece).


Install fresh clean installation of LinuxCNC. Maybe using Virtualbox.

Run LinuxCNC via Ubuntu’s pre-filled system menu.

In Linux configuration selector window, select sim – axis – axis_mm (and check Create Desktop Shortcut). After few questions, Axis GUI will appear – close it.

In terminal, run
 $ xinput list

Save the output. Connect 2nd mouse. It must be physically different from main mouse due to the identification string must be unique. Check if 2nd mouse work (cursor move, scroll) just as main mouse.

Run ‘xinput list‘ again. Compare the output with previous one. The differense is string contains the device name of interest. Remember the name. Mine is ‘2.4G Wireless Optical Mouse‘.

 $ xinput list-props ‘2.4G Wireless Optical Mouse’ | grep Enabled

  Device Enabled (115): 1

Note the number, mine is 115.

Now we disable the device for X Window but still leave it active for HAL:

 $ xinput set-prop ‘2.4G Wireless Optical Mouse’ 115 0

Test if 2nd mouse is not moving cursor anymore. To autorun this, go to Ubuntu’s System – Preferences – Startup apps, and add that command as ‘Add startup program‘.

 $ cat /etc/udev/rules.d/99-rtai.rules

Note the output. Run

 $ sudo echo ” >> /etc/udev/rules.d/99-rtai.rules
 $ sudo echo ‘SUBSYSTEM==”input”, MODE=”0660″, GROUP=”plugdev”‘ >> /etc/udev/rules.d/99-rtai.rules

Then again ‘cat /etc/udev/rules.d/99-rtai.rules’ and notice if line was correctly added.

Replug the 2nd mouse to activate new rule. Check if it moves cursor now. Run again to disable it:

 $ xinput set-prop ‘2.4G Wireless Optical Mouse’ 115 0


 $ halrun
halcmd: loadusr -W hal_input -KRAL Wireless <– where word ‘Wireless’ taken from unique dev name.
halcmd: loadusr halmeter

In ‘Select item to probe‘ window, select some suspect parameter like ‘input.0.rel-wheel-position‘.
Scroll wheel (or move, etc.) 2nd mouse, and see in ‘HAL Meter‘ window if parameter changes.
Then exit it and exit halrun. If none works, try to change word from dev name.


 $ gedit /home/test/linuxcnc/configs/sim/axis/axis_mm.ini

Then uncomment (near line 109)
 #POSTGUI_HALFILE = test_postgui.hal
to look like
 POSTGUI_HALFILE = test_postgui.hal
Save & exit.

Run (substitute same command as your working one before)

 $ echo ‘loadusr -W hal_input -KRAL Wireless’ >> /home/test/linuxcnc/configs/sim/axis/test_postgui.hal

then test it

 $ cat /home/test/linuxcnc/configs/sim/axis/test_postgui.hal

Start LinuxCNC by desktop icon. Go to Machine – Show HAL configuration. Select WATCH at right.
Select at the left, Pins – Input – 0 – your_suspect_parameter (like ‘rel-wheel-pos‘ etc.). It will be added to watch:


Scholl/move 2nd mouse and see if parameter changes. If not, there is problem somewhere, can’t continue.
Close HAL window. Exit LinuxCNC main window.

 $ gedit /home/test/linuxcnc/configs/sim/axis/test_postgui.hal

Add these lines to it. Note, this is simplest possible config, more useable and safe configuration are here wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant

 (... some previuos text ...)

loadrt conv_float_s32 count=3
addf conv-float-s32.0 servo-thread
addf conv-float-s32.1 servo-thread
addf conv-float-s32.2 servo-thread

setp axis.0.jog-vel-mode 0
setp axis.1.jog-vel-mode 0
setp axis.2.jog-vel-mode 0

setp axis.0.jog-enable 1
setp axis.1.jog-enable 1
setp axis.2.jog-enable 1

setp axis.0.jog-scale 0.01
setp axis.1.jog-scale -0.01
setp axis.2.jog-scale 1

net x-float conv-float-s32.0.in <= input.0.rel-x-position
net x-s32 conv-float-s32.0.out => axis.0.jog-counts

net y-float conv-float-s32.1.in <= input.0.rel-y-position
net y-s32 conv-float-s32.1.out => axis.1.jog-counts

net z-float conv-float-s32.2.in <= input.0.rel-wheel-position
net z-s32 conv-float-s32.2.out => axis.2.jog-counts

But WordPress editor or engina has as always multiple bugs, so below part of test is misformatted.

Save, exit, run LinuxCNC via desktop icon. Press F1 (Estop off), then F2 (Machine on).
Move your 2nd mouse and see how it moves (virtual) spindle!


That’s all now. Hope it can be useful :-)

This article based on my post here http://linuxcnc.org/index.php/english/forum/21-axis/26931-movement-for-atomic-steps-by-mouse-scroll-wheel


absolute, axis, controller, coordinate, example, GUI, HAL, how to, howto, joypad, joystick, LinuxCNC, manual, mice, mouse, MPG, pendant, relative, velocity,