QtDragon GUI

1. Introduction

QtDragon and QtDragon_hd are built with the QTVCP framework.
It is the creative vision of forum personality Persei8.
Much of it is based on the excellent work of others in the LinuxCNC community.
linuxcnc’s version is adapted from Persei8’s Github versions.
It is primarily meant for 3/4 axes machines such as mills or routers.
It works well with a touchscreen and/or mouse.
QtDragon supports multiple ways to touch off tools and probing work pieces.
You can use linuxcnc’s external offsets capability to automatically raise the spindle
during a pause. If you the VersaProbe option and remap code you can add auto tool length probing
at tool changes.

Note
QtDragon and QtVcp are relatively new programs added into linuxcnc. Bugs and oddities are possible. Please test carefully when using a dangerous machine. Please forward reports to the forum or maillist.
QTDragon Router
Figure 1. qtdragon - 3 or 4 Axis Sample (1440x860) in silver theme
QTDragon_hd
Figure 2. qtdragon_hd - 3 or 4 Axis Sample for larger monitors (1920x1056) in dark theme

2. Getting Started

If your configuration is not currently set up to use QtDragon, you can change it by editing the INI file.
This is not an exhaustive list of options.
Display Section

2.1. Display

In the section [DISPLAY] change the DISPLAY line to read:
qtdragon for a small version
qtdradon_hd for the large version.
you can add -c- or -v for debug output to the terminal.

[DISPLAY]
DISPLAY = qtvcp qtdragon

2.2. Preference

To keep track of preferences, qtdragon looks for a preference text file.
add the following entry under the [DISPLAY] heading.
This will save the file in the config folder of the launch screen.
(other options are possible see the qtvcp’s screenoption widget docs.)

[DISPLAY]
PREFERENCE_FILE_PATH = WORKINGFOLDER/qtdragon.pref

2.3. Logging

You can specify where to save history/logs.
In the section [DISPLAY] add:

[DISPLAY]
MDI_HISTORY_FILE = mdi_history.dat
MACHINE_LOG_PATH = machine_log.dat
LOG_FILE = qtdragon.log

2.4. Override controls

set override controls (1.0 = 100 percent):

[DISPLAY]
MAX_SPINDLE_0_OVERRIDE = 1.5
MIN_SPINDLE_0_OVERRIDE = .5
MAX_FEED_OVERRIDE       = 1.2

2.5. Spindle controls

Spindle control settings (in rpm and watts):

[DISPLAY]
DEFAULT_SPINDLE_0_SPEED = 500
SPINDLE_INCREMENT = 200
MIN_SPINDLE_0_SPEED = 100
MAX_SPINDLE_0_SPEED = 2500
MAX_SPINDLE_POWER = 1500

2.6. Jogging increments

Set selectable jogging increments

[DISPLAY]
INCREMENTS = Continuous, .001 mm, .01 mm, .1 mm, 1 mm, 1.0 inch, 0.1 inch, 0.01 inch
ANGULAR_INCREMENTS = 1, 5, 10, 30, 45, 90, 180, 360

2.7. Jog speed

Set jog speed controls (in units per minute)

[DISPLAY]
MIN_LINEAR_VELOCITY     = 0
MAX_LINEAR_VELOCITY     = 60.00
DEFAULT_LINEAR_VELOCITY = 50.0

2.8. User message dialog system

Popup Message dialogs, controlled by HAL pins
MESSAGE_TYPE can be okdialog or yesnodialog

[DISPLAY]
MESSAGE_BOLDTEXT = This is the short text
MESSAGE_TEXT = This is the longer text of the both type test. It can be longer then the status bar text
MESSAGE_DETAILS = BOTH DETAILS
MESSAGE_TYPE = okdialog
MESSAGE_PINNAME = oktest

2.9. Program Extensions/Filters

You can control what programs are displayed in the filemanager window with program extensions:
Create a line with the . endings you wish to use separated by commas, then a space and the description.
You can add multiple lines for different selections in the combo box

[FILTER]
PROGRAM_EXTENSION = .ngc,.nc,.tap G-Code File (*.ngc,*.nc,*.tap)

Qtdragon has the ability to send loaded files through a filter program.
This filter can do any desired task: Something as simple as making sure
the file ends with M2, or something as complicated as generating
G-Code from an image.

The [FILTER] section of the ini file controls how filters work.
First, for each type of file, write a PROGRAM_EXTENSION line.
Then, specify the program to execute for each type of file.
This program is given the name of the input file as its first argument,
and must write rs274ngc code to standard output. This output is what
will be displayed in the text area, previewed in the display area, and
executed by LinuxCNC when Run. The following lines add support for the
image-to-gcode converter included with LinuxCNC and running python based
filter programs:

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python

QtDragon has custom INI entries:

[TOOLSENSOR]
MAXPROBE = 40
SEARCH_VEL = 200
PROBE_VEL = 50
TOUCH = 29.7

[LASER]
X = 106.9
Y = -16.85

QtDragon has two optional probing tab screens:

[PROBE]
#USE_PROBE = versaprobe
USE_PROBE = basicprobe

QtDragon has two convenience buttons for moving between
current user system origin (zero point) and Machine system origin
These could also call OWord routines if desired.
user origin is the first MDI command in the list, machine origin is the second.
This example shows how to move Z axis up first. the commands are separated by the ;

[MDI_COMMAND_LIST]
MDI_COMMAND = G0 Z0;X0 Y0
MDI_COMMAND = G53 G0 Z0;G53 G0 X0 Y0

The sample configuration sim/qtvcp_screens/qtdragon/qtdragon_xyza.ini is already configured to use QtDragon as its front-end.
There are several others, to demonstrate different machine configurations.

3. Key Bindings

QtDragon is not intended to primarily use a keyboard for machine control.
It lacks many keyboatd short cuts that for instance AXIS has - but you can use a mouse.
There are several key presses that will control the machine for convenience.

F1 - Estop on/off
F2 - Machine on/off
F12 - Style Editor
Home - Home All Joint of the Machine
Escape - Abort Movement
Pause -Pause Machine Movement

4. Buttons

Buttons that are checkable will change their text colour when checked.

5. Virtual Keyboard

QtDragon includes a virtual keyboard for use with touchscreens.
To enable the keyboard, check the Use Virtual Keyboard checkbox in the Settings page.
Clicking on any input field, such as probe parameters or tool table entries, will show the keyboard.
It can also be shown by clicking the KEYBD button on the top of the screen,
unless the machine is in AUTO mode. To hide the keyboard, do one of the following:
- click the MAIN page button
- click the KEYBD button - go into AUTO mode

It should be noted that keyboard jogging is disabled when using the virtual keyboard.

6. HAL Pins

These pins are specific to the QtDragon screen, There are of course are many more HAL pins
that must be connected for linuxcnc to function.

If you need a manual tool change prompt, add these lines in your postgui file.

net tool-change      hal_manualtoolchange.change   <=  iocontrol.0.tool-change
net tool-changed     hal_manualtoolchange.changed  <=  iocontrol.0.tool-changed
net tool-prep-number hal_manualtoolchange.number   <=  iocontrol.0.tool-prep-number

This input pin should be connected to indicate probe state:

qtdragon.led-probe

These pins are inputs related to spindle VFD indicating: The volt and amp pins are used to calculate spindle power. (You must also set the MAX_SPINDLE_POWER in the INI)

qtdragon.spindle-modbus-errors
qtdragon.spindle-amps
qtdragon.spindle-fault
qtdragon.spindle-volts

This bit pin is an output to the spindle control to pause it:
You would connect it to spindle.0.inhibit.

qtdragon.spindle-inhibit

This bit output pin can be connected to turn on a laser:

qtdragon.btn-laser-on

This float output pin indicates the camera rotation in degrees:

qtdragon.cam-rotation

These bit/s32 pins are related to external offsets if they are used:

qtdragon.eoffset-clear
qtdragon.eoffset-count
qtdragon.eoffset-enable
qtdragon.eoffset-value

These float output pins reflect the current slider jograte (in machine units):

qtdragon.slider-jogspeed-linear
qtdragon.slider-jogspeed-angular

These float output pins reflect the current slider override rates:

qtdragon.slider-override-feed
qtdragon.slider-override-maxv
qtdragon.slider-override-rapid
qtdragon.slider-override-spindle

These pins are available when setting the Versa Probe INI option.
They can be used for auto-tool-length-probe at tool change - with added remap code.

qtdragon.versaprobe-blockheight
qtdragon.versaprobe-probeheight
qtdragon.versaprobe-probevel
qtdragon.versaprobe-searchvel

7. HAL files

The HAL files supplied are for simulation only. A real machine needs its own custom HAL files. The Qtdragon screen works with 3 or 4 axes with one joint per axis or 3 or 4 axes in a gantry configuration. (2 joints on 1 axis)

8. Manual Tool Changes

If your machine requires manual tool changes, QtDragon can pop a message box to direct you.
You must connect the proper HAL pin in the postgui HAL file. For example:

net tool-change      hal_manualtoolchange.change   <=  iocontrol.0.tool-change
net tool-changed     hal_manualtoolchange.changed  <=  iocontrol.0.tool-changed
net tool-prep-number hal_manualtoolchange.number   <=  iocontrol.0.tool-prep-number

9. Spindle

The screen is intended to interface to a VFD, but will still work without it. There are a number of VFD drivers included in the linuxcnc distribution. It is up to the end user to supply the appropriate driver and HAL file connections according to his own machine setup.

10. Auto Raise Z Axis

QtDragon can be set up to automatically raise and lower the Z axis when the spindle is paused.
When a program is paused, then you press the Spindle Pause button to stop the spindle and raise it in Z.
Press the button again to start spindle and lower it, then unpause program.
The amount to raise and lower is set in the Settings tab under the heading Z Ext Offset.
This requires additions to the INI and the qtdragon_post_gui file.

In the INI, under the AXIS_Z heading.

[AXIS_Z]
OFFSET_AV_RATIO  = 0.2

In the qtdragon_postgui.hal file add:

# Set up Z axis external offsets
net eoffset_clear    qtdragon.eoffset-clear => axis.z.eoffset-clear
net eoffset_count    qtdragon.eoffset-count => axis.z.eoffset-counts
net eoffset          qtdragon.eoffset-value <= axis.z.eoffset

# uncomment for dragon_hd
#net limited          qtdragon.led-limits-tripped <= motion.eoffset-limited

setp axis.z.eoffset-enable 1
setp axis.z.eoffset-scale 1.0

11. Probing

The probe screen has been through basic testing but there could still be some minor bugs.
When running probing routines, use extreme caution until you are familiar with how everything works.
Probe routines run without blocking the main GUI. This gives the operator the opportunity
to watch the DROs and stop the routine at any time.

Note
Probing is very unforgiving to mistakes; be sure to check settings before using.
QtDragon Probe
Figure 3. qtdragon - Probe Sample

QtDragon has 2 possible methods for setting Z0. The first is a touchplate, where a metal plate of known thickness is placed on top of the workpiece and then the tool is lowered until it touches the plate, triggering the probe signal. Z0 is set to probe height - plate thickness.

The second method uses a tool setter in a fixed position and a known height above the table where the probe signal will be triggered. In order to set Z0 to the top of the workpiece, it has to know how far above the table the probe trigger point is (tool setter height) and how far above the table the top of the workpiece is. This operation has to be done every time the tool is changed as the tool length is not saved.

For touching off with a touch probe, whether you use the touchplate operation with thickness set to 0 or use a probing routine, the height from table to top of workpiece parameter is not taken into account and can be ignored. It is only for the tool setter.

12. Touch plate

QtDragon Touch Plate
Figure 4. qtdragon - Touch Plate

You can use a conductive touch plate or equivalent to auto touch off (zero the user coordinate) for the Z position of a tool.
There must be a tool loaded prior to probing.
In the tool tab or settings tab, set the touch plate height, search and probe velocity and Max probing distance.

Note
When using a conductive plate the search and probe velocity should be the same and slow.
If using a tool setter that has spring loaded travel then you can set search velocity faster.
Linuxcnc ramps speed down at the maximum acceleration rate, so there can be travel after the probe trip
if the speed is set to high.

Place the plate on top of the surface you wish to zero Z on.
Connect the probe input wire to the tool (if using a conductive plate)
There is a LED to confirm the probe connection is reliable prior to probing.
Move the tool manually within the max probe distance.
Press the Touch Plate button.
The machine will probe down twice and the current user offset (G5X) will be zeroed at the bottom of the
plate by calculation from the touchplate height setting.

13. Auto Tool Measurement

QtDragon can be setup to do integrated auto tool measurement using the Versa Probe widget.
To use this feature, you will need to do some additional settings and you may want to use the
offered hal pin to get values in your own ngc remap procedure.

[IMPORTANT] Before starting the first test, do not forget to enter the probe
height and probe velocities on the versa probe settings page.

Tool Measurement in QtDragon is done with the following steps:

  • touch of you workpiece in X and Y

  • measure the height of your block from the base where your tool switch is located, to the upper face of the block (including chuck etc.)

  • In the Versa probe tab, enter the measured value for block height

  • Make sure the use tool measurement button in the Vesa probe tab is enabled

  • Go to auto mode and start your program

Note
When fist setting up auto tool measurement, please use caution untill you confirm
tool change and probe locations - it’s easy to break a tool/probe. Abort will be honoured
while the probe is in motion.

Here is a diagram:

images/sketch_auto_tool_measurement.png

With the first given tool change the tool will be measured and the offset will
be set automatically to fit the block height.
The advantage of this way is, that you do not need a reference tool.

Note
Your program must contain a tool change at the beginning.
The tool will be measured, even it has been used before, so there is no danger
if the block height has changed.
There are several videos on you tube that demonstrate the technique using Gmoccapy.
The Gmoccapy screen pioneered the technique.

13.1. Tool Measurement Pins

Versaprobe offers 5 pins for tool measurement purpose. The pins are used
to be read from a remap gcode subroutine, so the code can react to different values.

  • qtversaprobe.toolmeasurement HAL_BIT enable or not tool measurement

  • qtversaprobe.blockheight HAL_FLOAT the measured value of the top face of the workpiece

  • qtversaprobe.probeheight HAL_FLOAT the probe switch height

  • qtversaprobe.searchvel HAL_FLOAT the velocity to search for the tool probe switch

  • qtversaprobe.probevel HAL_FLOAT the velocity to probe tool length

13.2. Tool Measurement INI File Modifications

Modify your INI File to include the following:

  1. The PROBE section

QtDragon allows you to select one of two styles of touch probe routines.
Versa probe works with a M6 remap to add auto tool probing.

[PROBE]
USE_PROBE = versaprobe
The RS274NGC section
[RS274NGC]

# adjust this paths to point to folders with stdglu.py and qt_auto_tool_probe.ngc
# or similarly coded custom remap files
SUBROUTINE_PATH = ~/linuxcnc/nc_files/remap-subroutines:~/linuxcnc/nc_files/remap_lib

# is the sub, with is called when a error during tool change happens, not needed on every machine configuration
ON_ABORT_COMMAND=O <on_abort> call

# The remap code for Qtvcp's versaprobe's automatic tool probe of Z
REMAP=M6  modalgroup=6 prolog=change_prolog ngc=qt_auto_tool_probe epilog=change_epilog
The Tool Sensor Section

The position of the tool sensor and the start position of the probing movement,
all values are absolute (G53) coordinates, except MAXPROBE, what must be given in
relative movement. All values are in machine native units

[TOOLSENSOR]
X = 10
Y = 10
Z = -20
MAXPROBE =  -20
The Change Position Section

This is not named TOOL_CHANGE_POSITION on purpose - canon uses that name and will interfere otherwise. The position to move the machine before giving the change tool command. All values are in absolute coordinates. All values are in machine native units

[CHANGE_POSITION]
X = 10
Y = 10
Z = -2
The Python Section

The Python section sets up what files linuxcnc’s python interpreter looks for. ie. toplevel.py file in the python folder in the configuration directory:

[PYTHON]
# The path to start a search for user modules
PATH_PREPEND = python
# The start point for all.
TOPLEVEL = python/toplevel.py

13.3. Needed Files

You must copy the following files to your config directory

First create a directory named python in your machine’s configuration folder.
From YOUR_LINUXCNC_DIRECTORY/configs/sim/QtDragon/python, copy toplevel.py and
remap.py to your configuration’s new python folder.
Make a system link or copy the following files into the python folder described above.

In ~/linuxcnc/nc_files/remap_subroutine/ folder
make sure on_abort.ngc and qt_auto_tool_probe.ngc are present

In ~/linuxcnc/nc_files/remap_lib/python_stdglue/ folder
make sure stdglue.py is present.

Note
These file names and location could be different depending on installed verses development (RIP)
version of linuxcnc. You could use customized versions of the same files or name them differently.
The entries in the [RS274NGC] section dictate to linuxcnc what and where to look.
The names and location quoted should be available in either system by default.

13.4. Needed Hal Connections

Make sure to connect the tool probe input in your hal file:
If connected properly, you should be able to toggle the probe LED in qtdragon
if you press the probe stylus.

net probe  motion.probe-input <= <your_input_pin>

14. Run from Line

A gcode program can be started at any line by clicking on the desired line in the gcode display while in AUTO mode.
It is the operator’s responsibility to ensure the machine is in the desired operational mode.
A dialog will be shown allowing the spindle direction and speed to be preset.
The start line is indicated in the box labelled LINE, next to the CYCLE START button.
The run from line feature can be disabled in the settings page.

Note
Linuxcnc’s run-from-line is not very user friendly. eg. It does not start the spindle or confirm the proper tool.
It does not handle subroutines well. If used it is best to start on a rapid move.

15. Laser buttons

The LASER ON/OFF button in intended to turn an output on or off which is connected to a small laser crosshair projector.
When the crosshair is positioned over a desired reference point on the workpiece, the REF LASER button can be pushed which then sets
the X and Y offsets to the values indicated by the LASER OFFSET fields in the Settings page and the INI file.

16. Setup Tab

It’s possible to load Html or PDF file (.html ending) with setup notes.
HTML docs will be displayed in the setup tab and PDF will launch the system PDF Viewer.
Some program, such as Fusion and Aspire will create this files for you.
If you load a gcode program and there is an HTML/PDF file of the same name, it will load automatically.

QtDragon Setup Tab
Figure 5. qtdragon - Setup Tab Sample

17. Styles

Nearly all aspects of the GUI appearance are configurable via the qtdragon.qss stylesheet file. The file can be edited manually or through the stylesheet dialog widget in the GUI. To call up the dialog, press F12 on the main window. New styles can be applied temporarily and then saved to a new qss file, or overwrite the current qss file.

QtDragon styles
Figure 6. qtdragon - Two Style Examples

18. Screen resolution

This GUI was initially developed for a screen with 1440 x 900 resolution.
QtDragon_hd has a resolution of 1920 x 1056.
They are not resizable. They will work in window mode on
any monitor with higher resolution but not on monitors with lower resolution.

19. Customization

19.1. Stylesheets

Stylesheets can be leveraged to do a fair amount of customization, but you usually need to know a bit about the widget names.
Pressing F12 will display a stylesheet editor dialog to load/test/save modification.
For instance:

To change the DRO font (look for this entry and change the font name):

DROLabel,
StatusLabel#status_rpm {
    border: 1px solid black;
    border-radius: 4px;
    font: 20pt "Noto Mono";
}

To change the text of the mist button to air (add these lines)

#action_mist{
qproperty-true_state_string: "Air\\nOn";
qproperty-false_state_string: "Air\\nOff";
}

19.2. QtDesigner and python code

All aspects of the GUI are fully customization through Qt Designer and/or python code.
This capability is included with the Qtvcp development environment.
The extensive use of Qtvcp widgets keeps the amount of required python code to a minimum, allowing relatively easy modifications.
The LinuxCNC website has extensive documentation on the installation and use of Qtvcp libraries.
QtVCP Overview for more information

QtDragon customized
Figure 7. qtdragon - Customized QtDragon