My Cadsoft Eagle tips

 

Just some notes mainly for myself as I get into some of the finer points of Eagle, for instance I had a schematic that had been revised and no board, the previous version had both but there were enough changes to make it a hassle. So I figured script it, Eagle has a decently powerful scripting interface. Most of the things I end up trying to figure out involve changing existing laid out board to be suitable for my AccurateCNC 560 and PCB process.

There might and probably is a better way to do most of these, but that is partially why I’m putting up an entry.

I use the Sparkfun CAM (from http://www.opencircuits.com ) as starting off point,my DRC generally has 8mil min sizes and 31 mil minimum drill for via’s which is huge. Sparkfun also have their library available, but it has conflicting information for commercial use.

 

Script/command line

rotate =MR90 LED1  rotates and mirrors LED1 regardless of starting position, M=mirror
move LED1 ( 1.0 1.0 )  moves LED1 to 1.0 1.0
info LED1  equivalent to properties
show LED1 same as clicking with the mouse

 

Changing VIA sizes after the board has been laid out, without ripping up

I have some via rivets LPKF EasyContac , the smallest has an outer diameter of 31mil , most board via’s are much smaller, so I wanted a way to resize them. I did the DRC, switched off some of the layers, then just clicked through them.

change drill value

Obviously the downside is that the changed Via may now overlap or cause routing problems, sod’s law will guarantee it. Its funny how the smallest of changes will throw off an entire board, the knock on effect can make it go from i just need to resize that one via, to the whole board has to be rerouted.

I’d hoped this would do it, but alas no. From a cursory glance over other scripts, you generate a cmd that does the changes. I just have to figure out how to select the via I want to change.

B.signals(S) {
  S.vias(V) {
     if( V.drill < drillminsize ) {
              V.drill = drillminsize;
      }
     }
  }

So this is where i went with it

 

#usage "<b>Export size and position information from a board to a script.</b>\n"
       "<p>"
       "<author>Author: Charlie Wallace</author>"

// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED

real u2u(int x) { // resolution 1/100 mm
   x = round(x * 100)/100;
   return u2mm(x);  // if mm
}

real u2ang(real x) {
  if (x > 360)
     x = x -360;
  x = round(x * 10)/10;
  return x;
}

if (board) board(B) {

          output("test.scr","wt") {   

        // switch to metric
        printf("grid mm\n");

        // iterate elements
        B.elements(E) {
            printf("move %s (%g %g)\n",E.name,u2u(E.x),u2u(E.y));
            if( E.mirror )
                printf("mirror %s\n",E.name);
         }
    }
}

else dlgMessageBox("Start this ULP in a Board!", "OK");
exit (0);

 

First problem is that it uses a fixed name and path for the scr, second is that the mirror is a flip flop not an absolute. I’ll go over the existing parts first

the real u2u…just converts eagles units to mm, easy enough i copied it from one of the existing scripts, same for the u2ang().

if (board) board(B)

this checks to see if we’re in a board, and then starts an iterator for all the boards in B. its like a for loop that makes B point to each instance of the board.

output("test.scr","wt") {   

this creates an output file called test.scr with “wt” as write text, C programmers that are familiar with fopen will notice the similarities. Eagle uses {} instead of fopen/fclose style, that is that the file will remain open for writing within the { } .  as with fopen this overwrites anything that already exists.

          // switch to metric
        printf("grid mm\n");

 

we’re using metric positions, easy enough, this outputs the a line by itself to test.scr that just says

grid mm

next is  

     B.elements(E) {

 

this iterates each of the elements in the board, look at E_ELEMENTS in the eagle help manual for all the members

              printf("move %s (%g %g)\n",E.name,u2u(E.x),u2u(E.y));
            if( E.mirror )
                printf("mirror %s\n",E.name);

 

this prints out a move and maybe mirror ( if the part is mirrored) with the internal eagle units converted to mm so it appears as

move R1 (1.0 1.0)

that is basically it! it was faster for me to learn eagle scripting and write this, than it was doing an info, show, and typing in the coords by hand for 50+ components.

 

Next is to fix the mirror issue. After a quick grep of the help file for ‘mirror’ we see that the rotate is able to set the absolute, which is great since we need to add rotation as well. angle is the member in the UL_ELEMENT structure we need for the rotation, so :-

 

        if(E.mirror)
            printf("rotate =MR%g %s\n",E.angle,E.name);
        else
            printf("rotate =R%g %s\n",E.angle,E.name);

         }

That adds the rotation and the absolute mirror, it doesn’t deal with multiple layers.

As its stands now, it needs a file requestor dialog for the script, and to support layers. But it worked (for the most part) for what I needed. Oddly enough one of the components refuses to accept a rotation or mirror, it’ll move but that’s it. Even by command line, have to investigate that one, it certainly helped me transfer the board, but it needs work.

#usage "<b>Export size and position information from a board to a script.</b>\n"
       "<p>"
       "<author>Author: Charlie Wallace</author>"

// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED

real u2u(int x) { // resolution 1/100 mm
   x = round(x * 100)/100;
   return u2mm(x);  // if mm
}

real u2ang(real x) {
  if (x > 360)
     x = x -360;
  x = round(x * 10)/10;
  return x;
}

if (board) board(B) {

          output("test.scr","wt") {   

        // switch to metric
        printf("grid mm\n");

        // iterate elements
        B.elements(E) {
            printf("move %s (%g %g)\n",E.name,u2u(E.x),u2u(E.y));
        if(E.mirror)
            printf("rotate =MR%g %s\n",E.angle,E.name);
        else
            printf("rotate =R%g %s\n",E.angle,E.name);

         }
    }
}

else dlgMessageBox("Start this ULP in a Board!", "OK");
exit (0);

 

Polygon pours usually make for easier routing (as well as the normal benefits)

At the least this has been true for the boards I’ve been working on, having a common GND plane has made it much easier to route, the bonus being that you don’t have to work about the excess copper on the PCB during CNC too. Initially I’d been using PhCNC to do copper removal which looks nice and might help with assembly due to clearances, swarf and shorts during soldering but it takes a while to do and it eats up expensive end mills

 

Autorouter as a tool

Autorouters are a much maligned process, but its simple enough they’re a tool that may help with a process, not a solution for every situation. I use it to help me layout and then individually route, I find routing some of the harder parts by hand helps the auto routing a lot. Artistic style is one thing, but just like source code the pretty formatted code can still be buggy, it just makes more pleasing to humans, in circuits that is what schematics are usually for. Read up on all the right angle stuff, then find the papers where people have actually measured it and determine if your circuit needs it, granted habits are good but no need to go crazy but importantly learn why. Bunny over at Chumby Studios throws out some excellent tips. Engineers tend to be a bit overly obsessive, that is why they often ship late.

Don’t expect to the auto router to make pcb’s like you see on professional boards, it’s just not going to happen, but if you help it along a bit you’ll get good results. The usual horses for courses rule applies.

 

Multiple Monitors

Probably one of the best investments you can make, I like the Hannspree 28’s cheap and cheerful, Schematic on one, board on the other (and a third smaller one for the blog ! )

About these ads