I am completely new to using background logic and would like to start implementing it more in my programs. Any advice is appreciated. Attached is a few of the programs
BG logic
-
Kyle0588 -
April 24, 2017 at 7:32 PM -
Thread is marked as Resolved.
-
-
Kyle0588
BG logic are just TP programs running continuously in the back ground generally speaking
Your programs are well structure and documentedIs there anything in particular that you want continuously monitoring ?
-
I suppose not. Now i think about it i guess this particular job was a bad example. Say i had a robot servicing 4 different machines. 2 of them are running the same operation(op1) and the other 2 are running a second operation (op2) after op1 is complete. After i service any of the machines i am constantly looking for which machine is available and there is a clear wait time. I am trying to get every last second out of the cycle. I will attach program. Also is there anything out there on the web that gives you a good layout of BG logic and how it works ect.? Thanks again
-
Have you looked at the BGLogic sticky?
-
Sorry new to the website. I see the icon at the bottom of the screen but how do i get to it. and what does sticky mean?
-
means that it will not scroll down with the other messages, it will always "stick" to the top of that particular forum
-
just click HERE - you'll find some useful tips and tricks for the BG-Logic function under that link.
-
Kyle0588,
If you need monitoring few signals you can use TC_ONLINE!
for example a DI of Clamp closed! and keeping running your program!
-
Could you elaborate little more. What is TC_ONLINE ? Do you mean monitoring my inputs in the background while the program continues running?
-
I am completely new to using background logic and would like to start implementing it more in my programs. Any advice is appreciated. Attached is a few of the programsOne thing to be aware of is that not every TP program command or technique will work in BGLogic.
But we did implement control of three different Ethernet/IP VFD systems (conveyors, buffers) in BGLogic as three separate state-machines. They run automatically at startup, and full-time through an e-stop or robot pause/fault. So you can use BGLogic to obviate the need for Fanuc's PMC option. The downside is that online debugging is harder, since you cannot see it running live (AFAIK), but you could always stop the program in BGLogic and step through it in manual mode as just a regular TP program, which would help in debugging in many or most cases. Unfortunately, switching to foreground will just start back at the beginning of the program.We use a state-machine strategy for control as often as possible, so for VFD conveyor control, for example, we would have a R[nnn:ConveyorState] register to hold the current state. So the first state might be to wait for an index signal, 2nd state would start the VFD running at full speed, and the transition to third state might be a sensor detecting a decel flag and the VFD would be commanded to a very slow speed, while looking for the stop sensor as the transition to the 4th state, a stop state, after which it jumps back to the first state. Each 'state' is an IF statement checking to see if R[nnn:ConveyorState] is equal to a certain state number, such as 1000, 2000, etc. The state transition is effected by just setting the state register to the value of the next state. IF-THEN-ENDIF is new in the most recent Handling Tool (starting in v8.30?). Edited: The same thing CANNOT be accomplished with IF-JMP-LBL in BGLogic in older versions. I think they added forward JMP-LBL processing in BGLogic at the same time they added IF-THEN. (Need to segregate code-blocks that will be conditionally executed.)
One of the big advantages of using state-machine states, is you can know what state it is in when it gets 'stuck,' and each state would usually only have one or two inputs or conditions that it is looking at for its transition, so debugging is easier. If it is a question of a more complex state-machine taking an unknown path through several states and not doing what you think it should be doing, you can always stop running it as BGLogic and step through it in manual mode in the foreground. Since it is a state-machine, it will quickly return to the state logic it was at when you stopped it in BGLogic Setup. Or you can set the state register to some desired starting state to see what it will do from there as you step through it.
One of the things you can't use in BGLogic is TIMER, but you can go old-school with incrementing a register by 1 every cycle and storing current value at time-zero, and then comparing that against a time-zero-plus-dwell-time to use as a watchdog or dwell timer. One of my controllers involves interacting with robots on each end, lowering lift cylinders prior to indexing the conveyor, and raising them again after the index is complete. Another one was an even more complex buffering table that needed to home at start-up without dumping any parts, and then index to the first position, or the first location of any pre-existing parts found somewhere on the buffer. Our experience was that this was much simpler over all than using the PMC, but then we prefer using IEC-61131-3 Structured Text in our PLC programs anyway, which isn't an option in Fanuc PMC.
Sorry for explaining state-machines to those that already know how to use them, but I just wanted to indicate that all of this is possible in the newest HandlingTool BGLogic without a lot of the hassle that comes with using the PMC.
-
The same thing CANNOT be accomplished with IF-JMP-LBL in BGLogic, because JMP is not permitted. (There is no way to segregate code-blocks that will be conditionally executed.)
Jumping is allowed in Background Logic, but only going down in the program, not up.
-
Only in the recent versions of the software: 8.3, probably 8.2 (not sure).
-
Hello people! I'm using BG Logic to make my program safe with some external sensors....
My question is : Do you know if is possible to add more BG logic programs? I can only set 8.
Thank you! -
To add to this discussion - I, too, was intrigued by the option of running BG Logic, but quickly found its limitations to be ... limiting.
I eventually found a good way to operate my needed logic using BG Logic and a state-machine setup. I was able to use the DO[..]=PULSE to emulate a wait command. UPDATE: While DO[..]=Pulse does not create a program error, it also fails the pulse the selected output.
The only thing I haven't quite implemented is a TON (Timer ON) to use for debouncing. I may just have to set that up on my sensors directly.
Here's an example working program to operate an escapement attached to my robot:
Code
Display More1: !This background task controls ; 2: !the vibratory feed for inserts ; 3: ; 4: !It uses R[50] as a step sequence ; 5: ; 6: !Check if infeed needs homed ; 7: ; 8: IF (DO[25:Infeed Escap Retract]=ON AND DO[28:Infeed Lift]=ON),R[50:Feeder Sequence]=(10) ; 9: ; 10: LBL[10] ; 11: !10 home the infeed, wait ; 12: IF (R[50:Feeder Sequence]<>10 OR DO[32:WaitPulse]),JMP LBL[20] ; 13: DO[25:Infeed Escap Retract]=ON ; 14: DO[26:Infeed Escap Extend]=OFF ; 15: DO[27:Infeed Lower]=ON ; 16: DO[28:Infeed Lift]=OFF ; 17: DO[32:WaitPulse]=PULSE,5.0sec ; 18: R[50:Feeder Sequence]=20 ; 19: ; 20: LBL[20] ; 21: !20 Retract escapement and ; 22: !wait for part to advance ; 23: IF (R[50:Feeder Sequence]<>20 OR DO[32:WaitPulse]),JMP LBL[30] ; 24: DO[25:Infeed Escap Retract]=ON ; 25: DO[26:Infeed Escap Extend]=OFF ; 26: DO[29:Infeed Vibration]=ON ; 27: IF (DI[25:Part In Escapement]),R[50:Feeder Sequence]=(30) ; 28: ; 29: LBL[30] ; 30: !30 After part detected, wait ; 31: !a short time ; 32: IF (R[50:Feeder Sequence]<>30 OR DO[32:WaitPulse]),JMP LBL[40] ; 33: DO[32:WaitPulse]=PULSE,2.0sec ; 34: R[50:Feeder Sequence]=40 ; 35: ; 36: LBL[40] ; 37: !40 Advance escapement and ; 38: !wait a short time ; 39: IF (R[50:Feeder Sequence]<>40 OR DO[32:WaitPulse]),JMP LBL[50] ; 40: DO[26:Infeed Escap Extend]=ON ; 41: DO[25:Infeed Escap Retract]=OFF ; 42: DO[29:Infeed Vibration]=OFF ; 43: DO[32:WaitPulse]=PULSE,5.0sec ; 44: R[50:Feeder Sequence]=50 ; 45: ; 46: LBL[50] ; 47: !50 Raise part ; 48: IF (R[50:Feeder Sequence]<>50 OR DO[32:WaitPulse]),JMP LBL[60] ; 49: DO[28:Infeed Lift]=ON ; 50: DO[27:Infeed Lower]=OFF ; 51: R[50:Feeder Sequence]=60 ; 52: ; 53: LBL[60] ; 54: !60 Wait for robot to ; 55: !lower lift ; 56: IF (R[50:Feeder Sequence]<>60 OR DO[32:WaitPulse]),JMP LBL[70] ; 57: IF (DO[27:Infeed Lower]),R[50:Feeder Sequence]=(70) ; 58: ; 59: LBL[70] ; 60: !70 Robot tried to pick ; 61: !wait short time for settling ; 62: IF (R[50:Feeder Sequence]<>70 OR DO[32:WaitPulse]),JMP LBL[80] ; 63: DO[32:WaitPulse]=PULSE,1.0sec ; 64: R[50:Feeder Sequence]=80 ; 65: ; 66: LBL[80] ; 67: !80 check if part was ; 68: !successfully picked or failed ; 69: IF (R[50:Feeder Sequence]<>80 OR DO[32:WaitPulse]),JMP LBL[90] ; 70: IF (DI[25:Part In Escapement]),DO[31:Pick Fail]=(ON) ; 71: IF (!DI[25:Part In Escapement]),DO[30:Pick Success]=(ON) ; 72: R[50:Feeder Sequence]=90 ; 73: ; 74: LBL[90] ; 75: !90 Wait for robot to acknowledge ; 76: !the pick success or failure ; 77: !if does this by clearing the ; 78: !'success' of 'fail' bit ; 79: IF (R[50:Feeder Sequence]<>90 OR DO[32:WaitPulse]),JMP LBL[100] ; 80: IF (!DO[30:Pick Success] AND !DO[31:Pick Fail]),R[50:Feeder Sequence]=(100) ; 81: ; 82: LBL[100] ; 83: !100 Robot ack'd and ready to ; 84: !present next part (goto 20) ; 85: IF (R[50:Feeder Sequence]<>100 OR DO[32:WaitPulse]),JMP LBL[999] ; 86: R[50:Feeder Sequence]=20 ; 87: ; 88: LBL[999:END] ;
-
just click HERE - you'll find some useful tips and tricks for the BG-Logic function under that link.
I went to use this link and it no longer directs to "useful tips and tricks for the BG-Logic Function".
I will run some searches to see if I can locate the thread but if you could post another link that would be great!
-
-