Hello Guest it is April 16, 2024, 08:56:52 AM

Author Topic: Percent Complete  (Read 7653 times)

0 Members and 1 Guest are viewing this topic.

Percent Complete
« on: December 01, 2007, 10:54:11 AM »
Is there a way to determine what percent of the g-code has run?  (i.e.  current line / total lines * 100).  I would like to make large display that I can see from across the room that gives me a rough idea how far I am through the job.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Percent Complete
« Reply #1 on: December 01, 2007, 11:49:06 AM »
yes,

you could enter into a usrdro (drop it on the screen), the last line number of your program, Then in the macro pump do a x=Getoemdro(currentline) you will need to look up the dro number, then say y=getuserdro(where you entered the last line), The formula in teh macropump would be:    percentrun= ((x/y)*100) Then also put another user dro on your screen that will display the amount compleated send the rusult to this dro on the screen: SetUserDro(mydronumber, percentrun). so you will need to add two user dros to the screen.

enable macro pump and restart mach, you will have to use line numbers.

scott
« Last Edit: December 01, 2007, 11:50:48 AM by poppabear »
fun times

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Percent Complete
« Reply #2 on: December 01, 2007, 07:25:49 PM »
Cant help but think Brains would be better then the Macropump and there is a automated way to get the last line of Gcode or total file size...

Nice thing about this is in Flash we can display bar graphics or images to display amount completed and invoke scripts once at any point.

Here is the standard Mach3 1024.set modified with a page that has a large toolpath and DRO displaying amount completed.
Also included is the Macropump file, remember to turn on your macropump in the config page.

Code: [Select]
filesize = GetOEMDRO(1200)
filecurrent = GetOEMDRO(816)

'=== Get percent ===
  completed = ((filecurrent / filesize) * 100)
  Call setuserDro(1201,completed )
Re: Percent Complete
« Reply #3 on: December 02, 2007, 09:30:54 AM »
Thanks for the help, but it is not working.  The macro gets a divide by zero error as soon as mach loads.  I surrounded the calculation with "If filesize <> 0".  That stopped the error, but it appears filesize is never non zero because the DRO never changes.  I am having trouble finding documentation on the codes.  Where do you find the code to get the filesize?

Offline Bodini

*
  •  216 216
    • View Profile
Re: Percent Complete
« Reply #4 on: December 02, 2007, 09:53:47 AM »
Funny, i was thiking about this same thing just this week.  current line of code / # of lines of code isnt a real indicator of progress.  Unless the code is uniform in how long the machine takes to do it, it could be way off.  What if the code is g0x0y0, g1x20f20, g1y1?  See what i mean?  Its going 20 units, then 1, but it would read 50% done when it was actually like 95%!

I know, i know, you wanted a rough way to tell.

Maybe dro (814)/(815)?  you'd have to dobutton (1015?) first though to get the estimate established.

-Nick

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Percent Complete
« Reply #5 on: December 02, 2007, 01:37:47 PM »
Bdring, Do you have two DRO's 1200 and 1201 in your screen somewhere? You'll have to enter the total number of lines on the "Program Run" page in the screen set I posted....you shouldn't get that error unless you don't have the DRO's displayed in your screen somewhere.

Hey Nick yeah I see what you mean that's totally true...I bet the best result would be to get the total distance the machine has to travel and the current machine speed to give an accurate percentage
« Last Edit: December 02, 2007, 02:02:02 PM by zealous »
Re: Percent Complete
« Reply #6 on: December 02, 2007, 06:01:53 PM »
Thanks...I did not see that DRO to enter the total number of lines. 

It works now, but the If statement is needed to prevent the error on start-up.

I knew the issue of accuracy would come up.  I really don't care if it is very accurate.  I just want to get an idea of when the end is near.  I ran a few files today and found the line count method appears to be more accurate than the estimate method on my files and setup.  I also really only care if 90-100% area is accurate.

I tried to add button to get the file length with the following VB code.

Code: [Select]
Dim I
Dim textLine

Open "c:\mach3\gcode\roadrunner.tap" For Input As #1

While Not EOF(1)
Line Input #1, textLine
I = I + 1
Wend

Close #1

Call setuserDro(1202,I)
   


It works, but I need to know how to get the filename automatically.

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Percent Complete
« Reply #7 on: December 02, 2007, 07:33:40 PM »
WOW bdring nice job!!!

Here you go this will work :):

Code: [Select]
Dim I
Dim textLine

Open FileName For Input As #1

While Not EOF(1)
Line Input #1, textLine
I = I + 1
Wend

Close #1

Call setuserDro(1200,I)

You can put this along side the "Load Gcode" button but....I think that the VB "load Gcode" is spitting an error...we'll have to report it to Art if any one else is getting this as well...
« Last Edit: December 02, 2007, 07:44:48 PM by zealous »
Re: Percent Complete
« Reply #8 on: December 03, 2007, 08:39:25 AM »
Excellent...that did it.  In case it does not show...this is my first day tweaking Mach.  I am a seasoned programmer, but I am having difficulty tracking down some of Mach's finer details.   

I am not sure what you mean with the "load GCode" button.  I was trying to redo the Load button so it loads the file then calculates the length.  It tried a DoOEMButton(216), but it would hang on a part generation dialog box.

Anyway...I decided to try to take it one step further.  I programmed a quick PIC chip to output a byte received on the serial port to a pair of seven segment LEDs. 
I got Mach to output on the serial port the percent remaining.  I changed the value to an integer and tested it for change to prevent it from sending it too often. 
I assumed an unused SetVar number to hold the value.  I could not find details on what numbers to use. 

I found some cheap huge LEDs at www.futurlec.com.  I will use them if everything proves reliable and useful.


Code: [Select]
filesize = GetOEMDRO(1200)
filecurrent = GetOEMDRO(816)

'=== Get percent ===
If filesize <> 0 Then
completed = CInt((filecurrent / filesize) * 100)   
Else
completed = 0
End If 

If GetVar(2002) <> completed Then
Call setuserDro(1201,completed )
SendSerial(Chr(completed))
Call SetVar(2002, completed)
End If

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Percent Complete
« Reply #9 on: December 03, 2007, 12:24:25 PM »
bdring,

   Here was what I was talking about, download the zip file, I used an old screen set as an example, it is called    "1024percent.set"
on that screen you will see two dros above the Reset button. in the top dro is where you enter in the total number of lines in the file.
NOTE: that if you use the standard convention of numbering the lines by 10's then you will need to divide the last line by 10. The current file line execution dro numbers what line your on by its actual line number.

At any rate put in the last line number in the last line number dro and hit enter.

House keeping:  First put the macro pump  I sent you called "macropump.m1s" into the macro directory of the profile you are running, then under the configuration>general tick the run macropump box, and tick persistant dros. Also put the above screen set in machs main directory.

close and restart mach.

you will goto the file menu, and load your G code, then put in the last line number in the last line number dro, and hit enter, now hit cycle start, you will see the Percent Dro updating as Mach runs.  (remember to divide the last line number by your line number increments if you going by anything other than n1, n2, n3, ...etc.

Scott

fun times