Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: RedBlob on June 25, 2015, 04:26:20 AM
-
Hello,
I have tested some VB macro with VB Script Editor and is all OK.
I have saved the macro on my profile with extension m1s ( M901.m1s , M902.m1s ....... )
When I execute the macro from the VB Script Editor the macro is executed correctly.
When I call from Gcode with M901 command ( or M902 ) the macro don't work ...... and I need to press the RESET button to stop because the machine is like freezed.
What can be the problem ?
Thank you for help
RedBlob
-
Hi,
let us see your macros.
Thomas
-
The macro is this .... in the VB Editor it work without problem.
SoftLimitsOff
DoOEMButton(204)
Xaxis = 0
Yaxis = 1
Zaxis = 2
Plus = 0
Minus = 1
SetOEMDRO(3,10)
If GetCsmioIn(6) = False Then JogOn(Zaxis,Plus)
Do
If GetCsmioIn(6) = True Then Exit Do
Loop
JogOff(Zaxis)
Sleep(1000)
If GetCsmioIn(6) = True Then JogOn(Zaxis,Minus)
Do
If GetCsmioIn(6) = False Then Exit Do
Loop
JogOff(Zaxis)
Sleep(2000)
DoOEMButton(141)
Sleep(2000)
Code("G01 Z-10 F1000")
Sleep(2000)
'************************************************************************
'* SUBs & FUNCTIONs
'************************************************************************
Sub SoftLimitsOff ()
If(GetOEMLED(23)) Then
DoOEMButton(1029)
End If
End Sub
' -----------------------------------------------------------------------------
Sub SetSoftLimits (state As Boolean)
If(state) Then
If(GetOEMLED(23) = 0) Then
DoOEMButton(1029)
End If
Else
If(GetOEMLED(23)) Then
DoOEMButton(1029)
End If
End If
End Sub
' -----------------------------------------------------------------------------
Sub WaitForMove ()
While IsMoving()
Sleep(15)
Wend
End Sub
' -----------------------------------------------------------------------------
Public Function GetCsmioIn (n As Integer) As Boolean
Dim reg As Integer
If(n < 16) Then
reg = 90
Else
reg = 91
n = n - 16
End If
If(GetInBit(reg, n)) Then
GetCsmioIn = true
Else
GetCsmioIn = false
End If
Exit Function
End Function
' -----------------------------------------------------------------------------
Public Sub SetCsmioOut (ByVal n As Integer, ByVal state As Boolean)
If(state) Then
SetOutBit(90, n)
Else
ResetOutBit(90, n)
End If
End Sub
' -----------------------------------------------------------------------------
-
Hi,
modified yiur code a little bit. Hopefuly i can test tonight on my CSMIO machine.
Thomas
Sub Main()
SoftLimitsOff
DoOEMButton(204)
Xaxis = 0
Yaxis = 1
Zaxis = 2
Plus = 0
Minus = 1
SetOEMDRO(3,10)
If GetCsmioIn(6) = False Then
JogOn(Zaxis,Plus)
End If
Do
If GetCsmioIn(6) = True Then
Exit Do
End If
Loop
JogOff(Zaxis)
Sleep(1000)
If GetCsmioIn(6) = True Then
JogOn(Zaxis,Minus)
End If
Do
If GetCsmioIn(6) = False Then
Exit Do
End If
Loop
JogOff(Zaxis)
Sleep(2000)
DoOEMButton(141)
Sleep(2000)
Code("G01 Z-10 F1000")
Sleep(2000)
End Sub
-
Hi,
by the way your code looks like a kind of homing/probing function.
why don't you use G28 or G31 (or M31 from CSMIO homepage)
for this job.
this macro solution will be imprecise anyway.
Thomas
-
Double check that you're saving in the correct profile folder. I've seen many instances where users thought they were, but were actually using a different profile than they thought.
-
I think to have find the problem , but not the solution ......
The macro don't execute the instruction JogOn(Zaxis,Plus) .
If I disable the JogOn the script is executed correctly.
How is possible ?
-
Hi,
ok again, what are you trying to do with this macro.
i still think it is a homing/probing.
Thomas
sometimes an other way is the better way.
-
The macro move the axis in Jog until an external switch is pressed ( like an automatic pallet finder ).
I need to move the axis in manual Jog with a VB macro ......... I don't understand why this function is available but don't work in my application .
What is wrong ?
-
Hi,
The macro move the axis in Jog until an external switch is pressed ( like an automatic pallet finder ).
I need to move the axis in manual Jog with a VB macro ......... I don't understand why this function is available but don't work in my application .
What is wrong ?
have a look for G31/M31 for this, would be perfect for this.
Thomas