1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. KUKA Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

Loop through Z heigths

  • KevinS94
  • March 23, 2023 at 11:02 PM
  • Thread is Unresolved
  • KevinS94
    Reactions Received
    1
    Trophies
    1
    Posts
    3
    • March 23, 2023 at 11:02 PM
    • #1

    Hi,

    To reduce the program size, I want to use a While loop to Loop through my program and change the Z value every time.

    The following code (only relevant lines) is wrong, I cant use the variable Zax in my positions, how to fix this?

    ____________________________

    DEF JIHAAA3()


    DECL INT Zax

    Zax=2

    LIN {X 400.000,Y 850.000,Z 207.000,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


    LIN {X 500.000,Y 850.000,Z 8.000,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


    $VEL.CP=0.0099


    WHILE Zax < 200


       LIN {X 500.000,Y 850.000,Z Zax, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 499.881,Y 845.131,Z Zax ,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 499.526,Y 840.274,Z Zax ,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 498.934,Y 835.440,Z Zax ,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 498.108,Y 830.640,Z Zax, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 497.049,Y 825.887,Z Zax, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 495.760,Y 821.190,Z Zax, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS


       LIN {X 494.244,Y 816.562,Z Zax, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS

    ENDWHILE
    END


    Thanks!

  • kwakisaki March 23, 2023 at 11:37 PM

    Approved the thread.
  • Shellmer
    Reactions Received
    52
    Trophies
    5
    Posts
    161
    • March 24, 2023 at 3:51 AM
    • #2

    I'm a bit rusty on Kuka... but maybe if you declare that 8 points globally, you can then edit the Z coordinate of all points before performing the movement.

    Not inside the point itself, but overwritting the Z value of every position before executing the movement.

    Putting a variable inside the declaration of the local point will likelly result on a syntax error, also you are not incrementing zAx so that loop will run forever.

    You should be able to access data on the point by putting $xPointName1.x or something similar, like when you access the variables through the smartpad.

  • Online
    panic mode
    Reactions Received
    1,293
    Trophies
    11
    Posts
    13,122
    • March 24, 2023 at 1:51 PM
    • #3

    you need to lookup differences between variable, constant and literal.

    inside aggregate only literals are acceptable.

    also you have other issues there:

    there is no motion parameter initialization.

    there is no initial PTP motion for BCO

    your Z value in the loop is not changed at all - even if the variable was accepted, point value would not change etc.

    this is one way to cure some of those problems. this is tailored to match your attempt.

    the other way is to leave points as they are and manipulate base.

    Code
    DEF JIHAAA3()
    DECL POS P1,P2,P3,P4,P5,P6,P7,P8
    DECL INT Zax
    DECL REAL ZaxStep
    
    P1= {X 500.000,Y 850.000,Z 1000, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P2= {X 499.881,Y 845.131,Z 1000 ,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P3= {X 499.526,Y 840.274,Z 1000 ,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P4= {X 498.934,Y 835.440,Z 1000 ,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P5= {X 498.108,Y 830.640,Z 1000, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P6= {X 497.049,Y 825.887,Z 1000, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P7= {X 495.760,Y 821.190,Z 1000, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    P8= {X 494.244,Y 816.562,Z 1000, A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} 
    
    IF $MOVE_BCO THEN
      BAS(#INITMOV,0)
    ENDIF
    
    LIN {X 400.000,Y 850.000,Z 207.000,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS
    LIN {X 500.000,Y 850.000,Z 8.000,A -90.001,B 0.000,C 0.000,S 6,T 27,E1 0.000,E2 0.000,E3 0.000,E4 0.000,E5 0.000,E6 0.000} C_DIS
    
    $VEL.CP=0.0099
    
    Zax=0
    ZaxStep=2.0
    WHILE Zax < 200
       Zax=Zax+ZaxStep ; Z value is incremented
       
       P1.Z=P1.Z+ZaxStep   ; then it is applied to points
       P2.Z=P2.Z+ZaxStep 
       P3.Z=P3.Z+ZaxStep 
       P4.Z=P4.Z+ZaxStep 
       P5.Z=P5.Z+ZaxStep 
       P6.Z=P6.Z+ZaxStep 
       P7.Z=P7.Z+ZaxStep 
       P8.Z=P8.Z+ZaxStep 
       
       LIN P1 C_DIS ; then program is using those points
       LIN P2 C_DIS
       LIN P3 C_DIS
       LIN P4 C_DIS
       LIN P5 C_DIS
       LIN P6 C_DIS
       LIN P7 C_DIS
       LIN P8 C_DIS
    
    ENDWHILE
    END
    Display More

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Online
    SkyeFire
    Reactions Received
    1,059
    Trophies
    12
    Posts
    9,450
    • March 24, 2023 at 4:28 PM
    • #4

    I would recommend creating a Base that has its Z axis aligned the way you wish to offset your paths, and use that:

    Code
    DECL FRAME _fOffset
    DECL INT nIndex
    
    $BASE=BASE_DATA[1] ; original Base with no offsets
    FOR nIndex = 0 TO 10
        _fOffset = $NULLFRAME ; reset to all 0s
        _fOffset.Z = nIndex * 10 ; 10mm z-shift per pass
        $BASE = BASE_DATA[1] : _fOffset ; offset the Base frame
        PTP P1
        ;....
    ENDFOR
    Display More

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • KUKA
  • Print 3D
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download