Kicad and Wings

You couldn’t pair up a more esoteric set. The only thing that beats wings3d’s user interface is wxwidgets.

My understanding is that wings3d vmrl (or wrl) files are used in kicad because that is just about the only open format that also supports textured faces, but then kicad goes and only supports an old obsolete vmrl format. Some programs, like FreeCAD, can export wrl files. You might get excited by that. You might then get very, very disappointed. It is not compatible.

I’ve found a pretty good groove though for creating pretty 3d models for kicad. First I generate the model using either FreeCADftsh-mt or OpenSCAD. I find FreeCAD more amenable to creating things like pin arrays, like the ones in this 0.05 pitch header I modeled, and OpenSCAD a better fit for making oddball shapes. That probably seems backwards to other people. Meh, it’s my experience. OpenSCAD is also good for making parameterized models where you can generate a slew of different sized headers or SMD DIP packages. I’ve BOMeddip-smd some MOC3031 and opto-transistors in what can only be described as a standard DIP through hole package, but with the legs bent and flattened out for SMD. This here is the footprint preview in kicad. Having this modeled in OpenSCAD, and properly parameterized, would make adding a 10 pin version quick and easy. This one was, however, modeled with FreeCAD as well.

Once I’ve got a model I’m happy with, I export it into a format that wings3d understands. I have not,
for all my trying and googling, found any format that wings3d will import with color. Nothing. Nada. If anyone knows of one, please… So my export is usually STL or obj. Now here’s the trick! Create a separate export for each color. Everything that’s black, export in one file. Everything that’s silver in another, and so on.

Now start up wings3d. You might think you could give it a file on the command line, and have it open that file! You’re wrong. At least, if the file type you’re opening is actually an importable file type and not the native .wings filetype. But actually I do open a wings file, one I’ve populated with various “materials” that wings3d uses to apply colors to the final wrl export. Spend some time playing with the materials, maybe find some existing .wings files online for examples? It’s not hard, but it’s very much not intuitive. This post has a great rundown of how to access materials, create new ones, and apply them to surfaces.

Here’s the trouble. At least, I haven’t found a way to get materials from different files and combine them into a single file! The mind boggles. So whenever I want a new color, I open up that particular file that shall forever hold all my different materials, and add the new material there, not while I’m playing with my shiny new model. I know, it’s so tempting!

So, now I’ve opened my colors file that already has the colors I want. Then I delete the ‘test objects’ from geometry graph (there’s a few windows you’ll want open from the windows menu item while you work in wings3d). With a blank workspace, Go to File -> Import -> STL (or .obj). Import each separate model file for each color. This is the trick from before. As Happy Robot Labs mentions in the linked post above, selecting the faces to color is not exactly all that easy. Dragging a selection box is effective, but you’ve got to orient things. And any concave selections… forget about it. However, each separate import becomes a group. And with the solid red box icon selected, you just click on any part of that group and the whole thing is selected. Apply the material, bam.

Finally, export the material in .wrl format. Add it to the footprint in kicad (I usually have to scale it by 1/2.54), play with the rotations, and enjoy amazing 3d board previews!

RC Networks, They Matter!

After a long hiatus, I’m finally dusting off some projects and getting back into them, well, one in particular, the sous vide controller. I knew there were board errors from the prints I ordered early last year, I had even started to fix some of them. I got the boards and components and eagerly assembled one. Once I powered it on, there was one immediate problem. The LCD contrast with a diode that I wrote about previously, well, it’s not giving so constant a contrast on this board. Maybe it’s a poor diode, maybe I’ll build a bench power supply to vary the voltage across different diodes and see how they respond.

After putting some code on the chip, I found another problem. The push button on the encoder would not work. I got nothing at all from it. From probing the board and the resistors, I discovered that the button was active high, but my idle resistors were also pull-up. Tsk tsk. Ah well, that’s an “easy” fix, just scratch out some traces, re-route (in this case a power rail) around them, no problem, and connect the common side of those resistors to GND instead.

That got the button working, but not the encoder. Long story short, I played with the hard-to-see LCD for a while and then set it down for many moons. Oh that’s right, I also had to cut the common freewheel diode leg from the transistor array because apparently that’s not supposed to connect to “common”. Oops.

Fast forward, and now I dust it off, scratch my head, and try writing some simple encoder and button tests onto it. When they failed, I turned to my schematics, and scratched my head again. What I noticed actually pretty quickly is that the encoder legs were active LOW, but the push button active HIGH! *sigh* “I see why I did that,” in a way at least. I had to tie the push button active high because it shared with the common anode on the encoder LEDs. And it would seem I found that out after I made the quadrature active low.

So, I fixed all of that. I’m determined now to get this board to work. Of course I’ll make another run with corrections, but only after I find all the corrections. A few more trace cuts, more jumpers, and I got all the inputs working. Well, kinda… The rotary worked, a little bit. But not nearly fast enough. First I sped up the polling and that helped, only a little. Then I went full on PCINT driven, and no more improvement was to be found. At this point  I was beginning to suspect the RC network was too slow.

debounce-old

I plugged those values into units (not that that would be particularly needed in this case, but just the same, I highly recommend units!) and looky there. Fall time of 15ms! Yikes.

So I replaced the capacitors with some 15pF I found at Ra-Elco, and now it works flawlessly.

Moral is, don’t make board mistakes.
Moral is, you’re probably going to make board mistakes.
Moral is, don’t just pick component values because … whatever? Ya, don’t do that.