PC Board Tools

Here are the scripts I use to convert PC boards from Kicad to G-code.
http://www.lwill.net/downloads/boardtools-01.tar.gz
This is the README included for information.

README 03/28/20012

Tested with LinuxCNC 2.6.0~pre and KiCad (2012-01-19 BZR3256)-stable and
    pcb2gcode 1.1.4

### DISCLAIMER ###
CNC MACHINES CAN BE DANGEROUS!!!
THOROUGHLY CHECK AND TEST ANY CODE BEFORE RUNNING!!!

Files included in boardtools directory:
doall.py                    GUI front end for pcbbatch
pcbbatch.py                 Batch file to run all programs using config file
boardcfgdef.py              Default config file
Etch_Z_adjust.2.2.cl.py     Modified command line version
gerber2emc2cl.py            Modified command line version
p2gdrillopt.py              For optimizing drill files
p2gpathopt.py               For optimizing paths
demo                        Directory with sample Kicad layout, gerbers, and
                            sample boardcfg.py for testing

REQUIRED:
python-argparse
pcb2gcode installed on system
EMC2/LinuxCNC 2.5+
KiCad

Optional:
opti  (from Etch_Z_adjust)  Untested, I have not used it, not included

-Quick and dirty:
Extract.
For GUI, from boardtools directory run:

$python doall.py

    You will probably need to run doall.py at least once to verify default
    file paths. Save defaults to boardcfgdef.py in installed directory.

To try demo:
    Click "Load boardcfg"
    Open the demo directory and choose boardcfg.py
    Click "Default Paths" and set to the correct locations.
    Click on "Browse" under "Board back" and reselect "demo-Back.gbl"
        to make sure the path is working directory is correct.
        This will automatically set the other files correctly.
    Click "Run boardcfg" (it will automatically ask you to save)
    Check out the generated files!

To run a config file from a project directory:

$python boardcfg.py

-The idea:
Generate ready to run g-code files from KiCad for LinuxCNC using one interface.

-The method (how I do it):
Schematic and board layout with KiCad.
    I use the Comment layer for text and draw board outline using actual tool
    path based on the bit I will be using so I can leave gaps to keep boards
    paneled together. (there is an option to use pcb2gcode for outline instead)
Generate gerbers and drill files (4). *Back.gbl, *PCB_Edges.gbr, *Comments.gbr,
    and *.drl
Use pcb2gcode to generate back and drill g-code files.
    * the paths are very "stair-steppy" which I did not like
Use gerber2emc2cl to generate text and outline g-code files.
Join the paths and text together in one file.
Use p2gpathopt to reduce "stair-step", smooth paths, and reduce moves.
    Due crude optimizing.
Use p2gdrillopt to due crude optimizing and optionally use only one drill bit.
Use Etch_Z_adjust (*modified) to do auto-leveling.

-The Solution:
Have a config / batch script to do all this automatically.
    In reality there is a script that is placed in the drawing directory
    that holds the configs (boardcfg.py) and calls another script (pcbbatch)
    that does all the hard work. This way boardcfg can be run in place when
    a board is modified without copying main script to each drawing directory.
    All needed settings needed to run are saved in the boardcfg.py file.
A GUI to select all the various setting and generate the config file and
    optionally run it.
Config file default name is boardcfg.py This can be modified by hand "at own
    risk" if desired, but may break compatibility with GUI. Undocumented.

-What does the work:
pcb2gcode

Etch_Z_adjust.2.2.cl.py
    Modified command line version. Added ability to re-run file without
    re-probing. Modified to use a separate probe instead of tool bit, and to
    set tool height automatically.(Must use EMC2/LinuxCNC 2.5+!!!!!! uses G10)
gerber2emc2cl.py
    Modified command line version. Added ability to mirror and offset.
p2gdrillopt.py
    For optimizing drill files. Allows using only one drill and does crude
    optimizing using Morton number.
p2gpathopt.py
    For optimizing paths. Smooths out pcb2gcode paths by finding the midpoint
    of each stair-step, eliminates redundant points creating straight lines
    within a set tolerance. (difference in slope < .001 or about .057 degrees)
    Adds very slight deviations from original, but gives much smoother result.
    You decide.
    Also optimizes based on Morton number.

-Credit where credit is due:
While thoroughly hacked and mangled, my work is based on these previous works.
Both have no copyright/left restrictions in the files.
I likewise put no restrictions other than ask for credit if you use it.
(Please visit lwill.net)

Etch_Z_adjust from michael_m at cnczone.com

http://www.cnczone.com/forums/pcb_milling/82628-cheap_simple_height-probing-11.html#post843483

gerber2emc2 from SAMMEL Lothar on the LinuxCNC wiki

http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Converting_Tools

-Other software:
KiCad

http://kicad.sourceforge.net/wiki/Main_Page

LinuxCNC

http://www.linuxcnc.org

pcb2gcode

http://sourceforge.net/apps/mediawiki/pcb2gcode/index.php?title=Main_Page

-Why my settings / method seems weird:
I actually use a coated board and a drag bit to scribe the coating, then drill
    it without removing it from the machine, then etch in FeCl. The scribe
    only needs to be offset .001. The scribe and probe mount off to the side
    of my spindle, that is the reason for the offsets. I also use
    Etch_Z_adjust for engraving other things using a normal engraving bit and
    separate probe which was the original reason for modifying it.
I used the Morton number optimizing method because it was fast and simple and
    better than nothing. I may rewrite the optimizing method later.
This is my first major attempt at Python programming, so it is ugly. It
    started simple, and 1100+ lines of code later.... So don't ask why I did
    something the way I did, the answer you will likely get is
    "Because it worked!"
More info on this and other stuff at lwill.net/blog
All comments are welcome, but I reserve the right to ignore them!

I can be contacted though lwill.net

 
Screen shot of GUI:

Number of View :22416

PC Boards, My Way

I have found a new way of making PC boards.
I start with a bare board.
Place a thin layer of “secret” resistant coating on it.(on a spin coater)
Use my CNC router to “engrave” it with a drag scribe.
With out moving it, drill it and route outline.
Last etch it in ferric chloride.

Now this may seem odd at first. Why not just route the board with the CNC?
Let me try to explain. I have always used the photo resist method with laser transparencies and pre-sensitized boards, etched then drilled. When all goes well, the results are great. The biggest problem has always been getting a good 1 to 1 print from the laser printer. Next problem is lining the board up to drill it, which gets worse if the print was not square or to scale to begin with.
Now, my main reason is I am sorta cheep. I have never bought the right bits to do direct PCB routing. My router does pretty good, but I am just not sure how it would do, and hate to spend money just to break bits. I like the photo method, but bare boards are cheaper. There is also the fact I already have a bubble tank of etchant.
When I first started experimenting with my method I used an old photo board I had. It was a bit old, so I just tossed it in developer with out exposing it to fix the resist first. This worked, but still expensive board and the coating is very fragile and gets scratched during drilling. More on the coating later.

Read the rest of this entry »

Number of View :7470

Rain Barrel Controler Design

This is the (current) controller design.

It is very crude and has not been truly “engineered”, but I kept adding bits and trying values until it did what I wanted. Most of the values were chosen from what I had on hand and drove the design.
The circuit accomplishes 3 main functions.
First: Charge the battery with the solar cell.
Second: Turn on the pump at night, run to a set level of water, turn off and not run again until the next night.
Third: Use a moisture probe to prevent running if the ground is wet enough.
The solar cell is used as a light sensor as well as a power source.
Power from the solar cell is fed to a LM317 in a current source mode to supply approximately 125 mA to the 9.6V 1600mAH NiMH battery pack. This provides slightly less than a 10% charge rate based on 10 hours of full sun a day. According to most sources I found, this reasonable charge rate without over charging, since it is time limited by the amount of sun each day and not constant. R19 provides power to supply the electronics while the sun is out, and D10 when dark and running solely from battery.

Read the rest of this entry »

Number of View :9192

Rain Barrel control

I think I now have a working control for the rain barrel, with a moisture probe. This will prevent watering if the ground is already wet. I have a new PC board made and tested and just waiting for the weather to break a bit to get the barrel hooked up to test it. If all goes well I will add the design info to the rain barrel page soon. The whole control is pretty basic with only one adjustment for the probe so it should be cheap and reliable. Just don’t expect any bells and whistles.

Number of View :2813

Automatic Rain Barrel

We have a small garden out by our shed. It is not very big, sort of a “Square Foot Garden”. Just enough for some tomatoes, a cucumber and a few other plants. Of course one big key to a good garden is consistent watering, and of course I am a bit lazy and not very consistent. I wanted something to do it for me automatically.
images/rainbarrel/rainbarrel2.jpeg
The shed is about 50′ from the house, not far, but far enough to have to drag out a big hose. Living in a cold climate, the obvious solution do not work well here. I could not simply bury a hose without worrying about draining it so it will not freeze. I also did not want to bury any wire for automation either. I needed something that would stand alone, self power and supply water.

I decided on a rain barrel to attach to my shed. I simply used a 50 gallon trash can. I am not using the water for direct consumption, only irrigation. The first one was a heavy duty one some one had thrown away. (You can only use 35 gallon max for garbage here, so I could not use it for that) I lined it with a heavy 55 gallon “contractors” bag to keep the water clean and so it could be replace for easy cleaning. To hook it up to the gutter on the shed I made my own diverter/screen. (More on that later) The roof is about 10′x15′ and can fill the barrel with a moderate rain fall.

Read the rest of this entry »

Number of View :4325