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

0 Members and 1 Guest are viewing this topic.

Offline Petan

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
Re: BGLOGIC code that I have found useful
« Reply #45 on: August 22, 2017, 12:28:09 PM »
Thank you,
If I understand I use HOT START when Switch OFF and ON just with main switch on the front panel of the cabinet. Tha's why Flags is not going to FALSE after reboot.

How I can start program after start (after init)? I use Remote control.

There is not any variable "first scan" like PLC?



Offline bidzej

  • Hero Member
  • *****
  • Thank You
  • -Given: 22
  • -Receive: 103
  • Posts: 645
Re: BGLOGIC code that I have found useful
« Reply #46 on: August 22, 2017, 12:51:44 PM »
Hot-Start is used only if the robot is configured to perform it. Normally, after cycling power, the controller performs a Cold-Start. I've mentioned both just to be sure, that the program is always executed after powering up, regardless of the starup method being used.

There is no such thing as a dedicated "first scan" signal. You can evaluate UOP signals in the PLC to determine that the robot has just powered up and started the system, but the robot itself doesn't have it.

And as for starting the program - depends on what you actually want to do. You can write that "init" program to set a given flag or DO, like that:

Code: [Select]
F[1: pre-check cleaning] = ON
then use the flag in the robot's main program (if you use one):

Code: [Select]
...
IF F[1: pre-check cleaning]=OFF, JMP LBL[1]
CALL Cleaning
LBL[1 : skip cleaning]
...

and as I've written before, reset the flag to OFF in the program Cleaning as soon as the process is complete.

If there is no single main program in the robot which selects tasks based on orders from PLC, but rather a bunch of programs that are directly started by the PLC (like multiple PNSs, RSRs etc.), use a DO instead of the flag and write logic in the PLC to first call the cleaning program if the DO is set to on. Then reset the DO back to OFF at the end of the program and that's it.

Offline Petan

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
Re: BGLOGIC code that I have found useful
« Reply #47 on: August 22, 2017, 07:21:08 PM »
Probably I will solve it with DI, or I will set Flag to OFF when IMSTP is FALSE (in BG logic). I use PNS in my application. It doesn't matter if the torch will clean after press emergency stop.

But I still don't know, why restart of controller do not turn flags to false.
There is this text in manual:

Quote
The value of flags can be recovered by Power Failure Recovery function (HOT Start). It is the same
as the other output ports, for example DO.,

The following conditions set all Flags to OFF:
COLD start
• CONTROL start
• INIT start
...

That's why I think I use HOT start after cycle power. I would like to set flags to FALSE after start the controller. Either way, COLD start is standard start procedure (I hope). But unfortunately I don't know how to set COLD start to default start.

Offline bidzej

  • Hero Member
  • *****
  • Thank You
  • -Given: 22
  • -Receive: 103
  • Posts: 645
Re: BGLOGIC code that I have found useful
« Reply #48 on: August 22, 2017, 07:33:17 PM »
to check it, just go to MENU - System - Config and see if Hot-Start is enabled  :icon_wink:

Offline Petan

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
Re: BGLOGIC code that I have found useful
« Reply #49 on: August 23, 2017, 02:41:52 PM »
In my Fanuc I use Hot start.
At last, I have made a program and start it at "HOT start initialization". You have had true :)

 :merci:

Offline Philippe54

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
Re: BGLOGIC code that I have found useful
« Reply #50 on: December 13, 2017, 08:20:18 AM »
Hello,
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:

Offline bidzej

  • Hero Member
  • *****
  • Thank You
  • -Given: 22
  • -Receive: 103
  • Posts: 645
Re: BGLOGIC code that I have found useful
« Reply #51 on: December 13, 2017, 08:24:01 AM »
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.

Offline tacheson

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 30
Re: BGLOGIC code that I have found useful
« Reply #52 on: January 09, 2018, 06:10:18 AM »
   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! 

Offline MooseHorns

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 12
Re: BGLOGIC code that I have found useful
« Reply #53 on: June 13, 2018, 04:48:36 PM »
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.

Offline YellowOneKonbie

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 4
Re: BGLOGIC code that I have found useful
« Reply #54 on: June 13, 2018, 09:01:19 PM »
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 »