1. Home
    1. Dashboard
    2. Search
  2. Forum
    1. Unresolved Threads
    2. Members
      1. Recent Activities
      2. Users Online
      3. Team Members
      4. Search Members
      5. Trophys
  3. Articles
  4. Blog
  5. Videos
  6. Jobs
  7. Shop
    1. Orders
  • Login or register
  • Search
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Blog Articles
  • Products
  • More Options
  1. Robotforum - Support and discussion community for industrial robots and cobots
  2. Forum
  3. Industrial Robot Support and Discussion Center
  4. Fanuc Robot Forum
Your browser does not support videos RoboDK Software for simulation and programming
Visit our Mainsponsor
IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Sponsored Ads

FANUC programming, Sensor stutter problem

  • daniel.kunz
  • April 19, 2021 at 6:35 PM
  • Thread is Resolved
  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 6:35 PM
    • #1

    Hello everybody,

    our handling system has a vacuum gripper with 2 sensors to check if the part fell accidentally from the gripper.

    Currently i am checking these sensors with a monitor program.

    -> Monitor Program CHECK_PART:

    1: WHEN RI[3] = Off OR RI[4] = Off, CALL PART_LOST

    2: END

    -> PART_LOST Program:

    1: UALM[1]

    2: ABORT

    3: END

    Now my problem is following:

    We have very thin and light products which start to shake a bit while the robot is moving through the cell.

    The sensor starts to stutter a bit ON/OFF...

    Is it possible to give the monitor program a condition that the RI[3] or RI[4] have to be off for a minimum period of time?

    Or does anyone else have a better solution for this?

    Is there something like a timer i can activate for example 0.3 seconds and after this period of time i can set an output?

    We already tried to fix this problem by changing the sensors but it doesnt work...

    I would appreciate any help.

    Thanks in advance and Greetings

    Daniel

  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • April 19, 2021 at 7:00 PM
    • #2

    I think that the Condition program used by a Monitor can only be a basic comparison. So I don't think you make the condition have a minimum period of time.

    You could use Background Logic to increment a counter when RI[3] = OFF. If the RI comes back on, reset the counter. If the counter reaches a threshold then turn on a FLAG.

    Your Condition Program for your Monitor can watch for the FLAG.

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 8:40 PM
    • #3

    Thank you for your answer.

    I have never implemented a counter in FANUC TP how would i do this?

  • Online
    SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,423
    • April 19, 2021 at 9:01 PM
    • #4

    I would assume you would just pick an unused Register, and dedicate it for use as a counter.

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 9:06 PM
    • #5

    ok but would i do it like this?:

    BGL-Program:

    1: FOR R[99]=0 TO 3

    2: WAIT 0.1(sec)

    3: R[99]=R[99]+1

    so i get a 0.3 sec delay?

    Or would the WAIT instruction in my BGL make the robot stop moving for 0.3 sec?

  • Online
    SkyeFire
    Reactions Received
    1,051
    Trophies
    12
    Posts
    9,423
    • April 19, 2021 at 9:11 PM
    • #6

    WAIT command in a BGL program should only affect that BGL.

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 9:46 PM
    • #7

    Okay so i programmed this, but apparently i cant use a wait command in a BGL.

    What do i do now?

    1: IF (RI[3]=OFF OR RI[4]=OFF) THEN

    2:

    3: LBL[1]

    4: WAIT .10(sec)

    5: R[99]=R[99]+1

    6: IF (RI[3]=ON AND RI[4]=ON) THEN

    7: JMP LBL[2]

    8: ENDIF

    9:

    10: IF (R[99]=3) THEN

    11: F[1]=(ON)

    12: JMP LBL[3]

    13: ENDIF

    14:

    15: JMP LBL[1]

    16:

    17: LBL[2]

    18: F[1]=(OFF)

    19: R[99]=0

    20: ENDIF

    21:

    22: LBL[3]

    23: R[99]=0

    END

  • jmd2777
    Reactions Received
    34
    Trophies
    4
    Posts
    193
    • April 19, 2021 at 10:23 PM
    • #8

    Yeah, you have to re-think the logic to put it in a Background program.

    For example:

    !Increment counter if either input is OFF

    IF (DI[103]=OFF OR DI[104 ]=OFF),R[99]=(R[99]+1) ;

    !If both inputs are ON, reset the counter

    IF (DI[103]=ON AND DI[104 ]=ON),R[99]=(0) ;

    !If both inputs are ON, reset the FLAG

    IF (DI[103]=ON AND DI[104 ]=ON),F[55]=(OFF) ;

    !If the counter exceeds a threshold, turn on the FLAG

    IF (R[99]>100),F[55]=(ON) ;

    You would need to set the counter threshold to a value that works for your application. The counter will increment on each BG_Logic scan which is usually every 8 milliseconds.

    Also, you may be able to use an IF THEN in BG_Logic, but I'm not sure it is available in all software versions.

  • pdl
    Reactions Received
    268
    Trophies
    9
    Posts
    1,524
    • April 19, 2021 at 10:28 PM
    • #9

    Take in mind that BG logic in fast mode will run at a constant 8ms loop and your problem of no timers in BG will solve itself.

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 10:31 PM
    • #10

    so if i have a counter counting up to 100 i will get a 800ms delay?

  • pdl
    Reactions Received
    268
    Trophies
    9
    Posts
    1,524
    • April 19, 2021 at 10:33 PM
    • #11

    Yes, or to look at it the other way around, each second will increase your register value by 125.

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 10:34 PM
    • #12

    ah ty, i will go to sleep now and think about a solution tomorrow.

    I might write something again here.

    Thank you all so far.

  • pdl
    Reactions Received
    268
    Trophies
    9
    Posts
    1,524
    • April 19, 2021 at 11:03 PM
    • #13

    I just tested this in RoboGuide, it looks like the RoboGuide BG Logic in Fast mode cycles at 4 mSec. I.E. 1 second equals a register increment of 250. This was on an R-30iB+ virtual controller which makes sense, as one of the biggest changes to the "plus" controller was dropping the ITP to 4 mSec.

    You'll want to test this on the actual controller for real world numbers.

    TP Code:

    Code
    /PROG  TEST_BG_TMR
    
       1:  R[1:DO[1] TMR]=0    ;
       2:  R[2:DO[2] TMR]=0    ;
       3:  R[3:DO[3] TMR]=0    ;
       4:   ;
       5:  DO[1]=ON ;
       6:  WAIT   1.00(sec) ;
       7:  DO[1]=OFF ;
       8:   ;
       9:  DO[2]=ON ;
      10:  WAIT   2.00(sec) ;
      11:  DO[2]=OFF ;
      12:   ;
      13:  DO[3]=ON ;
      14:  WAIT   4.00(sec) ;
      15:  DO[3]=OFF ;
      16:   ;
    Display More

    BG Logic:

    Code
       1:  IF (DO[1]) THEN ;
       2:  R[1:DO[1] TMR]=R[1:DO[1] TMR]+1    ;
       3:  ENDIF ;
       4:   ;
       5:  IF (DO[2]) THEN ;
       6:  R[2:DO[2] TMR]=R[2:DO[2] TMR]+1    ;
       7:  ENDIF ;
       8:   ;
       9:  IF (DO[3]) THEN ;
      10:  R[3:DO[3] TMR]=R[3:DO[3] TMR]+1    ;
      11:  ENDIF ;
    Display More

    Result:

  • Erik Olsen
    Reactions Received
    53
    Trophies
    5
    Posts
    176
    • April 19, 2021 at 11:45 PM
    • #14
    Quote from pdl

    Take in mind that BG logic in fast mode will run at a constant 8ms loop and your problem of no timers in BG will solve itself.

    Quote from pdl

    I just tested this in RoboGuide, it looks like the RoboGuide BG Logic in Fast mode cycles at 4 mSec. I.E. 1 second equals a register increment of 250. This was on an R-30iB+ virtual controller which makes sense, as one of the biggest changes to the "plus" controller was dropping the ITP to 4 mSec.

    You'll want to test this on the actual controller for real world numbers.

    TP Code:

    Code
    /PROG  TEST_BG_TMR
    
       1:  R[1:DO[1] TMR]=0    ;
       2:  R[2:DO[2] TMR]=0    ;
       3:  R[3:DO[3] TMR]=0    ;
       4:   ;
       5:  DO[1]=ON ;
       6:  WAIT   1.00(sec) ;
       7:  DO[1]=OFF ;
       8:   ;
       9:  DO[2]=ON ;
      10:  WAIT   2.00(sec) ;
      11:  DO[2]=OFF ;
      12:   ;
      13:  DO[3]=ON ;
      14:  WAIT   4.00(sec) ;
      15:  DO[3]=OFF ;
      16:   ;
    Display More

    BG Logic:

    Code
       1:  IF (DO[1]) THEN ;
       2:  R[1:DO[1] TMR]=R[1:DO[1] TMR]+1    ;
       3:  ENDIF ;
       4:   ;
       5:  IF (DO[2]) THEN ;
       6:  R[2:DO[2] TMR]=R[2:DO[2] TMR]+1    ;
       7:  ENDIF ;
       8:   ;
       9:  IF (DO[3]) THEN ;
      10:  R[3:DO[3] TMR]=R[3:DO[3] TMR]+1    ;
      11:  ENDIF ;
    Display More

    Result:

    Display More

    Be a bit careful with this, after playing around with loops, JMP\LBLs, and condition statements it appears the scan rate of both the HIGH and Normal priority BG logic programs is variable based on execution time. Fanuc will set the scan rate to an interval greater than the total execution time of all BGLOGIC programs, and it appears to keep all BGLOGIC programs at the same scan rate, but it can and will change the scan rate during runtime.

    I was able to get the scan rate to vary from 8msec up to 120ms by changing the state of a flag, and executing more logic (400 lines increasing a register by 1) whenever the flag was true.

    If all you plan on using it for is a sensor debounce then this shouldn't really matter much however, in a time-sensitive process, I wouldn't count on the scan rate to remain constant if there is any conditional branching in my BG logic.

    Images

    • Scan.PNG
      • 20.01 kB
      • 670 × 409
      • 13
  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 19, 2021 at 11:53 PM
    • #15

    Oh okay that is good to know.

    I hope it doesnt affect my logic though.

    Thanks

  • HawkME
    Reactions Received
    568
    Trophies
    11
    Posts
    3,268
    • April 20, 2021 at 2:40 AM
    • #16

    For your situation it shouldn't really be a problem. If you do ever need a scan independent timer, you can use $FASTCLOCK. I believe it ticks every 2ms.

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 20, 2021 at 9:24 AM
    • #17
    Quote from HawkME

    For your situation it shouldn't really be a problem. If you do ever need a scan independent timer, you can use $FASTCLOCK. I believe it ticks every 2ms.

    i will keep that in mind.

    Here is my Code which seems to work:

    I check DO45 in my Monitor Program.

    1: IF (RI[3]=OFF OR RI[4]=OFF) THEN

    2:

    3:

    4: R[99]=R[99]+1

    5:

    6: IF (RI[3]=ON AND RI[4]=ON) THEN

    7: R[99]=0

    8: DO[45:PartLost]=(OFF)

    9: ENDIF

    10:

    11: IF (R[99]>=150) THEN

    12: DO[45:PartLost]=(ON)

    13: R[99]=0

    14: ENDIF

    15: ELSE

    16: DO[45:PartLost]=(OFF)

    17: R[99]=0

    18: ENDIF

    19:

    END

  • HawkME
    Reactions Received
    568
    Trophies
    11
    Posts
    3,268
    • April 20, 2021 at 11:14 AM
    • #18

    You can delete lines 6-9, they don't do anything. Otherwise looks good!

  • I3ooI3oo
    Reactions Received
    5
    Trophies
    3
    Posts
    77
    • April 20, 2021 at 2:49 PM
    • #19

    I would just debounce the signal. Since if the signal is good then any previous off signal can be ignored.

    IF RI[3] = OFF , R[99] = R[99] + 1

    IF RI[4] = OFF , R[99] = R[99] + 1

    IF RI[3] =ON AND RI[4] = ON , R[99] = 0

    IF R[99] = 50 , CALL PART_LOST

  • daniel.kunz
    Trophies
    3
    Posts
    18
    • April 20, 2021 at 2:51 PM
    • #20
    Quote from I3ooI3oo

    I would just debounce the signal. Since if the signal is good then any previous off signal can be ignored.

    IF RI[3] = OFF , R[99] = R[99] + 1

    IF RI[4] = OFF , R[99] = R[99] + 1

    IF RI[3] =ON AND RI[4] = ON , R[99] = 0

    IF R[99] = 50 , CALL PART_LOST

    oh well yeah that looks easier.

    Anyways both works i guess.

    Thank you

Advertising from our partners

IRBCAM
Robotics Channel
Robotics Training
Advertise in robotics
Advertise in Robotics
Advertise in Robotics

Job Postings

  • Anyware Robotics is hiring!

    yzhou377 February 23, 2025 at 4:54 AM
  • How to see your Job Posting (search or recruit) here in Robot-Forum.com

    Werner Hampel November 18, 2021 at 3:44 PM
Your browser does not support videos RoboDK Software for simulation and programming

Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Thread Tag Cloud

  • abb
  • Backup
  • calibration
  • Communication
  • CRX
  • DCS
  • dx100
  • dx200
  • error
  • Ethernet
  • Ethernet IP
  • external axis
  • Fanuc
  • help
  • hmi
  • I/O
  • irc5
  • IRVIsion
  • karel
  • kawasaki
  • KRC2
  • KRC4
  • KRC 4
  • KRL
  • KUKA
  • motoman
  • Offset
  • PLC
  • PROFINET
  • Program
  • Programming
  • RAPID
  • robodk
  • roboguide
  • robot
  • robotstudio
  • RSI
  • safety
  • Siemens
  • simulation
  • SPEED
  • staubli
  • tcp
  • TCP/IP
  • teach pendant
  • vision
  • Welding
  • workvisual
  • yaskawa
  • YRC1000

Tags

  • Fanuc
  • Programming
  • timer
  • sensor
  • stutter
  • handling
  1. Privacy Policy
  2. Legal Notice
Powered by WoltLab Suite™
As a registered Member:
* You will see no Google advertising
* You can translate posts into your local language
* You can ask questions or help the community with your knowledge
* You can thank the authors for their help
* You can receive notifications of replies or new topics on request
* We do not sell your data - we promise

JOIN OUR GREAT ROBOTICS COMMUNITY.
Don’t have an account yet? Register yourself now and be a part of our community!
Register Yourself Lost Password
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on Google Play
Robotforum - Support and discussion community for industrial robots and cobots in the WSC-Connect App on the App Store
Download