Learning to work with new QTVCP screens and handler

More
25 Oct 2020 18:43 #187212 by Pro_El
Hello, First off all i am new with building customized screens. I installed QT Designer and linuxcnc widgets and made some simple screen that worked for me. I have idea to use linuxcnc input output mesa boards or LPT port and custom screen conected with hal pins on classicladder. Here is my first problem. I'v reed tutorials for QTVCP and Widgets but i cannot find example how to connect Hal input - output button on my screen with classicladder so i can add some logic. The same problem is with number (enter in some entry box) i will enter on my new screen and want to use this number in classicladder for logic. How can i connect this with classicladder. I think i should modify handler.py but i do not now is this the best and easiest way..

Thanks my friends..

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

More
25 Oct 2020 22:08 #187236 by cmorley
You need to make a HAL file to load the components, connect the pins and start the thread running.

This sample requires an up to date 2.8 or master version.
It would be loaded with this command in a terminal:
halrun -I -f testpanel.hal

There is no classicladder program but if you hit the vars button you can:
see the checknutton 1 state in the bit vars window
you can control the LED 1 by clicking the %q0 vars checkbox
you can show/hide the classicladder window with the checkbox 4
you can see the dial1 output if you replace %W0 with %IW0 in the watch window

If your version of linuxcnc is not updated enough then you would need to supply a Qtvcp panel rather then using the builtin one.
This will hopefully give you enough to play around with.

Chris
Attachments:
The following user(s) said Thank You: Pro_El

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

More
27 Oct 2020 18:44 #187452 by Pro_El
I have 2.8 install on Buster and i will try this option with hal this weekend,
Thanks cmorley

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

More
13 Dec 2020 17:02 - 13 Dec 2020 17:04 #191875 by Pro_El
Hello,
I'v been learning quite a while to build screen . I am very new in python an trying to figure some actions. I'v reed all documentation for QUTVCP and Widgets. My problem now is:
I need to make some custom actions with touch of a button. I think should be good if i call some functions with more MDI commands similar to this function for probing
I make button in QTVCP screen but cannot activate function . I can make one MDI movment with build in action widget MDI option. But i need more comands to exsecute one by one in untitled.py file. I am working in 2.9 master and Buster, and have all requaerments like EStop, Machine On, Home, and MDI mode properly activated so MDI commands should work. If somebody can guide me for build function with 2 or 3 MDI action to start with a push of button will be very good.

touch-off example from QTDragon


def touchoff(self, selector):
if selector == 'touchplate':
z_offset = float(self.w.lineEdit_touch_height.text())
elif selector == 'sensor':
z_offset = float(self.w.lineEdit_sensor_height.text()) - float(self.w.lineEdit_work_height.text())
else:
self.add_alarm("Unknown touchoff routine specified")
return
self.add_status("Touchoff to {} started".format(selector))
max_probe = self.w.lineEdit_max_probe.text()
search_vel = self.w.lineEdit_search_vel.text()
probe_vel = self.w.lineEdit_probe_vel.text()
ACTION.CALL_MDI("G21 G49")
ACTION.CALL_MDI("G10 L20 P0 Z0")
ACTION.CALL_MDI("G91")
command = "G38.2 Z-{} F{}".format(max_probe, search_vel)
if ACTION.CALL_MDI_WAIT(command, 10) == -1:
ACTION.CALL_MDI("G90")
return
if ACTION.CALL_MDI_WAIT("G1 Z4.0"):
ACTION.CALL_MDI("G90")
return
ACTION.CALL_MDI("G4 P0.5")
command = "G38.2 Z-4.4 F{}".format(probe_vel)
if ACTION.CALL_MDI_WAIT(command, 10) == -1:
ACTION.CALL_MDI("G90")
return
command = "G10 L20 P0 Z{}".format(z_offset)
ACTION.CALL_MDI_WAIT(command)
command = "G1 Z10 F{}".format(search_vel)
ACTION.CALL_MDI_WAIT(command)
ACTION.CALL_MDI("G90")
Last edit: 13 Dec 2020 17:04 by Pro_El.

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

More
13 Dec 2020 17:33 #191876 by cmorley
If I understand correctly you need a button to call the function in the handler?

There are a couple ways to do this, one is using slots and signals:
linuxcnc.org/docs/2.8/html/gui/qtvcp.html#cha:designer-slots
You can use a normal button or an qtvcp action button in this way.

Or you can use an action button or HAL pushbutton to call the handler function:
linuxcnc.org/docs/2.8/html/gui/qtvcp_wid...#_push_button_widget
(scroll down a bit to 'Call python commands on state'

Chris

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

More
13 Dec 2020 18:44 #191886 by Pro_El
I finished everything with graphical signal connection with button and now when i start LCNC gives me this error

'VCPWindow' object has no attribute 'test_button'

What should i write to handler.py so i can use this signal to start mdi functions. Thanks Chris

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

More
13 Dec 2020 19:03 #191888 by cmorley
well 'test_ button' would be the name of the function you wish to call.

Though it looks like the function you wish to call is 'touchoff' and requires an argument.

so either rename the function you wish to call to test_button or redo the slot name in designer to 'touchoff'

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

More
13 Dec 2020 20:19 - 13 Dec 2020 20:21 #191901 by Pro_El
Working great, Function starts and MDI Program roll
I see one problem now

def test_button(self):
if STATUS.is_mdi_mode():
ACTION.CALL_MDI("G0 X100 Y100 F1000")
ACTION.CALL_MDI("G0 Y0 F1000")

First ACTION.CALL_MDI("G0 X100 Y100 F1000") did not finished it start the second line with ACTION.CALL_MDI("G0 Y0 F1000")

What can i do to make it to wait to finish the first line and then go on with second??

Thanks Chris you are the champion.
Last edit: 13 Dec 2020 20:21 by Pro_El.

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

More
13 Dec 2020 21:17 #191905 by Pro_El
I have one theory that can work. If i can connect is_running signal from LCNC i can start second LCNC MDI code after first MDI finish running. This is only theory. How can i connect this signal to handler.py. As far as i now i signal from STATUS but i don't now the syntax to do so.

thanks

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

More
13 Dec 2020 21:19 #191906 by cmorley
you shoulda left the MDI_CALL_WAIT
MDI_CALL_WAIT defaults with a 5 second wait time.
you can change it to something else:

ACTION.CALL_MDI_WAIT("G0 X100 Y100 F1000", 30)

I always though MDI calls stacked but my quick test seems to show they do not.

Chris
The following user(s) said Thank You: Pro_El

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

Moderators: cmorley
Time to create page: 0.264 seconds
Powered by Kunena Forum