Hello Guest it is November 19, 2019, 08:40:59 AM

Author Topic: Macro, Engraving, COnsecutive serial numbers  (Read 10825 times)

0 Members and 1 Guest are viewing this topic.

vmax549

*
Macro, Engraving, COnsecutive serial numbers
« on: March 28, 2009, 05:12:01 PM »
Here is a macro that will engrave consecutive serial numbers. It rREQUIRES that a new DRO be set up on your screen OEMDRO 1050.

OR NOTE this macro can be changed to use a persistant VARS instead of a new DRO to store the S/N.

Each time it is run it will increment the serial number UP one number. To reset the starting point simply reset the DRO or VAR to the new Number.


To use move to the starting point from the Number. THen call the M1500 macro. It can be called from the Gcode program or the MDI line or from a button script.

(The Depth of cut, Clear Z and spacing are adjustable from inside the Macro or can be made to be set from a macro argument if needed)

It wil start off by engraving       S/N:     then adds the serial number    IE:    S/N: 090300001  ,  next run  S/N: 090300002 , ETC


CODE EXAMPLE:
' Macro for consecutive S/N engraving from MACH

Sub main
Dim A As String
Dim Ch As String
Dim Cnt As Integer
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))

message "S"
Code "g90 G0  Z#1200 X[#1301 + .2250] Y#1302 "
code "G91G0 x -.0706"
code " y-.0449"
code "G90 G1Z#1300 F20."
code "g91 g1X.0159Y-.0361I.05J.0004"
code "X.0375Y-.0151I.0377J.0395"
code "G1X.0348"
code "G3X.0373Y.0151I-.0001J.0539"
code "X.0157Y.0361I-.0346J.0365"
code "X-.016Y.0383I-.0551J-.0004"
code "X-.037Y.0164I-.0378J-.0356"
code "G1X-.0352"
code "G2X-.0373Y.0157I.0003J.0528"
code "X-.0157Y.0372I.0371J.0376"
code "X.0157Y.0374I.0535J-.0004"
code "X.0373Y.016I.0377J-.0365"
code "G1X.0706"
code "G90 G0Z[#1200]"
Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

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

While IsMoving()
Wend

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

message "/"
Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "
code "G91G0X.0357Y.1071"
code "G90 G1Z#1300 F20."
code "G91 g1X-.1071Y-.2142"
code "G90 G0Z[#1200]"
Code "G0  Z#1200 X[#1301 + .2250] Y#1302 "

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

While IsMoving()
Wend 
 
Setvar(1301, getdro(0))
Setvar(1302, getdro(1))

message "N"
Code "G90  g0 X[#1301 + .2250] Y#1302 "
code "G91G0X-.0706 Y-.1078"
code "G90 G1Z#1300 F20."
code "G91 g1y.2156"
code "x.1412 Y-.2156" 
code "y.2156"
code "G90 G0 Z#1200"
Code "G0 Z#1200X[#1301 + .2250] Y#1302"

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

While IsMoving()
Wend

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

message ":"
Code "G90  g0 X[#1301 + .2250] Y#1302 "
code "G91G0y-.0559"
code "G90 G1Z[#1300 -.010] F20."
Code "Z#1200"
code "G91 Y.1118"
code "G90 G1Z[#1300 -.010] F20."
Code "Z#1200"
Code "G0 Z#1200X[#1301 + .2250] Y#1302"

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

While IsMoving()
Wend


P10= GetOEMDRO(1050)
A=Str(P10)
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
P10=P10+1
SetOEMDRO(1050,P10)
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 " G0 X[#1301 + .2250] Y#1302 "
code "G90 G0 z#1200"
code "G91 G0 X-.0004Y.1076"
code "G90 G1 Z#1300 F20."
code "G91 G1X.0176 "
code "G2X.0374Y-.0194I-.0021J-.05"
code "X.0164Y-.0417I-.0488J-.0432"
code "G1X-.0009Y-.1012"
code "G2X-.0157Y-.0372I-.0527J.0004"
code "X-.0372Y-.0157I-.0375J.0371"
code "G1X-.0353"
code "G2X-.0372Y.0157I.0004J.0528"
code "X-.0157Y.0372I.0371J.0376"
code "G1Y.1059"
code "G2X.0157Y.0389I.0585J-.001"
code "X.0372Y.0175I.0382J-.033"
code "G1X.0177 "
Code "G90 Z#1200"
Code "G0 Z#1200X[#1301 + .2250] Y#1302"

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 "G90  g0 X[#1301 + .2250] Y#1302 "
code "G91G0X-.0359Y.0719"
code "G90 G1Z#1300 F20."
code "G91 X.0357Y.0361"
code "Y-.2156"
code "X-.0357"
code "X.0718"
code "G90 G0 Z#1200"
Code "G0 Z#1200X[#1301 + .2250] Y#1302"

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 "G90 G0 Z#1200 X[#1301 + .2250] Y#1302 "
code "G91G0X-.071Y.0531 "
code "G90 G1Z#1300 F20. "
code "G91 G2X.0157Y.0375I.0535J-.0004 "
code "X.0377Y.0159I.0379J-.0371"
code "G1X.0352 "
code "G2X.0375Y-.0159I-.0005J-.0531 "
code "X.0159Y-.0375I-.0373J-.038 "
code "X-.0164Y-.0383I-.0527J-.0001"
code "G1X-.1256Y-.1213"
code "X.142"
code "G90 G0Z#1200"
Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

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 "g90 G0 Z#1200 X[#1301 + .2250] Y[#1302 ]"
code "G91G0X-.0605Y.0917"
code "G90 G1Z#1300 F20."
code "G91 G2X.0362Y.0159I.0366J-.0341"
code "G1X.034"
code "G2X.0357Y-.0159I-.0006J-.0494"
code "X.0151Y-.0379I-.04J-.0379"
code "X-.0151Y-.0379I-.0552 "
code "X-.0357Y-.0159I-.0363J.0335"
code "X.0357Y-.0159I-.0006J-.0494"
code "X.0151Y-.0379I-.04J-.0379"
code "X-.0151Y-.0374I-.0546J.0002 "
code "X-.0357Y-.0159I-.0363J.0335"
code "G1X-.034 "
code "G2X-.0362Y.0154I.0002J.0505 "
code "G90 G0Z[#1200]"
Code "G0 Z#1200X[#1301 + .2250] Y#1302"

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 "g90 G0 Z#1200 X[#1301 + .2250] Y#1302 "
code "G91G0X.0353Y-.1059"
code "G90 G1Z#1300 F20."
code "G91 Y.2117"
code "X-.1059Y-.1411"
code "X.1412"
code "G90 G0Z#1200"
Code "G0  Z#1200 X[#1301 + .2250] Y#1302 "

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 "G90 G0  Z#1200 X[#1301 + .2250] Y#1302 "
code "G91G0X.0714Y.1071"
code "G90 G1Z#1300 F20."
code "G91 X-.1428"
code " Y-.0714"
code "X.0895"
code "G2X.0374Y-.0159I-.0005J-.0531"
code "X.0159Y-.0374I-.0372J-.0379"
code "G1Y-.0358"
code "G2X-.0159Y-.0378I-.0537J.0003"
code "X-.0374Y-.0159I-.0379J.0372"
code "G1X-.0357"
code "G2X-.0379Y.0159I.0002J.0536"
code "X-.0159Y.0374I.0372J.0379"
code "G90 G0Z#1200"
Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

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 "G90 G0 Z#1200 X[#1301 + .2250] Y#1302 "

code "G91G0X.0555Y.091"
code "G90 G1Z#1300 F20."
code "G91 G3X-.0379Y.0155I-.0376J-.038"
code "G1X-.0352"
code "G3X-.0377Y-.0159I.0002J-.053"
code "X-.0157Y-.0375I.0378J-.0379"
code "G1Y-.1062"
code "G3X.0157Y-.0377I.0533J.0001"
code "X.0377Y-.0157I.0378J.0376"
code "G1X.0352"
code "X.0375Y.0157I-.0004J.0535"
code "X.0159Y.0377I-.0371J.0379"
code "G1Y.0352"
code "G3X-.0159Y.0375I-.0531J-.0005"
code "X-.0375Y.0159I-.038J-.0372"
code "G1X-.0352"
code "G3X-.0377Y-.0159I.0002J-.053"
code "X-.0157Y-.0375I.0378J-.0379"
code "G90 G0Z[#1200]"
Code "G0  Z#1200 X[#1301 + .2250] Y#1302 "
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 "G0 Z#1200 X[#1301 + .2250] Y#1302 "
code "G90 z#1200"
code "G91G0X-.0714Y.1071"
code "G90 G1Z#1300 F20."
code "G91 X.1428"
code "X-.1071Y-.2142"
code "G90 G0Z[#1200]"
Code "G0  Z#1200 X[#1301 + .2250] Y#1302 "

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 "G91G0X0.Y.1061"
code "G90 G1Z#1300 F20."
code "G91 X.0176"
code "G2X.0373Y-.016I-.0004J-.0525"
code "X.0157Y-.0374I-.0378J-.0378"
code "X-.0157Y-.0372I-.0528J.0004"
code "X-.0373Y-.0157I-.0376J.0371"
code "G1X-.0352"
code "G3X-.0373Y-.0164I.0005J-.0519"
code "X-.0157Y-.0383I.0398J-.0386"
code "X.0159Y-.0361I.05J.0004"
code "X.0375Y-.0151I.0377J.0395"
code "G1X.0348"
code "G3X.0373Y.0151I-.0001J.0539"
code "X.0157Y.0361I-.0346J.0365"
code "X-.016Y.0383I-.0551J-.0004"
code "X-.037Y.0164I-.0378J-.0356"
code "G1X-.0352"
code "G2X-.0373Y.0157I.0003J.0528"
code "X-.0157Y.0372I.0371J.0376"
code "X.0157Y.0374I.0535J-.0004"
code "X.0373Y.016I.0377J-.0365"
code "G1X.0176"
code "G90 G0Z[#1200]"
Code "G0 Z#1200 X[#1301 + .2250] Y#1302 "

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 "G90 G0  Z#1200 X[#1301 +.2250] Y#1302 "

code "G91G0X-.0555Y-.091"
code "G90 G1Z#1300 F20."
code "G91 G3X.0379Y-.0155I.0376J.038"
code "G1X.0352"
code "G3X.0375Y.0157I-.0004J.0535"
code "X.0159Y.0377I-.0371J.0379"
code "G1Y.1062"
code "G3X-.0159Y.0375I-.0532J-.0005"
code "X-.0375Y.0159I-.038J-.0372"
code "G1X-.0352"
code "G3X-.0377Y-.0159I.0002J-.053"
code "X-.0157Y-.0375I.0378J-.0379"
code "G1Y-.0352"
code "G3X.0157Y-.0377I.0533J.0001"
code "X.0377Y-.0157I.0378J.0376"
code "G1X.0352"
code "G3X.0375Y.0157I-.0004J.0535"
code "X.0159Y.0377I-.0371J.0379"
code "G90 G0Z#1200"
Code "G0  Z#1200 X[#1301 +.2250] Y#1302 "

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

While IsMoving()
Wend
End Sub

SETIJMODE(0)
CODE"G90"
CODE"M30"               

Re: Macro, Engraving, COnsecutive serial numbers
« Reply #1 on: December 21, 2012, 02:04:33 PM »
Hello. I am familiar with Fanuc controls with regards to sequential serialization but am a bit lost with Mach3. Never used the software before but it seems like the best option, cheapest option to use an old desktop mill for some offline engraving to save machine time. Is there any way you could describe how to get the new DRO and make things work within the Mach3 interface? I have a basic idea but have had no luck poking around in the demo I downloaded earlier yesterday. Would appreciate it greatly. Thank you!