Benjamin Howes

Hi I'm Ben, I'm an Entrepreneur and Developer. This is my Portfolio/blog :)

Importing PCB’s from kicad in openSCAD

For a university project I have a few PCB with rotary encoders that need mounting fairly accurately on a printed part. In order to design the 3d printed parts around the PCB’s I’d already designed, I was able to go through the following steps:

  1. Export a 3d model from PCBnew using `file->export->VRML`. There seem to be a few small issues with this, where the referenced files don’t get copied correctly. Have a google about id this is the case for you.
  2.  This should be importable by blender, so open up Blender, delete the little cube that’s there by default, then go to `file->import->3XD` and get your board in. (it should be populated at this point!)image
  3. Export an stl from Blender by going to `file->export->stl`
  4.  You’re ready to use it in openSCAD! you need the import command I found it useful to add a cube which is the board, since there doesn’t seem to be a board by default.

Result:image

It certainly seems to be quicker than making an accurate representation of the populated board, as is often needed for fitting boards into tight spaces!

nodejs Array performance

Don’t pay much (if any) attention to this for now! Mark pointed out in the comments that a big part of the performance decrease is due to the unshift() function. Imma gunna retest this and update accordingly. Cheers Mark for letting me know!

Preamble: I was playing around with a simple test the other night to prove to myself that gamblers fallacy is, just that, a fallacy! It’s something I’ve known for a long time, though there is still always this part of my brain saying “nooooo! It’s way more likely to be heads after these 3 tails!”. Recently I have been reading "Thinking, fast and slow" by Danie Kahneman which when talking about errors of `fast` judgements really made me think that it’s worth making a big deal out of this to try to make better judgements!

This post is about the performance of arrays in javascript and my experience of being humiliated in these matters by a friend (@BMirey). I wrote a simple test which loops over, doing a million coin flips and has a set of functions that return their guess for the current flip. One of these knows the result of the last few flips which it stores and bets on heads if it’s seen more tails recently and vice-versa (if it’s seen equal amounts then it’s random). Real simple stuff. The shocker here is that it took well over an hour to do a million runs!

The guessing logic looked like this:

 

While this was running Mike was, rightly, highly suspicious about how long things were taking. He set to work on a python port of my ~70 line coffee file, which can be seen here His ran in 14 seconds providing the answers as expected also! But… but? Something was wrong, surely! Mikes python code was around 300 times faster than my coffeescript, which is 2 orders of anyones magnitude.

I had a look about and found this stack overflow question and decided that I should have a look at using typed arrays! My modified code looks like this:

 

The million iterations now runs in 2.7 seconds - much better! It’s worth noting that removing the divisions helps (just uses counts without division as in the first example), but it’s got nothing on the speedup from switching to a proper typed array.

The entire coffee file to prove to the gambler within that it’s a fallacy can be found here

The lesson for me is that when doing something math heavy with arrays - use a proper typed array and consequently don’t do hash table lookups on every array access! I’ll do a proper analysis and a few graphs when I have my desktop in a few days!

It’s been a crazy couple of months since I last posted anything, which has been because too much has been happening (rather than nothing). Lots of exciting things happened with my group project and I shall be posting details on here as well as on the projects blog just as soon as my last exam is finished!

It’s been a crazy couple of months since I last posted anything, which has been because too much has been happening (rather than nothing). Lots of exciting things happened with my group project and I shall be posting details on here as well as on the projects blog just as soon as my last exam is finished!

Got all the plastic laser cut this morning and have put everything together - this completes the hardware for my 3rd year group project. See more about it at http://csecar.wordpress.com

Designs to go with the parts mentioned in the previous 2 posts. Going to get these laser cut first thing tomorrow, then It’s time to get a buggy with a few hundred pounds of extra electronics running around. Cannot wait!

Designs to go with the parts mentioned in the previous 2 posts. Going to get these laser cut first thing tomorrow, then It’s time to get a buggy with a few hundred pounds of extra electronics running around. Cannot wait!

Designs from previous post printed with pretty much all the additional electronics for our group project. 

Designs from previous post printed with pretty much all the additional electronics for our group project. 

I designed some parts for our group projects buggy. We need a perspex/plexiglass sheet to go between the front and back. This will hold all the additional electronics we’re retro fitting to our remote control car.
Going to print them out shortly :)

I designed some parts for our group projects buggy. We need a perspex/plexiglass sheet to go between the front and back. This will hold all the additional electronics we’re retro fitting to our remote control car.

Going to print them out shortly :)

A whole load of nice parts from my new machine. There are still a few little bits that go wrong from time to time with the firmware, which is probably a setting I need to change, but on the whole its printing great!

A whole load of nice parts from my new machine. There are still a few little bits that go wrong from time to time with the firmware, which is probably a setting I need to change, but on the whole its printing great!

The first perfectish part printed of a brand new reprap! There have been plenty of teething problems that I will try and update in the reprap wiki asap!

Team Fortress 2 in ubuntu 11.04

TF2 runs great in wine, other than one small issue - there seems to be something not quite right that causes some of the characters to appear white some of the time. The solution to this is simple, enable the developer console in the options, press ‘`’ and type:

mat_softwarelighting 1

Prepare for a few seconds of complete unresponsiveness whilst it thinks about that, then you should be alright. Do this in the menu screens before you’re actually playing because I’ve found that this can break things.

I have put this option in a autoexec.cfg, but I still seem to need to run it manually - will update this if I work out what’s going on with that.

This is only a workaround I know, but it makes the game playable, which is good enough for me :)