Friday, October 23, 2020

libngspice does not get built by default on macports

If you want to use PySpice, you first must have the library bindings installed. The Macports Portfile for ngspice does not build the libraries by default. Here's the symptom:
OSError: cannot load library 'libngspice.dylib': dlopen(libngspice.dylib, 2) : image not found. Additionally, ctypes.util.find_library() did not manage to locate a library called 'libngspice.dylib'
Basically, this means that there's just not a library. I couldn't find it anywhere, and then I realized that macports did not build the library by default.
Find where the portfile is:
sudo port file ngspice
Next, you have to edit it to add --with-ngshared:
    configure.args      --enable-cider \
                        --enable-xspice \
                        --enable-pss \
                        --with-editline \
                        --with-x \
                        --enable-debug=no \
                        --with-ngshared
Finally, you can build the port. If you have already installed it, you need to upgrade it:
sudo port -sn upgrade --force ngspice
I wish that there was some way to append a configuration argument via the command line, but I just cannot seem to make it work, even though there's a facility for it.

freehdl doesn't work as-is on macports

I had to add the following to the portfile:
configure.cxx_stdlib	libstdc++

Friday, September 11, 2020

PIC32MZ TFBGA pins are incorrect in the document

The PIC32MZ2048EFH144 is a fine MCU. I have code for both the LQFP-144 and the TFBGA-144, and there's not an obvious way to easily map between code version and the hardware pinouts. For this reason, I made a spreadsheet, and there were errors on the TFBGA-144 pinout. Please note the images below from version DS60001320G of the datasheet:
You will notice M11, M11 and Z13. Firstly, the issue is that there should never have duplicates, and then there's not a "Z" row on the BGA. The correct pins follow:
M11 RH15
K10 VSS
A13 RE3

The A13 was easy to guess, and I confirmed it by toggling the pin. The M11 I had tied to GND, and I confirmed this pin by watching the current fluxuate when I single stepped it while measuring current. The complete and correct pin list follows:
PIC32MZ144 QFP pin number PIC32MZ144 TFBGA pin number pin ID voltage tolerance name function
1 A12 RG15
2 B12 RA5
3 A11 RE5
4 B11 RE6
5 B10 RE7
6 A10 RC1
7 C9 RJ8
8 B9 RJ9
9 A9 RJ12 5V
10 A8 RJ10 5V
11 B8 RC2
12 C8 RC3
13 D8 RC4
14 B7 RG6
15 C7 RG7
16 D7 RG8
17 D6 VSS
18 A7 VDD
19 C6 RK0 5V
20 B6 MCLR 5V
21 A6 RG9
22 D5 RA0
23 A5 RE8
24 B5 RE9
25 C5 RB5
26 A4 RB4
27 B4 RJ11
28 C4 RJ13 5V
29 C3 RJ14 5V
30 B3 RJ15 5V
31 C2 RB3
32 D4 VSS
33 A3 VDD
34 B2 RB2
35 A2 RB1
36 A1 RB0
37 B1 RB6
38 C1 RB7
39 D2 RA9
40 D3 RA10
41 D1 AVDD
42 E4 AVSS
43 E1 RH0
44 E2 RH1
45 E3 RH2 5V
46 F4 RH3 5V
47 F3 RB8
48 F2 RB9
49 F1 RB10
50 G1 RB11
51 G2 RK1 5V
52 G3 RK2 5V
53 G4 RK3 5V
54 H4 VSS
55 H1 VDD
56 H2 RA1
57 H3 RF13
58 J4 RF12
59 J3 RB12
60 J2 RB13
61 J1 RB14
62 K2 RB15
63 K4 VSS
64 K1 VDD
65 K3 RH4
66 M3 RH5
67 L3 RH6
68 L2 RH7 5V
69 M2 RD14
70 L1 RD15
71 M1 RC12
72 N1 RC15
73 N2 VBUS 5V
74 N3 VBUS3V3
75 L4 VSS
76 N4 D-
77 N5 D+
78 M4 RF3 5V
79 M5 RF2 5V
80 L5 RF8 5V
81 K5 RH8 5V
82 K6 RH9 5V
83 L6 RH10 5V
84 M6 RH11 5V
85 N6 RA2 5V
86 M7 RA3 5V
87 L7 RA4 5V
88 N7 VDD
89 K7 VSS
90 K8 RF4 5V
91 L8 RF5 5V
92 M8 RK4 5V
93 N8 RK5 5V
94 K9 RK6 5V
95 L9 RA14 5V
96 M9 RA15 5V
97 N9 RD9 5V
98 N10 RD10 5V
99 M10 RD11 5V
100 L10 RH12 5V
101 K11 RH13 5V
102 L11 RH14 5V
103 M11 RH15 5V
104 N11 RD0 5V
105 N12 RC13
106 M12 RC14
107 N13 VDD
108 K10 VSS
109 M13 RD1 5V
110 L12 RD2 5V
111 L13 RD3 5V
112 K13 RD12 5V
113 K12 RD13 5V
114 J11 RJ0 5V
115 J12 RJ1 5V
116 J13 RJ2 5V
117 H13 RJ3 5V
118 H12 RD4 5V
119 H11 RD5 5V
120 J10 RD6 5V
121 H10 RD7 5V
122 G13 VDD
123 G10 VSS
124 G12 RF0 5V
125 G11 RF1 5V
126 F10 RK7 5V
127 F11 RG1 5V
128 F12 RG0 5V
129 F13 RA6 5V
130 E13 RA7 5V
131 E12 RJ4 5V
132 E11 RJ5 5V
133 E10 RJ6 5V
134 D11 RJ7 5V
135 D10 RE0 5V
136 D9 VSS
137 D13 VDD
138 C10 RE1 5V
139 D12 RG14 5V
140 C11 RG12 5V
141 C12 RG13 5V
142 C13 RE2 5V
143 B13 RE3 5V
144 A13 RE4 5V

Tuesday, August 25, 2020

Renaming a KiCad project

I keep my projects in svn, and kicad made it more challenging than I expected to rename a project. The orignal project was igbt-tx, and my new project is tx-3x1. First, you rename the top level project:
for f in igbt-tx*; do svn mv "$f" "$(echo $f | sed 's/^igbt-tx/tx-3x1/g')"; done
You then need update the libraries:
find ./ -type f -exec sed -i 's/igbt-tx/tx-3x1/g' {} \;
If you want to do this without svn, you need to just remove the "svn".

Friday, August 14, 2020

kicad eeschema parts off grid

One of the challenges of collaboration is configuration. I found today that if you "right-click", you can change the schematic grid. I was having trouble with my grid being 1.5 times of the collaborator. 

 

Thursday, July 23, 2020

converting between decimal and hex on the command line

I've never been on a *unix system without bc installed. (I was surprised recently as well that some Linux distributions do not include vi) Recently, I have had the need to convert decimal to hexadecimal and hexadecimal to decimal enough to warrant scripts.
#!/bin/sh
#dec2hex.sh
COMMAND=bc
if ! command -v $COMMAND &> /dev/null
then
    echo "$COMMAND could not be found"
    exit
fi 
echo "obase=16; $@" | $COMMAND

#!/bin/sh
#hex2dec.sh
COMMAND=bc
if ! command -v $COMMAND &> /dev/null
then
    echo "$COMMAND could not be found"
    exit
fi
echo "ibase=16; $@"|$COMMAND

Sunday, June 21, 2020

FreeCAD via Macports under MacOS 10.13.6

There were all sorts of errors getting FreeCAD to install, but I found a ticket:
https://trac.macports.org/ticket/60039
Sadly, it still took me a bit to sort it out. You need python2.7 and boost.
sudo port select python27
If you do not have python27, install it. (however, it'll probably come with boost)
sudo port install boost @no_single+no_static+python27
At this point, you should be able to build FreeCad
sudo port install freecad