Home » Articles posted by HSBallina

Author Archives: HSBallina

Moving

pierOn Error Resume Next has moved to its new home at blog.badpixel.se. Please feel free to join us there 🙂

3D printing – but not hasslefree

It’s been awhile since I finished the Prusa i3 printer and ever since I’ve been struggling with getting consistent prints 😦 Small prints usually works out well, but when it comes to larger parts, for instance replacement parts for the printer it doesn’t deliver.

MEndel Prusa i3

Last night I tried printing new X axis ends. The idler came out ok, at least sort of, but the motor end fails on the first layer. The list of issues is long:

  • slight warp
  • extracted filament lines don’t connect
  • drop effect on some layers
  • tight corners becomes rounded
  • overhangs fall apart
  • the nozzle hits previous layer when bridging

This is the result of the print from yesterday.

Printed with Repetier and slices with Slic3r. 0.5 mm nozzle, 0.3 mm layer height. 3.0 mm PLA, extruder temp: 185°C, bed temp: 60°C (first layer: 190°C/65°C). I’ve uploaded the gcode to Dropbox if you’d like to take a look.

Got a lot of questions right now…

Prusa i3 pt 2 – the plastics

The first parts I ordered were the plastics. I found a very nice eBay seller; reprappt, who was kind enough as to answer all of my newbie questions even if those not relating to the parts he was selling.

The full list of plastic parts needed for the i3 can be found on the RepRap wiki. Still being a bit confused over the complete material list I compared the parts I received with the list on the wiki. Still confused but it’s falling into place as the build is progressing. I’m the instructions from reprapuniverse.com. Although my setup differs somewhat the instructions are easy to follow and adapt to my build.

Prusa i3 plastic parts

Prusa i3 plastic parts

Warping

A few of the pieces have a slight warp and some need clean up of holes and edges but all in all I’m happy with them.

Warping is a common problem with certain thermoplastics. One of them being ABS which is commonly used with 3D printers. When the printing material cools it shrinks and if the material cools too quickly it leads to warping which in turn creates internal stress or tensions within the printed piece. The most common visible result of warping is corners lifting off the build surface.

In order to battle warping and thus creating better build quality a heated bed can be used for slowing down the cooling of the printed piece.

Warping of printed parts

Warping of printed parts

Warping can be not only ugly but also disastrous for precision parts. In my case it’s the X end idler and motor mount. The warp is obvious but the parts will work fine until I can print out replacements.

Cleaning up

Most of the parts need clean up. Usually the printing material closest to the heat bed tends to bleed some. Use a fine file or sandpaper and be careful, especially with parts like the extruder gears.

Close up of the extruder wheel

Close up of the extruder gears

Also some of the holes will most likely need to be widened. Depending on the size and amount of widening needed either use a round file or a drill. Be extra careful if using a drill. The parts can easily crack if the drill bit gets stuck or angled.

Widening the X end idler with an 8 mm drill.

Widening the X end idler with an 8 mm drill

My parts

These are all the plastic parts I have for my build.

This is the second post in the Mendel Prusa i3 printer build log. You can find all posts in the series here.

Building a Les Paul

The Les Paul has been my fave axe for as long as I can remember. Not seeing any falling into my price range anytime soon I’ve been set for a long time on building one.

I do find my way through a workshop but I’m by no means a luthier (yeah, I had to look that up) so I thought I’d pick up a kit with all the critical steps already done. Also since this will be first attempt on “building” a guitar I didn’t want to spend too much cash.

Les Paul kitI finally settled for a 59 model Les paul style flamed top kit off eBay. It’s a set-neck construction, has a basswood body with a flamed maple top and a hard maple neck with a rosewood fingerboard (628 mm/24.75″, 22 frets). Mechanics, pick-ups etc I’ll have to get to later on.

First thing I started thinking about was the paint work of course. Crazy or classic? Crazy will look – just crazy. Classic on the other hand will look awesome, as long as I manage to pull it off.

Seeing I have the 3D printer to work on during summer it will be some time before I come back to this project, but I was too stoked as for not sharing this 😀

Yes, I’m a complete newb and I will make mistakes. But most of all I will appreciate every little bit of advice I can get on the way.

Hooked on 3D

I’ve been browsing around, drooling for a 3D printer for quite some time now but not really having had the budget for one combined with the print quality (or lack thereof) of earlier home/DIY 3D printers I haven’t gotten around getting one. Until now, that is.

After a lot of browsing the Intertubes for information I settled for a Mendel Prusa i3 printer. I3 stands for iteration 3 and it’s the latest design by RepRap core developer Prusajr (Jozef Prusa). It incorporates lessons learned from the earlier two models combined with those of other modern RepRap designs.

Medel Prusa i3 single frame (photo by Bitfluser @ reprap.org/wiki)

Medel Prusa i3 single frame model (photo by Bitflusher @ reprap.org/wiki)

Apart form the single frame model there is also a box style frame. While the single frame model requires CNC or laser cutting for milling the pieces the box style frame is designed for easy manufacturing at home from plywood or MDF.

I decided early on that I wanted to get either a kit or buy parts and assemble the unit myself. Partly because shipping would be a pain in the a** and partly because I would probably get hit by additional costs for customs and taxes.

Sourcing the parts from different suppliers proved to be somewhat difficult. Not having a complete shopping list I opted for a few sets of parts; frame kit, plastics and electronics being the main three. In addition I will need a hot end and probably some other bits and pieces on the way.

This is the first in a series of posts about assembling a Mendel Prusa i3 printer.

irisRemote 1.0

Remote control for a Panasonic HMC-41 video camera.

This was a commission project for a friend. I hadn’t been playing with electronics for quite a while before taking on this project. Even had to get a new soldering iron since my old one just didn’t want to fire up. And the multi meter also had seen better days – constantly off by 200 ohms (though accurate enough for the build).

The design is based on an HMC-150 DIY remote controller build by Chris Woodhouse. I didn’t do any major changes except for the cable. Chris originally used an Ethernet cable which he soldered permanently to his controller. I opted for a detachable VGA cable instead.

The major thing I learned from the process was plan ahead. I had to redo the soldering a couple of times due to bad planning. Also make sure your components works visually the way you want. In my case the knobs didn’t cover the nuts of the pots – not looking as good as I planned.

Another thing I probably would have done differently was the control layout. I followed Chris’ vertical layout with alternating positions of switches and knobs. I retrospect the controller would be more ergonomical with a horizontal layout with knobs on top and switches below.

Goodie boxSlaughtered VGA cableCable crimped and sleevedCamera connectorsTesting button layoutCutting holes
Pots and switches in placeCable connectorTesting button orientation and label layoutPot knobsKnobs in placeInside view
Label test printsWrong!Front viewSoldering 101Soldering 101 - againSoldering 101 - yet again
Inside doneirisRemote 1.0irisRemote 1.0

irisRemote 1.0, a set on Flickr.

Gunnar Ulvaeus’ Scrapbook

If you’re visiting Stockholm I recommend a visit to the newly opened Abba The Museum situated at Djurgården.

I had the pleasure to work on one of the apps for the exhibition; Gunnar Ulvaeus’ Scrapbook. Gunnar is Björn’s father and the app is a digitized version of some of the newspaper and magazine clips he kept during the seventies.

Gunnar Ulvaeus' Scrapbook running on Surface RT.

The app runs on Surface RT tablets at the exhibition. As with most projects we were on a tight schedule and the first version only scratches the surface (no pun intended :P) of the possibilities of Windows Store Apps.

After the initial release we’ve gotten some feedback and are now working on some changes  to improve the app. For instance adding a flip view to make it possible to flip pages by swiping. Once we’re done I’ll get back with some examples on some of the design choices we did.

Meanwhile, get over to the museum and enjoy a piece of music history 😀

Arduino and Nokia 5110 Display

It’s been way too long since I posted something here. Mostly due to a hefty workload and whatever spare time I’ve had has effectively been eaten by other projects. Today finally I got to sit down playing with the Arduino and a Nokia 5110 display I picked up from eBay.

The libraries needed as well as a tutorial for interacting with the display can be found over at Adafruit. Note that if you don’t use Adafruits version of the display the pin-out might differ.

This is the code for the example above:


#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// SCLK, DIN, D_C, CS, RST
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);

#define _W 30
#define _SIZE 4
#define _BASEX 85
#define _BASEY 5
#define _NUMOFCHARS 14
#define _SPEED 2

void setup(){
 Serial.begin(9600);
 display.begin();
 display.clearDisplay();
 display.setContrast(10);
 display.display();
}

void loop(){
 display.clearDisplay();
 display.display();
 delay(500);

 for (int i = _BASEX; i > -width(_SIZE) * _NUMOFCHARS - width(_SIZE); i = i - _SPEED){
 display.clearDisplay();
 writeAt(i);
 display.display();
 delay(10);
 }
}

void writeChar(int ch, int sz, int x, int y){
 display.drawChar(x, y, ch, 1, 0, sz);
}

int width(int sz){
 return sz * 6;
}

void writeAt(int pos){
 int sz = _SIZE;
 int y = _BASEY;

 writeChar('A', sz, 0 * width(sz) + pos, y);
 writeChar('R', sz, 1 * width(sz) + pos, y);
 writeChar('K', sz, 2 * width(sz) + pos, y);
 writeChar('A', sz, 3 * width(sz) + pos, y);
 writeChar('D', sz, 4 * width(sz) + pos, y);
 writeChar('T', sz, 5 * width(sz) + pos, y);
 writeChar('O', sz, 6 * width(sz) + pos, y);
 writeChar('R', sz, 7 * width(sz) + pos, y);
 writeChar('G', sz, 8 * width(sz) + pos, y);
 writeChar('E', sz, 9 * width(sz) + pos, y);
 writeChar('T', sz, 10 * width(sz) + pos, y);
 writeChar('.', sz, 11 * width(sz) + pos, y);
 writeChar('S', sz, 12 * width(sz) + pos, y);
 writeChar('E', sz, 13 * width(sz) + pos, y);
}

The important thing is not to forget calling display.display() for sending the commands to the display.

Have fun!

Rotation and Snap in Windows Store apps

One of the many things you need to consider when submitting your app to the Windows Store is the ability to handle rotation and snap view. Now, as far as I know it’s not mandatory because in the first release of DeTV I lacked both but it was approved anyway. Also some apps are not even meant for running in snap view. Nonetheless if you can you should always try to support both snap view and rotation. In this demo I’ll guide you through the basics you need to know for implementing both orientation and snap in your app. But first a little background on layouts and resolutions: according to the Windows Store certification requirements your app must support  a minimum resolution of 1024 x 768. Also your app must remain functional when it is snapped and unsnapped. From this you can conclude that at a minimum your app has to support the following three visual states:

  • 1024 x 768 (the minimum resolution and while in filled state),
  • 320 x 768 (snap view) and
  • the default resolution you plan for your app (generally 1366 x 768).

Of course it’s not appropriate to just shrink or stretch the UI of your app in order to support the snapped and filled views. Luckily there’s a few tricks you can use out of the box for rearranging the display when snapping and unsnapping your app – kind of like responsive web sites change looks when viewed on a smartphone or pad. By default all Windows Store App templates support rotation but for some apps that might not be the preferred state. For instance for a game it maybe only makes sense to run in landscape mode. If you open the Package.appxmanifest file and check the Application UItab you can choose which rotations your app should support.

Supported rotations in the Package.appxmanifest

Supported rotations in the Package.appxmanifest

Getting started

Start by creating a new Blank Windows Store App. Unless your computer supports rotation run your blank app in the simulator. If you rotate it you’ll see that the app supports all rotations by default. You can play with the supported rotations in the Package.appxmanifest and view the results in the simulator as well. Now open the MainPage.xaml file and add a TextBlock. We’ll use it later for feedback on the rotation and snapped state.

<Page
  x:Class="RotationAndSnapDemo.SimpleOrientationSensorPage"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="using:RotationDemo"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d">

  <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <TextBlock
      x:Name="MyRotation"
      HorizontalAlignment="Left"
      TextWrapping="Wrap"
      Text="No Rotation Info"
      VerticalAlignment="Top"
      Margin="10,10,0,0"
      FontSize="24"/>
  </Grid>
</Page>

That’s it for the MainPage.xaml for the moment. Now open up the MainPage.xaml.cs file and start by adding a using statement: using Windows.Devices.Sensors;. Next we need an instance of the SimpleOrientationSensor.

using Windows.Devices.Sensors;
using Windows.UI.Popups;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace RotationDemo
{
  public sealed partial class MainPage : Page
  {
    private SimpleOrientationSensor orientationSensor;

    public MainPage()
    {
      orientationSensor = SimpleOrientationSensor.GetDefault();
      this.InitializeComponent();
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
      if (orientationSensor == null)
      {
        var messageDialog = new MessageDialog("No orientation sensor was found.");
        messageDialog.ShowAsync();
        return;

        MyRotation.Text = orientationSensor.GetCurrentOrientation().ToString();
      }
    }
  }
}

This is the code so far. Instantiate the SimpleOrientationSensor in the constructor and do a quick check in the OnNavigatedTo event if we have one available or not. Note: the messageDialog.ShowAsync(); will give you a warning because it’s not awaited but you can ignore that.

No orientation sensor found in the simulator

Even if you run the app in the simulator you probably don’t get the result you’d expect

This is because the simulator actually simulates the computer you’re working on. So, if it’s like mine, a 10+ kg workstation, odds are that you’ll be greeted with the above message. This also means we’ll need to come up with some other solution in order to test the rotation. Luckily there’s a simple solution to the problem. That is if you have a second device with rotation sensors available. In short you’ll need to install the Remote Tools for Visual Studio 2012 on the device. You can get it from the Visual Studio download page and I have a tutorial on remote debugging that explains how to install and set it up. Now if you run your app on the remote machine your textblock will tell you the current rotation of your device but it won’t reflect any rotation changes. For that we’ll have to add an event handler to our code to catch the changes.

using System;
using Windows.Devices.Sensors;
using Windows.UI.Popups;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace RotationDemo
{
  public sealed partial class MainPage : Page
  {
    private SimpleOrientationSensor orientationSensor;

    public MainPage()
    {
      orientationSensor = SimpleOrientationSensor.GetDefault();
      this.InitializeComponent();
    }

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
      if (orientationSensor == null)
      {
        var messageDialog = new MessageDialog("No orientation sensor was found.");
        messageDialog.ShowAsync();
        return;
      }

      orientationSensor.OrientationChanged += OrientationChanged;
      ShowOrientation(orientationSensor.GetCurrentOrientation());
    }

    protected override void OnNavigatedFrom(NavigationEventArgs e)
    {
      orientationSensor.OrientationChanged -= OrientationChanged;
      base.OnNavigatedFrom(e);
    }

    async void OrientationChanged(SimpleOrientationSensor sender,
      SimpleOrientationSensorOrientationChangedEventArgs args)
    {
      await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
        () => { ShowOrientation(args.Orientation); });
    }

    void ShowOrientation(SimpleOrientation simpleOrientation)
    {
      string orientation;

      switch (simpleOrientation)
      {
        case SimpleOrientation.Facedown:
          orientation = "facing down";
          break;
        case SimpleOrientation.Faceup:
          orientation = "facing up";
          break;
        case SimpleOrientation.NotRotated:
          orientation = "landscape";
          break;
        case SimpleOrientation.Rotated180DegreesCounterclockwise:
          orientation = "landscape-flipped";
          break;
        case SimpleOrientation.Rotated270DegreesCounterclockwise:
          orientation = "portrait";
          break;
        case SimpleOrientation.Rotated90DegreesCounterclockwise:
          orientation = "portrait-flipped";
          break;
        default:
          orientation = "unknown";
          break;
      }

      MyRotation.Text = "Current orientation: " + orientation;
    }
  }
}

The code above is what we need for our project for the moment. Press F5 to start it on your remote machine to see how it behaves. You can see that in addition to the landscape and portrait orientations there’s also facing up and facing down. These will trigger if you lay the device down or flip it upside-down. This way you can take actions in your code to rearrange the content for different orientations. You can also choose which orientations you want to act on. If you disable any of the orientations in the Package.appxmanifest file you’ll discover that the event is still fired for your disabled orientations even if the screen doesn’t flip that way.

About the code; first add using statements for the Windows.Devices.Sensors and Windows.UI.Popups namespaces. The Popups namespace is of course only for the message box and is not really needed for detecting orientation. Then add a SimpleOrientationSensor and instantiate it in the constructor method. If no rotation sensor is present this will return null.

In the OnNavigatedTo event handler check that a sensor is present and if not pop up a message and return. Otherwise add an event handler that will subscribe to the OrientationChanged event of the SimpleOrientationSensor. Lastly call the method for displaying the current rotation.

When leaving the page unsubscribe from the OrientationChanged event in the OnNavigatedFrom event handler. It’s no longer necessary.

OrientationChanged is the event handler that is assigned to subscribe to orientation changes. Note the async keyword in the method declaration. It’s used for making the method awaitable. Inside the event handler make a call to the ShowOrientation method for displaying the current rotation. Since the ShowOrientation method doesn’t have any awaitable code use the Dispatcher.RunAsync method for making the call asynchronously.

In the ShowOrientation method add a switch block for determining the current rotation and type in the messages that will be displayed for each rotation. Using this method the appearance of the app could now be revamped to fit the current orientation. But there’s an easier way.

The VisualStateManager

While acting on orientation changes in code is a possible way to re order the appearance of an app it might not be the most straightforward path. This is where VisualStateManager comes in.

In the project add a new Basic Page and call it RotationPage.xaml. As you can see in the description for the Basic Page it supports layout awareness. This is the magic key to using visual states in your app. The Basic Page is a LayoutAwarePage and provides in itself the structure to orient itself and snap properly. In addition to the VisualStateManager the Basic Page also adds a back button, title and a grid to your new page.

Add Basic Page

When you click on add you will most likely be greeted with a message telling you that the Basic Page is dependent on files missing from you project. Click Yes to add these files automatically.

Missing Dependencies

The new files are added to the Common folder in your project.

Common Files

Rebuild your project once for resolving the missing dependencies. Now you should be able to see your new page in the Design View in Visual Studio. Now take a look at the XAML. Look for the VisualStateManager.VisualStateGroups block. You’ll see a VisualStateGroup which in turn contains the visual states:

  • FullScreenLandscape
  • Filled
  • FullScreenPortrait
  • Snapped

Using the Storyboard you can apply different appearance for the different visual states. First you need to set a name for the root grid of the page so that you can access it later from the XAML. Also add a textbox on the page (I called it MyViewState).

<Grid Name="rootGrid" Style="{StaticResource LayoutRootStyle}">
...
<TextBlock x:Name="MyViewState" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="24" Text="No state yet"/>

Now find the block of visual states in the XAML. By adding Storyboard and animation tags to the visual states (the snapped and portrait states already have them) for manipulating the values of objects on your page.

<VisualStateGroup x:Name="ApplicationViewStates">
  <VisualState x:Name="FullScreenLandscape">
    <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MyViewState" Storyboard.TargetProperty="Text">
        <DiscreteObjectKeyFrame KeyTime="0" Value="FullScreenLandscape"/>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetName="rootGrid" Storyboard.TargetProperty="Background">
        <DiscreteObjectKeyFrame KeyTime="0" Value="#FFFF0000"></DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
    </Storyboard>
  </VisualState>
...

You can add animations to all four visual states and set different background colors if you like. If you run your app in the Simulator you will see that it actually supports the visual states even though it doesn’t support the SimpleRotationSensor object. Simple page layouts like the Basic Page really don’t need much rearranging of the content but the more complex your content gets the more you’ll have to pay attention to arranging it nicely for different visual states.

Summary

This should have given you an introduction on how to manage different visual states in your Windows Store App. For more complex layouts you will most likely have to rearrange grids or even create different layouts for the different states. The most important point you need to remember from this tutorial is that your app must support the snapped state.

Code

Download project files

Remote Debugging in Visual Studio 2012 on Windows 8

A very handy feature of Visual Studio 2012 is debugging on a remote machine.

Especially if you as I develop on a plain old workstation with few or no sensors available. I came across this issue when playing with the orientation sensors. In this tutorial I will walk you through the steps you need to set up remote debugging.

Remote Tools for Visual Studio 2012

The Remote Tools allow remote debugging, remote testing and performance profiling on computers that don’t have Visual Studio installed.

You’ll find them on the Visual Studio 2012 download page: http://www.microsoft.com/visualstudio/eng/downloads. Scroll down to Additional Software to find the Remote Tools for Visual Studio 2012. Choose language and version (x86/x64/ARM) and hit download from the computer you want to use as remote machine. Once you have downloaded the package the installation procedure is straight forward.

Remote Tools for Visual Studio 2012 installation

Configuring the Remote Debugging Monitor

After the installation finishes start the Remote Debugger (you’ll need administrative privileges for the first run). This will bring up the configuration window.

You will also be taken through the procedure for acquiring a Developer Licence exactly like when you created your first Windows Store App project.

Remote Debugger first run

If the Windows Web Services API is not installed hit the Install button. Now choose at least one type of network for the remote debugger to communicate on.

Click on Configure remote debugging to start the Remote Debugging Monitor. You should see a message that the Msvsmon is running and awaiting connections.

Visual Studio Remote Debugging Monitor

From the Tools menu choose Options for changing port number, authentication method and maximum idle timeout for the monitor. By default the authentication mode is set to Windows Authentication and the idle timeout is set to 0 (= no timeout).

Remote Debugging Monitor Options

When using Windows Authentication mode you can set who can connect to the remote debugger from the Permissions dialog.

Remote Debugging Monitor Permissions Dialog

Setting up Visual Studio 2012

Now go back to your development machine and open up the Properties page for your project and select the Debug tab. In the Debug Start Options section select Remote Machine as target device and click Find to browse for your device. You can also select whether to use authentication or not and if you want to redeploy your app each time you start the debugger. This will allow you to run your app from a clean install each time, but you will loose any app state by doing so.

Remote Debugger Start Options

Select your remote device from the Remote Debugger Connections dialog.

Remote Debugger Connections

Taking it for a spin

Now you’re all set for remote debugging on another device. You’ll be able to configure break points and step through your code as if it was running on your local machine.

Running Remote

If you take a peek at the Remote Debugging Monitor on your device you’ll see the connection from your development computer.

Visual Studio Remote Debugging Monitor

Running the Remote Debugger as a service

Normally the Remote Debugger runs as a Windows application but it’s possible to configure it to run a a service instead (as usual you’ll need administrative privileges to set this up). Start the Remote Debugger Configuration Wizard and follow the screens to set it up. This can be advantageous for instance if you want to be able to debug server applications such as an ASP.NET web site without first having to log in to the remote computer.

First select which account will be used to run the service. The account will need “Log on as a service” privileges and network access rights. It’s also advisable to add this account to the Administrators group.

Visual Studio Remote Debugger Configuration Wizard Page 2

Then configure which networks the service will allow connections from.

Visual Studio Remote Debugger Configuration Wizard Page 3

Wrapping it up

I hope you’ve enjoyed this short tutorial on remote debugging in Visual Studio 2012. If you liked it or found it helpful – share it with your friends. If something seemed quirky – let me know! You can find some more information about the Visual Studio 2012 Remote Debugger at MSDN.

%d bloggers like this: