External Coolant Controls

More
15 Aug 2021 17:43 #217835 by davidimurray
Hi All

After a hiatus, I'm back working on my new lathe. Having done some setup on the bench in Linuxcnc, I am now working on moving various functions into PP.

One thing I'm looking to do is add some external controls - in addition to the software controls. I can get either the external control, or the on-screen buttons to work. But not both together. Any help would be appreciated

Looking in the UI file - it appears PP looks at tormach.coolant-iocontrol
def on_coolant_button_release_event(self, widget, data=None):
        # POSTGUI_HALFILE contains:
        # net coolant-flood tormach.coolant => parport.0.pin-14-out
        # net coolant-flood-io iocontrol.0.coolant-flood => tormach.coolant-iocontrol
        # The UI code here watches tormach.coolant-iocontrol for changes from LinuxCNC.
        # See the periodic handler for details
        if not self.is_button_permitted(widget): return
        self.window.set_focus(None)
        # disable coolant lockout : if user commands coolant, do it immediately
        self.coolant_lockout = 0
        # use our tormach.coolant HAL pin to track actual coolant state
        coolant_on = self.hal['coolant']
        if not coolant_on:
            self.hal['coolant'] = 1
        else:
            self.hal['coolant'] = 0

In the postgui file I have the following. The last two line are the original PP code. As shown, the code switches my coolant relay with the external switch but on-screen does not work. If I uncomment the original code - it complains about more than one pin being connected to the signal.
#coolant toggle section#
loadrt toggle2nist count=1
loadrt edge count=1
addf toggle2nist.0 servo-thread
addf edge.0 servo-thread
net coolant-flood  <=  iocontrol.0.coolant-flood

# Coolant switch
net flood-button <= hm2_7i76e.0.7i76.0.0.input-06 => edge.0.in 
net button-edge <= edge.0.out => toggle2nist.0.in 
net flood-on <= toggle2nist.0.on => halui.flood.on 
net flood-off <= toggle2nist.0.off => halui.flood.off
net flood-control <= halui.flood.is-on => toggle2nist.0.is-on

#original tormach code below here
#net coolant-flood tormach.coolant
#net coolant-flood-io iocontrol.0.coolant-flood => tormach.coolant-iocont

Any ideas would be much appreciated.

Thanks

Dave

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

More
15 Aug 2021 19:31 #217840 by nkp
Replied by nkp on topic External Coolant Controls
        self.hal = hal.component("tormach")
        self.hal.newpin("coolant", hal.HAL_BIT, hal.HAL_OUT)
        self.hal.newpin("coolant-iocontrol", hal.HAL_BIT, hal.HAL_IN)
        self.hal.newpin("coolant-tgbutton", hal.HAL_BIT, hal.HAL_IN) #nkp
         # initial hal states:
        self.prev_coolant_iocontrol = self.hal['coolant'] = 0
        self.prev_coolant_tgbutton  = 0 #nkp https://forum.linuxcnc.org/pathpilot/43326-external-coolant-controls
          if self.prev_coolant_iocontrol != self.hal['coolant-iocontrol']:
            if self.hal['coolant-iocontrol']:
                self.hal['coolant'] = 1
            else:
                self.hal['coolant'] = 0
            # current becomes previous
            self.prev_coolant_iocontrol = self.hal['coolant-iocontrol']

        # nkp https://forum.linuxcnc.org/pathpilot/43326-external-coolant-controls
        if self.prev_coolant_tgbutton != self.hal['coolant-tgbutton']:
            if self.hal['coolant-tgbutton']:
                self.hal['coolant'] = 1
            else:
                self.hal['coolant'] = 0
            # current becomes previous
            self.prev_coolant_tgbutton = self.hal['coolant-tgbutton']
net coolant-flood     tormach.coolant           => parport.0.pin-14-out
net coolant-flood-io  iocontrol.0.coolant-flood => tormach.coolant-iocontrol


net tgb  tormach.coolant-tgbutton


loadusr sim_pin    tgb

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

More
16 Aug 2021 13:26 #217881 by andypugh
Replied by andypugh on topic External Coolant Controls
I use a 3-position switch and a mux component for this.
In the central "auto" position the mux passes through the iocontrol.0.coolant-flood signal.
Then the off input is simply setp to 0, and on to 1. So I can either leave the coolant under software control, or force it on or off.

(Note that this is done with a mux-generic component, that can be configured for bit-type signals.)

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

More
16 Aug 2021 20:07 #217915 by davidimurray
Thanks nkp - I tried for a few hours to get the code to work but I could not get it to switch with the external switch.

Andy - being cheeky would you have a sample of the code you use. I am a relative newbie to HAl and tried tonight to use mux-generic but think I confused myself!

Thanks both

 

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

More
16 Aug 2021 21:17 #217916 by andypugh
Replied by andypugh on topic External Coolant Controls
loadrt mux_generic config="bb4"
addf mux-gen.00 servo-thread

net coolant-off hm2_7i84.008a.input-25 => mux-gen.00.sel-bit-00
net coolant-on hm2_7i84.008a.input-26 => mux-gen.00.sel-bit-01
net coolant-flood mux-gen.00.out-bit => hm2_7i84.008a.output-08
net coolant-auto iocontrol.0.coolant-flood => mux-gen.00.in-bit-00
setp mux-gen.00.in-bit-01 0
setp mux-gen.00.in-bit-02 1
setp mux-gen.00.in-bit-03 0
 

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

More
19 Aug 2021 20:16 #218176 by davidimurray
Thanks Andy

I've been having a play and can get the external switch working, but not with the onscreen button. After some work, I;ve got HALshow working. And looking at the pins tormach.coolant seems to be the one that changes with the onscreen button.

I've tried changing
net coolant-auto iocontrol.0.coolant-flood => mux-gen.00.in-bit-00
to
net tormach.coolant => mux-gen.00.in-bit-00
but that doesn't work - any ideas much appreciated.

Thanks

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

More
19 Aug 2021 23:45 #218188 by andypugh
Replied by andypugh on topic External Coolant Controls

but that doesn't work 

How doesn't it work? Is there an error message? 

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

More
20 Aug 2021 11:28 #218230 by davidimurray
No error message. Pathpilot starts fine. When I toggle the on screen button, I can see tormach.coolant change states, but the output from the MUX does not change. If i use my external switch then the MUX output does change.

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

More
20 Aug 2021 11:31 #218231 by andypugh
Replied by andypugh on topic External Coolant Controls
What is the state of the mux select inputs in the "auto" position? perhaps toemach,coolant needs to go to in-bit-03

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

More
20 Aug 2021 11:53 #218234 by davidimurray
I will have a play later when I get back from work and try changing the bit

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

Moderators: cncbasher
Time to create page: 0.106 seconds
Powered by Kunena Forum