my weekend meta-project: magic panel PCB generator for Eagle

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Joe., lisa, luketeaford, Kent

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

my weekend meta-project: magic panel PCB generator for Eagle

Post by indigoid » Sun Apr 28, 2019 3:51 am

https://github.com/jsleeio/go-eagle

TLDR: magically generate an Eagle board file for a Euro front panel from your module's Eagle board file.

I haven't ordered any boards generated with this yet, so YMMV. But it looks good thus far, and I expect to order some quite soon :-)

Below is an example preview image from feeding the resulting Gerbers to OSHPark. The board file generated by my app was not modified at all before generating Gerbers.

Future improvement ideas include:

* 1U support, maybe
* Read panel legend text from Eagle component attributes
* ability to override inferred panel width
* reorganize code and make it way less horrible
* PCB "windows" for LEDs

The generated board files load into Eagle 9.3.2 pretty reliably. I haven't tried other versions.

Image
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
Roni
Common Wiggler
Posts: 51
Joined: Fri Feb 10, 2017 11:13 pm
Location: Melbourne, Australia

Post by Roni » Sun Apr 28, 2019 4:15 am

Nice. Be cool if it would do oval mount holes.

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Sun Apr 28, 2019 4:27 am

Roni wrote:Nice. Be cool if it would do oval mount holes.
Yeah I hear you. I've never tried to do this with PCB fabrication. Would it be a 3.2mm-width routed slot instead of a drill?
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
cygmu
Super Deluxe Wiggler
Posts: 1460
Joined: Mon Feb 15, 2016 3:33 pm
Location: UK

Post by cygmu » Sun Apr 28, 2019 4:46 am

This looks very cool and I'd love to tinker with it a bit.

Is the code actually in the git repo? I can't see the cmd subdirectory there.

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Sun Apr 28, 2019 4:58 am

cygmu wrote:This looks very cool and I'd love to tinker with it a bit.

Is the code actually in the git repo? I can't see the cmd subdirectory there.
fixed. Oops :-(
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
cygmu
Super Deluxe Wiggler
Posts: 1460
Joined: Mon Feb 15, 2016 3:33 pm
Location: UK

Post by cygmu » Sun Apr 28, 2019 5:19 am

Fabulous, thank you! Commence poking about in somebody else's code...

OIP
Common Wiggler
Posts: 154
Joined: Wed Oct 07, 2015 9:43 pm

Post by OIP » Sun Apr 28, 2019 6:07 am

awesome, even for generating image files to get laser cut this is very helpful

User avatar
Roni
Common Wiggler
Posts: 51
Joined: Fri Feb 10, 2017 11:13 pm
Location: Melbourne, Australia

Post by Roni » Sun Apr 28, 2019 6:48 am

indigoid wrote:
Roni wrote:Nice. Be cool if it would do oval mount holes.
Yeah I hear you. I've never tried to do this with PCB fabrication. Would it be a 3.2mm-width routed slot instead of a drill?
I don't use Eagle so stabbing in the dark here, my first inclination would be to make a standard through hole pad (oblong) and then draw a hole in the Milling layer, say 3.2 x 5.7. Not sure what parameters are available with routed slot but if it works and is easier go with that.

.

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Sun Apr 28, 2019 7:12 am

https://www.autodesk.com/products/eagle ... ted-holes/

This seems to cover it. AFAIK I've seen something similar in Mutable Instruments design files with 3.5mm jacks.

I'm on the fence here, though.

While they're very good for modules coexisting in a case where some modules aren't manufactured quite to spec, they also immediately make it more difficult to get PCB panels manufactured correctly. A panel with no milled/routed slots will be made as-desired pretty much every time, without fail. You just use the vanilla Eagle CAM job supplied by the fab shop, and send them the resulting Gerbers. I'm fairly sure this isn't true for slots.
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
Haralds:Werk
Wiggling with Experience
Posts: 269
Joined: Fri Sep 09, 2016 3:33 am
Location: Germany
Contact:

Post by Haralds:Werk » Tue Apr 30, 2019 4:00 am

Great project. Never thought about using eagel in this way. I'll give it a try with eagle 6.4.
www.haraldswerk.de
Home of Next Generation Formant

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Tue Apr 30, 2019 4:20 am

Haralds:Werk wrote:Great project. Never thought about using eagel in this way. I'll give it a try with eagle 6.4.
I suspect this won't work. May be wrong here but I don't think they were using XML files back in 6.x days
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
djthopa
Super Deluxe Wiggler
Posts: 1752
Joined: Thu Mar 22, 2012 5:48 pm
Location: Somewhere between a nappy and a wire

Post by djthopa » Tue Apr 30, 2019 4:33 am

Thanks for this!

Im always exporting from Eagle into Inkspace and overlaying the pcb pdf with a Eurorack Pcb generator some user posted here (THX112?)

Thanks for sharing

User avatar
infovore
Wiggling with Experience
Posts: 323
Joined: Wed Nov 11, 2015 9:36 am
Location: London

Post by infovore » Tue Apr 30, 2019 8:04 am

OK, so I've prodded this, and once I remember how to go get... how does it work out what components need holes? The generated board is the correct size, and contains no component holes at all.

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Tue Apr 30, 2019 5:34 pm

infovore wrote:OK, so I've prodded this, and once I remember how to go get... how does it work out what components need holes? The generated board is the correct size, and contains no component holes at all.
The components need to have a PANEL_DRILL_MM attribute indicating the hole diameter in millimetres. eg. "6.5" for a 6.5mm drill

I did this by editing the library components I use for pots, jacks and switches — only need to do it once with this method.

But you can also do it by right-clicking on the component in schematic or board (doesn't matter which) view and selecting Attribute

I plan to facilitate customising of the text labels via the same method.
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
infovore
Wiggling with Experience
Posts: 323
Joined: Wed Nov 11, 2015 9:36 am
Location: London

Post by infovore » Thu May 02, 2019 4:01 am

indigoid wrote: The components need to have a PANEL_DRILL_MM attribute...
gotcha! That makes sense. I'll give it another go at some point. And might submit a documentation pull request...

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Thu May 02, 2019 6:08 am

all feedback welcomed :-)

The code is a nasty mess at present. I've some ideas for cleaning it up and have started on doing exactly that. Hoping to spend more time on it this weekend. Two other items I'm wondering about:

(1) a good way to handle components where the drill hole may not be aligned with the component origin. At present my code assumes the origin is where you want the drill hole, and I think this is a good assumption. A good example of an exception to this might be the typical Bourns 3296W-style vertical trimpots like these:

https://au.mouser.com/ProductDetail/Bou ... Ycng%3D%3D

The Eagle part for these has the component origin over the centre pin, but the trim adjustment is aligned over one of the outer pins. One approach might be to have optional "offset" and "angle" attributes that move the drill hole relative to the component origin and rotation. This would make library footprint design more fiddly, but you'd only have to do it once...

(2) Multiple labels per component. I'm working on a PCB for the Morphlag with Dr. Dixon's suggested modification to add a toggle switch. The switch would need two labels — one above, one below.

I have a couple of ideas here. One is to simply have a dedicated layer (_tSilk maybe) and have all objects in that layer copied directly across into the panel board's top silkscreen. This would mean you could do whatever complicated panel artistry etc you wanted, and wouldn't need to worry about adding eleventy billion custom attributes to your libraries. And when you're working on the actual important bits of the board, you just hide that layer to keep it out of the way.
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
pixelforest
Common Wiggler
Posts: 135
Joined: Mon Jan 29, 2018 9:15 pm

Post by pixelforest » Fri May 03, 2019 3:02 am

i'll be interested to see how this does running through a converter to jump over to kicad as there's a pretty good existing workflow for doing pcb art with kicad/inkscape. thanks for sharing such a useful tool, it's been a pain to do this task manually

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Fri May 03, 2019 8:12 am

Started work on tidying things a bit. I've added a new utility panelgen that generates blank Eagle board files for Eurorack, Pulplogic 1U and Intellijel 1U. Working on this has helped me clarify somewhat how I want to proceed with tidying up the rest.

Looking forward to spending more time on this over the weekend!
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
cackland
Super Deluxe Wiggler
Posts: 1867
Joined: Thu Dec 28, 2017 5:42 pm
Location: Los Angeles, California

Post by cackland » Fri May 03, 2019 9:12 am

Sorry for my ignorance, but is this used by running a script? Maybe I missed the instructions on github?

User avatar
thx2112
Veteran Wiggler
Posts: 514
Joined: Sun Oct 12, 2014 10:10 am
Location: Earth, Sol, Orion Arm
Contact:

Post by thx2112 » Fri May 03, 2019 9:51 am

Here's the Eagle ULP I wrote a couple years ago. Use what you need if there's anything useful in there.

It just does the outline, and I never made a PCB panel with it, but exported the result as DXF to get panels laser cut. Eagle, for all its faults, exports rock-solid DXFs (and Gerbers).

In the parts library I added a new layer (115) to any component poking through the panel (pots, jacks, leds, etc.). In the Eagle PCB editor this generated panel was used as a guide to lay out all the components. Then just had to export layer 115 as a DXF and send to the laser cutter for perfectly fitting panels with no dicking around and worrying about whether the PCB will line up with panel.

Code: Select all

#usage "Create Eurorack panel outline on layer115"
//
//	By THX2112
//
string cmd="";
int HP=8;
real base=0;
real offset=.36;
real height=128.5;
real maxPCBheight=112.0;

string realToStr(real number)
{	
	string retVal = "";
	sprintf(retVal, "%f", number);
	return retVal;
}

string intToStr(int number)
{	
	string retVal = "";
	sprintf(retVal, "%d", number);
	return retVal;
}

string drawLine(real x1, real y1, real x2, real y2)
{
	string cmd = "";
	cmd += "WIRE (" + realToStr(x1) + " " + realToStr(y1) + ") (" + realToStr(x2) + " " + realToStr(y2) + ");";
	return cmd;
}

string drawArc(real x1, real y1, real x2, real y2)
{
	string cmd = "";
	cmd += "WIRE (" + realToStr(x1) + " " + realToStr(y1) + ") -180 (" + realToStr(x2) + " " + realToStr(y2) + ");";
	return cmd;
}

string drawHole(real x, real y)
{
	real HoleRadius = 1.6;
	real HoleWidth = 1;
	string cmd = "";
	cmd +=drawArc(x-HoleWidth,y-HoleRadius,x-HoleWidth,y+HoleRadius);
	cmd +=drawLine(x-HoleWidth,y+HoleRadius,x+HoleWidth,y+HoleRadius);
	cmd +=drawArc(x+HoleWidth,y+HoleRadius,x+HoleWidth,y-HoleRadius);
	cmd +=drawLine(x+HoleWidth,y-HoleRadius,x-HoleWidth,y-HoleRadius);
	
	return cmd;
}

int Result = dlgDialog("Enter Parameters") {
	dlgHBoxLayout {
		dlgLabel("HP");
		dlgIntEdit(HP, 1, 50);
		dlgStretch(1);
		dlgPushButton("+OK") dlgAccept();
		dlgPushButton("Cancel") dlgReject();
	}
};
// Calculate right side of panel
real width=(HP*5.08)-offset;

// Panel Coordinates
real x1=0;
real y1=0;
real x2=width*1000; // convert units to micrometers
real y2=height*1000;

// Hole Coordinates
real BottomHoles = 3.0;
real TopHoles = 125.5;
real LeftHoles = 7.5;
real RightHoles = ((HP - 3.0) * 5.08) + 7.5;
real HoleRadius = 1.6;
real HoleWidth = 1.6;
real x;
real y;

// Maximum PCB Extents
real RailSpace = (height-maxPCBheight)/2;
real TopExtent = height-RailSpace;
real BottomExtent = base+RailSpace;

// Draw panel and holes
cmd="";
cmd += "GRID MM 1 1;";
cmd += "CHANGE WIDTH 0;";
cmd += "LAYER 115 Panel;";
cmd += "SET COLOR_LAYER 115 WHITE;";
cmd += "SET WIRE_BEND 2;";
cmd +=drawLine(0,0,width,0);
cmd +=drawLine(width,0,width,height);
cmd +=drawLine(width,height,0,height);
cmd +=drawLine(0,height,0,0);
cmd +=drawHole(LeftHoles,BottomHoles);
cmd +=drawHole(LeftHoles,TopHoles);
cmd +=drawHole(RightHoles,BottomHoles);
cmd +=drawHole(RightHoles,TopHoles);
// Draw PCB extent limits
cmd += "CHANGE STYLE SHORTDASH;";
cmd +=drawLine(0,TopExtent,width,TopExtent);
cmd +=drawLine(0,BottomExtent,width,BottomExtent);
cmd += "CHANGE STYLE CONTINUOUS;";
exit(cmd);

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Fri May 03, 2019 6:27 pm

thx2112 wrote:Here's the Eagle ULP I wrote a couple years ago. Use what you need if there's anything useful in there.

It just does the outline, and I never made a PCB panel with it, but exported the result as DXF to get panels laser cut. Eagle, for all its faults, exports rock-solid DXFs (and Gerbers).

In the parts library I added a new layer (115) to any component poking through the panel (pots, jacks, leds, etc.). In the Eagle PCB editor this generated panel was used as a guide to lay out all the components. Then just had to export layer 115 as a DXF and send to the laser cutter for perfectly fitting panels with no dicking around and worrying about whether the PCB will line up with panel.
I like it a lot, thanks! Your approach definitely does avoid alignment problems. Have you tried modifying it to create Eagle boards? Or maybe just a separate CAM job that renders panel Gerber/Excellon files from your circuit's board file, using a different set of layers?

I thought about writing ULPs too but I'm much more comfortable with Golang, and its XML parser made handling the modern Eagle board files pretty uncomplicated.
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
thx2112
Veteran Wiggler
Posts: 514
Joined: Sun Oct 12, 2014 10:10 am
Location: Earth, Sol, Orion Arm
Contact:

Post by thx2112 » Fri May 03, 2019 7:34 pm

Ahhh. I saw "Eagle" and automatically thought "ULP". Now that I understand what you're doing: Interesting... I've been playing with Eagles XML file format , but only for component/inventory management. I'll have to look into your libraries further -- very intriguing.

The code only looks clean because I had a lot of practice from the Inkscape plugin written in Python, which was a mess. Eagle ULPs are basically C which I found a lot easier to write in -- plus I already made all the mistakes in the Python version.

To make panels I think you just need to use the outline layer (20) instead of 115. I do make PCB panels for 1U Tiles, but for those I created library parts since I only use three sizes. It's nice having the ULP version for Eurorack because you can dynamically change the HP to see how many controls you can squeeze in a panel. For Tiles that's not necessary since you only have a few fixed widths to play with, and already know what fits into each panel.

There's no need for a special CAM job: When a board is finished I export the Gerbers to a zip file to send to the PCB fab, then export layer 115 to DXF to send to the laser cutter. That last step could have been added to the CAM job, but it's literally three clicks.

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Fri May 03, 2019 8:07 pm

thx2112 wrote:There's no need for a special CAM job: When a board is finished I export the Gerbers to a zip file to send to the PCB fab, then export layer 115 to DXF to send to the laser cutter. That last step could have been added to the CAM job, but it's literally three clicks.
I meant having a CAM job that creates Gerbers for a PCB panel as well as the PCB for the actual circuit — rather than having a separate board file for the panel. If you had them in the one file you'd be more or less guaranteed correct alignment.

I used to use a lasercutter too (bamboo panels!) but it's 3 hours of transit just to get to/from the makerspace, and I don't have the free time anymore. So PCB panels from China instead.

Would like to figure out what I'm missing that's making OSHPark not accept my generated board files. Then people could use it to get panels made that are larger than their Eagle license allows :miley:
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
indigoid
Super Deluxe Wiggler
Posts: 1252
Joined: Thu May 29, 2014 7:52 pm
Location: Sydney, Australia

Post by indigoid » Fri May 03, 2019 9:20 pm

cackland wrote:Sorry for my ignorance, but is this used by running a script? Maybe I missed the instructions on github?
No, I didn't include instructions for that, sorry. Will fix that sometime this weekend — at least for macOS.
Zap him again! ZAP THE SONOFABITCH AGAIN!

User avatar
cackland
Super Deluxe Wiggler
Posts: 1867
Joined: Thu Dec 28, 2017 5:42 pm
Location: Los Angeles, California

Post by cackland » Fri May 03, 2019 9:28 pm

Ok great. Thanks :)

Post Reply

Return to “Music Tech DIY”