Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: mariusl on May 27, 2012, 06:22:54 AM

Title: Gcode does not execute correctly
Post by: mariusl on May 27, 2012, 06:22:54 AM
Hi,
I am new to Wizards, so please be patient. I Looked at some wizards and then created my own that output the following Gcode. Mach gets to line 3 and just get stuck there. What am I screwing up here?

Code: [Select]
F1800
G00 Z1
G00 X0 Y0
G01 Y0.5
G01 X199.5
G01 Y2.5
G01 X0.5
G01 Y4.5
G01 X199.5
G01 Y6.5
G01 X0.5
G01 Y8.5
G01 X199.5
G01 Y9.5
G01 X0.5
G00 X0 Y0
M30


And here is the VB that creates the code

Code: [Select]
Sub Main()
DoOEMButton (169)
FeedRough = Abs(GetOEMDRO(1070))
ToolDia = Abs(GetOEMDRO(1071))
ToolRad = ToolDia / 2

XPOS = GetOEMDRO(1072)
YPOS = GetOEMDRO(1073)

SafeZ = 1 'Abs(GetOEMDRO(1079))

Length = Abs(GetOEMDRO(1080))
Width = Abs(GetOEMDRO(1075))

StepDepth = Abs(GetOEMDRO(1076))
Clearance = StepDepth * 1.5

If FeedRough = 0 Then
    Code "(MSG,Feed Rate can't be zero)"
End If

If StepDepth = 0 Then
    Code "(MSG,Step down can't be zero)"
End If

If Length = 0 Then
    Code "(MSG,Length can't be zero)"
End If

If Width = 0 Then
    Code "(MSG,Width can't be zero)"
End If

OpenTeachFile "LaserPeenScan.tap"

XStart = XPOS
YStart = YPOS
XFinal = XPOS + Length
YFinal = YPOS + Width

XToolDown = XStart
YToolDown = YStart

PassNumber = 1
Code "F" & FeedRough

DepthofPass = StepDepth

PassType = 1

XStart = XPOS - Offset + ToolRad
YStart = YPOS + ToolRad
XFinal = XPOS + Length - ToolRad
YFinal = YPOS + Width - ToolRad

Code "G00 Z" & SafeZ
Code "G00 X" & XToolDown & " Y" & YToolDown

YpassNo = 0
Do
    YofPass = YStart + (ToolDia * StepDepth  * YpassNo)
    If (YofPass >= YFinal) Then
        Exit Do
    End If
    Code "G01 Y" & YofPass
    Code "G01 X" & XFinal
    PassType = PassType * -1
    YpassNo = YpassNo + 1
   
    YofPass = YStart + (ToolDia * StepDepth * YpassNo)
    If (YofPass >= YFinal) Then
        Exit Do
    End If
    Code "G01 Y" & YofPass
    Code "G01 X" & XStart
   
    PassType = PassType * -1
    YpassNo = YpassNo + 1
Loop
YofPass = YFinal
Code "G01 Y" & YofPass
If (PassType = 1) Then
    Code "G01 X" & XFinal
Else
    Code "G01 X" & XStart
End If

Code "G00 X" & XToolDown & " Y" & YToolDown

Code "M30"
CloseTeachFile

Call LoadTeachFile
End Sub

Main


Title: Re: Gcode does not execute correctly
Post by: ger21 on May 27, 2012, 08:58:29 AM
The g-code runs fine here.

One thing you need to add is a carriage return after the M30, or just a
Code "%"

Otherwise, the M30 won't be recognized.
Title: Re: Gcode does not execute correctly
Post by: mariusl on May 27, 2012, 01:49:42 PM
Thanks Gerry,
I have a development PC that the code does not run but when I installed on my actual machine PC it worked ok. Strange??