Monday, 30 May 2016

Controlling a 3D Printer with the new Raspberry Pi Zero 1.3

Last year I entered the world of 3D printing by purchasing a second hand RepRap Mendel Mono from eBay, with the initial aim of using it to print custom parts for my robots. The 3D printer has an Arduino based control board that contains the firmware required to drive the motors, heaters, fans and all the other time critical stuff that allows 3D printing to work, but with no LCD or any input controls a computer is required to tell this control board what to do.

I started off using a laptop to control the printer and then, once I was a bit more comfortable with how everything worked, I switched over to a Raspberry Pi B+, connecting to it via VNC. Eventually I started doing longer prints (i.e. the Astro Pi case) and wanted to be able to monitor the printer remotely, so after some research I switched over to using OctoPrint, which allows you to control the 3D printer via a web bowser, and has built in support for recording time lapses of the print itself.

When the Raspberry Pi Zero was originally released I did consider using one to control the printer, but didn't want to lose the camera support. Roll on six months and a new and improved Raspberry Pi Zero model was released, complete with camera connector, so it was time to give it a go.

Software setup

When setting up OctoPrint on the Raspberry Pi B+ I made use of the easily downloadable OctoPi SD card image, which meant it only took a few minutes to get everything up and running. However I wasn't sure it would support the latest board revision so instead followed the comprehensive instructions for building and installing OctoPrint, which took a little while on the Raspberry Pi Zero.

With the main OctoPrint software installed I then moved onto setting up mjpg-streamer for performing the video capture. As usual I'd managed to put the camera connector in upside down, despite checking the correct orientation before plugging the cable in, so ended up opening up the case to more easily flip it over.

Test Print

As the Raspberry Pi Zero only has a single USB port, and I had to connect it to the printer itself whilst simultaneously having a network connection, I needed to make use of a USB Hub. Unfortunately the UUGear Zero4U I recently purchased doesn't quite fit the new Raspberry Pi Zero board, so I ended up making use of a slightly less compact setup with an external USB Hub.

With the Raspberry Pi Zero connected to the printer and the camera positioned I started off with a fairly simple test print that only takes 10-15 minutes to complete, just to make sure everything was working as expected. During the print I kept an eye on the CPU load and memory usage of the Raspberry Pi Zero, just to make sure everything was running happily.

A longer print

With the test print out of the way it was time to try something a bit more time consuming, to see if the Raspberry Pi Zero had the staying power to keep on driving the printer. Something I had been meaning to print for a while was a 5 1/4" to 3 1/2" drive bay adaptor. This was something I had originally thought about buying in a shop, but as I looked at the price of it (around £6 to £7) I realised I should be able to print one at home for a fraction of the cost. A bit of hunting around on the internet had come up with a few designs that people had put together, so I selected one and set it off printing.

Total print time turned out to be just under 4 hours, of which I mostly monitored progress by viewing the video feed from my phone. Whilst the video resolution was the same as I use on the B+, the newer 8MP camera did seem to give a sharper image.

I did, of course, notice that the corners of the print had lifted at one end, but as the resulting item was going to end up inside a computer case I wasn't worried enough about it to stop the print and re-try. Besides, that edge is always a pain to get levelled!

With the 4 hours up the print looked good enough, apart from where the corners had lifted of course, and the Raspberry Pi Zero was still running happily (and still is now, several days later). A couple of times the OctoPrint page seemed to stop updating, but a reload got it working again. After removing the print, and detaching the raft that was supposed to help the print stick to the glass, it was time to see how well it worked. Due to the print lifting on one side I did have to slightly extend the screw holes, but my USB3 front panel fitted in nicely and I soon had it mounted in my PC case.


Based on this quick test am I going to switch over to controlling my 3D printer using a Raspberry Pi Zero? Probably, yes.. at least when I manage to get ahold of more than one of the newer boards!

Not because of the price, after all I already have the B+, but more because it will allow me to create a more compact setup.  I'll need to do something about requiring the external USB hub first, either getting a newer Zero4U that's been updated to work with the revision 1.3 board, wiring the Raspberry Pi's serial port directly to the printer, or by connecting up the networking differently e.g. by using the IoT HAT that I backed recently.

But for now I'll be switching back to the B+, as I have other uses for my singular Raspberry Pi Zero 1.3 board!


Sunday, 1 May 2016

Two weeks with the Oculus Rift - Part Two

This is the second half of my ramblings about the Oculus Rift, so if you've not read part one yet you may want to go check it out first before continuing on here.

After having played Lucky's Tale I thought I'd carry on taking things slowly before diving into the other launch title EVE: Valkyrie, just to make sure I was used to the headset before exposing myself to a high speed, high action style game.

So next up was 'Henry', a short animated movie from Oculus Story Studio that places you in Henry's front room, allowing you look all around and watch the story unfold. Henry isn't just an animated movie recorded with a '360' view, but its a proper 3D environment, allowing you to look over, under and behind the various objects in the room and generally gives you a much better impression of being there.

The instructions suggest the best viewing position is sitting down, however in my setup that would leave me sat on the floor in  front of my desk, leaving the sensor partially obscured. In theory if I had a bigger room I could set the sensor up to allow this, but for now I just watched the movie standing up (luckily its not too long!).

This was also the first title where I noticed the 'len flare/god rays' that have previously been mentioned. The movie itself wasn't a problem, but it was really obvious on the opening and ending titles.

There are a couple of other animations in the store, although these are much shorter, with the ones I watched next being INVASION!, Lost and COLOSSE. These follow a similar format where you are fixed in place, looking around as the scene unfolds. In INVASION! you have a clear view to the mountains and, if you look down, a fluffy bunny body. Lost has you in a forest where you can lean your body to look between the trees and has a 'The Iron Giant' kinda vibe to it, something that could possibly be included as a DVD/Blu-ray bonus feature.

COLOSSE is slightly different in that you get transported during the story to a couple of different locations, with the final scene encouraging you to look around in all directions. Whilst these shorts are fun enough to watch once, I'm not sure I'll go back to rewatch them (other than to show off to friends/family) and trying to do a full 1 to 2 hour long movie in this format may be a stretch, but we shall have to wait and see what people come up with on that one.

But are all these movie-like experiences static? Well no, there's the 'The Body VR' which takes you on a journey through the human body, with you sitting in a little pod that takes you from place to place. This generally works quite well, with a narrator describing what you are seeing (Instead of having to try and read text) with the pod moving slowly enough that there's plenty of time to look around and is unlikely to cause any nausea. Apart from, that is, 2 or 3 times when the 'pod' suddenly 'jumps' 90 degrees, which can leave you a little disoriented, especially if you were already looking in that direction.

Other media content that can be found on the Oculus Home store are the 360 pictures and videos. The pictures were fun, able to bounce around the world looking at the various landmarks, a considerable improvement compared to 'drag scrolling' the view in a web browser, or looking at it on a small mobile. I was also able to view a 360 photo I had taken the previous weekend and that looked nice (apart from the bits where it overlaps.. need to practise taking those more!).

The 360 videos were a bit of a disappointment, frequently buffering and when they do start playing they are often so compressed looking that its almost not worth watching them. Reminding me of the days where I would try and find the smallest video files to download over my modem, so it wouldn't take hours to arrive. The best 360 video in the list was the Virgin Media advert! Possibly due to it being streamed from the UK.

I had much better luck watching 360 videos from YouTube using Virtual Desktop, where it would download the entire high quality video before starting to play it back, often a bit of a wait but a much nicer experience overall.

But enough with the media playback... back to the games!

Farlands is a colourful, planet exploration game, where you analysis and photo the alien creatures to learn more about them, with your discoveries allowing you to unlock more items to use, and more areas to explore. Its a fun little diversion that seems to be designed for short, but daily visits, which as there is only so much to do each time works out fine.

Movement is handled by instantly teleporting to your destination, so you move around the area in short jumps. The system allows you to select what direction you're facing after the teleport, which means you don't have to keep turning around to see everything (Which would lead to cable tangle).

There's also a map of each area where your view pulls back, allowing you to see the entire area, in a sort of tilt-shift miniature world kinda way, and you can watch the aliens moving around before teleporting back to the area, or up to your ship.

The final game I played in this two week period was EVE: Valkyrie, I'd left it until last because I wanted to make sure I was comfortable enough in VR before trying anything too hectic, which flying around in a space ship that can go in any direction certainly is!

EVE: Valkyrie is basically dog-fighting in space, two teams battling to win each round. Either in a straight forwards team deathmatch, or trying to capture various points in the map. Whilst you can, in theory, dive straight in, I elected to go through the tutorial and training first to get a feel of the ship, and used to playing this in VR.

Traditionally in flight sims I either look around by using the 8 way hat, or by toggling into a look mode and using the mouse to change the view. With the Rift its much more natural, giving you the freedom to look in any direction without needing to think about what you are doing, what button to press and how many times to press it.

After taking a good look around my ship it was time to actually take control. Moving up and down and side to side was fine, then I tried rolling the ship... Now whilst it didn't make me feel nauseas, my stomach was certainly a little uncomfortable with the manoeuvre as my brain was expecting to feel some sort of movement. I persevered and carried on with the tutorial, performing a few more rolls, trying to get used to it a bit more.

In my younger years I was lucky enough to fly a few light aircraft and I would have to say that this is nothing like that! Its missing the noise, vibration, smell of the engine or any of the g-force that you feel doing similar manoeuvres.. Its a bit closer to gliding, with the lack of engine noise, and if you pretend you're in your favourite sci-fi program that has inertial dampers, null gravity fields or similar then all is good!

Weapon wise the ship I flew has a front facing cannon and a head tracking homing missile. With that you just have to look at an enemy ship, wait for it to lock on, and launch the missiles. Which enables you to fire missiles at one ship, whilst shooting the cannons at another one (In theory anyway!). There's also an ECM (Which really looks like a flak cannon) for stopping enemy missiles, as well as drones that can be deployed.

With the tutorial out of the way it was on to an actual match and once I was out in space and getting involved in the action I stopped noticing the mild discomfort when I rolled the ship, and after a match or two it went away. The matches tend to be quick and hectic, with me looking around in all directions trying to keep track of the enemy craft. I played the first few rounds with the XBox controller, before switching over to a joystick and throttle, finding that easier to use when turning, rolling, launching missiles and firing the cannon all at the same time.

The different levels have various ships/asteroids that you can fly around and through, giving lots of opportunities for sneak attacks, or just running and hiding when your shields are low. Team deathmatch is fairly simple, you're just trying to destroy the enemy ships before they destroy you. The 'capture the flag' style mode has three points around the map that you need to deploy drones nearby to 'capture' them, which you then have to protect, whilst also working to destroy the enemies drones to make it easier to capture the other points.

All in all a fun, fast action packed game, that I will be playing more of if I ever mange to finish writing this post! And as promised in my last posting, here is a short video of myself playing EVE: Valkyrie to give you a better idea of how it works, and how easy it is to look around, following the enemy ships in even the most hectic of moments.

Now if you'll excuse me I have more ships to go hunt down!