Hello Guest it is March 28, 2024, 03:10:19 PM

Author Topic: Terminate a brain with "run macro M650.m1s" ???????  (Read 39505 times)

0 Members and 1 Guest are viewing this topic.

Offline Greolt

*
  •  956 956
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #10 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
« Last Edit: February 25, 2008, 09:55:42 PM by Greolt »

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #11 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
« Last Edit: February 26, 2008, 09:48:06 AM by poppabear »
fun times

Offline Greolt

*
  •  956 956
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #12 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

Offline Greolt

*
  •  956 956
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #13 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

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #14 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

fun times

Offline Greolt

*
  •  956 956
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #15 on: February 28, 2008, 08:46:40 AM »
Thanks Scott.

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

Greg

Offline Greolt

*
  •  956 956
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #16 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. :)
« Last Edit: February 28, 2008, 07:55:41 PM by Greolt »
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #17 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.
« Last Edit: March 18, 2013, 03:02:45 PM by Kenneth »
Kenneth

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #18 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
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Terminate a brain with "run macro M650.m1s" ???????
« Reply #19 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
fun times