Hello Guest it is April 29, 2024, 04:48:59 AM

Author Topic: first gcode program not generating correct toolpath  (Read 8845 times)

0 Members and 1 Guest are viewing this topic.

first gcode program not generating correct toolpath
« on: March 11, 2011, 12:56:42 PM »
I'm new to CNC, GCode, etc. I've been working with my machine for a few months in my spare time and I've finally been able to dedicate more time to this, so I'm trying my first program (I've written tons of small snippets of code, so I'm at least somewhat familiar with the language).

I am trying to drill pockets in a grid for fixture bolts. The pockets need to be every 4.5688" in the Y direction and 4.3654" in the X direction. I've incrementally written the following code to move to each location, call a subroutine to cut the pockets, and then move to the next location. Everything works except for the code to cut the pockets.

I do not know how to use G2/G3 yet, so I used one of the wizards to generate the code to cut the pocket. I know the problem is that the code was generated to run in absolute coordinates and I am trying to use incremental coordinates as it makes more sense for this program.

The first picture is the toolpath for the pocket code only when it is generated correctly.
The second picture is the toolpath for the pocket when it is in my program and obviously incorrect.
The third picture is the overall toolpath of the program. It is correct except for the slight drift to the right because of the misshapen pocket.

Below is my Gcode. I do a lot of programming in C and C++, but I've never written Gcode programs. If my code looks odd that is probably why. The idea is to call multiple routines from "main" to use the power of the language (I know you are all aware of this already). The first subroutine to be called will call the second subroutine to drill 5 holes and then move to a new row of holes. The second subroutine calls the third and fourth subroutines to drill the 2 different pockets I need in the table for the shaft and head of the bolt.

Code: [Select]
G0 G49 G40  G17 G80 G50 G64 G20
G90
G0 Z.25
G0 X0 Y0
M98 P1 L10
G90
G0 Z.25
M30

O1
M98 P2
G90
G0 Z.25
G91
G0 X-4.3654 Y-18.2752
M99

O2
M98 P3
M98 P4
G91
G0 Y4.5688
M98 P3
M98 P4
G91
G0 Y4.5688
M98 P3
M98 P4
G91
G0 Y4.5688
M98 P3
M98 P4
G91
G0 Y4.5688
M98 P3
M98 P4
M99

O3
G90
G0 G43 H0  Z0.25
G01 Z-0.1693 F15
G91
G2 Y0 X0.0375 R0.0187 F10
Y0 X-0.0375 R0.0375
Y0 X0.075 R0.0562
Y0 X-0.075 R0.075
Y0 X0.0915 R0.0832
Y0 X-0.0915 R0.0915
X0.0915 Y0 R0.0915
G90
G0 Z0.25
M99

O4
G90
G0 Z.25
G91
G0 Z-.2
M99

Finally, my question. Is it possible to use the code from the wizard to cut the pockets or am I going to have to write my own?

Thanks,
Tony
Re: first gcode program not generating correct toolpath
« Reply #1 on: March 11, 2011, 02:12:22 PM »
Look under general config and check for IJ checker box and change it to incremental.

Jeff
Re: first gcode program not generating correct toolpath
« Reply #2 on: March 11, 2011, 08:03:02 PM »
Thanks for your response. I tried checking that box but it didn't help. Is it because the pocket is cut in R mode instead of IJ mode? I don't know how to use G2/G3 so I am unable to make that pocket cut without the wizard. Since it is generating the code in R mode, I may not be able to do this in a program right now and instead will have to manually move to each location and cut each hole.
Re: first gcode program not generating correct toolpath
« Reply #3 on: March 11, 2011, 11:20:04 PM »
If you could post a drawing of what you need, I could build the code for you.


Jeff
Re: first gcode program not generating correct toolpath
« Reply #4 on: March 12, 2011, 02:14:45 PM »
That's really nice of you. Thanks.

I don't have CAD yet, but I drew you a picture by hand and marked the relevant dimensions. In case something doesn't make sense, I'll explain it in words also.

I want to make a grid of holes and pockets for tee nuts and bolts for fixturing. The center of each hole should be 4.5688" on center in the Y direction and 4.3654" on center in the X direction. The hole needs to be made of two pockets - one for the head of the bolt and one for the shaft of the bolt. The pocket for the head needs to be 0.1693" deep and 0.433" in diameter. The hole for the shaft needs to be 0.5657" deep and 0.295" in diameter. The second hole will be a through hole but I'm having the cutter stop 0.005" from the bottom surface to prevent dust from falling through. The grid of holes will need to be 10 wide in the X direction by 5 tall in the Y direction. The end mill I'm using is 0.25" in diameter and the flute length is 0.6".

Please let me know if this is sufficient information. I really appreciate you offering to do this.
Re: first gcode program not generating correct toolpath
« Reply #5 on: March 12, 2011, 03:52:43 PM »
HI.

I will need to know what kind of machine you have in order to set deep of cut, feed and RPM.

What material, thickness.

Do you have a way to clear the chips when milling the small holes. 1/4 end mill for a .295 hole will be tough for the end mill if you do not clear chips from the hole(depend of material too)

Can you drill with you machine.

Is the "0" of the part is at the bottom right corner

When you say the second hole will be a through hole but stop at 0.005 from the bottom mean that you keep the end mill from going through the part.

Jeff

Re: first gcode program not generating correct toolpath
« Reply #6 on: March 12, 2011, 04:04:26 PM »
HI.

I will need to know what kind of machine you have in order to set deep of cut, feed and RPM.

It is a CNC router with a Hitachi M12VC as the spindle (8-25k RPM, set manually). It can rapid at 150ipm. I use 15ipm for plunge feed and 20ipm for cutting feed, which were never calculated but work fine.

Quote
What material, thickness.

3/4" MDF

Quote
Do you have a way to clear the chips when milling the small holes. 1/4 end mill for a .295 hole will be tough for the end mill if you do not clear chips from the hole(depend of material too)

I have sufficient dust collection I think. I've also cut these pockets using the code from the pocket wizard and it worked fine. My code cut the deep pocket in 2 passes if that helps at all.

Quote
Can you drill with you machine.

Yes, but I don't have the right size bits. It can plunge cut with a cc end mill just fine, though.

Quote
Is the "0" of the part is at the bottom right corner

Yes...sort of. The way I drew my picture (0,0) is at the bottom right and the X axis moves would all be negative. My table is bigger than what I drew, but I wanted to show where the actual holes should be. If you put the first hole at (0,0) I could line it up where I want it and then the other holes would all be in the right place.

Quote
When you say the second hole will be a through hole but stop at 0.005 from the bottom mean that you keep the end mill from going through the part.

Yes, that is correct. I did this with my test holes and there was a tiny piece of material left at the bottom that I could pop out with a screw driver. I don't want all the dust falling on my ballscrew.

If it would be easier I could call you or you could call me. Thanks.
Re: first gcode program not generating correct toolpath
« Reply #7 on: March 12, 2011, 04:20:18 PM »
Pictures to make it clearer...

Re: first gcode program not generating correct toolpath
« Reply #8 on: March 12, 2011, 04:31:25 PM »
Try with this program.

Test it cutting above the work surface for the first time then set the Z to the right depth.(Top of part)

They're no sub program so it is a big file.

Jeff
Re: first gcode program not generating correct toolpath
« Reply #9 on: March 12, 2011, 04:57:27 PM »
It looks like it is very close to correct. There is an offset at the beginning of the program that shouldn't be there as I have shown in the attached picture. The first hole should be at (0,0), but it is moving to (-4.3654, 4.5688) and then cutting the first hole. Also, I didn't let it run the entire time, but it looks like it is only cutting the top pocket on the first pass. Is that right? Will it come around again and cut the bottom pocket?

Also, here is a video of it running the tool path to demonstrate what I'm saying.