BGLOGIC code that I have found useful

  • Hello,

    Since Fanuc Doesn't have A TCP Position output. There is some Bglogic I found that Was able to Output real time TCP position.

    There are variables to monitor TCP speeds from the robot though brute force. By wright System Variables to group outputs. keep in mind the robot outputs in MM and can only send an max of one unsigned integer. so what I did was scaled it into CM via*10 and send it over. I ended up not using W.P.R. A small issue is, these values only update when a program is ran, not when being Jogged.

    (Although if you wanted to monitor these values and compare them to last time they were update, you can catch maintenance driving the robot around and trying to start it up in a different location :smiling_face:

    1: ;
    2: R[20:X POS OUT]=($SCR_GRP[1].$MCH_POS_X) ;
    3: R[21:Y POS OUT]=($SCR_GRP[1].$MCH_POS_Y) ;
    4: R[22:Z POS OUT]=($SCR_GRP[1].$MCH_POS_Z) ;
    5: R[23:W POS OUT]=($SCR_GRP[1].$MCH_POS_W) ;
    6: R[24:P POS OUT]=($SCR_GRP[1].$MCH_POS_P) ;
    7: R[25:R POS OUT]=($SCR_GRP[1].$MCH_POS_R) ;
    8: ;
    9: R[20:X POS OUT]=R[20:X POS OUT]*10 ;
    10: R[21:Y POS OUT]=R[21:Y POS OUT]*10 ;
    11: R[22:Z POS OUT]=R[22:Z POS OUT]*10 ;
    12: R[23:W POS OUT]=R[23:W POS OUT] ;
    13: R[24:P POS OUT]=R[24:P POS OUT] ;
    14: R[25:R POS OUT]=R[25:R POS OUT] ;
    15: ;
    16: ;
    17: GO[3]=R[20:X POS OUT] ;
    18: GO[4]=R[21:Y POS OUT] ;
    19: GO[5]=R[22:Z POS OUT] ;
    20: GO[6]=R[23:W POS OUT] ;
    21: GO[7]=R[24:P POS OUT] ;
    22: GO[8]=R[25:R POS OUT] ;

  • Place your Ad here!

  • Very useful post

    I wish to create a user alarm when a certain DI gets on but I am not able to write User alarm in BG logic as I am getting syntax error .
    Please help me guys I am a newbie and wish to learn

    Thanks in advance !!!!! :help:

    If di[1]=off jump lbl[1]

    and I have found this useful, you can use both a remote uop cycle start and the button on the controller.
    configure a DI it a Uop I cycle start then...
    IF (SI[6:Cycle start]),$REMOTE_CFG.$REMOTE_TYPE=(2)

    Edited once, last by dmbj ().

  • Much appreciated! Did not know where the variables where located!

  • Here is one that I've found useful.

    We use multiple consecutive RO's for tool changing, vacuum grippers, ionizers, etc. During development we manually force RO's to verify things. I wanted to make sure an operator could not accidentally drop a tool unless another action was performed first. Basically an interlock.

    An operator has to force DO[1]=ON before they can drop a tool using RO[1]=ON. As soon as RO[1] is turned back to OFF after it's been ON, DO[1] resets to OFF and has to be forced again to drop a tool.

    RO[1] is the tool change output (ON drops the tool)
    DO[1] is the Interlock
    DO[2] is a flag used to switch DO[1] OFF

    PS. If anyone looking at this knows of a way to streamline this (I'm definitely a beginner) please let me know.

  • ME andy,

    Looks good, I use a similar program for tool changers. I prefer to used the mixed logic statement instead of the if, then,end if, because it is less lines of code. Mixed logic is the: If (...). It works like this:

    If (!DO[1]), RO[1]=off
    If (RO[1]), DO[2]=on
    If (RO[1]!=DO[2]), DO[1]=off and DO[2]=off

    Same program in 3 lines instead of 10.

    Sent from my VS985 4G using Tapatalk

  • can bglogic be created without the use of roboguide. i'd like to create a program to reset the occasional chain fault without the operator having to handle the TP. R-J3, 430iW, control reliable, version 5.1 (i think).

    it would be nice if I could find a way to set $mcr$chain_fault to true without too much interface.

    any thoughts?

    "Everyone has the will to win, but precious few have the will to prepare to win"

  • hi
    you said "can bglogic be created without the use of roboguide. " what that a question ?
    Background logic and Roboguide are two different things.

    BGlogic is just a TP program (with some considerations), no more than that, you dont need Roboguide at all to program it

    Retired but still helping

  • I've tried to locate the bglogic with no success. I've read (MENU, SETUP, BGLOGIC) but i'm not seeing BGLOGIC as an option. we're quite versed in ladder and have an idea of what we'd like to do with this feature if we can find it. We'd really like a way for the operators to reset an occasional chain fault without having to access pages on the TP. if what i'm reading is correct, we can see plenty of options for this feature as well.


    "Everyone has the will to win, but precious few have the will to prepare to win"

  • are you saying to create a normal tp program and just call it BGLOGIC? if so, what calls it to run? Would it just be a command line in my MAIN.TP?

    2. J [P1] blah, blah, blah

    "Everyone has the will to win, but precious few have the will to prepare to win"

  • Bglogic must be a non group program and only allows LOGIC being a non group program. Hence absolutely no movement commands.

    There is also lots of rules you must follow.
    there can be no wait commands.
    there can be no jumps up in the program on only down
    mixed logic is your friend

    and to start it, you go to menu, setup, bglogic and set the program there. it will run constantly when the controller is powered up.

  • this feature must not be on our robot. When we go MENU, SETUP, we see program select but there is no BLOGIC there. :wallbash:

    "Everyone has the will to win, but precious few have the will to prepare to win"

  • [quote='Sergei Troizky','']
    Changing the startup default Joint jogging coordinates to World:

    IF (!F[1:BOOT DONE]),$JCR_GRP[1].$JOG_COORD=(2) ;
    F[1:BOOT DONE]=(ON)

    Hi. I am new to this. Can you please explain flag off in first line and then on in second line. How does this work? Thanks.

  • Quite easy - flags are set to FALSE on startup. The Background Logic program (which runs in a loop) reads the F[1] and if it is FALSE, changes the system variable. Then the flag is set to TRUE, so the instruction in the IF statement is not executed in the coming executions of the program (so the operator can freely change the jog mode using the TP).

  • Guys, anyone know how to check a condition in BG while program is running? For example, I need to check, is there any vacuum before to start the program,and also,while program is running i need to check that vacuum sensor all the time.

  • for that, you can use mixed logic (instructions that are available under IF/SELECT -> IF (...) THEN) and flags (which can be assignet to UOPs for example).

    well, I was thinking about that. Something like - when program starts it puts the flag to 1, then, in bg im always cheking for that flag. If it's found to be active (1), then check the DI . If DI[] = on then nothing, if DI[]=off then hold. but the problem is - how to use If in If? is that possible in bg logic? also, how to make hold on condition?

  • You can easily embed an IF into an IF when using mixed logic.
    Then set a Flag appropriately and assign that flag to the UI2 (HOLD) (by configuring it as rack 0, slot 34, start point according to the flag number). Add some logic to enable moving the robot / troubleshooting when a problem occurs (I would use UOs for that).
    And be sure to enable UOPs and provide control over the "basic" UIs (ENABLE, SFSPD, HOLD).

  • Thank you for a posting.It's very useful. I wish to create a user alarm when a certain DI gets on but I am not able to write User alarm in BG logic as I am getting syntax error .Please help me

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

Advertising from our partners