Crazyflie Nano Micro Quadcopter

posted 27 Sep 2013, 11:40 by Colin Bell   [ updated 27 Sep 2013, 12:14 ]

Solder Sucker #1 - Crazyfly Nano Quadcopter


Who doesn't want a quadcopter? Nobody I know....these are very cool toys and notoriously difficult to fly, even for experienced RC geeks. 

The basic principle comes from the four propellers providing lift to a frame which contains the circuitry, battery and other stuff necessary to make it fly. Now where these really become cool is that once they are set-up correctly, they can take off and land vertically, hover at any altitude and are among the most maneuverable RC toys you can get.  Add GPS and you have a drone, add a camera and you can take cool pictures of the top of your head from 50m up. You get the idea - it's a must have for any self respecting nerd.

Enter the Crazyflie Nano, billed as the smallest quadcopter kit available today. This little beast weighs in at a mere 19g, and measures only 90mm between rotors, hence the Nano moniker. It's no slouch in the design area though, the board contains the control circuitry for a 3-axis accelerometer and 3-axis gyro, which means that it is capable of self-leveling. The frame is made of the PCB circuit board itself, and the motors attach using small plastic adapters which slide onto the board. The only other 'kit' component is the battery, which is simply stuck directly onto the top of the board in the middle.
The nice thing about the Nano is that it was all designed using open source tools and software, and with development in mind. In fact, it's worth remembering before you splash out on one, that this is still being billed as a prototype. The good news here is that this means that lots of people will develop for it for a good while, the bad is that you're unlikely to get much in the way of official support.

The kit build assembly itself was trivial, (so much so that I didn't even bother to photograph it) taking about fifteen minutes, and only requiring eight solder joints to assemble. Once the battery was plugged in and stuck down, the tiny wannabe drone was ready for action.
The only gotcha bit about assembling was to remember to alternate the connections so that the motors all spin in the correct direction - if you build one of these, pay particular attention to this as these joins are small (0603 sized components, so not too bad for hand soldering) and if you get one wrong, it's a pain to remove and re-solder it - if you are unfortunate enough to need to do this, I suggest to watch overheating the PCB tracks as I suspect that they will lift.

In addition to the Nano itself, you'll also need to buy the CrazyRadio, which does not come with the kit. This allows USB based PC communications with the Nano. Also in addition, you will need a joystick to actually control the Nano - don't make the mistake I did and assume that the CrazyRadio offers the platform for this role - it doesn't. The Crazy Radio is simply for handling telemetry between the Nano and your PC. There are several ways to control the Nano, with many more interesting ways in development, such as Android and RaspberryPi control, so there's plenty of scope to break away from the PC going forward. For now though, I decided to use a standard BlueTooth adapter and a Playstation 3 6 axis controller, which is what I'll focus on in this blog.

I got my Nano and CrazyRadio from Cool Components in the UK. 

To get the Nano up and running, first download the telemetry/control (CF-Client) software from the wiki here. This will allow you to install the CrazyRadio software, and connect to the Nano over both USB and radio links. You will need to do this to ensure that the devices are talking to each other correctly. I didn't have any issues with this stage, and found that both devices worked first time.

At this point, you'll be getting all excited about your first flight, and wondering how the hell to do that...read on.

As I mentioned previously, you need to figure out how to actually control the flight of your Nano. The CrazyRadio wiki page concerning input options is somewhat skimpy on information or detailed instructions, and in order to really find out what to do, you need to turn to the forum. I must admit, I had help from my son on this (thanks Connor!) as he had already built his Nano and got it running a few weeks prior to me.

As the page says, you can get the Nano flying (albeit not particularly well) straight out of the box using a PS3 controller. Where the information is somewhat confusing is over the use of the MotioninJoy software which isn't clear at first glance. This software acts as middleware between Windows (and presumably Linux) internal input driver mappings and the device, allowing both wired and BlueTooth joysticks to work with the CF-Client and also to be configured heavily. My son and I have modified the configuration of this to give what we consider to be a sensible flight control, so I'll post the configuration file and show the settings below to save you the hassle.

So, first up, install a BlueTooth dongle on your PC if it isn't already equipped, and install the Motioninjoy software from the link above.

Here are some screenshots of the Motioninjoy settings we use:






Click on the =>Options link in the DS3 Tool and you can configure the PS3 controllers buttons.















(apologies that its in two images, the DS3 app doesn't allow you to resize the window...)


Once you've got that set-up and your PS3 controller connected over USB or Bluetooth, go ahead and load the CF-Client. You'll need to leave the Motioninjoy DS3 Tool app running in the background.

Go to the 'Input Device' menu, and select the 'Motioninjoy Virtual Game Controller' option, which if all is well should appear as an option now. From the same menu, go to 'Mappings' and make sure that the 'PS3 Mode 2' option is selected. Out of the box, you should see the PS3 controller is able to interact with the CF-Client, but with the default settings, control will be very limited. My suggestion is to exit the CF-Client at this stage, and follow the instructions below to give a much more intuitive control experience.


If you're using Windows, you'll also need to edit the  "PS3_Mode_2.JSON" file in the folder:

 '<root drive>\Users\<user>\AppData\Roaming\cfclient\input'

with the following code (I suggest you backup your existing one to another folder and then overwrite with the code - I find that Notepad++ displays the file correctly but I can't vouch for other editors):

{
  "inputconfig": {
    "inputdevice":
    {"name": "Playstation 3 Mode 2", "updateperiod":10,
     "axis": [
          {"name":"thrust", "type":"Input.AXIS", "id":1, "scale":-1.0, "key":"thrust"}, 
          {"name":"yaw", "type":"Input.AXIS", "id":2, "scale":-1.0, "key":"yaw"},
          {"name":"roll", "type":"Input.AXIS", "id":3, "scale":1.0, "key":"roll"},
          {"name":"pitch", "type":"Input.AXIS", "id":4, "scale":-1.0, "key":"pitch"},
  {"name":"pitch", "type":"Input.AXIS", "id":5, "scale":1.0, "key":"pitchf"},
  {"name":"Pitch Cal+", "type":"Input.BUTTON", "id":0, "scale":0.5, "key":"pitchcal"},
          {"name":"Pitch Cal-", "type":"Input.BUTTON", "id":2, "scale":-0.5, "key":"pitchcal"},
          {"name":"Roll Cal +", "type":"Input.BUTTON", "id":1, "scale":0.5, "key":"rollcal"},
          {"name":"Roll Cal -", "type":"Input.BUTTON", "id":3, "scale":-0.5, "key":"rollcal"},
  {"name":"Killswtich", "type":"Input.BUTTON", "id":9, "scale":1.0, "key":"estop"}
     ]}
  }
}

This code, in addition with the amended configuration in Motioninjoy's DS3 Tool, will give the following behavior when using a PS3 controller:

Left Analog Stick Up/Down  Thrust Control
Right Analog Stick Up/DownPitch Forward/Backwards
Right Analog Stick Left/Right Roll control
Left Analog Stick Button  Kill switch
Left/Right Lower Shoulder triggersLeft/Right Yaw
Triangle/X   Trim Pitch +/-
Circle/Square   Trim Roll +/-


This gives the basic control you need in an intuitive format, along with the option to perform in-flight trimming, which is essential at the beginning when you're trying to stabilize the Nano as it shoots around the room in various surprising directions at high speed.

Here is a link to the file in case you can't be bothered to manually amend the file: Link to the PS3_Mode_2.json file

Once you have all the above configured, test that it's responding properly in the CF-Client - you should see various values changing for the items above as you move the sticks around and push buttons. Once you're happy that all seems to be working, go ahead and follow the instructions to connect to the Nano to the CF-Client - you're ready to scare the cat!




You'll note from the pictures that I've painted the M1 motor bracket with pinkish nail varnish. This is simply to show me which way is forward when the Nano is in flight. Unfortunately, the only colour my better half had on tap was the pinky colour you see - I'm going to have to bit the bullet and buy some Blood Red varnish of my very own (first time for everything I guess...) as although its reasonable visible from a couple of meters, it's impossible to see it from a greater distance. 

So why do this at all? Well, with a Quadcopter, you will be effectively working in the 3D realm when it comes to flight control. Concepts like forward, backwards left and right become seemingly somewhat arbitrary, particularly if you lose control or hit something during flight, causing the Nano to spin. If you designate M1 as forward in your mind before you even start flying, you have a point of reference which can be critical if you get into a situation whereby you need to avoid an obstacle - and trust me, you will.






My suggestion before you finally power up, connect over radio and actually hit the thrust on your controller, is that you limit the Nano's capabilities in the CF-Client software first - this is especially important if you will be flying around a small room with furniture in it and a ceiling less than 3m high. The Nano is extremely light and it's power to weight ratio is huge - and now I know from experience that on a fully charged battery, with thrust set to maximum, it will launch from the floor like a bullet and hit the ceiling in much less than a second! 

Also, when you first assemble the Nano, unless you are extremely lucky, you will need to adjust trim in order to have any control at all over it - I had a few hours of fun before I got the trim figured out, just attempting to get it to hover in one place. 
What you will observe is that until the trim is set, the Nano will zip around in random directions taking leaves off plants, and scaring the bejeesus out of the cat - and all this will happen very, very quickly unless you limit it.

Fortunately, limiting is very straightforward and quite configurable - in the CF-Client, simply set the Flight Mode to Advanced, and then modify the Advanced Flight Control parameters. These can be modified while the Nano is in flight too, and take immediate effect.

For your first flight, and to enable you to set trim from the controller while the Nano is in the air, I suggest the following settings:


Max angle/rate30.00
Max Yaw angle/rate50.00
Max Thrust (%)60.00
Min Thrust (%)1.00 
SlewLimit (%) 50.00 
Thrust Lowering SlewRate (%/sec) 70.00 

This will be somewhat more controllable than the default settings and allow you to get used to how the Nano responds. As I said, trim is the first obstacle you are likely to face, so just try hovering and see which way it flies and compensate accordingly in-flight using the shape keys on the controller (assuming you're using the above configuration).

You may also have to play with the thrust settings - for my Nano, setting 60% allow it to lift off the floor, and hover without much interaction from me playing with the thrust control on the controller, so it's perfect for trim setting. Remember though, the lower the battery gets, the more thrust may be required to get it off the ground - it's always best to do any trim calibration with a fully charged battery.
   
Once you've got it hovering more or less stably, you can increase the values above to get a more exciting and maneuverable flight - the Nano once set up properly is almost pin point accurate and incredibly fast - but you need a big room to enjoy it fully!  



Comments