Status of hal pin- to change hal button or led?
- woodworkerjb
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 1
13 Mar 2020 00:41 #159968
by woodworkerjb
Status of hal pin- to change hal button or led? was created by woodworkerjb
I am trying to setup my lathe up so that before allowing a cycle start the collet closer has ample psi as well as the door being closed.
My code for checking the status of the two requirements is:
loadrt and2 names=cycle_ready
addf cycle_ready servo-thread
#NOTE:qtpyvcp.airpressure.checked and qtpyvcp.doorclosed.checked is for development, the physical mesa card pin will inserted.
net air_ok qtpyvcp.airpressure.checked => cycle_ready.in0 ##
net door_ok qtpyvcp.doorclosed.checked => cycle_ready.in1
net all_ok => cycle_ready.out
From this I would like to have an indicator on my qtpyvcp that 1.) Displays the Cycle Start button green if cycle_ready is true red if false. and 2.) I want to indicate on the panel a green led if collet is closed and a red led if open.
I have tried setting qtpyvcp.cycle_ready to TRUE as well as 1 but I am coming up short on how to interact between the two. . I have read about the widgetRules process but I can't find a status rule that would allow me to status the cycle_ready pin. Can someone point me in the right direction on what I should read or examples I could study to archive this? As a side question I read in a post that a plug-in was being written to enable the hal pins in the channel selection. Is this plug-in available?
Thanks
My code for checking the status of the two requirements is:
loadrt and2 names=cycle_ready
addf cycle_ready servo-thread
#NOTE:qtpyvcp.airpressure.checked and qtpyvcp.doorclosed.checked is for development, the physical mesa card pin will inserted.
net air_ok qtpyvcp.airpressure.checked => cycle_ready.in0 ##
net door_ok qtpyvcp.doorclosed.checked => cycle_ready.in1
net all_ok => cycle_ready.out
From this I would like to have an indicator on my qtpyvcp that 1.) Displays the Cycle Start button green if cycle_ready is true red if false. and 2.) I want to indicate on the panel a green led if collet is closed and a red led if open.
I have tried setting qtpyvcp.cycle_ready to TRUE as well as 1 but I am coming up short on how to interact between the two. . I have read about the widgetRules process but I can't find a status rule that would allow me to status the cycle_ready pin. Can someone point me in the right direction on what I should read or examples I could study to archive this? As a side question I read in a post that a plug-in was being written to enable the hal pins in the channel selection. Is this plug-in available?
Thanks
Please Log in or Create an account to join the conversation.
13 Mar 2020 02:08 #159977
by KCJ
Replied by KCJ on topic Status of hal pin- to change hal button or led?
The easiest way to do this right now is probably to add a little code to the VCP's mainwindow python file. For probe basic this would be the probe_basic.py file.
In the import section at the top of the file add
Add this to the end of the __init__ method
Add this method anywhere in the mainwindow class
Then in your POSTGUI_HALFILE connect your pin to the pin we just created
This will cause the border of the widget named cycle_start_button to change to red when the qtpyvcp.cycle_ready.in pin is low, and true when the pin is high.
NOTE: If you are using probe basic the name of the cycle start widget is actually actionbutton_3
You can add a HalLedButton to indicate the status of the collet closer, and connect it in your POSTGUI_HALFILE. There is no need to add any python code for that since the widget takes car of creating and watching its HAL pin.
See: www.qtpyvcp.com/widgets/hal/index.html?h....hal_widgets.hal_led
In the import section at the top of the file add
from qtpyvcp import hal
Add this to the end of the __init__ method
hal_comp = hal.COMPONENTS['qtpyvcp']
# add a cycle_ready pin to the default qtpyvcp hal component
self._cycle_ready_pin = hal_comp.addPin("cycle_ready.in", "bit", "in")
self._cycle_ready_pin.value = self.isEnabled()
self._cycle_ready_pin.valueChanged.connect(self.onCycleReadyPinChanged)
Add this method anywhere in the mainwindow class
def onCycleReadyPinChanged(self, value):
if value:
self.cycle_start_button.setStyleSheet('border-color: green')
else:
self.cycle_start_button.setStyleSheet('border-color: red')
Then in your POSTGUI_HALFILE connect your pin to the pin we just created
net cycle_ready.out => qtpyvcp.cycle_ready.in
This will cause the border of the widget named cycle_start_button to change to red when the qtpyvcp.cycle_ready.in pin is low, and true when the pin is high.
NOTE: If you are using probe basic the name of the cycle start widget is actually actionbutton_3
You can add a HalLedButton to indicate the status of the collet closer, and connect it in your POSTGUI_HALFILE. There is no need to add any python code for that since the widget takes car of creating and watching its HAL pin.
See: www.qtpyvcp.com/widgets/hal/index.html?h....hal_widgets.hal_led
Attachments:
The following user(s) said Thank You: anfänger
Please Log in or Create an account to join the conversation.
- woodworkerjb
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 1
13 Mar 2020 03:06 #159982
by woodworkerjb
Replied by woodworkerjb on topic Status of hal pin- to change hal button or led?
KCJ, thank you so much I will try your code as well as read up on python to better understand the process.
Please Log in or Create an account to join the conversation.
- woodworkerjb
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 1
13 Mar 2020 17:25 - 14 Mar 2020 00:14 #160056
by woodworkerjb
Replied by woodworkerjb on topic Status of hal pin- to change hal button or led?
Close but not there yet.
After playing with the location and spacing syntax for a while I came up with:
class ProbeBasic(VCPMainWindow):
"""Main window class for the ProbeBasic VCP."""
def __init__(self, *args, **kwargs):
super(ProbeBasic, self).__init__(*args, **kwargs )
hal_comp = hal.COMPONENTS
# add a cycle_ready pin to the default qtpyvcp hal component
self._cycle_ready_pin = hal_comp.addPin("cycle_ready.in", "bit", "in")
self._cycle_ready_pin.value = self.isEnabled()
self._cycle_ready_pin.valueChanged.connect(self.onCycleReadyPinChanged)
def onCycleReadyPinChanged(self, value):
if value:
self.cycle_start_button.setStyleSheet('border-color: green')
else:
self.cycle_start_button.setStyleSheet('border-color: red')
It appears the new pin is in fact being created in the qtpyvcp but I get an error from saying that custom_postgui.hal:11 PIN 'qtpyvcp.cycle_ready.in' does not exist. Line 11 is net cycle_ready.out => qtpyvcp.cycle_ready.in
Any thought would be appreciated. I am hoping that I have added the lines properly to the probe_basic.py file.
After playing with the location and spacing syntax for a while I came up with:
class ProbeBasic(VCPMainWindow):
"""Main window class for the ProbeBasic VCP."""
def __init__(self, *args, **kwargs):
super(ProbeBasic, self).__init__(*args, **kwargs )
hal_comp = hal.COMPONENTS
# add a cycle_ready pin to the default qtpyvcp hal component
self._cycle_ready_pin = hal_comp.addPin("cycle_ready.in", "bit", "in")
self._cycle_ready_pin.value = self.isEnabled()
self._cycle_ready_pin.valueChanged.connect(self.onCycleReadyPinChanged)
def onCycleReadyPinChanged(self, value):
if value:
self.cycle_start_button.setStyleSheet('border-color: green')
else:
self.cycle_start_button.setStyleSheet('border-color: red')
It appears the new pin is in fact being created in the qtpyvcp but I get an error from saying that custom_postgui.hal:11 PIN 'qtpyvcp.cycle_ready.in' does not exist. Line 11 is net cycle_ready.out => qtpyvcp.cycle_ready.in
Any thought would be appreciated. I am hoping that I have added the lines properly to the probe_basic.py file.
Last edit: 14 Mar 2020 00:14 by woodworkerjb. Reason: Original post was not clear
Please Log in or Create an account to join the conversation.
14 Mar 2020 01:21 #160113
by KCJ
Replied by KCJ on topic Status of hal pin- to change hal button or led?
I have attached a complete working probe_basic.py file with the needed changes.
I tested it by adding this line to my POSTGUI_HALFILE
If you want to quickly check what HAL pins the current VCP has you can run
Let me know if you still run into missing HAL pin errors.
Cheers,
Kurt
I tested it by adding this line to my POSTGUI_HALFILE
net estoped halui.estop.is-activated => qtpyvcp.cycle_ready.in
If you want to quickly check what HAL pins the current VCP has you can run
halcmd show pin qtpyvcp
Let me know if you still run into missing HAL pin errors.
Cheers,
Kurt
Please Log in or Create an account to join the conversation.
- woodworkerjb
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 1
14 Mar 2020 21:14 #160214
by woodworkerjb
Replied by woodworkerjb on topic Status of hal pin- to change hal button or led?
Kurt,
I can't tell you how much I appreciate your patience! The first attempt with your code and addition to the POSTGUI_HALFIle failed so I removed all of the probe_basic files and reinstalled from a fresh git.clone. I replaced the newly created probe_basic.py with the one you provided yesterday. I then placed the net estoped halui.estop.is-activated => qtpyvcp.cycle_ready.in line into the created postgui_halfile (hallib/time.hal).
After all that I continue to get the error message: hal:13: Pin 'qtpyvcp.cycle_ready.in' does not exist. Failed to load POSTGUI_HALFILE with error: 1
I can't tell you how much I appreciate your patience! The first attempt with your code and addition to the POSTGUI_HALFIle failed so I removed all of the probe_basic files and reinstalled from a fresh git.clone. I replaced the newly created probe_basic.py with the one you provided yesterday. I then placed the net estoped halui.estop.is-activated => qtpyvcp.cycle_ready.in line into the created postgui_halfile (hallib/time.hal).
After all that I continue to get the error message: hal:13: Pin 'qtpyvcp.cycle_ready.in' does not exist. Failed to load POSTGUI_HALFILE with error: 1
Please Log in or Create an account to join the conversation.
14 Mar 2020 23:02 #160228
by KCJ
Replied by KCJ on topic Status of hal pin- to change hal button or led?
How are you installing QtPyVCP / ProbeBasic? It could be that you are not actually running the modified files, so the HAL pin is not being created.
Since you are modifying files within ProbeBasic you will need to install from your local directory containing the changes.
First uninstall any existing version of ProbeBasic (run multiple times until you get a red error in the terminal)
Then from your probe_basic directory run
This will create what is called a development install, and will allow you to modify files within probe_basic and have the changes be picked up next time you start it without needed to reinstall after each change.
Hope that helps!
Kurt
Since you are modifying files within ProbeBasic you will need to install from your local directory containing the changes.
First uninstall any existing version of ProbeBasic (run multiple times until you get a red error in the terminal)
pip uninstall probe_basic
Then from your probe_basic directory run
pip install -e . --no-deps
This will create what is called a development install, and will allow you to modify files within probe_basic and have the changes be picked up next time you start it without needed to reinstall after each change.
Hope that helps!
Kurt
Please Log in or Create an account to join the conversation.
- woodworkerjb
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 1
19 Mar 2020 20:02 #160771
by woodworkerjb
Replied by woodworkerjb on topic Status of hal pin- to change hal button or led?
Kurt,
Thanks for the help. I spent many many hours on this without success. I then decided to go drastic! I formatted the hard drive and did a clean install of everything. Now it is working. Happy that worked, because plan C for this problem would have involved a sledge hammer, and colorful language. Again thanks for the help and patience.
JB
Thanks for the help. I spent many many hours on this without success. I then decided to go drastic! I formatted the hard drive and did a clean install of everything. Now it is working. Happy that worked, because plan C for this problem would have involved a sledge hammer, and colorful language. Again thanks for the help and patience.
JB
The following user(s) said Thank You: KCJ
Please Log in or Create an account to join the conversation.
20 Mar 2020 01:04 #160813
by KCJ
Replied by KCJ on topic Status of hal pin- to change hal button or led?
Glad you got it to work!
I need to find an easier way for people to do simple customizations to VCPs like this without needing to change files in the VCP it's self.
I need to find an easier way for people to do simple customizations to VCPs like this without needing to change files in the VCP it's self.
Please Log in or Create an account to join the conversation.
Time to create page: 0.098 seconds