Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Tarak on April 15, 2007, 08:34:02 PM

Title: Is it possible to have an elapsed time display for VB code?
Post by: Tarak on April 15, 2007, 08:34:02 PM
I have multiple buttons that run a different program each (see pic), is it possible to have a display that shows how long it has taken from start to finish for the VB script each time it is run.
The display I currently have will only display the time of a loaded program that runs.
Is there a way to do this?
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: poppabear on April 16, 2007, 07:08:14 PM
Yea, here you go Darc:

'Drop you a User Dro numbered 1200 or what ever, change code below to reflect new number. I put some sample moves in for you to see, how it times how long the script takes to run the code, notice the get timer(0) is at the end of the script to give you culamative time.

settimer(0)

Code "G0 x2"
Code "G0 x0"
code "M30"
While IsMoving()
Wend

x=GetTimer(0)

SetUserDRO(1200,x)

'Scott
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: Tarak on April 16, 2007, 10:00:10 PM
Thanks Scott.
Works beautifully, just what I was after.
Thanks again.
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: Tarak on April 17, 2007, 05:28:49 PM
Hi poppabear, just a quick question regarding the code, whenever I have the timer in my program, it works great.
The only problem I have found is that the spindle won't start, even though there is an M03 in the script.
During the running of the cycle, if I press esc it displays terminating script and then starts the spindle??????
If I remove the code the spindle works as per normal.......nah nah nah nah (twilight zone).
Any ideas
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: poppabear on April 17, 2007, 08:40:38 PM
Hey Darc,

   there was some noise about, you can't (or shouldn't call), a macro from within a macro.
So, what I would do, is get the Output pin that your M3 controls and just control the output specifically.
i.e.

ActivateSignal(OUTPUT1)  'change to whatever output your M3 triggers.

'If that STILL, doesn't work, then the question becomes a "Art or Brian" question, since it may have something to do with
'how Mach parses the code or some other internal issue.

Scott
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: Tarak on April 17, 2007, 11:58:18 PM
Thanks heaps, it works treat now..
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: sunmix on April 26, 2007, 12:36:01 PM
hey hi everyone, i've tried it in my mach, for example the code for Macro M3 is like this:

settimer(0)

Code "G0 x2"
Code "G0 x0"
Code "G4 P" & (getUserDRO(1001))

While IsMoving()
Wend
 
ActivateSignal(Output1)
x=GetTimer(0)

SetUserDRO(1002,x)

DRO 1001 is the time that i've set for it to count : for example 10 seconds.
DRO 1002 is the elapsed time that it would show after the action is completed.

When i type M3 on my MDI, it triggers the macro,
and during this process, it should be running for about 16-20seconds.
instead the DR0 1002 shows out 1.6164. what have I went wrong?
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: poppabear on April 26, 2007, 05:40:40 PM
get you code, OUT, of the m3 macro, that is for spindle clockwise.

Make a Custom Macro, that you post after you post the M3 if you want them close together.

Scott
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: sunmix on April 27, 2007, 09:13:06 AM
Scott,

I don't quite understand what do you mean, it was just an example, my real code was for controlling heights and delays for my oxy/plasma.

what did u mean by " Post after you Post the M3 if you want them close together"?
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: poppabear on April 28, 2007, 07:35:10 AM
Look at your "G4" settings in your general config, make sure your pauses are set to seconds, not micro seconds.

I meant, after your g-code puts out a m3, the next m code should be this one that you want special stuff, it you want it tied close to your m3.

scott
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: sunmix on April 29, 2007, 11:42:22 AM
yes, it's in seconds, and i'm very sure because i've been using the G4 to delay my oxy and plasma cutting.
Title: Re: Is it possible to have an elapsed time display for VB code?
Post by: sunmix on May 10, 2007, 10:41:36 AM
okay guys, ive settled it, i have to install a mach3 with driver in order the mach3 system to count properly, thx guys! =>