Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Tarak on October 06, 2007, 03:22:41 AM

Title: Well this counter has officially got me stumped....please help a poor soul...
Post by: Tarak on October 06, 2007, 03:22:41 AM
Any thoughts as to why I can't get this counter to display correctly?

SetOEMDRO(1214,Remain)
Code "M98 P1 L10"
Code "O1"
Code "Z[#1-[#1*2]]"
Remain= Remain - 1
SetOEMDRO(1214,Remain)
Code "M99"
Title: Re: Well this counter has officially got me stumped....please help a poor soul..
Post by: Graham Waterworth on October 06, 2007, 10:01:17 AM
Hummmmmmmm, yes it was a thought, not had a genuine one for a while.

The top and bottom of it is it will not work.

If it was a normal program it would look something like this :-

O0001
#1=1
M98 P2 L10
M30

O0002
G00 Z[#1-[#1/2]]
#1=[#1-1]
M99

The way you are doing it the sub dose not exist until the VB script creates it line by line.

Go back to the start and tell us what you are trying to do, there will be a way but I don't think this is it.

Graham.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: Tarak on October 06, 2007, 10:37:16 AM
Thanks for the reply Graham.
Basically I'm trying to display in a DRO how many repitions of a sub routine remain using a script.
So to use your example program:

O0001
#1=1
M98 P2 L10
M30

O0002
G00 Z[#1-[#1/2]]
#1=[#1-1]
SetOEMDRO(1214,#1) ' I know this isn't correct syntax, but if it was, this is exactly what I was hoping I could do.
M99

Is it possible to display in a DRO the valueof a variable? e.g #1
Title: Re: Well this counter has officially got me stumped....please help a poor soul..
Post by: Graham Waterworth on October 06, 2007, 10:52:46 AM
What you can do is this :-

Set up a M code macro that reads the parameters from a M code call, e.g.

'M1010.m1s
Dim P as Integer
P=Param1()
SetOEMDRO(1214,P)
End

Then in your G_code call M1010 P#1

Not done this in a while but I think its right.

If it works, where do I send the bill  ;D

Graham.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: poppabear on October 07, 2007, 03:43:08 PM
Darc,

Try this Make and put the macros 200 and 201 in your macro folder

O0001
#1=1
M98 P2 L10
M201          'reset counter macro after subroutine exits
M30

O0002
G00 Z[#1-[#1/2]]
#1=[#1-1]
M200          'counter macro
M99



'M200.m1s  counter Macro

Remain=GetOEMDRO(1214)
Remain=(Remain+1)
SetOEMDRO(1214,Remain)

'M201.m1s reset counter macro

SetOEMDRO(1214,0)


'Scott
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: poppabear on October 07, 2007, 07:47:26 PM
Oppsssssss,

   Darc, didnt pay attention to the dro range make that "SetUSERDRO(1214,x)"...........

scott
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: Tarak on October 09, 2007, 07:48:39 AM
Thanks alot guys, it works well, I used Scotts M200 & M201, it took me a while to realise I needed
If IsLoading()Then
Else
******
End If

But it works great.
Thanks again.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: Vogavt on August 24, 2008, 08:20:58 PM
So can we get the working code all in one place/post? Never having done this sort of thing, I don't know where to put what.  Really need this sorted out to help another poor soul...

Thanks in advance,

Vogavt
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: mikemolnar on April 30, 2013, 08:31:53 AM
I want to return some learning back to this thread and thank the contributors.

Below is a test of a loop counter for a subroutine. I used the Tool DRO to display
the counts because I do not use this feature at all. Some day I may alter the
Mach screen to display a loop counter DRO.

I use Mach3 to run a Shark router for making violin parts. It takes the grunt work away,
namely gouging wood. Of course, there is a LOT of finishing work needed
afterwards.

Again, thanks to all.

Mike



-------------
G90 G21 G58 G40 G50
(a)
M98 P1000 L10
M201 (Clear the Tool Counter)
M30 (END)
O1000
M200 (Increment to Loop Counter)
G04 P1000 (Min. is 100 ms)
M99
--------------
M200
If IsLoading() Then
'Do Nothing, program loading

Else

Dim Lcount As Integer
Lcount = GetOEMDRO(222) 'Loop counter

SetOEMDRO(824,Lcount) 'Tool # DRO


End If
--------------
M201
' clear the Tool DRO

If IsLoading() Then
'Do Nothing, program loading

Else

Dim Lcount As Integer
Lcount = 0

SetOEMDRO(824,Lcount) 'Tool # DRO


End If
-------------
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: Ya-Nvr-No on April 30, 2013, 03:52:40 PM
there is a variable that you can just display on the screen like I have created to keep track of the depth of subs.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: mikemolnar on April 30, 2013, 04:02:16 PM
The point of my post was to show how to do the basics. What you did is the next step.

I think you should take us through all the steps to create your nice display.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: BR549 on May 02, 2013, 07:26:51 PM
There is a sub loop counter dro in mach3 I believe it is #222. But you have to add a G4P0 to the end of the sub in order for it to work correctly. Thing is it only counts UP not down. What we need is a routine to parse through the loaded Gcode and calculate the total number of loops in the code. Then one could apply the subtraction and know how many are left to do and how many have been done.

(;-) TP

Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: Ya-Nvr-No on May 02, 2013, 08:52:31 PM
Works fine for me as it is, counts down, lets me know what loop it is in. Used it for a well over a years now. It is the variable that Mach uses to keep track of the loop.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: mikemolnar on May 03, 2013, 08:18:44 AM
BR549: I used #222 and it counts DOWN. Check my post on page 1 that lists the code and uses #222.

Ya-Nvr-No: How about taking us through the steps of making your cool counter display.

Mike
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: Ya-Nvr-No on May 03, 2013, 10:09:00 AM
I created the screen DRO and attached the #222 variable, I showed the machscreen and how I attached it.
Sorry I dont know what else to show you. It was easy peasy. Now whenever I use a sub it displays the counter and counts down. Kind of gets odd with nested subs but I started to understand it quickly enough. It is just showing the count of the present sub it is in. Some of my subs are 3-4 deep. So it flashes a lot of numbers as it is jumping around.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: BR549 on May 03, 2013, 02:42:09 PM
oops yous guys are right it does count down. I was remembering off the cuff.

(;-) TP
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: BR549 on May 03, 2013, 03:08:01 PM
The process does not have to be that complicated. Add teh Dro to the screen and add a G4P0 to the end of the sub.

(;-) TP
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: mikemolnar on May 03, 2013, 03:14:44 PM
Ok. Point me to where I add the DRO.
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: BR549 on May 03, 2013, 09:28:51 PM
Add it to the main screen anywhere you want it to be.

(;-) TP
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: mikemolnar on May 04, 2013, 06:02:31 PM
What tool did you use to attach the DRO to the screen?
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: BR549 on May 04, 2013, 06:39:51 PM
MachScreen

(;-) TP
Title: Re: Well this counter has officially got me stumped....please help a poor soul...
Post by: mikemolnar on May 04, 2013, 09:00:05 PM
And what about Ya-Nve-No? What did you use? And which options did you use?