Hello Guest it is June 04, 2023, 12:07:55 AM

Author Topic: Time Log-File Macro  (Read 3195 times)

0 Members and 1 Guest are viewing this topic.

Time Log-File Macro
« on: December 10, 2012, 05:59:58 PM »
Hi BR549 or is it Terry? or both

Back in 2009 you posted a macro to record time date etc and log it.
I have just finished building a tangential cutting machine for cutting composite materials.

I would like to record the time that the machine uses the cutting knife so I can get some indication of when to change the knife, before it becomes to blunt.

The machine also has a pen to write on each part.
Both the pen and knife are controlled by separate air cylinders and I am using the mist control and flood control to control each on.

When I need to use the pen plus the knife I use M7 for the 1st part of the G-Code program (all the letters and numbers etc) M9 to turn it off then in the cutting section of G-Code I use M8 which activates the Knife. At the end of the program before the M30 I again use the M9 code.

What I would like to achieve in the log is as your march 28 2009 post is all of the details you had included but a separate section for both the knife and pen.

Some times I will run the knife only or just the pen only.

I would also if possible like the data to be sent to an excel file.

Also if it it not too difficult after the data is written or "printed" in the  file another macro will close Mach3 and shut the computer down.

I would like to have the Macro's available to just add into the G-Code file either automatically when I program it or add it. I am using Cambam to generate the G-Code.

Some years ago I downloaded and used a program called ExportXL which I used to export data from Autocad straight into excel.  It was written by a programmer from Greece and it it is brilliant. I may be able to ask him for some help if need be about getting  into excel but need to get the basics and starting point first.

I have been able to understand some macro's and write a few in excel but having some difficulty in the Mach 3 macro's.

I have read many of your posts and see that you are a bit of an expert at macro's and Vbasic

I am having second thoughts about the M30 closing down mach 3 and computer so don't worry about that

Thanking you and looking forward to reading your reply

Evan Thomas

Offline BR549

  •  6,965 6,965
    • View Profile
Re: Time Log-File Macro
« Reply #1 on: December 10, 2012, 08:25:47 PM »
Well I don't know about expert BUT I am persistant and my Wife says Stubborn so maybe that is GOOD?BAD? (;-) . You are in luck I do something similar for plasma.  Try this approach. You will have to add code to the MACROPUMP or IF you do not have one create one. Same with the M1030 macro. The M30 activates the M1030 at file end.

What it all does is this IF the M7 or M8 is active Mach3 will start a timer for the length of time each are active. When the M7/8 functions are shut down Mach3 will retreive the time on the timers and post it to DROS for holding. Each time the M7/8 functions are restarted the timers start again,etc,etc. and the time is added to the holding dros.

At the end of the program when the M30 runs it calls the M1030 macro to transfer the values from the DROs to the FIle . The entry consists of the Date,Time,Filename,Pentime,&KnifeTime. It is written in comma delimited ascii so excell can read it in. Then the Dros are Zeroed and reaady to go again.

********** ADD to the MacroPump. IF you do not have a macropump create one

'Macro for pen/knife cut time

If GetOemLed(12) And Not GetUserLed(2007) Then
   End If
If Not GetOemLed(12) And GetUserLed(2007)   Then
   SetUserDro(2007, (GetUserDro(2007) + GetTimer(1)))
   End If
If GetOemLed(13) And GetUserLed(2008) = False Then
   End If
If Not GetOemLed(13) And GetUserLed(2008) Then
   SetUserDro(2008, (GetUserDro(2008) + GetTimer(2)))
   End If

******** ADD to the M1030 macro. IF you do not have one create one

'M1030 Macro For CutTime Write
Open "C:\Mach3\CutTime.txt" For Append As #1
Print #1, "" &Date &" , " &" " &Time &" , "&" " &Filename &" , " &"PenTime"  &" , " &GetUserDro(2007) &" , "&"KnifeTime" &" , " & GetUserDro(2008)
Close #1

******** Add to END of the M1030 macro to shut down mach3 and PC****** OPTIONAL (;-)

 Message("...Shuting down MACH3 and PC...")