It doesn’t matter which side of a resistor goes to which connection, and sometimes switching them around can make a board much easier to route. Same goes for equivalent IO pins on a microcontroller and lots of other cases. Here we see what a big difference a little pin swapping can make, and how to give the TopoR auto-router the freedom to swap your pins for you.
Why do clean schematics turn into ugly boards?
Here is the simplest Larson Scanner I could think up…
So clean and simple and zen. Alas, when I go to lay out the board, things start to look complicated…
All those crisscrossed rat lines are because the pins on the schematic are organized logically by name/function, but the pins on the board layout are hopelessly tied to the reality of their locations on the physical part.
This is the nicest route I could find…
Such a mess compared to the clean lines of the schematic. If only there was some way to clean this up…
Swapping equivalent pins for easier routes
It turns out that all of the pins that I am using on the ATTINY25 are equivalent-it doesn’t matter which pin goes to which LED since I can compensate in software.
In this simple case it is visually obvious which pin should go to which LEDs for a nice route, so I could go back and manually hack up the schematic to get those ratlines untangled. But in a real design, not only would I not want to go back and re-do the schematic, I probably could not even figure out what the best pin assignments would be.
Pin swapping tells the software which groups of pins are equivalent so that it is free to use the best pin for each connection.
Using Pin Swap in the TopoR Autorouter
- Export the design in TopoR PCB format.
- Use a text editor to edit the FST file you just exported. For each group of pins that can be swapped, set the
pinEqualto the same non-zero value. Here I set all the GPIO pins of
U1(the ATTINY) to have the value
- Save the file and re-import it into TopoR.
- Pick Tools->Pin Swap to visually confirm you picked the right pins.
- Autoroute the board with the
Pin Swapbox checked and watch as the pins are magically connected exactly where they should be!
Ahh! Isn’t that so much better?!
Note that TopoR’s pin swapping is not perfect. Here I offered to let it swap the two negative terminals of the battery, but it will not swap pins that are not connected to nets, so missed the opportunity to save that long flying trace to the rightmost pad…
So clearly there is room for improvement, and I am still pining for an autorouter that never misses an easy opportunity while also deeply searching for the really hard ones. But until then, I will be happy with an imperfect one that overall does a better job than I could and saves me huge amounts of time.
Q: Dude, real men don’t let a machine do their job for them. I learned to route with tape and an exacto knife before you was born, and I would have used my intuitive routing Fu to make that original schematic match your output board with a blindfold on while I was asleep.
I picked a trivial example to show exactly what was going on – and even in this case I think it is better to make a clear schematic and then let the machine map that to the best physical layout. With more complicated boards I think it becomes impossible to predict which pins are going to end up being best to assign to which nets. Heck, you might not even know what the geography of the final board is going to be when you are making the schematic. Better to capture design intent in the schematic in a way that is easy to read and update, and let the machine do the busy work of translating that into a physical layout. Think of the autorouter as a compiler for your schematic… and do not try to outsmart the compiler!
Q: How much is TopoR paying you for these unabashed plugs?
They gave me a 20% discount on a licence, but I bought that licence because the software (and really the general idea of better-than-human autorouting) has saved me so many hours of busy work. It has even made some boards possible that I am pretty sure no human would have been able to make work.
Q: Can I do this with EagleCAD?
Yes, this same procedure should work fine with Eagle, and Eagle even has a way to indicate equivalent pins when making a new component. If your components have this set up right, you can automatically get some pin swapping without the hassle of the XML editing.
Q: But now how does my software know which mixed-up GPIO pin goes to what?
Yea, this sucks.
So far I’ve just been manually typing in the new pins into a header file. Maybe someone should write a little Python script to do this automatically. Really ideally you would have tools that could keep your hardware and software designs in sync with each other automatically and you’d deal with everything abstractly and never even think about which pins were connected to what. A boy can dream…
Q: Yea, yea – this auto-routing stuff is fine, but you don’t have any current limiting resistors on those LED, bro. The second you but a battery in this, the whole thing is going to BUST INTO FLAMES!
A: No current limited resistors are required. Article forthcoming.