Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: rotahed on February 09, 2010, 11:07:00 PM
-
Hi
My farther and I developed a THC device (independently controls the Z motor) to upgrade a customers old CNC plasma (using a hypertherm 1100). Since this has been functioning perfectly for the last couple of months the customer wants to get some extra functionality that their software will not allow.
This is where Mach3 comes in I believe.
I have been playing with the trial program and have successfully got inputs and outputs to trigger relays and what not. I have also modified macros to do specific tasks push buttons and. We also wrote some brains and they worked to a point and then it broke my brain. As a result I think maybe I need to write a macropump. Correct me If I'm Wrong
But I have virtually no experience with VB and have no idea whether what I want to do is possible.
If anyone could have a look at my scenario and maybe help me out and point me in the right direction it would be great. Ie do I use a brain and then call a macro from the brain or just use the macropump.
Control Process
macro And Functions
M3 - set Enable6, unset (Retry ) Variable
M5 - unset Enable6, unset (Machine is cutting) Variable
Main Program Routine
Run Gcode, M3 send torch fire signal-feedhold-wait for RTG signal from plasma unit-when RTG active-cycle start
check if Enable6 is active (Enable6 is set by m3 macro and unset by the M5 macro)
if Enable6 is and (Machine is cutting) Variable DeActive then DoOEMButton(1001) 'feed hold' (press once)
if Enable6 is active and FeedHold active, activate Output1
if Output1 is active and OEMTrigger1 not active wait (some amount of time not specified yet) then repeat this step
check Output1 and check OEMTrigger1 if both active DoOEMButton(1000) 'cycle start'
when Enable6 and Output1 and OEMTrigger1 Active Set a (Machine is cutting) Variable
Sub Routine
Flame out occurs while machine is in the middle of a part This procedure is to reestablish torch cutting.
Try 3 times or until successfull and continue as normal. If it fails 3 times Display warning for the operator and END Program
(In this instance OEMTrigger1 would drop out)
check OEMTrigger1 check (Machine is cutting) Variable True
if OEMTrigger1 is DeActive and (Machine is cutting) Variable True DoOEMButton(1001) 'feed hold' (press once) and DeActivate Output1
wait (some amount of time not specified yet) and check OEMTrigger1 is DeActive and (Machine is cutting) Variable True and Output1 DeActive then
Activate Output1
wait (some amount of time not specified yet)
Check if Output1 is active and OEMTrigger1 DeActive DeActivate Output1 and increment (Retry) Variable return to sub-routine start
Check (Retry) Variable if <3 return to sub-routine start If = to 3 then Display Warning on screen and hit stop button.
if Output1 and check OEMTrigger1 if both active DoOEMButton(1000) 'cycle start'
Return To main
Thanks in Advance
Christian
-
HI all
OK after trawling the forum for various bit and pieces I decided to have a go at writing some vb for my macro pump but when I try to step through I get errors and I'm not sure what I have done wrong errors are as follows.
Error on line 24- label not defined. (also if I remove the end sub after the goto statement and place it at the very end of the code the error disappears and I get the following error "Compile error syntax error" and it highlights the SU in the End Sub line.)
Its driving me nuts! please help
Thanks in advance
christian
Sub main()
If IsActive(ENABLE6) And (GetUserDRO(1000) = 0)Then 'check enable6 is active and variable UserDRO(1000) is not active
DoOEMButton(1001) 'Do button Feed Hold (pause motion on machine)
End If
If IsActive(ENABLE6) And (GetOEMLed(111) = True) Then 'check that Enable6 and Feed Hold(OEMLed) are true
ActivateSignal(OUTPUT1) 'Activate Output1 or Fire torch.
End If
Sleep (100)
If IsActive(OUTPUT1) And IsActive(OEMTrigger1) Then 'Loop until output1 and oemtrigger1 (RTG) are active
DoOEMButton(1000) 'Set cycle start when they are active
SetUserDRO(1000,1) 'Set variable UserDRO(1000) to 1 or high
End If
If IsActive(OUTPUT1) And (GetUserDRO(1000) = 1) And Not IsActive(OEMTrigger1) Then 'check output1 is true and variable userdro(1000) is 1 and OEMTrigger1 is False
DoOEMButton(1001) 'press feed hold button if RTG Drops away
GoTo flameout 'proceed to flameout routine
End If
flameout:
For counter = 1 To 3 'loop 3 times
DeActivateSignal(OUTPUT1) 'turn off output1
Message ("Waiting For THC To Establish An Arc") 'display message
Sleep (3000) 'sleep time in milliseconds
ActivateSignal(OUTPUT1) 'turn on output1
Sleep (3000) 'sleep time in milliseconds
Message ("")
If IsActive(OUTPUT1) And IsActive(OEMTrigger1) Then 'check output1 and oemtrigger1 if true press cylestart
DoOEMButton(1000)
End If
IF counter = 3 Then
'Define some constants for MachMsg dialog types
MachMsgTypeOK = 0
'Define some constants for MachMsg return codes
MachMsgReturnOK = 1
'Display an Abort/Retry/Ignore dialog
Ret = MachMsg("Plasma Failed to Start three times. Press OK to Abort program", _"FLAME OUT WARNING", MachMsgTypeOK)
If Ret = MachMsgReturnOK Then
DoOEMButton(1003)
End If
End If
Next
End Sub
-
Hi All
Let me first say to all beginners MAKE SURE YOU READ THE CYPRESS ENABLE AND MACH3 PROGRAMMERS REFERENCE PDF'S CAREFULLY!!!!!!
After going back and reading these for the millionth time I found I had made a few mistakes mainly "IsActive(OUTPUT1)" instead of "IsOutputActive(OUTPUT1)"
and "IsActive(OEMTrigger1)" instead of "IsActive(OEMTrig1)" Silly dumb monkey :-[
Anyway here is the code that actually works
Sub main()
'i=i+1
'message "Macro Running #"&i
If GetOEMLED(851) And GetVar(1) = 0 Then 'check enable6 is active and variable UserDRO(1000) is not active
DoOEMButton(1001)
ActivateSignal(OUTPUT1)
'Sleep (6000) 'Do button Feed Hold (pause motion on machine)
End If
If IsOutputActive(OUTPUT1) And IsActive(OEMTRIG1) Then 'check output1 and oemtrigger1 (RTG) are active
DoOEMButton(1000)
SetVar(1,200) 'Set cycle start when they are active
'Set variable UserDRO(1000) to 1 or high
End If
If IsOutputActive(OUTPUT1) And Not IsActive(OEMTRIG1) And GetVar(1) = 200 Then
DoOEMButton(1001)
End If
If Not GetOEMLED(851) Then
DeActivateSignal(OUTPUT1)
End If
'If IsActive(OUTPUT1) And (GetUserDRO(1000) = 1) And Not IsActive(OEMTRIG1) Then 'check output1 is true and variable userdro(1000) is 1 and OEMTrigger1 is False
'DoOEMButton(1001) 'press feed hold button if RTG Drops away
'GoTo flameout 'proceed to flameout routine
'End If
End Sub
It doesn't do exactly what I want but it is a start so will keep you all posted!
-
Hi All
Just thought I would post to close this topics as all issues have been resolved.
With some help from DaveCVI and Zealous Thanks guys.
Christian'