Preventing gcode execution under certain conditions

More
22 Jun 2019 11:53 #137583 by JetForMe
I'm slowly refining my router table configuration, and I'm at a point where I want to add a bunch of rules about when things can occur.

For example, I don't want the spindle motor to be able to start if the draw bar is in the open position or there's insufficient air pressure (both of which are inputs to my Mesa card).

Another example: I don't want to allow a program or the manual button to unlock the power draw bar.

I have a lot of rules that I'm implementing in classic ladder. I know I can assert joint alarms, but are there other alarms I can assert?

Is there a signal for "program is running?"

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

More
22 Jun 2019 16:05 #137593 by pl7i92
yu can interfear by halui
blocking by halui.spindle.stop bit in
a rising edge on this pin stops the spindle

so your in puts also sets the halui.spindle.stop bit
the power draw bar. is for safty always at the user execute
interfearing that will cause you in some trouble

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

More
22 Jun 2019 23:16 #137616 by tommylight
You can also use the logic components of Linuxcnc for that type of interlocks and also have the mesage displayed if and when some of the conditions are not met so you do not have to look around the machine if it is because of the srawbar or air pressure, or anything else.
Am on the phone , so have a look at "and" "or" "xor" etc so you get a better idea on how to implement those imterlocks.

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

More
23 Jun 2019 01:03 - 23 Jun 2019 01:03 #137626 by andypugh

Is there a signal for "program is running?"


Yes. halui.program.is-running

linuxcnc.org/docs/2.7/html/man/man1/halui.1.html
Last edit: 23 Jun 2019 01:03 by andypugh.
The following user(s) said Thank You: JetForMe

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

More
23 Jun 2019 02:25 - 23 Jun 2019 02:26 #137634 by rodw

For example, I don't want the spindle motor to be able to start if the draw bar is in the open position or there's insufficient air pressure (both of which are inputs to my Mesa card).


This could be easilly done in hal using components without the overhead of classic ladder with two and2 components.
Simply connect your two mesa pins to the first and2 inputs. So the output of the and2 will only be true when both conditions are met.

Then connect the output of this and the motion.M.on to the inputs of another and2. Then connect the output of this second component to the relay or whatever turns your spindle relay on. So now, the spindle cannot start until everything is safe.

If you go to the main HTML documentation page for your version, down the bottom, there is a button that says "Expand Man Pages". Make sure its selected and the docs for a whole smorgasboard of hal components will be displayed. These are the logic components others have referred to.

If you can't find ones that do what you want, then its easy to use halcompile to create your own. This would actually be a good simple example to write as a starter. You could make an and3 component that had 3 inputs and one output that went true when all inputs were true. You could resolve this to a single line of c code.

You can find the source code for the existing default components here
github.com/LinuxCNC/linuxcnc/tree/master/src/hal/components

The and2 souce is here:
github.com/LinuxCNC/linuxcnc/blob/master...components/and2.comp

You can see how trivial the code would be to add an extra in2 pin and change line 18 to && the third pin. Then its just a matter of using halcompile to install it
I know you can Code in C from some of your earlier comments, but this is LinuxCNC's best kept secret. The ability to extend the system with your own custom components which become no different to any of the system components once installed.

I've never bothered to learn how to use classic ladder. I think I'd use a custom component if ever I really needed to.
Last edit: 23 Jun 2019 02:26 by rodw.

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

More
23 Jun 2019 14:55 #137653 by andypugh

If you can't find ones that do what you want, then its easy to use halcompile to create your own. This would actually be a good simple example to write as a starter. You could make an and3 component that had 3 inputs and one output that went true when all inputs were true.


There is no need to write an "and3" component as the "logic" component already offers And for as many inputs as you configure it with.

I use LUT5 for this sort of thing, though, as it allows you to configure 1 output for every possible state of 5 inputs.
It becomes especially useful when one of the inputs is connected to the output as then it can be a very configurable sort of latch.

But, here is the component I use to interlock the tool release on my milling machine. It both prevents the tool from being released if the spindle is moving, and prevents the spindle from starting if the tool is released.

spindle_interlock.comp
component spindle_interlock """Prevents tool or chuck release when the spindle is 
running""";

pin in signed encoder-counts "connect this to the spindle encoder";
param rw unsigned encoder-vel = 1 """how many counts per sec to accept as
spindle-stopped""";

pin in float spindle-speed-in """Pass-through the spindle speed request only if
the release is not activated""";
pin out float spindle-speed-out;

pin out bit release-allowed "For operating an indicator lamp, for example";
pin in bit release-request "The release request from the button/pedal";
pin out bit release-out "the release signal to the valve";
pin in bit release-state = 1 """This bit sets the value that is passed to
"release-out". Toggle it to 0 or 1 to suit internal or external gripping,
for example""";

function _;

license "GPL";
author "Andy Pugh";

pin out float vel;
pin out unsigned st;
pin out float timer;

;;

FUNCTION(_){
    //static int st = 0;
    static int last_counts;
    static double last_timer;
    //static double timer;
    //double vel;
    
    timer += fperiod;
    if (last_counts != encoder_counts){
        vel = abs(last_counts - encoder_counts) / timer;
        last_timer = timer;
        last_counts = encoder_counts;
        timer = 0;
    }
    else
    {
        vel = 1/(last_timer + timer);
    }
    
    switch (st){
        case 0: // spindle stopped, release allowed
            if (vel > encoder_vel) {
                st = 1; 
                break;
            }
            if (release_request){
                st = 2;
                break;
            }
            release_out = ! release_state;
            spindle_speed_out = spindle_speed_in;
            release_allowed = 1;
            break;
        case 1: // spindle moving
            // This state deliberately never changes the release-out pin
            if (vel <= encoder_vel){
                st = 0;
                break;
            }
            spindle_speed_out = spindle_speed_in;
            release_allowed = 0;
            break;
        case 2: // spindle released
            if (! release_request ) {
                release_out = ! release_state;
                st = 0;
                break;
            }
            release_out = release_state;
            spindle_speed_out = 0;
    }
}
The following user(s) said Thank You: JohnnyCNC, JetForMe

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

More
23 Jun 2019 15:05 #137656 by pl7i92
as you see yu can have it multiple way
and the plasma will just firer if no airpresure nothing else nothing to material or plasma itself
it just gives a silent ping
and the arc-ok will stop the motion

most plasmas got a safty cycle so it will shut down system at 2-4sec no flame generated

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

More
23 Jun 2019 21:24 #137673 by rodw

as you see yu can have it multiple way
and the plasma will just firer if no airpresure nothing else nothing to material or plasma itself
it just gives a silent ping
and the arc-ok will stop the motion

most plasmas got a safty cycle so it will shut down system at 2-4sec no flame generated


Except he's building a router. Plasmas's don't have drawbars

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

More
24 Jun 2019 20:16 #137751 by JetForMe
Outstanding, lots of good stuff in this thread. Thank you all!
The following user(s) said Thank You: rodw

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

More
25 Jun 2019 03:58 #137774 by cmorley
linuxcnc.org/docs/2.7/html/config/core-c...html#sec:motion-pins

motion.feed-inhibit
motion.spindle-inhibit

might be useful to you too.

Chris M

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

Time to create page: 0.095 seconds
Powered by Kunena Forum