7351
General Mach Discussion / Re: Help! How to write Macro for M11 and M10 in Mach3
« on: November 30, 2016, 10:15:42 PM »
Hi,
after a little messing around this macro seems to work, I hope as you intended.....
Sub main()
code ("g1 x100 y0 f300")
While IsMoving()
If getOEMDRO(800)>20 Then DoOEMButton(233)
If getOEMDRO(800)>80 Then DoOEMButton(234)
Wend
End Sub
Where 'getOEMDRO(800)' is the current position of the X axis and because its inside the "While IsMoving()' loop
is continually updated.
'DoOEMButton(233)' turns on output4 if enabled in 'port and pins' and
'DoOEMButton(234) turns output4 off.
I propose you use output4 to control your spray valve.
As I've written it (I use mm) the movement is from 0 to 100mm at 300mm/min but the object to be painted
is only 60mm wide,and occupies the space from X=20mm to X=80mm. Each of your painting moves could be
done in a macro with intervening G0 moves to setup for the next 'live one'
G0 X0 Y0 ;preposition your machine
M100 ;your first paint pass
G0 X0 Y10 ;preposition for your second pass
M101 ;your appropriately coded second paint pass
and so on.....
The idea might be a bit 'clunky' but I think it might achieve what you want.
There is a timer function in VB which might also work, I haven't messed with it.
My reasoning goes that because you've set the acceleration in your motor tuning
setup it is possible to calculate the distance the axis travels by the time it reaches
its constant speed, ie the feedrate.
Hope this gives you some ideas to pursue. Let us know how you make out.
Craig
after a little messing around this macro seems to work, I hope as you intended.....
Sub main()
code ("g1 x100 y0 f300")
While IsMoving()
If getOEMDRO(800)>20 Then DoOEMButton(233)
If getOEMDRO(800)>80 Then DoOEMButton(234)
Wend
End Sub
Where 'getOEMDRO(800)' is the current position of the X axis and because its inside the "While IsMoving()' loop
is continually updated.
'DoOEMButton(233)' turns on output4 if enabled in 'port and pins' and
'DoOEMButton(234) turns output4 off.
I propose you use output4 to control your spray valve.
As I've written it (I use mm) the movement is from 0 to 100mm at 300mm/min but the object to be painted
is only 60mm wide,and occupies the space from X=20mm to X=80mm. Each of your painting moves could be
done in a macro with intervening G0 moves to setup for the next 'live one'
G0 X0 Y0 ;preposition your machine
M100 ;your first paint pass
G0 X0 Y10 ;preposition for your second pass
M101 ;your appropriately coded second paint pass
and so on.....
The idea might be a bit 'clunky' but I think it might achieve what you want.
There is a timer function in VB which might also work, I haven't messed with it.
My reasoning goes that because you've set the acceleration in your motor tuning
setup it is possible to calculate the distance the axis travels by the time it reaches
its constant speed, ie the feedrate.
Hope this gives you some ideas to pursue. Let us know how you make out.
Craig