Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program Event or Function Call for 3D Printing Extruder Control
Dear Community,

I'm trying to use RoboDK and a Kuka with KRC4 controller for 3D printing and I'm hoping to control both the Robot and the Extruder through RoboDK using the "Run on Robot" function.

My idea is to have three very similar function calls "SetRPM", "Extruder" and "MCode". SetRPM giving the F Value, Extruder the E Value of the G1 commands and MCode all the M commands of the G Code. The functions would then use TCP/IP over Ethernet to send these values as text string to a controller board for the extruder before sending the corresponding move to the robot and then continuing with the program.

I'm hoping that this way the error between the moves and extrusions is limited to one move at a time and therefore very small to avoid either the robot or extruder running faster than the other.
So far I have modified the post processor so it adds the lines SetRPM(ExtruderSpeed) and Extruder(PRINT_E_New) with the parameters in the brackets being the values for F and E. When I generate a program for the functions are being passed on to the robot program as you can see in the code example below at the end of the post.

My question is now, if I run this program through RoboDK on the robot can I use these lines to call functions or program events that will then send the corresponding code through a ethernet connection to the controlboard of the extruder? If so, do you know of any similar code snippets I could adapt the code from?

I have seen a lot of posts in the forum regarding 3D printing but none with this issue, is there perhaps a easier solution that I'm not aware of?

Best regards

LIN {X 301.500,Y 498.500,Z 15.000,A 180.000,B 0.000,C -180.000} C_DIS
$VEL.CP = 0.02500
LIN {X 301.500,Y 498.500,Z 15.000,A 180.000,B 0.000,C -180.000} C_DIS
$VEL.CP = 0.06000
LIN {X 301.500,Y 498.500,Z 0.300,A 180.000,B 0.000,C 180.000} C_DIS
$VEL.CP = 0.02500
LIN {X 301.500,Y 498.500,Z 0.300,A 180.000,B 0.000,C 180.000} C_DIS
$VEL.CP = 0.03000
LIN {X 301.500,Y 301.500,Z 0.300,A 180.000,B 0.000,C -180.000} C_DIS
Hi Patrick,

The post processor and the driver are different (having a working post processor does not mean the driver will work).

The best way to make this work with the driver is to trigger a program with a number. For example:
will pass the program id 73. However, this was designed to make it work for more simple calls (program ID). Example:
Program 1
This will pass the program_id number 1. You can pass a floating point number (32 bit precision, more information here).

Note that it is not possible to trigger programs by name using this method. You are also limited to 1 value. We can improve it to pass 2 or 3 values if you need.

Once you pass the program id (as an integer or a decimal value) you need to implement your actions in the driver (SRC file). I attached the sample implementation code and comments in the driver file.

;----- Run program COM_VALUE1 ---------
; (to trigger from RoboDK: use robot.RunCodeCustom("program id", INSTRUCTION_CALL_PROGRAM)
program_id = COM_VALUE1
SWITCH program_id
; -- run program 1 --
; Drill()
; -------------------
; -- run program 2 --
; Cut()
; -------------------

Hi Albert,

thank you for the reply this actually helps a lot! I've been trying to modify the scripts in RDK and the Postprocessor when what I needed was the Robot driver. I looked in the directory where the drivers are and found that the kuka driver "apikuka" is a .exe file that i can't modify but there is a 
From a quick look it seems that the driver is for a robot with 7 degrees of freedom, I'll try to get it working with our 6 DoF robot, but could you provide the apikuka.exe as .py file?

I would approach the problem by adding another elif like the one below:

   elif n_cmd_values >= nDOFs_MIN and cmd_line.startswith("MOVL"):
       # Activate the monitor feedback
       ROBOT_MOVING = True
       # Execute a linear move. RoboDK provides j1,j2,...,j6,j7,x,y,z,w,p,r
       if ROBOT.SendCmd(MSG_MOVEL, cmd_values):
           # Wait for command to be executed
           if ROBOT.recv_acknowledge():
               # Notify that we are done with this command

and change it so if the code starts with "Call Extruder" it establishes a connection by telnet to the extruder, sends the Gcode command and closes the connection.

Best regards
Hi Patrick,

After reading the second message I realized that you would like to communicate to the extruder using the computer (not the robot). Correct?

In this case the integration may be easier as you can program the socket communication protocol using Python. Otherwise, you may need to purchase KUKA Ethernet/XML option to do so with a KUKA KRC controller.

To react on a program call (such as Extruder) in a custom way you can create an Extruder script like the one attached. You can collect arguments using sys.argv as shown here:

E_Value = None
# Check if we are running this program inside another program and passing arguments
import sys
if len(sys.argv) > 1:
   E_Value = float(sys.argv[1])

Let me know if this is not what you are looking for.


Attached Files
.py (Size: 1.79 KB / Downloads: 19)
Albert that's brilliant! It works! You saved my day :D

I just noticed the attached file when I went to post this, I went with Telnet instead but the segment to quit if in Simulation mode is neat, I'll add that and post some details on the scripts I end up using once I'm through testing in case someone else has the same issues.

Thank you!
Hello PatrickC,

I am also trying to implement extrusion via a python script in RoboDK for online programming of our Fanuc 6 axis robot. Did you come up with a solution after all? Myself, I was trying to use the Printrun library (from the Pronterface project) to send some G-code commands over to the extruder, but I can't make it work.

Could you share some details about the scripts that you developped? Any help would be highly appreciated.

Thanks a lot!

Are you using a custom made extruder?

If so, I recommend you to just send raw strings or binary data to update the extruder speed. You can implement your own protocol to just send the necessary information to the extruder.
Hi Albert. I am using an Arduino controler with the Marlin Firmware to drive the extruder. I would like to interpret the RoboDK's Extruder( function to send my own G-code to the Marlin Firmware.

Users browsing this thread:
1 Guest(s)