Movement for atomic step(s) by mouse scroll wheel?

28 Aug 2013 13:46 #38177 by jpka
I am sorry for this novice-like question. I sure that Adult Machinists never thinks about it and possibly hates it. I know that there is many levels of translation and matematics between top-level controls (G-code, Axis, etc) and lowest level LPT port pin change. But maybe it is possible to go through all these levels and have the possibility in AXIS to generate individual steps (output STEP pin pulses and DIR control for currently selected axis via Axis interface) using say mouse scroll wheel in Axis ?
Or i need to ensure that is absolutely impossible at all now and in far future.
I also remember questions here about similar things (direct user control of stepgens) years ago, but today can't find anything related.
Thank you so much! :cheer:
28 Aug 2013 13:58 #38178 by cncbasher
treat the mouse as a Quadrature encoder , and then use Hal directly as if your using a Handwheel encoder jog .
28 Aug 2013 15:48 #38183 by andypugh

cncbasher wrote: treat the mouse as a Quadrature encoder

Is it possible to connect the mouse to hal_input and still have it work as the system pointing device?
31 Aug 2013 19:30 #38304 by jpka
Hi! After long searching, i unfortunately still can't find examples for

Quadrature encoder


using a Handwheel encoder jog

. Instead, i find this howto:
While it is not what i need, i follow it, using 2nd mouse in place of joypad. It is work (see 'P.S.' below), and using 2nd mouse looks to be useful sometimes, but unfortunately i can only control velocity of jog, not the position. When i look here it is shown that halui.axis.n.pos* parameters are read-only unfortunately. So the question #1 is, How to set position via halui ?
But i again note that even if is possible to find answer to Q1, is not exactly what i need (but can be useful in other case). It is not so important here if i will use mouse, encoder, keyboard etc. as control input. What is essentially important is how to control movements not using velocity, position, acceleration, etc, but individual atomic steps? Question #2, It is possible to generate individual steps of motors via AXIS ?
P.S. about

connect the mouse to hal_input and still have it work as the system pointing device

, It is possible as i see during my tests, and it is default behaviour, but looks not useful. So i need to isolate my 2nd mouse from Xserver via 'xinput' commands. Then mouse not control system cursor, but still work with halui. Example commands here: , and i will write full howto about it, when i get something really useful (answers to Q1 and/or Q2).
Thank you!
31 Aug 2013 22:57 #38315 by andypugh

jpka wrote: i can only control velocity of jog, not the position.

Look at the pins axis.N.jog-counts, axis.N.jog-enable and axis.N.jog-scale here:
The following user(s) said Thank You: jpka
01 Sep 2013 04:22 #38334 by jpka
It works exactly as i need! Thanks!
btw, i write (simplest possible) example howto for using 2nd mouse as controller (move as X, Y control and scroll wheel as Z control). While it is not exactly what i looking for, but it is good intermediate result, is looks useful somewhere, and good learning example and starting point for me to get what i want, if it is possible at all.
So here's the howto. It based on clean install of LinuxCNC running in simulation mode, mm units.

/!\ 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.
Install fresh clean installation of LinuxCNC
Run LinuxCNC
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 startp 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. (PICTURE 1)
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
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 <= input.0.rel-x-position
net x-s32 conv-float-s32.0.out => axis.0.jog-counts

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

net z-float <= input.0.rel-wheel-position
net z-s32 conv-float-s32.2.out => axis.2.jog-counts
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! (PICTURE 2)
That's all now. Hope it can be useful :-)
01 Sep 2013 04:27 #38335 by jpka
01 Sep 2013 17:24 #38356 by Rick G
Well that is quite an interesting concept, thanks for sharing.

Rick G
Time to create page: 0.083 seconds
Powered by Kunena Forum