Machsupport Forum

Mach Discussion => Brains Development => Topic started by: Greolt on February 20, 2008, 06:42:45 PM

Title: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 20, 2008, 06:42:45 PM
Can I terminate a brain with "run macro M650.m1s"  ?

I want a simple LPT input to trigger a macro.  Are brains the way to do this?

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on February 20, 2008, 11:39:26 PM
Yes, but you will have to use brains and macropump

in brains:

InputX >NOP>UserLED1500  (save as name it, and turn it on in Brain config).

open up VB editor:

put thiis in and Save as "Macropump.m1s":

'Macropump.m1s

X=GetUserDRO(1500)

If GetUserLED(1500) and X=0 Then
code "M650"
SetUserDRO(1500,1)
end If

If Not(GetUserled(1500)) and X>0 Then
SetUserDRO(1500,0)
End If

'remember after you save it as your macropump, then turn on macro pump under general, close and reopen mach, make sure you enabled your triggger brain.
'scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 21, 2008, 06:05:24 AM
Thanks very much Scott.

I have read through your post about ten times.  :)

Mostly it makes sense. Couple of questions,

The purpose of the brain?  Is that just because I asked how to do it with a brain or is there a purpose for it?  Why not a macro pump alone?

UserLED and UserDRO.  Do they need to actually exist on the screen?  Or can they just be phantoms in the background?

Next question,  the purpose of this is to trigger a Auto Tool Zero routine with an external button press.

Do I need to build in protection against accidental activation while Mach is doing something else?  Running a program or whatever.  Or is Mach going to protect itself from that automatically?

If you have read this far thanks again.  :)

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on February 21, 2008, 10:16:09 PM
I did it with Brian becuase you wanted to do it that way.........hehehehe

You can do it with a Macropump alone if you want.

Yes the Dros and Leds can be invisibable.

No safeties are in it, you would need to put them there.

Scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 22, 2008, 12:11:50 AM
Thanks Scott

I'll have to get back to this in a couple of days.

We have our Melbourne Australia CNC BBQ on tomorrow and I have stuff to get ready. :)

Will have some more questions then. ;D

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 25, 2008, 05:02:33 AM
Scott

I have looked at this macro till my old brain hurts and I just can't get my head around it.

What is the purpose of reading and setting  "UserDRO (1500)"  ?

If I could grasp that the rest looks easy.

X=GetUserDRO(1500)

If GetUserLED(1500) and X=0 Then
code "M650"
SetUserDRO(1500,1)
end If

If Not(GetUserled(1500)) and X>0 Then
SetUserDRO(1500,0)
End If

Despite searching for a while, I don't understand the "If Not" .  Perhaps if I did the rest would make sense. ???

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on February 25, 2008, 11:51:58 AM
DRO 1500 is a "Lock out", it only allows the code to run ONE time in the macro pump per push and release of the button. Otherwize the macropump would hit the command several times before you could remove your finger.........

scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 25, 2008, 05:34:49 PM
OK let me ask about the "If Not"

It is this that is a sticking point in my grasping it.

This is my best guess at what it is,

If Not(GetUserled(1500)) and X>0 Then

Means

If GetUserLed(1500)  is zero and X > zero Then

Is that right?

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on February 25, 2008, 08:26:29 PM
hehehehe isnt logic FUN!!!!

  the If Not looks to see if it is OFF and if it is off that condition is TRUE cause the NOT inverts the logic............

Scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 25, 2008, 09:00:22 PM
So then I gather my example , the second one, is sort of right?

I know that it is not usable VB,  but is that what the first one means?

Thanks,  Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 25, 2008, 09:15:54 PM
Well here is my attempt at a working macro.

No laughing allowed.  ;D

I could not grasp the "If Not" thing but this makes sense to me.


'Macropump to activate Auto Tool Zero (M650) from an external switch via input #4
'OEMled 824 or Input 4, will be normally active (1) until switch is pressed/closed (0)

A = GetOEMLed(824)  ' Input 4 LED
B = GetOEMled(164)  ' Spindle Rotating LED
C = GetOEMled(999)  ' System movement Led
D = GetUserDRO(1500)

If A and B and C and D = 0 Then   ' if every one of the three LEDs and one DRO are at zero then the M650 will be run
Code "M650"
SetUserDRO(1500,1)
End if

If A and D > 0 Then     ' if the switch has not been released then A will still be at zero so this will act as a lockout
SetUserDRO(1500,0)
End if

What do you think? 

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on February 26, 2008, 09:43:32 AM
'First off, I would NEVER laugh at you, you can ask Brian, I started off not knowing a darn thing
'Like you I asked questions, and plugged at it and played with it, till I did know, still have alot to learn.


'Here is a correction to your macro below


'Macropump to activate Auto Tool Zero (M650) from an external switch via input #4
'OEMled 824 or Input 4, will be normally active (1) until switch is pressed/closed (0)

A = GetOEMLed(824)  ' Input 4 LED
B = GetOEMled(164)  ' Spindle Rotating LED
C = GetOEMled(999)  ' System movement Led
D = GetUserDRO(1500)

If (A = 0) and (B = 0)  and (C = 0) and (D = 0) Then   ' if every one of the three LEDs and one DRO are at zero then the M650 will be run
Code "M650"            'The INput4 is pressed here and it locks out here
SetUserDRO(1500,1)
End if

If (A = 1) and (D > 0) Then     ' if the switch has been released then A will be at 1 so this will unlock for next press
SetUserDRO(1500,0)            'the input4 switch has been released
End if

'scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 26, 2008, 05:29:29 PM
Thanks heaps Scott.

So I got it almost right except I did not know how the "and" statement worked.

That will mean I can have the Input #4 the more logical way.  At rest = 0,  Pressed = 1.

If (A = 1) and (B = 0)  and (C = 0) and (D = 0) Then

If (A = 0) and (D > 0) Then

I only had it around the other way because I thought I needed it to make the "and" work in the first line.

I'm off to test this on my router.

Have in mind to build in a delay so that the switch must be pressed for one second before the M650 will run.

But I will get back to that.   So beware of more questions soon. ;D

Thanks again,   Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 28, 2008, 07:44:47 AM
Scott

I got it to work.  Had to go with "IsActive(INPUT4)" as the "GetOEMLed(824)" would not work for some reason.

I tried to use "Ismoving()"  instead of  "GetOEMled (999)"  to check for system movement but could not figure how to get it to work.

Any ideas?

Greg




'Macropump to activate Auto Tool Zero (M615) from an external switch via input #4

A = IsActive (INPUT4)  ' Is switch pushed
B = GetOEMled (164)   ' Spindle is Rotating LED
C = GetOEMled (999)   ' System movement LED
D = GetUserDRO (1140)

If A And (B = 0) And (C = 0) And (D = 0) Then
Code "M615"
SetUserDRO(1140,1)
End If

If (A = 0) And (D > 0) Then
SetUserDRO(1140,0)
End If
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on February 28, 2008, 08:32:58 AM
try

C=IsMoving()

If A And (B = 0) And (C = Flase) And (D = 0) Then

Try these replacements see if it makes a difference, I havnt tested this, I am at work.

scott

Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 28, 2008, 08:46:40 AM
Thanks Scott.

Will try in the morning.  1:00 AM here.  :)

Greg
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Greolt on February 28, 2008, 07:52:56 PM
Scott

I have it all working as I wanted.

Using the brain to apply the switch delay (for safety)

Brain also takes care of checking that spindle and movement are not active (more safety)

Then hands it over to the macropump  ( a simpler version now)

It has the interlock and triggers the M615

I have learnt some new stuff.  :)

Thanks heaps for your help Scott

Greg

PS: that Ismoving() worked as you said but I'm not doing it that way now. :)
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 18, 2013, 02:54:01 PM
i'm trying to set three leds(XZY) to show movement. with program
running or jogging with keyboard or remote. i have this and it does
nothing even if i set the 0 to 1 or 1 to 0. don't want anyone
writiing the code just let me know which to use. or do i do this
in a brain ?

X = GetUserLED(1120)
Y = GetUserLED(1121)
Z = GetUSerLED(1122)
If IsMoving Then
SetUserLED(X,0)
SetUserLED(Y,0)
SetUserLED(Z,0)
Else
SetUserLED(X,1)
SetUserLED(Y,1)
SetUserLED(Z,1)
End If         

Thanks for any help

p.s. i know about LED 999, but would like to be able to see a led
light when i'm jogging one axis.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 18, 2013, 03:33:15 PM
I think a Brain would be better Kenneth.  But, your getting user leds and setting user leds based on those............. why not just put the user leds on the screen if they are showing movement?  I think I know what your wanting to do.  I did it once with a brain compareing dros for axis i think.  If the dros were changeing the leds would light.

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on March 18, 2013, 07:59:50 PM
'Try this in your macro-pump.

X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122
CurrXPos = GetOEMDRO(800)
OldXPos = GetUserDRO(2000)
CurrYPos = GetOEMDRO(801)
OldYPos = GetUserDRO(2001)
CurrZPos = GetOEMDRO(802
OldZPos = GetUserDRO(2002)

if CurrXPos <> OldXPos then
   SetUserLED(X_MovingLED,1)
   SetUserDRO(2000,CurrXPos)
else
   SetUserLED(X_MovingLED,0)
   SetUserDRO(2000,CurrXPos)
end if

if CurrYPos <> OldYPos then
   SetUserLED(Y_MovingLED,1)
   SetUserDRO(2000,CurrYPos)
else
   SetUserLED(Y_MovingLED,0)
   SetUserDRO(2000,CurrYPos)
end if

if CurrZPos <> OldZPos then
   SetUserLED(Z_MovingLED,1)
   SetUserDRO(2000,CurrZPos)
else
   SetUserLED(Z_MovingLED,0)
   SetUserDRO(2000,CurrZPos)
end if

'Scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 19, 2013, 08:46:23 AM
Thanks Brett and Scott,
i understand what you mean Brett, so i'm trying the below. not sure
about brains...still learning as i never saw anything like brain.below changes
the leds but i have to change the 0,1 positions in the script.

Scott,
i couldn't get yours to wotk(you were missing a parenthesis
if i changed 1,0 position, it did change the led. but didn't change
when i would jog an axis. one more thing is that i didn't have a userDRO(2000,2001 or 2002)
not sure if i was suppose to make em or they're a system defaults.
Thanks again


X = GetUserLED(1120)
Y = GetUserLED(1121)
Z = GetUserLED(1122)

If IsMoving() Then
   GetOEMDRO(0)
   SetUserLED(X,1)
Else
   GetOEMDRO(0)
   SetUserLED(X,0)
End If

If IsMoving() Then
   GetOEMDRO(1)
   SetUserLED(Y,1)
Else
   GetOEMDRO(1)
   SetUserLED(Y,0)
End If

If IsMoving() Then
   GetOEMDrO(2)
   SetUserLED(Z,1)
Else
   GetOEMDRO(2)
   SetUserLED(Z,0)
End If
         
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 19, 2013, 09:19:53 AM
stepping thru this, the program skips over the If
and goes straight to the Else. is this right ?
if i change SetUserLED(X,1) to SetUserLED(X,0)
the led changes
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 19, 2013, 09:39:31 AM
If an led is one, it is on.  The leds are two state images.  Half the pictur is for on, the other half is off.  If the image doesnt have the right picture on the proper side, it will reflect the opposite of what it actually is.

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 19, 2013, 09:41:51 AM
i have other leds that work as should. where do i find these pictur ?
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 19, 2013, 10:03:08 AM
Open your screen in Mach screen and look at the properties for the led.  That will tell you where the picture resides.

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 19, 2013, 10:07:58 AM
the image path is - None -
all my user leds have none but they work.
and all my picture are in Mach3\Bitmaps
and sub folder MillBitmaps
and i have Red/Green LED = Yes
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 19, 2013, 02:41:47 PM
this doesn't change no matter 0 , 1

X = GetUserLED(1120)
Y = GetUserLED(1121)
Z = GetUserLED(1122)

If IsMoving() Then
   GetOEMDRO(0)
    SetUserLED (X,1)
   GetOEMDRO(1)
    SetUserLED (Y,1)
   GetOEMDrO(2)
    SetUserLED (Z,1)
Else
   GetOEMDRO(0)
    SetUserLED (X,0)
   GetOEMDRO(1)
    SetUserLED (Y,0)
   GetOEMDRO(2)
    SetUserLED (Z,0)
End If
       
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 06:04:47 AM
tried below again and added a UserDRO(2000) and when i changed
SetUserDRO(2000,CurrZPos) to tried below again and when i changed
SetUserDRO(2000,CurrZPos)  to SetUserDRO(2000,100) it changes
the dro(2000) to whatever i change the number to. so i was wondering
if "Curr?Pos" works? as the dro never changes with Curr?Pos. not sure
about Old?Pos either :)
Thanks


X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122
CurrXPos = GetOEMDRO(800)
OldXPos = GetUserDRO(2000)
CurrYPos = GetOEMDRO(801)
OldYPos = GetUserDRO(2001)
CurrZPos = GetOEMDRO(802)
OldZPos = GetUserDRO(2002)

if CurrXPos <> OldXPos then
   SetUserLED(X_MovingLED,1)
   SetUserDRO(2000,CurrXPos)
else
   SetUserLED(X_MovingLED,0)
   SetUserDRO(2000,CurrXPos)
end if

if CurrYPos <> OldYPos then
   SetUserLED(Y_MovingLED,1)
   SetUserDRO(2000,CurrYPos)
else
   SetUserLED(Y_MovingLED,0)
   SetUserDRO(2000,CurrYPos)
end if

if CurrZPos <> OldZPos then
   SetUserLED(Z_MovingLED,1)
   SetUserDRO(2000,CurrZPos)
else
   SetUserLED(Z_MovingLED,0)
   SetUserDRO(2000,CurrZPos)
end if
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 07:23:36 AM
Never mind :)
i see what i misunderstood about Curr?Pos and Old?Pos
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 08:02:43 AM
clicking run continuely in the VB editor makes the UserDRO(2002) change.
and about every third to fifth click makes the UserLED change(Red/Green)
the UserDROs 2000 and 2001 never change that i can see

X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122

CurrXPos = GetOEMDRO(0)
OldXPos = GetUserDRO(2000)
CurrYPos = GetOEMDRO(1)
OldYPos = GetUserDRO(2001)
CurrZPos = GetOEMDRO(2)
OldZPos = GetUserDRO(2002)


If CurrXPos <> OldXPos Then
   SetUserLED(X_MovingLED,1)
   SetUserDRO(2000,CurrXPos)
Else
   SetUserLED(X_MovingLED,0)
   SetUserDRO(2000,CurrXPos)
End If

If CurrYPos <> OldYPos Then
   SetUserLED(Y_MovingLED,1)
   SetUserDRO(2001,CurrYPo0)
Else
   SetUserLED(Y_MovingLED,0)
   SetUserDRO(2001,CurrYPos)
End If

If CurrZPos <> OldZPos Then
   SetUserLED(Z_MovingLED,1)
   SetUserDRO(2002,CurrZPos)
Else
   SetUserLED(Z_MovingLED,0)
   SetUserDRO(2002,CurrZPos)
End If
       
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 08:21:41 AM
currently
dro 2000 = 0.00
dro 2001 = +10.00
dro 2002 = +27978.00

in the vb editor if i change UserDRO(2002 .CurrZPos)
to UserDRO(2002 .0) the number changes to zero. if set back to
UserDRO(2002 .CurrZPos) changes back to +27978.00
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 10:08:21 AM
one more thing. the three userdro(2000,2001,2002)
i can enter info into 2001 and 2002, press enter and the info
remains. when i try that with 2000, it always goes back to zero.
ALL three have the same info in machscreen, except for oem code.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 20, 2013, 10:33:34 AM
Are you useing 2000 in another macro or for soemthing else in the screen already?  Looks like the code in last few post is writing to dro 2000.  If that code is running in a macro pump you can enter what you want and every time the macro runs it will rewrite it to what you have told the macropump to.

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 11:07:59 AM
no sir, that is the only dro 2000. this is the first
i use 2000,2001 and 2002.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 20, 2013, 11:34:46 AM
just to make sure i didn't do something i shouldn't,
i changed from Version R3.043.066 to Version R3.043.062
cause i read 66 was unstable.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 20, 2013, 02:54:31 PM
Going back to .062 should be fine.

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 21, 2013, 01:48:57 PM
got this to work. it changes the dros but the leds only change if dros
are different(off) otherwise if same(on). does change anything
when movement.


X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122

CurrXPos = GetOEMDRO(800)
OldXPos = GetUserDRO(2001)
CurrYPos = GetOEMDRO(801)
OldYPos = GetUserDRO(2002)
CurrZPos = GetOEMDRO(802)
OldZPos = GetUserDRO(2003)

While IsMoving()
Wend
If CurrXPos <> OldXPos Then
   SetUserLED(X_MovingLED,1)
    SetUserDRO(2001,CurrXPos)
Else
   SetUserLED(X_MovingLED,0)
    SetUserDRO(2001,CurrXPos)
End If
While IsMoving()
Wend

If CurrYPos <> OldYPos Then
   SetUserLED(Y_MovingLED,1)
    SetUserDRO(2002,CurrYPos)
Else
   SetUserLED(Y_MovingLED,0)
    SetUserDRO(2002,CurrYPos)
End If
While IsMoving()
Wend

If CurrZPos <> OldZPos Then
   SetUserLED(Z_MovingLED,1)
    SetUserDRO(2003,CurrZPos)
Else
   SetUserLED(Z_MovingLED,0)
    SetUserDRO(2003,CurrZPos)
End If
         
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: poppabear on March 22, 2013, 03:58:59 PM
Isn't that the same code, I posted up for you, with the exception you added while IsMoving()?
If so, DON'T put a while IsMoving() in a macro pump (if that is where you put it), it will cause you PROBLEMS.
Also, If your LED are showing reversed logic, then swap the 1 and 0.
OR, if your mapping them through a brain for some other reason, invert the input.

scott
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 25, 2013, 05:51:02 AM
the same code, except i changed my dros from 0,1,2 to 800,801,802 and it started working.
this is a VB script. not using brain or pump(not sure what's a macro pump). it doesn't change
the leds UNLESS i change the position of ON(1) and OFF(0) in the scrip.
so maybe i'm using the scrip wrong.
 Thanks Scott.

there's a reason why there're two sets of dros?
0,1,2 and 800,801,802
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 07:38:02 AM
using your code, the LEDs change if the two DROs are different(on)
OR that same.(off) not if they are moving. so i was trying different things.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 08:36:23 AM
with below, starting with LEDS off and DROs same.
clicking does nothing. if i change the position of XY and/or Z
the LEDs turn on for any axis that is different from userDRO.
click again and they turn off. clicking again changes nothing. as long
as the two DROs arethe same. turns on again if different. so i'm still
trying........

p.s. is there a doc for the different comparison"<>"

X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122

CurrXPos = GetOEMDRO(800)
OldXPos = GetUserDRO(2001)
CurrYPos = GetOEMDRO(801)
OldYPos = GetUserDRO(2002)
CurrZPos = GetOEMDRO(802)
OldZPos = GetUserDRO(2003)

If CurrXPos <> OldXPos Then
   SetUserLED(X_MovingLED,1)
    SetUserDRO(2001,CurrXPos)
Else
   SetUserLED(X_MovingLED,0)
    SetUserDRO(2001,CurrXPos)
End If

If CurrYPos <> OldYPos Then
   SetUserLED(Y_MovingLED,1)
    SetUserDRO(2002,CurrYPos)
Else
   SetUserLED(Y_MovingLED,0)
    SetUserDRO(2002,CurrYPos)
End If

If CurrZPos <> OldZPos Then
   SetUserLED(Z_MovingLED,1)
    SetUserDRO(2003,CurrZPos)
Else
   SetUserLED(Z_MovingLED,0)
    SetUserDRO(2003,CurrZPos)
End If
                     
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 09:01:08 AM
tried below with  Curr?Pos = IsMoving
with nothing changing

X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122

CurrXPos = GetOEMDRO(800)
CurrYPos = GetOEMDRO(801)
CurrZPos = GetOEMDRO(802)

If CurrXPos = IsActive(X) Then
   SetUserLED(X_MovingLED,1)
Else
   SetUserLED(X_MovingLED,0)
End If 

If CurrYPos = IsActive(Y) Then
   SetUserLED(Y_MovingLED,1)
Else
   SetUserLED(Y_MovingLED,0)
End If

If CurrZPos = IsActive(Z) Then
   SetUserLED(Z_MovingLED,1)
Else
   SetUserLED(Z_MovingLED,0)
End If
                     


X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122

CurrXPos = GetOEMDRO(800)
'OldXPos = GetUserDRO(2001)
CurrYPos = GetOEMDRO(801)
'OldYPos = GetUserDRO(2002)
CurrZPos = GetOEMDRO(802)
'OldZPos = GetUserDRO(2003)

If CurrXPos = IsActive(800) Then
   SetUserLED(X_MovingLED,1)
    'SetUserDRO(2001,CurrXPos)
Else
   SetUserLED(X_MovingLED,0)
    'SetUserDRO(2001,CurrXPos)
End If 

If CurrYPos = IsActive(801) Then
   SetUserLED(Y_MovingLED,1)
    'SetUserDRO(2002,CurrYPos)
Else
   SetUserLED(Y_MovingLED,0)
    'SetUserDRO(2002,CurrYPos)
End If

If CurrZPos = IsActive(802) Then
   SetUserLED(Z_MovingLED,1)
    'SetUserDRO(2003,CurrZPos)
Else
   SetUserLED(Z_MovingLED,0)
    'SetUserDRO(2003,CurrZPos)
End If
           
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 09:50:36 AM
trying 3 single scripts for each axis.
no worky

?_MovingLED = 112?

Curr?Pos = GetOEMDRO(800)
X = XY or Z

If CurrXPos = IsActive(800) Then
   SetUserLED(?_MovingLED,1)
 Else
   SetUserLED(?_MovingLED,0)
 End If 

just so ya'll know what i'm doing.
open mach3, menu Operator\VB Script Editor.
then running script from there.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 10:14:23 AM
and does mach3 run ALL the scripts in c:\mach3\macros\userfolder  ?
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 26, 2013, 10:43:19 AM
Kenneth, I think you are wanting leds assigned to each axis that turn on when that axis is moveing.  Is that correct?

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 11:18:50 AM
yes sir
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 26, 2013, 11:44:21 AM
I dont see how you will ever do that in a button.  The script in a button runs once for each press unless the script tells it to run in an infinate loop which is not good.  The macro pump is like a button that runs roughly 10 times a second, brains are faster than that.

Brett
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:01:55 PM
Hi Kenneth,
   I've been watching this since you started. I'm no macro author so I could make no suggestions.
But, I did do as PoppaBear offered and with a slight typo correction, his scheme worked perfectly here.
I added 3 LED's, one beside each axis DRO and put the following in the pump. Seems to work like a charm.
If anything is moving, the associated LED is ON.

X_MovingLED = 1120
Y_MovingLED = 1121
Z_MovingLED = 1122
CurrXPos = GetOEMDRO(800)
OldXPos = GetUserDRO(2000)
CurrYPos = GetOEMDRO(801)
OldYPos = GetUserDRO(2001)
CurrZPos = GetOEMDRO(802)
OldZPos = GetUserDRO(2002)

If CurrXPos <> OldXPos Then
   SetUserLED(X_MovingLED,1)
   SetUserDRO(2000,CurrXPos)
Else
   SetUserLED(X_MovingLED,0)
   SetUserDRO(2000,CurrXPos)
End If

If CurrYPos <> OldYPos Then
   SetUserLED(Y_MovingLED,1)
   SetUserDRO(2001,CurrYPos)
Else
   SetUserLED(Y_MovingLED,0)
   SetUserDRO(2001,CurrYPos)
End If

If CurrZPos <> OldZPos Then
   SetUserLED(Z_MovingLED,1)
   SetUserDRO(2002,CurrZPos)
Else
   SetUserLED(Z_MovingLED,0)
   SetUserDRO(2002,CurrZPos)
End If  

I wish I could offer more and I hope I am understanding exactly what it is you are wanting.
Cheers,
Russ
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 12:06:21 PM
thanks, think that's my problem. i'm not using a pump, brain OR button :)
was just writing script and think it would run. i was thinking a script WAS a
pump. so how do i write one of these pump things ? :)
Thanks again Brett and Russ
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:09:57 PM
In your M3 folder, open macros, choose the profile you are running, then open macropump.m1s.
Copy and past what I posted in there and save.
thats it.
all you need is the 3 user led's on your screen, the user dro's are invisible to you
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 12:13:44 PM
the file i'm using is in that folder and i don't
have a file named macropump.m1s in there.
and i did try this before, it just changed the leds once
bunch of m##.m1s
thanks

p.s. if i don't have the DROs in the set file, will it work ?
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:22:42 PM
Should be there, you must have lost it.  :D

Put you another one there, open the editor, paste in the stuff, then name Macropump.m1s.
No prob.
Russ
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:27:57 PM
Better yet, just plop this in your profile macros folder

Just remove the KENNETH_
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:31:06 PM

 

p.s. if i don't have the DROs in the set file, will it work ?


yep .. you dont need to see 'em, the macro is comparing them so it can show you the led's ... you dont need to see 'em at all.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 12:40:27 PM
i copied the file to c:\mach3\macro\userprofile
looked at my set file to see if the LEDS and DROs
were set the same(they are). i'm missing somethinbg else
as this doesn't do anything but change the LED once and
doesn't change the userdro to the same as oemdro.

will delete the dros after i get this straight
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:44:16 PM
Do you have "Run Macropump" checked in Gen. Config ?
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 12:46:01 PM
then shut down Mach and restart ... just for shts n' giggles.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 12:53:47 PM
did that(twice...while giggling)
when i open mach3, Y leds is lit. if i move it
with arror keys. it goes off(0) but if i move Z,
y dro changes. i check the set file and they are different.
yes Pump is clicked in general

oemdro = x 800
y = 801
z = 802

userdr = 2001 - 2002  -  2003
(changed em to stop using 2000)

p.s. i renamed the file from KENNETH_Macropump.m1s
to Macropump.m1s.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Overloaded on March 26, 2013, 01:05:50 PM
did that(twice...while giggling)
 

userdr = 2001 - 2002  -  2003
(changed em to stop using 2000)

 
;D
You did change every instance of the new dro's in the macro ?
You have tried so many things, you might have internal conflicts. Get rid of anything you're not using (been there)
Also, mine blinked a little strange at first (i think), loaded and ran a small gcode file and it's been perfect ever since. (don't know why that would matter though).
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 26, 2013, 01:16:59 PM
shut down mach3 and machscreen. opened macropump
and checked everything. i did have the dros off by one number.
(don't know why that matters) opened mach3 and poof....
working. they blink if i jog a few seconds but think it's just because
of the loop. THANKS !!!!!!!!!!!!!!!!!!!!!

Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 27, 2013, 06:47:59 AM
so i HAVE to have a file named macropump and everything in it will run ?
could i have left the name KENNETH_macropump ? and do ALL
the files in userprofile folder run all the time or some do and others are
connected to buttons. trying to understand macropump. is it just
the file name ? is the m1s extension pump related ? :)
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 27, 2013, 10:25:43 AM
macropump.m1s is the only macro the pump runs and it must be named correctly.  In fact, I don't think if the m on macropump was capitalized it would run.  You need to realize that in a computer, the name is the same as an address.  Some things will allow for discrepancies such as capitol or lower case but most will not.  If you have one digit, space, letter, character wrong, you will be pointing to something other than you planned.  macropump.m1s is the file that the macropump runs.  It is looking for macropump.m1s and no other.  It is also looking for it in the macros folder, sub folder of the profile you created it for.  If one digit is different, not even on the same street as the one it's looking for.  Wrong folder and it might as well be in a different state.  Wrong drive and it's in another world.  This is true for image locations in screens too.

Everything in the macropump will run roughly 10 times a second but be careful.  If your macros are large it will take longer to run through them so the update will be slower making it less than 10 times a second.  Also, you can get yourself into a mess with the wrong bit of code in a macro.  For what your doing I think a brain would be a much better option.

No, not all the macros in a profiles marcos folder run all the time, the macropump.m1s is the only one and only if it is enabled in general config.  The others run only when called by a button, gcode, etc.

Yes, exactly, it is just the file name as most things in a pc are. KENNETH_macropump.m1s would have never ran the first time. Neither would macr0pump.m1s.  All I changed is the o for a zero......... that one has bitten me more than once.

The .m1s extension is a macro. m4.m1s is the spindle CCW macro.

Brett

 
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Chaoticone on March 27, 2013, 11:24:06 PM
Quote
I don't think if the m on macropump was capitalized it would run.

I stand corrected........... one of the other good members sent me a PM informing me that in CB, nothing is case sensitive.  I hesitated to post this because I think consistency is very important in some things.  So, you may well have no problems swapping capitalized letters for lower case and visa verse but I think when doing things of this nature, it is all practice and should be used to enforce good habits, not create bad ones.

Brett   
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: BR549 on March 29, 2013, 01:41:33 PM
Not exactly sure of what yall are doing BUT have you thought of using the "Execute Button Script" function to terminate the brain ?

Just a thought, (;-) TP
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on March 30, 2013, 12:05:57 PM
ok.... what i'm trying to do.
i would like to have LEDs light when i'm jogging or a program is running and the axis are moving.
didn't know which to use, brain,script or whatever there is available. so i started
with script as i did a "little" of that before. let me know which would be better and
i'll erase all i have and start on that.

P.S. i do appreciate ALL ya'll help.
THANKS!!!!!!!!!!!!!!!!!!!!!!!!!
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: BR549 on March 30, 2013, 07:43:46 PM
OK look at the axis vel dro, if greater than ZERO turn on a LED else (if = to zero) turn the led off.

If GetDro(6) >0 then  ' If A axis is moving
SetUserLed(2000,1)   'A axis LED
Else
SetUserLed(2000,0)
END IF

Same for all axis you want to monitor.  You can run it as a Brain OR a macropump.

IF you run it as a Macropump ypou need to put in some code to bypass the function IF conditions are the same each pass of the pump to keep from bogging down the MP

 OR am I missing something?

Just a thought, (;-) TP
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: BR549 on March 30, 2013, 08:51:20 PM
This works here from the macropump. IF the led function is current then it bypasses the function .

'Axis Motion LED Control**********************
' X axis LED = 2000
' Y axis LED = 2001
' Z axis LED = 2002


'X axis LED Control***************************

If GetDro(6) > 0 And  GetUserLED(2000) = 0 Then
   SetUserLED(2000,1)
End If

If GetDro(6) = 0 And GetUserLEd(2000) = 1 Then
   SetUserLed(2000,0)
End If

' Y axis LED Control***************************

If GetDro(7) > 0 And  GetUserLED(2001) = 0 Then
   SetUserLED(2001,1)
End If

If GetDro(7) = 0 And GetUserLEd(2001) = 1 Then
   SetUserLed(2001,0)
End If

'Z axis LED Control*****************************
If GetDro(8) > 0 And  GetUserLED(2002) = 0 Then
   SetUserLED(2002,1)
End If

If GetDro(8) = 0 And GetUserLEd(2002) = 1 Then
   SetUserLed(2002,0)
End If

'End of File***********************************

End
  
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on April 01, 2013, 07:35:27 AM
thank you TP and BR549.
this works better as the LEDs don't blink if axis moves a longer than a
1/2".  they're either on or off.

which would be 'better' to use to not to make mach3/computer
do a lot of work for nothing? brain or script(micropump)?
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: BR549 on April 01, 2013, 09:34:03 AM
In this case the macropump as you can run a bypass type code that does not pulse the LED every pass.

(;-)TP
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 11:00:37 AM
getting back into mach3 and getting a controller that will work with it.
i'm having trouble getting "all" the macros to work. some do, some don't
beloew is one that doesn't. i figured if i (ya'll) can fix one, the others will follow :)

not me script(thanks TP)

'Axis Motion LED Control**********************
' X axis LED = 1120
' Y axis LED = 1121
' Z axis LED = 1122


'X axis LED Control***************************
If GetOEMDro(800) > 0 And GetUserLED(1120) = 0 Then
   SetUserLED(1120,0)
End If

If GetOEMDro(800) = 0 And GetUserLEd(1120) = 1 Then
   SetUserLed(1120,0)
End If

' Y axis LED Control***************************

If GetOEMDro(801) > 0 And  GetUserLED(1121) = 0 Then
   SetUserLED(1121,1)
End If

If GetOEMDro(801) = 0 And GetUserLEd(1121) = 1 Then
   SetUserLed(1121,0)
End If

'Z axis LED Control*****************************
If GetOEMDro(802) > 0 And  GetUserLED(1122) = 0 Then
   SetUserLED(1122,1)
End If

If GetOEMDro(802) = 0 And GetUserLEd(1122) = 1 Then
   SetUserLed(1122,0)
End If

'End of File***********************************

End
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 11:25:10 AM
and i have Run Macro Pump clicked in Config/gen set
there's no other setting some where. is there ?

running ver 3.043.062
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: cncalex on January 20, 2014, 11:38:38 AM
vel Dro X =806
vel Dro Y =807
vel Dro Z =808

Every time you check / uncheck run macro pump, or after you edited it you must resart Mach3

Alex
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 11:51:25 AM
yes sir, i do restart mach3 after clicking RMP.
what's "ChargePump On In Estop" ?
does that start macropump when estop is pressed ?
Thanks

kenneth
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 11:55:02 AM
think i misunderstood MacroPump. i'm not using file macropump.
this is a macro. does that matter ?
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 12:07:31 PM
i noticed if i "step" it in the editor, it skips SetUserLed and just
goes to Get....
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: cncalex on January 20, 2014, 12:22:04 PM
If you want it run " all the time "  then you need the macropump.m1s  All other macros run only one time when you call them from MDI or G-Code or Butten Press.
Also it can be done with a Brain.
The "ChargePump On In Estop" means that the saftey signal  ( ChargePump ) will be activated even when Mach is in E-Stop ( Reset ) state.
Alex
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 12:28:38 PM
thank Alex,
using the macropump, the waits a couple of seconds
before lighting. i know the pump runs fast. are the leds
waiting for the pump to cycle ? and a while back, they helped
me get it working as a separate macro.
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 02:38:23 PM
got macropump to work. it hesitates starting and stopping.
but i guess that would be my computer slowing the macropump.
THANKS Alex !
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: Kenneth on January 20, 2014, 02:46:08 PM
for those who would like this macro...

'Axis Motion LED Control**********************
' X axis LED = 1120
' Y axis LED = 1121
' Z axis LED = 1122


'X axis LED Control***************************
If GetOEMDro(806) > 0 And  GetUserLED(1120) = 0 Then
   SetUserLED(1120,1)
End If

If GetOEMDro(806) = 0 And GetUserLEd(1120) = 1 Then
   SetUserLed(1120,0)
End If

'Y axis LED Control***************************

If GetOEMDro(807) > 0 And  GetUserLED(1121) = 0 Then
   SetUserLED(1121,1)
End If

If GetOEMDro(807) = 0 And GetUserLEd(1121) = 1 Then
   SetUserLed(1121,0)
End If

'Z axis LED Control*****************************
If GetOEMDro(808) > 0 And  GetUserLED(1122) = 0 Then
   SetUserLED(1122,1)
End If

If GetOEMDro(808) = 0 And GetUserLEd(1122) = 1 Then
   SetUserLed(1122,0)
End If

'End of File************************************

End
Title: Re: Terminate a brain with "run macro M650.m1s" ???????
Post by: cncalex on January 20, 2014, 03:37:07 PM
Glad you are sorted.  :)

The  Brian works also. see pict.

Alex