July 19, 2019, 12:34:15 PM
Robotforum | Industrial Robots Community

 BGLOGIC code that I have found useful

veryhot_post_sticky Author Topic:  BGLOGIC code that I have found useful  (Read 67836 times)

0 Members and 1 Guest are viewing this topic.

December 13, 2017, 08:20:18 AM
Reply #50


One thing I found very useful is the shifted override.
Instead of going from 5 to 5%, when you activate $SHFTOV_END=1 then it goes 100-50-5-1 and the same way back.
Great for integrators but it's better to disable it for real production  :icon_wink:

Today at 12:34:15 PM
Reply #51



December 13, 2017, 08:24:01 AM
Reply #51


well, this has nothing to do with BG-Logic.
The variable you mentioned is usually set to 1 in smaller robots (like ArcMates), so the override can be set in steps 1-25-50-100[%].
But you're right, better to leave it at 0 in bigger ones.

January 09, 2018, 06:10:18 AM
Reply #52


   6:  --eg:Initialize Strobe ;
   7:  !-------------------------------- ;
   8:  IF (F[42:OFF:Flasher .2sec]=OFF),F[43:OFF:Flasher .5sec]=PULSE,1.0sec ;
   9:  IF (F[43:OFF:Flasher .5sec]=OFF),F[42:OFF:Flasher .2sec]=PULSE,1.0sec ;
  10:  IF ($PWRUP_DELAY.$SY_READY=0),F[42:OFF:Flasher .2sec]=(ON) ;

This always helped me.  These two flags pulse back and forth.  Also, you don't have to worry about initializing it because it triggers when the sysvar PWRUP_DELAY is complete. 

I always use these flashers, and maybe more than just two, to indicate to operators what's happening if I only have a stack light with the standard 3 colors (Green=Running, Red=Faulted, Amber=Hold).  Then I can flash the yellow or other colors for other action items.

Example below.  When the inbound stack of parts is running out, i would indicate to the fork truck operator to prepare a new skid of parts.

   1:  !-------------------------------- ;
   2:  !Background Logic ;
   3:  !-------------------------------- ;
   4:   ;
   5:   ;
   6:  --eg:Initialize Strobe ;
   7:  !-------------------------------- ;
   8:  IF (F[42:OFF:Flasher .2sec]=OFF),F[43:OFF:Flasher .5sec]=PULSE,1.0sec ;
   9:  IF (F[43:OFF:Flasher .5sec]=OFF),F[42:OFF:Flasher .2sec]=PULSE,1.0sec ;
  10:  IF ($PWRUP_DELAY.$SY_READY=0),F[42:OFF:Flasher .2sec]=(ON) ;
  11:   ;
  12:  --eg:Flash Lights to Indicate to Operator Inspect Part is ready ;
  13:  !-------------------------------- ;
  14:  IF (F[15:OFF:Low Stack SrchVis]=ON),UO[3:OFF:Prg running]=(F[42:OFF:Flasher .2sec]) ;
  15:  IF (F[15:OFF:Low Stack SrchVis]=ON),UO[5:OFF:Motion held]=(F[42:OFF:Flasher .2sec]) ;
  16:  IF (F[15:OFF:Low Stack SrchVis]=ON),UO[6:ON :Fault]=(F[42:OFF:Flasher .2sec]) ;
  17:   ;
  18:  --eg:If UO is on or if Flasher is on Turn light On ;
  19:  !-------------------------------- ;
  20:  IF ((F[15:OFF:Low Stack SrchVis]=ON AND F[42:OFF:Flasher .2sec]=ON) OR UO[3:OFF:Prg running]=ON),DO[1017:OFF:Intrcnct EXGOP]=(ON) ;
  21:  IF (F[15:OFF:Low Stack SrchVis]=OFF AND UO[3:OFF:Prg running]=OFF),DO[1017:OFF:Intrcnct EXGOP]=(OFF) ;
  22:   ;
  23:  IF ((F[15:OFF:Low Stack SrchVis]=ON AND F[42:OFF:Flasher .2sec]=ON) OR UO[5:OFF:Motion held]=ON),DO[1018:OFF:Intrcnct EMGTP]=(ON) ;
  24:  IF (F[15:OFF:Low Stack SrchVis]=OFF AND UO[5:OFF:Motion held]=OFF),DO[1018:OFF:Intrcnct EMGTP]=(OFF) ;
  25:   ;
  26:  IF ((F[15:OFF:Low Stack SrchVis]=ON AND F[42:OFF:Flasher .2sec]=ON) OR UO[6:ON :Fault]=ON),DO[1019:OFF:Intrcnct EMGEX]=(ON) ;
  27:  IF (F[15:OFF:Low Stack SrchVis]=OFF AND UO[3:OFF:Prg running]=OFF),DO[1019:OFF:Intrcnct EMGEX]=(OFF) ;

Also, mapping your UOPs to virtual bits is slick too.  (Rack 0, Slot 0, Start 1-1000)  Then, you can have ALL THE POWER! 

June 13, 2018, 04:48:36 PM
Reply #53


We often want to send a negative value to the robot for either an offset modifier, or to modify other registers.

We use mostly 16-bit words to communicate a negative number actually subtracts from the high end 65535, so when the PLC sends a -1 it actually sends to the robot 65535, we modify that using a BG Logic program similar to this:

1:  IF (GI[X]<=32768), R[X]=(GI[X])
2:  IF (GI[X]>32768), R[X]=(GI[X]-65536)

which sets the GI's to a register and gives them the appropriate sign, this does obviously limit your total value options to -32,768 thru 32,768; but we rarely need a value higher than 10,000.

June 13, 2018, 09:01:19 PM
Reply #54


You can actually do that in one line if you want.

1:R[X]=(GI[X]-(GI[X]DIV 32768)*65536)
« Last Edit: June 13, 2018, 09:03:56 PM by YellowOneKonbie »

February 15, 2019, 02:00:15 PM
Reply #55


I want to start the robot with an external button (no PLC). I also want to give operator an external reset button.
Always the same program (Program Select = OTHER, $shell_wrk.$cust_name : MAIN)

I'm thinking that I need to monitor the state of the buttons through BGLOGIC.

Can anyone help with BGLOGIC and I/O config setup please?


February 15, 2019, 03:09:33 PM
Reply #56


Global Moderator
You don't need BGlogic for that. Just configure your button to the UOP Inputs. Look up UOP in the manual and it will tell you everything.

Sent from my SM-G930V using Tapatalk

Today at 12:34:15 PM
Reply #57



February 15, 2019, 04:41:14 PM
Reply #57


So configure UI[5: FAULT RESET] and UI[6: START] to the same points as my digital inputs DI[5] & DI[6] and wire my switches to the DIs locations.

Then for example my start button on DI[6] will activate UI[6:START] to move the robot, right?

February 16, 2019, 02:01:59 AM
Reply #58


Global Moderator
You will actually want UI[18] production start, in order to start your Main program. UI[6] will start the currently selected program, not necessarily Main, or it can be set to continue only in the system config. I suggest making start for continue only = true.

The UI signals don't have to be mapped to any specific DI'S, just make sure they are set to the correct rack, slot , start point for your push buttons.

Sent from my SM-G930V using Tapatalk

Share via facebook Share via linkedin Share via pinterest Share via reddit Share via twitter

BGLOGIC code questions

Started by Paulfedoniuk on Fanuc Robot Forum

7 Replies
Last post July 05, 2017, 02:01:19 PM
by Paulfedoniuk
R J2 BGLogic

Started by mortoch on Fanuc Robot Forum

1 Replies
Last post October 07, 2016, 02:15:05 AM

Started by Skipp on Fanuc Robot Forum

4 Replies
Last post November 14, 2018, 06:22:10 PM
by HawkME
PLC , BGLogic , or both?

Started by sean.ad on Fanuc Robot Forum

7 Replies
Last post June 28, 2017, 07:17:26 PM
by sean.ad