41
Brains Development / Is it possible with E-Stop to activate macro in Mach3 Turn
« on: April 09, 2016, 05:37:11 AM »
Hi folks, I never used brains in Mach3.
So to describe what I want to do.
I made macro that count impulses from z axis and when counted number is 4000 output need to be acitivated for 8 seconds, on output is connected relay that turns on oil pump for lubrication of bedways.
I tested macro in way that I added custom button on Mach3 screen and gave name Auto Lube. When I press Auto Lube button macro is being triggerd and inside is while 1 loop that counts rising pulses from z axis , everyting works correct (max frquency of counting impulses is 10 Hz), problem that I have is when RESET or E- stop i spressed my macro is stopped also and I need to press Auto Lube again to contine counting impulses from z axis, so it is not real Auto Lube when I need to press after every RESET start counting.
I tired to solve problem by implementing little changed code (with out while 1 loop) in macropump and after testing I conclude that when code for counting is used in macropump result is wrong, I save number of counted impulses in file named oilpump.txt with macro automaticaly, so if I produce 10 pulses I count 1 or 0, in conclusion it counts something but too slow so result is wrong.
So my idea how to solve that problem is to use macro that I used over Auto Lube button but in way that over brain I activate/trigger macro for controling oilpump.
So when from some reason RESET is presed (E-Stop) my macro will stop with counting but when I acknowledge RESET it would be good that macro for contoling oilpump contiue with counting impulses from z axis.
So that is my idea but as I said I never used brains in mach so I am wondering how to do that or if it is possible at all to do that.
Point is that counting impulses should be automaticaly (macropump does not give good results) and in worst case I can consider that counting is still in auto mode if I press acknowledge RESET.
Also I got tip to ask Machsupport is it possible to extract data from Maintenance Hours info (there exist information about total travel for all axis, it would be good when I could acess that information, I mange to find one post where one guy is asking same question but before few years ago for same pupose as me but he nevr got puplic anwesr so I think I have slim chances with that option).
Anyway if somebody have some idea what I can try , also one friend told me maybe it is possible to configure Mach3 to count steps , I thought good idea but also did not manage to found how to use that , I connected inductive sensor on z axis and when timing pulley is rotating I can pick up pulses , evry rotation of ballscrew is one pulse, and as pitch is 5 mm evrry 4000 rising edges I can detect 20 m of travel.
Hope I described good enough what is my idea .
Will put macro that works fine so maybe somebody have some better idea or something , I do not know...
I am using Index and Timing inputs because I use CSMIO/IP-S controller and did not noticed problems, I can rung G code and sense pulses on thoes imputs with no problems.
Sub main ()
Dim oldp,newp,n,error_m As Integer
Dim Msg
oldp=0 ' when I press Autolube button on Mach3 screen counter will be set on 0
Open "C:\Mach3\oilpump.txt" For Output As #1
Print #1,oldp
Close #1
While 1
If Not IsActive(Index) Then
n=0
Else
n=1
End If
Sleep 10 ' sample input f = 100Hz
If IsActive(Index) And n=0 Then ' before 10 ms Index was zero , count only rising edges
Open "C:\Mach3\oilpump.txt" For Input As #2
Line Input #2, oldp
newp=oldp+1
Close #2
If newp=10 Then ' for testing purposes newp is 10 in reality it needs to be 4000 for 20 m of travel with 5 mm pitch ballscrew
ActivateSignal(Output8) 'oil pump is on output 8
error_m=1
Sleep 1000 'turn on pump for period of 8 seconds , 8 x 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
DeActivateSignal(Output8)
newp=0
If error_m=1 Then
Msg = "Oil pump error --> check oil level "
MsgBox Msg
Else
Msg = "Lubrication was sucessful after 20 m of travel "
MsgBox Msg
End If
End If
Open "C:\Mach3\oilpump.txt" For Output As #1
Print #1,newp
Close #1
End If
Wend
End Sub
So to describe what I want to do.
I made macro that count impulses from z axis and when counted number is 4000 output need to be acitivated for 8 seconds, on output is connected relay that turns on oil pump for lubrication of bedways.
I tested macro in way that I added custom button on Mach3 screen and gave name Auto Lube. When I press Auto Lube button macro is being triggerd and inside is while 1 loop that counts rising pulses from z axis , everyting works correct (max frquency of counting impulses is 10 Hz), problem that I have is when RESET or E- stop i spressed my macro is stopped also and I need to press Auto Lube again to contine counting impulses from z axis, so it is not real Auto Lube when I need to press after every RESET start counting.
I tired to solve problem by implementing little changed code (with out while 1 loop) in macropump and after testing I conclude that when code for counting is used in macropump result is wrong, I save number of counted impulses in file named oilpump.txt with macro automaticaly, so if I produce 10 pulses I count 1 or 0, in conclusion it counts something but too slow so result is wrong.
So my idea how to solve that problem is to use macro that I used over Auto Lube button but in way that over brain I activate/trigger macro for controling oilpump.
So when from some reason RESET is presed (E-Stop) my macro will stop with counting but when I acknowledge RESET it would be good that macro for contoling oilpump contiue with counting impulses from z axis.
So that is my idea but as I said I never used brains in mach so I am wondering how to do that or if it is possible at all to do that.
Point is that counting impulses should be automaticaly (macropump does not give good results) and in worst case I can consider that counting is still in auto mode if I press acknowledge RESET.
Also I got tip to ask Machsupport is it possible to extract data from Maintenance Hours info (there exist information about total travel for all axis, it would be good when I could acess that information, I mange to find one post where one guy is asking same question but before few years ago for same pupose as me but he nevr got puplic anwesr so I think I have slim chances with that option).
Anyway if somebody have some idea what I can try , also one friend told me maybe it is possible to configure Mach3 to count steps , I thought good idea but also did not manage to found how to use that , I connected inductive sensor on z axis and when timing pulley is rotating I can pick up pulses , evry rotation of ballscrew is one pulse, and as pitch is 5 mm evrry 4000 rising edges I can detect 20 m of travel.
Hope I described good enough what is my idea .
Will put macro that works fine so maybe somebody have some better idea or something , I do not know...
I am using Index and Timing inputs because I use CSMIO/IP-S controller and did not noticed problems, I can rung G code and sense pulses on thoes imputs with no problems.
Sub main ()
Dim oldp,newp,n,error_m As Integer
Dim Msg
oldp=0 ' when I press Autolube button on Mach3 screen counter will be set on 0
Open "C:\Mach3\oilpump.txt" For Output As #1
Print #1,oldp
Close #1
While 1
If Not IsActive(Index) Then
n=0
Else
n=1
End If
Sleep 10 ' sample input f = 100Hz
If IsActive(Index) And n=0 Then ' before 10 ms Index was zero , count only rising edges
Open "C:\Mach3\oilpump.txt" For Input As #2
Line Input #2, oldp
newp=oldp+1
Close #2
If newp=10 Then ' for testing purposes newp is 10 in reality it needs to be 4000 for 20 m of travel with 5 mm pitch ballscrew
ActivateSignal(Output8) 'oil pump is on output 8
error_m=1
Sleep 1000 'turn on pump for period of 8 seconds , 8 x 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
Sleep 1000
If IsActive (Timing) Then
error_m=0
End If
DeActivateSignal(Output8)
newp=0
If error_m=1 Then
Msg = "Oil pump error --> check oil level "
MsgBox Msg
Else
Msg = "Lubrication was sucessful after 20 m of travel "
MsgBox Msg
End If
End If
Open "C:\Mach3\oilpump.txt" For Output As #1
Print #1,newp
Close #1
End If
Wend
End Sub