Zoe the Zero – 5.2 – Anakin, the dark side

Anakin arrived yesterday.  Within a couple of minutes of unpacking the box, I knew it wasn’t suitable because the hole in the center of motor mounting brackets was not deep enough to accommodate the T-motor Air Gear 200 motors set I want to use.

In addition (and I knew I was taking a gamble here), the arms are too short for the Air Gear 200 props which are about 6.7″ span; Anakin is specced to use 6″ props.

Finally, the rear arms are too long for the motor wires to dangle out the end to attach to the ESC.  Again I’d suspected this would be the case.

But I decided to build it anyway, kind of a challenge as since ordering, I’d read multiple write ups about how hard the build was.

Here’s the result with a banana for scale.  Probably took me at least a couple of hours; I had to deviate from instructions several times after aborting a build using the official way since it simply wasn’t possible – biggest problem was that the push-fit grommets and nuts were too loose, and I resorted to some nut-lock to keep them in place.

Anakin Banana

Anakin Banana

My advice? If you decide to buy and build Anakin, put a swear box on your construction bench; by the time you have it built, you’ll have enough cash to buy a frame that will work with the T-motor Air Gear 200, and that won’t take two hours of your life to build!

Zoe the Zero – 5 – Hardware

There’s now a two week wait before further progress can be made on Zoe the Zero.  The PCBs are in production, and the frame is on its way from China.  It’s not the frame I was intending to use as that one is unlikely to be available until the new year.  But some ebay hunting turned up a fab frame from Tarot, the guys who I got Phoebe’ and Chloe’s fab legs from.  Click the pic to see more, but be patient – the Tarot site is very, very slow.

Tarot TL280C

Tarot TL280C

Zoe the Zero – 4 – WAP

Normally, I’d turn on the wireless access point last of all as it removes access to the internet and therefore access to software updates.  But having proven the Quadcopter code runs fine now, its another step I can take pending the arrival of the new PCB.

But first, there’s one more app to install to allow file transfer between the Quadcopter and other computers in the wap network.

sudo apt-get install ftp

WAP relies on installation of the host access point daemon, hostapd.  The official Raspberry Pi WiFi dongle uses the Broadcom  BCM43143 chipset which is supported by hostapd in the Raspian Jessie distribution.  Many other WiFi dongles, especially those from EDUP, Edimax, TP-Link and most other far-eastern brands use RealTek RTL8188CUS chipset.  This is not supported by the default hostapd, so you need to download their enhanced version of the hostapd source code from here and compile it.

Assuming you have a dongle that does not require a revised hostpad, the first step is to install the software

sudo apt-get install hostapd udhcpd

Configure hostapd by creating /etc/hostapd/hostapd.conf “sudo vi /etc/hostapd/hostapd.conf” and add the following, choosing the RealTek driver rtl187xdrv if your dongle uses the RealTek chipset:

interface=wlan0
#driver=rtl871xdrv
drive=nl80211
ssid=MyWAPSSID
channel=1
wmm_enabled=0
wpa=1
wpa_passphrase=MyWAPPassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0

Now to configure the WAP static IP address – “sudo vi /etc/network/interfaces”, adding the static IP address for wlan0 and commenting out anythign related to the dynamic address.

iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
#allow-hotplug wlan0
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp

We next need to configure dhcp for the clients accessing the network to  provide their IP addresses – edit /etc/udhcpd.conf adding:

start 192.168.42.20 # This is the range of IPs that the hostspot will give to client devices.
end 192.168.42.254
interface wlan0 # The device uDHCP listens on.
remaining yes
opt domain local
# opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
opt subnet 255.255.255.0
opt router 192.168.42.1 # The Pi's IP address on wlan0 which we have set up.
opt lease 864000 # 10 day DHCP lease time in seconds

Note the dhcp address range starts at 192.168.42.20 allowing some space for static addresses 1 – 19.
In the same file, delete or comment out “#” any other lines as these are just example settings.

Enable dhcp by editing /etc/default/udhcpd thus to comment out the line

#DHCPD_ENABLED="no"

Add the dhcp leases file by typing

sudo touch /var/lib/misc/udhcpd.leases
sudo chmod 666 /var/lib/misc/udhcpd.leases

Enable hostapd by editing /etc/default/hostapd thus, adding

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Edit /etc/hostname to ensure the domain name is included – in my case, the domain is called local, and the hostname is wappi, so /etc/hosts reads

wappi.local

Next assign static IP address for the server in /etc/hosts

192.168.42.1 wappi wappi.local

Turn off the ifplugd (pluggable interface daemon) for the WiFi dongle as it seems to cause conflict between hostapd and udhcpd – edit /etc/default/ifplugd

# This file may be changed either manually or by running dpkg-reconfigure.
#
# N.B.: dpkg-reconfigure deletes everything from this file except for
# the assignments to variables INTERFACES, HOTPLUG_INTERFACES, ARGS and
# SUSPEND_ACTION.  When run it uses the current values of those variables
# as their default values, thus preserving the administrator's changes.
#
# This file is sourced by both the init script /etc/init.d/ifplugd and
# the udev script /lib/udev/ifplugd.agent to give default values.
# The init script starts ifplugd for all interfaces listed in
# INTERFACES, and the udev script starts ifplugd for all interfaces
# listed in HOTPLUG_INTERFACES. The special value all starts one
# ifplugd for all interfaces being present.
INTERFACES=""
HOTPLUG_INTERFACES=""
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

Finally (and I don’t know if this was necessary), update /etc/resolv.config to local domain name resolution rather than relying on an external DNS

domain local
search local
nameserver 192.168.1.254

Check, double check, and triple check that you’ve done all the above steps, and then finally

 sudo reboot

I’ve written a set of notes containing all the above which I find useful to have open on the screen while I’m configuring the WAP.

Zoe the Zero – 3 – I2C

I thought I’d be unable to proceed further until the new PCB had arrived, but I’d forgotten I’d already started building Zoe prior to the release of the Pi Zero; So I had an HAT PCB ready and tested with an A+.  Since the GPIO pins for the A+ and Pi Zero are identical, I could test the I2C and the Quadcopter code itself.

First step is to run

i2cdetect -y 1

which if you are using the Drotek MPU9250 + MS5611 breakout should look like this:

 0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77

68 is the MPU-9250 I2C address and 77, the address of the MS5611.

Next, update the baudrate of the I2C interface to the maximum the MPU9250 can use since we want to get as much data as we can as frequently as we can.  Open up /boot/config.txt and set the following and reboot.

dtparam=i2c_arm_baudrate=400000

At this point, it’s possible to run the quadcopter code to test the I2C.

cd ~/Quadcopter
sudo ./qc.py -g
sudo ./qc.py -f fp.csv

Here I got 2 surprises.  First it just worked, and second, there were no signs of I2C errors.  So I upped the dri_frequency in the code

dri_frequency = 500
samples_per_motion = 5

And that worked too; with the A+ and the same PCB this didn’t work – data samples were being missed. Perhaps it’s the 1GHz overclocking? I dunno and I don’t care, it bodes well for when the Pi Zero size PCB arrives.

When the new PCB does, I’ll have to redo this to check the PCB itself, but it’s a reassuring test to have passed.

Zoe the Zero – 2 – Initial Installation

First step is to flash your (at least) 8GB micro SD card with the latest Jessie.  Currently that’s the 2015-11-21 version.

To setup a PiZero, because it only has one USB port, you need a powered (at least) 4 port USB hub, a mini HDMI to HDMI adapter, and a micro USB to USB A adapter.  With that you can set up a PiZero with keyboard, mouse, WiFi dongle and screen, and so get it connected to the internet.

Once connected the next step is to change the various bits of system configuration:

  • expand file system
  • set minimal GPU memory as she’ll be headless
  • christen her – zoe in my case
  • enable I2C
  • boot to console login prompt
  • overclocking – mine seems happy in Turbo mode @ 1GHz! – CPU temperature showing 38.4 degrees
/opt/vc/bin/vcgencmd measure_temp

I’ve found the only way I can guarantee each of these steps works is to reboot between each.

Next step is to update the code to the latest

sudo apt-get update
sudo apt-get dist-upgrade

Next install the various tools required

sudo apt-get install i2c-tools python-smbus python-dev

Next install the RPIO library – ignore the build warnings

git clone https://github.com/metachris/RPIO.git
cd RPIO
sudo python setup.py install
cd ..

If you are installing onto a RPi B2 (the 4 core), then you need to replace the RPIO/source/c_gpio/cpuinfo.c with this one before building:

cpuinfo.c

Next install my performance enhanced GPIO library from GitHub

git clone https://github.com/PiStuffing/Quadcopter
cd Quadcopter
tar xvf GPIO.tgz
cd GPIO
cd source
touch *
cd ..
sudo python setup.py install
cd ..

I think that’s everything.  Next step is to get and populate the pHat – it’ll be a couple of weeks before I get hold of this, so don’t hold your breath for the next update.

Zoe the Zero – 1

I have a PiZero.

I have my eyes on a fantastic frame, ESC, motor, prop kit due for release in December at less than £100 (speculative) – more on that when it’s available.

How could I resist bringing Zoe back.  First step is a new custom PCB designed for the Drotek 10DOF MPU-9250 + MS5611 breakout. Here’s my sketch to be Eagled and made.

Zoe the Zero PCB layout sketch

Zoe the Zero PCB layout sketch

I’ll keep blogging “Zoe the Zero” posts, as there’s plenty to do prior to the frame being released onto the market.  And no, I will not be naming that frame until I have one in my grubby hands given the madness of the PiZero release.


Please don’t start your build based on this set of blogs until I’m complete; I’ll be updating the blog each time I achieve the next step successfully, and at any point, one of those steps may go very wrong. Also do consider other costs before you start – while the PiZero and frame together should be less than £100, there’s probably another £100 in battery, charger and PCB build costs. Oh, and the net result is still just a semi-autonomous quadcopter – only as good as Phoebe is currently – caveat emptor.