Unable to resolve coolant momentary switch issue

More
05 Aug 2017 12:59 #97028 by IIOII
I'm new to LinuxCNC and I'm having difficulty getting the following setup to work.
I'd like the coolant to turn on or off using either the Axis checkbox or an external momentary switch.

What's the best way?

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

More
06 Aug 2017 04:21 #97059 by Todd Zuercher
There are halui pins for controlling coolant (flood and mist). They are separate three separate pins for both, on, off, and a status pin. You can use some hal logic to control them using a single momentary input,.

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

More
06 Aug 2017 12:15 #97066 by IIOII
I've been troubleshooting the below code without success. When the momentary switch is pressed, the coolant is turned on, but unable to turn off again. Any suggestions on how to rectify?
loadrt toggle2nist count=1
addf toggle2nist.0 servo-thread

#Seems these need to be here to keep check boxes visible
net coolant-flood     <=  iocontrol.0.coolant-flood

# Coolant switch
net flood-toggle toggle2nist.0.in <= hm2_7i76e.0.7i76.0.0.input-27
net flood-on toggle2nist.0.on => halui.flood.on 
net flood-off toggle2nist.0.off => halui.flood.off

# Coolant LED control
net flood-control halui.flood.is-on => hm2_7i76e.0.7i76.0.0.output-14

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

More
07 Aug 2017 03:18 #97090 by Todd Zuercher
I'm not sure that the Toggle2NIST component is the right tool for the job. (at least by it's self.) Toggle2NIST holds it's output pins true between button presses. What might be a better option is to just use a couple of and2 comps, a not, and maybe a oneshot (or edge).

The idea being a button press and the coolant on pin true, sends a pulse to the coolant off pin, and Similarly a button press and a coolant-on-not pin true would send a pulse to the coolant on pin.

When ever I try, this sort of hal logic, it always seems to end up much more complicated than it appears at first glance on the surface.

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

More
07 Aug 2017 05:49 #97093 by rodw

When ever I try, this sort of hal logic, it always seems to end up much more complicated than it appears at first glance on the surface.


Thats why I think that making a custom component is often so much easier. What you can do in 2-3 lines in C can take half a page in hal.

This is probably LinuxCNC's best kept secret.

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

More
07 Aug 2017 13:47 #97104 by Todd Zuercher
Easy peasy, if your fluent in C. I'm not, so I just muddle along stringing together hal commands.

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

More
07 Aug 2017 23:02 #97132 by IIOII
I've written some similar logic in Lua for a previous Mach4 build, so the logic and code should be somewhat similar in C. What's the process for creating and compiling a custom C component? Alternatively, does anyone have some hal logic they could share to achieve the required result?

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

More
08 Aug 2017 03:01 #97156 by rodw

I've written some similar logic in Lua for a previous Mach4 build, so the logic and code should be somewhat similar in C. What's the process for creating and compiling a custom C component? Alternatively, does anyone have some hal logic they could share to achieve the required result?


If you drop in on the plasma and laser section on this forum, there are several components I've written. Use them as an example.
This is a simple one. forum.linuxcnc.org/plasma-laser/32657-th...-indicator-component
Then its just as simple as typing "halcompile --install mycomponent.comp"
And the component is compiled and installed for you.

Just remember your component is being called every time the servo loop is called. Don't do any loops, just wait until the next pass through.

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

More
08 Aug 2017 14:27 - 08 Aug 2017 14:31 #97174 by Todd Zuercher
This will work with the toggle2nist, it just needs to be connected right and maybe an edge, added.
loadrt toggle2nist count=1
loadrt edge count=1
addf toggle2nist.0 servo-thread
addf edge.0 servo-thread

#Seems these need to be here to keep check boxes visible
net coolant-flood  <=  iocontrol.0.coolant-flood

# Coolant switch
net flood-button <= hm2_7i76e.0.7i76.0.0.input-27 => 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

# Coolant LED control
net coolant-flood => hm2_7i76e.0.7i76.0.0.output-14
Last edit: 08 Aug 2017 14:31 by Todd Zuercher.
The following user(s) said Thank You: OT-CNC, IIOII

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

More
08 Aug 2017 17:08 #97190 by andypugh

What's the process for creating and compiling a custom C component?


linuxcnc.org/docs/2.7/html/hal/comp.html

For fun you could use LUT5, with inputs from the button, halui.coolant.is-on and the iocontrol coolant pins.
LUT5 is especially good fun when you feed its own output back as an input. But it does tend to make for rather "write once" HAL code.

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

Time to create page: 0.095 seconds
Powered by Kunena Forum