Wednesday, May 22, 2013

UAE Vehicle Test

As an expat in the UAE, it doesn't make economic sense to buy a fancy new car if you have no idea how long you are going to be here.  My own vehicle is a young and sprightly 2004 Dodge Durango 5.7 litre V8, which does 0 to 100km/h in about 7s,  uses only 14 litres per 100km in fuel and cruises at 120km/h at slightly more than idle speed.

The Al Ain Traffic Department has a large test centre, driving school and registry, which is always overcrowded and getting a vehicle processed there can take half a day if all the Dust Devils are smiling kindly upon you.  This year, I went to a small test centre in Al Foah, a village on the outskirts of the city instead.

They open at 8am and I was first in line.  I had my car serviced at the dealer the week before, so I left the service papers on the front seat.  The test then took only a few minutes.

For the exhaust test, the vehicle is put on a dynamometer, but since the big Dodge is all wheel drive it always just climbs off the machine, so they test it at idle, which is probably not much use.

Inspection = 120 Dh
Insurance (3rd party UAE and Buraimi) = 750 Dh
Parking fine in Dubai = 100 Dh
Registration = 105 Dh

In by 8am and out 30 minutes later - probably less than the time I would have spent looking for parking at the main test centre and well worth the 15 minute drive to get there.

Scanner SMB Access


The company has a networked scanner which is configured to save scanned PDF documents on a MS Windows SMB share.

Hooking up from a Linux machine requires a domain name, user name, password and mount operation.   I need to scan things maybe once a month, so I don't want to bother with a permanent connection.

Here is a simple little script to handle this share.  The script uses Zenity and Beesu to make it a little more user friendly.  You should replace the IP address of the scanner, YOURDOMAIN and myusername with your credentials.  You should also create the mount point /mnt/scan.
#! /bin/bash
pass=$(zenity --entry --title="Add an Entry" --text="WindowsPassword:" --entry-text "password" --hide-text)
beesu - mount -t cifs -o domain=YOURDOMAIN,username=myusername,password=$pass //172.22.213.17/Scanfile /mnt/scan
nautilus /mnt/scan
beesu - umount /mnt/scan
and Bob's your uncle.

Tuesday, May 21, 2013

Virtualbox with Ubuntu and Xubuntu

It has been a few years since I last used Ubuntu Linux and since some of my students are using it, I decided to install it on Virtualbox and see what the fuss is all about.  Ubuntu used to be quite a nice system, but it seems to have regressed terribly and is now almost unusably slow and clunky due to the Unity/Gnome desktop.

My favourite desktop system is KDE.  I like my rotating desktop cube and wobbly windows, but on slower systems, I use the simpler XFCE or LXDE.  Gnome/Unity however, is the Win8 of Linux at this stage of its development and is much unloved.

Security Problems

The Ubuntu desktop also presents a serious security risk in its default configuration, since the Lens sends all your local and remote search activities to various third parties.  Ubuntu now is really a spyware system just like that other legacy system when it is infected with viruses and junkware. The only difference is that in Ubuntu, the spyware is deliberately installed, though it can be deactivated with a dozen or so clicks of the mouse, it doesn't deactivate everything.  The result is that Ubuntu is a total no-no for government users, lawyers, doctors and the like.  Anybody that needs FIPS compliance, should use Red Hat Fedora Linux.

However, Linux is Linux is Linux - so it can be fixed without too much trauma, by switching to the XFCE desktop.

Of course, you can avoid half the hassle by installing Xubuntu to begin with and not Ubuntu, but most people select the default download and then they are disappointed with the performance and don't know how to fix it.  So here, I deliberately use the bad version and then repair it.

Get It

Go to http://www.ubuntu.com/download/desktop and download the latest and greatest version of Ubuntu desktop edition.

Make a VM

Run Virtualbox and make a new VM.  Select Ubuntu Linux for the type, size the disk as 30GB and allocate 1GB RAM to it.  Boot up and select the ISO image file you downloaded from Canonical and let it go with all the defaults.

Fixit

Once you have Ubuntu up and running and experience its sluggishness, you'll be permanently cured of this  version of Linux in no time.

Click the lens at the top left, search for a 'terminal' and install some fixes:
$ sudo apt-get install linux-headers-$(uname -r) build-essential xubuntu-desktop

That lot will ensure that you can use the system for software development as well.

Restart Using XFCE

Restart the VM:
$ sudo reboot

 When you log in, select the XFCE desktop in the round little thingy to the right of your user name.

Your system will now run a hundred times faster.

Install Guest Additions

To make it work properly, you also need to install the guest additions, so that you can resize the screen, make the mouse move smoothly, share files with the host and make sound work.

Click on the top Virtualbox menu bar Devices and Install Guest Additions.  Nothing much will happen.  Open the File System browser and click VBoxAdditions.  Right click and select Open Terminal Here.  Run the VBoxLinux.run file:
$ sudo ./VBoxL[tab] 

Now when you reboot the VM again, things should be honky dory.

Browser Security

While I am on the security complaints topic, you can make your internet browsing a lot more pleasant by installing a couple of add-ons called Adblock Plus and Ghostery.  These two will make your internet browsing much faster and will suppress the worst of the web. These are available for most browsers, even for Google Chrome.  In Firefox, click on Tools, Add-ons and search for them.  In Chrome, click the Spanner, then Tools, Extensions.  It is a similar process in other browsers.

Other VM Optimizations

In a Virtual Machine, you should also disable power management and the screen saver, since they will cause trouble and you already got these features on your host.

Bugs

If the Virtualbox guest additions process complains that it cannot find the correct kernel headers even though you know that you installed them and other things compile just fine, then you may need to upgrade Virtualbox itself on the host machine.  The error message is a maybe a little subtle - it cannot find the correct kernel headers, so you got to upgrade.

La voila!

Herman

Compile a Moxa Serial Widget Device Driver on Ubuntu Linux

We needed a Linux serial device driver for the Moxa U1250 series multi-port USB to Serial adaptors.  The released driver on the Moxa web site only works with Ubuntu Linux up to version 11 and with Fedora Linux up to version 16, so you need a Virtual Machine of the right version for it.  Otherwise, ask Moxa support for a Beta version of their driver for the newer kernels.

Ubuntu Software Installer

There are basically three Linux development streams:
  • Slackware
  • Debian 
  • Red Hat
The Ubuntu distribution is part of the Debian family.
The Fedora distribution is part of the Red Hat family.

Each of these families has their own incompatible code packaging systems.  Each distribution has its own set of file servers and when you install a system, it will be configured to look at those servers for updates.  These servers are distributed all over the world at universities and large corporations.  Because they are perfect copies of each other, the servers are also known as 'mirrors'.

The update program used by Ubuntu is known as 'apt'.  To get a program from a mirror, you run a program called 'apt-get'.

To install stuff, you need super user (administrator) privileges.  You can elevate your permissions temporarily using a program called 'sudo' (set user do).  So therefore the command to get all system updates is:
$ sudo apt-get update

Similarly, to install a program, you would run:
$ sudo apt-get install programname

Apt keeps a database of installation data, so you can also use apt to remove a program, or upgrade an installed program to the latest version.  The graphical software wizard, is simply a nice looking front end for apt.

Low level programs such as device drivers, are operating system kernel modules that can be loaded and unloaded at run time - on the fly.  When you plug a new thing in, the system will automatically load the required driver if it is available,  For that to work, the driver needs to match your running kernel exactly. 

The Linux system is changing all the time.  It has a very rapid development cycle.  Therefore, most drivers are distributed as C source code and you have to compile it on your system before you can use it.

Software Development Tools

To do software development and compile device drivers for example, you need GCC (the GNU Compiler Collection) and the interface definition for your kernel version (the kernel header files).  These can be installed using apt. The command is something like:
$ sudo apt-get install linux-headers(versionnumber)
$ sudo apt-get install build-essential


The kernel version number can be displayed with the 'uname' command.  The command 'uname -a' will show all version parameters of the current running kernel.  The command 'uname -r' will show only the version number, so one can make a generic install command like this:
$ sudo apt-get install linux-headers-$(uname -r) build-essential

Compile and Install

After the above, one can download and compile the U1250 Linux device driver from http://www.moxa.com (or email their support guys for a Beta version).

Compile and installation of any program usually follows a simple recipe, explained in the README and INSTALL files that come with each package.  The recipe is usually the same, but once in a blue moon it isn't, so it is always a good idea to read the readme file and in this case it is indeed different from the norm:
$ make driver_make

************************************************************************
 Ubuntu 12.04.2 LTS 
 \l 3.5.0-23-generic
 MOXA UPort 1200/1400/1600 series driver ver 1.2.5
 Release Date: 2013/04/03
************************************************************************

If and only if there are no errors above:
$ sudo make install
[sudo] password for herman: 
************************************************************************
 Ubuntu 12.04.2 LTS 
 \l 3.5.0-23-generic
 MOXA UPort 1200/1400/1600 series driver ver 1.2.5
 Release Date: 2013/04/03
************************************************************************
************************************************************************
 MOXA UPort 1200/1400/1600 series driver ver 1.2.5 installed successfully.
************************************************************************

Configure the Port

Now, when you plug the Moxa U1250 in, it should show up in /dev as ttyMXUSB0 and ttyMXUSB1.

Configure the device for RS232:
# setserial /dev/ttyMXUSB0 port 0x0

or for RS422:

# setserial /dev/ttyMXUSB0 port 0x2

and for RS485 2-wire:

# setserial /dev/ttyMXUSB0 port 0x1

It is all explained in the readme.txt file and I recommend you use it with Cutecom.

La voila.

USB Serial Device With Unknown IDs

Sometimes, you get a new USB serial widget and although it uses a regular FTDI chip, the manufacturer thought it wise to change the IDs, so that the Linux system doesn't recognize it.  Yes, I am glaring at you SerialComm...

You can work around that by forcing the vendor and device IDs when the driver is loaded.

For example:
Plug the offending USB serial adaptor in.
$ dmesg

Note the Vendor and Device IDs:
[452076.573062] usb 2-1.2: New USB device found, idVendor=0403, idProduct=6001

Now load the module:
# modprobe usbserial vendor=0x0403 product=0x6001

and now it should show up in /dev:
$ ls /dev/ttyU*
ttyUSB0

Turn that into a little script in /usr/local/bin for next time and la voila!

Saturday, May 18, 2013

ArduPlane Smoke Test

Where are we?

The first step is just to be sure everything runs.

Mission Planner test

Plug the computer into the USB port of the AP.  Enable the FTDI USB device in the Windows VM.  The AP should power up like a Yuletide tree.  Let it go online and download the latest AP firmware.

If you carry your whole setup (minus the main wing) into your garden and if you have WiFi access out there, then the GPS, magnetometer and gyros should activate and after a while you should see your location on the map and wherever you went, that is where you are.


If you live in a desert like me, then you may not want to stay out there too long, but most people could carry on doing the rest of the tests on a patio table - all you need is power, WiFi and coffee.

So now you can see where that is going - either you need to pair a smart phone with your laptop PC or get a cell phone data modem of sorts for use out at the airfield.  This isn't a cheap hobby.

Manual Override

Initially, you need to fly and land the plane manually and will only engage the AP for brief periods till you are sure that it is calibrated right and won't flip the plane over, or fly away into the sunset, so the override switch on IN 8 on the AP is all important.

If you have a 6 channel RC set and you selected the Gear switch on channel 5, then it should be on the left of the transmitter, while the Flaps switch should be on the right.  I am right handed, so I prefer using the Flaps switch for the best reaction time.

On my system, Manual is in the Up position.

Smoke Test

Ensure that the plane is tied down securely.  It is also advisable to remove the propellor for the very first test.
  • Unplug the USB cable.  
  • Ensure that the BOB PSU is plugged in.  
  • Push the left hand throttle lever forward. 
  • Turn on the transmitter.  
  • Turn off the motor safety switch.  
  • Turn on the AV power switch.
  • Everything should light up like a Yuletide tree.
Nothing else should happen.

Move the right hand elevator and left hand rudder levers.

If they move the wrong way, then reverse the action in the transmitter setup and save it for your model name.  Any half decent transmitter can save the setup for multiple models.

If nothing happens, flip the Manual Override switch (Flaps on right) and try again.  Once working, mark the Manual position clearly.  On my system, Manual is in the Up position.

Now, check that there are no papers lying about and briefly try to run the motor a little bit with the left hand throttle lever.  (I once had the prop on and it tried to empty a box of tissues for me, which was rather spectacular).

If you see smoke, well, then you can see exactly what is wrong.

If all is well, then you should run the motor at half throttle while monitoring the battery and time how long it takes to run down.

Battery Performance

The Tornado 3400 NiMH battery performance is interesting.  I wired a multi-meter to the battery and played with the system on the bench:
  • At full charge, the battery measured 9.64V with no load.
  • With the motor running at half throttle, it ran down to 7.7V in about 4 minutes.  
  • At the 7.8V point the motor revs dropped suddenly and I closed the throttle.
  • With the motor turned off, the battery recovered to 9.03V.
  • Playing with the servos had no discernable effect on the battery.  They drew very little power.
  • Even though the battery was now clearly depleted, the motor could still run at 5 clicks of the throttle for several one minute periods.
Therefore, with careful motor use, it appears that the system can safely run for 20 minutes.  Just gliding, the system can run for a very long time and with the motor off, the electronics can safely keep running on a flat battery and glide home.

During this half hour of testing, the transmitter battery went from 11.1V to 10.3V.

Radio Interference

During the above tests, I noticed that the transmitter interfered with my Kindle WiFi connection and my online Prague Radio Gothic reception would drop out annoyingly (Abu Dhabi Classic is the strongest radio signal in Al Ain and that gets really tiring after a few years...).  Although the RC system kept working, it is probably a good idea not to use WiFi or Bluetooth devices while flying.

Trim

Once the whole system is under control, you can mount the propellor and go and fly the plane to set the trim values on the transmitter.  After that, you can calibrate the AP https://code.google.com/p/ardupilot-mega/wiki/RCSetup


Time for some nealkohol pivo...

Herman


Friday, May 17, 2013

ArduPlane Mission Planner Installation

I love it when a plane comes together...

Getting the ArduPlane autopilot installed in a plane is quite intricate and getting the Mission Planner software to work is also an adventure all by itself, hence this little guide.

Virtualbox

The Mission Planner software is a legacy 'Java' application created with the Microsoft DotNet toolkit.

Assuming that you have a real computer - Linux or Mac - you would need a virtualizer to run some version of Windows.  I always use Windows XP for virtual machines, since I own about a dozen useless licenses for it and it is light and fast on a VM.

First get Virtualbox from Oracle for your machine https://www.virtualbox.org/wiki/Downloads.

Make a VM and install your favourite least hated version of Windows, then select Guest Additions from the Devices menu and install it in Windows, then restart the VM.  Your screen should now resize and the mouse and copy/paste buffer should work transparently with UNIX.

DotNet

Getting DotNet installed on XP is not easy.  Download the following from Microsoft:

  • MSI installer.
  • Dotnet Framework 2, 3, 3.5 and 4.

Reboot umpteen times - at least booting is very fast on a VM.

USB UART Driver

The FTDI installer may be in a zip file.

Reboot umpteen times again - the pleasure of the Windows user experience.

I machined a neat hole in the fuselage under the wing, opposite the AP USB connector with a Dremel, so that I can plug the computer in without hassle.  Then I remembered to add some foam tape under the AP to isolate the accelerometers from the engine vibration and had to make the hole bigger - sigh.

Mission Planner

Finally, you can install Mission Planner from https://code.google.com/p/ardupilot-mega/downloads/list.

Be sure that the motor is switched OFF when you plug the USB cord in, since USB will power up the AP electronics for you and if the transmitter is off, depending on what else you got plugged in, then the motor may start up at full speed unexpectedly.  There is a safety diode in the AP to prevent it from powering the receiver and servos, but I don't know how you wired your things up.

La voila!

Next up - smoke test...

Herman