Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Program Event or Function Call for 3D Printing Extruder Control
#1
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
Patrick


Code:
LIN {X 301.500,Y 498.500,Z 15.000,A 180.000,B 0.000,C -180.000} C_DIS
MCode(83)()
MCode(83)
$VEL.CP = 0.02500
SetRPM(0.000)
Extruder(-6.500)
LIN {X 301.500,Y 498.500,Z 15.000,A 180.000,B 0.000,C -180.000} C_DIS
MCode(107)()
MCode(107)
$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
SetRPM(6000.000)
Extruder(73.713)
LIN {X 301.500,Y 301.500,Z 0.300,A 180.000,B 0.000,C -180.000} C_DIS
#2
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:
Extruder(73)
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.

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


Albert
#3
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 apikukaiiwa.py. 
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:

Code:
   elif n_cmd_values >= nDOFs_MIN and cmd_line.startswith("MOVL"):
       UpdateStatus(ROBOTCOM_WORKING)
       # 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
               UpdateStatus(ROBOTCOM_READY)


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
Patrick
#4
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:

Code:
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.

Albert


Attached Files
.py   Extruder.py (Size: 1.79 KB / Downloads: 7)
#5
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!
  




Users browsing this thread:
1 Guest(s)