BG Logic - set a signal on and off for amount of time

  • Hello,

    I've been thinking lately if there's a possibility to set a signal on and off variably, e.g. 2 seconds.


    I want to use a bg logic program because everytime a TP is on (SO [7]) - the light flashes for 2 seconds (On for 2 secs, off for 2 secs and so on).

    I could easily do it using Wait() but in bg logic it's impossible to use wait instruction.

  • An easy way to time in BG logic is to constantly increment a counter. The counter value will equal the number of scans. So if your scan time is 8 ms then 250 scans = 2 seconds. When your counter reaches 250 reverse your output state and reset the counter to 0. Now you have a flashing output.

  • But won't this work for 2 secs only when the light is on? I want it to be off for 2 secs too.

    Edit: nevermind I already got that working by adding another counter. Thanks for help.

    Edited 2 times, last by Nvm123 ().

  • Tip#1: Use heartbeat signal and small logic to do it.

    Tip#2: Use $FAST_CLOCK internal system clock to count 2 sec and do what you need.

    Tip#3: Use TIMERS


    Timer probably the easiest way. Just do smth like this


    IF TIMER>0 AND TIMER<2

    stay ON

    ENDIF

    IF TIMER>2AND TIMER<4

    stay OFF

    ENDIF


    IF TIMER>4

    TIMER RESET

    ENDIF

  • You can get it to work with a single counter by reversing the output state:


    : IF R[x:counter]>250, (DO[x]=!DO[x]);

    Thanks, exactly what I was searching for.... but there is a little syntax flaw:

    : IF R[x:counter]>250, DO[x]=(!DO[x]);

  • I am very new to the robotics field and want to use BG Logic. I have a similar problem as you had.


    I want to create a heartbeat as soon as the cycle starts. I had read all the suggestions below but was not able to code it correctly in my tp.


    Can you please tell me how did you used the counter with a proper syntax.


    Thanks in advance.

  • Fanuc have a heartbeat. Menu > I/O > Cell Interface


    Counter with Fanuc heartbeat:

    pasted-from-clipboard.png

    DO[1000] = Fanuc heartbeat

    F[1] = Auxiliar flag

  • As scotty already said, use fanuc heartbeat signal.


    Press the [MENU] key and select "I/O". Then press F1, [TYPE] and select "Cell Interface". In the output screen ("IN/OUT") you will find “7 Heartbeat signal”. 7 Heartbeat signal. To allocate the signal, press F2, "CONFIG".

    If you want change “Heartbeat timing”:

    Press the [MENU] key. Select “6 SETUP” then "1 Prog Select". Type value in milliseconds.


    For more information, please refer to the OPERATOR’S MANUAL (Basic Function) B-83284EN/10.

Advertising from our partners