Unable to resolve coolant momentary switch issue

More
9 years 2 months ago #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 to join the conversation.

More
9 years 2 months ago #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 to join the conversation.

More
9 years 2 months ago #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?
Code:
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 to join the conversation.

More
9 years 2 months ago #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 to join the conversation.

More
9 years 2 months ago #97093 by rodw

Todd Zuercher wrote: 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 to join the conversation.

More
9 years 2 months ago #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 to join the conversation.

More
9 years 2 months ago #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 to join the conversation.

More
9 years 2 months ago #97156 by rodw

IIOII wrote: 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 to join the conversation.

More
9 years 2 months ago #97174 by Todd Zuercher
This will work with the toggle2nist, it just needs to be connected right and maybe an edge, added.
Code:
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

Please Log in to join the conversation.

More
9 years 2 months ago #97190 by andypugh

IIOII wrote: 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 to join the conversation.

Time to create page: 0.099 seconds
Powered by Kunena Forum