how to implement a security switch launching a program / gcode

Moderators: TomKerekes, dynomotion

Jojo
Posts: 8
Joined: Fri Apr 27, 2018 6:34 am

Re: how to implement a security switch launching a program / gcode

Post by Jojo » Thu May 03, 2018 9:55 am

Hi Tom,

ok, I see, will skip the abbreviation in the future:-))

The frequency-converter that drives the spindle is connected to a power plug that I control with Bit 1. So if i do
ClearBit(1);
I physically remove the Spindle from electricity (dont know how to formulate, I basically "unplug" it).

The M5 command on the other hand does not shut down electricity on the spindle, but is the regular command in GCode to stop the spindle. In KmotionCNC this equivalent to hitting F11..

Kind regards,

Johannes

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: how to implement a security switch launching a program / gcode

Post by TomKerekes » Thu May 03, 2018 5:41 pm

Hi Johannes,

I think I understand that. But you still haven't told me how M3 and M5 turn the Spindle on and off if they do not use the Relay.

Look in the KMotionCNC | Tool Setup | M3 and M5. What Action is configured?
Regards,

Tom Kerekes
Dynomotion, Inc.

Jojo
Posts: 8
Joined: Fri Apr 27, 2018 6:34 am

Re: how to implement a security switch launching a program / gcode

Post by Jojo » Thu May 03, 2018 9:19 pm

Hi Tom,

M3 and m5 are configured to set bit 0 to 0 or 1 (pic attached),which is really weird, since this bit is supposed to switch electric power on a second 220V-plug, that I currently dont use (and where nothing is attached to); it does not have anything to do with the frequency converter..
M3_M5.png
I guess this is still a left-over of my initial trials..
Can it be that M3 and M5 (F9 and F11) have a double effect, so not only whats defined in the tool-setup, but also the "regular" gcode-meaning of the M-command?
http://linuxcnc.org/docs/html/gcode/m-c ... e:m3-m4-m5

The second pic shows that I implemented two button to set bit 1 to 0 or 1, and thats the bit driving the electric power for the frequency converter.
button_setup.png
and this one actually works; frequ.conv. can be turned on and of with this.

Kind regards,

Johannes

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: how to implement a security switch launching a program / gcode

Post by TomKerekes » Thu May 03, 2018 9:58 pm

Hi Johannes,

I'm not sure what you mean by "double effect" or "regular meaning". Yes M3 should turn on the Spindle but what could KMotionCNC possibly do besides what it has been told to do for M3? Yes the M3, Spindle On Button, and the F9 Hot Key should all do the configured M3 Action.

I don't see how the M3 and M5 commands could possibly work. Do they work?
Regards,

Tom Kerekes
Dynomotion, Inc.

Jojo
Posts: 8
Joined: Fri Apr 27, 2018 6:34 am

Re: how to implement a security switch launching a program / gcode

Post by Jojo » Sat May 05, 2018 10:29 pm

Hi Tom,

finally had access to the machine yesterday and was able to timplement the door switch and the new init-script.
First of all, thanks for all the help, it worked out pretty well:-)
And yes, I was totally confused about the M3, M5 command... As shown in my screenshot, I actually did really use bit 0 (relay) to switch the spindle on and off in the frequency converter! Aside from the PWM that sets the rpm.. So, I dont hav to use
DoPCInt(PC_COMM_MCODE,5); // command M5
(which would also work), but
ClearBit(0);
to stop the spindle (equivalent to M5).

All this works pretty well now!

However, I of course have one more question...
Once the dooropenbit is activated, the spindle stops and halts. The only issue I have now, is that the user can start the milling (and splindle) again while the door is still open.
So I guess what I need is a "simple" version of the

case StateDoorIsOpen:

of the very first code you suggested; basically another if-statement in the ServiceDoorMonitor function that checks if the dooropenbit is active and if so, prevents any motion or spindle spinup..

Will see if I can come up with something. Or in case you have a quick hint, I'd be very interested;)

Kind regards,

Johannes

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: how to implement a security switch launching a program / gcode

Post by TomKerekes » Sat May 05, 2018 11:23 pm

Hi Johannes,

That's good progress.

Here are some thoughts:

It might be better to prevent a Job from starting with the door open rather than trying to halt/kill it once it starts. I think you can configure a Cycle Start Action to check for the door open and if open Halt. Maybe even with a message box of "Please Close Door before running Job".

To prevent the Spindle from coming on: since it is a simple output bit you might just continuously clear the bit whenever the door is open.

Regards
Regards,

Tom Kerekes
Dynomotion, Inc.

gui_marchioro
Posts: 57
Joined: Sun Aug 21, 2022 11:22 pm

Re: how to implement a security switch launching a program / gcode

Post by gui_marchioro » Fri Nov 04, 2022 5:18 pm

Hello Tom,

I have implemented a similar routine, to prevent Cycle Start to execute if the board was not properly initialized or homed. It does work, but the G code execute in average 3 lines before Halt. There is a way to prevent this to happen?

Below is the code that I execute when Cycle Start is requested:

Code: Select all

// Program to be executed when the Cycle Start button is pressed
// DoPC(PC_COMM_EXECUTE);
void main()
{
    if (GetInitExecuted() == 0 || GetHomingExecuted() == 0 || GetIsExecutingHoming == 1)
    {
        DoPC(PC_COMM_HALT);
        MsgBox("Execute the Init and Homing function before run a program", MB_ICONEXCLAMATION);
        DoPC(PC_COMM_RESTART);
    }
}
Sincerely,
Guilherme

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: how to implement a security switch launching a program / gcode

Post by TomKerekes » Fri Nov 04, 2022 5:27 pm

Do you have the Cycle Start Action configured to wait?
Regards,

Tom Kerekes
Dynomotion, Inc.

gui_marchioro
Posts: 57
Joined: Sun Aug 21, 2022 11:22 pm

Re: how to implement a security switch launching a program / gcode

Post by gui_marchioro » Fri Nov 04, 2022 5:33 pm

No, I was using just the "Execute Prog" (image attached).
tool-setup.png
Is it required to use "Exec/wait" instead?

Sincerely,
Guilherme

User avatar
TomKerekes
Posts: 2529
Joined: Mon Dec 04, 2017 1:49 am

Re: how to implement a security switch launching a program / gcode

Post by TomKerekes » Fri Nov 04, 2022 5:58 pm

Yes
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply