Hello Guest it is April 23, 2024, 04:14:04 PM

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

0 Members and 1 Guest are viewing this topic.

Resetting machine coordinates in G code program
« on: June 27, 2015, 03:19:56 PM »
I am working on a wire bending machine. I am trying to find a way to reset the machine coordinates to home after each part.

The wire that I am bending has perforations. What I would like to do is have a block of code at the beginning of the program that would run the X axis homing sequence. This would work in conjunction with a photo eye to align the notches for the next part. It would also prevent the DRO from running up to ridiculous numbers. Particularly seeing as how we are running in millimeters. There is a button on the current machine diagnostics page that performs the function that would work for me; it is labeled "RefX". Is there a way to execute this function from within a G code program?

Many thanks in advance to those of you who are way smarter than me.

dan

Offline RDR

*
  •  22 22
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #1 on: June 27, 2015, 04:56:02 PM »
G28.1 Reference Axis
Program G28.1 X~ Y~ Z~ A~ B~ C~ to reference the given axes. The axes will move at the current feed rate towards the home switch(es), as defined by the Configuration. When the absolute machine coordinate reaches the value given by an axis word then the feed rate is set to that defined by Configure>Config Referencing. Provided the current absolute position is approximately correct, then this will give a soft stop onto the reference switch(es).

I found this on machmotions website not sure if this will help you.  This was for mach3 but I would think mach4 will also do this but not sure if they have it working yet I have not tried
Re: Resetting machine coordinates in G code program
« Reply #2 on: June 28, 2015, 10:59:46 AM »
Unfortunately G 28.1 comes up as "unrecognized command". Does anyone know of a way to execute the "RefX" button functionality through G code or some other type of command that I can insert into a program?

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: Resetting machine coordinates in G code program
« Reply #3 on: June 28, 2015, 11:51:11 AM »
I believe that Mach4 uses G30 instead of G28.1.
You might want to look at the Mach4 g-code manual.
Gerry

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

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Resetting machine coordinates in G code program
« Reply #4 on: June 28, 2015, 12:14:43 PM »
I am not trying to return to a predetermined axis position but instead create one from the current location. I want to load the wire in the machine and then when I run the program the first thing that will happen is that it will run through the X axis machine home function which will find the next perforation in the wire. It will then set machine zero based on that location. The part program will then run and bend the wire. When I go to run the program again it will do the same reset the X axis 0 location function and then bend the next part.

Saw not trying to return to a predetermined point I'm trying to create a new one.

dan
Re: Resetting machine coordinates in G code program
« Reply #5 on: June 28, 2015, 08:59:09 PM »
Write a script using the 'AxisSetMachinePos' function. I believe that is the function that would apply to your requirement. I.e., setting a new offset for Xaxis. (This is just off the top of my head, look at mach4.api to find the right function for your application.) Hope this helps a little and points you in the right direction...
« Last Edit: June 28, 2015, 09:01:13 PM by Screwie Louie »
Re: Resetting machine coordinates in G code program
« Reply #6 on: June 30, 2015, 12:48:28 AM »
or write a macro using mc.mcAxisSetPos function call...

"Set the position of the axis by changing the current Fixture offset."

Try both functions and see which one is best for ya.    mc.mcAxisSetPos or mc.mcAxisSetMachinePos

the macro would be called after each iteration, resetting your axis back to 0 in your work coordinates.
« Last Edit: June 30, 2015, 12:53:54 AM by Screwie Louie »

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #7 on: June 30, 2015, 01:55:19 AM »
 mc.mcAxisSetPos is work position

mc.mcAxisSetMachinePos is machine position you would start with this one for the first spots so it a home position, then use the first one for the magic eye when it see the gap or what ever reset`s to x work zero
Re: Resetting machine coordinates in G code program
« Reply #8 on: June 30, 2015, 02:46:57 AM »
Cool, thanx Dan!

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Resetting machine coordinates in G code program
« Reply #9 on: June 30, 2015, 03:05:00 AM »
mc.mcAxisSetPos is work position

mc.mcAxisSetMachinePos is machine position you would start with this one for the first spots so it a home position, then use the first one for the magic eye when it see the gap or what ever reset`s to x work zero

if the wire is in a long run you wont need to home each time just once then work zero what axis`s need to be zeroed then run the bends then when magic eye see`s the gap reset to work zero start again.

if it`s a sort run and you change wire homing is a good idea each run

you can use mcAxisSetMachinePos (mInst, 0, 0.0 /* set part zero */);

you can do this in lua or a macro b for you to get help you need to make a start on the code unless one of the mach boys helps you and have a look in the M4 api you can get to it through the Lua editor