How can I link into qtpyvcp jog functions using hal pins

More
29 Apr 2020 19:35 - 29 Apr 2020 19:37 #166133 by auto-mation-assist
I would like to get access to the qtvcp jog functions from hal pins.

My machine has a manual rotary switch for placing the machine in manual mode. When switched from CNC to manual mode it automatically moves Z axis to its home position which also allows the ball screw clamp to be released since its access hole will be aligned. After this it disables the servo drives but leaves the linear axis encoders active so that hey can be used for positioning.

There is also a push button switch on the machines front panel that when pushed it will automatically move the machine out of any limit condition just enough to clear the active limit switch or switches.

Both of these use functions have used jogging features for generating the proper directional movement and were originally coded years ago using Gmoccapy which has hal jogging pins that can be used for such a purpose.

I have added some hal pins to qtpyvcp which show up in halshow now and also renamed the ones in my postgui hall file to the names of the new pins now provided by qtpyvcp as shown below. Now I need to find the best way to link these new pins into qtpyvcr jog functions and hope for some suggestions that will not create problems later on.

This is in my postgui hale file.

# Move out of limits using the push button on machines control panel "MOV OUT LIM"
# Z plus output is merged with output from manual mode via or2. This moves Z up
# to home position to allow for unclamping of Z axis ball screw drive clamp.
net limits-xlim-p qtpyvcp.jog_x_minus.in <= and2.1.out
net limits-xlim-n qtpyvcp.jog_x_plus.in <= and2.2.out
net limits-ylim-p qtpyvcp.jog_y_minus.in <= and2.3.out
net limits-ylim-n qtpyvcp.jog_y_plus.in <= and2.4.out
net limits-zlim-p qtpyvcp.jog_z_minus.in <= and2.5.out
net limits-zlim-n qtpyvcp.jog_z_plus.in <= or2.0.out
Last edit: 29 Apr 2020 19:37 by auto-mation-assist.

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

More
30 Apr 2020 00:28 #166178 by KCJ

I have added some hal pins to qtpyvcp which show up in halshow


Did you actually add jog HAL pins to QtPyVCP, or did you just add them to your HAL file?
Was the original "jog off limit" logic implemented in python or HAL? If in python it would be helpful to see that code so I could better assist in migrating it to QtPyVCP methods.

It sounds like you are using hardware switches and buttons for the user input, so I would suggest keeping this all in HAL rather than relying on userspace/GUI code. Should be safer and more reliable.

Why don't you just use the halui jogging interface for moving off the limits? It's quite complete: www.linuxcnc.org/docs/html/man/man1/halui.1.html

Cheers,
Kurt

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

More
30 Apr 2020 03:50 #166185 by auto-mation-assist
Kurt, I added the pins to basic_probe.py and all logic is implemented in my .hal and postgui.hal files. The two switches I mentioned are indeed hardware switches and route their some signals to a mesa 7i80 board.

I will look into the halui link which also reminded me that while I was working on a on a QTvcp interface about a year ago that I had converted some of this code to be done in the python handler. I will look at some of that code and see if there is something useful there.

I have probe_basic running and controlling my milling machine. Homing works but it does drive Z axis plus into positive limits due to some overshoot upon completion right now. Its limit is a bit to close at 0.05 positive from home position. Using the limit override in the machine pull down menu in probe_basic and turning power back on and using the jog buttons give me no motion. Perhaps my servo drives are not being enabled in this condition right now.

I'm still working a bit on my .hal and postgui.file and can post these later for your review.

Thanks for your help

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

More
02 May 2020 19:23 #166421 by auto-mation-assist
I have added some pins in probe_basic.py for now to see if they would show up ok and they do.
But there is likely a better place for them, perhaps even a user component?

# added the below items to add pins - see qtpyvcp 'hal_glib.py'
# these pins are false when not in limits and to be linked from postgui.hal
hal_comp = hal.COMPONENTS
self._x_pos_limitsw_pin = hal_comp.addPin("x_pos_limitsw", "bit", "in")
self._x_pos_limitsw_pin.value = self.isEnabled()
self._x_pos_limitsw_pin.valueChanged.connect(self.move_out_of_limits)
self._x_neg_limitsw_pin = hal_comp.addPin("x_neg_limitsw", "bit", "in")
self._x_neg_limitsw_pin.value = self.isEnabled()
self._x_neg_limitsw_pin.valueChanged.connect(self.move_out_of_limits)
self._y_pos_limitsw_pin = hal_comp.addPin("y_pos_limitsw", "bit", "in")
self._y_pos_limitsw_pin.value = self.isEnabled()
self._y_pos_limitsw_pin.valueChanged.connect(self.move_out_of_limits)
self._y_neg_limitsw_pin = hal_comp.addPin("y_neg_limitsw", "bit", "in")
self._y_neg_limitsw_pin.value = self.isEnabled()
self._y_neg_limitsw_pin.valueChanged.connect(self.move_out_of_limits)
self._z_pos_limitsw_pin = hal_comp.addPin("z_pos_limitsw", "bit", "in")
self._z_pos_limitsw_pin.value = self.isEnabled()
self._z_pos_limitsw_pin.valueChanged.connect(self.move_out_of_limits)
self._z_neg_limitsw_pin = hal_comp.addPin("z_neg_limitsw", "bit", "in")
self._z_neg_limitsw_pin.value = self.isEnabled()
self._z_neg_limitsw_pin.valueChanged.connect(self.move_out_of_limits)
hal_comp.ready()


If any of the above are true and the qtpyvcp 'overide limits' is pushed or my mechanical button on the machines front panel is pushed I would like to execute something like the below in qtpyvcp.

def move_out_of_limits(self):
hal_comp = hal.COMPONENTS
enable = True
jointflag = 1
axisjoint = -1
distance = 0.2000
CMD = linuxcnc.command()
# CMD.override_limits() # not automatic
if self.hal_comp == True:
dir_vel = -5
axisjoint = 0
if self.hal_comp == True:
dir_vel = .5
axisjoint = 0
if self.hal_comp == True:
dir_vel = -.5
axisjoint = 1
if self.hal_comp == True:
dir_vel = .5
axisjoint = 1
if self.hal_comp == True:
dir_vel = -.5
axisjoint = 2
if self.hal_comp == True:
dir_vel = .5
axisjoint = 2
if axisjoint != -1:
CMD.state(linuxcnc.STATE_ON)
CMD.jog(linuxcnc.JOG_INCREMENT,jointflag,axisjoint,(float(dir_vel)),(float(distance)))

# visual limit warning indicator label
if self.w.plab_f2_limits_label.getText() != Limits:
self.w.plab_f2_limits_label.setText('Limits')

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

Moderators: KCJLcvette
Time to create page: 0.072 seconds
Powered by Kunena Forum