Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Mortenx on June 10, 2021, 09:40:45 AM

Title: Mach3 macro homing
Post by: Mortenx on June 10, 2021, 09:40:45 AM
Hi,

I have a lathe with a C-axis that is engaged with an electrical clutch to the spindle that works very well, I have a macro that enables the clutch and it works fine, then I have an other macro that also homes the C-axis that also works fine, the use of this is when I do more operations that have normal turning in between c-axis operations and these operations needs to be angled to each other. Every time a program calls my macro with homing and it's done I have to press cycle start to continue? guess it has something to do with the homing. My macros are like this:

with auto homing:

While IsMoving()
Wend
DoSpinStop()
While GetOEMled(1000)
Wend
If getoemled(164) Or getoemled(165) Then

Else

ActivateSignal(OUTPUT4)
Sleep(300)
   If GetOEMLED(845)   Then
      Code "G91 G0 C35"
      While isMoving()
      Wend
   End If
Code "G90"
DoOEMButton(1027)
While ismoving()
Wend
End If



without homing:

While IsMoving()
Wend
DoSpinStop()
While GetOEMled(1000)
Wend
If getoemled(164) Or getoemled(165) Then

Else

ActivateSignal(OUTPUT4)
Sleep(300)
End If   



Hope you can help me out, or give me a clue what to look for.

Regards Morten.
Title: Re: Mach3 macro homing
Post by: TPS on June 10, 2021, 11:21:42 AM
you can try to do a

RefCombination(32)

insteed of

DoOEMButton(1027)

maybe it helps
Title: Re: Mach3 macro homing
Post by: Mortenx on June 10, 2021, 12:59:19 PM

Thanks for the suggestion, I tried changing my macro, but if I run a g-code where it calls that macro it does not home my c-axis, and if I put it in the MDI it homes the c-axis but after that it kind of hangs for like 20 sec. before mach will accept a new command.

regards Morten
Title: Re: Mach3 macro homing
Post by: TPS on June 11, 2021, 01:58:10 AM
sounds strange. witch Version of Mach3 are you using?
Title: Re: Mach3 macro homing
Post by: Mortenx on June 11, 2021, 06:43:03 AM

Yeah it's strange, I use Mach3 version R3.043.062 - the recommended version with my ethernet smoothstepper.



Regards Morten
Title: Re: Mach3 macro homing
Post by: TPS on June 14, 2021, 01:13:53 AM
sorry, missed your answer.

for the Moment the only idea i have is, that Mach may be corrupted.
i would try to install a fresh copy.
Title: Re: Mach3 macro homing
Post by: Mortenx on June 22, 2021, 10:56:28 AM
Hi,

thanks for your answer, I tried another pc with a fresh mach3 install, same as above.

Guess I have to live with pressing cycle start for now:-)

Regards Morten
Title: Re: Mach3 macro homing
Post by: Graham Waterworth on June 22, 2021, 09:48:04 PM
Have you tried using the Standard button call DoButton (27)

or

Code ("G91 G28 C0")
While IsMoving()
  Sleep(25)
Wend

Title: Re: Mach3 macro homing
Post by: Mortenx on June 24, 2021, 02:35:31 PM
Hi,

Thanks for your reply, tried both solutions, the dobutton(27) also waits for cycle start to be pressed if called from a gcode, the other one works if I run it in the editor, but if called from a gcode it just does not home the axis, but does not wait for cycle start.

Regards Morten
Title: Re: Mach3 macro homing
Post by: TPS on June 25, 2021, 01:36:46 AM
witch Motion Controller are you usining?
Title: Re: Mach3 macro homing
Post by: Mortenx on June 25, 2021, 01:41:59 AM
Hi,

I am using a ethernet smooth stepper from warp9.

Regards Morten
Title: Re: Mach3 macro homing
Post by: Graham Waterworth on June 25, 2021, 10:21:03 PM
When you are trying the macro do you have single block enabled?

Title: Re: Mach3 macro homing
Post by: Mortenx on June 26, 2021, 01:04:35 AM
Hi,

No single step enabled, just runs the macro. Mach must have a stop function after doing a homing sequence?
Title: Re: Mach3 macro homing
Post by: TPS on June 26, 2021, 03:09:16 AM
here is a piece of code that i am using on one of my machines:

Code: [Select]
Sub Main()
' -------------------------------------------------------------------------------
' TPS 26.06.2021 
' do a referece 
' new version with OEM Led's
' -------------------------------------------------------------------------------
'quit if file is loaded
If IsLoading() Then
    GoTo Ende
End If

Message ("automatic reference started")

'reference Z
Message ("Z-axis reference")
DoOemButton(1024) 'Ref Z
Sleep(500)
While GetOemLed(809) = true
    Sleep(200)
    If GetOemLed(800) Then
        Sleep(500)
        Message"error while referencing"
        End
    End If
Wend

Sleep(500) 'wait
Message (" ") 'clear status line
Sleep(200) 'wait
Exit Sub
 '--------------------------------------------------------------------------------

Ende:   
End Sub     

it is for z-axis because i have no c-axis.
it runs from VB-Editor and also due g-code call.

in your case it would be oembutton(1027) and oemled(812) for c-axis.
Title: Re: Mach3 macro homing
Post by: Graham Waterworth on June 26, 2021, 12:56:11 PM
If you run a normal .tap file with the following lines what happens

%
O0001 (TEST C HOMING)
G91 G28 C0
M30
%
Title: Re: Mach3 macro homing
Post by: Mortenx on June 28, 2021, 01:25:47 PM
Thanks for all the answers.

I must have done something wrong when testing G91 G28 C0, because I can make that work, but it uses Mach3 homing setting and not the more precise smoothstepper homing - backing off the sensor at another speed.

When playing with the above, I found out that it homed at another speed and did not back of the sensor, and then it hit me, could it be a smoothstepper homing bug? Yes it is, if I disable the smoothstepper homing settings it works as expected.

I will contact warp9 and tell them about the bug.

Once again, thanks for all your solutions and help, this is a fantastic place.

Regards Morten.
Title: Re: Mach3 macro homing
Post by: Mortenx on July 01, 2021, 03:38:39 PM
Hi again,

It is not a ESS bug, but a mach3 thing - Andrew from warp9 explained to me...

But the G91 G28 C0 does not work - it just moves the C-axis to machine C0 position, but when the clutch for the caxis have been disengaged for normal turning it does not know where it is, I did not see this when playing with it the last time...

I have asked warp9 if they have a suggestion, and if possible to use ESS for homing only some axis and other use mach3 homing.

I am still open to any input you might have.

Regards Morten

Title: Re: Mach3 macro homing
Post by: TPS on July 02, 2021, 03:37:24 AM
have you tryed to use G28.1 insteed of G28

G28 is a Return to home Position
G28.1 is a Reference Axis
Title: Re: Mach3 macro homing
Post by: Mortenx on July 02, 2021, 09:20:40 AM
Hi,

Tried G28.1 and it works from the MDI, but if macro called from gcode, the smoothstepper takes over the homing and wait for cycle start :(

Regards Morten
Title: Re: Mach3 macro homing
Post by: TPS on July 02, 2021, 01:10:01 PM
this with the cycle start must be smoothstepper specific.

i use Buttons 22-24 on my machines (CSLAB controller) within macros and do not have to press cycle start.
Title: Re: Mach3 macro homing
Post by: Mortenx on July 02, 2021, 01:20:25 PM
Hi TPS,

thanks for your reply, I will link this to Andrew at warp9.

Regards Morten
Title: Re: Mach3 macro homing
Post by: TPS on July 02, 2021, 01:28:14 PM
attached a macro i use on one of my machines.

and this is a typical Header for my g-code

Code: [Select]
N0001 %1 (Teutoburger GC01 +C01 Tür links)
N0002 G61                                 (Genauhalt)
N0003 G90                       (Absolute Maßangaben)
N0004 G90.1                             (I/J absolut)
N0005 M5                                (Spindel aus)
N0006 G17                             (X-Y Fräßebene)
N0007 G21                               (alles in mm)
N0008 G40                       (Radiuskorrektur aus)
N0009 G49                       (Längenkorrektur aus)
N0010 G50                         (Skallierungen aus)
N0011 G54                  (Werkstückkoordinaten ein)
N0012 G43 H0             (Werkzeughöhenkorrektur aus)
N0013 M1004               (alle Achsen referenzieren)

i run this macro in all my programs
Title: Re: Mach3 macro homing
Post by: Mortenx on July 02, 2021, 01:31:32 PM
Thanks TPS,

I have written to Andrew and asked him to check this topic and your post, I will update this topic when I know more, thanks again!

Regards Morten