Hello Guest it is April 18, 2024, 11:08:14 PM

Author Topic: homing macro and Ismoving  (Read 13825 times)

0 Members and 1 Guest are viewing this topic.

Offline TPS

*
  •  2,505 2,505
    • View Profile
homing macro and Ismoving
« on: August 31, 2014, 10:18:48 AM »
Hello together,
first of all excuse my bad english.

after hours of searching i will post my problem here.

i have written a small macro for auto homing and clearing home limit swtiches if
necessary.

here the code:
Code: [Select]
Sub Main()
' -------------------------------------------------------------------------------
' TPS 30.08.2014 
' Referenzschalter freifahren und anschliessend Referenzieren
' -------------------------------------------------------------------------------
'beim Laden des Files Abbrechen
If IsLoading() Then
    GoTo Ende
End If

Message ("Automatische Referenzfahrt")

'Referenz INI Z freifahren
If GetOEMLED(836) Then
Code "G91" ' Inkremental Modus
Code "G0 Z-50" ' Freifahren
WaitMoving
Code "G90" ' Absolut Modus
End If

'Z referenzieren
DoButton(24)   'Zuerst Z
WaitMoving

'Referenz INI X freifahren
If GetOEMLED(830) Then
Code "G91" ' Inkremental Modus
Code "G0 X-50" ' Freifahren
WaitMoving
Code "G90" ' Absolut Modus
End If

'Referenz INI Y freifahren
If GetOEMLED(833) Then
Code "G91" ' Inkremental Modus
Code "G0 Y-50" ' Freifahren
WaitMoving
Code "G90" ' Absolut Modus
End If

'X und Y referenzieren
RefCombination(3) ' dann X und Y
WaitMoving
Code "G54" 'Koordinatenverschiebung ein
Sleep(200) 'warten
    Message (" ") 'Stauszeile löschen
Exit Sub
 '--------------------------------------------------------------------------------

Ende:
 
 Message ("Automatisches Referenzieren Abgebrochen")
   
End Sub   

'Funktion zum warten bis Antrieb steht
Function WaitMoving()
Sleep(200)
While IsMoving()
Sleep(200)
Wend
End Function 


sorry for the german comments.

the problem ist that the macro hangs in about 1 of 50 tryes
at the line

   While IsMoving()

line. if i press the stop button
i get the message:

internal error at line ..


i have no idea what i am doing wrong.

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

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: homing macro and Ismoving
« Reply #1 on: August 31, 2014, 10:30:04 AM »
Try removing the Sleep(200)'s from the WaitMoving function.

All you need is :

While IsMoving()
Wend
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: homing macro and Ismoving
« Reply #2 on: August 31, 2014, 01:25:26 PM »
Hello Gerry,

tryed this already, but i figured out
that without the sleep it does not
wait after the

DoButton(24)

for z-reference.

Thanks Thomas
« Last Edit: August 31, 2014, 01:30:59 PM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: homing macro and Ismoving
« Reply #3 on: September 02, 2014, 02:14:15 AM »
Hello,

back again after additional testing.

i tryed

Code: [Select]
Sleep(200)
While IsMoving()
Wend

crashed at line While IsMoving() with internal error

i tryed

Code: [Select]
While IsMoving()
Wend

did not stop after the DoButton(24)

i tryed

Code: [Select]
Sleep(200)
While Not IsStopped()
Wend

crashed allways at line While Not IsStopped() with internal error


maybe i am searching at the wrong side of the road, because i am
using a csmio/ip motion controller and do not know whether this
function call (IsMoving()) is only handled by Mach Software or
also by the plugin.

possibly i have to talk to the csmio/ip people.

Thanks Thomas





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

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: homing macro and Ismoving
« Reply #4 on: September 02, 2014, 04:16:36 AM »
I think you can change your home off distance in homing and limits config. to clear the switches by any amount you wish. I think you will continue to have problems as long as you use the while IsMoving() in the reference all button while using CSLabs. If you do ask CSLabs I would be interested in hearing their explanation.

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 TPS

*
  •  2,505 2,505
    • View Profile
Re: homing macro and Ismoving
« Reply #5 on: September 02, 2014, 04:26:50 AM »
Hello Brett,

i emailed CSlabs the problem.
will get back to you with the response.

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

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: homing macro and Ismoving
« Reply #6 on: September 02, 2014, 03:12:01 PM »
ok, small update,

i am sure it is not the Ismoving() thing.

replaced it with:

While GetOEMled(999)
Wend

should be the same i thought.
but i am geting no internal error anymore, it just hangs.

for the moment i am out off any ideas.

looks like i have to to accept, that it is not
working 'sometimes'.
with no idea what i can do if it is not working (automaticly)

just frustraiting.

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

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: homing macro and Ismoving
« Reply #7 on: September 02, 2014, 03:22:14 PM »
I had the same idea and tried the same with the same results. I had to just do it another way. Really, the way the CSLabs handles homing I figured out there was no need for the While IsMoving() in my script. I am acustomed to haveing to add a move away from the switch in my homing script. CSLabs will do this for you without altering the script. Just set your home off distance in Mach.

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 TPS

*
  •  2,505 2,505
    • View Profile
Re: homing macro and Ismoving
« Reply #8 on: September 03, 2014, 02:52:12 AM »
Hello Brett,

i thought this HOME OFF DISTANCE is the distance
witch is driven after the homing, i am gona test this today.

what i want to do with my script is to clear the homing limits
before i start a homing, because it is not homing when its
on an limit.

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

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: homing macro and Ismoving
« Reply #9 on: September 03, 2014, 04:43:21 AM »
Hello Brett,

her the answer for CSLab

Quote
Dear sir,
Homing is an autonomous function of CSMIO/IP motion controllers and Mach3 may have a problem with IsMoving() function.

To control if homing is finished you can use LED diodes  GetOemLed(807)  / GetOemLed(808) / GetOemLed(809).

DoButton( 22 )
Sleep(200)
While GetOemLed(807) = true
    Sleep(50)
    If GetOemLed(800) Then
        Sleep(500)
        Message"Error"
        End
    End If

Wend
Message"Axis referenced"

 The way shown above works perfect

Regards

Wojtek Trawicki

Thomas
« Last Edit: September 03, 2014, 04:44:56 AM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.