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:
40  M_RunCode(5
41  M_RunCode(0)
42  M_RunCode(3)

and these two appear at the very end:
16554 M_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, M03 and M05 are 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 a digital output to 1 or 0.


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 (...)
#6
Hello, 

I'm in the same situation.

I’m using a Kuka IIWA for 3D printing and I want to translate an M_RunCode, but I don’t understand where and how to use the code.

For exemple, in my Gcode, when I have "M999", I want that the postprocessor write "blablabla" in my java program and when i've other "M", I want an other code.

I've try to modify the RunCode of Kuka IIWA PostProcessor as explain here (https://robodk.com/forum/Thread-Using-M-...ction+call) but it doesn't' work.

Can you help me please ?
#7
How did you try to customize your KUKA post processor? If you can provide the RDK project file and post processor edits we can better help you.

You can find some examples showing how to customize post processors here:
https://robodk.com/doc/en/Post-Processor...SamplePost
  




Users browsing this thread:
1 Guest(s)