Tuesday, May 21, 2013

Sparky Brushless Gimbal Controller testing

Time for a follow up on my previous post about the brushless gimbal driver add-on for Sparky!  It is now working and I even have some testing flights when I'm quite happy with the results.

Iconic-X Frame modification

I mounted two GoPro's on my Iconic-X FPV frame.

The first is obviously mounted like the normal FPV camera (which then uses a minimosd as described here).  I then bolted the RCTimer 2-axis gimbal to the top of the isolated part of the frame (very little vibration in this configuration).  Also, tanks to Kendall at UAVObjects for having the gimbal in stock and really fast delivery.  So at this point it's quite a monsterous beast (and one I don't want to crash).   You'll see it works really well for roll but I haven't tuned up the pitch quite enough.

It also still has the minimosd being fed directly from Sparky to provide an OSD which you'll see again in the video below.

UG-2 Gimbal

I was also really excited to get a brushless gimbal for larger cameras from Rusty at AGLHobbies which is using two motors that are prewound from RCTimer.  You can see it in the second half of the video above although I need to get some more flights in and do some more tuning to really show it off. Here are some pics of putting it together for anyone that was as clueless as me.

I have a little bit of testing in the video below and it's working pretty reasonably (like the RCTimer gimbal Sparky is under-compensating pitch) but this was the first flight and I need to spend some time tuning it.


So without further ado, a video:

Sparky Brushless Gimbal add-on success from James Cotton on Vimeo.

When demonstrating the gimbal in flight there are four screens.  The normal FPV from gopro, the version from the ground station (with OSD overlay), one from a fixed tripod, and finally the stabilized gimbal.  Overall I'm pretty happy with the results and want to take this out in a big field and do some FPV and enjoy the video madness.

You can see during some of the more aggressive maneuvers the attitude drifts - this is likely the complimentary filter drifting from acceleration.  I'll try tweaking the settings and seeing if I can get it more resilient.  There is also a noticeable under-compensation in pitch although I'd say it is eating up 95% of the movement.

 Control Scheme

So this threw me for a loop for a few days.  It was trivial to get it working ok but I wasn't getting great results.  Especially roll just had insufficient torque and felt sloppy.  I ordered a gimbal controller (the Martinez controller I believe) from UAVObjects (thanks again) and pretty quickly got the RCTimer gimbal working, so I now knew the hardware was capable and that I was failing.  However one thing I picked up pretty quickly from the tuning settings people were using was they typically used a lot less power than I started with (e.g. around 30%) which did improve things substantially.

I conceded defeat and looked into the code at  What seemed odd to me was that the gyro came in twice - once where it was integrated to determine the electrical output phase (scaled by what they called Kp) and a second time after the integration where it was added to the phase to create a phase lag or lead essentially (what they call Kd).  That seemed a bit odd, but when you write it out that basically is the same as normal Kd, except they bypass differentiating and then integrating it right back.  I'm guessing this improves the noise performance.  This term made quite a difference.  Here is a picture of the control scheme for the curious:

Where in my case I'm using essentially attitude control mode where the outer Kp maps to that Ki, the inner Kp maps to that Kp, and then I have an additional damping term that is fed into pios_brushless.c which creates a phase offset to the integrated position.  There are still lots more knobs to tweak, and I'd like to try setting that damping to zero and using a normal Kd since we have control over the bandwidth then.  At least convince myself I can get somewhere similar.

Anyway, that was fun.

Also I want to thank, ReadError who is awesome and threw a few brushless add-on boards in with one of his PCB orders.

Sunday, May 19, 2013

Sparky: testing and building (no crashing??)

Update2: Sparky2 is available here
Update: for information on Sparky 2 see this post

Warning: there are reports that some of the cheaper boards (e.g. from Witespy / ReadyToFlyQuads) have problems with the baro, so you will not be able to do altitude hold or navigation. There is also no "V1.2 2.0" - he is selling version 1.0 with known problems.

Now that I have some boards back of the final revision of Sparky, I've been hard at work upgarding my fleet from CC3D.  If you missed the previous posts, Sparky is somewhere between CC3D and Quanton/Revolution. There is also discussion the old Tau Labs forums.

Basically this board evolved cause I have a lot of frames and wanted something high quality and easy to make a bunch of for myself.  Hopefully others will like it too.  Here is a list of the features
  • Smaller than CC3D by 20%
  • Single sided for easy assembly and also you can double sided tape it to things
  • It has a mag, accelerometer, gyro and barometer which means it is capable of full navigation (hopefully I'll do some RTH testing this week).  
  • Two serial ports, one of which supports Mavlink + GPS so you can have OSD, GPS and Telemetry.
  • Altitude hold
  • Runs the full INS EKF at 500 Hz
  • There are 10 channels of output (of you can use some of those for ADC inputs for battery / RSSI sensing)
  • OSD via minimosd using mavlink protocol (so you can run the regular firmwares or the minimosd-extra)
  • CAN bus support with built in driver for easy extensibility
  • Daughter board that can drive a brushless gimbal system (still under development to get it really locked in)
  • Camera stabilization support
  • It is not designed to take PWM inputs though, to keep the size down.  It supports DSM2, S.Bus, and PPM.  I know not everyone will like this tradeoff although you can use a PWM to PPM converter if needed.
So I've been putting it through the ringer and having lots of fun.  If you saw my previous post, I built a pretty cool tricopter that has the servos on the front and can do horizontal forward flight.  Here are the rest of the things I converted over to Sparky:

So those are
  • Triblivion
  • UAP-1 with RusticWave gimbal
  • Iconic-X FPV frame (from Quadaddict)
  • Aggressor (again from Quadaddict, a great sport flyer)
  • HT-FPV
  • And a UG-2 gimbal I'm tuning up
The receiver port pinout is super useful, at least for me.  All my quads are flying using an OrangeRX satellite and the receiver port has both the board supply and regulated 3.3V. That means each board I just solder three wires of the satellite cable to the board and I'm good to fly.

It's nice to no longer need a satellite adapter like on CC3D.  Now I just need a few more OrangeRX satellites (hurry up Hobbking!).  I'm really happy with how they all fly, although I think one of the motors on aggressor is going bad (again, hurry up Hobbyking!).

Here is a video showing off a few of the features.  I need to spend a lot more time flying to really show this thing off, and hopefully I'll get some RTH tests in this week.

Sparky Testing from James Cotton on Vimeo.

The main things this shows off are

  • Altitude hold
  • OSD with home direction and coordinates (F3 ADC code is about to merge so then I'll redo this with battery voltage and current on the OS D too).  Sorry the video recorder was cropping the screen, and my RF link wasn't behaving terribly well :(
  • Camera stabilization 
  • Brushless gimbal control with a daughter board
I still need to test position hold and return to home - hopefully the wind drops in the next day or two.


Now that I have six soldered up for myself and getting my fleet airborne again (selfish bastard I am), it was time for a solder party to make a few boards for devs and testers.  It was a long couple of hours, but actually went faster than when I made the first 15 prototype CC3Ds for testers (man that was ages ago).  That's the big benefit of keeping it single sided for home assembly.  Anyway, I took some photos for you guys if you haven't seen the process before.

Jigging them up and using the stencil to apply paste

All the ICs are now placed.  Woops, short one MCU.  Always should count parts before deciding how many to solder.

Ok, now all the parts are placed into the oven with you.  Careful not to put any on the bent wire since I did that the other night and knocked one down, ruining all the placements *sigh*.

And the finished product.  All flashed and ready to rumble.

So that was my Saturday evening.  Well there was also scotch.  I have a few spare so if anyone wants one drop me a line.  I'll make another batch if there is demand.

Update: Here is a demo of Sparky doing PH and RTH:

Sparky testing PH and RTH from James Cotton on Vimeo.

Monday, May 6, 2013

Brushless Gimbal Driver add on for Sparky

So back in January when I designed Sparky, one of the goals was to keep all the components on a single side.  Aside from making assembly a breeze, the advantage of this was that I could make an add on board for the back which would drive a brushless gimbal.

I finally got around to making a prototype a few weeks back and got to test it this weekend.  The results are pretty decent for a first test.

Sparky Brushless Gimbal add on board testing from James Cotton on Vimeo.

In the first part with the transmitter it is in manual mode.  In the second part it is holding the attitude based on the transmitter stick.  In manual it moves smoothly but I still need to do some tuning for attitude mode.  It seems to ratchet a bit which I think is essentially being overtuned and briefly having the velocity go too high.

I hacked up a different controller that seems to work a bit better, but I don't want to get too obsessive testing until I get a more realistic load (gimbal + camera) set up. It might also be fun to try using the LQR controller again for this.  Plus autotuning should let me characterize the whole gimbal performance just like a quad and optimize it.

Fun times!

Oh, and one other cool thing I need to try.  Since Sparky was sort of designed with this in mind, I'll connect two of them via CAN so I can relay the desired gimbal position from the main flight controller Sparky to the brushless gimbal Sparky.  That way both transmitter control and also things like POI tracking should work.  Similarly we can use CAN to the ground station modem and make an antenna/camera tracker pretty easily.

The last thing I really need to decide on: if I don't want to continue having lines to enable or disable the gimbal outputs, then I can use 9 channels and drive a three axis gimbal.

I'm also kind of tempted to hack the ESCs I made to drive a brushless as well so that it can be added to any FC as a PWM output (credit goes to dongs/timecop for doing this the other day).