Hello Guest it is March 29, 2024, 07:01:04 AM

Author Topic: Well this counter has officially got me stumped....please help a poor soul...  (Read 11897 times)

0 Members and 1 Guest are viewing this topic.

Offline Tarak

*
  •  229 229
    • View Profile
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"

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
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.
« Last Edit: October 06, 2007, 10:16:41 AM by Graham Waterworth »
Without engineers the world stops

Offline Tarak

*
  •  229 229
    • View Profile
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

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
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.
Without engineers the world stops

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
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
fun times

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Oppsssssss,

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

scott
fun times

Offline Tarak

*
  •  229 229
    • View Profile
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.

Offline Vogavt

*
  •  260 260
    • View Profile
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.