586,655 active members*
2,998 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > G-Code Programing > Using a system variable (time) to start a program
Page 1 of 2 12
Results 1 to 20 of 24
  1. #1
    Join Date
    Jan 2007
    Posts
    52

    Question Using a system variable (time) to start a program

    OK guys,
    I have two machines, one is a Kitamura HX500i and the other is a Makino A51. I need to run a warmup program for the axis and the spindle for atleast 30 minutes prior to production to ensure all the axis and the spindle is warmed up enough to produce parts with consistency. We have seen as much as .003" change in dimensions from running a part with the machine "cold" and after running a warm-up program for a period of time. We have a down time of approx 4 hours between 2nd and 1st shift (2am to 6am) and want to try to get a macro program to start a program at a set time (lets say 0500 hrs everyday).

    I was thinking of maybe having the operator start a program at the end of 2nd shift, or incorporate a macro to start the warm up if the machine sits for a set period of time waiting (i.e. when the operator leaves at the end of 2nd shift with the pallet #2 ready to go, it goes in normally, but when that done, the machine will just sit waiting on the pallet ready button to be pressed for the pallet #1 to go back in, but as the operator has gone for the day and pallet #1 still has finished parts so dont want to rerun over it, the machine just sits waiting).


    Is this possible? What variables would I look at?


    Thanks,
    Jake

  2. #2
    Join Date
    Sep 2010
    Posts
    1230
    Quote Originally Posted by Jake E. View Post
    OK guys,
    I have two machines, one is a Kitamura HX500i and the other is a Makino A51. I need to run a warmup program for the axis and the spindle for atleast 30 minutes prior to production to ensure all the axis and the spindle is warmed up enough to produce parts with consistency. We have seen as much as .003" change in dimensions from running a part with the machine "cold" and after running a warm-up program for a period of time. We have a down time of approx 4 hours between 2nd and 1st shift (2am to 6am) and want to try to get a macro program to start a program at a set time (lets say 0500 hrs everyday).

    I was thinking of maybe having the operator start a program at the end of 2nd shift, or incorporate a macro to start the warm up if the machine sits for a set period of time waiting (i.e. when the operator leaves at the end of 2nd shift with the pallet #2 ready to go, it goes in normally, but when that done, the machine will just sit waiting on the pallet ready button to be pressed for the pallet #1 to go back in, but as the operator has gone for the day and pallet #1 still has finished parts so dont want to rerun over it, the machine just sits waiting).


    Is this possible? What variables would I look at?


    Thanks,
    Jake
    Hi Jake,
    Yes its possible, but it would require modification to the PMC program, or a relay that is controlled by one of the interface signals, to effectively press the pallet ready button. Post back if you want to get involved with that and I or other Forum members will be able to explain.

    Regards,

    Bill

  3. #3
    Join Date
    Aug 2011
    Posts
    2517
    if the machine is left running after the operator leaves it should be possible as long as the machine has not got to the M00 or APC wait command.
    you could have a macro time check at the end of the program that checks the time and if after 2am (when no one is there) then sit there and wait until 5am then run a macro that does a warmup.
    if not between 2am to 6am it skips the macro warmup and runs as per normal.

    Initially I'm not thinking of it in CNC Macro terms, more in very rough pseudo-code computer programming terms.
    Basically just ideas. something like.....

    Let's say the time is 2:48am when the machine reaches the end of the program.....


    Function (convert_current_time_to_decimal)
    Begin
    A = hour macro variable (e.g. 02)
    A = A + 100 (=200)
    B= minute macro variable (e.g. 48)
    C= A+B (248)
    End

    (Skip Normal Working Hours)
    IF C > 600 GOTO 100 (i.e. any time from 6am to 23:59, operator there working)
    the next line is only read if time is between 000 (midnight) and 1:59am (159)
    IF C < 200 GOTO 100 (i.e. operator is still present and working)
    the next line is read if time is 2am or after

    (Time is now after 2am)
    IF C > 200 THEN
    WHILE C > 200 AND < 500 DO1
    DWELL 60 seconds (i.e. G04 U60.0 or whatever time period you want)
    Convert_Current_Time_To_Decimal (this calls the above Function)
    C = C (i.e. set old time value to current time value)
    END1
    RUN warmup
    100 END


    *edit*
    Adding a rough macro. The manual says time is one variable (#3012). I had previously thought each component (H:M:S) was separate. This makes it even easier as the time variable is a decimal number.


    The actual macro might look like this..... (Note I have not checked if this runs nor have I check the formatting for the IF or WHILE). The theory is solid though


    %
    O0001
    (normal program here)
    ......
    ......
    M98 P9000 (call macro. check current time variable and run warmup program when time is after 5am)
    M00
    (APC command here or whatever is called to keep the machine going on the next pallet)
    M30

    %
    O9000 (time check)
    IF [#3012 GT 060000] GOTO 100 (i.e. any time from 6am to 23:59, operator present. #3012 within range 060000 to 235959)
    IF [#3012 LT 020000] GOTO 100 (i.e. operator is still present and working. time between midnight and 2am. #3012 within range 000000 to 015959)
    IF [#3012 GT 020000] THEN (time is now after 2am but before 6am)
    (not sure of the exact formatting for a double WHILE check with an AND.....)
    WHILE [#3012 GT 020000 AND LT 050000] DO1
    (maybe WHILE [[#3012 GT 020000] AND [#3012 LT 050000]] ??)
    G04 U60.0 (wait 1 minute or U600.0 wait 10 minutes etc.)
    END1
    M98 P0002 (call warmup program)
    N100 M99
    %

    %
    O0002 (warmup program)
    (some warmup stuff here)
    .....
    .....
    M99
    %



    I pulled this out of my ass. Be kind with your comments and corrections

  4. #4
    Join Date
    Jan 2007
    Posts
    52
    Thanks guys,
    I will be looking into it today, hopefully the program idea by fordav will work for me.

    Again, thanks and will post up status later.

    Jake

  5. #5
    Join Date
    Aug 2011
    Posts
    2517
    I ironed out the bugs.
    I still couldn't get the WHILE with AND working on the machine just an alarm
    (125 FORMAT ERROR IN MACRO) but not really needed anyway.
    Two nested WHILE's will do the same thing.
    This is tested and works....

    %
    O9000 (CHECK TIME / RUN WARMUP)
    #100=20000 (START WAITING)
    #101=50000 (START WARMUP)
    #102=60000 (END WAITING)
    #103=#3012 (TIME WHEN THIS MACRO STARTS)
    IF [#3012 GT #102] GOTO 100 (AFTER 6AM)
    IF [#3012 LT #100] GOTO 100 (BEFORE 2AM)
    IF [#3012 GT #100] THEN (AFTER 2AM)
    WHILE [#3012 GT #100] DO 1
    WHILE [#3012 LT #101] DO 2
    G4 U1.0
    #100=#3012
    END 2
    END 1
    M98 P0002 (RUN WARMUP PROGRAM)
    N10 M00
    M99
    %

    The way it works is the start time is checked and if not within the range 2am
    to 6am it jumps to N10
    #100 is checked and the outer loop (DO 1) starts
    #101 is checked and the inner loop (DO 2) starts.
    #100 is re-used and counts up every second because of the dwell.
    The current time is getting closer to the warmup time (#101) each second. Because
    #100 is getting larger every second as well the current time eventually becomes
    equal to #100 which ends the outer loop (DO 1) at the same time as the inner loop
    ends (DO 2)
    At that point the M98 is read.

    The added variables at the top allow you to watch (or debug) the progress by
    monitoring the variables on the macro variable page.
    #103 is there purely to see when the macro actually started (assuming the
    machine was running when everyone went home #103 = the time when the
    PALLET of parts was completed.

    Note the time format. it's 24 hour military time etc.
    020000 is 02:00:00 (2am) but the leading zeros are truncated so 2am = 20000.
    6am = 60000.
    3:30pm is 153000.
    etc

    By changing #100,#101 and #102 and the IF checks you can get this to start
    any time you want or skip it entirely.

  6. #6
    Join Date
    Feb 2006
    Posts
    1792
    Quote Originally Posted by fordav11 View Post
    ...
    WHILE [[#3012 GT 020000] AND [#3012 LT 050000]] ??)
    ...
    AND would work as intended provided parameter 6006#0 is set to 1.

  7. #7
    Join Date
    Aug 2011
    Posts
    2517
    that's interesting. thanks for the info.
    6006 is not listed in my manual (Fanuc Series 21i Model A Parameter Manual B-63090EN/01)
    an older 18 series manual has it listed. It disables all logical operations!

    my parameter is set to 0.
    I will test this next week and report back....

    I also discovered it is listed in the later revision B-63090EN/02 parameter manual.

  8. #8
    Join Date
    Feb 2006
    Posts
    1792
    See the attachment for more details.

    Fanuc gives ample scope to confuse the users. I cannot see any utility of this parameter except to keep CNC forums going.
    Attached Files Attached Files

  9. #9
    Join Date
    Aug 2011
    Posts
    2517
    I tried it again after changing parameter 6006.0 to 1
    It still gives an alarm: 125 FORMAT ERROR IN MACRO

    I even tried something simple like
    WHILE [#100 AND #101] DO 1

    same alarm.

  10. #10
    Join Date
    Feb 2006
    Posts
    1792
    Quote Originally Posted by fordav11 View Post
    WHILE [#100 AND #101] DO 1
    This syntax is not correct.
    #100 and #101 should be replaced by conditional expressions returning TRUE or FALSE.
    What other syntax you tried?

  11. #11
    Join Date
    Aug 2011
    Posts
    2517
    I'm not really trying to evaluate anything to true or false. I just want to do one calculation AND another calculation until they are LT or GT something else then exit the WHILE

    This is what I tried. it doesn't work.
    WHILE [[#3012 GT 20000] AND [#3012 LT 50000]] DO 1

    at this point is doesn't really matter because I solved the initial problem using two WHILEs
    it's more of a curiosity now

  12. #12
    Join Date
    Feb 2006
    Posts
    1792
    Quote Originally Posted by fordav11 View Post
    ...
    This is what I tried. it doesn't work.
    WHILE [[#3012 GT 20000] AND [#3012 LT 50000]] DO 1
    The syntax is correct. I am clueless as to why this gives format error.
    Please try this and check if it works:
    #1 = #3012;
    WHILE [[#1 GT 20000] AND [#1 LT 50000]] DO 1;

  13. #13
    Join Date
    Aug 2011
    Posts
    2517
    tried your example and got the same alarm

  14. #14
    Join Date
    Feb 2006
    Posts
    1792
    As I said, I am clueless.
    Please excuse me for wasting your time, but please try this also:

    #1 = #3012; (no change)
    ; (insert semicolon in a new block)
    WHILE [[#1 GT 20000] AND [#1 LT 50000]] DO 1; (no change)

    The idea is to see if buffering (and immediate execution) of macro statements has to do anything with this, since #3012 continuously updates. An extra semicolon would prevent buffering.
    If this also does not work, please execute block-by-block and see what valve is stored in #1 just before WHILE block.

    Learning never ends!

  15. #15
    Join Date
    Jan 2007
    Posts
    52
    here is what we came up with...


    /GOTO1234
    #149=5.0000(TIME FOR START DECIMAL)
    #130=#3012(ACTUAL TIME)
    #131=#130/10000(gives hour only)
    IF[#131LT12.00]GOTO6666
    #149=#149+24.00(if stop time is 2100hrs, then we add 24 to 5 for calculation purposes)
    N6666
    #132=ROUND[#131]
    IF[#131GE#132] GOTO 4444
    #132=#132-1
    N4444
    #133=#131-#132(FRAC MIN & SEC)
    #133=#133*100 ()
    #134=ROUND[#133]
    IF[#133GE#134]GOTO5555
    #134=#134-1
    N5555
    #135=#134*60(MIN IN SEC)
    #136=#132*3600(HRS IN SEC)
    #137=#135+#136
    #149=#149*3600
    #138=#149-#137
    G4X#138
    #3000=100(START WARM UP)
    M98P2010L3
    M30

    N1234
    M99


    we tried and it works well.

    We added the M30 after the warmup so the operator can make sure the next pallet is ready to go.

  16. #16
    Join Date
    Aug 2011
    Posts
    2517
    just curious did you try my version with the WHILE's?
    I tested it and it works fine too and is less complicated

  17. #17
    Join Date
    Jan 2007
    Posts
    52
    We were going to, but the only issue was that sometimes we wont have a second shift operator, and also it lets us have the machine dwell over night on the weekend shift until 5am then it starts the warmup.

  18. #18
    Join Date
    Jun 2008
    Posts
    1511
    Quote Originally Posted by Jake E. View Post
    We were going to, but the only issue was that sometimes we wont have a second shift operator, and also it lets us have the machine dwell over night on the weekend shift until 5am then it starts the warmup.
    Sorry for jumping in guys as I skimmed thru most of the code in the posts.

    Jake are you saying that you are running a program thru the entire night, every night in a dwell mode?? Or I should say that is your intention?

    Stevo

  19. #19
    Join Date
    Aug 2011
    Posts
    2517
    it's intended. he wants the machine to warmup on a morning before anyone comes in to work. if no one works weekends he still wants the machine to warm up early Monday morning. Please read ALL of it if you want to usefully contribute to the discussion rather than create more questions where the answer is just above in previous posts.......

  20. #20
    Join Date
    Jun 2008
    Posts
    1511
    Ford,
    I did read ALL of it before I posted. I just did not read it word for word. This is not the only forum that most of us are in. Reading every post every word across many threads that you are helping in is not going to happen.

    The reason I am asking the question is because it is not a good idea to leave the machine on and out of Estop 24/7.

    And as to your comment…..that is why I “Quoted” a remark from Jake rather than just throwing out some random question or comment. This isolates everything and saves on confusion. Also if I am not mistaken….wait, let me check….oh ya I did apologize right in the first words of my post. I will apologize again for adding confusion as I guess I just ass u med that a simple question would not have confused you but I must have been mistaken.

    I am now curious…. Jake, Bill, Sinha. Where any of you confused with my question in post #18??

    Stevo

Page 1 of 2 12

Similar Threads

  1. Dry-run system variable?
    By machzero in forum Okuma
    Replies: 12
    Last Post: 05-21-2015, 01:13 PM
  2. Replies: 1
    Last Post: 11-17-2011, 03:38 PM
  3. Replies: 0
    Last Post: 12-27-2010, 09:55 AM
  4. okuma time variable
    By Bala in forum Okuma
    Replies: 1
    Last Post: 11-28-2007, 11:55 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
  •