Monday 24 October 2016

Replacing the Hubsan X4 Desire (H502E) camera with a Mate808


A GPS camera quad for under £100! What's not to like?

I've been messing around with quadcopters for the past couple of years but started with a Hubsan X4. I quickly grew out of it for models which were faster and could carry better cameras, finally graduating to building my own frankenquads to my own specification.
However when Hubsan released a brushed quadcopter with GPS for under £100 I couldn't resist. I didn't really know whether I'd find its sedate pace a bit dull but hey, GPS!

I've really loved the freedom of not worrying about losing orientation when it is a small dot in the sky but the one thing that has bugged me is the relatively poor camera quality. Even comparing it with my old X4 camera, it comes off badly. Worse, after just 6 flights I had a motor seize so returned it for a replacement. However the new one had an even worse camera.

Reading the discussions on rcgroups, it wasn't uncommon to have focusing problems or a green hue. I had both. My options were to take it apart and try to refocus the lens or purchase a replacement. At best, I'd end up with something like my original - not that great.

I'd love to get quality like my Mobius or a Runcam but at around 40 grams these action cameras are too heavy. Also the processing required to encode x264 means they get hot and interfere with GPS reception. While thinking about trying a 808 #16, I discovered the Mate808 and decided this was worth trying to squeeze into the H502E.

I considered trying to keep the remote control function to start and stop the video but the connector from the main board was too small for any of my test equipment so I opted for buttons on the side of the quad. I only ever video the whole flight so this isn't really a loss for me. I expected the control circuity to be simple enough that a transistor circuit could handle the switching of the Mate808 but this will remain a project for another day.



The tiny Mate808 camera.

 

Pros.

Lightweight - without the battery and case it weighs only 6 grams.
Energy efficient - consumes around 100ma at 4 volts when recording.
Small - the pcb measures 45mm x 34mm.
Cool - not even warm to the touch when recording.
Proper latching card slot.

Cons.

Quality -  it isn't on a par with something like a Mobius, but it is much better than the native camera. Chuck Lohr says "For video, the sensor image 1600x1200 is cropped to 1600x900. Then it is up-scaled to 1920x1080".
Large data rate -  a little under 4 minutes 20 seconds consumes 1GB.

The Mate808 has 2 lens options, 70 and 120 degree variants. I opted for the 70 due to worries about not fitting the lens into the H502E lens holder. Also the wide angle lens is hot glued and although a caseless version is available, I would have to wait for the slow boat from China. The 70 degree version in a case is available on Amazon.co.uk for next day delivery. No contest.

Installation.

After removing the 20 screws in the arms we can start to disassemble the quad.
Pull the case apart near the motors and work your way towards the body, using something like a credit card to carefully separate the plastic catches.
Remove the 2 plugs connecting the GPS board and then the top casing can be removed.


 


We need to unscrew and lift the control board up to gain access to the camera board. The motors and their mounts can be lifted from the case, but the leds are more awkward. Much easier to desolder them from the main board before continuing. Make a note, or use this photo, to record which coloured wires go where.



Remove the camera board connector and lift the control board to reveal the camera board underneath.



The Mate808 is easy to open. Remove it from the case and disconnect the battery from the board.
We need to prepare the board by soldering wires for the switches in parallel with the existing ones. I chose to mount an extra led in the quad's body as a recording indicator. I did try to remove the pcb led a few times but failed. Rather than risk damaging the board I soldered mine in parallel with the yellow Mate808 led so I had to choose a red one as this will light at a lower voltage than a yellow one. It will also be the brightest option.

The Mate808 has an internal 1s battery but the Hubsan is a 2s quad, so we need to reduce that voltage. I used a step down module from Bangood which isn't the smallest or the lightest option (1.6g) but it does the job nicely.
Take care to set the output voltage to 4 volts before soldering it to the Camera pcb.



In order to fit the camera board into the lower case of the quad we need to remove some of the plastic. Cut the old board's 4 retaining clips, then cut space for the usb socket and board components. Lastly make a diagonal cut for the micro SD card slot.
The main thing to concentrate on is allowing access to the card slot so it can slide in and out smoothly. The other cuts are just to allow the board to sit low and stable in the bottom of the case.



Next we need to mount the switches. I used some pcb switches as they were cheap and small. The base measures 6mm x 6mm and they are available in different lengths. When I ordered these I went for the 9.5mm ones but I ended up cutting and filing them down to be almost flush with the case so I could have got away with something smaller. Search ebay, amazon or your favourite store for "micro momentary switch" to locate these.



Drill 2 holes in the side of the body for the switches and one for the led. Take care to ensure they don't obstruct the quad's battery housing when in place. Drill from the outside and then remove the burrs with a knife or much larger drill bit turned by hand.



So that the board doesn't move when pressing the card in and out, I made a 'shelf' from hot glue by wrapping a thin plastic bag around the board, locating it correctly and then building up layers of hot glue to make a snug fitting shelf. I then removed the camera and trimmed the glue with a knife.
I also put a blob of glue to align with one of the holes in the camera board so that I could screw the board down (left hand blob of glue in this picture).



Place the board in the case, screw the corner down ensuring the micro SD card still slides in and out cleanly.
Solder the switches and led and locate the step down converter in front of the board. It fits at a slight incline but doesn't obstruct the battery housing. I placed some thin plastic between the converter and camera to prevent any accidental shorts.



Place the lens into the front of the battery housing as you replace it back in the case. 

 



Lower the control board back into place and screw it down onto the battery housing.
Solder the step down converter to the quad's main power connections. Take care to heat these joints well and get the solder flowing. They will need much more heat than the other connections. Finally resolder the  led wires.



Attach the top case by reconnecting the GPS connectors and screwing everything back together. And that's it, all finished.
Here's what the underneath should look like. An odd angle but perfectly functional and the quad now has a latching micro SD card slot.



A side view of the new buttons and led.



Comparison of old and new cameras.

 

This is a still from a video taken with the original camera. Pretty much everything is out of focus and the green hue is very noticeable.





And here is the Mate808 replacement. Again this is from a video but I've resized it to match the dimensions of the original camera. Apart from the much better quality, notice the field of view is narrower. Actually this picture doesn't do the camera justice. I took these videos before fitting the camera to do a side by side comparison and the Mate808 had some jello which you can see as blurs in the enlarged version of this picture. Take a look at the video below for a better idea of the quality.



As a result of the success of the project I've ordered a wide angle lens for the Mate808. I'm optimistic it will fit the red lens surround without any modifications but I'll post my results here when it arrives.

Video sample.

 When I first tested the video in my garden all looked good but any flights higher than around 10 to 20 metres suffered from minor 'jello'. Not terrible but not great either. I'm not sure exactly why but some interaction of wind and propellers is my guess.
I crudely balanced the propellers and discovered all of them needed some work. I don't have a balancer and used a small drill bit which I jiggled but the difference in jello is stark. I'm sure more accurate balancing is the key to getting the most stable recordings.

Make sure you watch this in 1080p!

Conclusion.

With a final weight (without battery and sd card) of 123.5 grams, this modification has added approximately 2 grams but greatly improved the video quality. Possible improvements include remote control of the camera, adding an fpv transmitter to the Mate808 usb video output and replacing the 70 degree lens with a 120 degree one.


Wednesday 19 March 2014

Spotify on the Acer c720 Chromebook

Spotify is the streaming service that needs no introduction. Although the official Spotify download page states that they only support Windows and Mac systems, they do have a "Spotify for Linux preview". I've been using this for a few months now and found it to be bug free and fully featured. The interface is easy to use and integrates well with KDE.

If you followed my previous post about installing Minecraft on the Acer c720 then you will have a Kubuntu installation that we can use to run the Spotify client.
Installation is simple and should take no more than a few minutes depending on the speed of your internet connection.

If you haven't got a Spotify account, now would be a good time to sign up by going to https://www.spotify.com clicking on "Log In" and then "Sign Up".
Signing up for a free account will let you test things out before deciding if you want to pay for a subscription.

I'm going to take you through installation using the shell so let's start by running Konsole which you can find by clicking Kickoff (the start button) Applications-System-Terminal or by using the hotkey combo "CTRL+ALT+T".

Now you need to copy and paste into Konsole (use "edit-paste" or a double fingered tap in the window) the following 4 commands, one at a time, pressing enter after each entry.
 
(Add repository)
sudo apt-add-repository -y "deb http://repository.spotify.com stable non-free"

(Authentication)
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59

(Retrieve new lists of packages)
sudo apt-get update

(Install. 48MB to download)
sudo apt-get install spotify-client


If all commands completed ok you can now close Konsole and go to Kickoff-applications-Multimedia-Spotify. Sign in enjoy!






Thursday 2 January 2014

Minecraft on the Acer C720 Chromebook

Update 20th July 2015:
Page now updated to work with the 14.04 long term support release (Trusty Tahr) which will last until 2019.

The Acer C720 makes a great little laptop to run Minecraft. As a Chromebook we can't run Java code directly so we are going to install Ubuntu Linux to achieve this.
We have a few choices at this point, how we install it and what version we install but first we need to enable developer mode or we can't install anything.

The bit we are interested in is "To enter Developer mode you first invoke Recovery mode. To invoke Recovery Mode, hold down the ESC and Refresh (F3) keys and poke the Power button. On the Recovery screen, press Ctrl-D (there's no prompt - you have to know to do it). It will ask you to confirm, then reboot into Developer mode. While in Developer mode, your system will show a scary "OS Verification is OFF" boot screen and you need to press Ctrl-D or wait 30 seconds to continue booting."
Note: the instruction to 'poke' just means press normally, as if you were turning on your machine.

Now we are ready to install Ubuntu. We have a choice of using 'Chrubuntu' (a dual boot system where at power on, you choose to boot Ubuntu or Chrome OS) or Crouton (a chroot system that runs Ubuntu at the same time as Chrome OS, similar (ish) to the way Virtualbox allows a guest operating system to run at the same time as the host).
I'm choosing Crouton, simply because my son has had Minecraft freeze when running with Chrubuntu. I've not got to the bottom of why yet, it might be running out of memory, bugs in Minecraft/java or problems with the drivers in use when running native. There's the added disadvantage of no working suspend mode although it's reasonable to expect this to be solved soon.
So, on to Crouton. For details see David Schneider's page at https://github.com/dnschneid/crouton
We have a choice of which desktop version to install, XFCE, LXDE, KDE or Unity. The first two are lightweight (require low memory and processor resources) but in my opinion look a bit dated (without a lot of tweaking) and the C720 is more than capable of running the other two. KDE or Unity? I like KDE's more conventional (ie similar to the windows start button and taskbar interface) approach but I've grown to like Unity and I think it makes a great interface for those new to computers.
To install the latest long term support KDE version (14:04 at the time of writing) do the following.
Download Crouton (get the file from https://github.com/dnschneid/crouton 3rd line down starting with http://goo.gl )
Open a shell by pressing "ctrl+alt+t"
type "shell" then press enter
type "sudo sh -e ~/Downloads/crouton -r trusty -t kde" and press enter
The script will run, downloading and installing, eventually asking you for a default username and password. This process took me around 15 minutes on my 10 Mbit connection.
Make a note of your password. You will need it to install software!

We can now run our chroot with the following command
"sudo startkde" (enter).
You should now see the kde start screen and after a few seconds we have our working Ubuntu ready to play with.
A few tips:
The "Kickoff" button is the blue button in the lower left of the screen where the Start button would be on Windows.
Look in the home directory and it's empty except for the downloads folder. This is actually our Chrome OS downloads folder so this is a handy way of transferring files between operating systems. You might want to manually create the more normal folders such as pictures, videos, documents etc.
We can switch back to Chrome OS by pressing "shift+ctrl+alt+leftarrow".
Switch back to the chroot with "shift+ctrl+alt+rightarrow".
(leftarrow is where the F1 key would be, rightarrow=F2 and refresh=F3) 
Exit Ubuntu by logging off. Press the "kickoff" button, then "leave", then "log out".

If you live outside of the USA, you will probably want to set your locale and keyboard map.
Click "Kickoff", system settings, locale. Click the country tab, select your country and click apply. Click "overview" (top left).
Click input devices, layouts tab, 
Check the "configure layouts box". Click add and then select your desired language and click ok. Select the us layout and click remove.
Click apply. Cllick close.


If you don't have an Minecraft account, switch to Chrome and create one by going to https://minecraft.net/
Go to https://minecraft.net/download and download Minecraft.jar from the section "Minecraft for Linux / Other"

Switch back to Ubuntu where we will move Minecraft to a games/minecraft directory, install java and configure a menu entry.
In KDE, click the kickoff button and type "kons" in the search box and click on 'konsole" to open the terminal application.
Type the following, pressing enter after each line.  Note, Linux commands are case sensitive!
mkdir ~/games
mkdir ~/games/minecraft
mv ~/Downloads/Minecraft.jar ~/games/minecraft
sudo apt-get install openjdk-6-jre
sudo apt-get install kmenuedit

Now log off (press the "kickoff" button, then "leave", then "log out"), wait for the terminal to stop printing text, and log back in again by pressing the "up arrow" and "enter" restarting Ubuntu.

Right click on the kickoff button (two fingered click if using the touchpad) and select "edit applications".
[ If "edit applications" doesn't appear as an option, you will need to install kmenuedit. Open a terminal and type "sudo apt-get install kmenuedit". When this has installed, close the terminal, log out, log back in (restarting ubuntu) and try again) ] 
Click on "Games", click "New Item", type "Minecraft" and click "OK"
In the command field, type "java -jar Minecraft.jar". Note case is important!
Click the "Advanced" tab and type "~/games/minecraft/" in the work path.
Click to select "Run in terminal"
Click "Save" and then close the editor.

Improve the look of your menu item by adding an icon. Search for "minecraft icon", save your favourite (ideally a .png file of around 128x128 pixels) and move it to your ~/games/minecraft folder. Then edit the menu entry and select the icon by clicking on the blank square (menu editor) and browsing to your icon.


Minecraft menu entry
Minecraft menu entry.


You should now be able to run Minecraft from the KDE menu, right click the menu entry to add it to your list of favourites (so it will be listed on the first screen).

Full screen with all the graphical options turned up to full, you should see around 35 frames per second rising to 50 when all the chunks have loaded. You can display the frames per second by pressing the refresh key (press again to remove).
Improve performance by going into the minecraft video settings and lowering the render distance. I find 8 a good choice.


Minecraft up and running nicely
Minecraft up and running nicely.


If this process seems complicated and you are worried you might screw it up. Remember that your Chromebook backs itself up to the cloud so the worst case is you need to restore it from a disk image but your data and settings will be preserved. Details are here. https://support.google.com/chromebook/answer/1080595?hl=en-GB
However as we are running Ubuntu under Chrome OS problems are much less likely than installing a separate operating system.





Monday 2 December 2013

Acer C720

In 1999 I received the prestigious title 'King of Wires' from Her Royal Highness Queen Elizabeth II at a ceremony at Buckingham Palace. I have always been keen to pass this title on to my son so at the age of 8.75 it seemed time for him to own his first laptop.
A macbook would be too expensive and I'm not that keen on regularly clearing malware and viruses off a windows laptop (although I'm happy to be paid to do that) so Linux it must be.
£400+ looked the likely price (getting a bit steep) until I looked again at the chromebook. Since last looking, Acer have released the C720. The intel haswell processor gives not only gives great performance and battery life, but with linux installed you get full access to closed source software that has always been a restriction of the Arm based machines.
So here we have a machine for under £200 with great battery life capable of running Minecraft (apparently essential for all children of his age) and watching 1080p youtube videos (of Minecraft).

I've only spent a few hours with the machine but here are a few observations.

Case: Looks ok for the price. Plasticy. A bit flimsy. Opening the lid warps the screen somewhat. Trying to bend the screen/lid is alarmingly easy. I'm hoping this will do no long term damage to the screen over time, it is for a child after all.

Battery life: Claimed life is 8.5 hours. I'm not sure yet as I haven't had chance to run through a few charge/discharge cycles but 6+ hours wouldn't surprise me. I managed to play with Chrome OS, install crouton and Chrubuntu rebooting and fiddling around for a couple of hours and still had a claimed 5.5 hours left.
This is great.

Screen: Coming from a very old Dell latitude X1, the resolution is pretty similar 1366x768 (vs the dell's 1280x768) but what I noticed immediately is how bright the display is. I can use this outside no problem.

Trackpad: It's a single block with no buttons. Right click becomes 2 fingers and you can also use them to scroll with. I'm sure I'll get used to it.

Ports: Nice to get a USB3.0 and SD slot. You also get USB2.0 and HDMI. With only 16GB disk (SSD), it's nice to add a big SD card or low profile USB flash drive.

 Software: Chrome OS is really just a web browser (Chrome of course) with some extra bits and pieces. You get flash support so flash games or video sites work fine. I was pleased to see 1080p youtube videos and HD Iplayer programs playing without any frame drops. A video player is provided for any local content you have. Some MKV videos I tested played flawlessly with perfect audio sync. There are offline programs for creating office documents that I haven't looked at yet. The file manager is basic but functional. Games and other simple apps can be added via the Chrome store. Again I've not looked at this much but I am expecting they fall a little short of the experience of Android or Ubuntu stores (for example).

Really I was interested in getting Ubuntu up and running for Minecraft, so that's what my next post will discuss.







First post. I'm not actually a doctor either....

Hi, I'm Doctor Tim and this is my blog.
In 1995 I was struck off by the General Medical Council for installing Doom on a patient's dialysis machine so since then I've not been a doctor either.