AeroQuad – Arduino-based multi-rotor aircraft

While I was poking around about what kinds of cool things people do with an Arduino, I stumbled across AeroQuad.  It’s a site and community for folks who are developing an open-source multi-rotor RC helicoptor.

An AeroQuad (pic courtesy AeroQuad.com)

Now that’s awesome.


As soon as I saw that, I thought to myself “Dude, you totally have to make one of them!”.  Cue the research frenzy, cost analysis, and wife justification strategies (love you, snookums).  And guess what, it looks like it’s pretty viable, and should make a great project to get me back into electronics and also leave me with something totally awesome at the end of it.

So, in order to make a Quad, there’s quite the number of items that are required.  Later posts will detail just how I’ve gone about actually getting those items and putting everything together into a (hopefully) working quadcopter;

  • A work area.  My shed’s a storage disaster.  So the need for a work area has triggered off a cleaning frenzy of throwing out lots of stuff, installing shelving to get boxes off the floor, and I also charged out and bought all the stuff to build a (wooden) workbench.  The bench I’ll discuss in brief later.
  • A variable power soldering iron or a 15W and a 30W iron.  I only owned a 40W iron, which is a bit hefty for delicate electronics on sensors, so I picked up a $99 soldering station from Jaycar.  According to the salesman, the “temperature control” actually just varies wattage, so it can stand in for a 15W iron.
  • Arduino UNO.  You can also use an Arduino Mega for more sensors, but I want to start small and simple.  I got a Uno with my Inventor’s kit, but I’ve ordered a second off eBay.
  • AeroQuad Shield.  This is a board that sits on top of the Uno and provides connectivity to the sensors.  It’s not technically required, but I just got the v1.9 board from the AeroQuad store to get it over and done with.
  • Nintendo WiiMotion Plus.  The WMP has a 3-axis gyroscope in it, which is useable with AeroQuad, and is pretty damn cheap.  I picked up one from eBay, and am planning to use it in the build.  There’s been reported issues with AeroQuad 2.4 software and Wii components, but it’s a work in progress and being fixed.
  • Nintendo Wii Nunchuk.  The Nunchuk has a 3-axis accelerometer in it, which goes with the WMP and the shield to make a 6DOF IMU (inertial measurement unit).  These three items make the navigation heart of the AeroQuad.  The Mega can also take a barometer, magnetometer and such for even better navigation.
  • Miscellaneous Cabling & Stuff.  Various connectors and stuff are required, I’ll get them as I need them.
  • Frame.  I haven’t bought the frame components yet, since they aren’t needed in the early stages.  But I’m planning on using a X of square-section aluminium tube for the arms, with a plastic case for the electronics.  Motor-to-motor diameter will be about 20-24 inches.
  • Battery.  Not required just yet, but a main 3S1P LiPo (lithium-polymer) battery is required to drive the motors.  I’ll probably aim for a 4000mAh version.  Most advice seems to be to pick a 3S1P battery (11.1 volts) which weighs about the same as the rest of the quad.
  • Charger to suit Battery.  Not required yet, but a charger with an automatic balancing feature is pretty key, especially with LiPo’s which tend to explode if they’re badly charged.
  • Propellers.  Not required yet.  They have to be balanced and in counter-rotating pairs.  I’ll probably be going with cheapo 10×6 inch props, since I’m likely to break heaps.
  • ESC’s.   Not required yet.  Electronic Speed Controllers drive the main motors at a speed as governed by the servo connection on them.  They’re basically like a relay, but variable.  The DC brushless motors used in a quad can draw a lot of current, and given the motor/prop combo I’m probably going with, I’ll likely be getting Turnigy Plush 25A ESC’s.
  • Motors.  Not required yet.  Motor/Prop combination is a bit tricky, and also relies on the size and mass of your quad.  I figured out that the Turnigy 2217-20 motors should give me the thrust I want (3kg, which will be a bit more than double the weight of the quad), while not overdriving the ESC’s.
  • Transmitter and Receiver.  I wound out ordering a HobbyKing HK-7X radio and receiver.  Honestly, I would have preferred a Spektrum DX7, but they are very expensive, and I just can’t justify the money on a first quad.  As long as the HK-7X actually works, it should be $60 well spent.  I can go with the Spektrum later, if I wind up getting more models or need the better quality.

I’ve ordered in all the electronics – so that’s the controller, IMU components, and Tx/Rx.  I’ll wait until I’ve settled on a frame and have a better idea of weight before I start ordering ESC’s, props and motors.  I’ll have plenty to play with in the meantime.

So as you can imagine, I’m impatiently awaiting my parts arriving.

Electronics & Me – A History

Rewind 25 years or so.  I’ve always had an interest in electronics.  Mostly in pulling stuff apart and tinkering with it – I even built a few little FM radio transmitters in my early teens.  Of course, then I discovered computers, and the hardware side of things took a pretty big back seat from then.  And when I discovered the Internet in 1992, that was the end of that.  For a while at least.


Besides the assembly part of computers, I didn’t really have much more to do with low-level electronics for quite a number of years after then, until I was about 21 or so.  It was around about then that I decided to go back to study, and I decided I’d go and do Electronics at TAFE.  TAFE is the Australian equivalent of a tech school or community college.  I started off with a Cert II in Electronics, which covered off soldering and other basic electronics, and then I moved up to an Adv. Dip IV in Electronic Engineering (which did some microcontroller stuff, and a lot of maths).  Since I’d grown up a bit by then, was paying for the course out of my own pocket, and wanted to study, I actually did the work, did the homework, and practically aced every subject I went into.

Then I wound out moving to another state, and I transferred across from the Adv. Dip to a Bachelor of Information Technology, where I did a big heap of subjects in programming, discrete maths, cryptography and the like.  I got the Bachelor’s degree in the end, and that led me into my first professional job in IT, and the rest there is history.  I now work in IT.  And again, electronics took a back seat to the stuff I was doing with programming and general IT.

But during all this, I still kept all my old stuff – my soldering iron, my breadboards, benchtop power supply, parts, IC’s and such.  It just sat in the shed, in a box which time forgot.

Fast forward to a few months ago.  I received a whopping huge power bill, which scared the living bejesus out of me.  So I resolved to get to the bottom of my power usage, and I set up an ENVI-R, hooked up through USB to a Linux box using MRTG to track my power usage.  The story of that will be for another post.  Anyhow, I got talking to a colleague of mine who said he’d built his own power meter using an Arduino microcontroller.

Meet the Arduino Uno microcontroller.

Arduino.  There’s a word I hadn’t heard of before.  What was this thing?  So I did some digging.  You see, when I last was heavily into electronics, microcontrollers were clunky, difficult things, which were usually pretty expensive to boot, so I’d never really looked into them.  But when I looked at just how the field had grown in the last ten years (incredibly, it’s been that long!), my jaw dropped.

A single-board, all-in-one microcontroller, with multiple analog inputs, many digital inputs and outputs, which has built-in flash, an EEPROM, and enough onboard storage to hold a pretty hefty amount of code?  And it can be programmed with USB?  And it has an onboard voltage regulator?  And you can program it in a familiar C-style programming language?  And it’s only $30 for the board??  What the hell happened while I was sleeping?

Course, the answer to that is simple.  Times changed.  The open source revolution sprung up and started getting into hardware.  Flash became really cheap (back when I was first doing this stuff, microcontrollers were programmed via an EPROM you had to wipe with a UV light!).  Integration moved ahead to the point where you can pack all that stuff into a single DIP at low cost.

Awesome.

So I charged right out and got myself a Sparkfun Inventor’s Kit for Arduino.  In between all my other things, I’ve been messing about with it.  And collecting ideas for what I want to do with my newfound discovery.

So, I realize I’m pretty late to the game with this sort of thing, but I just wanted to share my joy at discovering that such a thing exists and is practical and low cost.

PowerCLI: Get-VMSize

I’m employed as a server admin, with most of my time spent working with VMware and managing a reasonably sized fleet of machines.  As such, I have a range of various Powershell scripts I’ve written to take advantage of VMware’s PowerCLI interface for Powershell.  PowerCLI is, in a word, great.  It provides some pretty good in-depth insight to what’s going on in vCenter, and since it ties into Powershell, it’s easy to script up whatever you want to do.

Anyhow, below is a filter script, which was cobbled together from some code from a source I can’t recall (if you know the original source, let me know so I can attribute it properly!).  The purpose of this script is to take a bunch of VMs, calculate the Size and Used disk space of those VMs, and dump that out.

Begin {

}

Process {
    $vm = $_

    $report = $vm | select Name, Id, Size, Used
    $report.Size = 0
    $report.Used = 0

    $vmview = $vm | Get-View
    foreach($disk in $vmview.Storage.PerDatastoreUsage){
           $dsview = (Get-View $disk.Datastore)
        #$dsview.RefreshDatastoreStorageInfo()
        $report.Size += (($disk.Committed+$disk.Uncommitted)/1024/1024/1024)
        $report.Used += (($disk.Committed)/1024/1024/1024)
    }

    $report.Size = [Math]::Round($report.Size, 2)
    $report.Used = [Math]::Round($report.Used, 2)

    Write-Output $report
}

End {

}

 An example of its use follows;

Get-VM | .\Get-VMSize.ps1 | Measure-Object -Property Size -Sum

The input should be a VMware.VimAutomation.ViCore,Impl.V1.Inventory.VirtualMachineImpl object, such as what gets returned by Get-VM.  Each output object from the script will contain the following fields;

  • Name – The text name of the VM as given by the Name field in the input object.
  • Id – The ID of the VM as given by the Id field of the input object.
  • Size – The sum of the sizes of all disks used by the VM.  This size is the figure set when provisioning the disk, not the actual on-disk allocation (ie, it will be bigger than the disk use if you are using thin provisioning).
  • Used – The amount of actual disk space being used by all disks on the VM.  This size is smaller than Size if the VM is thin provisioned.

Enjoy.

It Lives!

It’s alive!  ALIVE!!

Wow.  It’s been a very long time since I’ve posted here.  I created this blog a long, long time ago with the intention of regularly posting my forays into IT.  However, it appears I never really got around to posting anything except for a few little snippets.

We’ll give it another go.

This blog is having a minor change in purpose.  There will be all kinds of eclectic stuff posted here, so use the tags if a particular subject matter does / doesn’t interest you.

Let’s see whether I can keep the posting up this time around.

WIDCOMM Bluetooth = Crap

So, I got hold of an i-Mate Smartflip smartphone for work, and wanted to configure it for ActiveSync over Bluetooth. I’ve got a Compaq nc8430 laptop. Here’s where the fun begins.

In a nutshell, ActiveSync doesn’t work using the default WIDCOMM Bluetooth stack that comes with the HP. And the Bluetooth chip that’s on the nc8430 doesn’t work with Microsoft’s Bluetooth stack (that comes with Windows XP SP2).

That’s not entirely true. The chip is completely compatible with Microsoft’s Bluetooth driver and stack. It’s just not in the INF file, so the MS driver won’t install. To fix, we crack out Notepad, open up C:\WINDOWS\INF\BTH.INF, and add in a line for the transceiver, as follows;

[HP.NT.5.1]
“HP USB BT Transceiver [1.2]”= BthUsb, USB\Vid_03F0&Pid_0C24
“HP Integrated BT Transceiver [2.0]”= BthUsb, USB\Vid_03F0&Pid_171D

The bolded part is the bit you add. This then allows the Microsoft Bluetooth driver to think that the BT chip in the nc8430 is compatible, and then allows you to install it (when you select Advanced and pick the driver). When you go and install the driver again, the Microsoft Bluetooth stack installs itself and you’re rolling.

Once that’s done, create an incoming COM port on your laptop. Then turn on discovery, and in ActiveSync on the phone, tell it to connect via Bluetooth, and follow the instructions to pair. Fixed.

Of note, the Microsoft stack doesn’t seem to work too well with the Nokia 6230i. You need to use the WIDCOMM stack for that.

Fixing W32Time in a Guest OS

NOTE: For informative purposes only. I take no responsibility at all for any harm that may result to your environment as a consequence of this information. Use at your own risk, and research appropriately!

Sometimes you must run W32Time on a guest OS, but it’s not a good idea to run it at the same time as using VMWare Tools time synchronization. A good example of this is a domain controller – it must have W32Time running, must have accurate time, and must supply time to member servers.

First, a note. Don’t just go and point your PDC at some dummy NTP source that doesn’t exist. If you do that, after some period W32Time will just shut down and stop serving time. Instead, we need to find a way to get W32Time and VMWare Tools to co-exist peacefully.

The solution is to set W32Time so it only tries to slew the clock very occasionally, so the adjustments made by VMWare Tools dominate the clock and keep it in sync. Since W32Time is still in contact with a valid time source, it doesn’t commit seppuku.

You can do this by changing this registry key to “Weekly”. Data type is REG_SZ, if you need to create it;

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters\Period

Restart the W32Time service when you do that, and then all should be well. Oh yeah, and after giving it a little while to settle down, don’t forget to check your event viewer, and do a;

w32tm /stripchart /computer:ANOTHER_DC

to check that your machine is still in sync with the rest of your domain.

VMWare & the System Clock

The system clock behaves … strangely … under VMWare in a guest OS. It tends to run slow, and the amount by which it runs slow varies wildly from day to day. Without a fixed time synchronization source, guests will quickly fall out of synchronization and time-critical mechanisms such as Kerberos will break.

This happens because the guest OS assumes that there is a constant period of time between instructions – ie, it has all of the processor’s attention. The system clock is a high-precision clock maintained by this fact. When you put a guest OS into a virtual environment this goes out the window – the guest no longer has a consistent period of time between instructions, in general this time is longer than expected. Therefore means that individual ticks of the system clock take longer than the fixed (outside) time periods they should, and the system clock runs slow.

So, how do we stop this? Well, one solution is to use a guest-internal NTP client such as W32Time. This is a very bad idea. NTP clients adjust the system clock by slewing (speeding up or slowing down) the clock progressively so they can converge the system clock with NTP time. Since the system clock is running at an unpredictable rate, slewing the clock is a recipe for disaster – it causes the clock to swing to and fro and never stabilize. An unstable clock can cause very strange things to happen.

We could also just keep setting the time as we need to. This is also a very bad idea. Modern OSes rely on the continuity of time. If you just keep resetting the clock, the system ‘loses time’, and tasks that were supposed to run in the lost time just don’t happen.

The solution is to let VMWare Tools handle the problem, and check the box that lets it synchronize with the host. When you do this, VMWare Tools slews the clock appropriately so it doesn’t break anything, and your time converges as you’d expect. When you do this, you must turn off any other kind of time sync software such as W32Time, otherwise they will fight over the clock and much havoc will ensue.

There are certain times when you must run an NTP time server such as W32Time (such as on a domain controller). How you go about preventing W32Time and VMWare Tools fighting is an issue for another post.

NTP Time Synchronization in VI3

Time synchronization is of critical importance in a VMWare infrastructure. If it goes wrong, all hell breaks loose, especially in a Windows 200x environment using Kerberos.

Due to how system clocks work in VMWare, this means that you need to use VMWare Tools’ sync capability to keep your VMs right on time. This means that all your hosts need to be properly synchronized.

So, how do you do this? If you’re using any fancy deployment solution like Altiris, disable time synchronization in it. Why? Because if you don’t, you’ll forget six months down the track, virtualize your deployment solution, and then wonder why all your clocks go crazy.

Read this article and implement it. That’ll get your NTP daemon sorted out, but that’s not quite enough. You need to get your machine’s system clock and hardware clock in sync before NTP can slew the clock and keep it synchronized.

In order to do that, get into a console on your VI3 server, and do the following (I assume that firewall.contoso.com is one of your NTP sources, change to suit);

service ntpd stop
ntpdate firewall.contoso.com
hwclock –systohc
service ntpd start
watch “ntpq -p”

That will configure your system and hardware clocks to be close to the NTP source you named, and then start a watch process showing you the state of your NTP peers.

After a while, you should see an asterisk appear next to one of the peers (not LOCAL, that’s your host’s internal clock). When that happens, you’re all good.

Making a transform for any MSI installer

Many MSI installers will let you generate unattended installs, using command-line arguments, but they may not permit the use of a standard transforms (MST) file to make the unattended install. This is a major problem if you are attempting to deploy software via GPO, since you can’t specify a command line.

There’s a way around this, though. Go and get the Windows 2003 SP1 Platform SDK, and install ORCA from it. The SDK is a big download, but c’est la vie.

Once you’ve got ORCA up and running, make a copy of the MSI file you’re customizing (we’ll call them install.msi and install-cust.msi). Then open up install-cust.msi in ORCA. You will see a VAST number of tables. Don’t worry about them too much. Go find the Property table.

Editing the copied MSI

Now, when you use command-line arguments, what actually happens is the MSI inserts those into the Property table when it runs. So, let’s say you needed to add a TARGETDIR=c:\ argument into the Property table. Go look for the TARGETDIR property, and if you find it, edit it. Otherwise add it by right-clicking on the right-hand pane and clicking Add Row. Enter the values as appropriate. When you’re done, save and close ORCA.

Generating the transform MST

From a command prompt, get to a directory that has the two MSI’s in the same location. What we’ll run here is msitran.exe, a Microsoft tool that came with the SDK that generates an MST that’s the diff of two MSI’s.

Run the following command, and you’ll get a transform named install.mst;

“c:\program files\microsoft platform sdk\bin\msitran.exe” -g install.msi install-cust.msi install.mst

Voila! You now have an MST for your original MSI that incorporates the changes you wanted!

Manually running the MSI with the MST

In order to test deploy, you just run the following command. That runs the MSI, applies the MST you created, and does so in basic mode (which is what you’d typically use in an unattended install);

msiexec /i install.msi TRANSFORMS=install.mst

Assuming that works fine, go ahead and deploy via your method of choice.

First Post!

Welcome!

This blog is my first attempt at composing a blog and keeping it going. While most of the goings on here are IT-related, not everything will be.

Thanks for dropping by!