Delete a bunch of mongo databases at once

I know this is knucklehead stuff, but I never trust myself to do it without 10 minutes of practice beforehand:

var dbs = db.getMongo().getDBNames()
var prefix_to_drop = 'testdb_';

for (var i in dbs) {
  db = db.getMongo().getDB(dbs[i]);
  if (db._name.lastIndexOf(prefix_to_drop,0) === 0) {
  print("Dropping " + db._name);
  db.dropDatabase();
  }
}

I use this when I’ve been breaking tests, and the database cleanup is getting skipped. And I end up with 150 test databases lying around.

Calibrating e-steps

Every time I have to do this, I forget what to do, and have a frustrating time. Because it’s simple.

G91 – Sets the printer into relative mode. This is so that issuing:

G1 E10 – actually moves 10mm. I do this twice in row for each measurement. The first one compensates for the inaccuracy of the previous measurement.

I could issue a G92 to zero everything instead of doing the G1 twice, but I don’t.

Then M92 E800 to set esteps per mm to 800. Mark on the filament 10mm on the ruler, then send G1 E10, and see how far the mark is from the 0mm mark on the ruler. Once it’s as accurate as can be at 10mm, do a couple at 50mm or 100mm to check the accuracy better.

I just got a new extruder.

Settings:

  • Mini extruder with NEMA14, E3D hotend: e-steps per mm: 700
  • Bulldog Lite with bowden, E3D hotend: e-steps per mm: 114

 

New 3D printer

I’m building up a new 3D printer, a Mendel Prusa i3.  I ordered a mechanical pack from Greg Colbourn on the eMaker site that included all of the hardware, rods, nuts and bolts, bearings, motors and a set of flat parts in 6mm plywood.  I got a RAMPS electronics pack from the now-ubiquitous reprapdiscount, and was impressed by it.  It included hall-effect endstops and a neat LCD display, and a MK2A PCB heatbed.  I also got a 30A, 12V power supply.

I sanded down the plywood and finished it with some oil (and very handsome it is too) and printed off a set of Prusa i3 parts on my little eMaker Huxley in some nice silver ABS.  I think perhaps the Huxley has detected that it is fabricating the parts for its replacement, and is acting up a bit so a couple of the parts are a bit curled, but fortunately the design of the i3 parts is such that the squareness or flatness does not rely on a good bond to the bed.  Good work.

The mechanical parts went together with a minimum of fettling but I had to print some holders for the LM8UU bearings on the y axis.  These are designed to be simply zip-tied into some slots on the y-carriage, but I found that y-carriage itself collides with the y-axis motor at the far end of it’s travel.  Not by much, but a little, and enough to raise the bed a touch, so I modified the Y bearing holders from the i3-mini variant of the machine and that raises it a mm or so.  Bit of a pain because the hole spacing is so tight, but it works.

I like the three-point heatbed fixing / suspension system on my eMaker Huxley, so I went for the same thing on  this machine.  RepRapPro sell parts separately, so I got the aluminium heat spreader and the MDF insulator from them, along with the spring mounting hardware to go with it.  Of course, this system doesn’t use the four outer corner bolts like the i3 is set up, so I printed some extra pieces that bolt onto the y-carriage.  I lose some z build height, but it’ll do until I get an adapted y-carriage cut.

One of the most troublesome points of failure in my eMaker machine is the termination of the power electronics.  The Sanguinololu board isn’t great for the heatbed because the traces are pretty slim and I think the power handling is close to its rated limits.  That, together with _just slightly too little wire_ for the moving parts has meant that the cable to the heat bed has burnt out a couple of times.  I was determined to make a better job of the wiring this time around to avoid the froth of cabling that surrounds the Huxley.

To this end, I finally got some bootlace ferrules and made up a high-power wiring loom with with ferrules on one end (for screwing into the screw terminals on the RAMPS board), and fork or ring terminals crimped on the other end.  The fork terminals go into the screw-down terminals on the power supply, and the ring terminals are bolted into holes on the PCB heatbed.  I had to drill the holes out a little for that, but there is plenty of contact between the washers on the bolts and the traces on the bed, so it’ll be ok, and it has the benefit of being completely solder-free, and everything is disassembleable and replaceable.  This will make it less brittle, and more reliable.  I don’t know why more people don’t do this.  Soldering trailing wires onto moving PCBs is a really bad idea but this seems to be accepted practice on repraps.

Hot end is a lovely E3D, all-metal device.  Haven’t used it in anger yet, but it builds easily, heats up fast and squirts hot plastic out, and that’s what I look for in a hot end.  It came with a cartridge heater rather than a resistor.  I like it.

Finally is an extruder.  After being used to a bowden extruder on the Huxley, it seems weird to expect to fit a massive NEMA-17-toting extruder on the x-carriage itself, so I’m planning to eventually go with a bowden arrangement again.  It just seems more civilised.  However, E3D are out of stock of the bowden kit, so that’ll have to be a later development.  In the meantime, I’ve got the hardware for an MGS (metal gear system) extruder, and am printing up the RP parts for it right now.  The small gear on my old eMaker, Wade’s-style extruder has always worried me, and has always been deformed.  I just don’t like it, so I was pleased to see a metal system around.  I wonder if a direct-drive is better again, but I’m happy to wait to try that.

 

 

JMyron – unsatisfied link is now satisfied

I was putting JMyron on a new machine, to use in Processing on Windows 8, and kept getting this:

Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: C:\Program Files\processing-1.0.4\libraries\JMyron\library\JMyron.dll: Can't find dependent libraries
     at java.lang.ClassLoader$NativeLibrary.load(Native Method)

Well, I used Process Monitor to see what was going on, and spotted a load of failed attempts to open MSVCP71.dll during sketch startup.  I tracked down a copy of that C library (msvcp71.dll and msvcr.dll), dropped them into my system32 dir and hay bingo, works.  Process monitor is ace.

I had already installed the C++ 2010 redist.  I guess JMyron needs some extra sugar.

 

Installing OS over PXE on machine without USB/optical drive

I got a little second-hand Dell D430 laptop to use for my upcoming polargraph show. I’m actually really impressed, it’s a dinky little thing.  No optical drive however, and installing an OS from a USB memory stick didn’t seem to work.  So I’ve done it over the network, and it even seems to work.

PXE (Pre execution environment) is the method, and this is a way of booting over LAN.  Hit F12 on the POST screen and then boot from NIC.  There needs to be a server on the network with TFTP running on it, to dish up the necessary files.  This is hard, but there is a nice little app called SERVA that handles the TFTP/DHCP stuff, because I don’t know how to.  Anyway, I followed the instructions on this site and windows 8 is winging it’s way onto my new old machine.

Issues:

I initially tried putting the windows 8 disk in and symlinking to it instead of copying the files into the TFTP source folder.  That worked up to a point, but the installation failed.  I think it is because SERVA needs to add some files to the windows installation to customise it for this method, and obviously that can’t work if it’s read-only (on a CD).   So actually copy them over, or at least make sure they are somewhere that is writable.

CV on Raspberry Pi

OpenCV is a pain.  I guess I’m just being a dolt, but I can’t get it working.

I want to run a piece of software on my pi that will run my slow photo booth at the upcoming Edinburgh mini maker faire.

SimpleCV - http://www.raspberrypi.org/phpBB3/viewtopic.php?t=36348&p=305689

Issue with getting lots of VIDIOC_QUERYMENU: Invalid argument and then a bunch of “Select Timeout” messages:

from http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=11745:

You can not edit the binary uvcvideo.ko file directly. I advise not trying to compile it yourself. It’s not worth the struggle. You can try various options temporarily on the fly. Attach your webcam, the driver module should be loaded and shown by

CODE: SELECT ALL
lsmod

. Then you unload the module using

CODE: SELECT ALL
rmmod uvcvideo

. Afterwards you can reload the module with something like

CODE: SELECT ALL
modprobe uvcvideo nodrop=1 timeout=5000

. Fiddle around with the settings.
You can make a set of parameters permanent by editing the file /etc/modprobe.d/modprobe.conf . For the above settings, simply add a line saying

CODE: SELECT ALL
[code]uvcvideo nodrop=1 timeout=5000[/code]

.

 

Accessing raspberry pi by name rather than by IP address

I’m using a virgin media superhub that does DHCP, but doesn’t have any kind of DNS stuff in it.  So I can ssh to my pi using it’s IP address, which is inconvenient because it makes me go and look the address up in the router.  For my application (the alarm clock), both devices (the pi and the kobo) need to be able to find each other, or at least the kobo needs to be able to find the pi to register itself.

I’m guessing there’s smarter ways of doing this, but until I am schooled, I’m working on these lines:

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=34620

http://cymplecy.wordpress.com/2012/08/09/auto-install-a-simple-samba-setup/

So the pi is samba-able now.  I guess samba uses netbios, and that’s the enabler for hostname resolution.

So now I can hit raspberrypi from my windows machine.  However, I suspect, I also need to netbiosify the kobo, and I guess that won’t be as easy.

Put Pronterface on pi.

Get VNC working: http://gettingstartedwithraspberrypi.tumblr.com/post/24142374137/setting-up-a-vnc-server

Install pronterface: http://entropyprojects.blogspot.co.uk/2012/07/reprap-printing-from-raspberry-pi.html

Instead of copying the files from github manually, install GIT with sudo apt-get install git then do git clone https://github.com/kliment/Printrun.git to get the files.  Skills.

 

Cheating on Windows 8

I really like Windows 8. I think it looks neat, and works well. And while the fullscreen/windowed duality often seems slightly embarrassing (control panel etc), I applaud Microsoft for being bold. And I love whizzing through the start page with my touchscreen laptop.

Trouble is, I’ve just realised that the start page is superfluous, and other than that, it’s entirely the same as Windows 7.

I missed jump lists from Windows 7 – these are the things in the start menu, where your applications have an arrow next to them, and that arrow expands to show recently used documents (for that application), as well as a particular pinned docs. I think these are really useful for documents that aren’t frequently used enough that they would stay top of my main “recent documents”, and because of not being frequently used, I can’t remember where they are, or which version I used last. An example is the designs for my Up To Much jewellery boxes. I don’t often print off a batch, but when I do I have to go into the main ring box folder and try and wade through the dozens of versions to remember which exact variation on the filename I used last. Not difficult, perhaps. But it’s easier to just choose it from a list without even opening the application.  Jump lists are a feature I didn’t even realise I wanted.

So anyway, to get jump lists on Windows 8, it is necessary to pin the application to the taskbar and then it pops up on a right-click. But I prefer to keep a pruned taskbar, particularly since I am now more used to using windows-key->start typing to launch apps and don’t need icons floating around everywhere. I really expected jump lists to be present on the start page, so a application tile would spawn some little tiles with it in.

So rambling on, I put StartIsBack on my machine, and instantly forgot I was even using Windows 8. It boots to the desktop, and gives me my jump lists. The start menu is a bit untidy, and not as beautiful as the start page. I haven’t even seen the start page for the last week. Which begs the question – why did I upgrade to Windows 8? And I don’t know either.

Kobo mini serial port

I’m building an alarm clock that will use a kobo e-ink reader as it’s interface and display, so I’ve been trying to figure out how to interface to it.  I got a kobo mini just after christmas for £50.  It’s a linux box, and I’m actually really impressed by the hackability of it.  It’s very open, easy to get into it (even for a noob like me), and has got busybox and python on it.

Most of the information I needed I’ve got from Mobileread’s Kobo Touch hacking wiki which gives a good guide as to how to get root access.

Prompted by soapy frog’s reports I also cracked up the mini:

Kobo mini mystery optical components

and soldered in some pin headers, then wired in a 3.3v TTL Serial-to-USB adapter board (with an FTDI chip on it), and was delighted to find that I could then PuTTY to that virtual com port (115200 8 N 1) and get root terminal access.

USB to serial adapter being used to connect to the linux console on my kobo mini.