Hello Guest it is June 19, 2019, 05:51:52 AM

Author Topic: How to activate more then one macro with diffrent OEM Trigger Inputs ????  (Read 5572 times)

0 Members and 1 Guest are viewing this topic.

Hi folks.

So I want when I activate physical switch to macro be triggered/activated also, I know how to do it for one OEM Trigger Input, but when I use 2 diffrent OEM Trigger Inputs and when each input need to activate its own macro problems start.

So I embedded in existing macros that I used over Screens  this command ----->  from example that I found in manual

Example:
‘ Assume OEMTRIGGER5 is assigned to OEM code 301
‘ Assign the M1025 macro to OEM Code 301
SetTriggerMacro(1025)
‘ Now, when OEMTRIGGER5 is driven to its active level,
M1025.m1s will be executed

Also read on forum for specific requests how to use brains, macro pumps (never used anything of that , but have feeling I will...)

So is there any solution or procedure what I need to activate,write to be able to use different OEMTrigger inputs (I read thate exist 15) to activate diffrent macros, I found posts from 2009 , I do not know is anything new since then...

So picture is worth 1000 words, I want to control over foot control (just for example) opening and closing part catcher, for that I use two inputs and two macros, it only works situation one input one macro (other input do job of first input what is wrong/duplicate, so I concluded that I need to know something more...)



Any help appreciated :)
 
I have tried to use the OEMtrigger to Macro Call before with no real success, not sure what it was, anyways, what I was trying to do was change the feedrate depending on which direction I had a switch.  In the macro I started out with an "IF" statement, if input 1 then ---> Code --> end if        if input 2 then ---> Code ---> end if.  From your pictures you may have to add an led to the screen to compare the two options.  But that would be simple enough.  Just a thought.
-Chad
Chad Byrd
I have tried to use the OEMtrigger to Macro Call before with no real success, not sure what it was, anyways, what I was trying to do was change the feedrate depending on which direction I had a switch.  In the macro I started out with an "IF" statement, if input 1 then ---> Code --> end if        if input 2 then ---> Code ---> end if.  From your pictures you may have to add an led to the screen to compare the two options.  But that would be simple enough.  Just a thought.
-Chad
Hi

Picture is just so I can easier explain what I did and what I want to do.

So when I press/activate mechanical switch which is connected to OEMTrig#1 I want for example to execute m301.m1s macro and when I press other switch that is connected to OEMTrig#2 I want to execute m302.m1s macro. So I do not want to press anything on screen in order to activate macro, because of that I am using OEMTrig#_ _ inputs (1 to 15).

This what you see on picture works only in case: choose one of 15 OEMTrigg# (inputs) and activate only one macro.

Offline Hood

*
  •  25,844 25,844
  • Carnoustie, Scotland
    • View Profile
Above I see m301.m1s and m302.m1s and all you seem to be doing is activating and deactivating OutPut 5, is that all you want to do?

If there is more to it can you put up examples of the macros?


Hood
Above I see m301.m1s and m302.m1s and all you seem to be doing is activating and deactivating OutPut 5, is that all you want to do?

If there is more to it can you put up examples of the macros?


Hood

Hi Hood, yes I want to learn how to do that over OEMTrig inputs because when I learn how to do that I will apply that knowledge to control power chuck and tail stock over foot control(2 pedals connected on push switches, so with one pedal will need to open and close power chuck and with other pedal move tail stock in or out). I wanted to start with something simple that I can control easy (those macros are little complicated then this example).

Like I said in first post I got feeling that will need to learn what is macropump, and I did, that was easy, thing is that in Mach3 Turn I have only 4 inputs so need to save them so because of that I want to use OEM Trigger for those things where I do not need to press anything on screen.

I manage to put macro for power chuck in macropump so for tailstock I can use OEMTrig#1 that calls one macro, but it would be better If I know how to control power chuck also over another OEMTrig input.

Have question, is it possible to use OEMTRig in macros like this If IsActive(OEMTrig1)Then or is IsActive reserved for Inputs (1 to 4), I got script error , I am not sure is it possible to use or I do not write OEMTrig1 good (OEMTrigger1, OEMTRIGGER#1.... or how else?)
« Last Edit: April 07, 2016, 05:45:30 PM by zmajmr »

Offline Hood

*
  •  25,844 25,844
  • Carnoustie, Scotland
    • View Profile
Ok the macropump is basically a macro that is constantly running in the background and can be used for things like this.
First thing to do is go to Config Menu then General Config and choose Run Macro Pump.

Next go to Operator menu and Choose Edit VB Scripts,  open the macropump.m1s.
Enter your code and save, making sure it is in the correct folder, it has to be in the profile folder that you are using which is in the macro folder., for example C:\Mach3\macros\Mach3Turn

For your examples above the code in the macropump would be

If IsActive(OemTrig1) Then
ActivateSignal(OutPut5)
End If

If IsActive(OemTrig2) Then
DeActivateSignal(OutPut5)
End If 


Now the important thing.
EVERY time you alter code in the MacroPump you MUST restart Mach as it loads only when Mach starts, so if you do not restart your previous code will still be loaded and thus you won't see any difference.

Hood
Ok the macropump is basically a macro that is constantly running in the background and can be used for things like this.
First thing to do is go to Config Menu then General Config and choose Run Macro Pump.

Next go to Operator menu and Choose Edit VB Scripts,  open the macropump.m1s.
Enter your code and save, making sure it is in the correct folder, it has to be in the profile folder that you are using which is in the macro folder., for example C:\Mach3\macros\Mach3Turn

For your examples above the code in the macropump would be

If IsActive(OemTrig1) Then
ActivateSignal(OutPut5)
End If

If IsActive(OemTrig2) Then
DeActivateSignal(OutPut5)
End If  


Now the important thing.
EVERY time you alter code in the MacroPump you MUST restart Mach as it loads only when Mach starts, so if you do not restart your previous code will still be loaded and thus you won't see any difference.

Hood

Hi again, thx for you answer, I learned all that few hours before you wrote it but it is good to have that information in one place for future readers.

Need to add that I discovered today that best place to put SetTriggerMacro(*********) command is in macropump, I wrote that my example works as it is but that is not 100% true , it works sometimes and sometimes not, when I cut and paste SetTriggerMacro(*********) to macro pump it works every time (but only in case one OEMTrigger#(input) triggers one macro), I experiment with already made macros that I activated over buttons on screen so because of that it sometimes worked and sometimes not.

Just wanted to document that if you want to use SetTriggerMacro, do what it say in manual and put SetTriggerMacro in macropump, so for my example:

in macro m301.ms

it needs to be only this content:

'part catcher
ActivateSignal(Output5)

and

in macropump (which is macro like Hood described) need to be
SetTriggerMacro(301)  

it is coincidence that my macro have number 301 same as code that need to be set for OEMTrig#1 in System Hotkeys Setup.

Hood, your code is OK and new thing that I learned from it is how to write IsActive(OemTrig2) ,   I tired lot of combinations so at the end I did not know is my syntax bad or I just can not check is OemTrig2 active in same way as I check is some Input active for example

IsActive(Input1)

So I did not tested your example but will .

Anyway I am trying to find out how to with OEM Trig1 and OEMTrig2 activate 2 different macros (I know it can all be in one macro but I want 2 macros because I have different macros that want to execute with different OEMTrig(Inputs 1 to 15).

So as I learned how to use macropump, I copy pasted code for operating power chuck in macropump so one problem solved and second macro for operating tailstock can be used with OEMTrig1 to activate macro that contains logic for operating tailstock.

So in conclusion, I solved problem (controlling power chuck and tail stock over physical buttons but not as I planed , 2 OEMTriggerInputs and 2 different macros), but it would be good to know is it possible to do that as I described , so maybe someone who see this have some idea or know how how to execute that , but if not OK, I will use it as I did.

New problem that I have is connected with problem of activation pump for lubrication bedways, in manual it say activate pump after 20 m of travel on period of 8 second.

I successfully made macro to do that, originally on z axis is mounted inductive sensor that sense every rotation of timing pulley and when I take in count that ballscrew have pitch 5 mm it is easy to calculate that need to active pump after 4000 pulses.

I made macro and connected it with button in mach3 screen (I named button Auto Lube) and in macro impulses are counted and saved in file named oilpump.txt, when 4000 impulses is counted output activates for 8 seconds and counter of impulses resets on zero , that is basically what macro does , in reality it have little more stuffs but pretty much that is idea.

Now problem is when I press RESET from some reason in Mach3, or some trigger is activated (soft limits or something third) my macro is rest also, so I need manually to press button on screen that activates macro , probably more experience users will say that is textbook example to use macropump, :). Well thing is that I tried to use it inside macropump but from some reason when code that works perfectly fine when it is activated over screen button, in macropump does not count existing pulses or in other word it counts too slow , I do not know how is that possible but it is (I was experimenting all day and it simply does not work good).

My friend told me that it is probably possible to set Mach3 to count step signals (good idea), I surfed on net but did not managed to find something that will help me.
So I wonder is it possible to use some function that will return step numbers or something similar or if somebody have some idea how to make my macro for controlling oil pump to work automatically after reset is acknowledge , macropump according to my test will not work, will copy past macro for oil pump which works good when it is activated ove button on Mach3 screen.

I removed while loop , sub main part when it is used in macropump, even tried to eliminate other parts but it simply does not want to count correct.

In case of no ideas I can use it as it works and will delete initialization part that sets initial set when file is opened for first time to zero and will activate it every time manually after RESET is triggered.

Hope you can follow what I write :)

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


P.S:

I am using Index and Timing inputs (Index is input that counts pulses from z axis and Timing is input on which is connected pressure switch from oil pump, I do not use parallel port , I am using CSMIO/IP-S motion controller so it works like this, I do not know is it bad idea or not, but what can you do when you have only 4 Inputs)  :)
« Last Edit: April 08, 2016, 12:22:39 PM by zmajmr »

Offline Hood

*
  •  25,844 25,844
  • Carnoustie, Scotland
    • View Profile
If you are using the CSMIO then you would be a lot better off using the built in modbus for its I/O.
It can be used via Macropump or Brains and doesn't require messing with OEMTriggers or setting up port and pin numbers in Mach, it also means you are not limited by the amount of Inputs in Mach.

I think CS-Lab have a macro for an oiler on their website.
Hood
If you are using the CSMIO then you would be a lot better off using the built in modbus for its I/O.
It can be used via Macropump or Brains and doesn't require messing with OEMTriggers or setting up port and pin numbers in Mach, it also means you are not limited by the amount of Inputs in Mach.

I think CS-Lab have a macro for an oiler on their website.
Hood

Well that is new information for me, I thought I have only 4 inputs (not sure what that means but I can tell that I needed to set which pin and port is used in input setup).

Yes they have macro for oil pump but it is based on time, it activates output every x minutes (you choose x by yourself) , I want to make lubrication according to manual of my machine and it say every 20 meters of travel.

I am messing with OEMTrigger(inputs) because I do not know how to trigger macros with out touching screen buttons in Mach3.

I was wondering all the time why I have so much inputs on CSMIO and I have only 4 inputs in mach3 turn.

So biggest problem for now is oil pump macro, like I said in macropump it just does not counts impulse correct (it manage to count every 10 impulses) and over macro triggered buy button it counts correct but RESET is party breaker :).

Offline Hood

*
  •  25,844 25,844
  • Carnoustie, Scotland
    • View Profile
Here is info on using CSMIO I/O
http://www.cs-lab.eu/en/upload/fotki/Elementy,%20banery/CSMIO-IP-A%20artykuł.jpg

I think there are also examples in the I/O modules manual.

There is stored info in Mach for axis distances but I am not sure if you can get that info from VB or not, you can view it from Operator Menu then Maintenance Hours.
Best bet would be to email Mach Support and see if there are any OEM codes for these DROs.
Hood