Machsupport Forum

Mach Discussion => Mach Screens => Topic started by: Seba on September 20, 2019, 04:04:32 PM

Title: Opening g-code
Post by: Seba on September 20, 2019, 04:04:32 PM
Hello. Please help, how do I set up Mach Counter in Mach Screens?
My second request was wanted on the desktop waving to insert keys with g-cods because I still mill 5 same items.
Thank you
Title: Re: Opening g-code
Post by: Graham Waterworth on September 20, 2019, 08:22:55 PM
Create a button a Label and a DRO on the screen of your choice.

Set the DRO to a user variable e.g. 1200

Set label to "Part Counter" and position close to DRO

Label the button "Reset Counter" and set it to run vb script

Enter VB code :-

SetUserDRO(1200,0)

Save screen.

Then on the end of every g-code file just before the M30 enter

#1200 = [#1200 + 1]

Or you can set up a Macro to do it

M1025.m1s
count = GetUserDRO(1200)
count = count + 1
SetUserDRO(1200, count)

Title: Re: Opening g-code
Post by: Seba on September 21, 2019, 04:07:03 AM
Hello.
thank you very much for your help, I can ask for a more detailed explanation because I know neither programming nor too much on Mach 3, so I would be very grateful for some file or video tutorial.
Title: Additional button Mach Screens
Post by: Seba on September 28, 2019, 05:01:40 PM
hello how to add an extra button in
Mach Screens which will open g-cod from file C:\Users\Sebastian\Desktop\PRACA\CNC\ciastk.tap
Title: Re: Opening g-code
Post by: ZASto on September 29, 2019, 07:29:11 AM
Create a button a Label and a DRO on the screen of your choice.

Set the DRO to a user variable e.g. 1200

Set label to "Part Counter" and position close to DRO

Label the button "Reset Counter" and set it to run vb script

Enter VB code :-

setuserdro(1200,0)

Save screen.

Then on the end of every g-code file just before the M30 enter

#1200 = #1200 +1



Wel, Graham
The incrementing of the #1200 works, incrementing is not shown in DRO


Title: Re: Opening g-code
Post by: Seba on September 29, 2019, 11:33:43 AM
What is wrong?
Title: Re: Opening g-code
Post by: ZASto on September 29, 2019, 02:19:47 PM
Not incrementing DRO, user variable incrementing.
Title: Re: Opening g-code
Post by: Graham Waterworth on September 30, 2019, 12:21:03 PM
Try a different DRO, #1200 may be in use by another macro
Title: Re: Opening g-code
Post by: ZASto on September 30, 2019, 06:38:12 PM
You were right, I use 1200 for some other things, but...
even if I change the variable to, eg. 999 or 1000 (with corresponding changes in screenset), still no update of DRO.

It only works if I call a macro.

Code: [Select]
M1100.m1s:

counter = getuserdro(1100)
counter = counter + 1
setuserdro(1100, counter)

Anyway, I tried to help Sebastian since I do need counters :)
Title: Re: Opening g-code
Post by: Graham Waterworth on October 01, 2019, 10:52:17 AM
That should not be a problem, just add the M1100 to the end of your program and it will work.

How did you want it to work?

Title: Re: Opening g-code
Post by: ZASto on October 01, 2019, 05:13:47 PM
Graham, it works through macro, that was the point of my writing.
It does not display of variable in DRO.
Anyway, Sebastians problem is solved with macro.