M_RunCode(n) Lines inserted in .src when importing cnc code- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: General questions about RoboDK (//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK) +--- Thread: M_RunCode(n) Lines inserted in .src when importing cnc code (/Thread-M-RunCode-n-Lines-inserted-in-src-when-importing-cnc-code) |
M_RunCode(n) Lines inserted in .src when importing cnc code-JeffNickel-04-10-2020 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 RE: M_RunCode(n) Lines inserted in .src when importing cnc code-Jeremy-04-10-2020 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-code-reference-list-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 Depending on how you integrated the spindle to your robot, it can be as simple as putting adigital outputto1or0. Have a great day. Jeremy RE: M_RunCode(n) Lines inserted in .src when importing cnc code-JeffNickel-04-13-2020 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 RE: M_RunCode(n) Lines inserted in .src when importing cnc code-JeffNickel-04-13-2020 Thanks, Almost there, Jeff RE: M_RunCode(n) Lines inserted in .src when importing cnc code-robo1973-06-18-2022 [attachment=3476] (04-13-2020, 05:33 PM)JeffNickel Wrote: Thanks,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 做什么需要to be done to start the spindle. Elseif Param = 5 then 做什么需要to be done to stop the spindle. Elseif (...) |