Hello Guest it is September 27, 2021, 10:10:19 AM

Author Topic: I am having a sleep problem :)!~ CNC LATHE tool changer macro  (Read 1892 times)

0 Members and 1 Guest are viewing this topic.

Offline mike^3

*
  •  117 117
    • View Profile
I am having a sleep problem :)!~ CNC LATHE tool changer macro
« on: October 17, 2015, 06:00:28 PM »
Hi everyone! you are all great! I appreciate all help. Im getting really frustrated with this...  ??? ??? ???

Heres my problem, in this macro the second wait command does not happen, even though I think it is written properly. Please take a look


Here is the code that I have, it works fine but it will not wait after it senses the right input, I put ****** by it...



I only added the ****** for the first two cases, but not the rest, its the same thing for the rest. Perhaps the wait commands are not put in properly?



The first whileismoving() works fine but the second one does not work, it doesnt even wait... Any ideas?



'Macro ATC turret V2.02.01


Sub MovePos(ByVal ToolNumber As Integer)

OldTool = GetCurrentTool()

NewTool = GetSelectedTool()

ToolNumber = NewTool

If NewTool = OldTool Then

Message" Same Tool, NO ACTION"

End

End If

If NewTool > 8 Or NewTool < 1 Then

MsgBox" Tool # Not a Valid Number 1-8 ONLY, ENDING Program RUN "

DoButton(3)

End

End If

Tcount = 0

Select Case ToolNumber 'Position to each tool number by input signal

 

 

Case = 1

Message" Select Tool #1 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000 ******************it will wait here fine...

Wend


ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = true And GetOemLed(822) = false And GetOemLed(823) = false And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000 **********************It does not wait here for some reason***************

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"


End If


'''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop




message " Tool #1 Loaded"


''*****************************************************************

Case = 2

Message" Select Tool #2 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000 *************waits ok

Wend


ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = false And GetOemLed(822) = true And GetOemLed(823) = false And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000  **********************it does not wait

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If


''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop


message " Tool #2 Loaded"


''*****************************************************************

Case = 3

Message" Select Tool #3 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000

Wend



ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = true And GetOemLed(822) = true And GetOemLed(823) = false And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop

message " Tool #3 Loaded"


''*****************************************************************

 

Case = 4

Message" Select Tool #4 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000

Wend



ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = false And GetOemLed(822) = false And GetOemLed(823) = true And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop


Message " Tool #4 Loaded"


''*****************************************************************

Case = 5

Message" Select Tool #5 "



ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000

Wend


ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = true And GetOemLed(822) = false And GetOemLed(823) = true And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop

message " Tool #5 Loaded"


''*****************************************************************

Case = 6

Message" Select Tool #6 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000

Wend



ActivateSignal(Output6) 'Start Turret


Tcnt = 0

 

Do Until GetOemLed(821) = false And GetOemLed(822) = true And GetOemLed(823) = true And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If



'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop

message " Tool #6 Loaded"


''*****************************************************************

Case = 7

Message" Select Tool #7 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000

Wend


ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = true And GetOemLed(822) = true And GetOemLed(823) = true And GetOemLed(824) = false Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop

message " Tool #7 Loaded"


''*****************************************************************

Case = 8

Message" Select Tool #8 "


ActivateSignal(Output5) 'Releases stop dog


While IsMoving()

Sleep 1000

Wend


ActivateSignal(Output6) 'Start Turret


Tcnt = 0

Do Until GetOemLed(821) = false And GetOemLed(822) = false And GetOemLed(823) = false And GetOemLed(824) = true Or Tcnt > 200000

Tcnt = (Tcnt+1)

Loop


If Tcnt >= 200000 Then

DoButton(3)

DeActivateSignal(Output5) 'Stopping turret

DeActivateSignal(Output6) 'Lowering and stopping air motor

MsgBox" Tool Turret Timed Out not receieving input signal from turret encoder"

End


Else


DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor

Message"Lowering and stopping air motor"

End If


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Tcnt2 = 0


Do Until isactive(29) ' Check for reseating of turret

Tcnt2 = (Tcnt2 +1)

If Tcnt2 > = 10000 Then

DoButton(3)

MsgBox(" Turret Timed Out and Did Not Reseat")

End

End If

Loop

message " Tool #8 Loaded"

''********************************************************************

End Select


SetOemDro(824,NewTool)

End Sub

End

Offline TPS

*
  •  2,202 2,202
    • View Profile
Re: I am having a sleep problem :)!~ CNC LATHE tool changer macro
« Reply #1 on: October 18, 2015, 03:53:41 AM »
Hi,

While IsMoving()
Wend

is only used if any axis is moving (XYZABC)

so:
Code: [Select]
DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

While IsMoving()

Sleep 2000  **********************it does not wait

Wend


DeActivateSignal(Output6) 'Lowering and stopping air motor



should be:

Code: [Select]
DeActivateSignal(Output5) 'Trigger Stop Dawg

Message"Triggering Stop Dawg"

Sleep 2000  **********************it does not wait

DeActivateSignal(Output6) 'Lowering and stopping air motor



Thomas

anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline mike^3

*
  •  117 117
    • View Profile
Re: I am having a sleep problem :)!~ CNC LATHE tool changer macro
« Reply #2 on: October 18, 2015, 06:32:30 AM »
I tried that doesn't work....it still does not pause after deactivating output 5....any other wait functions?

Offline mike^3

*
  •  117 117
    • View Profile
Re: I am having a sleep problem :)!~ CNC LATHE tool changer macro
« Reply #3 on: October 18, 2015, 07:44:03 AM »
I got the pause to work properly by removing the while and wend functions!

But the turret is still not changing to the right positions,

heres a video

https://www.youtube.com/watch?v=sK_UEFM9VtQ

Offline TPS

*
  •  2,202 2,202
    • View Profile
Re: I am having a sleep problem :)!~ CNC LATHE tool changer macro
« Reply #4 on: October 18, 2015, 07:48:24 AM »
Hi,

you are "dancing" on two parties (threads) now.

have a look for the origin thread.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Tweakie.CNC

*
  • *
  •  8,807 8,807
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Re: I am having a sleep problem :)!~ CNC LATHE tool changer macro
« Reply #5 on: October 18, 2015, 10:49:44 AM »
It's certainly very confusing with two threads running on the same subject.  ???

Please continue this discussion here;   http://www.machsupport.com/forum/index.php/topic,30989.msg215501.html#new

Tweakie.
KEEP SAFE !