Tuesday, June 13, 2017

Failed Print and Recovery

I was able to turn a printer fail into a success. I started printing a toilet for my daughter's 18" American Girl doll. I scaled up this model (https://www.thingiverse.com/thing:1866716) by 304% to get the appropriate size. Final height is ~180mm. I rotated and sliced the model into a tank and bowl parts. The bowl was going to require supports for a couple areas, but that was no problem.  I set it up to print both parts at 0.20 layer height and let it rock. To my horror the next morning I came in and saw this:

I thought 15 hours of printing was lost. I searched the forums for what this error meant, and it turns out that the thermistor that reports the bed temperature had come loose.  To protect itself and our home, the printer aborts whatever it's doing when this occurs.  I took the bed off, fixed the loose bed thermistor, reassembled everything, and recalibrated the bed. I'm glad I took the photo of the failure screen because it told me it was printing at 61mm layer height when it aborted. Since it aborted the print and didn't make spaghetti of everything I went back into Slic3r and cut the model again at 61mm. I then decided to print the remaining pieces separately:

Once finished, I had 4 parts instead of 2. Oh well! I glued the parts together with CA, and started printing the lid.

The lid is supposed to stick into a receiving hole in the bowl, but there's no way for it to flip up or down. I made a quick pair of supports for hinges in TinkerCad, cut off the tab from the lid and made a hinge pin from some T-pins. After adjusting the fit, I glued the hinges to the bowl with CA.

My daughter is super excited to have a potty for her doll. It only took a couple bucks in plastic and a few days' work. Yay daddy!

New Hobby - 3D Printing

I've been wanting a 3D printer for quite a while, but we could never really justify the cost.  A couple of co-workers were raving about the Prusa i3 Mk2 (http://www.prusa3d.com/) and all the awards it had just won.  I had looked around at others as well, but the general consensus was this was the real deal.  The only thing I had to do now was convince my wife.

She asked the typical questions: "What are you going to do with it?" "It's so expensive!" "You'll just print little doo-dads."  "That's an expensive toy!" What guy's toy isn't expensive, huh?  It wasn't until she saw that it could print doll furniture that she was hooked as well.

My co-workers and I all ordered our printers within a month or so, but with a 2 month backlog at Prusa the wait was killer.  Finally, my kit arrived!  I spent the first evening into the wee hours assembling the main bed.  Wow!  This thing is like IKEA on steroids!  The next day I spent all morning assembling the rest and started the calibration.  All told, assembly was some 8-9 hours!

I've been steadily printing stuff since then: a couple doo-dads, Pokemon characters and stuff for my RC planes.

Wednesday, June 29, 2016

Some coming soon items

I realize that I haven't posted to this blog in a very long time.  I feel like such a slacker.  Since the last few posts I've added a new hobby - flying RC airplane and helicopters.  I'll have to dedicate a few posts to that.  I've also done some work on the home computer setup, so I need to update that as well.  I'm hoping I won't neglect this site as much going forward.

Thursday, January 30, 2014

ESXi Upgrade on Home Server

My home computer setup was starting to show its age.  My previous setup was a pair of Core2Duo class systems each with 4GB of DDR2 RAM.  One functioned as a server running ESXi 5, and the other as a gaming rig with a pretty slick ATI Radeon 6850.  The gaming rig did just fine for most modern games with that video card, but the ESXi server was over-taxed when trying to run anything more than a couple small Linux VMs.

I read about folks having success with "whitebox" ESXi servers at thehomeserverblog.com, and figured I'd follow suit.  I purchased a Gigabyte 970A-UD3P motherboard, AMD FX8350 CPU, and 32 GB of Gskill DDR3 RAM from Newegg.  In retrospect I probably should have forked over the extra dough for the 990 chipset, but C'est la vie.

I got everything hooked up and my VMs migrated over, when I noticed that my CPU and memory stats were nearly idle.  Even after installing a couple of Windows 2k8 R2 VMs that had struggled before.  I looked over thehomeserverblog.com article again, and he speaks about using the AMD IOMMU passthrough to give the physical video card over to a VM for desktop-like performance.  I thought, "with all this overhead, could I virtualize my gaming rig?"

It turns out, it's not as easy as it looks.  IOMMU (and the matching Intel feature VT-d) are not widely supported, nor well documented.  I figured it should be as easy as enabling the feature in the BIOS and patching the device through.  Ha ha...nope.

While configuring IOMMU passthrough in ESXi is no challenge in and of itself, getting the VM to recognize and use it is something else.

I started out simply enough with a spare video card (a Nvidia Geforce 210) card and passed it through.  The VM saw it in the hardware list, and I could install the drivers for it, but it was never able to actually use it.  It's been a few days now, so I don't remember the exact error code, but try as I might it never worked.  I decided that since the thehomeserverblog.com had used ESXi 5.0 instead of the latest 5.5, that I might start there.  I also read numerous places about broken IOMMU support in ESXi 5.1.

I reverted my ESXi box to 5.0 and installed a fresh Windows 7 VM with 2 GB RAM.  This RAM value is important as you shall see later.  I also moved the ATI Radeon 6850 from the gaming rig to the server to give this thing the best possible shot.  With my fresh install done and VMware Tools installed, it could indeed see the physical card.  Now could it use it?  After installing the latest ATI drivers, YES! It could!

Ok, onto the next steps.  2 GB of RAM isn't going to get me very far, so I upped it to 4 GB.  Uh oh! VMware spits out some error about needing a parameter "pciHole.start=XXXX" inserted into the .vmx file or it can't start the VM.  As it turns out, this number they give you is freaking wrong!  I searched around and around the interwebs for someone doing the same thing as me and found this VMware community post:  communities.vmware.com.  If you read down the forum a while, it mentions that to get it to work correctly with >= 4GB RAM you actually need 2 parameters in your .vmx file:

  • pciHole.start=1200
  • pciHole.end=2200
I threw those in the .vmx file and voila!  It works!  I rebooted it a few times and finally settled on 4 CPU cores and 16 GB of RAM for said Windows box.  I quickly installed a copy of Battlefield 3 and gave it a whirl.  (A side node, I also passed through a 4-port USB 2 PCI card in addition to the graphics so the keyboard, mouse, etc. are all "native" to the VM).  The game played just fine with no appreciable lag.  It also helps that the Windows .vmdk disk files reside on SSD storage.  :-)

Now that I had a functional example, how to get my already installed games into the VM?  Enter VMware Converter.  This is a free download and can be used to migrate a live machine into a VMware environment.  I shutdown my clean VM and ran the converter on my live gaming rig.  Once it was in ESX, I removed the PCI passthrough from the clean VM, attached it to the migrated one, added the pciHole parameters, and booted it up.  Sweet!  It works!  Since the migrated VM already had the drivers installed, the card was recognized immediately.

So far I've played a bit of Battlefield 3, Bulletstorm, and checked a few other games with no problems whatsoever.  I'm pleased I'll be able to not only make everything faster, but reduce the number of boxes under my desk as well.

Thursday, October 10, 2013

Whereabouts Software, Part 4 - Arduino Code

The Arduino code is responsible for connecting to the Wifi network, getting the latest data from the server (with the help of the fetch_current.php script), and moving the servos to the correct location.

Arduino sketch:  Whereabouts.ino

Before you download and install the sketch to your Arduino, you will need to update some of the code for your specific environment:

/* Network Information */
char ssid[] = "your_SSID";      //  your network SSID (name) 
char pass[] = "your_WPA_pass";  // your network password

// WiFi/Ethernet vars
IPAddress server(10,10,10,10);

This is all pretty self-explanatory. Add the Wifi SSID, WPA password, and server IP address to the sketch.

// Servo control vars
// The number of people (or hands) that I have on the clock
#define NUM_PEOPLE 5
// Names of the people we track (must match what is returned from the server
String peopleNames[NUM_PEOPLE] = {String("DAD"), String("MOM"), String("CHILD1"), String("CHILD2"), String("CHILD3")};
// The locations that we will fill from the server
String peopleLocations[NUM_PEOPLE] = {String(""), String(""), String(""), String(""), String("")};

This requires coordinating the sketch with the database user table. The strings "DAD", "MOM", etc. are usernames in the user table. These will be matched in the fetch_current.php script. If you have more or fewer users, they will need to be adjusted here.

// Make the HTTP request
client.println("GET /server_path/fetch_current.php HTTP/1.0");

Update the 'server_path' with the URL path to the fetch_current.php script on the server.

There are a few other tuning parameters in the sketch to control the servo movement, but these should get you started.


Whereabouts Software, Part 3 - Fetch Current

The PHP script that is called by the Arduino looks into the database and grabs the most recent locations for each user.  It then returns the data in an XML output that the Arduino can parse.

Here's the source code:  fetch_current.php

You will need to update the following with your own server data:

// Database connection information
$db_hostname = "localhost";
$db_username = "db_username";
$db_password = "db_password";
$db_database = "whereabouts";

When executed with `php fetch_current.php` you should receive output similar to this:

<?xml version="1.0" encoding="ISO-8859-1"?>

The clock will use the user names and locations to move the hands to the appropriate places.

Whereabouts Software, Part 2 - Fetch Locations

The server side collection and processing is done with a PHP script on a LAMP (Linux, Apache, MySQL, PHP) server and is executed by cron.  I set mine to query the phone data every 15 minutes, and it didn't seem to kill my battery any more than normal.  Increase or decrease the timing as you see fit.

The script is dependent on the work of Tyler Hall and his sosumi PHP library to get the location data from the Find my iPhone service.  You will need to download the class from his website.

The script included below will query the phone data for users in the database whose 'location_source' is 'GPS'.  You will need to modify the following in the script to get the location grabbing code to work:

// Enter your iCloud username and password
$ssm = new Sosumi('your_apple_id', 'your_password');

// Database connection information
$db_hostname = "your_database_host";
$db_username = "db_username";
$db_password = "db_password";
$db_database = "whereabouts";

Once this is completed, run the script with `php fetch_locations.php` and observe the output.  You should see something similar to this:

Timestamp: 1381456148
Date Time: 2013-10-10 20:49:08

 LAST DATA: USER1                      | PHONE DATA: USER1                     
 Timestamp: 1381454227                 |  Timestamp: 1381455996                
  DateTime: 2013-10-10 20:17:07        |   DateTime: 2013-10-10 20:46:36       
  Latitude: xx.xxxxxxxx                |   Latitude: xx.xxxxxxxxx           
 Longitude: yy.yyyyyyyy                |  Longitude: yy.yyyyyyyyyyy          
  Accuracy: zz                         |   Accuracy: zzz                       
  Location: home                       |   Location: home                      
            NEW PHONE DATA!            | No change.  Still at: home            

 LAST DATA: USER2                      | PHONE DATA: USER2                   
 Timestamp: 1381455883                 |  Timestamp: 1381455907                
  DateTime: 2013-10-10 20:44:43        |   DateTime: 2013-10-10 20:45:07       
  Latitude: xx.xxxxxxxxxxx             |   Latitude: xx.xxxxxxxxx           
 Longitude: yy.yyyyyyyyyyy             |  Longitude: yy.yyyyyyyyy          
  Accuracy: yy                         |   Accuracy: yy                        
  Location: home                       |   Location: home                      
            NEW PHONE DATA!            | No change.  Still at: home            

Here's the source code:  fetch_locations.php