586,121 active members*
3,463 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Fanuc > Can I get the status of relay in a program?
Results 1 to 17 of 17
  1. #1
    Join Date
    Dec 2008
    Posts
    8

    Can I get the status of relay in a program?

    Is it possible to get the status of a relay (on/off) in the ladder from within a subprogram or a macro? I have a custom M-code that turns on a certain relay under certain conditions and need to have the ability to check the status of that relay from within a program or macro. Maybe by using an IF- statement or something of that nature?

    Thanks,
    Steve

  2. #2
    Join Date
    Jun 2008
    Posts
    1511
    I would think if you have a custom code to activate the relay then you should be able to check the status of it. But it will depend.

    What kind of Fanuc control are you using? Does the custom code run a program or does it activate the relay via ladder?

    Stevo

  3. #3
    Join Date
    Dec 2008
    Posts
    8
    Control is Fanuc 21i-T. It is just an m-code that turns on a relay with the ladder logic. I need to be able to check the status of that relay from either the main program or a macro / subprogram.

  4. #4
    Join Date
    Jun 2008
    Posts
    1511
    Ahhhh man I just typed up a whole page of what to do and now just realized that it will not work. I need more info. First off is the M-code tied to an input/output system variable? You should be able to find that info in the MTB manual. Is there an M-code to deactivate the relay opposite of the M-code you use to activate it?

    What exactly is this M-code used for? IOW what are you activating, what conditions must be met, and why?

    Stevo

  5. #5
    Join Date
    Dec 2003
    Posts
    24221
    Wouldn't the system variables that read D1/D0 from #1000 I believe, do the trick?
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  6. #6
    Join Date
    Jun 2008
    Posts
    1511
    Yes Al you are correct that is what I originally started typing up before. He will have to see if any of them are tied to the M-code he is using. I would ass u me that one of them are.

    What I originally started typing up:
    If your M-code to turn on the relay is tied to an input/output signal then there should be a system variable attached to it. IIRC they should be the same for your control. #1000-#1035 are input signals corresponding to UI000-UI031. #1100-#1135 are the output signals corresponding to UO000-UO001.

    Stevo

  7. #7
    Join Date
    Dec 2008
    Posts
    8
    I will start at the beginning. We have a high volume production shop with about 55 miyano's. Actually I'm going to modify the ladder so that when an operator opens the chuck with the foot pedal it will turn on a relay (internal or a physical output), I have an m-code that will turn it off when needed. We drill and then ream a hole in the center of the part. Operators have to check the drill size numerous times a day. We use M1 as an optional stop so when the operator needs to check the drill size they just turn on the M01 button. They are supposed to check the drill size with the part in the chuck and just hit cycle start and go. Unfortunately sometimes they take it out and replace it with a raw blank (non drilled) part and start up the program (without resetting it). A reamer doesnt fair well without first having a drilled hole to follow, causing a crash and the loss of a $300 reamer.I would like to call a macro after the M1 line in the program, the macro would use an IF statement to check the status of the relay to see if the chuck was opened, if so then it would zero return the machine and reset the program resulting in no crash and saving me lots of money. I can modify ladder programs but have little experience with looking up system variables or anything of that nature in the main program. If I can look up a system variable that had a given "D" address then that would be fine. I just dont know what commands to use or what system variable corresponds with what relays or "D" address from the ladder. Thanks for any input you guys have.....

  8. #8
    Join Date
    Oct 2003
    Posts
    45
    Do it all in ladder:


    Inhibit Chuck Open:

    Cycle start sets an R flag=1
    R flag=1 inhibits chuck open


    Enable Chuck Open:

    Call Custom Defined Mcode at end of program sets R flag=0
    MDI Custom Defined Mcode to set R flag=0
    Optional - Reset logic to set R flag=0

    Del

  9. #9
    Join Date
    Aug 2008
    Posts
    97
    the program can both read and write to the ladder using the #1000 to read and the #1100 series to write conditions to the ladder. an example is if you would like to read say the skip signal x4.7 you would put this input to a G54 or G55 bit 0-7 coil in that ladder at this point you can monitor the input signal. Some machines have some addresses preassigned to these coils. Check your ladder for any G54 or G55 coils. If not then this can be done with a very simple ladder edit. I some automated machines in the shop that have complex ladders and programs where they talk between each other. If you need any help with ladder edit I could help as i have written several ladders. Oh and the read variables start at #1000=G54.0 #1001=G54.1 then progress untill you get to g54.7. The write ones are an F address but i would have to double check before telling you as i don't use these much

  10. #10
    Join Date
    Dec 2008
    Posts
    8
    After checking, I have open coils in the ladder that have nothing assigned to them, starting at G055.2 through G055.7. I could essentially turn one of these on (and latch it on) if the chuck has been opened and use a spare M-Code to just turn it off. Then inside a macro I could use and IF statement to check the status of that coil? The problem I have is I know very little about Fanuc controls and the language used in them to access these coils. I can do normal programming for the CNC and modify the ladder, just no experience with custom macros with Fanuc. What is the difference between the G coils and D coils? Can you check the status of both types or just the G? Thanks you guys are a great source of knowledge...

  11. #11
    Join Date
    Dec 2003
    Posts
    24221
    G registers in the ladder are registers for the PMC to communicate with the CNC side via the BMI, (Basic Machine Interface), G are sent to the CNC side from PMC, F are sent from CNC to PMC.
    R are internal general purpose registers.
    The G & F have pre-asigned functions as spelt out in the connection (BMI) manual.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

  12. #12
    Join Date
    Aug 2008
    Posts
    97
    yes you could use these addresses. But you would have to asign an input rather internal in the ladder with an R address or an external x address to turn this coil on or off. Never make any ladder edits with out verifying everything several times. As for the macro programming one thing about Fanuc is they give you everything you need but don't tell you how to use it for your application. If you have or can get the PLC programming manual and the macro programming manuals its all there. As for the language you will be looking for if say G54.0 is #1100 variable in your program if #1100=1 it is high and is turned on if #1100=0 it is not. So you can in one line check the status and then set your conditions whether it be jump to the next line or set up a custom macro alarm. Some of these alarms set the machine to Feed hold and some can e-stop the machine. you have to decide how to proceed from there.

  13. #13
    Join Date
    Jun 2008
    Posts
    1511
    You have the ladder guys on it now to help you find or setup the system variable that you need. Once this is done the code is very simple. We will do your main program where the M1 is that stops the program so the guys can check the drill size. We then will setup a subprogram to call and check the status of the chuck. You will also need the M-code to deactivate.

    These are just examples to use for programming purposes.
    O0001 main program
    O9000 subprogram to check chuck
    #1100 if =1 is high, chuck has been opened.
    M123 deactivate status of #1100 from 1 to 0

    O0001

    M1(CHECK DRILL SIZE)
    M98P9000
    …(code to ream hole)

    N999M30

    O9000
    IF[#1100EQ1]GOTO200
    M99
    N200M123
    M99P999

    So if you read it through program 9000 gets called after the M1 and if #1100 is equal to 1 then the chuck has been open and in program 9000 it will jump to N200 and read your M123 which will deactivate #1100 and with M99P999 it will return to program O0001 but skip to address N999 which will end your program bypassing the reaming operation. Now if program 9000 were to run and the chuck was never open then the program will not jump to N200 but will simply read the next line which is a standard M99 and will end program 9000 returning to program O0001 and read the next block which is reaming the hole.

    Stevo

  14. #14
    Join Date
    May 2008
    Posts
    19

    Relay Status

    If you need to know the true relay status, the best method would be to measure the voltage across the contacts and feed it into a spare controller input. You will most likely have to condition the signal for the input. That is the only true status. Checking the coil voltage or software command only tells you that the relay has been commanded. If the relay has failed, command status won't tell you.

  15. #15
    Join Date
    Mar 2006
    Posts
    167
    Would it not be easier to change the ladder to either open chuck with pedal gives reset signal, or better still, pedal is disabled unless reset signal is active? Either way, the program will be reset when the chuck is opened.

    regards, Oz

  16. #16
    Join Date
    Dec 2008
    Posts
    8
    OK I have my ladder modified now and will be turning on G0055.2, which address corresponds to this one. One person said it started at #1000 and another person said it started at #1100. Thanks, Steve

  17. #17
    Join Date
    Dec 2003
    Posts
    24221
    #1000- relates to status of physical inputs, #1100- to physical outputs status.
    Al.
    CNC, Mechatronics Integration and Custom Machine Design

    “Logic will get you from A to B. Imagination will take you everywhere.”
    Albert E.

Similar Threads

  1. Using a solid state relay as a main stop relay
    By garagefela in forum CNC Machine Related Electronics
    Replies: 4
    Last Post: 02-26-2010, 11:27 PM
  2. How to monitor pin status?
    By DustToDust in forum LinuxCNC (formerly EMC2)
    Replies: 1
    Last Post: 09-18-2009, 05:23 PM
  3. status bar mx3
    By fenix728 in forum Mastercam
    Replies: 6
    Last Post: 03-26-2009, 03:06 AM
  4. status bar
    By miltonmorales in forum Mastercam
    Replies: 8
    Last Post: 02-04-2008, 10:56 PM
  5. What is the status of the new 3016FX?
    By ltmquik in forum Fadal
    Replies: 0
    Last Post: 04-10-2007, 06:08 PM

Posting Permissions

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