586,469 active members*
3,716 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Detect "Optional Stop" status in program/macro?
Results 1 to 15 of 15
  1. #1
    Join Date
    Jan 2010
    Posts
    99

    Detect "Optional Stop" status in program/macro?

    hey everyone

    i'm wondering if there is a way to detect the state of the opt-stop switch on the operator's panel on any fanucs... programmatically.

    system variable # by chance? that would be perfect

    i want to send out status changes via dprnt when opt stop is on, but igonore them when the M1 is ignored (ie opt stop off)

    thanks
    - gwarble

  2. #2
    Join Date
    Jan 2010
    Posts
    99
    from what i can tell this isn't possible... maybe i can modify the ladders to set a macro variable or a system variable with the opt-stop pushbutton...

    - gwarble

  3. #3
    You will need to tie the input for the switch to a variable via the PMC

    UI0000 = #1000
    ~~~~
    UI0031 = #1031

    UO0000 = #1100
    ~~~~
    UO0031 = #1131

    GL
    ************************************************** *********
    *~~Darwinian Man, though well-behaved, At best is only a monkey shaved!~~*
    ************************************************** *********
    *__________If you feel inclined to pay for the support you receive__________*
    *_______Please give to charity https://www.oxfam.org.au/get-involved/_______*
    ************************************************** *********

  4. #4
    Join Date
    Feb 2007
    Posts
    314
    I found a way to do that without editing ladder but it is a little bit strange.
    First i set a macro called by M01 (O9021)

    O9021
    #3001=0 (RESET TIMER)
    M01
    IF[#3001 LT 1000] GOTO 20
    IF [#500 EQ 0] GOTO10 (DONT SEND IF THE STATE HAS NOT CHANGE)
    POPEN
    DPRNT[M01 ON]
    PCLOS
    #500=0 (RETAIN THE STATE OF THE SWITCH)
    N10 M99
    N20 IF [#500 EQ 1] GOTO 30 (DONT SEND IF THE STATE HAS NOT CHANGE)
    POPEN
    DPRNT[M01 OFF]
    PCLOS
    #500=1 (RETAIN THE STATE OF THE SWITCH)
    N30 M99

    The bad thing it is that you send the info only after cycle start is pressed after the M01.

    How it works: first a timer is set to 0 and begin do count(by milisecond increment) If M01 is deactivate, a small amount of time depending of the block processing time, will be ellapsed so you have to set the comparative value of the first IF higher than the processing time to jump a the right place.

    If M01 is activate, the timer will increase while the pause is active and when you will end the pause, the timer value will be higher than the comparative value, so you will know that M01 was active.

    I tested it on a 0-MD and it works fine.

    Let me know if you can do sometinhg with that

  5. #5
    Quote Originally Posted by samu View Post
    O9021
    #3001=0 (RESET TIMER)
    M01
    Wouldn't this cause a loop ? calling M01 inside the macro.

    Quote Originally Posted by samu View Post
    IF[#3001 LT 1000] GOTO 20
    IF [#500 EQ 0] GOTO10 (DONT SEND IF THE STATE HAS NOT CHANGE)
    POPEN
    DPRNT[M01 ON]
    PCLOS
    #500=0 (RETAIN THE STATE OF THE SWITCH)
    N10 M99
    N20 IF [#500 EQ 1] GOTO 30 (DONT SEND IF THE STATE HAS NOT CHANGE)
    POPEN
    DPRNT[M01 OFF]
    PCLOS
    #500=1 (RETAIN THE STATE OF THE SWITCH)
    N30 M99

    The bad thing it is that you send the info only after cycle start is pressed after the M01.

    How it works: first a timer is set to 0 and begin do count(by milisecond increment) If M01 is deactivate, a small amount of time depending of the block processing time, will be ellapsed so you have to set the comparative value of the first IF higher than the processing time to jump a the right place.

    If M01 is activate, the timer will increase while the pause is active and when you will end the pause, the timer value will be higher than the comparative value, so you will know that M01 was active.

    I tested it on a 0-MD and it works fine.

    Let me know if you can do sometinhg with that
    ************************************************** *********
    *~~Darwinian Man, though well-behaved, At best is only a monkey shaved!~~*
    ************************************************** *********
    *__________If you feel inclined to pay for the support you receive__________*
    *_______Please give to charity https://www.oxfam.org.au/get-involved/_______*
    ************************************************** *********

  6. #6
    Join Date
    Feb 2007
    Posts
    314
    It won't cause a loop. When you use a M or G code inside a macro called by itself, it will be executed normally inside the macro. It allow to call macro with standard G or M code without loose the functionallity of this code.

  7. #7
    Join Date
    Jan 2010
    Posts
    99
    yup, samu's right... and if you need to call a macro from a macro you can use g65 p90xx if necessary


    i like your clever thinking finding a solution for this with the timer, samu... but like you pointed out you only know after the M1

    the two methods i've tried (but don't like the extra step) is to define my own M1 as follows, which allows me to use #101 macro variable as a secondary opt-stop with "status" dprnts:

    Code:
    O9006(OPT STOP...) 
    IF[#101EQ1]GOTO1111
    M1 
    M99
    N1111
    POPEN
    DPRNT[//HOLD] 
    PCLOS
    M0 
    POPEN
    DPRNT[//START]
    PCLOS
    M99
    also, depending on your use of block skip, you could use that as well, with or without GOTOs, like:

    Code:
    O9006(OPT STOP...) 
    /M1
    /M99
    POPEN
    DPRNT[//HOLD*M1] 
    PCLOS
    M1
    POPEN
    DPRNT[//START*M1]
    PCLOS
    M99
    just some preliminary work arounds... but none as easy as the "opt stop" button alone

    - gwarble

  8. #8
    Join Date
    Feb 2007
    Posts
    314
    I'm curious. Why do you want to DPRNT M01 switch status?

  9. #9
    Join Date
    Jan 2010
    Posts
    99
    so i know when a machine has stopped...

    really the computer software should handle it but its a work in progress...


    i don't want to DPRNT the M1 status... i want to send the "HOLD" string when the machine stops at the M1 and send the "START" string when the cycle start happens again, if the opt stop actually stops the program... and send nothing if M1 does nothing

    i want my log of statuses to look like this:
    status: time:
    Code:
    start 30sec
    hold 10sec
    start 30sec
    end
    when opt stop is active, and like this:
    Code:
    start 60sec
    end
    when i switch off opt-stop... instead of:
    Code:
    start 30sec
    hold 0sec
    start 30sec
    end

    my first example, pretend variable #101 is another opt-stop button... and it works like i want opt-stop to

    thanks
    - gwarble

  10. #10
    Join Date
    Feb 2007
    Posts
    314
    I wrote a set of macro that do exactly wath i think you want. It is the macro itself that calculate time ellapsed and send it with the appropriate string (start, hold, end) I don't have time to post it right now but tomorow i will show you. Maybe it could be interesting to add time between cycle(part changing time)

  11. #11
    Join Date
    Jan 2010
    Posts
    99
    i'm not sure conceptually how the machine would know ahead of the M1 via timer... but i'd love to see your macro solution

    thanks
    - gwarble

  12. #12
    Join Date
    Feb 2007
    Posts
    314
    I hope that i will be clear enough and you'll take time to understand it.English is not my first language, so some explanation could appear nebulous. Have Fun
    effectively, the machine won't know ahead for M1, but once the pause is finish, it send the duration of the pause and the time ellapsed before the pause. I keep the same concept to detect M01. At the begining of the main program i store the current time of day(system variable #3012) in a common variable via a macro that translate it into second for easy calculation. Instead of M01 i call the detection macro.

    At the first line of detection macro, i store again the current time of day in another common variable.If M01 is not detected, i go back to the main program.If M01 is detected, once the pause is finished i store again (always via a macro) the current time of day and call another macro to do the calculation of the duration of each segment(Time ellapsed from start to pause and pause duration) and DPRNT this info before go back to main program.

    At the end of the main program, once again, i store the current time of day and call a macro to to de calculation and send the right info.

    Here is the code:
    O1234 (Main program)
    M64 B101(SAVE CURRENT TIME OF DAY in #101 once it is translated in second)
    G04 X2.0
    M98 P9021 (M01 WITH DETECTION)
    G04 X2.0
    M64 B104 (SAVE CURRENT TIME OF DAY IN #104)
    IF[#110 EQ1] GOTO 10 (IF M01 WAS ACTIVE)
    G65 P9022 A#104 B#101 C1.0 (CALCULATE DURATION OF WHOLE PROGRAM C=0 FOR HOLD TIME, C=1 FOR START TIME)
    GOTO 15
    N10 G65 P9022 A#104 B#103 C1.0 (CALCULATE DURATION AFTER PAUSE)
    N15 POPEN
    DPRNT[END]
    PCLOS
    M30

    O9021 (M01 DETECTION)
    #3001=0 (RESET TIMER)
    M64 B102 (STORE TIME OF DAY IN #102)
    M01
    IF[#3001 LT 1000] GOTO 20 (IF M01 IS INACTIVE)
    M64 B103 (STORE TIME OF DAY IN #103)
    G65 P9022 A#102 B#101 C1.0 (SEND START TIME BEFORE PAUSE)
    G65 P9022 A#103 B#102 C0 (SEND HOLD TIME)
    #110=1 (STORE THAT M01 WAS ACTIVE)
    M99
    N20 #110=0 (STORE THAT M01 WAS INACTIVE)
    M99

    O9022 (CALCULATE DURATION,TRANSLATE IN HOUR,MINUTE,SECOND AND SEND INFO)
    #106= [#1- #2] (DELAY TIME IN SEC)
    #107= FIX[#106/3600] (HOUR)
    #108= FIX[[#106- #107*3600]/60] (MINUTE)
    #109=[#106-#107*3600-#108*60] (SECOND)
    POPEN
    IF [#3 EQ 1] GOTO10 (IF START TIME IS OUTPUT)
    IF [#107 EQ 0] GOTO3 (IF LESS THAN 1 HOUR)
    DPRNT[HOLD;#107[20]HOUR;#108[20]MIN;#109[20]SEC]
    GOTO20
    N3 IF[#108 EQ 0] GOTO4 (IF LESS THAN 1 MINUTE)
    DPRNT[HOLD;#108[20]MIN;#109[20]SEC]
    GOTO20
    N4 DPRNT[HOLD;#109[20]SEC]
    GOTO20
    N10 IF[#107 EQ 0] GOTO13
    DPRNT[START;#107[20]HOUR;#108[20]MIN;#109[20]SEC]
    GOTO20
    N13 IF[#108 EQ 0] GOTO14
    DPRNT[START;#108[20]MIN;#109[20]SEC]
    GOTO20
    N14 DPRNT[START;#109[20]SEC]
    N20 PCLOS
    M99

    O9023 (STORE AND TRANSLATE TIME OF DAY IN SECOND)
    #1=#3012
    #3=FIX[#1/10000]
    #4=FIX[[#1-#3*10000]/100]
    #5=[#1-10000*#3-100*#4]
    #[#2]=3600*#3+60*#4+#5 (TOTAL TIME IN SEC)
    M99


    O9023 is called by a M code that is not buffered (set M code value in parameter #111 or #112 (on a 0-MD)) It is very important else, the time of day will be stored as soon that the line #xxx=#3012 is read into the buffer. Another method shold be to put a cople of empty block before that line but cause the buffer size isn't the same on evry control it is not a good way to do. Argument passed in this macro is the variable number where time of day will be stored(in sec).

    In my example:
    #101=time at start
    #102=time at the beginning of pause
    #103=time at the end of pause
    #104=time at the end of program

    when you call macro O9022, you also pass as argument the two time value on wich the duration have to be calculated and if it is a START or a Hold period. So:
    A=end of period
    B=start of period
    C=0 if it is a hold and 1 if it is a start (to send the good string before the time)

    It works great, the only fail is if a part is start before midnight and end after midnight. But it won't be difficult to correct it.

    It could be easier to use timer instead of time of day but #3001 can only count about 64 sec and #3002 is only precise within 3.6 sec (1/1000 hour)

    Here is how the data looks like once it is send

    START 5SEC
    END

    START 2SEC
    HOLD 2SEC
    START 4SEC
    END

    START 2SEC
    HOLD 4MIN 13SEC
    START 3SEC
    END

    START 3SEC
    HOLD 2MIN 20SEC
    START 3SEC
    END

    Another possible faillure i forgot, timer #3001 reset itself after about 64 sec. So if pause duration is about a multiple of 64 sec, pause can end when timer value is less than the comparative value in the macro detection.To reduce this risk, comparative value must be set as small as possible(just high enough to compansate block processing time)

  13. #13
    Join Date
    Jan 2010
    Posts
    99
    nice solution... i can see your methodology and seems like a good way to do it...

    the difference in what i really want is this, i had the DPNT[//HOLD] status signal update the machine's status in real time, so if i'm off on the other side of the shop i can see when the machine has ended or is at an opt stop

    good solution for more precise time tracking

    thanks
    - gwarble

  14. #14
    Join Date
    Feb 2007
    Posts
    314
    Thanks for quick reply!!

    I must admit that i have no more idea except edit ladder. Or like you said, use block skip in conjonction with M00.But it could be confusing

  15. #15
    Join Date
    Jan 2010
    Posts
    99
    yup thats what its looking like

    thanks for your help, ideas, and posts

    best of luck...

    - gwarble

Similar Threads

  1. Replies: 17
    Last Post: 11-20-2020, 09:48 PM
  2. New Mach version "Elapsed Time" doesn't stop
    By kprice1658 in forum Tormach Personal CNC Mill
    Replies: 5
    Last Post: 04-14-2010, 09:53 PM
  3. How to monitor VSD-A "Ready" status?
    By LBodnar in forum CNC Machine Related Electronics
    Replies: 19
    Last Post: 06-05-2009, 01:59 PM
  4. Replies: 2
    Last Post: 06-13-2008, 11:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •