Electronics DIY blog

DIY is fun and is food for the brain and spirit. Don't be afraid to learn.



Showing posts with label GCode. Show all posts
Showing posts with label GCode. Show all posts

Sunday, October 13, 2013

SketchUp 3D to GCode plugin

Since the CNC build is very slow due to the lack of time to do any real iron working I've turned into an old quest that was still pending.

A year or so ago I started experimenting with the SketchUp API to have some fun and learn something new.
I've never programmed with Ruby before but my C and C# experience made it pretty easy to learn it in no time.
Then I came to an idea. Make a plugin to convert a SketchUp model directly to GCode.
I debated for a couple of months on the API classes to try to see how I would pull this off. Other things came and I put this project aside.
Early this week I decided to pick this up again. After some intense brainstorming to my self I came with an idea that seemed to work. And it did but the process do scan the model involved boolean operations on SketchUp solids (a hole bunch of them actually) and that is a performance killer.
When I increased resolution SketchUp would stall.

NOOOOO... I found a solution and it was too slow. But then the math concepts I learn in high school came to my head and BAZINGA...

Yeah baby...
What I'm showing here are the results of my SketchUp to GCode converter plugin.

This is in a pre-alpha stage right now, so I'm not going to go in to much detail about this, but I can tell you that it works... :-D

Here are a couple of examples (SketchUp model vs NCPlot- this displays the GCode)

SketchUp modelGCode plot
Example 1
Generated GCode - Dual pass mode
Example 2
Generated GCode - Single pass mode
With some small adaptations this can be used to produce plastic printing GCode too.
I'm developing some more features on this.

Stay tuned...

Tuesday, September 4, 2012

PCB-GCode tips and tricks for full isolation

My PCB milling techniques are getting better at each trial-error experience.

Going to the SMD area there are a few tricks and adjustments that will improve the overall quality of the work.

By the way I'm now using some 0.1mm @ 60º V-bit for the PCB echting process instead of the 10º I was previously using. The results are a lot more even. I'm now going at 0.02mm of depth instead of the 0.05mm in my last config. Actually my new config has changed quite a bit.

I'm now using these settings:

Milling depth: 0.02mm
Tool size: 0.4mm (I moved the compensations and safety margins to this field. Run-out, vibrations and all unknowns are in here instead of being in the default isolation margin.)
Default isolation margin: 0.05mm. Reflects the changes above.
I still use the double passage method for best results. Maximum and Set Margin should reflect that has explained in an early post.

Also as I stated in early considerations the DRC tool in eagle is very important. And should reflect the given formula (Minimum clearance = Tool size + 2xDefault isolation margin) for all clearances.

Ensuring full PCB routing trick


Some times enough clearance between track simply can't be achieved or is too difficult. Here is a technique to overcome that limitation. (Remember this will ignore the clearance rule so your machine may not be capable of reproducing a good route/via/pad because it is just bellow the resolution it withstand).
You clould "lie" to the pcb-gcode plugin about the size of your tool to achieve until path was achieved, but this would result in poor final qualitty since all routes/pads/vias would become thinner than expected. This should be avoid.

Here is an example.

Check your clearances. Try to fix as many has you can. Remember that if you can't guarantee the given clearance the gcode generated will also reflect that and route isolation will not be fully achieved.
In the following circuit I used the DRC tool and my failed clearances were highlighted like in this image.

Eagle after DRC tool

Generated echting gcode
As you can see the the milling route in the areas without enough clearance is not generated.
To overcome this manually add some milling routes in the Milling Layer (layer 46 of eagle)

Manually added route

Generated milling gcode

Merged gcodes (milling + echting)
Has you can see the highlighted gcode and track are actually the milling gcode. The final result is a single pass routing to perform the desired isolation.
If the echting tool is not too big and the routes are not that thin the achieved result is very acceptable. The resulting route will be slightly thinner but it wont be that bad. This will in almost every situation yield best results.

Here is the output of the above circuit with those tips applied

Milled board with SOIC28, mini USB and SMD parts

NOTE:

I detected a small bug in pcb-gcode plugin. The first routing of the mill gcode file those not go to the default milling depth (the G01 Z-X.XXX FXXX instruction is not being generated). You must added it manually.

Cya next time.

Thursday, August 23, 2012

Milling PCB in a CNC - The guide

OK. So here is a little resume of my process to make PCB with my crap of a CNC.

I'm using freeware version of Eagle to make the schematic and board and then I use pcb-gcode plugin to generate the gcode for the milling.

My steps are these:-Make the schematic and board in eagle.
-After all is in place use the Drc tool in eagle to check your clearances. To do this go to the clearances tab of the Drc tool and set all clearances according to this formula:

Minimum clearance = tool width + (2 * safety offset from pad/via distance)

Why?
Because using the same formula in the pcb-gcode plugin will allow you to make the PCB using 2 passes (making a PCB in a single pass doesn't always ensure proper isolation and almost always needs deburring and more the two passes is excessive and time consuming). The 2-pass isolation has yield the best results for me with a 10º v carbide bit. I'm still waiting for the 60º bit. I'm hopping it can produce similar results with a single pass. For now I'm sticking with 2.

The above formula is a reference and should be used has a reference only. If overlay occurs it's not the end of the world. The amount of overlay is the problem. Some SMD components might not even comply with the clearances. It's OK. But you should check the generated gcode for those places to see if they where properly isolated.

-Next configure pcb-gcode plugin. If you are going to work in metric units (mm) change the gcode-defaults.h in the setting folder of the pcb-gcode plugin to output the coordinates with only 3 decimal places after the floating point.

This is done by changing this line:
string FORMAT     = "%-6.4f ";      /* coordinate format */

To:
string FORMAT     = "%-6.3f ";      /* coordinate format */

Milling depth = -0.05mm
Remember most copper sheets in raw PCB is 35 microns (0.035mm). 0.05mm should be enough without going too deep.

Tool width = 0.2mm.
In my case I'm using a 0.1mm v-bit 10º. I set this to 0.2mm to compensate for run-out, vibration and bit wobbling (being such a thin bit it bends while trying to remove the copper. It's like forcing a needle to scratch a surface. Bending will occur. Also must compensate for the widening of the tip as it goes deeper.

Default isolation = 0.15mm
this is an other place where you can compensate for all the variables above. I prefer not to do it here. In here I like to put the amount safety margin to apply to pad/via clearance.

Isolation step <= Tool width.

Maximum isolation = Default isolation + Isolation step.
This insures 2-pass milling.

Don't forget to set the feeding speed. I'm using between 60 and 100mm/min. Faster then that bits will brake, deformations in isolation will be produced and you don't want that.

-After a good gcode is achieved It's milling time. Secure the PCB to the table in a way that avoids (un)leveling (usually the PCB is not perfectly flat due to storage conditions).
Two ways to do this.
The pro way. Use a vacuum table.
The cheap and dirty (but totally works). Double side scotch tape. This the one I use. It works (period). Read this.
Home the bit with one of the to procedures I've mentioned in a early post (Eagle2GCode - Part 2).

And you are good to go. You should be ready to start milling.

Good luck.

Tuesday, August 7, 2012

Eagle 2 GCode - Part 2

OK seems my early considerations where partially wrong. The depth of the engraving bit must be ~0.05-0.06mm.

My initial considerations where wrong because I was not homing the bit properly.

Two ways to home the bit (that are actually almost the same).


Homing method 1 (cheap and dirty) - Use an power source of some kind to drive an LED (in series with a resistor if not adequate to drive the LED directly) and use the contact between the bit and the raw copper as a switch to indicate if there is contact between both.
Here is a schematic.

Homing detection schematic


Homing method 2 (more precise) - Exactly the same but using on of inputs in the CNC control board/Software.

Note: For some reason the EMC 2 is rounding my GCode floats to the 0.1mm scale. Don't know why this is happening but I'm upgrading to EMC 2.5.0 seems to have fixed it. Also I had to reconfigure the gcode-default.h file of the pcb-gcode script to write floats with 3 digits after the dot separator. This prevent rounding errors of the gcode interpreter in the EMC 2 reported in arc movements in mm units.


This is a picture of my first trials.

From left to right - 1st attempt had a bad configuration was doing it half sized, next is 1,2mm deep with multiple passes (excessive), next reduced number of passes (still excessive), next at 1mm with one pass (still excessive but acceptable).

These are my SMD trials (just a simple SOIC8 circuit and a resistor)


1st SMD trial


1st SMD trial detail (depth 0.075mm to deep in the majority of the circuit)
2nd SMD trial detail (depth 0.05mm to shallow in some places)

Here are a few videos from the machine working.









Despite the results are not perfect I'm getting pleased with it. There are still a lot of headroom and some tricks in my sleeve to improve this with minimal changes.
Let's see how far I can take this.

Friday, August 3, 2012

CNC Control Software

For the CNC control software I've chosen the LinuxCNC. It's free, open source, easy to configure and use, and there's a huge community that continuously improves it. There's a ton of documentation about how to configure this software but the quick guide is a good place to start.

For the PCB machine code generation I user the free version of Eagle PCB and the awesome pcb-gcode plugin.

The sync tuning of these two tools can do all the difference between a nice clean PCB and a bad one.

I'll keep dumping my tune-up's here, along with pics of the results.

Cheers.

Thursday, August 2, 2012

Eagle 2 GCode

I'm now in a test and trial fase for achieve good PCB boards with my CNC.

After 2 kind of failed circuits, here are my early conclusions:

Engraving at 0.2mm depth is to much. 0.1mm is to shallow in some areas due to CNC table alignment defects and the PCB raw sheet defect (it’s not perfectly flat since the board may be bend due to incorrect storage positions and handling). 0.12-0.15mm should yield the best results (still to be tested).
I'm using a 0.1mm 10º V carbide bit to do routing isolation. Applying the formula for the cutting tool wide in this wiki I should consider a minimum tool size (width) setting of 0.15-0.2mm (that also compensate the above errors plus spindle and bit run out).
To keep it simple and fast I’ll be only performing the isolation routing and skip the copper removing in bigger areas. For this pcb-gcode plugin for Eagle should have the following configs:

Tool depth for isolation and Z Down - 0.12-0.15mm (value to be tested) (Z Down is negative)
Default Isolation (*), Maximum Isolation and tool Size – 0.15-0.2mm (this will insure a single passage – the isolation routing passage).

(*) Default Isolation is the tool offset from the track. For best results this should be the same as the tool size. ALWAYS do the Clearence check in the DRC tool of EAGLE. Set the DRC checking rules in the Clearence tab to at least 2xDefault Isolation + 1xTool Size. This checks for error of overlapping that otherwise may result in the isolation routes not being generated.

Also using Voronoi-Regions gcode generetor software can be a good solution to maximize copper area and conductivity.


I’ll test some more and post the results later.