RPi radial illuminator

Hello,

I would like to follow the studio clock example of @DougE and post my own scripting-related project. That’s my first project ever, but there was quite a bit of python coding involved, so I thought it could be useful.


That’s a simple LED illuminator circuit for a camera project I’m working on, it matches the outline of the Raspberry Pi camera. I have a more detailed description of it on our hackerspace’s wiki: wiki (EN) and wiki (IT).

Scripting

Coming to the scripting part, I have all the sources on gitlab, for who is interested. I got quite picky with the alignment of the components, so I ended up writing some helper classes to handle polar coordinates, chords and sectors (polar.py). This made much easier to code the rest.

I think that the scripting support for Kicad is a very strong feature (and a must have!) but it’s not that easy to do complex stuff due to the forced C+±like syntax you need to adopt because of the Swig bridging. So I wrote a small set of classes that act as an “alternative data model” for Kicad objects (cad.py) and that can be populated from Kicad and be written back.

This “conversion” is probably the most interesting part for people who would like to approach scripting Kicad. That’s all in pcb.py; it reads and writes tracks, fills, pads, components, position, rotation, pad offsets, so if you need any of these, it’s definitely somewhere in there.

The actual placement and routing happens in radial_illuminator.py. I have a more detailed description of this on the wiki. That includes

  • aligning the pads on the circle in a way that they are equidistant
  • approximating a circular track
  • approximating a circular sector fill
  • optimizing orientation an position of some components

The script can be reused for making other designs of the same kind by changing the configuration.

Misc

I had the pcb fabricated withby Elecrow, it was no problem, but I had some difficulties finding online the right settings to use, so here’s a picture of the ones I used, in case someone else needs them.

Also I would like to link here the resources I used to figure out how to script this stuff:


I hope that I will have time to document the code better. :grin:

I also hope that this is not too much python to be off topic for this forum :confused:

6 Likes