December 18, 2018, 11:51:19 PM
Robotforum | Industrial Robots Community

 BGLOGIC code that I have found useful


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

0 Members and 2 Guests are viewing this topic.

December 21, 2015, 05:41:08 PM
Reply #25
Offline

roboteacher


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"

Today at 11:51:19 PM
Reply #26

Advertisement

Guest

December 22, 2015, 02:06:57 AM
Reply #26
Online

Fabian Munoz

Administrator
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
somar

December 22, 2015, 08:06:01 PM
Reply #27
Offline

roboteacher


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.

thanks

December 22, 2015, 08:22:00 PM
Reply #28
Offline

roboteacher


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?

1. CALL BGLOGIC
2. J [P1] blah, blah, blah

December 23, 2015, 11:35:20 AM
Reply #29
Offline

dmbj


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.


December 23, 2015, 02:05:23 PM
Reply #30
Offline

roboteacher


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

December 13, 2016, 06:46:44 PM
Reply #31
Offline

Mike T


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

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.

Today at 11:51:19 PM
Reply #32

Advertisement

Guest

December 13, 2016, 07:04:32 PM
Reply #32
Offline

bidzej


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

December 13, 2016, 07:50:00 PM
Reply #33
Offline

Mike T


Gotcha. You guys are good. I always learn something here. Thanks.

March 02, 2017, 11:37:57 AM
Reply #34
Offline

Acapulka


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.

March 02, 2017, 11:43:38 AM
Reply #35
Offline

bidzej


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

March 02, 2017, 12:12:15 PM
Reply #36
Offline

Acapulka


IF/SELECT -> IF (...) THEN[/i]) 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?

March 02, 2017, 12:40:42 PM
Reply #37
Offline

bidzej


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

April 03, 2017, 07:18:36 AM
Reply #38
Offline

androidrobo


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

Today at 11:51:19 PM
Reply #39

Advertisement

Guest

April 03, 2017, 07:29:06 AM
Reply #39
Offline

bidzej


Hi.

I guess the problem is somewhere in your syntax, as BG logic is capable of controlling UALMs as far as I remember. Post it in a separate topic so we can see and discuss it.

April 28, 2017, 09:48:53 PM
Reply #40
Offline

Jaycephus


FYI, prior to HandlingTool v8.3, BGLogic could be used for state-machine logic control, but it was more cumbersome, since without JMP-LBL, you could not create code-blocks that would only run if certain conditions were met. Every line would be executed every scan.

Now, IF-THEN-ENDIF can be used in BGLogic, so that you can create cleaner-looking state-machines, for example, in BGLogic, since only the instructions within a specific IF-THEN-ENDIF code-block might be the only thing executed until a condition is met.

An IF-THEN-ENDIF block of code could be the only code executing in a BGLogic program when a state-number register is set to a specific state number. Then when the state-transition condition occurs, an IF statement that monitors the transition condition within the IF (R[nnn:MyState]=<State1Num>) THEN-ENDIF block would assign <State2Num> to R[nnn:MyState], and then the IF (R[nnn:MyState]=<State2Num>) THEN-ENDIF code-block would start executing.

example 'code':

<always-run code here for start-of-scan processing or some conditional reset code, etc. For example, a watchdog time counter:>
R[10:ScanTimeCounter]=R[10:ScanTimeCounter]+1;

! State 10, initialize ;
IF (R[10:ConveyorState]=10) THEN ;
 <initialize registers or outputs> ;
 ! wait for the start/enable signal ;
 IF (F[1:IndexConv]) THEN ;
  <do cycle inits or wait for an index signal, or possibly kick off index from here>
  R[10:ConveyorState]=1000 ;
 ENDIF ;
ENDIF ;

! State 1000, begin index ;
IF (R[10:ConveyorState]=1000) THEN ;
 GO[1:ConvSpeed]=1000 ;
 DO[1:RunConvFwd]=ON ;
 R[12:WatchdogCount]=R[10:ScanTimeCounter] ;
 ! Just one-shot & goto State 2000 ;
 R[10:ConveyorState]=2000 ;
 ! (It would be nice to have a JMP-LBL to end of program right here to do some check-code every scan prior to a subsequent state after a transition, but there are other ways to do that too.) ;
 ! (in this case it executes the subsequent state immediately, which could be preferred.) ;
ENDIF ;

!State 2000, wait for slow zone ;
IF (R[10:ConveyorState]=2000) THEN ;
 ! Wait til slow-down sensor ;
 ! Transition condition... ;
 IF (DI[2:SlowSensor]),
  ! set slow speed... ;
  GO[1:ConvSpeed]=50 ;
  ! Reset watchdog... ;
  R[12:WatchdogCount]=R[10:ScanTimeCounter] ;
  ! and go to State 3000 ;
  R[10:ConveyorState]=3000 ;
 ENDIF ;
 ! Check for Watchdog ;
 IF ((R[12:WatchdogCount]+42)<R[10:ScanTimeCounter]) THEN ;
  ! Something bad may have happened, better handle it immediately ;
  <stop conveyor, set alarm, set error register value, go back to State 10, etc.>
 ENDIF ;
ENDIF ;

!State 3000, wait for stop signal ;
IF (R[10:ConveyorState]=3000) THEN ;
 ! Wait til stop sensor ;
 ! Transition condition... ;
 IF (DI[3:StopSensor]),
  ! stop conveyor... ;
  DO[1:RunConvFwd]=OFF ;
  ! set speed back to default... ;
  GO[1:ConvSpeed]=1000 ;
  ! Reset watchdog... ;
  R[12:WatchdogCount]=R[10:ScanTimeCounter] ;
  ! and go to State 4000 ;
  R[10:ConveyorState]=4000 ;
 ENDIF ;
 ! Check for Watchdog ;
 IF ((R[12:WatchdogCount]+22)<R[10:ScanTimeCounter]) THEN ;
  ! Something bad may have happened, better handle it immediately ;
  <stop conveyor, set alarm, set error register value, go back to State 10, etc.>
 ENDIF ;
ENDIF ;

<State 4000, etc...>

<end-of-scan always-run code>

END ;


(Can someone confirm that JMP-LBL can still not be used in v8.30? I don't have access at the moment. It would still be useful in an IF-THEN-ENDIF state-machine program in BGLogic. I know for a fact I can put a JMP in a BGLogic program without a fault in v8.30, but I didn't realize it might not work, and the program in question would actually work fine without the JMP being functional. It's only purpose was to force only one code-block to run per scan, so at transition, it JMPs to the end, but if the JMP wasn't executing, it would only execute the subsequent state code-block 1 scan early.)

For older versions, you could use a lot of IF (<mixed logic>), <assignment> statements with the State register check in every IF statement:

! State 1000, begin index ;
IF (R[10:ConveyorState]=1000), GO[1:ConvSpeed]=1000 ;
IF (R[10:ConveyorState]=1000), DO[1:RunConvFwd]=ON ;
IF (R[10:ConveyorState]=1000), R[12:WatchdogCount]=R[10:ScanTimeCounter] ;
 ! Just one-shot & goto State 2000 ;
IF (R[10:ConveyorState]=1000), R[10:ConveyorState]=2000 ;


!State 2000, wait for slow zone ;
 ! Wait til slow-down sensor ;
IF ((R[10:ConveyorState]=2000) AND DI[2:SlowSensor]),R[10:ConveyorState]=2100 ;
 ! Check for Watchdog ;
 ! If Watchdog, go to an unique error state to handle the condition... ;
IF ((R[10:ConveyorState]=2000) AND ((R[12:WatchdogCount]+42)<R[10:ScanTimeCounter])),R[10:ConveyorState]=9200 ;


!State 2100, respond to reaching slow sensor ;
 ! 1st set slow speed... ;
IF (R[10:ConveyorState]=2100),GO[1:ConvSpeed]=50 ; ;
  ! Reset watchdog... ;
IF (R[10:ConveyorState]=2100),R[12:WatchdogCount]=R[10:ScanTimeCounter] ;
  ! and go to State 3000 ;
IF (R[10:ConveyorState]=2100),R[10:ConveyorState]=3000 ;


!State 3000, wait for stop signal ;
 ! Wait til stop sensor ;
IF ((R[10:ConveyorState]=3000) AND DI[3:StopSensor]),R[10:ConveyorState]=3100 ;
 ! Check for Watchdog ;
 ! If Watchdog, go to an unique error state to handle the condition... ;
IF ((R[10:ConveyorState]=3000) AND ((R[12:WatchdogCount]+22)<R[10:ScanTimeCounter])),R[10:ConveyorState]=9300 ;


!State 3100, respond to stop signal ;
  ! stop conveyor... ;
IF (R[10:ConveyorState]=3100),DO[1:RunConvFwd]=OFF ;
  ! set speed back to default... ;
IF (R[10:ConveyorState]=3100),GO[1:ConvSpeed]=1000 ;
  ! Reset watchdog... ;
IF (R[10:ConveyorState]=3100),R[12:WatchdogCount]=R[10:ScanTimeCounter] ;
  ! and go to State 4000 ;
IF (R[10:ConveyorState]=3100),R[10:ConveyorState]=4000 ;

 
- Jay

May 01, 2017, 01:52:18 PM
Reply #41
Offline

Nation



Just confirmed in RoboGuide, conditional and non-conditional jump label work at least as far back as V7.70.
Check out the position converter I wrote here!

June 14, 2017, 12:08:52 PM
Reply #42
Offline

dewitm


Can someone confirm that JMP-LBL can still not be used in v8.30? I don't have access at the moment. It would still be useful in an IF-THEN-ENDIF state-machine program in BGLogic. I know for a fact I can put a JMP in a BGLogic program without a fault in v8.30, but I didn't realize it might not work, and the program in question would actually work fine without the JMP being functional. It's only purpose was to force only one code-block to run per scan, so at transition, it JMPs to the end, but if the JMP wasn't executing, it would only execute the subsequent state code-block 1 scan early.)

Just confirmed in RoboGuide, conditional and non-conditional jump label work at least as far back as V7.70.
[/quote]
Only forward, not backwards

August 21, 2017, 07:52:53 PM
Reply #43
Offline

Petan


Hello,
I have FANUC R-30iB Plus Controller and I want to clean welding torch after startup. I use code similar this (I don't use it in BGlogic, but in standard welding program):

Code: [Select]
IF (!F[1:CLEANED]), DO[100] = PULSE [2s]
 F[1:CLEANED]=(ON)

It works, but I have problem. Flag F[1] does not set to OFF after startup. It still ON.
We switch off controller directly by the main switch.

Is there any other configuration?
Thank you.
« Last Edit: August 21, 2017, 08:02:07 PM by Petan »

August 22, 2017, 06:14:25 AM
Reply #44
Offline

bidzej


just use the BG logic to set the flag, then reset it in the torch cleaning program, somewhere at the end.

EDIT:

Or even better - instead of BG-logic, use an initialisation program which would start at Hot- and Cold-Start (make sure it has no motion group and"ignore pause" set to TRUE), which would set the flag (or even the DO directly). Then use it to call the cleaning program and reset the flag/DO at the end of the program.
« Last Edit: August 22, 2017, 06:20:38 AM by bidzej »

August 22, 2017, 12:28:09 PM
Reply #45
Offline

Petan


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?



Today at 11:51:19 PM
Reply #46

Advertisement

Guest

August 22, 2017, 12:51:44 PM
Reply #46
Offline

bidzej


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.

August 22, 2017, 07:21:08 PM
Reply #47
Offline

Petan


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.

August 22, 2017, 07:33:17 PM
Reply #48
Offline

bidzej


to check it, just go to MENU - System - Config and see if Hot-Start is enabled  :icon_wink:

August 23, 2017, 02:41:52 PM
Reply #49
Offline

Petan


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:


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

xx
BGLOGIC code questions

Started by Paulfedoniuk on Fanuc Robot Forum

7 Replies
1206 Views
Last post July 05, 2017, 02:01:19 PM
by Paulfedoniuk
xx
BGLOGIC

Started by Skipp on Fanuc Robot Forum

4 Replies
276 Views
Last post November 14, 2018, 06:22:10 PM
by HawkME
xx
R J2 BGLogic

Started by mortoch on Fanuc Robot Forum

1 Replies
1016 Views
Last post October 07, 2016, 02:15:05 AM
by ESIELI
question
PLC , BGLogic , or both?

Started by sean.ad on Fanuc Robot Forum

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