PCB using CNC engraver

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

PCB using CNC engraver

Post by nahshon »

I'm just starting to learn KiCad.
There are some external utilities that produce GCode from gerber files. I have not tried any.
FreeCAD cannot import gerber files, but there is a very nice workbench KicadStepUp that can import from a kicad_pcb file.
I'm trying to glue KicadStepUp and Path. At this time there are too many manual steps. Basically just find the areas where copper has to be removed and then use Path Pocket to handle them.
I don't know if there is demand. Ideas on how to proceed?

In the pictured example the PCB image was added and manually aligned with the generated path. Path colors were changed for better visibility.
I wish I could use "Spiral" for the pocket operation. When trying it did not complete in about an hour and I had to kill FreeCAD.
FreeCAD-pcb.png
FreeCAD-pcb.png (52.67 KiB) Viewed 3300 times
-- Itai
Attachments
KiCad-test.FCStd
(588.54 KiB) Downloaded 42 times
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: PCB using CNC engraver

Post by nahshon »

Adding a macro that I use to extract the pcb outline and the areas where copper has to be removed.
Attachments
PcbCnc.py
(2.68 KiB) Downloaded 74 times
MRx
Posts: 319
Joined: Wed Jul 08, 2020 5:59 am
Location: Tainan / Taiwan

Re: PCB using CNC engraver

Post by MRx »

I'd rather use flatcam and Autoleveller for that job.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: PCB using CNC engraver

Post by easyw-fc »

nahshon wrote: Fri Dec 31, 2021 1:56 pm I'm just starting to learn KiCad.
There are some external utilities that produce GCode from gerber files. I have not tried any.
FreeCAD cannot import gerber files, but there is a very nice workbench KicadStepUp that can import from a kicad_pcb file.

-- Itai
you may consider fcad_pcb which is designed to do it
https://github.com/realthunder/fcad_pcb
FreeCAD scripts for PCB CAD/CAM & FEM

fcad_pcb is yet another way to improve ECAD/MCAD collaboration between FreeCAD and KiCAD.

The original purpose of these tools was to do PCB milling in FreeCAD. It can do much more now.:

It can generate gcode from kicad_pcb directly without going through the gerber stage.
It can let your modify the PCB directly inside FC (done already),
and potentially export back to kicad_pcb (partially done).
and finally it can generate solid tracks, pads and plated drills to enable FEM and thermal analysis on KiCad pcb boards.
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: PCB using CNC engraver

Post by nahshon »

MRx wrote: Sun Jan 02, 2022 7:17 am I'd rather use flatcam and Autoleveller for that job.
I have not had success installing flatcam. I'm using Fedora35 (that's Python3.10) and I'm failing with some dependencies.

I'm planning to use gcode-ripper for Z axis corrections. Would Autoleveller be better?
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: PCB using CNC engraver

Post by nahshon »

easyw-fc wrote: Sun Jan 02, 2022 9:06 am you may consider fcad_pcb which is designed to do it
https://github.com/realthunder/fcad_pcb
I tried it an still haven't found a way to produce any gcode. It looks like all the effort is into creating a model for FEM.
Anyway, the fcad_pcb project hasn't got beyond typing commands into the python console. I don't see it taking a practical, user friendly direction.
nahshon
Posts: 225
Joined: Wed Jul 24, 2013 8:06 pm

Re: PCB using CNC engraver

Post by nahshon »

Edit: Fixed bugs and updated attached file.

Ok, I had some progress.
The updated macro PcbCnc.py is doing almost everything.
It's expecting a job template job_PCB.json (attached example) in the same directory as the python file. Using these tools from the template:
  • Tool#11: an endmill to remove copper, Usually about 0.2mm.
  • Tool#12: An endmill to to cut the profile of the PCB.
  • All other tools are drill bits.
Path jobs and Path ops (pocket, drilling and profile) are created for each operation. Doing it was not trivial! If nothing else, this script can be used to get examples for path creation from a python macro.

The macro works very well for my small PCB examples. It failed badly for some more complex cases. I do not know if the problems are from the KicadStepUp workbench that I use or from LibArea that is used to process pockets, or anything in the middle.

Generated operations:
  • Pocket operation for each copper layer.
    • Bottom side is mirrored. Alignment holes are not generated.
  • Drilling operation for all drill sizes.
    • Each drill bit is used for holes smaller or equal its diameter, which cannot be drilled with a smaller drill bit.
    • Large circular holes that do not have large enough drill bit will cause an error (they should be processed with profile or helix operation).
  • Profile operation for the outside shape and for holes that are not circles.
  • Since all operations are Path WB Operations, the user can make changes before actually creating the G-Code.
picture.png
picture.png (77.98 KiB) Viewed 2820 times
Attachments
PcbCnc.zip
(4.97 KiB) Downloaded 74 times
Post Reply