External Enable, Spindle CW & CCW Buttons (HAL Support)

More
24 Apr 2023 13:58 #269760 by Stevosmiff
Hi All, 

Could I please have some help with some custom HAL?

Hi I'm Steve, and I'm in the process of converting a Bridgeport (clone) to CNC using the MESA 7i96s and AC servo drivers. I would like to use the existing manual (hardware) buttons on the milling machine to control the 'machine enable' and the 'spindle'. So far, I have LinuxCNC all up and running with Servo and spindle control running fine through LinuxCNC. I have physically wired the buttons to the inputs of the MESA card. In HAL configuration I can see the input buttons switching when I press them. What I'm stuck with is the custom HAL code to connect the button signals to control the following:

1. Machine Enable
When the physical enable button is pressed it latches through a contactor circuit and thus provides the MESA card with a latched 'on' input. When this is on, I would like the 'machine,is-on' to be triggered. And vise verse, when the input is off, the 'machine.is-on', should be cancelled.

2. Spindle CW 
When the physical Spindle CW button is pressed it latches through a contactor circuit and thus provides the MESA card with a latched 'on' input. When this is on, I would like the it to act as a M3 command . And vise verse, when the input is off, it should be like a M5 command.

3. Spindle CCW 
Again, when the physical Spindle CCW button is pressed it latches through a contactor circuit and thus provides the MESA card with a latched 'on' input. When this is on, I would like the it to act as a M4 command . And vise verse, when the input is off, it should be like a M5 command.

I have read all I can in the HAL manuals and I have to say I'm lost with what code is required and where I should put it!

Any help will be gratefully received. 

Best Regards 

Steve 

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

More
01 May 2023 17:53 - 01 May 2023 17:57 #270417 by Aciera
Maybe like this:

# --- MACHINE ENABLE ---
net machine-button-panel <= hm2_<your_mesa_input_pin_here> => halui.machine.on

# --- M3 PANEL BUTTON ---
net m3-cmd-panel <= hm2_<your_mesa_input_pin_here> => halui.spindle.0.forward

# --- M4 PANEL BUTTON ---
net m4-cmd-panel <= hm2_<your_mesa_input_pin_here> => halui.spindle.0.reverse


Since you don't want a panel button for M5 you will need to run the signals 'm3-cmd-panel' and 'm4-cmd-panel' through a 'not' component. Those two negated signals could then be passed through a 'oneshot' component each and the resulting pulsed signals combined with an 'or' component and that output fed to 'halui.spindle.0.stop'

Easier would be to have a separate button for spindle stop:

# --- M5 PANEL BUTTON ---
net m5-cmd-panel <= hm2_<your_mesa_input_pin_here> => halui.spindle.0.stop

[edit]
The 'oneshot' component can also be set to trigger on negative edges using parameters so the 'not' component could be omitted.
linuxcnc.org/docs/html/man/man9/oneshot.9.html
 
Last edit: 01 May 2023 17:57 by Aciera.
The following user(s) said Thank You: blazini36

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

More
01 May 2023 19:52 #270424 by blazini36
That's some good advice

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

More
02 Feb 2024 21:10 #292251 by echristley
What I did for the stop was to AND the "-not' from the Mesa pin, and run the output of the AND to halui.spindle.0.stop

The trick is that halui only responds to the rising edge of events, and then latches. When toggled to forward or reverse, the signal rises and triggers halui. The not of that signal drops, but halui ignores it. When you switch back to center, halui ignores the forward and reverse inputs, because they're falling. But, both nots are true again, and the output of the AND rises, triggering the halui's stop input.

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

Time to create page: 0.100 seconds
Powered by Kunena Forum