Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Baumeister25 on May 01, 2010, 05:28:45 PM

Title: Time estimation until tool change
Post by: Baumeister25 on May 01, 2010, 05:28:45 PM
Dear all,

due to the fact that i run quite long tap files and dont have a automatic tool changer on my mill i would like to know how long the estimated time
until the next tool change is. I didnt find much in the forum about that topic. Could somebody give me a hint how such a macro could look like?
Great would be of course to have a DRO which shows the time until next tool change and which is updated every minute or so. Possible?

Thanks in advance for your ideas and support!

Wolfgang
Title: Re: Time estimation until tool change
Post by: stirling on May 04, 2010, 07:27:52 AM
Hi Wolfgang - not sure how you'd do this and as no one else has come up with a solution...
I remember reading somewhere how you could come at it from a different angle. Stick a mobile phone somewhere appropriate on your rig and a "finger" somewhere on your Z assembly. Pre set a text and toolchange gcode to hit the send button. Now your mill texts you when it needs a toolchange - cute or what?  ;D

Cheers

Ian
Title: Re: Time estimation until tool change
Post by: Baumeister25 on May 04, 2010, 03:16:59 PM
Hi Ian,
yeah, cute! :-* I already thought my question is so unbelievable good that nobody
has a solution. But i see you are creative. Unfortunately my wife always demands that
i know in advance when i need to go back to basement to my cnc......how to do?  ???
Still hope somebody can help me to find out in advance when i have the next meeting with my
cnc to change the tools!
Thanks!!!
Wolfgang
Title: Re: Time estimation until tool change
Post by: BR549 on May 04, 2010, 04:45:59 PM
I have looked through all my notes and don't have a solution. The only way to know when the next tool change would be is to let mach do an TIME estimate based on the gcode(feedrate * distance) to the next TC  THEN start a countdown timer running, BUT we don't have access to that info(;-).

That would need to be done at a pluin level OR the driver level.

You could use a digital Kitchen (http://en.wikipedia.org/wiki/Vance_Miller) timer and set it for each segment?

PS: It is not a new question(;-) that was asked several years back along with a countdown timer for program end.

THERE IS a process that mach does when loading a new program file that checks the code for errors before it loads. THAT would be a place to include the countdown timer calculation process. You would just have to convince Brian that it is a good idea.
Title: Re: Time estimation until tool change
Post by: stirling on May 05, 2010, 10:54:59 AM
The best I can suggest is that you turn off your controler, select auto toolchange in configs and modify the M6start macro. Then you can do a real time simulation run prior to your actual cutting which will record the time of the toolchanges. Not ideal but at least it is 100% accurate. (remember to switch back to manual toolchange before your real run)

here's a skeletal addition to M6start.m1s. I'll leave it to you to convert to HH:MM:SS

Open "toolchangetimes.txt" For Append As #1
Print #1, Timer & " " & getselectedtool()
Close #1    

Just don't let your wife see it she'll probably point out that it's not an optimal or ideal solution  ;D

Cheers

Ian
Title: Re: Time estimation until tool change
Post by: BR549 on May 05, 2010, 11:36:19 AM
HUM that is a good idea Ian. You could also just look at the TC led to use to trigger the time function as the program ran.

 I think I will ADD that routine to the JOB REPORT function that we run. It might be handy to know the spans between tool changes along with total run time of the job.

Then if really needed you could run a simple countdown routine that you plugged in the span times and it would allow you to see the countdown time LIVE.

You could also add a function to output to a relay so a TC warning alarm could be used say 5min BTC the flashing light/buzzer goes off to alert you to an upcoming TC.

(;-)
Title: Re: Time estimation until tool change
Post by: BR549 on May 05, 2010, 04:53:13 PM
OK it is possible to do a SOSO countdown timer BUT you would need to input each leg or devise a scheme to use #vars in the preamble of your GCode to set #vars with the TC times.

NOW to integrate it into looking at T#s and the M6start macro to do a tool count.

Title: Re: Time estimation until tool change
Post by: BR549 on May 06, 2010, 12:18:17 AM
The new WorkLog works with the new TC code.

Sample report:

"5/5/2010.....C:\Mach3\GCode\TestWorkLog.txt, StartTime 11:28:57 PM"
"__________ToolChange  T# 1 ,11:28:58 PM"
"__________ToolChange  T# 2 ,11:29:17 PM"
"__________ToolChange  T# 3 ,11:29:46 PM"
"__________ToolChange  T# 4 ,11:30:05 PM"
"          C:\Mach3\GCode\TestWorkLog.txt..........EndingTime11:30:26 PM"
"5/5/2010.....C:\Mach3\GCode\roadrunner.tap, StartTime 11:31:26 PM"
"__________ToolChange  T# 6 ,11:31:26 PM"
"__________ToolChange  T# 12 ,11:33:57 PM"
"__________ToolChange  T# 0 ,11:37:02 PM"
"          C:\Mach3\GCode\roadrunner.tap..........EndingTime11:37:10 PM"
Title: Re: Time estimation until tool change
Post by: BR549 on May 07, 2010, 02:07:17 PM
THis will do a basic Time to TC countdown based on times derived from the worklog it will ouput the countdown to either the message bar OR a user DRO you would create on the screen.

'Program Load,  Program The Vars to the TC time values derived from the WorkLog
#310 = 0      'Turns OFF Timer
#400 = 0      'Sets TC Var Holder to Zero
#401 = 10      'Start of the TC values 401 = 1st TC time
#402 = 2      '2nd
#403 = 6      '3rd
#404 = 0      '4th, etc

***************************
'M6Start (add too)
setvar(310,0)         'Turn Off Timer
SetVar(400,(Getvar(400)+1)      'Up the Tool# count
IF GetVar(400) = 0 Then End      'IF var value = 0 then end
IF GetVar(400) > 0 then SetVar(301,400)   'IF Var has a value then process
End   

***************************
'M6End (add too)
SetVar(310,1)      'Turn ON Timer
End

**************************
'M1030 End ( Create) , Is called by the M30/program end
Message" End Of Program Run"
SetVar(310,0)      'Turn Off Timer
'SetOemDro(1000,0)      'Reset Dro
SetVar(400,0)      ' Reset TC Vars to Zero
SetVar(401,0)
SetVar(402,0)
SetVar(403,0)
SetVar(404,0)
SetVar(405,0)
SetVar(406,0)
SetVar(407,0)
SetVar(408,0)
SetVar(409,0)
SetVar(410,0)
End

***************************
'Macropump (add to)
If Getvar(310)<>1 Then End      ' IF Timer is OFF then end
settimer(10)
SETvar(298,(GetTimer(10)))
setvar(299, (Getvar(299) + (GetVar(298)/60)))
Setvar(301, (Getvar(300)- Fix(Getvar(299))))
Message" Next TC Due In " &getvar(301) &"  Minutes"      'Use IF you use message bar
'SetOemDro(1000,Getvar(301))          'Use only if you use a DRO to display countdown
End   


Hope it helps,
Title: Re: Time estimation until tool change
Post by: Baumeister25 on May 09, 2010, 10:02:20 AM
Dear BR549,

i have some questions to your post. Sorry for the maybe stupid questions but i am not that experienced with macros yet.

1) Where do i get the "new WorkLog" Macros from?
2) When/how to start the "Worklog" Macros? Like a button which starts worklog and then directly the program run?
3) What do you mean with the "  'Program Load " part? What/how to create to get the
    TC times from the worklog inside the #40x variables? Do i manually need to input?
4) Is the M1030 macro automatically called if the program reaches the M30 line
    or do i need to change anything?

Thanks for your support!

Wolfgang
Title: Re: Time estimation until tool change
Post by: BR549 on May 09, 2010, 12:16:23 PM
OK Lets start with the Code for the WorkLog,

First create a new button on the main screen OR use an existing EMPTY button. I used the AutoToolZero button as it is NOT used. This button is used to START any program that you want logged. Just load your program and if you want it logged then Push the Button to start the program. It will turn ON the  LOG function and start the log. IF there is NO worklog.txt file  IT will create the file for you.

Next add in the M6start code to the M6start macro

NOW  create an M1030 macro. It will automatically be called by the M30 in the program. You must enclude an M30 and your program end for this to work.

Once you have started the program with the LOGFILE button you do not use it again until the next program start. To restart after the tool changes you do the standard cyclestart as you normally do.

IF you do not want to log the file then just use the Cycle start button. The M1030 will sense that you did not use the LogFile button and wil NOT add any info to the file.

******************************************************

'Macro ProgramRun use for start worklog code
Open"C:/Mach3/worklog.txt" For Append As #1
Write #1,"" & Date &"....." & Filename &"," &"StartTime " & Time()
Close#1
SetVar(499,0)
DoButton(0)
End

*******************************************
'M6Start Macro

  tool = GetSelectedTool()
  SetCurrentTool( tool )


Open "C:/Mach3/Worklog.txt" For Append As #1
Write #1,"__________ToolChange "  &  "T# " & GetSelectedTool() & "," & Time()
Close #1
End
 

*******************************************

'Macro M1030 use to build the M1030 macro that the M30 calls at program end

Sub main()
If GETvar(499) <> 0 Then End
If GetVar(499) =0 Then

Open "C:/mach3/worklog.txt" For Append As #1
Write #1,"          " &Filename &"..........EndingTime" & Time()
Close #1

setVar(499,1)
End If
End Sub 
 
*******************************************
WorkLog Sample Output

"5/9/2010.....C:\Mach3\GCode\TestWorkLog.txt,StartTime 12:01:42 PM"
"__________ToolChange T# 1,12:01:43 PM"
"__________ToolChange T# 2,12:01:55 PM"
"__________ToolChange T# 3,12:02:00 PM"
"__________ToolChange T# 4,12:02:05 PM"
"          C:\Mach3\GCode\TestWorkLog.txt..........EndingTime12:02:10 PM"

Hope that helps
Title: Re: Time estimation until tool change
Post by: Baumeister25 on May 13, 2010, 10:48:59 AM
Dear BR549,

thanks for your help. I can create the Worklog now (sample see below). But its running in real time, so for my programs
it would run 10h or so. How can i make the worklog creation running faster? Furthermore i need to click start after TC each
time.

"5/13/2010.....O:\Zeichnungen\BF20L_3Phasenmotor\lichtschrankenhalter.tap,StartTime 4:21:44 PM"
"__________ToolChange T# 8,4:21:45 PM"
"__________ToolChange T# 7,4:25:03 PM"
"__________ToolChange T# 14,4:26:37 PM"
"__________ToolChange T# 13,4:28:30 PM"
"__________ToolChange T# 8,4:32:51 PM"
" O:\Zeichnungen\BF20L_3Phasenmotor\lichtschrankenhalter.tap..........EndingTime4:41:53 PM"


Now i have the TC times inside the worklog file. How do i now get it used for the DRO? Shall i just add
the code from your post from May 7 and create a OemDRO 1000? In this case i need to manually input
the #401, #402... variables each time as far as i understand. Is it possible to read it out from the worklog or
in some other way that i dont need to input the times manually?

Wolfgang
Title: Re: Time estimation until tool change
Post by: BR549 on May 31, 2010, 02:04:12 PM
Sorry Wolfgang I missed your reply, Did you get it working??

Title: Re: Time estimation until tool change
Post by: Baumeister25 on May 31, 2010, 02:40:09 PM
Hi BR549,
somehow. Its working to create the worklog file. But it runs 10h in case of a 10h program.
Thats not what i really want.

Besides that i tried to directly write the times until next tool change
into the #40x variables. It works to write the TC times into the variables but when i click "CycleStart" to
really run the program the variables are all reset ...
Does Mach always reset all variables when i use "CycleStart"??

Wolfgang
Title: Re: Time estimation until tool change
Post by: BR549 on May 31, 2010, 02:45:15 PM
DID you mean 10hours in the case of 10 minute program??   OR do you mean you would like to run the program quickly to "GET" the TC times without having to wait the ten hours(;-)

NO mach does not reset vars automatically UNLESS you close down mach then only Vars#500-600 are persistant and are saved by mach.

 We can start from there IF you wish to continue. YOUR choice(;-)
Title: Re: Time estimation until tool change
Post by: Baumeister25 on May 31, 2010, 02:56:03 PM
I would like to get the TC times "quickly" without waiting 10h in case of a 10h program.

Ok. Maybe my programming error. Need to try again and check if i can find out why the variables where
gone after new CycleStart. I didnt close down Mach so it should work.
Title: Re: Time estimation until tool change
Post by: BR549 on May 31, 2010, 03:05:36 PM
OK I see what you mean by reset the VARs. In the M1030 routine, WHICH is automatically called by the M30,  it does reset the Vars back to zero. AS it thinks you are finished with the Program (M30 program end)

OR that can be changed to NOT reset the VARS(;-) at program end.

This process is assuming that your Vars were originally loaded from the Gcode file. IF you hand load the Vars from the MDI then you must do it each time you run the program.

UNfortunately it cannot PRE RUN the program Quickly AS mach does not have a function call to access any times from the preveiw routine like some other system have.

This routine ASSUMES that you have run it before and already have the times available.  Perhaps you can ask Brian to consider this function in the new MachV4.

Sorry for the confusion, (;-)
Title: Re: Time estimation until tool change
Post by: BR549 on May 31, 2010, 03:17:12 PM
Saying that, SOME cams can output those TC times as VARs in the original POST so they would be available.

We are working with LES over at SheetCam to do just that. SO in that case"Sheetcam" users would have that info available first hand and at first run of the program.

Title: Re: Time estimation until tool change
Post by: Baumeister25 on May 31, 2010, 03:26:30 PM
I use Pro Engineer as CAM. Need to check if i can get my post processor to tell me this times
and put it into the G code file...could be.

I think a countdown until next TC would be a good idea for the MachV4!
Title: Re: Time estimation until tool change
Post by: BR549 on May 31, 2010, 04:03:10 PM
I agree, YOU have a GREAT idea (;-)  Might want to drop your idea in the new features section.

(;-)