Background Logic programs are scan routine programs that constantly run in the background. They are executed one line at a time, from start to finish, repeatedly. If you know anything about PLC programming, they are very similar to the way those programs are structured and run. You can only use assignment statements in background logic programs. This means that you can not use motion instructions, branching statements (jump, label, call, run, etc...), timers, WAIT instructions or macros.
So basically you are limited to setting registers, I/O and system variables. And the only conditional statement you can use is the mixed logic IF statement: IF (...)
All of this is to keep the program simple so that it can be executed quickly. In my experience, if you're dealing with less than 16 inputs and 16 outputs, background logic is a good way to avoid using a PLC in the workcell if you don't have to. Anything more than that would probably be better suited to either the PMC option or a PLC. For me, the primary way I use it is to set up run conditions that must be met before the robot can be operated in automatic.
You can setup BG LOGIC from Menu -> Setup -> BG LOGIC where you can choose your BG LOGIC program.
F=(OFF) IF (DI AND !F),F=(ON) F=(DI) IF (F), R=R+1
First scan with DI on: F=(OFF) ;We always turn this flag off at the start of the cycle IF (DI AND !F),F=(ON) ;If DI is on, and F is off, we want to turn F on F=(DI) ;Now we want to set F to the same state as DI. This means that on the next "scan", the condition in the previous line will not be met. IF (F), R=R+1 ;If we've gotten this far, and we see that F is on, that means we know it's the first scan where we've seen DI on Second scan with DI on: F=(OFF) ;Again, this flag gets turned off to avoid repeating any of those assignments again IF (DI AND !F),F=(ON) ;This time around F is on, so this condition is not met, and F stays off F=(DI) ;This holds F on until we see DI turn off. IF (F), R=R+1 ;This line will not execute First scan with DI off: F=(OFF) IF (DI AND !F),F=(ON) ;DI is off, and F is still on from the last cycle. Condition still not met. F=(DI) ;Now F is turned off. The next time DI comes on, the above condition will be met again. IF (F), R=R+1
嗯，BG LOGIC 真是个好东西；http://www.robot-forum.com/ 真是个好论坛。