KUKA 6-axis (position) to PLC

  • Hi all. I am new to this group looking for help and aim to learn more.


    I am currently using kuka robot KR3, with CPU (computer) KRC3 (windows 95) and monitor(HMI/control panel) KRC3. I am using the Siemens PLC s7-1200 that is connected with KUKA with profibus (cm 12435). There is already the communication between the PLC and the Robot. For now I am using PLC to just to give command which mean there is start,stop and emergency button controlled with PLC programmed in TIA portal v13.


    The robot is just doing pick and place function for this moment. Now my big desire is to send the at least 6 Axis (real axis when the robort is moving) to the plc. I can see the real axis(A1 to A6) and other axis at real time in the control panel of kuka. But I want those axis to be sent to PLC mab be with some outputs or any way. I already spent alot of time but I am not able to even know the i/o of those axis or position. I can access to pmfbs.ini or iosys.ini but I have no knowledge what to change there?


    Can you please give detail information step wise how can I at least send the 6 axis to the PLC? I can log in to expert mode too. Is it easy to send axis to PLC or do i need to write again complex program? Hope to get some help.
    Thank you very much in advance.
    Sincerely
    SUdan

  • AD
  • What do you mean by "real axis when the robort is moving"? Do you mean when it starts or when §pos_act is reached?
    You can use $AXIS_ACT to get the current/actual position of the robot in Axis-specific. You can declare a axis-specific variable and assign $AXIS_ACT it when you need to fetch those values for PLC. You can then copy each axis value axis-specific variable into six different real variables in order to transfer each to PLC.

  • Yes, I mean all the six angles (in the degree) when the robot is moving. Can you please tell me how can I use $Axis_ACT ? And where and how can i declare axis-specific variables and assign $axis_act? Sorry to ask but i really have no idea how to assign variables to angles(6 Axis) or use $axis_act?


    And thank you very much for the answer.

  • in .dat file declare your varables, say:
    DECL GLOBAL E6AXIS AxesTemp={A1 0.0,A2 0.0,A3 0.0,A4 0.0,A5 0.0,A6 0.0,E1 0.0,E2 0.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0}
    DECL REAL Axis1
    .....
    .....
    DECL REAL Axis6


    In .src file:
    AxesTemp= $AXIS_ACT ; Actual axes values are copied into AxesTemp where you need them, then
    Axis1=AxesTemp.A1 ; Each axis is copied into real variables
    .........
    ........
    Axis6=AxesTemp.A6


    Now you will have each value for each axis in real variables. They can then be transferred to PLC as output signals, for example:
    GLOBAL SIGNAL Axis1$OUT[1] TO $OUT[32] ;axis 1 value


    There may be other better ways to do, but you can give this a go. Good luck

    Edited once, last by davidina ().

  • Thank you very much for the help. It really like like working concepts :coeuranime:


    I am going to try this out. But can i again ask few questions? For the declaring variables, you mention .dat but is it configure.dat or which .dat file? Is it the the .dat of the file that i have programeed for pick and place option? Can you please tell me which exactly?


    And again same question for .src? which .src file? DO i have to make new?
    And lastly where (which file)I can declare those global signal (real variables) to send to PLC.


    Thank u so so much :)

  • You only need to include those in your .dat and .src files you have already for your pick and place. The real variables are just for fetching the actual positions.
    When you declare those variables as global you can use them in the .sub file directly for parallel execution.
    You need to create those output signals the same way you did with other Robot<-->PLC signals before. I have only given you that signal range as an example. You must also map them in the in the configuration with the Profinet or other method you use.

  • Thank you for the reply
    I tried to declare Global variables in so many place like .dat and in.src and even in config.daT BUT I AM NOT able to declare. I tried to picture here but it didnot allowed me.
    Declaring realaxis in .dat is ok and $axis_act in .src is also ok , no compiling error. But when i tried to declare global in .src or in .dat , of my pick and place program there is compiling error saying "illegal or unknown block".


    Can u please tell me where can i declare the GLOBAL SIGNAL Axis1 $OUT[1] TO $OUT [32] . Why is that error?


    Thank u :coeuranime:

    Edited once, last by sudan ().

  • 1. GLOBAL variables can only be declared in DAT files. It is not legal in SRC files.


    2. DAT file must be set PUBLIC to make GLOBAL declarations legal.


    3. What KSS version is your KR3 Running?


    4. If you want realtime feedback of $AXIS_ACT, you will need to place your executable code into SPS.SUB


    5. SIGNAL declarations are used to create "group" I/O signals that convert between binary numbers and their Integer equivalents


    6. You will need to convert your $AXIS_ACT values into Integer equivalents before trying to send them. Usually this can be done by multiplying by 100 before sending, then dividing by 100 at the receiving end.


    So, a simple example: In $CONFIG.DAT:

    Code
    SIGNAL Axis1 $OUT[1] TO $OUT[32] ; 32-bit output integer
    SIGNAL Axis2 $OUT[33] TO $OUT[64] ; 32-bit output integer
    ; insert signals for Axes 3-6 here


    In SPS.SUB, between the LOOP and ENDLOOP lines, add:

    Code
    Axis1 = $AXIS_ACT.A1 * 1000 ; gives 0.001deg resolution on the transmission
    Axis2 = $AXIS_ACT.A2 * 1000 ; 
    ; add lines for A3-A6 here


    You may need to ensure that your IOSYS.INI and PFBMS.INI allocate enough bytes for 6*32=192bits. Or, if you don't need such high resolution, reducing to 16-bit signals would probably be sufficient.

  • Hi SkyeFire and hermann, Thank you for the information :coeuranime:. Will you help me to find answer of more questions? I don't know exactly kss version but it is KRC V4.1.5 and KSV: V4.74


    Can you please tell me how to make the .dat file public as i need to make global variables? Yes i need the realtime feed back, So will you please tell me, which part of executable code do i need to put in sps.sub? The full code .src of my pick and place program? or declaration from .dat? and between which lines in .sub should i keep my executable codes?


    And i have made signal deceleration like u showed in .dat file of my own code not in $config.dat, is it ok? or can I declare signal in both place or only in .dat of my program? and when i used global in front of signal there was error. How can those signal be global?


    And thank you for the example of codes, i will convert my $AXIS_ACT value like you showed. But my one question is , in the above post davidina told " AxisA1=AxesTemp.A1 ; Each axis is copied into real variables" and i did same. Still do i need to do like u told, in sps.sub?


    Sorry for long text and thank u for answer :)

    Edited once, last by sudan ().


  • Can you please tell me how to make the .dat file public as i need to make global variables?


    example:

    Code
    DEFDAT  myDatFile PUBLIC
    
    
    ;Everything in the file here
    
    
    ENDDAT



    So will you please tell me, which part of executable code do i need to put in sps.sub? The full code .src of my pick and place program? or declaration from .dat? and between which lines in .sub should i keep my executable codes?


    You can not put all your code in .src in sps.sub. Only the relevant "fragment" for sending the values to PLC in real time are necessary. Please note that sps.sub runs parallel with robot program and it is independent. You can make the conversion of real to integer in the sps.sub, for example


    And i have made signal deceleration like u showed in .dat file of my own code not in $config.dat, is it ok? or can I declare signal in both place or only in .dat of my program? and when i used global in front of signal there was error. How can those signal be global?


    You can not declare a signal in both places. In any of the cases it should work if properly declared. If your DAT file is declared as public as shown you will no more have problems declaring global variables in it.


    1. Declare variables global in DAT file
    2. Assign to those variables the current values of $AXIS_ACT in sps.sub
    3. Do the conversion in sps.sub as SkyeFire illustrated.
    4. Declare those signal range in Config.dat
    5. Do the proper I/O mapping in the configuration
    6. Make the conversion in the PLC program as you want.
    7. Check all over again for possible errors.


    Good luck

  • Hi davidina. Thank u once again for your kind and helpful information.
    I tried to make .dat file PUBLIC but it gave me error saying " DEFDAT trial1 PUBLIC, DEFDAT inadmissible". Its error 2042. I trioed to look to error manual but that was not helpful. Then When I finished typing DEFDAT myDatFile PUBLIC , I could not find those lines in my .dat file. IT is automatically hidden. How can i get rid of this problem. Then i go to error list and try to modify the line I cannot see those line "DEFDAT myFilename PUBLIC"


    can u please tell me Why is that error and why is it hidden? And in myDAt file I should keep my own file name yes example like DEFDAT trial1 PUBLIC?


    :help:

    Edited once, last by sudan ().

  • KSS version 4.1.7 may pre-date the implementation of GLOBAL declarations. Probably the simplest approach is to declare whatever variables you need "globalized" in $CONFIG.DAT, without the GLOBAL keyword.


    Long story short, on older KSS versions the only way to make global variables was to declare them in $CONFIG.DAT. Any variable declared in that file is global by default. The addition of the Public DAT file and GLOBAL declarations was added later, but $CONFIG.DAT's original features remained, for backwards compatibility.

  • Thank you
    I managed to make the variables global in .dat
    I want to configure signal in $confg.dat but i cannot edit the file. There is message saying "the file is linked and opened read only"


    So can u please tell me how can edit $config.dat and sps.sub? I am already in expert mode but still i can view those file not edit.


    THank u :)

  • Hello every one Thank you for all the information and time . I really appreciate :headball:



    I declared global real axis (for all a1 to A6 6 angles) in .dat file.
    DECL GLOBAL E6AXIS AxesTemp={A1 0.0,A2 0.0,A3 0.0,A4 0.0,A5 0.0,A6 0.0,E1 0.0,E2 0.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0}
    DECL global REAL Axis1
    .....
    .....
    DECL global REAL Axis6


    ALso wrote the In .src file:
    AxesTemp= $AXIS_ACT ; Actual axes values are copied into AxesTemp where you need them, then
    Axis1=AxesTemp.A1 ; to Axis6


    then declared signal in $config.dat
    SIGNAL Axis1 $OUT[102] TO $OUT[133] ; 32-bit output integer
    SIGNAL Axis2 $OUT[134] TO $OUT[165] ; 32-bit output integer
    ; same for all till $OUT[293]


    I also wrote executable code need to be sent to PLC in SPS.Sub
    Axis1 = $AXIS_ACT.A1 * 1000 ; gives 0.001deg resolution on the transmission
    Axis2 = $AXIS_ACT.A2 * 1000 ;
    ; addfor all 6 angles



    Now if there is any way to see if i did every things correctly?? Well of course there is not compiling error. I can run the robot. How I can see these bits into plc (Simen)? Yes there is connection already via profibus. What is my next step to see the all six angles of robot in PLC while the robot is moving?

  • Have you done I/O Mapping before? This must be done before you can get any values from Robot in the PLC. If you are not familiar with this there so many topics related to this in this forum. It is no more allowed to post kuka materials on the forum but if you have, I would recommend to also check the kuka manual about the steps to make the mapping.

  • You can check what the robot is sending by pulling up Axis1 (or 2, or 3, or...) in the Variable Monitor, and also by observing the $OUTs in the I/O monitor. As for whether this information travels across the ProfiBus to the PLC, that depends on your IOSYS mapping.


    As long as $OUT 102-293 are already mapped to the PLC, you should only need to create some 32-bit input-word blocks in the PLC mapped to the correct Integer inputs (and then divide by 1000 to restore the decimal point).

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now