Hello Guest it is March 28, 2024, 03:30:35 PM

Author Topic: Resetting machine coordinates in G code program  (Read 15947 times)

0 Members and 1 Guest are viewing this topic.

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #20 on: June 30, 2015, 10:35:53 PM »
that`s better yes there is using a Macro b or a Macro call at the end of the G code or what may be easier is a trigger when the eye see the notches it stop all motion then re zero the axis`s you don't need to re home if the distance between each notch is the same, you just need to do a Work Zero.

if it`s not then you will need to home the axis`s every time you do a run

a macro like what you did would work how mad lou did it with a trigger to make it happen first so trigger, stop all motion de ref the machine re home start again if notches not the same or stop all motion zero all axis back to work zero start again if notches are the same if they are, zeroing in work will not change home if you home first home is where the machine is in spaces, work is where the work is retaliative to home
Re: Resetting machine coordinates in G code program
« Reply #21 on: July 01, 2015, 12:05:24 AM »
Here ya go. Try this. I had to put Lua to sleep for 5 seconds to let Mach4 report, exit, enter the appropriate machine state to continue.

The 5 seconds should be reset to the time it takes for your machine to home the X axis. To fast and Mach4 cannot properly communicate with the controller. In the simulator, I had it as fast as 2 seconds. But that's the sim and not real life. After the m101 macro, the X axis is re-homed, the next block of gCode is executed.

function m101 ()
    local inst = mc.mcGetInstance ()
    mc.mcCntlCycleStop (inst)
    mc.mcAxisHome (inst, 0)
    wx.wxSleep (5)
    mc.mcCntlCycleStart (inst)
end

Sample gCode:
    G00 G90 Z0.0
    X4.5 Y3.5
    m101
    X2.5 Y1.5
    m101
    X1.333 Z2.123
    X3.6 Z4.234
    m101
    X1.0 Y1.0 Z0.0
    m02

Hope this helps a little.  --josh


Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #22 on: July 01, 2015, 12:25:01 AM »
on to it
Re: Resetting machine coordinates in G code program
« Reply #23 on: July 10, 2015, 08:28:35 AM »
I think I'm doing something wrong.

I got the machine back together and attempted to run Louie's macro but I am having no luck. I copied and pasted it into the machine profile macro folder and named it m100.mcs. I noticed all of the other macros that are in there such as M3 have two folders one that looks like it's compiled. What am I doing wrong? Can someone explain in layman's terms?

dan

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #24 on: July 10, 2015, 03:05:38 PM »
--Try this code for your m101() macro

function m101 ()
    local inst = mc.mcGetInstance(0);
    mc.mcCntlCycleStop(inst);
    mc.mcAxisHome(inst, 0);
    wx.wxSleep(5);
    mc.mcCntlCycleStart(inst);
end

if (mc.mcInEditor() == 1) then --this was missing from the above post
    m101();
end

--Scott
fun times
Re: Resetting machine coordinates in G code program
« Reply #25 on: July 22, 2015, 06:34:01 AM »
Gentlemen,

I am not getting any errors when I run this code but it is not doing anything. Does anyone have any other suggestions?

Getting desperate. I should've stayed in school like my mom said.

dan

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #26 on: July 22, 2015, 06:54:53 AM »
have you tried it in the editor with a g code running it works that way

local inst = mc.mcGetInstance(0);
    mc.mcCntlCycleStop(inst);
    mc.mcAxisHome(inst, 0);
    wx.wxSleep(5);
    mc.mcCntlCycleStart(inst);

this works in a button it`s not the best way to do it
Re: Resetting machine coordinates in G code program
« Reply #27 on: July 22, 2015, 11:00:21 AM »
Well, I started over and deleted and then reinstalled Mach. Now it's working fine.

Thanks to all of you very smart people for the help, it is greatly appreciated.

Please see my new post about how to make a program repeat.

dan