Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: mn_mike on October 08, 2012, 12:48:55 AM

Title: DRO problem???
Post by: mn_mike on October 08, 2012, 12:48:55 AM
Hello group, I just bought Mach3 and I am an addict...

Mike from MN here..

I am trying to take the shared serial number macro and make it my own.

I cut it up and replaced the "g-code" with my own and modifying it and works.

The problem is that I need to use an input with trailing zeros, example:

0001
00001
012
01112

The DROs default is either integer or double and it does not let you use trailing zeros.

I cannot explicitly define the number of trailing zeros because the number of digits will vary as you can tell my the example.

Ideally I have it setup to add +1 to the number so it is just a matter of typing it in and hitting cycle start with the proper "M-Code" but if there is some way I can place a "textbox" on the screen I would just manually type each serial in as I go (the Macro sub converts the data to a string anyways).

So can anyone help me out. In the screen editors I downloaded, neither has a textbox input option just labels that are hard coded.

Thank you,

Mike in MN
Title: Re: DRO problem???
Post by: Hood on October 08, 2012, 03:12:14 AM
What is the shared serial number macro ?
You can have a text box appear on screen from a macro so that you can input data and the macro will do whatever you ask it to do with it but not sure if that is really what you are wanting.
Not clear really on anything you are asking, that could well be just because I am thick or could be because I am not sure what this serial macro is ;D
Hood
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 10:42:26 AM
Actually you are needing leading zeros. YES you can set up the dro to take them BUT you cannot have variable length leading zeros you have to define the max number needed and work with that.

00000000
00000123
00909999

etc

OR you can do as Hood suggested and create a Value entry box in the macro to ASK you what the serial number is to be. A box would pop up and you put your value in and press enter(;-)

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 10:50:14 AM
Thanks for the response.

The macro I am referring to is here:  http://www.machsupport.com/forum/index.php/topic,11018.0.html

It's simple and to the point for a serial number system.

I searched a bit and haven't been able to find a string input to a screen solution.

Can you point me to an example of value entry box? I would certainly do a popup box, but I am just getting my feet wet to Mach3 and running through all the different forum threads and literature is a bit overwhelming.

It's appreciated.

Thank you,

Mike in MN
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 11:11:20 AM
Been a while since I worked on that one(;-).

You can add or modify the screen set to include a DRO from MACH SCREEN a screen writer program for building screens for MACH3 it can be downloaded from this site.

IF you wanted a Value box we can help with that.

There are 2 resources you may want to download, the "Customising Mach2" Manual AND the Mach programmers manual. 

(;-) TP

Title: Re: DRO problem???
Post by: Hood on October 08, 2012, 11:19:31 AM
If you want leading zeroes just have 0* in the format string, example %06.f would have 6 leading zeroes

Hood
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 11:30:42 AM
If you want leading zeroes just have 0* in the format string, example %06.f would have 6 leading zeroes

Hood

Thank you.

The problem lies in it being formatted as  a double or integer. It will not pass those leading zero's into the macro because of the way it is defined.

Which brings me to the idea of using a "string" input. Then it should hold all the values.

Also, for each different family of parts that I am trying to serialize, the length of the leading zero's vary. 0001, or 000001. So I would have to change the "screen" DRO format each time if I could somehow make the leading zero's get recognized.

BR549... I have already added a DRO to the screen and have played with it extensively. The problem lies in the formatting of the box.


Thank you,

Mike in MN
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 11:35:33 AM
You cannot have a leading zero as a variable length from the DRO.  You have to set the number of leading zeros and that is what you have to work with from a DRO.


Here is a simple example of a Value BOX and writing that value to the Mach3 status line

Value = Question( "What is the value ??" )   
Message(Value)

(;-) TP
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 11:48:49 AM
Mike To use the number from the DRO as you need it you would format the value to the defined length

Here is and example

Value = Format (GetUserDro(2009), "000000")

Message(Value)


BUT still you must work with a defined field length of leading zeros.

NOW working with the Value box you can get a string that is what you input so you can vary the filed length on the fly

000123
0987

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 12:01:15 PM
TP,

Thanks for the response.

I will look into the Value Box idea. I would much rather just type in the serial each time then going in and changing the leading value of a DRO. My goal is to set it up so any operator can go over and throw a part on the machine and hit go. Having them manually change the DRO leading zero value would be not the ideal production environment.

So just so I am clear, in my macro, would the value box go right at the beginning of the VB code?

My VB code skills are very limited, I can edit most code, but not write fresh.

Thank you,

Mike in MN

Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 12:32:25 PM
So, the value box is close, but still not accepting the "000" (multiple).

Here is the code

Code: [Select]
' Macro for consecutive S/N engraving from MACH
Main
End

Sub main
Dim A As String
Dim Ch As String
Dim Cnt As Integer
Dim Value As String
SetVar(1303 , .250)  'LetterSpacing
Setvar(1300 , -0.005) ' Z Depth cutting
Setvar(1200 , 0.050) ' Safe Z
'CPx= Getoemdro(0)
'CPy= Getoemdro(1)
SETIJMODE(1)
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

Value = Question( "What is the value ??" )   
Message(Value)

A = Value
For Cnt=1 To Len(A)
  Ch=Mid(A,Cnt,1)
  Select Case Ch
    Case "0" ZERO
    Case "1" ONE
    Case "2" TWO
    Case "3" THREE
    Case "4" FOUR
    Case "5" FIVE
    Case "6" SIX
    Case "7" SEVEN
    Case "8" EIGHT
    Case "9" NINE
  End Select
Next

I defined "value" as a string, but it's still not accepting multiple "zeros"???

Any thoughts?

Mike in MN
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 12:34:16 PM
IF you could post the Macro code it would be much easier to help.

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 12:44:02 PM
Attached is the M1502

Basically everything after what I added in the other post is just g-code.

It works flawlessly if there is no leading Zeros (all real numbers).

Thank you,

Mike in MN

Here is the code in the attached file (The g-code is incomplete as of right now with regards to the "Zs" I will absolute code them.)

Code: [Select]
' Macro for consecutive S/N engraving from MACH
Main
End

Sub main
Dim A As String
Dim Ch As String
Dim Cnt As Integer
Dim Value As String
SetVar(1303 , .250)  'LetterSpacing
Setvar(1300 , -0.005) ' Z Depth cutting
Setvar(1200 , 0.050) ' Safe Z
'CPx= Getoemdro(0)
'CPy= Getoemdro(1)
SETIJMODE(1)
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

Value = Question( "What is the value ??" )   
Message(Value)

A = Value
For Cnt=1 To Len(A)
  Ch=Mid(A,Cnt,1)
  Select Case Ch
    Case "0" ZERO
    Case "1" ONE
    Case "2" TWO
    Case "3" THREE
    Case "4" FOUR
    Case "5" FIVE
    Case "6" SIX
    Case "7" SEVEN
    Case "8" EIGHT
    Case "9" NINE
  End Select
Next

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))
SETIJMODE(1)
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   

End Sub




Sub ZERO
message "Zero"
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

Code "G91X.025"
Code "G91X.0419 Y.013"
Code "Z-.2"
Code "G1 Z-.06 F10."
Code "G91G3 Y.0539 I-.0741 J.027"
Code "G91X-.0374 I-.0187 J-.0066"
Code "G91Y-.0539 I.0741 J-.0269"
Code "G91X.0374 I.0187 J.0067"
Code "G0 Z.26"
Code "G91X.0045 Y-.013"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend
End Sub



Sub ONE
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "One"
Code "G91X.025"
Code "G91Y.0685"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91X.0114 Y.0115"
Code "G91Y-.08"
Code "G0 Z.26"
Code "G91X-.0114"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91X.0229"
Code "G0 Z.26"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend
End Sub




Sub TWO
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "Two"
Code "G91X.025"
Code "G91X.0017 Y.0685"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91G2 X.0444 Y-.0104 I.0205 J-.0123"
Code "G91X-.0059 Y-.0143 I-.0228 J.0011"
Code "G91X-.0206 Y-.0153 I-.1236 J.1441"
Code "G91G3 X-.0196 Y-.0285 I.0186 J-.0339"
Code "G91G1 X.0478"
Code "G0 Z.26"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   
End Sub



Sub THREE
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "Three"

Code "G91X.025"
Code "G91X.0011 Y.0685"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91G2 X.0395 Y.0052 I.0221 J-.0151"
Code "G91X-.0164 Y-.0337 I-.0135 J-.0142"
Code "G91G0 Z.26"
Code "G91X.0057"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91G2 X.0119 Y-.0338 I-.0017 J-.0196"
Code "G91X-.0418 Y.0052 I-.0185 J.0222"
Code "G0 Z.26"
Code "G91X.048 Y-.0114"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend 
End Sub



Sub FOUR
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "Four"
Code "G91X.025"
Code "G91X.0414"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91Y.08"
Code "G91X-.0414 Y-.0612"
Code "G91X.0531"
Code "G0 Z.26"
Code "G91Y-.0188"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   
End Sub



Sub FIVE
 Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "Five"
Code "G91X.025"
Code "G91X.0484 Y.0801"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91X-.0484"
Code "G91Y-.0355"
Code "G91G2 X.0458 Y-.0045 I.0205 J-.0268"
Code "G91X-.0245 Y-.0401 I-.0214 J-.0145"
Code "G91X-.0213 Y.0114 I0. J.0254"
Code "G0 Z.26"
Code "G91X.0501 Y-.0114"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   
End Sub



Sub SIX

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))


message "Six"
Code "G91X.025"
Code "G91X.048 Y.068"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91G3 X-.0434 Y-.0043 I-.0208 J-.0116"
Code "G91X-.0016 Y-.0457 I.0667 J-.0252"
Code "G91X.0457 Y-.0016 I.0231 J.0057"
Code "G91X-.0457 Y.0016 I-.0226 J.0073"
Code "G0 Z.26"
Code "G91X.0468 Y-.018"
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   
End Sub




Sub SEVEN
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))


message "Seven"
Code "G91X.025"
Code "G91Y.08"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91X.048"
Code "G91G3 X-.024 Y-.08 I.1214 J-.0801"
Code "G0 Z.26"
Code "G91X.024"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   
End Sub




Sub EIGHT

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "Eight"
Code "g90 G0  Z#1200 X[#1301 + .2250] Y#1302 "

Code "G91X.025"
Code "G91X.0214 Y.0428"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91G2 Y.0372 I0. J.0186"
Code "G91X.0237 Y-.0186 I.004 J-.0193"
Code "G91X-.0237 Y-.0186 I-.0195 J.0005"
Code "G91G3 Y-.0428 I0. J-.0214"
Code "G91X.0266 Y.0214 I.0042 J.0219"
Code "G91X-.0214 Y.0214 I-.0214 J0."
Code "G0 Z.26"
Code "G91X.0214 Y-.0428"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend   
End Sub




Sub NINE
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))


message "Nine"
Code "G91X.025"
Code "G91X.0018 Y.0122"
Code "Z-.03"
Code "G1 Z-.23"
Code "G91G3 X.0434 Y.0043 I.0208 J.0116"
Code "G91X.0016 Y.0457 I-.0667 J.0252"
Code "G91X-.0457 Y.0016 I-.0231 J-.0057"
Code "G91X.0457 Y-.0016 I.0226 J-.0073"
Code "G0 Z.26"
Code "G91X.003 Y-.0622"

Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

While IsMoving()
Wend
End Sub

SETIJMODE(0)
CODE"G90"
CODE"M30"               
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 12:48:27 PM
I see your point I will think about this and get back.

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 12:53:28 PM
Ok, I feel kind of bad going through all of this before looking over the documents...


I changed the "Question" to "AskTextQuestion" per the Macro-Prog-Ref pdf. It works like I want it to now.

I will try using this format and refine the code and see how things work from there.

I do appreciate you giving me the direction.

Thank you,

Mike in MN
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 12:56:06 PM
I was just about to suggest the same change(;-) BUT you beat me to it. The aggravating thing about AskTextQuestion is the operator HAS to manual click on the LINE to be able to input the value. MAJOR pain.

Let us know how it works out, (;-) TP
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 01:08:42 PM
Just another thought, You CAN create your own text box in VB and have it operator friendly AND make it a s large or small as you need. The asktextquestion box was what Art created to make it easier on us.

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 01:17:31 PM
Just another thought, You CAN create your own text box in VB and have it operator friendly AND make it a s large or small as you need. The asktextquestion box was what Art created to make it easier on us.

(;-) TP

I would be interested if  you have a little direction for the texbox. Can that be incorporated in the "Screen"?

Mike in MN
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 01:25:10 PM
    Begin Dialog DialogName1 60, 60, 160, 70, "Input Serial Number"
        TEXT 10, 10, 28, 12, "SN:"
        TEXTBOX 42, 10, 108, 12, .SNStr
        OKBUTTON 42, 54, 40, 12
    End Dialog
    Dim Dlg1 As DialogName1
    Dialog Dlg1
 
    MsgBox Dlg1.SNStr
End 


It cannot be directly BUT you can add a button to call up the textbox from the screen.  You would save the value to a DRO or variable or possible a user message line.

(;-) TP
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 01:31:00 PM
Probably best to Save it to a Gcode Var (SetVar(500, Value) )that way it is directly available from inside the macro. IF you want it to be incremental  you would save it to a VAR in the range or 500-600 that way it is saved when you close down MAch3 and is available when you start back up to continue the SN string where you left off.

At the same time I would write the value to teh MACH3 staus bar so the OP can SEE what he actually typed in to verify it is correct BEFORE he makes a bad serial number.

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 01:41:38 PM
Probably best to Save it to a Gcode Var (SetVar(500, Value) )that way it is directly available from inside the macro. IF you want it to be incremental  you would save it to a VAR in the range or 500-600 that way it is saved when you close down MAch3 and is available when you start back up to continue the SN string where you left off.

At the same time I would write the value to teh MACH3 staus bar so the OP can SEE what he actually typed in to verify it is correct BEFORE he makes a bad serial number.

(;-) TP

TP,

Thanks for all the direction.

I already thought about posting the value from the message to a "Label" in the screen for verification.

The status bar would be a good one also. It does kick out the number as it reads each sub, but a full value would be a nice catch htere.

I will post what I end up with when I get there.

PS. I am brand new to this Mach3 stuff, but so far digging it. It's kind of fun being able to manipulate things. I have a serial number program on the CNC Machining Center that uses macro variable with "sub" program calls. I don't think Mach3 uses sub-programs, but the "M" macros seem to suit the need the same, just a little differently.


Thanks,

Mike in MN
Title: Re: DRO problem???
Post by: BR549 on October 08, 2012, 02:05:21 PM
MACH3 does use SUBs from inside the GCODE  M98 P? L?   Where P is the sub name  and it can be called from the sub directory where it is stored.

(;-) TP
Title: Re: DRO problem???
Post by: mn_mike on October 08, 2012, 02:08:35 PM
I will have to look into that. Either way I would still need a variable to be input via the screen, so the approach I am taking may be better suited for this platform.

We will see how it evolves.

Thank you,

Mike in MN