My apologies for the late reply. I was so shocked that anyone had posted to this forum that I lost consciousness.
I have a “complete” example of a microcontroller with charlieplexed LEDs and pushbuttons at the end of this post. It doesn’t have enough comments, but ask me questions and I’ll explain what’s going on if it isn’t clear. (Note that I didn’t build or simulate this circuit. I was just getting a sense of how complicated the code would be.)
You point out another issue that needs addressing: examples of complete designs. I have a list of example designs that I’ve been trying to create. These are mainly subsystems like power supplies, ADC/DAC interfaces, USB interfaces, etc. that can be assembled into larger systems. Unfortunately, this has remained an unrealized goal as I keep going off on other things. I’ll probably publish my list in another post and see if anyone has ideas for moving this forward.
Another useful resource would be a page of complete SKiDL designs done by others, similar to this page for MyHDL projects. Unfortunately, I can’t make a page like that without designs from other users and these have been hard to find. Probably a page of completed designs would help to generate more SKiDL projects from others, but that’s a chicken-and-egg problem.
Any way, here’s the promised complete charlieplexing example. (It was done a while ago, so I’d probably do some things differently today.)
from skidl import *
def chplx(b, diode_t, two_pin_t=None):
for hi in b:
for lo in b:
if hi != lo:
diode = diode_t()
hi += diode['A']
if two_pin_t != None:
two_pin = two_pin_t()
two_pin[:] += diode['K'], lo
lo += diode['K']
led_t=Part('device', 'LED', TEMPLATE, footprint="KiCad_V5/LED_SMD.pretty:LED_0805_2012Metric_Castellated")):
switch_t=Part('Switch', 'SW_SPST', TEMPLATE,footprint="KiCad_V5/Button_Switch_SMD.pretty:SW_SPST_CK_RS282G05A3")):
chplx(b, diode_t, switch_t)
vdd, gnd = Net('VDD'), Net('GND') # power & ground nets.
vdd.drive = POWER
gnd.drive = POWER
c = Part('Device','C', TEMPLATE, footprint="KiCad_V5/Capacitor_SMD.pretty:C_0805_2012Metric") # capacitor template.
uc = Part('MCU_Microchip_PIC16',
'PIC16F83-XXSO', footprint="KiCad_V5/Package_SO.pretty:SOIC-18W_7.5x11.6mm_P1.27mm") # Microcontroller.
uc['VDD, VSS'] += vdd, gnd # Attach pwr, gnd to uC.
c_byp = c(value='10uF') # Add bypass capacitor.
c_byp[1,2] += vdd, gnd
xtal = Part('Device','Crystal', footprint="KiCad_V5/Crystal.pretty:Crystal_SMD_0603-2Pin_6.0x3.5mm") # Crystal.
uc['OSC1, OSC2'] += xtal[1,2] # Attach crystal to uC.
c1, c2 = c(2, value='10pF') # Crystal trim caps.
c1[1,2] += xtal, gnd # Connect trim caps.
c2[1,2] += xtal, gnd
chplx_leds(uc['RB[3:0]']) # 12 charlieplexed LEDs.
chplx_switches(uc['RA[3:0]']) # 12 charlieplexed switches.