15 May 2013

Raspberry Pi - The Time-lapse Dolley Project and Windows compatible SD partitions

About a week ago I sat down and thought about our impending VC visit to see our little Raspberry Pi lab and I started thinking about what we could do as a little example project. I've deliberately kept this as my little secret because I wanted to do something that nobody else here has thought of but what to tackle and could I do it in a week?

I started to think about what visual computer-jiggery (technical term) has most impressed me this year and the answer came from Netflix. Yes I was impressed by the opening credits for the US version of House of Cards. The technique they use is called motion-time-lapse. Time-lapse is where you create an animation from single photo's or stills taken every minute or so then joined together into a film. It looks far more effective with the added motion though. This comes from something called a time-lapse-dolly which is a technical term for slow-moving-thing-that-the-camera-sits-on.

I've recently been playing with 'Motion' on the Pi, which is a great little web-cam application that can also do time-lapse. I did some time-lapse using windows applications a few years back so I already knew how to do that part (as you can see here). I can say that if anything, Motion makes the process even easier as it will chain the stills together for you and output an Mpeg clip.

So my challenges now are two-fold. I would like to output the clip to a windows box so I can add some music. I want this to be from the Schizm tracker (ie produced on the Pi). I doubt the Pi is quite powerful enough to do the video editing - at least not in the timeframe required (tomorrow). I'm not even sure if my old Amiga Pro-tracker days are enough to quickly get me up-to-speed with Schizm tracker but that's for later. First I need a motion-platform and I'd like that to be controlled by the Pi and I also need to be able to get the footage off the Pi for editing.

Luckily I have an 8GB SD-card with a 4GB Wheezy image installed so that meant there would be space. I had to use 'sudo apt-get gparted' from the terminal to install Gparted which didn't seem to be there to start with. If that command fails, remember to try 'sudo apt-update' & 'sudo apt-upgrade' and go for coffee while they do their thing). Once I got Gparted installed, I could run it from the terminal but it wouldn't let me create a dos-compatible partition. Odd I thought, and then I went down the CFdisk route (cfdisk /dev/mmcblk0) which did the same thing. It turns out the Windows file-system support comes from another package which may not be installed. Try 'Sudo apt-get install dosfstools' and at this point the fat16 & fat32 (ie MS Windows compatible) formats appeared in Gparted - they also fixed the command line version 'mkfs.vfat /dev/mmcblk0p3' which was previously not working. Now I just need to mount this at boot time and get Motion to output it's files to the Windows compatible partition - I will find out later if this works.
== Edit ==
While the extra space was usable by the Pi, my Windows XP box insisted the data partition was not available because "the partition or volume is not enabled"? Restarting my PC as suggested obviously did nothing to fix this. It looks as though Windows is not inclined to play nicely with partitions on SD cards so in the end I used winscp to copy the files I needed over to my Windows PC.
== End Edit ==


It's typical that with this rush job on the go, I've had loads support of requests further depleting my available time. Luckily I started thinking about the dolley last week and this is where my lack of electronics knowledge has let me down a little. The more I read about interfacing the Pi's GPIO to things, the more it sounds like a bad idea and I don't want to risk my precious Pi (any of them). Anyway, back to the dolley. If you watched my timelapse example you might have noticed that my son was fascinated by recycling-trucks when he was younger. I have now recycled one of these which has a simple motor (forwards only) and makes a perfect dolly; I just need to control the motor.

Once I started reading into it, I found there were lots of ideas to try but they all seemed a bit risky. I read things which suggested the Pi should not be used to power any loads (i.e. the motor) and some even suggested they could not provide enough power to control a relay without risk. Luckily, someone out there mentioned opto-isolators and the idea took. I already have a project where the Pi drives some low-power LEDs and so far that Pi has not blown up. The recycling truck also has an LDR fitted which I figured I could use inline with a battery source to drive the motor. And this is where I really need the electronics background because it just didn't work. It seems even when you shine a torch at it, the resistance is still too high to be inline with the motor.


=Update=
I discovered some opto-isolator chips at Maplins which I figured would be worth a go for the price. Sadly I didn't manage to get the project working in time so I need to do some further debugging on the motor circuit. It works fine when the opto is bypassed and the opto works as proven by an in-line LED. The issue seems to be when the two are connected in series. I didn't manage to get this working in time but we still did a timelapse demo. Sadly I also didn't have enough time to knock together a quick Schism module as I lost a lot of time debugging sound (eventually fixed using sudo apt-get uninstall pulseaudio).