Hello Guest it is November 15, 2019, 12:35:56 PM

Author Topic: Is it possible with E-Stop to activate macro in Mach3 Turn  (Read 4159 times)

0 Members and 1 Guest are viewing this topic.

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              
Re: Is it possible with E-Stop to activate macro in Mach3 Turn
« Reply #1 on: April 09, 2016, 12:01:48 PM »
Yupiiiiiiiiiiii, I manage to solve problem alone , will make video how I did it  :) one more time yupiiiiiii
Re: Is it possible with E-Stop to activate macro in Mach3 Turn
« Reply #2 on: April 10, 2016, 07:27:46 AM »
Here is update, manage to solve problem of oilpump to work automatically , by myself (that is important, just kidding).

Here is in video what I did

https://youtu.be/G*********qxjDDw?t=2s

So to recapitulate what all I tried before I came to this solution.

First I made macro that controls oil pump and it is activated/triggered over button that I add in mach3 screen by program machscreen editor (it is free), and in my case I connected input that counts impulses on input Index and pressure switch from oil pump (that serves for detection is there any oil and is pump in working condition ) on Timing input, as I  use CSMIO/IP-S as I concluded I can treat those inputs(Index and Timing ) as regular inputs (Input 1 to 4) and I used them because I I thought I have only those 4 inputs.

So macro for for controlling oil pump works correct when is executed over button (I named it Auto lube) and everything work OK until E-stop is activated , I made macro for oil pump to save how many impulses is counted in file named oilpump.txt so I can have exact number of counted impulses even if I close Mach3 and open it again (for that I need to delete from code part that initializes counter of impulses on zero every time I press Auto Lube button).

So next I thought that problem that I have by stopping macro by Estop can be easily solved by inserting code in macropump (like Hood said it is macro but it executes cyclic after you turn on mach3, you do not need to press any buttons or switches , you just need to adjust in general config that you want to use it, just check box where it say macropump and that is it, escape mach3 and come back and it should work, and inside of macropump you can put what ever you want that need  checks to be executed cyclic (from my experience, I put inside logic that checks do I want to open or close power chuck, and now will need to put same logic for tailstock, and most important thing that I discovered you need to put inside of macropump SetOEMTrigger(*********) function).

So as I wanted to cyclic run code that will count impulses in order to control oil pump I put code inside of macropump, and I thought, OK it will work same as in macro triggered by button (Auto lube), but it does not work , why, probably because of code that is necessary for macro for counting impulses, it needs to detect is it rising edge present (otherwise if sensor is active , macro will count presence  of sensor same as timing pulley made one revolution which is not good , because of that it needs to count changes not presence  , and other thing is that data is saved in file (and file needs to be open and closed), anyway probably that goes from some reason slow in macropump and because of that it misses to count impulses (it counts but not accurate).

And only solution till now that I can use is to use code over macro triggered by Auto lube button, but in that way macro counts correct but it is stopped when Estop is activated, I have nothing against   stopping because I will not get wrong data but I need to manually press activate pump and I can easily forget to press button, so after reading forums I discovered that there exist brains in mach3, only problem I never used them and have no clue what that should be, it sounds complicated "brain" haha. It is similar to ladder diagram for programing PLC, so you can activate output by input and you can between insert some logic and as I read they are faster then macros.

So I had simple idea, when Estop is acknowledged (I need to press RESET) if I want to start macro for oilpump (I named it m555.m1s) , so if Estop is triggered I must press RESET if I want to continue to work, I can not forget to press it.

And after experimenting with bits that I tested before (some OEM cods) I gradually came to solution to choose brain and make some logic, I guess.

So when Estop (LED with code 800) is not turned on , it needs to activate OEMTrigger1 which triggers macro (m555.m1s), Estop and OEMTrigger1 are connected over (no operation inverted), and as I described in macropump needs to be SetOEMTrigger(555) .

How that works, macropump is cyclic running and inside of it is SetOEMTrigger(555) and it waits for OEMTrigger1 to be activated (in  System HotKeys Setup under Triggerer#1 is selected code 301, and that means when OEM Trigger#1 input is activated it will trigger my macro m555.m1s , and that will happen when I press on button RESET (for that need to be no operation inverted).

Hope you can follow idea and what I did, in that way I do not need to worry about oil pump at all because it will automatically be under control of macro555 (it is script because I do not made button for it, script/macro all the same to me) and information about how many impulses is counted is in file oilpump.txt, I just need to worry is there enough oil in reservoir Smiley

I do not know why link for video is wrongly showed *******, I did not wrote those symbols

If you are interested in video try to copy paste this in youtube search :

Macropump Macro Mach3 Brain OEMTrigger

Offline Tweakie.CNC

*
  • *
  •  7,997 7,997
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: Is it possible with E-Stop to activate macro in Mach3 Turn
« Reply #3 on: April 14, 2016, 04:15:23 AM »
Nothing at all to do with the subject of the topic but...

Quote
I do not know why link for video is wrongly showed *******, I did not wrote those symbols

Been puzzling over this and concluded that YouTube chose an unfortunate combination of letters for the video's address. Somewhere in this forum's engine is a routine to remove offensive words and replace with asterisk's - thus the problem with your link to the video.

Tweakie.

Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.
Re: Is it possible with E-Stop to activate macro in Mach3 Turn
« Reply #4 on: April 14, 2016, 05:00:28 AM »
Nothing at all to do with the subject of the topic but...

Quote
I do not know why link for video is wrongly showed *******, I did not wrote those symbols

Been puzzling over this and concluded that YouTube chose an unfortunate combination of letters for the video's address. Somewhere in this forum's engine is a routine to remove offensive words and replace with asterisk's - thus the problem with your link to the video.

Tweakie.



OK, it is not problem, like I said copy-past in youtube this :

Macropump Macro Mach3 Brain OEMTrigger

And you will find video (I mean , anybody who wants to see procedure).