Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started 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"
-
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.
-
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
-
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.
-
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
-
Oppsssssss,
Darc, didnt pay attention to the dro range make that "SetUSERDRO(1214,x)"...........
scott
-
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.
-
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
-
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
-------------
-
there is a variable that you can just display on the screen like I have created to keep track of the depth of subs.
-
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.
-
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
-
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.
-
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
-
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.
-
oops yous guys are right it does count down. I was remembering off the cuff.
(;-) TP
-
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
-
Ok. Point me to where I add the DRO.
-
Add it to the main screen anywhere you want it to be.
(;-) TP
-
What tool did you use to attach the DRO to the screen?
-
MachScreen
(;-) TP
-
And what about Ya-Nve-No? What did you use? And which options did you use?