View Full Version : Need Help! Macro Advice - Customising Mach3


UKRobotics
03-31-2008, 01:51 PM
Hi All,

My CNC Mill is a Bridgeport Series 2 Interact 4 retrofit which is now
very close to completion. Bar a few loose wires here and there it is
nearly ready to run but I want to get the logic side of things tested
and working reliably before I start trying to cut parts.

One of the things I need to do is get Mach3 to control my powered draw
bar. Now I know at its simplest level I could just create a button in
screen designer and link that to the associated output but I wish to
add a bit more inteligence than that.

What I would like is a VB script which (when i press the drawbar open
button) checks if the spindle is running and if so displays a message
saying so whilst not allowing the drawbar solonoid to be fired. Then
I'd like it to check the proximity sensor input which monitors the
position of the drawbar mechanism. If the sensor input is not high
then it should display a warning about the z axis not being homed
whilst again refusing to fire the solonoid valve until the situation
changes. Finally if those conditions have been satisified then it
should allow the solonoid to be fired.

Now I hope I'm not asking too much here, but I'd be really greatful if
somone could write me a few lines of example code to do what I have
described above so I have a starting point to work from.

I have watched all the video tutorials relating to macros on the Mach3
website and read though most of the written doccumentation but I could
really do with a headstart in the right direction to get me going!


Regards,


Dom

keithorr
03-31-2008, 03:52 PM
If you have a relay that closes when you spindle is active you can use an uncommited pole in the relay to send an input signal to Mach and poll the input (closed loop). Otherwise poll an led on the screen (open loop)

If your LED is OEM Code 11, (a setting that lights the led when the spindle is running)
You could try the following:

If (GetOEMLED(11) =True Then
DoSpinStop ;(or whatever logic you want to follow)
End If

PoppaBear10
06-08-2008, 07:09 PM
Dom

Ok,

1). Lets call your Drawbar open button INPUT3 in mach3, (change to fit your situation, ASSUME active high)
2). Lets call your Z upper prox switch INPUT4 in mach3, (as above, ASSUME active high)
3). Lets call your Solinoid for your drawbar OUTPUT4, (as above)
Note: make sure in ports and pins you have all these enabled and set to appropiate active high

INPUT3 "On" = your pushing the button for drawbar open
INPUT4 "On" = Your Z up Prox switch is Active (Z is all the way up)
SpindleRPMOut = 0 (see below), means the spindle output from mach is Dead or "0 speed".
OUTPUT4 "On" = this activates your solinoid to relese drawbar or what ever.

Next:
goto config>General> tick "Run Macropump"
goto operator>VB scripter, open the Macropump file in your profiles macros.

Put in the following code:

'Macropump.m1s

SpindleRPMOutput=GetOEMDRO(99) 'this is the Spindle percent DRO, 0 is NO speed out, 1 is full speed out.

If IsActive(INPUT3) and IsActive(INPUT4) and SpindleRPMOutput=0 Then
ActivateSignal(OUTPUT4)
Else
DeActivateSignal(OUTPUT4)
If NOT(IsActive(INPUT3)) and IsActive(INPUT4) and SpindleRPMOutput=0 Then
Message("Z must be all the way UP!!!")
End If
If IsActive(INPUT3) and IsActive(INPUT4) and SpindleRPMOutput<>0 Then
Message("Spindle MUST BE OFF!!!!")
End If
If NOT(IsActive(INPUT3)) and IsActive(INPUT4) and SpindleRPMOutput<>0 Then
Message("Turn Spindle OFF and Z UP!!!!")
End If
End If

'******************end macropump code*************

Now do a "Save As" and save the above macro as: Macropump.m1s
close VB scripter
goto diagnostics page and test your 2 inputs, and your 1 output
(to test output, open vb scripter, put: ActivateSignal(OUTPUT4),
next line is DeActivateSignal(OUTPUT4) you should see output4 led turn on
and hear your solinoid click.

Close mach3, then reopen mach 3, you have to do this for the macro pump to come on.
NOTE: when mach comes back up, open general config, and make sure the macropump tick box
is still ticked, sometimes it doesnt, if not, retick close and reopen and check again.

scott