Tag Archives: BYOAQ-BAT

Post navigation

I ended up doing a complete reinstall from scratch to upgrade Zoe to my new Pi-Zero-W, so here’s my latest set of installation instructions. I recommend printing these off so you can refer to them easily as you do the installation.

These work for any version of Raspberry Pi running the latest Raspian Jessie Lite.

I can confirm that the Pi-Zero-W inbuilt WiFi does support WAP / soft-AP.

Annoyingly, I messed up soldering the GPIO connection onto the Pi-Zero-W, so I have another one on the way.

All of Hermione and Zoes’ powerware – battery, ESCs, motors and props come from a single supplier: Paul Maddock who runs electricwingman.com based in Chester, UK where I used to live until 2010. Over the years, he’s provided a great service, including a couple of specials for me, and so is definitely worth a mention.

If you want a super strong X8 compatible frame that’s large enough for every possible sensor, there’s only one out there that fits the bill. And it fits it well, and then some. It’s designed and hand-made in Poland at quadframe.com by Jakub Jewula.

Hermione’s frame

The frame is carbon fiber throughout. The arms are hinged to allow them to fold for transport, but lock into place amazingly sturdily for flight. The kit comes complete with a simple but well designed power distribution tower, outer-plates for 5V power, WiFi and GPS as shown (or whatever you want to add) and various shelves for flight controllers, LiPo’s etc. I love the way all the wiring for motors, power, GPS and WiFi can be fed down their tubes to protect them from blades during flight.

The standard legs aren’t strong enough for some of the catastrophic falls Hermione has had during her development, so I use these instead.

Hermione’s closeup

I have a few bits of build advice:

Don’t be scared to tighten the bolts as hard as possible for brackets attached to the CF tubes

Don’t bother with the bolt to join the CF arm to the shoulder socket joint, just use epoxy resin glue; it gives a better distributed, stronger connection, and hence significantly reduces the chance of damage on impacts by ensuring forces are passed through to the frame itself.

Apply a little grease to the shoulder joints so they can’t lock up if you over-tighten them.

Wrap some duct-tape at the ends of each arm where the motor bracket joins to prevent hard side impact pushing the motors down the arms.

Add these foam rubber balls to the end of the legs to try to absorb some of any impact landings.

If you want a cover, this salad bowl is a perfect fit, shown in a previous revision of her frame build:

Not the first test flight, but the first I managed to capture on video. Yes, she flew too high, and yes, she drifted towards me, but that was to be expected. The zero-gravity calibration does still shift with temperature, and I’d calibrated at about 20°C, and flown at 10°C, so 10.5mg offset from calibration which equates to 1% error in gravity. She also needs some vertical velocity PID tuning as she’s relying on the integral too much. She also probably needs PID tuning on the pitch rotation rate to help with the drift towards me. And I’d like to experiment with the independent gyro and accelerometer dlpf settings. But regardless, this was at least equal, if not better than anything Phoebe, Chloë or Zoë ever flew.

If you haven’t already, please read the previous BYOAQ-BAT articles first – just search for the BYOAQ-BAT tag.

Only one very simple test is required before HoG takes to the air. With your quad on the ground, and motors and HoG powered up, simply type

sudo python ./qc.py --tc 1 -h 200

Each blade props should spin in turn in the order of front left, front right, back left and back right. The front left and back right props should spin anti- / counter-clockwise, the front right and back left props clockwise. If the props don’t spin, increase -h slowly (in tens) until they do. If any of the props spin the wrong way, swap any pair of the three wires driving the ESC. If each props is rotating in the right direction, check that each prop is producing a down-draft, not an up-draft. If there’s an up-draft, then swap the props.

For PID tuning, I’m not going into the details of how to do it from scratch, but here are some guidelines of how you can take my PID gains and tweak them to fit your quad.

First, only the inner PIDs which control stability need proper tuning specific to your quad. The are the pitch, roll and yaw rate PIDs. The rest are almost certainly fine for any quad.

In the Quadcopter.py code, look in CheckCLI at the various i_am_phoebe, i_am_chloe, i_am_zoe and i_am_hog settings:

cli_hover_target is not strictly necessary – it’s just used to slowly spin up the motors to roughly hover speed before takeoff. I general have it set to 500 for 12″ props, 550 for 11″ props and 600 for 10″ props. This value is the size of the PWM pulse width from the HoG to ESCs in microseconds

cli_pr*_gain, cli_rr*_gain and cli_yr*_gain vary with length of arms and power of motors, and the weight distribution of the quad. The ratio of 2:1:0 for P:I:D seems to work well. Phoebe has short arms and small props, Zoe had larger props, and HoG has long arms and large props – compare the setting for each to see the effect. In addition, all my batteries face front to back, so it takes more power to pitch rather than roll, hence the difference between cli_pr*_gains and cli_rr*_gains.

finally, cli_vv*_gains are for vertical acceleration, but if you compare Phoebe to Zoe and HoG, you’ll see the setting is inconsistent. Because of gravity, the only real tuning required is “enough” power; hence small props have larger PID values.

If you haven’t already, please read the previous BYOAQ-BAT articles first – just search for the BYOAQ-BAT tag.

Calibration used to warrant a vast article, needed special equipment and electronics and took at least an hour as HoG had to be separate from her frame. With the discovery of 0g offsets the other day, calibration is quick, requires only a flat vertical wall and horizontal floor, and assuming your quad frame is sturdy and the PCB is horizontal, the calibration can take place with the HoG in place in her frame.

HoG sits on the most horizontal surface available. Use a spirit level if possible, otherwise use a hard floor or kitchen worktop (not a wobbly table and not carpet). Run

sudo python ./qc.py -g

Do this a few times, and then look in qcoffsets.py. There are 3 columns representing acceleration in the X, Y, and Z directions respectively. What we’re interesting in are the zero-gravity offsets: with HoG sitting on the floor, with her Z axis aligned with gravity, the values in the first two columns are the X and Y zero-gravity offsets. Change the Quadcopter.py code to use these values. Here’s what I got for HoG in her test on the floor after averaging several readings.

self.ax_offset = 1166.28
self.ay_offset = 654.5
self.az_offset = 0.0

Next do the same, but with HoG held against a wall – i.e. a vertical surface where the Z axis is in a 0g environment. Update the offsets above with the Z axis offset: