Testing WireViz

Published on Tuesday, July 14, 2020
Tags: hardware, software

I wanted to play with the WireViz Python package, which makes pretty wire diagrams. Installation was pretty easy, just created a virtualenv and installed with pip:

pip install wireviz

Documentation is pretty limited, but looking through the tutorials and the data models you get a pretty good idea of what’s possible.

I’m using the wiring diagrams from my guide to add an auxiliary audio input to a 2005 Subaru Outback, which is pretty simple, there’s an audio jack which connects to the Outback’s motherboard and the Outback’s FM audio module (and ground).

The input is a YAML document with three sections: * connectors - A list of connectors and the information about their port. * cables - A list of wires (and their information, e.g. gauge). * connections - A lists of ports that should be connected via each cable.

I had a pretty simple example, but it ended up being quite a bit of YAML:

connectors:
  RADIO: &radio
    # Since we only care about two of the pins, refer to them directly.
    pinnumbers: [31, 32]
    pinout: [FM R, FM L]
    type: Outback Radio Module
    show_name: false
    show_pincount: false
    hide_disconnected_pins: true
  MOTHERBOARD:
    <<: *radio
    type: Outback Radio Motherboard
  AUDIO:
    pincount: 5
    pinout: [GND, L OUT, L IN, R IN, R OUT]
    type: 1/8" Stereo Audio Jack
    subtype: "RadioShack #274-246"
    show_name: false
    show_pincount: false
  GROUND:
    pinout: [GND]
    type: "Ground"
    show_name: false
    show_pincount: false

cables:
  W1: &wire
    wirecount: 2
    gauge: 22 AWG
    colors: [RD, GN]
    category: bundle
    show_name: false
    show_wirecount: false
  W2:
    <<: *wire
  GND:
    wirecount: 1
    gauge: 22 AWG
    colors: [BK]
    show_name: false
    show_wirecount: false

connections:
  -
    - RADIO: [31,32]
    - W1: [1-2]
    - AUDIO: [4,3]
  -
    - MOTHERBOARD: [31,32]
    - W2: [1-2]
    - AUDIO: [5,2]
  -
    - GROUND: [1]
    - GND: [1]
    - AUDIO: [1]

The only thing I couldn’t figure out was how to list two pins with the proper names and pins numbers, but ignore all the other ones. Note a huge deal for a 36-pin connector. See the comments below, this is doable, although a little awkward!

It did create a fairly pretty diagram after running wireviz subaru-wiring.yaml and is certainly easier than directly using graphviz. It creates a SVG, PNG, bill of materials, and HTML page (with the bill of materials and image on it). Overall, I’d use it again if I had a need!