Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
M_RunCode(n) Lines inserted in .src when importing cnc code
#1
When I import a cnc .nc file the generated program consistently has 5 lines that cause a compile error when copied onto my Kuka KR C4 8.3 controller.

These three appear early in the code:
40M_RunCode(5
41M_RunCode(0)
42 M_RunCode(3)

and these two appear at the very end:
16554M_RunCode(5)
16554 M_RunCode(2)
END



Once these 5 lines are deleted the code compiles and runs fine. How can I rectify this issue?

Thanks.

I looked into the gcode I'm importing and it contains 5 matching lines:

M05
M0 ;T102
M03S10000

and

M05
M02

It must be these causing the problem. Is my program suffering without these 5 lines?

Jeff
#2
Hi Jeff,

That depends on what these M codes actually do.
I took a look real quick on google and I found this list:
https://www.cnccookbook.com/g-code-m-cod...cnc-mills/

So, in your case,M03andM05are quite important as they pretty much mean "Spindle On" and "Spindle Off".

The "M_RunCode"s in the .src files come from the "Robot Machining Project" you created in RoboDK.
If you open the "Program Events", you will find it in the "Left column".

So you can fix the situation in two different ways.
If you don't need them, you can simply delete the content of the "Call M code" text box.

If you need them, and this is part of the "integration" side of your project, you need to create a subroutine in the robot controller named "M_RunCode".
RoboDK will call this subroutine every time it sees an "M code" in the machining program.
RoboDK will transfer the value (number) of the M code as a parameter of the "M_RunCode" subroutine. (ex : M05 becomes M_RunCode(5))
In the subroutine, you create a series of "If" statement that looks a bit like that:
Quote:If Param = 3 then
Do what needs to be done to start the spindle.
Elseif Param = 5 then
Do what needs to be done to stop the spindle.
Elseif (...)

Endif

Depending on how you integrated the spindle to your robot, it can be as simple as putting adigital outputto1or0.


Have a great day.
Jeremy
#3
Hi Jeremy,
Thank you, I like your subroutine idea. I'll create one to handle all of my I/O issues. I make most of the tools we need so mapping I/O lines to M codes will work fine.

Thank you.
Jeff
#4
Thanks,
Almost there,
Jeff
#5

(04-13-2020, 05:33 PM)JeffNickel Wrote: Thanks,
Almost there,
Jeff
Hi !! I don't really understand how to create M_RunCode in a robot?
What should the M_RunCode instruction take?
I want to run
M_RunCode (107)
M_RunCode (104)
generated by the postprocessor

Where to enter?
If Param = 3 then
Do what needs to be done to start the spindle.
Elseif Param = 5 then
Do what needs to be done to stop the spindle. Elseif (...)




Users browsing this thread:
1 Guest(s)