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. Fanuc 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

Types of IF Instructions

  • Raltru
  • July 22, 2019 at 10:09 PM
  • Thread is Resolved
  • Raltru
    Trophies
    3
    Posts
    40
    • July 22, 2019 at 10:09 PM
    • #1

    I have programmed some types of robot controllers.

    I noticed few of them, including of same controller model, are there ways of write them differents than other.

    I want to know why and if there is any way to change the form of predefined in IF/Select menu.

    Thanks to all readers.

  • Go to Best Answer
  • BOTTECH
    Reactions Received
    9
    Trophies
    3
    Posts
    109
    • July 22, 2019 at 10:20 PM
    • #2

    I'm unsure of what you mean, do you mean your conditions that you pass in the IF statement or something different?

    i.e. IF DI[1] (IF statement with IO condition)
    IF F[1] (IF statement with Flag condition)

  • scotty
    Reactions Received
    43
    Trophies
    5
    Posts
    497
    • July 22, 2019 at 11:54 PM
    • #3

    Fanuc robot controllers with version 7.7 and under have next syntax:

    Code
    IF (condition), decision(jump/call)


    Everything that you can find above 8.* you have choice to use old style if logic or you can do regular for everybody

    Code
    IF (condition) THEN
    !do smth
    (optional)ELSE
    (optional) !do else logic
    ENDIF
  • Raltru
    Trophies
    3
    Posts
    40
    • July 25, 2019 at 2:03 PM
    • #4
    Quote from BOTTECH


    I'm unsure of what you mean, do you mean your conditions that you pass in the IF statement or something different?

    i.e. IF DI[1] (IF statement with IO condition)
    IF F[1] (IF statement with Flag condition)

    I am writing my memory, I cant now write real examples.

    For example I can in few robots use IF DI[1]=ON, DO[2]=ON but in other I have to do it with Jump Label/Call

    Quote

    IF DI[1]=ON, JUMP LBL[1]
    ...
    ...
    LBL[1]
    DO[2]=ON

    Quote from scotty


    Fanuc robot controllers with version 7.7 and under have next syntax:

    Code
    IF (condition), decision(jump/call)


    Everything that you can find above 8.* you have choice to use old style if logic or you can do regular for everybody

    Code
    IF (condition) THEN
    !do smth
    (optional)ELSE
    (optional) !do else logic
    ENDIF

    So, only is version of robot??

    There is any way to add/change the predefined kind of IFs?

    Thanks all guys =) :top: :top:

  • RobotCoder
    Reactions Received
    5
    Trophies
    4
    Posts
    39
    • July 31, 2019 at 5:28 AM
    • #5

    You're probably referring to mixed logic which is much more versatile.
    IF (...) vs IF ...=...

    It incorporates ...=(...) and ...=PULSE

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,760
    • October 10, 2019 at 3:04 PM
    • #6

    I think my issue is related to this thread...…..

    I have been programming using Roboguide using a Controller with:

    V8.30P/48

    I have written many subroutines which use the syntax:

    IF...……...THEN.....ELSE.....ENDIF

    I have just been provided a backup from another system, opened it up in Roboguide and that version is:

    V8.20P/31

    I have found none of my programs that contain the IF.....THEN......ELSE......ENDIF syntax will load into it...……:wallbash:

    An example below:

    Code
      20:  IF (F[10:Pallet 1 Ready]=(ON) AND F[18:Pallet 1 Unload]=(OFF)) THEN ;
      21:  R[7:Target Pallet No]=1    ;
      22:  F[14:Pallet 1 In use]=(ON) ;
      23:  JMP LBL[2] ;
      24:  ENDIF ;

    Is there anything I can do about this in terms of being able to use my pre-written subroutines?

    Any assistance with this would be very much appreciated, as this leaves me with a hell of a lot of work to do otherwise?

    On another note, I have to express my disappointment with Fanuc Products if this results in me having to re-write my code.

    I sincerely hope this is down to myself making errors and not the product itself, as this is not good at all...…………:censored:

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • HawkME
    Reactions Received
    567
    Trophies
    10
    Posts
    3,268
    • October 10, 2019 at 3:37 PM
    • Best Answer
    • #7

    It looks like the IF-Then-Endif statement was not introduced until v8.3.

    I think you will either need to re-write your code or update the robot software. If you update the robot software you will want to make sure you take an image backup before in case something goes wrong with the update.

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,760
    • October 10, 2019 at 4:40 PM
    • #8

    Ooooh Man.....I really wished you had a golden nugget you could hand me...………..:computerhit:

    Fanuc was edging Kawasaki in many areas and this has just swung the vote to Kawasaki.

    With this archaic syntax now will have me bouncing around programs like a monkey on a bungee.

    Still, if that's how it is, I just need to now run out of tears so I can see clearly enough to mod away...…..:bawling:

    I suppose it'll be a question of whether to upgrade software just for this purpose.....I'll have to at least ask the question.

    Does Fanuc charge for upgrade of software (I don't know whether I can hear you laughing at me for asking this)?

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • jay
    Reactions Received
    25
    Trophies
    3
    Posts
    82
    • October 10, 2019 at 4:50 PM
    • #9

    To be fair, both FANUC's TP and KAREL programming languages have been extremely stable for decades, especially in a forward-compatible direction (i.e. code written in 1999 will probably work on an R-30iB+ controller).

    It is a bit baffling that IF-THEN-ELSE controller structures weren't supported until R-30iB, but I'm glad we finally have them. It's too bad you happened to be on v8.20 and not v8.30 :loudly_crying_face:

    ONE Robotics Company

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,760
    • October 10, 2019 at 5:01 PM
    • #10

    Baffling for sure...….and there is probably a good reason behind it too embedded in the realms of some boffins logic who gets paid a hell of a lot more than me.....Not that I'm bitter at all...Heehee

    Still, glad I've found a 'breakpoint' between these versions early doors.....it's not a job stopper, just what I call one of those 'buggeration' factors that appear small, but carry a nasty nip.

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • HawkME
    Reactions Received
    567
    Trophies
    10
    Posts
    3,268
    • October 10, 2019 at 5:14 PM
    • #11

    If you have a login to the Fanuc CRC then you can get the auto-update software for free. You would want to download the latest version of version 8 software which is: V8.30P/52 AUTO Update.

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,760
    • October 10, 2019 at 5:19 PM
    • #12

    The strange thing is, this system has just been installed and the existing systems (hence the reason I had a backup of one) are on later versions to this.

    I shall explore this now as a viable option as it would be better to at least have some continuity throughout regarding software levels.

    HawkME

    Many thanks for that, much appreciated.....that's half a golden nugget at least...……….:top:

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • kwakisaki
    Reactions Received
    694
    Trophies
    11
    Posts
    4,760
    • October 24, 2019 at 7:18 PM
    • #13
    Quote

    if you have a login to the Fanuc CRC then you can get the auto-update software for free. You would want to download the latest version of version 8 software which is: V8.30P/52 AUTO Update.

    Unfortunately it's not as simple as that...…………..I'm in the UK and Fanuc's policy regarding software here is soooooo restricted indeed.

    No option of you doing any option install or software upgrade yourself, you have to provide an image to them and they do the work for you.

    And yes, everything you have to pay for, even for a software update from 8.20 to 8.30.

    To be honest, I'm really hacked off with their approach regarding software options and updates, I wish I was in the USA sometimes.

    I'm in the process of trying to source alternative solutions...…..do you know if Fanuc US will deal outside of their region?

    I'm going to find out I think anyway...………….

    View my channel at Industrial Robotics Consultancy Limited - YouTube

  • Robot Programmer
    Reactions Received
    5
    Trophies
    3
    Posts
    26
    • October 25, 2019 at 2:41 PM
    • #14

    When I call Fanuc tech support it is either $500 or $2000 to do what I'm asking about.

    I recently had a EOAT that required 5 32bit floating point parameters over Profi-Net. I asked if there was some kind of translating subroutine as the robot has a 16bit Motorola processor. They sent me a .pdf for mapping global data. (no mention of converting the data). Fortunately the PLC programmer on the job took the communications for the EOAT and we handshaked the IO for me to control it.

  • ashley
    Reactions Received
    1
    Posts
    39
    • October 15, 2024 at 2:31 PM
    • #15

    hello I'm reopening this subject about the IF fonction.
    I'm new to fanuc and I have some experience on Staubli robotic.
    The programming section is , as you might expect, a lot different from fanuc.

    I've 2 questions about the IF section :

    I didn't find much about the classic IF ...... ELSIF fonction. If you have plenty of statements you usually goes for the elsif fonction to process faster.

    Example:

    If Instruction = 1 THEN
    do task 1
    ElsIf Instruction = 2 THEN
    do task 2
    ElsIf Instruction = 3 THEN
    do task 3
    ElsIf Instruction = 4 THEN
    do task 4
    Else THEN
    do Nothing
    EndIf

    The Elsif fonction doesn't seem to exist.
    If saw they used the SELECT fonction that seems to works similar (If I understood correctly) but It only work on register when I need to use AI instead. Should I mapped this AI into a register and use the SELECT fonction that act as ELSIF ?

    Another question on the LBL / JUMP LABEL fonction that I clearly do not understand the purpose.

    Why not simply writing the code of the section needed

    Exemple :

    If Instruction = 1 THEN
    JMP LBL[1]
    END_IF

    If Instruction = 2 THEN
    JMP LBL[2]
    END_IF

    If Instruction = 3 THEN
    JMP LBL[3]
    END_IF

    LBL[1]
    J P[1] 100% CNT50

    LBL[2]
    J P[2] 100% CNT50

    LBL[3]
    J P[3] 100% CNT50

    Could be written as follow :
    If Instruction = 1 THEN
    J P[1] 100% CNT50
    ENDIF
    ElsIf Instruction = 2 THEN
    J P[2] 100% CNT50
    ENDIF
    If Instruction = 3 THEN
    J P[3] 100% CNT50
    EndIf

    Maybe In case you need to JMP into a Label twice inside a program but I guess It usually never happen.

    Thank in advance

  • pdl
    Reactions Received
    266
    Trophies
    9
    Posts
    1,504
    • October 15, 2024 at 6:25 PM
    • #16

    The IF/THEN/ELSE instructions were not available on Fanuc controllers until late into version 8 (R30iB). This is why Fanuc programmers were forced to use JMP LBL's instead of IF/THEN/ELSE. As you pointed out, it can make for some real spaghetti code.

    This may also be why you don't have the ELSE instruction. What version of software are you running?

  • PnsStarter
    Reactions Received
    90
    Trophies
    6
    Posts
    325
    • October 15, 2024 at 8:53 PM
    • #17

    Hi ashley,

    as pdl wrote.

    And:

    ELSIF is not available.

    But:

    you said you're using AI , so i would recommend SELECT:

    Code
    :  R[1]=AI[1]    ;
    :  SELECT R[1]=0,CALL TEST ;
    :         =1,CALL TEST(35) ;
    ...
    ...
    :         =4,CALL TEST4(3) ;
    :       ELSE,CALL TEST_ABC(2) ;

    Backdate/TP-Tools: A small collection of tools that simplify the commissioning and programming of Fanuc robots. (github.com)

  • ashley
    Reactions Received
    1
    Posts
    39
    • October 16, 2024 at 1:47 PM
    • #18

    thank you a lot for your response, I'm using the version 8.3.

    I understand now why the JUMP LBL fonction must be added then :smiling_face:

    fanuc should try to implement the elsif fonction , it might reduced the number of line of code.

    I will use the SELECT Fonction then, I'm assuming the programme automatically skip to the end on the SELECT fonction once it reach one of the condition (like a switch case fonction)

  • Online
    DS186
    Reactions Received
    198
    Trophies
    6
    Posts
    1,048
    • October 16, 2024 at 5:10 PM
    • #19
    Quote from ashley

    I will use the SELECT Fonction then, I'm assuming the programme automatically skip to the end on the SELECT fonction once it reach one of the condition (like a switch case fonction)

    That ist correct. SELECT is the same as SWITCH (e.g. KUKA) and TEST (e.g. ABB).

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

Users Viewing This Thread

  • 1 Guest
  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