Intro to FANUC Background Logic

Filed under: FANUC TP Programming

FANUC’s Background Logic feature is basically the ladder-logic you know and love in TP Program form. These programs only consist of Mixed Logic statements (e.g. F[1]=(DI[1] AND DI[2])), and the programs are constantly scanned in the background while your robot is online, ignoring all E-Stops, alarms, etc. Depending on the complexity of your system, you may be able to skip the PLC and simply use BG Logic to control everything.

How Complex Can My System Be?

Well, that depends on a few things:

  1. How fast does your scan time need to be?
  2. How comfortable are you with ladder logic?
  3. How comfortable are you translating ladder logic to mixed logic?

Scan time

Each BG Logic program can run in one of two modes: Normal and High-Level. A Normal mode BG Logic program’s scan time will vary with the number of items to be scanned (no maximum). A High-Level mode BG Logic program is guaranteed to scan up to 540 items every 8ms. An “item” is is any instruction (e.g. assignment, if-statement), operator (e.g. AND, OR, =, ‘(’, ‘)’, +) or piece of data (F[], R[], DI[], DO[]).

The scan time of a normal mode program is:

              Total # of Items
  Scan Time = ---------------- * ITP
                    600

Your ITP is typically 8ms unless you’re using a Genkotsu robot.

Example:

Let’s first draw a ladder-logic diagram:


  |                              |
  |                        F[1]  |
  |------------------------(  )--|
  |                              |
  |          DI[1]         F[2]  |
  |-----------] [----------(  )--|
  |                              |
  |          DI[2]         F[3]  |
  |-------*---] [---*------(  )--|
  |       |         |            |
  |       |  F[2]   |            |
  |       *---] [---*            |
  |                              |

How would you write this in a BG Logic program?

  F[1]=(ON) ;
  F[2]=(DI[1]) ;
  F[3]=(DI[2] OR F[2]) ;

Now what about scan time? If we’re running in Normal mode, we have to count up the number of items in our program.

It’s easy to see we have 3 mixed-logic assignment instructions. Counting up the parens and boolean operators gives us 8 operators. We have 6 data points after counting all instances of F[] and DI[].

  # instructions  | # operators  | # data  | TOTAL
  ----------------+--------------+---------+------
  3               | 8            | 6       | 17

              Total # of Items
  Scan Time = ---------------- * ITP
                    600

                17
            = ----- * 8
               600

            = 0.227ms

You can see that we have plenty of time to scan through this simple program during one 8ms ITP, but you can also see how the total # of items adds up pretty quickly.

How comfortable are you with ladder logic?

Even if you don’t come from a PLC background, hopefully the ladder logic diagram above makes sense. Imagine current running from left to right to the coil on the right side of the rung. If the contact is closed (true or ON), current is allowed to continue on to the right. If current reaches a regular coil, it gets energized.

How comfortable are you translating ladder logic to mixed logic?

The example above was pretty easy, but what about a more complicated rung?


  |                                           |
  |     DI[1]   DI[2]   DI[3]   DI[4]   F[1]  |
  |--*--] [--*--] [-----] [--*--]/[--*--(  )--|
  |  |       |               |       |        |
  |  |       |      DI[5]    |       |        |
  |  |       *------] [------*       |        |
  |  |                               |        |
  |  |     F[1]             DI[1]    |        |
  |  *-----] [--------------] [------*        |
  |                                           |

This turns into the following BG Logic code:


  F[1]=((DI[1] AND ((DI[2] AND DI[3]) OR DI[5]) AND !DI[4]) OR (F[1] AND DI[1])) ;

It’s a lot easier to see what’s going in the diagram, but it’s possible with Mixed Logic too.

Keep It Simple

Do you really need to add the complexity of an additional PLC to your system? If you’re only controlling a couple of actuators and turning a couple of conveyors on and off, maybe not. Combine Background Logic with the iPendant as your HMI and you’ve saved yourself quite a bit of money.


There's more where that came from.

I email (almost) every Tuesday with the latest insights, tools and techniques for programming FANUC robots. Drop your email in the box below, and I'll send new articles straight to your inbox!

No spam, just robot programming. Unsubscribe any time. No hard feelings!