Call a program using SR and BG logic

  • Hello everyone,

    I have a CR-7ia/L fanuc robot with a R30-iB plus controller.

    So my problem is that I want to start a program with a value save in a SR by a barcode scanner pluged in an HMI and with the action of an operator send it to the SR.

    I found out on the forum that you can call an SR and start the program with the same name, but I wanted it to be automatic. I thought that I could use BG logic, but find out that I can't call a program in them.

    I also find on the forum people talking about macro, but I never used it and from what I understood I need to write in my BD logic :

    UI [4:Cycle stop] = on

    Wait DO [170] = on // action from the operator to send the value of the bar-code scanner to the SR

    DO [XXX] = ON

    and then use the DO to start a macro, but I don't know how. Is that right ?

    Is there something I'm missing or am I completely wrong ?

    Thanks for taking the time to read this and for anyone who can help.

  • AD
  • Theo,

    Can you clarify that this is the behavior that you want:

    An operator places a barcode in front of a scanner. The barcode is scanned and the robot starts running a motion program automatically.

    Is that correct?

    What is the other equipment in the workcell? Is there a PLC? What type of HMI?

  • Yes it's correct but after the barcode is scanned, the operator press a buton on the HMI to send it to the SR.

    I don't have a PLC, The HMI I'm using is a Proface SP5000 series communicating with the robot in ethernet/IP and using SNPX.

  • Theo.g

    Create a TP program. Something simple

    Program name is TEST

    IF R[5:trigger]= 3 THEN



    Go to menu, setup and select to run back ground.

    While is running, display the Register values using DATA. Put a 3 on R5 and you will see a 7 on R8

    This is something simple to see how BG logic works

    I know what you are going to ask ? What about the MACRO part. Hold on, just try what I told you


  • You could use a macro, but I would highly recommend using UOP production start instead.

    You cannot troubleshoot live running macros , but you can if you use UOP. Macros have their place but usually there is a better way.

  • Hello Fabian, thanks for your response. I did what you wrote it worked, but I don't understand why you wanted me to do this. I know it's somehow related, but I probably didn't explain enough how my program/robot work or I don't understand what you are implying.

    So to summarize my robot is bagging different parts, and these parts are linked to the barcode that the operator must scan, but we do not bag on just one type of part, but on several so we have several barcode all linked to a program and I just wanted to scan the barcode and that it choose the right program.

    Hello HawkME, thanks for your response. I'll try to see how I could do this.

  • I thought you didn't understand how you set up a program running BG. So, I did that.

    I showed how you can trigger an action, you wrote "and then use the DO to start a macro, but I don't know how. Is that right ?"

    Ok, write this

    IF DO[xx]=ON THEN

    your program here


    To make a macro, go to DETAILS on any of your TP program, go to subtype and make it a macro


  • Theo is the robot running all the time or are you starting the robot from the HMI. You could start a main program using the Prog Select. Then scan your barcode and wait for a value in SR[1]. Once you have your value you can then start your robot program weather you have vision or its a pick and place.

  • Hi again Fabian, yes sorry I probably wrote what I mean badly, but thanks for your response about the macro I'll try it.

    Hi mastro, my robot will work continually after the barcode is scanned. What I mean is after the operator has scanned the barcode, the operator will write the number of kit that we need on the HMI that it's linked to a register and at the present select the program on the teach, get out of the robot space and start the program with a remote control and the robot will work until the last kit. Thanks for your response I'll try it too.

    Edited once, last by Theo.g ().

  • Hello everyone.

    I'm coming back to this thread, to say that I finally managed to make it work with the macro.

    To summarize, on my HMI I have a button that activate a DI that is assigned to a macro that I created. This macro, launch a program who simply as a CALL instruction (CALL SR[1]).

    However, while I was testing it, I step on a problem. Which is that I have different payload for my program and at the start of each program the payload change. But when the payload change my program stop and I need to press the start button to launch it.

    Is there a way to bypass this?

  • Are you modifying 1 payload in your program? What we do for example is we set payload 1 for just the weight of the tool. Then if the part we are picking is much heavier we would set the payload 2 which would be the weight of the tool plus the weight of the part we are picking. You will see the robot hesitate because you are changing the payload but if you robot is coming to a complete stop I would say you are faulting out and resting or something in your system config is wrong can you show us how you are setting the payload. A picture of you program would help a lot.

  • It's stop on the line 11 with the message 'Over payload change distance', but I just need to press the start button and it will continue the program.

  • On line 25

    J P[5] 100% CNT0 Personally I would never do something like this. Move as fast as I can I try yo stop suddenly on a dime

    Maybe this is the reason

    The robot reads ahead and right after a payload change is trying to run line 25

    Do me a favor, go slower or change the CNT or add a pre point


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now