Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: dh42 on February 22, 2013, 04:15:21 PM

Title: Maintenance - box "Spindle On Time" is alway 0
Post by: dh42 on February 22, 2013, 04:15:21 PM
Hello,

In the maintenance windows, "Spindle On Time" never show other than 0  >:(

My spindle is a simple Kress on output#1 ... if I can get this counter to work, it would by very useful to manage the brush replacement  :)

Somebody know how to activate this counter ?

Sorry for my bad English  :-[
++
David
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on February 22, 2013, 04:36:04 PM
It does not work, never has.

(;-) TP
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: dh42 on February 22, 2013, 04:47:22 PM
Hello,

Ah OK ! ...  I thought I had forgotten to check a "box" somewhere ...

I'll look if there is a way to do something with the "brain" ... that I just discover  :-[ .. like a pop up alert ...

(on the Kress my brushes are "out" every ~ 200 hr if max RPM used)

++
David
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 01, 2013, 04:01:04 PM
I would LOVE to know if anyone has gotten this working, I really want to start tracking my spindle on time.  One suggestion I read was to wire up a simple clock that starts timing when M3 turns the spindle on, might be tricky since the spindle is 230v, but there's probably something out there.  Or use another output to turn on the clock along with the spindle.
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 01, 2013, 06:20:34 PM
IF you are running the LPT version it is possible. we use it to track torch on time .

(;-) TP
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 01, 2013, 10:09:53 PM
Doesn't LPT stand for the printer port?  So I don't get it. I've got a Tormach and am using the Tormach version of Mach3, but am not afraid to mess with it if I can get this to work.  Very cool that you can track your torch time.  Or is LPT a fancy screenset?
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 02, 2013, 09:54:56 AM
It is the printer port version. We can access the internal timer in mach3 that runs the printer port driver and use it to track time.

You can do this several ways one version uses a dro and a button ON SCREEN. The dro to veiw the time and a button to reset.

Another version uses button scripts to show the time when requested .

Another version uses macros that you can call from the MDI so no mods to Mach3 screens are required.

Basically it works this way. In the M3 macro you put in code to start the timer.  Then in the M5 macro you put in code to check the timeer and add the time to the running total.  So now you have a spindle run timer that can tell you how long the spindle has ran in HOURS or minutes or secs(;-).

If you tell me which way you need it I can lay out the code for you.

Just a thought, (;-) TP
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 02, 2013, 02:38:10 PM
Well aren't you just full of awesome today.  If it's not too much of a burden it would be very helpful if you could lay out the code.  I'm sure this could help a lot of people.  I did a bunch of googling and the only answer is basically your original one "It does not work, never has." ;-).

I think an on screen DRO/button would be slick, something small and simple enough that people can drop it anywhere using one of the mach editors.  Although I can see the appeal of an unobtrusive macro.  I want to set my e-mail calendar to notify me once a month and tell me to write down the spindle hours, so either way works for me.  

If possible set it to output "**** hours ** minutes", that should satisfy everybody.  Or just seconds and people can do their own math.  I'm easy, any help you can give would be awesome.  I've tweaked buttons and macros before but I'm not comfortable writing them from scratch yet.  

Cheers!
John
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 02, 2013, 10:04:19 PM
OK add this in your M3 macro

SetTimer(10)


Add this to your M5 Macro

SetUSerDro(2000, (GetUserDro(2000) + ((GetTimer(10) /60) /60)))


Place a USERDRO(2000) on your screen

Place a button on your screen next to the dro and add this to the button.

SetUserDro(2000,0) With a format of *********x.xx   


NOW as you work when the M3 is called it starts a timer, when the M5 is called it gets the time from the timer(10) and converts it to HOURS then adds it to the UserDro(2000) value.

When you need to zero the hours just press the button that reset the DRO to Zero.

That is all there is.

(;-) TP
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 04, 2013, 12:02:50 AM
Looks like it's working great, thank you!  Not too difficult to implement, I used Mach3Screen.exe to edit the .SET file.  Leaving the format as the default %+.4f works great and shows 4 zeros.

One slightly weird thing is that if you enter M5 multiple times it'll keep adding the timer to the DRO, whatever the time has been since you started it with M3.  I assume that "SetTimer(10)" is an arbitrary 10th timer available, is there a way to turn it off with M5?  Like a code that does the opposite of SetTime(10).  Google tells me KillTime(10) but that produces an error.  This is sort of a pointless bug because when are you going to enter M5 more than once, but it got me curious.  Also, I want to edit the reset button, escape key, and e-stop button to do the same thing that M5 does, that way the timer isn't counting for hours or days after a crash.  

Otherwise it does work fantastically well.  Humm, to make it even slicker I wonder if we can add a date field.  As in, XX hours since MM/DD/YY, hitting the reset button triggers the date field to update.

Thanks for the help, this is fun.
John
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 04, 2013, 12:25:08 AM
If I put this in the reset button:
SetUserDro(2003,Date)
it will output a setting to my date DRO but the format is weird.  Using the default %+.4f format it shows 41368.00 and today is April 04 2013.  If I change my computer date back one day it will display one digit lower as 41367.00.  So it seems to work, I just have to figure out the format.

I'm reading this page 76-80 but it's not really helping haha:
http://www.machsupport.com/docs/VBScript_Commands.pdf
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 12:57:30 AM
Instead of a dro use a UserLabel()

Set uP a userlabel on the screen say UserLabel(15)

Then code to add date,time

SetUserLabel(15,"" &Date &Time)

(;-) TP

Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 04, 2013, 01:36:45 AM
Can't get it to work.  In my Reset Hours button I have this:

SetUserDro(2000,0)
SetUserLabel(15,"" &Date &Time)

What do I call my Label, 15?  Doesn't work.  I tried calling it (15), UserLabel15, UserLabel(15), no dice.  I can't get any action to it.  Thoughts?
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: cncalex on April 04, 2013, 10:54:39 AM
Hi guys,
Quote
is there a way to turn it off with M5?
No. ( I think  ;D )

but you can add this to your sequence

If GetOemLED(11)=-1 then

bla bla bla ( your timer addition )

end if

Alex
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 11:02:25 AM
The label would be called UserLabel15 if you used the number 15 . It can be any number as long as the label# and call # are the same.

(;-) TP
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 12:22:17 PM
OK just tested some more and that was a bad plan, Mach3 does not SAVE userlabels to the XML on shutdown.

So plan B you would write the date to a file to hold and call it to screen in the intiation string so it views in the label when you start MACH3.

Just a bit more programming, (;-) TP




Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 01:34:16 PM
OK plan C (;-) Extract the Month, day, Year from the DATE as mm,dd,yy  then create a Interger as a string.
Then write the interger to a DRO(which IS saved)




It would look like this as an integer

040413    where mmddyy is the format

Yep I would do it that way so no file writing involved.

Just a thought, (;-) TP

Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 04, 2013, 02:18:38 PM
CNCAlex, this worked great!
If GetOemLED(11)=-1 then
   SetUSerDro(2000, (GetUserDro(2000) + ((GetTimer(10) /60) /60)))
End If
Now multiple M5's don't keep adding to the timer.  Which brought me to another thought, how can I "watch" the spindle LED GetOEMLED(11) so that when that turns off, it executes the same code as above?  That way an e-stop, esc key, Program Reset, etc will all turn off the timer so it doesn't keep running for hours or days because I never executed M5.

BR549, truly appreciate all the help.  I got the date to work as a label but just like you said Mach forgets about it upon restart.  What about this, instead of displaying the date, every time you hit the Reset Hours button it adds a note to a text document somewhere.  The line would say 42.2342 Hours on 04-04-13, and every time you clicked the reset button it adds another line.  This would be an easy way to log it without having to remember it all.  And it'll save us from accidentally resetting the timer halfway through the month without writing it down, cuz the file will have it all tracked.  So once a month, or just whenever you think about it, you can click the reset button and log the time since the last time you reset it.

Thoughts?  Hope I'm not asking too much here ;-)
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 02:44:32 PM
OK just to clear something up the timer is NOT really a run timer as per say. It just sets a flag and then compares 2-1=secs.  when Mach shuts down the function stops.

AND this will NOT work unless you are running the LPT version driver(;-) so if you are using a SS it will not work.

Just thinking ,I think this would work from the macropump and be an automatic Function done this way. It uses bypass functions so it does not ping the leds all the time. IF the function needs to change only then will it ping the LEDs.
At least I think , I have not tested it in real life for this function. Look like that is YOUR job now (;-)

If GetOemLed(11) AND Not GetUserLed(1000) then
       SetTimer(10)
      SetUserLed(1000,1)
End If

If NOT GetOemLed(11) AND GetUserLed(1000) then
       SetUSerDro(2000, (GetUserDro(2000) + ((GetTimer(10) /60) /60)))
        SetUserLed(1000,0)
End IF

Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 05:47:17 PM
OK for the DRO to store the date. It comes out as "040413" (no quotes), Make your dro with 6 leading values and NO trailing.

MyDate =  format(Date ,"mmddyy")
SetOemDro(2000,Mydate)


NOW you can track date and hrs on screen and it will stay persistant. SO NOW you want to write it to a file?

Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 06:19:55 PM
OK here is how to write the log file. This assumes that you converted the start date to an integer and store it in UserDro(2001) and the Spindle run time hrs is stored in Userdro(2000). Each time it write the the file it ADDS it to the end of the file.

It writes the LOG date(current date) the start date of the total and the total hours.

Open"C:/Mach3/Spindle_HRS_LOG.txt" For Append As #1
Print #1,"LogDate: " & Date &" StartDate: " & Format(GetUserDro(2001),"000000")  &" " &"Total Spindle Hours: " & GetUserDro(2000)
Close#1
End
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 04, 2013, 08:53:07 PM
OK you have gone this far might as well add TOOL cut time or inches to your list for tool wear tracking. there are 2 slots in teh tool table that are not being use by Mach3 you could store the tools cut time and Cut inches to the table (;-) then add a bit of code in the tool change macrop to WARN you when a tool is reaching a replacement point based on time or inches cut.

See where this leads (;-) Long night late into the wee hrs of the morning and just as the sun breaks  you realize it is still NOT done. There is MORE to add. LOL

(;-) TP
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: Vogavt on April 05, 2013, 09:48:45 AM
So can you put this all together in on listing of code AND give more details on how to implement it, i.e., create a button, create a file (macro), etc, etc.

Thanks!

I was just about to purchase a resettable clock off eBay and another clock to keep the total time.
Just for eye candy really, since it appears that Mach3 will keep the info.

I want some way for it to tell me that it's time to check brushes, perform gib tightening checks, oil, change coolant, etc. based upon user defined presets for my machine.  Would be nice if the macro could popup a dialog or even a macro that could tally the run time and give a countdown of sorts to look at.
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: John Grimsmo on April 06, 2013, 11:03:41 PM
Quick update, more later.  I've been using the spindle timer on my Tormach (this is before BR's new updates on Apr 04).  It seems to work fine on my home computer when typing M3/M5, but on the Tormach it's not adding properly.  I've put at least 10 hours of spindle time on in in the past few days and it's only reading 0.8xx hours.  Sometimes it adds time, sometimes it doesn't.  Sorry I can't give any better debug details than that.  My codes do have definite M3 and M5 calls. 

BR I'm looking forward to your new code and date extraction, I'll try it out in the next few days. 
Title: Re: Maintenance - box "Spindle On Time" is alway 0
Post by: BR549 on April 07, 2013, 10:17:02 AM
John try the Tormach this way. Mach may need time on the Tormach to do the updates.

If GetOemLed(11) AND Not GetUserLed(1000) then
       SetTimer(10)
While Ismoving()
Wend
      SetUserLed(1000,1)
While Ismoving()
Wend
End If

If NOT GetOemLed(11) AND GetUserLed(1000) then
       SetUSerDro(2000, (GetUserDro(2000) + ((GetTimer(10) /60) /60)))
While Ismoving()
Wend
        SetUserLed(1000,0)
While Ismoving()
Wend
End IF