Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: gotswrv on July 06, 2008, 08:16:09 PM

Title: reset home with G code
Post by: gotswrv on July 06, 2008, 08:16:09 PM
Hello all,
I'm a newbie to Mach 3 but have been very impressed. I am a toolmaker, and have some experience with CNC mills and lathes. So far Mach 3 has been awsome, love being able to tailor everything.

I recently started working on building a 4x4x3' hot wire machine and also purchased a 2x1'x4" router. Programming is being done with Featurecam and/or Mastercam as these are what we use at work. So far there is one thing I would like to do that I cannot figure out...

How can I make the machines reset home position after every run? I would like this to be done with a G-code command that I can just put into the post.

Thanks,
Sam
Title: Re: reset home with G code
Post by: Chip on July 06, 2008, 09:04:40 PM
Hi, Sam

Put 

G00 Z0
G00 X0 Y0
M30

Before the M30 in your G-code files should do it.

Chip
Title: Re: reset home with G code
Post by: ger21 on July 06, 2008, 10:24:41 PM
G00 Z1 might be better.

However, if you want the machine to actually home to home switches, use G28.
Title: Re: reset home with G code
Post by: gotswrv on July 06, 2008, 10:29:55 PM
Thanks Chip,
Maybe I wasn't very clear, I am not trying to return to current machine zeros. I would like to have it reset zero, or home the axis. Ahh, let me see, okay, "ref all home" is the button that I would like to be auto pressed by calling a code.
Pretty sure what you suggested is a G28, assuming home position being zeros.

I would like to know if there is a way to reference all homes at the end of a program automatically. If not already in Mach3, is it possible to create a macro thing? I don't know anything about macros, but if needed I'll learn. I can see myself calling on something like this even throughout a program just to keep everything honest.

Thanks again for the help!
Sam
Title: Re: reset home with G code
Post by: ger21 on July 06, 2008, 11:09:00 PM
G28 will home the machine, and if you add coordinates to the G28, it'll rapid to those coordinates before homing.

G28 X1 Y1
Title: Re: reset home with G code
Post by: Chip on July 07, 2008, 01:13:59 AM
Hi, Sam

If I understand, Your code finishes X## Y## Z## and you want to Zero the DRO's at there current position with G-code or M-code. ?

The attached Macro, M2500.M1S will do this for you.

You need to put it in your Macro folder for the Profile your loaded at startup. Example: C:\Mach3Mill\Macros\Mach3Mill.

Add the M2500 in as below, In your G-code file.

N255  X2.0380  Y1.1590   
N260 G0  Z1.0000
M2500
M30
%

It can be changed as needed, It's just some DoOEMButton,s 1010, 1009, 1008, z,y,x, Same as Pushing the Zero X,Y,Z, Buttons.

Let Us Now, Chip
Title: Re: reset home with G code
Post by: gotswrv on July 07, 2008, 09:15:11 AM
Okay now I'm getting confused. I thought G28 would send the machine to the taught home, usually 0,0,0 for me. I would like to teach the machine it's home by touching off the limits with the G/M-code, so that at a tool change or during a long run it can check up on itself, atleast after each run. I'm not at the machine right now, but I thought that is what "ref all home" was doing for me, now I cannot be sure. Am I all messed up here??? Also wondering if it is possible to do this in program or will it freak things out.

Maybe I can free up some time today at work and study up on macros and look at the one you provided. If not I'll get to it tonight.

Thanks again,
Sam
Title: Re: reset home with G code
Post by: Chip on July 07, 2008, 10:31:15 AM
Hi, Sam

It's now a little clearer, Ref All Home will reset your Dro's to zero, I think a Macro to send to home position might work.

I'll think on it, Maybe someone will comment further.

Thanks, Chip 
Title: Re: reset home with G code
Post by: ger21 on July 07, 2008, 10:39:56 AM
Just read the manual's section on G28, it should explain it for you.
Title: Re: reset home with G code
Post by: gotswrv on July 07, 2008, 01:06:08 PM
Section 5.6.1.4 right.?. I'm reading...
Reads (to me) that commanding a G28 will return the machine to the G28 location as defined in the "Motor Home/Softlimits" (5.6.1.1 in the manual).

I think Chip is following me now, sorry I cannot explain better.

thanks,
Sam
Title: Re: reset home with G code
Post by: Graham Waterworth on July 07, 2008, 02:59:38 PM
Hi,

G28 x0 y0 z0 sends the machine to a known home position, e.g. the machine has already been homed before.

G28.1 x0 y0 z0 will send the machine to find the home position whether its been there before or not.

Graham.
Title: Re: reset home with G code
Post by: gotswrv on July 07, 2008, 05:01:43 PM
Thats awesome!!!
Title: Re: reset home with G code
Post by: gotswrv on July 07, 2008, 09:36:09 PM
Okay guys,
Setup for a program at X8.00 Y7.00 Z-1.35 zero all as you would for a work offset. Then crank on your drives to intentionally loose position drastically. Executing the above G28.1 X0Y0Z0 send the machine to zero it's axis but does not reset the offset but corrects it!!! How cool is that!!! Touches off all homes and finishes with X-8.00 Y-7.00 Z1.35, brilliant, it's going into the post processor.

Only issue is the order executed is not Z axis first, but I can easily work with that, maybe as simply as execute a G28.1 Z0 followed by g28.1 x0y0. I'll have more time to play tomorrow. Hey, maybe a G28.1 Z0 Y0 X0... Graham, thanks so much!

Chip and ger21, thank you both as well!!! I will start playing with macros soon as well.

Thanks again to all,
Sam
Title: Re: reset home with G code
Post by: ger21 on July 07, 2008, 09:51:38 PM
Only issue is the order executed is not Z axis first, but I can easily work with that, maybe as simply as execute a G28.1 Z0 followed by g28.1 x0y0.

I think that's the way to go.
Title: Re: reset home with G code
Post by: Graham Waterworth on July 08, 2008, 04:03:41 AM
Thats awesome!!!

Another little known gem out in the open  ;D

Graham.
Title: Re: reset home with G code
Post by: XLR84x4 on December 16, 2008, 07:38:51 PM
Hi All,

I found this little gem. I have tried adding G28.1 A0 after a cycle of a specific cut before moving on to the next as a way of picking up of lost steps by referencing the A axis. I have found that the program stalls/stops at the addition of this code.

Is there somthing I have missed?
Title: Re: reset home with G code
Post by: vmax549 on December 16, 2008, 08:09:32 PM
yOU can use G28.1 X#.## . Y#.## Z#.##  to reference the axis to the home switches. BUT it follows the fanuc convention of going by way of a waypoint(can be the present point) BUT it then makes an interpolated 3 axis move to the approx home switch positions then references the switches. It is the fastest way to ref home, Just make sure the path is clear(;-)

IF you want it to do exactly like the Ref all home  where it refs Z then X then Y  then you will need to create a macro that calls the "Ref all home" button.

Let us know if you need help with it, (;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on December 16, 2008, 10:10:59 PM
Thanks TP

I only wish to reference the A axis.

Yes it would be great to have a macro and use M codes throughout the code.

I have never written a macro so I would certainly like some help

C
Title: Re: reset home with G code
Post by: vmax549 on December 17, 2008, 09:21:22 PM
G28.1 A0     will reference A axis to the home switch by way of A0.000 If that is not what you need email me and I will send you a macro to ref A axis.

OR now is a good time to build your own Mcode(;-)

From the main screen at the top select the pulldown menu"Operator" then VB script editor. IF a file is loaded on the screen then from the editor select file, close. This will leave a blank page to work on. Type in the phrase   DoButton(25)

Save the file as M1001( you can use any number 1000 and up safely). Make sure it saves to the c:\mach3\macros directory (;-)

Close the editor

Go to the MDI screen and type in M1001 and the A axis should reference HOME from its present location .

NOTE : You do have to have a home switch installed on A(;-) for this to work.

If all is well then you have created a Mcode that you can call from a gcode program at any time you need.

NOTE: Make sure that you program the Z to a clear safe position before calling the M1001 (;-)


Hope that helps, (;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on December 17, 2008, 10:04:55 PM
Thanks TP,

I have sent you an email
Title: Re: reset home with G code
Post by: Graham Waterworth on December 17, 2008, 10:12:08 PM
could you just clarify the problem here, are you loosing position on rapid moves or what?

Graham
Title: Re: reset home with G code
Post by: XLR84x4 on December 17, 2008, 10:28:08 PM
Hi Graham,

My machine is a CNC fabric Cutter using a rotary knife attached directly to an A axis. I'm running the machin in Tangential mode.

I'm using a Smooth Stepper with Gecko 203v for the Y + A  and a 320 for the X.

My problem is with some files my A axis gains steps  on One file it is +3 deg and on others is +10 deg on a dry run ie no load on the A axis. I have been adjusting feed rates and motor tuning etc with similar results on the same files. I have also tried DXF and Iges drawings to enhance the feedrates of F10000mm/min.

I'm now runing the machine in Plasma mode as it has the most smoothest and fastest movement at F10000.

My table size is X1500 x Y1200mm and we basically cut the same shapes continuously.

So towards the end of a file run as the A axis is getting out of position it starts to drag the knife. So I'm thinking that I can add a M code after each part is cut to realign the knife before the next cut.

I have tried the G28.1 A0 and what happens is Mach excutes the A axis home and re-zero's however it then haults until the cycle start is enable again.

I have tried adding a P command before and after the G28.1 A0 to allow for the knife to home in time before the next move and also to seperate it from the previuos lines G00 move. I read that as it is a Group 0 it can have confilcts with group 1 code. Still however the runing file pauses at the G28.1 A0.

if I type G28.1 A0 in the MDI all is oK, Just aproblem when implemented in the Gcode.
Attached is the gcode file where I have added the G28.1 A0 after the first part is cut.

C
Title: Re: reset home with G code
Post by: vmax549 on December 17, 2008, 10:44:12 PM
It would be best to correct the problem(;-) If you are sure it is gaining steps not loosing steps then the 2 areas to check are incorrect steps per unit setting or Noise.

To test step settings dry run a program to just ref all  then rotate the head 10 times and see if it physically ends back at zero. you can also check for error after you have rotated the A 10 times by then going to the MDI page and press the verify button. Mach will then return to home and recheck the position and display the error in the message bar. If it does not come back to zero recheck your steps per unit settings. If it comes back to zero you may have to hunt down the noise that is getting in the drives cables while running.

IF you are acutally loosing steps then that is another chapter in the book(;-)

Hope that helps, (;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on December 18, 2008, 12:35:51 AM
I have just done some tests.

The MDI test with verify confirmed sucessfull?? Basically I ran A 180 to A360 approx 20 times and verified. It all looks Ok as far as position and DRO.

My Steps/mm on the A are 5.55555555555 calculate @ 200 x 10 micro step / 360 deg. I did change this to 5.5555 and ran one file with 70 parts. All was OK with this meaning the A DRO at zero  the knife position was at zero deg at the finish

I ran another file with 20 x parts and at the end set a A0 command and knife position was + 8 deg

Regarding noise the cables to the motor are not sheilded or the pairs from the SS to the G203V.

The question is why is it ok on some files and not on other files

Will a reference A macro that I can drop into the Gcode after each item do the trick. The G28.1 A0 command worked but would not continue running the file

Thanks again for the fault finding tips
Title: Re: reset home with G code
Post by: vmax549 on December 18, 2008, 06:24:17 PM
YES a macro will do what you want. the gcode file runs until it gets to the Macro, then mach references A then continues on with the file uninterrupted.   Just tested it here(;-)

(;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on December 18, 2008, 08:51:50 PM
Nice one TP,

I would be keen to give your macro a try
Title: Re: reset home with G code
Post by: vmax549 on December 20, 2008, 11:04:41 AM
Here it is M1099
Title: Re: reset home with G code
Post by: Graham Waterworth on December 20, 2008, 12:27:38 PM
This macro is not the answer, all it will do is home the axis when you insert it into the code.

Would it not be better to correct the fault, if its a rounding error in the step count, which it looks as if it is then driving the A axis at 1.8:1 ratio will remove the error and the step count will be perfect and the guess where to put the macro in the code is eliminated.

Just my opinion.

Graham
Title: Re: reset home with G code
Post by: vmax549 on December 20, 2008, 01:28:59 PM
I agree with Graham, it would be far better to "fix "the problem then try to make a software crutch. BUT if this keeps you going until you can correct the hardware problem then it is an appropriate patch.

It seems that on a static test the stepps are correct.  SO that leaves either losing steps or gaining steps. I would almost bet you are losing steps due to the  vel and accel rates. IF it were gaining steps due to noise it would show up almost all the time and be very random in the overstepping amount.

Losing steps on the other hand would mostly show up in certain conditions such as high cut load, high accel rates or trying to keep up with high velocity cuts.(;-)

Just a thought (;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on December 23, 2008, 04:24:36 AM
Thanks for your info,

I have ran some tests today adjusting steps/mm etc.

Yes my machine is gaining deg on the A axis. On MDI A code tests like AO to A180 back to A0 etc the A axis works great. When I run different Gcode files the results at the end are varied when sending an A0 at the finish ie +3deg to +10 deg gains depending on code. Modifying steps/mm isnt the solution as I can adjust these to suit one file and then the A home is out after the completion of another

I did try the M code however it homes the A axs then pauses until cycle start is depressed

My thoughts is that the tangental A code that Mach outputs is where the problem lies.

Thanks
Jason
Title: Re: reset home with G code
Post by: vmax549 on December 23, 2008, 11:20:29 AM
HUM it passed right throught the macro here and continued on with the code???

ANother test ,(;-) on a gcode file you know it happens try reducing the Fspeed to 1/2 normal (fro) and see if it still occurs.  With a file that rotates the cutter CW & CCW it could loose steps and LOOK like it gained steps(+3-10) in the end.

IF the cutter stepper(A) is undersized it may have trouble with low torque and fast moves. IF so a stronger steppper motor OR gear it 2:1 for more torque IF you can get by with  lower speed on rotation.

ALSO check your stepper drive motr settings if it is set lower than max amps for the motor the motor will have less torque to work with.

Just a thought, (;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on January 02, 2009, 05:10:13 AM
I have been working on the machine today trying different things.

The macro continues to pause ater the a axis homes, I will read up tonight on a cycle start command to add to the macro.

Most of my code runs CCW and at the completion of one file the A was +20 deg out and another file it as +12deg, this was check by MDI'ing a A0 command then jogging backwards the axis until the homing limit is hit . I worked on reducing my step/deg number and found that 5.535/deg had the filet hat was + 20 out at the finish now finishing at 0 however the other gcode file is -7 deg when zeroed with these settings. These test were ran with the blade removed so no load on the stepper. I did another file wth 5 different shapes like a square, circle, pentagon and eclipse of varying sizes and at the completion the A axis was ok ie no lost steps. I tried running the problem files with reduce feed rates and vel and Acc settings on the A axis with similar gains of posttion as above. BTW I have I and J codes in these files. Meaning I have drawn the shapes using arcs and fillets between straight lines. I have done this as the speed of the machine is not compromised as the A axis runs in Exact stop mode even though I have a G64 in the code. This may have to do with the way the A axis code is outputed.

I may be wrong here but I thnk the A code is developed like this
A90
x100 y100


If it was done like this it may work better??
A90 X100 y100

My next process is to set the chains for the parts to run in the CW diection and see how the position ends up.

Thanks for the help and Happy New Year
Title: Re: reset home with G code
Post by: vmax549 on January 02, 2009, 11:32:43 AM
Just a thought but,  A90 x100 Y100 will give you an interpolated move that has the knife turning the entire length of the straight xy move that should create a drag on the knife as it is NOT in angular position at the start.

I would think the angular rotation should occur at the radius points where the knife has to make the radius transition. AND the knife should be in position at the end of the arc to make the next straight move. Or at a sharp coner

A90 X100 Y100 R.25 ( knife follows the arc)

X150 Y100

A120 (sharp angle no radius)

Y150

Just a thought, (;-) TP
Title: Re: reset home with G code
Post by: XLR84x4 on January 05, 2009, 09:49:43 PM
Ok more testing today.

Happy New year to you all.

I still have the code pausing with the  M1099 A home command. I tried a dobutton (0) after this however it did not excute the A home. I tried adding a Code "G4 P5" after the A home and before the cycle start. Still it did not do the A home:)

I have run some simple 5 shape tests with F10000 and it is OK with refernce to A axis positionng.

I tried a 20 part cut in the CW direction and the error is exactly the same as the CCW being +15 degs out.

I switched my A axis stepper to Unipolar and change the current set resistor. Reduce A Axis motor tuning to V5000 A500 and run a test at F2500. The problem still exisits as if it was with high V and A setting and feedrates of F10000.

I am not sure where to go from here??
Title: Re: reset home with G code
Post by: Graham Waterworth on January 06, 2009, 06:57:09 PM
I think your problem is an accumulation of part steps on complex shapes, on simple shapes you do not have the problem as the a axis is only moving a few times.

I would put a belt drive on the a axis that changes the steps per rev to an even number, so if you ran at 200 steps per rev the 360 degrees / 200 steps = 1.8:1 ratio.

You could then microstep and the step error would be reduced by the fixed ratio drive.

Just my thoughts.

Graham
Title: Re: reset home with G code
Post by: XLR84x4 on January 06, 2009, 09:54:02 PM
Thanks Graham,

I like our idea. Wha are your thoughts on using a 0.9 deg stepper so that the step count/deg would be 4000/360 =11.1111111

Or are you thinking that a whole  number of steps/deg would reduce this error.

If this is the case do you think that a 3.6:1 would be better still with a higher step count.

I'm tossing up the amount of work required to do the reduction drive compared to sourcing a 0.9 deg stepper.

Thanks again
Title: Re: reset home with G code
Post by: Graham Waterworth on January 08, 2009, 05:29:19 PM
In my opinion there is no better drive than a whole number of steps per rev, no loss of part steps and no rounding errors.

The best machines out in the industrial world use encoders that have multiples of 360 pulses per rev. They don't use these for fun :)

Graham
Title: Re: reset home with G code
Post by: ian3846 on February 21, 2009, 06:03:29 AM
would it not be g 91 g 28 zo xo yo ?