Hello Guest it is March 28, 2024, 08:31:38 PM

Author Topic: Problem with G91 and G90 in macro - tool changer  (Read 5090 times)

0 Members and 1 Guest are viewing this topic.

Problem with G91 and G90 in macro - tool changer
« on: November 06, 2015, 01:06:08 PM »
Hello everybody, my first post on forum.

I have problem, I am using Mach3 Turn for controlling Emco Turn 220 P.

I made macro for operating tool changer (with 8 tools), lathe have x and z axis and my motion controller have y axis also. I am using y axis for operating tool changer. Now problematic part

because of nature of design of turret it can only rotate it in one direction so after surfing on net I decided to operate turret by moving y axis in incremental distance more or G91.

Thing is that I want after positioning of turret is done , to get back in absolute mode or G90, and that I can not accomplish no matter what I try. In macro after turret is rotated for necessary amount I use command for activation of absolute distance mode , why, because I expect that  when I return in "main program" there should be activated G90 but it is not, I need to do it manually by typing in MDI g90, otherwise I can not activate go to home position plus some bad things happened ( I get notification that home position is not possible in incremental mode).

Other interesting thing that surprised me is that when I wrote in macro 2 commands , first for incremental movement and second for absolute movement , will happen that first will be executed part connected with absolute movement and then part with incremental movement.

From my experience till now with writing macros I learned that commands executed from top to bottom, this prove me wrong .





On those 2 pictures is my attempt to diagnose how macros work or why after my command Code "G90" there is not change when macro is executed , I mean it stay in incremental mode in main program / screen in Mach3 Turn.

So when I call m112 first what happens is: execution of movment on Z axis and after that execution m111 where in incremental mode my turret is being rotated until sensor is triggered.

I will even put videos of my work on turret so if somebody is interested he can see what I made

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

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

So main main problem is what to write in macro where is incremental mode used ( G91) so when I go back to main program I am again in absolute distance mode ( G90).

Hope I described my problem detailed enough, if somebody have any questions will try to help to explain non understandable things.
 :)
 

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Problem with G91 and G90 in macro - tool changer
« Reply #1 on: November 06, 2015, 05:31:58 PM »
OK first it is a BAD idea to call a macro from a macro with Code""  . Bad things can happen. There IS a way to do it check the latest manual for MACRO progamming .

If you need to switch back to Abs mode do it with  Code" G90"  I just tried it it works fine here in a turn macro.

(;-) TP
Re: Problem with G91 and G90 in macro - tool changer
« Reply #2 on: November 07, 2015, 06:26:07 AM »
OK first it is a BAD idea to call a macro from a macro with Code""  . Bad things can happen. There IS a way to do it check the latest manual for MACRO progamming .

If you need to switch back to Abs mode do it with  Code" G90"  I just tried it it works fine here in a turn macro.

(;-) TP

Hi , I thank you for replying , I tired first without calling macro in macro , but when I run out of ideas I tried to in macro call macro like in picture just so I can verify/determine what is going on, does G90 have any influence.

I made new movie so you can see what is going on
https://www.youtube.com/watch?v=gMtDIiEhH3g

here is code of

m111

Code " G90 "

Code "G91G01 Y9 F40"
While isMoving()
If (IsActive(Input1)) Then
DoOEMButton(1003)
    Code " G90 "          
End If
Wend


I tried like this too

Code " G90 "

Code "G91G01 Y9 F40"
While isMoving()
If (IsActive(Input1)) Then
DoOEMButton(1003)
            
End If
Wend
Code " G90 "


But does not help


And here is code for tool change (I need to solve problem with G91 to G90 switching there too, but I guess if some one help me to solve problem in m111 I will know how to change by myself.


This is M6Start.m1s
Code " G90 "

 Message "Previous tool was " &GetCurrentTool ()
 
 OldTool= GetCurrentTool ()

NewTool = GetSelectedTool ()

SetCurrentTool (NewTool)  

a=GetSelectedTool - OldTool

 If (a = 1) Or (a = -7) Then
 Code "G91G01 Y1.251 F200"
 Code "G91G01 Y-0.201 F10"
  While IsMoving()
  Wend

 End If
 
 If (a = 2)  Or (a = -6) Then
 Code "G91G01 Y2.301 F200"
 Code "G91G01 Y -0.201 F10"
  While IsMoving()
  Wend
 
 End If

 
 If (a =3)  Or (a = -5) Then
 Code "G91G01 Y3.351 F200"
 Code "G91G01 Y -0.201 F10"
  While IsMoving()
  Wend
 
 End If
 
 
If (a =4) Or (a = -4) Then
Code "G91G01 Y4.401 F200"
Code "G91G01 Y -0.201 F10"
 While IsMoving()
 Wend
 
 End If
 
 
 If (a =5)  Or (a = -3) Then
 Code "G91G01 Y5.451 F200"
 Code "G91G01 Y -0.201 F10"
  While IsMoving()
  Wend
« Last Edit: November 07, 2015, 06:28:40 AM by zmajmr »
Re: Problem with G91 and G90 in macro - tool changer
« Reply #3 on: November 08, 2015, 12:14:47 PM »
https://www.youtube.com/watch?v=gMtDIiEhH3g

does anybody have clue what I can try ?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Problem with G91 and G90 in macro - tool changer
« Reply #4 on: November 08, 2015, 03:36:04 PM »
You code is a bit odd in that you are calling and IF inside of a While Ismoving() statement

Try it like this

Code" G91"
Code" G01 Y9 F40"
Code"G90"
While Ismoving()
Wend

If Isactive (Input1) then
DoOemButton(1003)
else
Message" Function NOT active"
End
End If


You do need to plan for a timeout function to wait for it to happen. You can use a Do Loop with an excape function to exit in the event of an endless loop.

(;-) TP
Re: Problem with G91 and G90 in macro - tool changer
« Reply #5 on: November 08, 2015, 03:49:59 PM »
will try tomorrow in the morning, hope it will work, thank you :)
Re: Problem with G91 and G90 in macro - tool changer
« Reply #6 on: November 10, 2015, 02:40:13 AM »
I just wanted to try new idea from B459 s post , because I got no luck with my experimenting and after I turned on my computer other day and Mach3 I was surprised that code that I wrote actually works correct

so this works good:

Code " G90  "

Code "G91G01 Y9 F40"
While isMoving()
If (IsActive(Input1)) Then
DoOEMButton(1003)
Code " G90  "          
End If
Wend


Now I was wondering how come it did not worked day before, I had idea that maybe I need to write like this "G90"  instead " G90 " (with no space between quote marks and letter and number), so tired to play with this and that does not have influence.

Thing is that I was using MachScreen editor to connect button in Mach3 screen with execution of code, and I learned that function in Mach 3 (in Mach3 macro folder) must match with function you can access when you are in MachScreen editor, I even deleted macro in Mach3 (its content and you could still have it to work ) , and why it worked, because content was not deleted in MachScreen editor.

Anyway if you are not aware of this things you can try to modify macro all day and you can not see changes in work if you not change it in MachScreen editor. And after change it is good to close Mach3 and open it again so you can be sure that changes are refreshed/ updated. For macros that are not connected with buttons , I mean the ones  I did not added in MachScreen editor there was not problems , change was updated after I clicked in File Save option.

Anyway hope this will help to someone, I was really out of hope on this there was no logic to me , I mean why it did not worked.

Thanks once more for help BR549  :)