10
\$\begingroup\$

Are there any code based tools for drawing schematics=? I only need to draw some simple diagrams, including some 16pin microcontroller, wire, power supply, etc.

I'd like to use code to specify the pins and components, and let the software do the layout for me. Kind of like define a graph with graphviz dot format.

Some thing I have in mind is:

define a Microcontroller
pin1.label="Vcc"
pin1.goto=other components

How can I design a circuit using a text based format?

\$\endgroup\$
1

6 Answers 6

6
\$\begingroup\$

You should take a look at skidl which uses python to design and test a circuit and it will create the netlist https://github.com/xesscorp/skidl

\$\endgroup\$
4
\$\begingroup\$

SchemDraw and lcapy are two Python schematic drawing libraries.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I've fixed the link for SchemDraw... but it looks like Icapy just isn't available anymore. \$\endgroup\$ Commented Jun 14, 2022 at 13:27
3
\$\begingroup\$

You could use TeX http://www.ctan.org/tex-archive/graphics/circuit_macros/

\$\endgroup\$
3
\$\begingroup\$

Try Fritzing.

It's an all in one simplified schematic and breadboard designer with a straightforward XML format.

http://fritzing.org/support-us/developer/fritzing-sketch-file-format/

\$\endgroup\$
1
  • \$\begingroup\$ This link seems to be broken! \$\endgroup\$ Commented Jun 14, 2022 at 13:36
2
\$\begingroup\$

gschem has a simple text-based file format. But if you want to automatically place the wires making connections on the schematic, then you are asking for autorouting, similar to a pcb layout package. I don't know any software package that implements this.

A schematic is a visual way to represent a netlist. It is for humans. The computer (and the electrons) just care about the netlist. So you could design the pcb from the netlist and skip the schematic step altogether. Schematics with big FPGAs or processors end up as netlist anyway: each pin is shown connected only to a named net. If that is what you are planning, there's no need to draw a schematic.

\$\endgroup\$
2
\$\begingroup\$

I think that you're going to struggle to find or make such a package.

To represent connections, there are plenty of netlist formats; several EDA packages use text-based formats for internal representation, and almost all can output a text-formatted netlist. This is probably the easiest third of what you want. I'm not aware of any that have a syntax that's easy to write and keep track of.

The labeling and definition functionality is typically contained in a part library. Again, there are text-based formats for this. Some manufacturers publish text-based pinouts of all their components to be used in generating a library. This functionality should probably be separated from the netlists, i.e. you'll do #import and then instantiate one.

Laying these components out in a sensible way is the last third of the problem, but it would be 99.99% of the effort. As Mark said, schematics are for humans. There are some basic rules, like voltages are higher on top and signals/data flows left to right that help make schematics more readable, but there's a lot of information contained in the arrangement of symbols that would be difficult, if not impossible, to represent in a netlist or other code format. Autorouters are a very high-dollar code project, and autoplace would be, if they could get it to work well. Those tools are used on PCBs, which don't generally contain semantic information in their placement.

If you can generate a schematic from code that's almost as readable as a human-designed schematic, then you'll be a millionaire in no time.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.