-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Electrical circuit diagrams #2112
Comments
Anybody working on this ? Thinking about starting to implement this feature |
I worked on this a bit, a long time ago, but forgot about it. I still think it's a great idea, though. I think we need to figure out the input & output we expect, first. The example I gave in the other issue was this:
graph TD
R1[1M]
R2[10K]
U1[Arduino Nano]
U2[F0D420]
500V --- R1
R1 --- R2
R1 -- A0 --- U1
R2 --- GND1
500V -- 6 --- U2
U2 -- 4 --- VOUT
U2 -- 1-D2 --- U1
U2 -- 2-GND --- U1
Maybe a first pass is a squared-off layout instead of "bug" and a rudimentary mapping of names? So to parse this, Maybe a sensible structure to shoot for for input?:
But also, netlistsvg can do really fancy stuff with an existing netlist format (yosys JSON.) It uses elkjs for layout, which might be cool for other mermaid-things: It seems like the main trick is the skin-lookup, where if you have this "cells": {
"<cell name>": {
"type": "<type name>",
"parameters": {
"WIDTH": 3,
...
},
"port_directions": {
"<port name>": "<input|output>",
...
},
"connections": {
"<port name>": [ 3, "0", ... ],
...
}
}, It will check the skin (an SVG file with groups, like this) for I like that this JSON format already exists, but I find the format of my hacked I found this which uses the JS layout engine that elk was based on so we might be able to use that for some layout, if the layout stuff already in mermaid can't do it. |
I noticed some of elk here so maybe just inlining that makes sense. |
I would love this and it would complement my use of mermaid. Subscribed |
This would be really useful, has anyone found any other resources to do this? |
Will be great to add this type! Subscribed |
This would be great to include in project documentation! |
I believe it would be very useful to create electrical circuits with mermaid. Many programmers have some electrical engineering background and I think at least a few of them have felt the need to draw electrical circuits. |
Based on the flowchart, it would be easier to first add support for block diagrams. There are mainly four steps required for preliminary support, each step being independent of the others, and the difficulty and specificity increasing sequentially. Below is the first step:
After completing this step, we can approximately depict some simple Block Diagrams as shown below: flowchart-elk LR
a["📡"]:::Trans
--- LNA{"RF amp"}:::BlackWhite
-->Mixer1(("`**✕**`")):::BlackWhite
-->filter["〰\n∿\n〰"]:::BlackWhite_05
---A1{"IF amp"}:::BlackWhite
---d["-▶|-"]:::BlackWhite
---A2{"PA"}:::BlackWhite
---speaker["🔊"]:::Trans
osc["∿"]:::BlackWhite_10-->Mixer1
classDef Trans fill:#ffffff00,stroke-width:0px,font-size:30pt;
classDef BlackWhite fill:#ffffff00,stroke:#000,stroke-width:2px;
classDef BlackWhite_05 fill:#ffffff00,stroke:#000,stroke-width:2px,line-height:0.5;
classDef BlackWhite_10 fill:#ffffff00,stroke:#000,stroke-width:2px,line-height:1.0;
The source code uses a lot of Unicode and some less common features, and it was not easy to draw:
flowchart-elk LR
An-->S-->L
M1-->C1-->AD1
M2-->C2-->AD2
subgraph A
Q-->M1
Q-->M2
LO-->Q
L-->M1
L-->M2
end
flowchart LR
An-->S-->L
M1-->C1-->AD1
M2-->C2-->AD2
subgraph A
Q-->M1
Q-->M2
LO-->Q
L-->M1
L-->M2
end
These four steps are just preliminary support for the most basic block diagrams, considering the diversity of circuit levels and the complexity of circuit topologies, to support all circuit diagrams from transistor level to system level is likely to require a huge investment:
|
Projects worth referencing: Lcapy, Schemdraw, d3-hwschematic, SKiDL, netlistsvg, CircuiTikZ, circuit_macros (link2), PySpice |
Is your feature request related to a problem? Please describe.
N/A
Describe the solution you'd like
It would be nice to be able to specify the connections between each circuit element and have mermaid-js figure out the circuit. I believe this was requested in the past (see issue #811) but the issue was closed due to lack of activity
Describe alternatives you've considered
N/A
Additional context
N/A
The text was updated successfully, but these errors were encountered: