How to prompt a user for input to set a variable

More
13 Jan 2013 12:34 #28642 by forbes_rl
Hi all,

I am fairly new to Linux CNC and am converting some lathe g-code...one thing I can't figure out is how to prompt the operator for input.

What I want to do is:
1) pause the program, e.g. with M00
2) measure the part diameter with a micrometer
3) based on the measurement, re-set the G92 offset so the actual and displayed diameter are the same
4) continue program execution

In the previous system I used, the GUI would let you change the tool offsets when the program was paused, but the Axis GUI doesn't seem to allow that; at least the touch-off controls on the Manual Input tab are disabled if the program is running, even if paused. In yet another system I used to use, there was a special G-Code that would pop up a dialog into which the operator could type a value, which would set a variable. The variable could then be used in a subsequent G92 statement in the program to achieve the same effect. I can't see anything like that in linuxcnc. I do see something about custom g-codes can call external programs, but don't see anything about how to get a value back into a variable.

Any suggestions on how this can be done?

Thanks in advance,

Rob

Please Log in or Create an account to join the conversation.

More
14 Jan 2013 00:26 #28655 by ArcEye
Hi

Yes this is a problem.
Whilst user M Codes can pass parameters to a script or binary, there is no mechanism for a return value.

A lot of the problem is what is allowed when Linuxcnc is in Auto mode.
It would not matter if the Axis touch off button were enabled, that sets the values via a MDI call to G10 L20 Pnn and you can't make MDI calls in Auto mode

So likewise you cannot do a G92 call to adjust your offset whilst in Auto mode.

There is hope, the 2.6~ master version has mechanisms for passing values in named parameters, that can be used in G Code as part of the G code remapping.
There will probably be a way of using the same thing to achieve a parameter which can be read by the interpreter and and yet is accessible externally.

The only way I can think of at present, is to write a component which responds to a button press for instance, takes Linuxcnc out of Auto mode, pops up the dialog and gathers the values, executes the relevant MDI commands and then puts Linuxcnc back into Auto mode.

I am writing a new GUI for Linuxcnc at present and may have to experiment to see if this is achievable in practice.

regards
The following user(s) said Thank You: forbes_rl

Please Log in or Create an account to join the conversation.

More
14 Jan 2013 00:36 #28656 by BigJohnT
I would think it is possible with the python interface as you say take it out of auto do some stuff then run from line...

John
The following user(s) said Thank You: tivoi

Please Log in or Create an account to join the conversation.

More
14 Jan 2013 00:41 #28657 by ArcEye

I would think it is possible with the python interface as you say take it out of auto do some stuff then run from line...


From what I remember that was what the modified toolchanger component did to allow jogging in a toolchange.
As with anything will need to be played with to make sure there are no gotcha's!

Please Log in or Create an account to join the conversation.

More
15 Jan 2013 02:15 #28692 by ArcEye
Here's a very bad video screen capture to show it can be done in testing, just remains to put something coherent together.
(The test program is a milling one, I haven't gotten around to implementing lathes yet in my GUI)

Please Log in or Create an account to join the conversation.

More
17 Jan 2013 01:10 - 17 Jan 2013 01:19 #28755 by ArcEye
Here's a better video, using a component to do the same thing, with Axis.

It is possible to execute MDI commands, but what Axis does is sometimes not as expected, nor as my own GUI did.

(Tip, use Ctrl + to enlarge the viewer so that it can be properly watched)

In case you cannot see too clearly, the program runs until the M0 line
Then the component is activated raising a dialog into which the MDI line G0 Z1 is entered along with Run From Line 14 (the M0 line)
This is then executed raising the Z axis to 1 and Linuxcnc is then returned to Auto mode
Pause is clicked and it resumes the program

Last edit: 17 Jan 2013 01:19 by ArcEye.

Please Log in or Create an account to join the conversation.

More
22 Jan 2013 22:40 #28970 by forbes_rl
ArcEye,

Interesting! I know nothing about the internals, but if the "Run From" causes the moves to be recalculated based on the current position it seems like that should work.

What inspired you to work on a new GUI...is there some particular functionality you want ?

Rob

Please Log in or Create an account to join the conversation.

More
22 Jan 2013 23:37 #28975 by ArcEye
Unfortunately the module is very experimental at present.

It is written in Qt4 C++ using HAL and NML libraries I have written to interface with Qt.
They use the same underlying calls, but send and return Qt data types, QStrings, QStringLists etc instead of the standard C types.
This makes it very easy to incorporate any Qt GUI elements, of which the dialog is an example.

I am writing the Controller GUI and libraries to thoroughly understand the internals of Linuxcnc.
I hate the Tk/gTk interface of Axis and I also refuse to learn python, having spent many years learning C / C++.

All the underlying code of Linuxcnc is in C /C++, I want to try to bring a modern clean interface to it.
Once done it will be easy to create Qt panels that meld straight into it, accessing the underlying data structures.

If you want to see what can be done mid-program, you could install the modified hal_toolchange component
wiki.linuxcnc.org/cgi-bin/wiki.pl?ManualToolChangeMacro

It drops out of Auto mode to allow jogging, you can program an unnecessary toolchange and then see if you can achieve what you want in the MDI window.
I'll let you know if my component gets near general testing stage

regards

Please Log in or Create an account to join the conversation.

More
29 Jan 2013 20:05 - 09 May 2013 21:33 #29257 by ArcEye
Hi

I have done some more testing and the module seems ready for wider tests.
It is for Ubuntu 10.04 running the 2.6.32-122-rtai kernel with Linuxcnc 2.5.1

It is called qtReset.
Basically it will allow you to execute any MDI command whilst a running program is paused, either in a programmed M0 pause
or from the pause button having been pressed.
It was conceived to allow 'touch-off' to reset diameter value on a lathe mid program, but with care it should be able to do more.

A pop up dialog takes the MDI line to be executed and the program line to run from once executed.
If no run-from line is specified and the Line No entry is left at the default 0, nothing will happen.

If the run-from line specified is the one with M0 in it, the program will remain paused until the Pause button is released.
This opens up the possibility of executing several MDI commands one after another and returning to the M0 line each time.

It has been tested in a sim only and it is recommended to test whatever commands are desired in a sim first.
Shifting an offset with a tool in the spindle or toolholder obviously can have physical outcomes on a machine, that need checking
before trying for real.

The module is packaged in a .deb with the support libraries required and an example config ( a version of the axis_mm sim ) which will be
installed with the other example configs and available from the config picker dialog at linuxcnc startup.

The .hal and .ini files in this config show the connections required. There is only one bit pin connection which simply triggers the dialog
making it simple to trigger via a pyvcp button or similar.
The module is userspace and its while() loop checking for activation has a quite long sleep period to ensure it does not hog resources.
If the dialog does not appear when you click the button, just click again and it will.

You will require Linuxcnc 2.5.1 and libqt4-gui and libqt4-core to be installed prior to installing the module qtReset
Do this via Synaptic Package manager.
Then on the command line, from the directory that you have copied the .deb to
sudo dpkg --install qtReset-0.1.deb

Usual caveats, not warranted of any use whatsoever and may completely mess up your system and machine. Use at your own risk.

That said, someone may find it useful

regards

www.mgware.co.uk/LinuxCNC/qtReset.zip
Last edit: 09 May 2013 21:33 by ArcEye.

Please Log in or Create an account to join the conversation.

More
24 Mar 2015 04:05 #57126 by Treetop
Hi- I am just starting to use LinuxCNC (2.6.1 on Debian Wheezy). Has this topic moved on at all since 2013? I was looking to do something similar to pause and then input a parameter value from the keyboard.


Regards

Jeff

Please Log in or Create an account to join the conversation.

Time to create page: 0.096 seconds
Powered by Kunena Forum