Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: whatda? on November 10, 2008, 11:13:56 PM

Title: Activating macros with more than one oem triggers
Post by: whatda? on November 10, 2008, 11:13:56 PM
Hi All,
Does anyone know If theres anyway to activate different macro`s with different oem triggers?
I have searched alot of the threads ,with no luck.
From what I have read,you can only use the one oem trigger to run only one Macro,
is this correct???

Problem is I have a pendant providing button inputs to a BB, which inturn I would like
to activate,
 1.Auto Z zero routine (macro)
 2.Auto zero xy offset routine,(from laser guidance).

Any help or ideas would be great,
OR   maybe there is a brain routine out there ....somewhere?


Thanks
regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 11, 2008, 05:53:00 AM
Whatda

Fairly sure you can do this with a macropump and a brain for each macro call.  Unfortunately I am not the one to ask how. :)

Poppabear will most likely be able to set you on the right track.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 11, 2008, 11:07:17 AM
Greg, thanks for the plug...........hehehee

Whatda, Like Greg said above (BTW he sales himself short he is Dead on with what he is telling you).

You can do it in a Brain, or Macro pump, or both........

I can help you but you will need to define what you want the Macros to do, perhaps post the two macros you want to activate here with their code. From the Code we can see what things can be done in Brians and what can be done in Macropump or both.........

scott

Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 11, 2008, 04:13:21 PM
Thanks guys,

Macro one... (auto  Z zero ) activated somehow from oem trigger6


CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' two second delay
Code "G31 Z-20 F100" 'Z goes down a max of 20mm at 100mm/min
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z20" 'retract Z to 20 mm
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)"
Exit Sub
End If



Macro Two... (auto zero XY from a offset laser) activated somehow from oem trigger5


Xmove = GetUserDRO(1152) 'X distance DRO
Ymove = GetUserDRO(1153) 'Y distance DRO

Code "G91 G0 X" &Xmove & "Y" &Ymove
While IsMoving ()
Wend
Code "G90 M9"
DoOEMButton (1008)
DoOEMButton (1009)


For info I am already using one initialization string (gen. config. page)
for activation of another macro (homing routine) via brtains.
And I cant see that you can use more than one ,ie this way.

Any help on this macro pump/brains would be excellent.


Thanks
Regards

Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 11, 2008, 06:14:51 PM
Oh.........ok

Put this in your Macro pump:

CounterFIVE = GetUserDRO(2100)
CounterSIX = GetUserDRO(2101)

If IsActive(OEMTRIGGER5) and CounterFIVE = 0 Then
Code "M*********"  'put your auto Z zero macro number here
CounterFIVE = 1
End If

If NOT(IsActive(OEMTRIGGER5)) and CounterFIVE = 1 Then
CounterFIVE = 0
End If


If IsActive(OEMTRIGGER6) and CounterSIX = 0 Then
Code "M*********"  'put your auto XY zero macro number here
CounterSIX = 1
End If

If NOT(IsActive(OEMTRIGGER6)) and CounterSIX = 1 Then
CounterSIX = 0
End If

'scott
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 11, 2008, 06:36:33 PM
Here is my try at it. Though I recommend you take Poppabear's more professional guidance.

As far as I know a brain can not trigger a macro on it's own.  So the macropump does that.

However brains are a no brainer to implement safety timers and lockouts.  (pun intended)  ;D

The two macros that you posted need to be placed in the macro folder with the name of your profile.  Eg.  Mach3Mill

Call them  M615.m1s  and  M616.m1s

The macropump calls the relevant macro when a user LED goes active. 

It basically is one which Poppabear wrote for me a while ago.  Much the same as posted above.

The brain sets the LED when the switch is pushed and held for 1.5 seconds but only if there is no motion,  the spindle is not running and reset is not active.

Being an external momentary switch I think the 1.5 second delay is a good safety measure.   

This means you must push and hold the switch for 1.5 seconds before anything will happen.

Do not want unintentional activation of either macro.

So the addition of the brain is just to allow for easy implementation of the safety lockouts.

Now take note I have done this as a learning exercise for myself.  Have a look but rely on Poppabear for proper advise.  :D


Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 11, 2008, 09:47:36 PM
Thanks very much for looking into this for me,
But I plugged it all in and nothing?
I think I have a basic idea of the processes but
 I must be missing something.(please bare with me, my half neuron is working over time)!

From what I gather , the macro`s run when either User led is activated,(from one of the Triggers),
I like the safety timer idea,excellent!
so far so good I hope????

So therefore I have to display/install a "User"Led on my screen ,
 how then would  I assign it a code . (eg GETOEMLED 1140)
I have looked at screen4 and I cant see how you do that?
A = GetOEMled (1140)
B = GetUserDRO (1140)
C = GetOEMled (1141)
D = GetUserDRO (1141)




And as you have shown on yours, Scott the macro pump  below,
which is  indicated as UserDROs ( which Iam not familar with also)

CounterFIVE = GetUserDRO(2100)
CounterSIX = GetUserDRO(2101)
Sorry but Iam not sure what these lines or numbers (ie 2100) should do either.

In the mean time I will go back to the books and try and figure this out,
Thanks for your efforts.


Greg ,That brain you posted ,looks great ,
I wish I knew what it all means? very impresive!!


Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 11, 2008, 09:51:25 PM
Whatda

Those User LEDs and DROs don't need to exist on screen.

Mach will just use them in the background.

Greg

EDIT:  Did you place the macro pump in the macro folder and activate it in General Config?  (Then Restart)
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 11, 2008, 10:34:51 PM
Go Get Um Greg!!! U DA Man!!!!

whatcha:  the Udros are used as interlocks so that the code runs only Once per button push, since the Macropump has a nonstop scanner once you enable it, the interlocks will not let the code execute more than once per push/release.

if safety is an issue, in the code in the Macro pump you can add "and" 's into the if statement like NotGetOEMLED800 to make sure the estop is not on ect.

scott
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 11, 2008, 10:40:00 PM
 ;D ;D Your taking the mickey out on me aren't you Scott.   ;D ;D

Seriously though, I for one appreciate all the help you give here and on other forums.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 11, 2008, 10:49:54 PM
hehehehehe............Yeap............

BTW: I am old and out of touch, what does taking the Mickey out on me mean?? I would like to use it in a sentance in my remedial class at local community college.  :)

scott
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 11, 2008, 11:01:11 PM
More polite way of saying "Taking the Piss"

If your so old should you not be in bed.  It is late.   ;D ;D
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 11, 2008, 11:36:18 PM
Thanks Guys,
Sorry ,probably need a abit more spoon feeding, on this one.

On the screen design ,do I put a DRO`s and LED`s somewhere,(even off the screen),
and then do I assign it with the codes you gave me in the box labeled "OEM code function)?

Thanks
Re gards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 11, 2008, 11:45:59 PM
Don't worry about the LEDs and DROs.

They do not exist as far as the screen is concerned.

They are just like a variable within Mach.  You never need to see them.

Mach will see them just fine even if they are not graphically represented on screen.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 12:09:48 AM
So basically copy and paste what you sent and enable macropump and the brain
and it should work.

Whatda
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 12:19:29 AM
Yeah that should be it.

Put the macropump along with the two macros named as we said into the macro folder.

The brain into the brain folder.  Enable the brain under Brain Control.

Activate macropump in General Config.

That's the easy bit.  :)

Most people I help have most trouble getting their switches set up to inputs on their BoB.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 01:58:57 AM
Well it worked,,,,YAAAAA!!!!  ;D

Thanks so much Greg and Scott,I would have never been able to make that brain.
Great program with excellent support,

Not sure about the delay (safety aspect) side of things with the brains
as the macros will run ,with a quick press of the button,
that is I dont have to hold the button down for 1.5 seconds.
Anyway it works and Iam happy with that.

I have attached a couple of photos of my homemade pendant,
and setup.

The little computer is a EEE pc which works well .

Thanks again
Regards
Whatda?


Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 02:16:37 AM
Glad it is working but I must have made a mistake in the brain timer.

Here is a new brain try it.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 02:34:08 AM
I will give it ago after dinner and let you know.

Thanks
regards
Whatda
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 04:16:35 AM
No ,Sorry it didnt work Greg.
Came up with trigger error, then shut mach down....whoops?
I have gone back to the old one for now.

Is there any chance you can make the same brain without the
timer function,so I can study whats actually happening before
the timer comes into play.
As I think what appears to happen is that the delay occurs prior
to running the macros.
That is, as the Auto Z zero button is pushed , about a 5 second delay occurs ,before the Z axis moves.


Anyway something to think about I guess.
But I would be greatfull If I could send the Brain without the timer.

Thanks
Regards
Whatda
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 05:46:58 AM
OK try this brain.  This one I tested on my machine. Works consistently.  :D

Also that Tool Zero macro that you are using has a delay in it.  Be better if that was taken out.

Two delays built in to the one routine is confusing.

Change this line,  Code "G4 P2" ' two second delay

To this,  Code "G4 P0.1" ' short delay

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 12, 2008, 09:58:07 AM
whatcha,

when your done, with Greg here, post up some pics of your machine.

scott
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 06:24:53 PM
OK ,I think Iam nearly there,


 Auto ZERO XY macro works well. (that is from OEMtrigger #5)

Auto Z zero not so well.(OEMtrigger #6)
On  starting mach up the auto zero routine starts,moving the z axis.
and other times no delay required on holding you finger down on the button,
starts straight away

Looking at the brain when Idle, I notice the first box with OEMtrigger #5( xy routine)
is shaded blue with a :0 after #5 ( I guess showing inactive)?

And the OEMtrigger#6 box is shaded green with a :1 after #6 ( I guess active?)
Is this how it should be?

Other than that ,I dont know I have looked at every other thing.

Here`s a few shots,
I wacked  a touch screen on the little EE pc ,which also works well.
Right now half way through a screen design.


Thanks regards
Whatda


Thanks
Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 12, 2008, 06:50:34 PM
Nice router looks like a Precix

   Look at the brain, and notice the initial Pulse delay time, the button has to be on for that delay time before the Pulse releases. If you want it to fire right at button push then put 0 in the initial delay.

scott
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 07:12:37 PM
I've had a go of one of those Exitech routers.  It had a DSP controller.

Have you ditched the DSP or did it come with PC control from the start?

With the brain we are obviously the blind leading the blind.

I probably should not have stuck my nose in.  Sorry about that.  :D

I have been playing around with it on my machine and it seems to work as expected including the delay.

If you are not fussed about the switch delay then I would ditch the brain altogether.

Every other safety thing the brain is doing can easily be incorporated into the macropump if needed.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 07:19:21 PM
Thanks Scott,but I dont think thats it.
There is some other thing that must be screwing with it.

Both triggers have the same delay programed in the brain.
The XY trigger works as it should. 

The z zero dosnt,
No Delay,momentary button push and away it goes?
And also on startup of mach the Z zero macro starts
and the Z axis starts moving down.(which is not real flash)

I have checked on the BB that the input is working as it
should, I think I will try another input ,
see how I go.

Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 07:24:25 PM
Whatda

With using the EEE I presume you are not running off an LPT

Are you using a SmoothStepper or some other external device?

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 07:30:08 PM
Greg ,your help/suggestions are all good,
gives me something to look at and learn,
mistakes are part of my process.

I dont think its from the brain you made though,
I`ll try changing the inputs,see what happens,
With my earlier remarks about the shaded coloured boxes around the initially trigger inputs
in the brain ,why is one coloured green and the other blue.

I have had nothing but trouble with this breakout board,
So strong chance its that.
I was going to send it back, but with postage cost ,better of sending it to the bin!!

Yes,it is a Chinese Excitech router,and it did come with a DSP which was OK ,but Very VERY limited
to what it could do.

I`ll do more testing


Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 07:31:41 PM
No the EEE pc only has USB and yes of the smooth stepper,
inwhich is excellent!!!!
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 07:40:44 PM
In my fiddling with it I have discovered something which you might be finding too.

On Mach startup the brain all works fine.  And I can watch it in "View Brain" no problems.

But if I "Reload Brain" and do not restart Mach it will play up.  And show in "View Brain" much the same as you are describing.

In the Artsoft Video it says you do not need to restart Mach but maybe that is incorrect.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 07:50:20 PM
I have it slightly different,
as when you first start mach ,and even when you load the brain
it fires of the Z zero macro (without a button push)

Thats why I thick these coloured boxes have the answer
That is ,this trigger is somehow active.

I have tried a different input  I will  now try another trigger,
which by the way how do you edit a brain?

Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 07:56:17 PM
Open it up in "Brain Editor"

Five minuets playing around with that and you will know more than I do about it.  ;D

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 08:02:26 PM
Yes I found the editor
and tried a different trigger,
still the same,
I will try the same input pin and trigger thats on the xy
see if I can fault find that way.
 thanks
Regards
Whatda
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 08:06:43 PM
Make sure with you trying different things that you don't get something wrong in "Ports and Pins"

Don't want two inputs on one pin or something like that.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 08:18:31 PM
I reversed the triggers around ,just in  the brain same results only with the other macro.

Is there any chance you could write a brain without the timer function and I`ll will check it out.


Thanks
Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 08:30:49 PM
I made up a simple brain IE trigger ------- Userled .

and its working find and not firing of the macro when
I start mach.
Not sure how I go about implementing the and or functions
with axis movement and the spindle on.

Will look into it and come up with some trial and ERROR stuff.,

Thanks
Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 08:32:13 PM
OK here it is.  You could write it in a couple of minutes.  It would be a good exercise to do.  :)

I repeat though there is no point having a brain at all if not wanting the timer.

It will all be simpler to do in the macropump with the exception of the switch delay.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 08:46:50 PM
Thanks For that Greg,
What I am trying to do is isolate the problem.
This will probably do for now though.

Thanks for all your help.

Is there any manuals on Brain,somewhere,
I can study up on,
I just had abit of ago then,but couldnt find
where you found/inputed ( and . and input.)
The rest  seems all straight forward ,,,sort of.

Thanks
Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 08:56:45 PM
There are a couple of videos.  Have a look at them.

Mostly you are going to learn more by poking around with it.

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 12, 2008, 09:01:02 PM
I think I found the problem,But Iam not sure how to fix it?
With that last brain you sent ,the z zero routine activates after
any  axis has been moved.
And every time you move a axis.

So somewhere in the and ,and input its getting into trouble.

Will keep trying.

Must go and have some Lunch.

Regards
Whatda?



Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 12, 2008, 09:36:51 PM
Well after you said that I raced out to the shed and tried it.

Apart from it having no delay (very quick) it worked fine on both macros.

I'm thinking you may have a dicky input.  Are you getting noise on it?

Have you tried the filtering in the SmoothStepper plugin?

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: poppabear on November 13, 2008, 12:22:48 AM
Look in your Ports and Pins under Inputs it sounds to me like you have One of the OEMTRIGGRS set to "Active High", and the other to "Active Low", OR, your actual swithes one may be N/C and the N/O.

scott
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 13, 2008, 02:02:05 AM
YES!!

Sorry to drag you guys trough all of this
But you are right one of the pins had to be
active High.
If I had known a bit more about Brains
I could have found that myself ,Sorry.

I had a felling that it was why the coloured boxes were
different in the initial inputs to brains??and
of course they are the same now,(no registered inputs).


Anyway working like a charm now,Thanks so much for your help.

NOw on to the next problem, No *********x in the fridge ,Bugger!


Regards
Whatda?
Title: Re: Activating macros with more than one oem triggers
Post by: Greolt on November 13, 2008, 03:08:23 AM
Glad it is going for you now Whatda.

Think about putting those time delays back in won't you.   ;D

Greg
Title: Re: Activating macros with more than one oem triggers
Post by: whatda? on November 13, 2008, 03:09:56 AM
Already in, and working like a treat,Thankyou


Whatyda?