Author: Tobias

So we did it again, forgot to post our Monday post on Monday. Are we getting sloppy or maybe it was the 16 hour travel to US that put us off track, well we need to shape up anyway! :) This Tuesday we have been visiting the USC robotics labs, more about that will come on a later post. Thanks Wolfgang for organising our visit and everybody for showing us around.

So now it is all about Maker Faire Bay Area for us. We have been putting in a lot of time to get the demos working and now we are getting really close. The autonomous control with Kinect 2 is starting to work but we must say, tuning the position PID controllers has turned out to be hard but we have some basic hovering working.

We have also been working on some LED-ring and buzzer control from the PC side. That is working really well and it is all setup using 0MQ to the cfclient. We are now able to play MIDI over the Crazyradio to the Crazyflie: MIDI -> 0MQ -> cfclient -> Crazyradio -> Crazyflie -> buzzer & LED-ring.

As soon as  we are back from Maker Faire we will make all the code available (because now it is in the quick and dirty stage)!

So once again, we would love to meet up so please come and visit ut as at our booth at the Maker Faire Bay Area!

Maker Faire Bay Area 2015

Yes, next week we are packing our bags and traveling the ~8500 Km from Malmö, Sweden to visit the Maker Faire Bay Area outside San Francisco and it is going to be great!

Malmö to Bay area We are planning some nice demos including autonomous flight with kinect2 and wireless computer controlled light effects using the LED-Ring so be sure to check us out! cf2 - kinect2 We are really looking forward to this event and we really hope you can pay us a visit if you are attending the Faire!

mf_bayarea_seeusthere

 

As many out there think is is more fun to fly the Crazyflie rather then develop upon it (like we do :-)) we have quickly looked at ways to pilot it with a RC transmitter. This forum thread is a good starting point for a developer discussion. To summarize it a bit there are many ways of implementing it which all require more or less development and has different pros/cons

  • Attach the Crazyradio PA to the expansion module/port of an RC transmitter.
  • Implement the E-Sky transmitter protocol or other nRF24L01+ protocols in the nRF51.
  • Using the DeviationTx code and a nRF24L01+ module.
  • Attaching a RC receiver to the deck (expansion port) interface.

Today I will write a bit more about the DeviationTx as it is a great open source project and that it has support for the Crazyflie. It was over a year ago we got contacted by Victor who wanted to implement the Crazyflie protocol in the DeviationTx code base, which he did pretty quickly. We feel ashamed for taking so long to try it out. So during the weekend I freed up some time and gave it a shot. The DeviationTx project replaces the firmware in Walkera transmitters with a better one which has the possibility to support a great amount of RC models. However many of them use different transceivers modules so this must be added to the hardware. Well a bit of hardware hacking is always fun and we had a nRF24L01+PA module laying around. They have a module installation document but I found it easier follow this guide as I had the same type of module and transmitter (Devo7e).

devo7e nRF24L01 module

The module installation was done pretty quickly but what took time was to update the firmware. The instructions tells one to download the walkera update tool but I just couldn’t find it on their website, nor the original walkera devo7e firmware (which they recommend to test with first). Thankfully I could find one using google and ended up using this link. Next thing was to fire up a windows 7 virtual machine to install it in which it worked without problems. So did the flashing of the DeviationTx firmware, I flashed the nightly build 4.0.1 and copying the file system according to the instructions. What I forgot though was to edit the hardware.ini file to enable the module which I understood when the protocol selection had a star in front of the name <*CFlie> (OK, I admit, I thought the hardware wasn’t working at first…). Then I setup a new model using the <CFlie> and I used the Fixed ID to setup the address, The data rate and channel are combined in the fixed id using channel as lowest two decimal digits and the rate the first were 0, 1, and 2 for 250kbit/s, 1Mbit/s, and 2Mbit/s respectively. So channel 80 on 2Mbit/s is encoded as 280 and channel 80 on 250kbit/s as 80.

And boy I was happy when I saw the green led (radio com led) blink on the Crazyflie 2.0, but nothing happened when I pushed the trust… Then I remembered, we recently implemented a lock so that a zero thrust must be sent at least once for it to unlock (to prevent Crazyflie to fly away if the gamepad is not setup correctly and constantly sends 100% thrust :). Looking into the source code one could see the trust was at minimum 5535 which was never unlocking the thrust. Removing this lock in the Crayflie 2.0 firmware and it was flying! but in plus mode… The Deviation cflie module code seem to rotate the pitch/roll setpoints.

Next step will be to do some modifications to the Deviation cflie module for Crazyflie 2.0, adding code to unlock the thrust and disabling the axis rotation, then make a pull request to the DeviationTx project for everyone to enjoy.

A big thanks to the DeviationTx project and to Victor for the cflie module implementation! Ohh, and by the way, they are making a universialTx module that will support almost any RC model out there, including Crazyflie, can’t wait to see that.

We have finally managed together with Seeedstudio to improve the CCW propellers and to setup a process to acquire a free set of CCW replacement props. As continuing from this post we have discovered that many of the CCW propellers from the first batch of Crazyflie 2.0 where a bit too unbalanced. Too be a bit more technical the tolerance distribution for the CCW propellers was a bit offset, so instead of the majority being decently balanced, many where unbalanced and needed balancing. This is not really a big issue and can pretty easily be corrected by balancing them with some tape according to this guide and we still recommend them to be balanced to get the best flight performance. We however think there where to many unbalanced propellers so we offer every one that bought a Crazyflie 2.0 kit from the first batch a free set of CCW propellers including shipping from China. To acquire a free set of CCW propellers please fill in this form.

Propeller guy

Finally here is the last, and probably most interesting part of the “Measuring propeller RPM” series, see part 1 and part 2 to catch up. Now it is time to gather some data and display what we get.

As described in part 2 we are now able to measure each propeller RPM with the expansion board we made and with the code we added. This can, as been described in part 2, be logged to a csv file using the cfclient. Next thing would be to do something useful with it. To do that we use Octave (very similar to Matlab but open source). The first thing that could be interesting to know is the step response for a  motor and propeller. This was acquired by altering the Crazyflie 2.0 firmware a bit to do a step from zero to max trust and then to zero again. It was done on M1 with a fully charged battery.

M1 step response

 

The motor goes from zero to 25k rpm in about 180ms, quite impressive. What is also interesting is that the falling slope in the range 15k to 20k rpm is quite similar to the rising slope in the same region. The inertia of the turning parts of the motor and the propeller is quite low so this energy will quickly be consumed when the motor and propeller starts to coast. This is good as it will lead to better maneuverability.

 

 

 

cf2 thrust fixtureKnowing the RPM is great but it is the thrust that is most interesting. So to get this we need a rig where we can measure it. We made one out of a bottle to which we glued a prototype board on that we put on a scale, not a perfect rig but simple and probably good enough. Then we made a program that ramped up the PWM from 0% to 93.75% in 16 steps with stabilization disabled. We also connected the Crazyflie 2.0 to a power box where we could measure the current. The program would increase the thrust in 16 steps and during each step we took a reading of the thrust and current. The RPM, voltage and PWM was logged over the cfclient at the same time. Some manual work was needed afterwards to correlate the data and get it into a table. While in the table a lot of interesting plots could be graphed.

rpm and thrustThe first one would be the rpm and thrust as this transfer function is interesting. By using the Octave polyfit function the second order fit could be found. It is a pretty accurate fit and with this fit it is easier to get the thrust, as the rpm is the only variable needed, which is easier to measure. The fitting function returned by polyfit is:

Thrust (in gram) = 1.0942e-07*rpm² – 2.1059e-04*rpm + 0.15417.

 

 

 

Here is a combined plot of some other interesting parameters. Notice that the voltage graph is ~quadratic, the current ~square-root and the power linear. From the power graph one can find out that the thrust efficiency is about 3.8 gram/W. Not super good but pretty good for a quad of the Crazyflie 2.0 size.

thrust_v_a_w_rpm_tight

Another interesting graph is the graph of the flight time. Since we know the power consumption and the battery characteristics we can plot a graph of an estimated flight time depending on the battery size. This graph makes the assumption the battery capacity per weight is 32mAh/g.

flighttime_capacity

And finally the transfer function we set out to find, the PWM to thrust. The problem with this is that motors are controlled by voltage (PWM) and the voltage comes from the battery, which varies with the power taken from the battery due to internal resistance. Therefor we made two fitting functions, one based on measured battery voltage while applying PWM, and one based on the PWM. Looking at the graph one interesting thing is that the polyfit is making a better fit (red curve) for the PWM. I would have expected the opposite. Something that we will have to investigate further. Or maybe one of our readers have the answer?

pwm_to_thrust

On the wiki we will update this analysis with some more details and the raw data so if you are interested please have a look! Hopefully using this information we can make the Crazyflie 2.0 fly even better.

On the news side there is a new version of the Android client available on Google play, thanks Fred! Also Fred has uploaded the slides of his Crazyflie lightning talk at Fosdem 2015.

We finally got some time to follow up on the previous blog post Measuring propeller RPM: Part 1. In this post we will continue where we left of and describe a little about the software we have implemented.

The sensor output, as showed in the scope picture, can be connected directly to a digital input. We connected them to the expansion port signals TX2, RX2, IO2 and IO3 as they are all internally connected to a timer with capture capability, TIM5_CH3, TIM5_CH4, TIM3_CH2, TIM3_CH1 respectively. With the capture functionality it is possible to trigger a timer read on events like a pin change. Thus it is not that difficult to calculate the period time of the input signal which can be used to calculate the rpm. Setting up the timer to run at 1us tick was a bit tricky but manageable. With 1us tick it will wrap around, it’s a 16 bit timer, so after 1us * 65536 = 65.5ms. This means the slowest rpm that can be measured is about 458 rpm (1/(2*65.5ms)*60). The division by 2 is because there are 2 blades on the prop. Since hovering happens way over 458 rpm it doesn’t matter much that we can’t measure any slower speed.

Next thing was to setup the capture compare. The ST library already provides the basic API, TIM_ICInitStructure, so it was more or less just a matter of finding how to configure it. The capture part of the timer can do quite fancy things but in the end we decided it was easiest to just use it the simple way, were it stores the timer value in the corresponding capture compare register on a predefined edge. As the register values will be overwritten when the next pulse comes we setup a interrupt handler to take care of the result. What the interrupt handler ended up to do was to copy the timer value, use that to calculate the rpm and then save the result in a variable. It turned out to be good to do an average of the two latest values as the pulses was not fully symmetrical because of the two blades. This was then done the same way for each propeller input and, voilà, rpm measurements was taken. (Well, there certainly was a bit of hair pulling before it all worked but in the end it worked! Love that feeling)

Getting it down to a cfclient was a piece of cake using the logging framework. We just defined the variables to be logged, setup the logging in the cfclient and it could all be plotted. The variables was defined using the macros below.

LOG_GROUP_START(rpm)
LOG_ADD(LOG_UINT16, m1, &m1rpm)
LOG_ADD(LOG_UINT16, m2, &m2rpm)
LOG_ADD(LOG_UINT16, m3, &m3rpm)
LOG_ADD(LOG_UINT16, m4, &m4rpm)
LOG_GROUP_STOP(rpm)

Then by connecting the the Crazyflie a log configuration could be created called “motor” containing the rpm values as well as voltage and PWM.

log configuration rpm

After that by opening the Log Blocks tab the “motor” log configuration could be enabled a written to files. The data log output folder can be opened from the menu by selecting “Settings -> Open config folder”. In my case in “logdata/20150202T17-29-49/motor-20150202T17-35-09.csv”. This CSV file can then be imported to a program such as Octave, Matlab, Spreadsheet etc for further analysis.

Log write to file

The data can also be plotted in real-time using the plotter as in the picture below. Hmmm, interesting, the Crazyflie 2.0 seems to hover at about 19000 rpm with the RPM measurement board attached.

plotting of rpm

 

The idea was to do the analysis part in this post as well but it turned out to be a little bit to much, therefore stay tuned for the final analyzing part!

We have had numerous request to get a transfer function from the motor PWM output to propeller RPM. The next step would then be to get the propeller RPM to thrust transfer function as well. With that it is easier to do calculations on the system and mathematical models. So this and probably next post will be about how to obtain this function and also give a bit of insight in how one can do development with the Crazyflie 2.0.

First thing how do one do propeller RPM measurement? A quick search on the internet and you will find that using an optical switch is a common method. I also found this guide written for Arduino which was a great start. Since I preferable wanted to measure the RPM while flying the switch needed to be small and lightweight. I found two types that could be useful. A slotted type and a reflective type. The reflective type, QRD1114, is small and promising but would it work? I got some of each type just in case.

Now the optical switch needs interfacing and power. Sparkfun made a good tutorial using the QRD1114 sensor so I will not go into details. Since we use 3V instead I adjusted the resistor for the LED to 82 ohms instead. This will give me ~20mA emitter current. I also played a bit with the sensor output pull-up resistor. If you go with a to strong pull-up, the sensor will need a lot of light to pull it down and if it is to week, it will rise to slow. 12k pull-up seams like a good compromise in my lighting conditions.

Optical switch circuit

 

As a first thing I wired it up on a breadboard using the Crazyflie 2.0 breakout board to get a sense if it would work or not. My finding by measuring the output signal with a multimeter is that it is pretty sensitive to surrounding light but that could be solved by flying in a dim room since it is mainly intended to be used for research.

Now it was time to build a circuit using the prototyping expansion board. I also multiplied the circuit 4 times so I can measure all 4 motors. The inputs I use was TX2, RX2, IO2 and IO3. This because they are all connected to timers so I could use the input capture timer functionality later when I get to the software part. Bending the legs on the QRD1114 was a pretty fiddly job but worth it as it came out so cool in the end. Before I connected it to the Crazyflie 2.0 I measured the current draw and it all seamed OK, ~80mA (4 x 20mA). I also double checked all the connections since it is easy to put a lot of time thinking it is a software fault later if things aren’t working as they should.

As a first test I just turned on one of the motors at a PWM of 10000 and measuerd the sensor output with a scope. The black color of the propeller wasn’t so good so I searched around in the office and found some reflective paint we used a while ago. I painted the backside of the propeller and it made a big difference. In the pictures below you can find the scope picture using a 12k pull-up and some pictures of the painted props.

Next part I will start doing the software and analysis so stay tuned!

Well its hard to believe that yet another year has passed. Maybe because it’s been such an hectic year for us at Bitcraze things has been moving so fast. It has not only been hectic but very exiting as well, we managed to release the Crazyflie 2.0 platform just in time for Christmas. That was our goal when we started working on it in March and we can’t really believe we made it. Sure, there are still lot’s of things to be done but now we can all unleash our creativity and start having fun while creating the future for small drones. So what does that mean? Well we don’t know what you have planned but we can at least share some of our ideas for 2015

  • Improve documentation and instructions
  • Develop new expansion boards where GPS and Camera are on top of the wish list
  • Improve the smartphone apps
  • Master thesis in dynamic mesh networks
  • Improve firmware and merge it with Crazyflie 1.0
  • Support for on-board scripting languages such as micro-python and Lua.
  • Improved ROS support
  • And much more!

With that said we thank you all for your support and wish you all a great 2015.

xmas_2014_cf2

This week is going to be an exiting week! Crazyflie 2.0 has started to ship and we are pushing out a lot of code during the week. We wish that we would have gotten more time to work on the code before releasing it, but all three of us have been really busy with production. With the first units now shipping we can finally switch focus to software and documentation. Since there’s quite a few source code projects we are releasing, they each get its own bold headline below. As we role out the different releases we will update this post and post the link in social networks.

iOS Client

main_screen_joysticks_appimg

iOS joystick screen – Download on Appstore

This is our first ever iOS app, and it’s just been released. It got accepted just in time and you can get it from the AppStore, free of course. Currently it is pretty simple, you can connect to a Crazyflie 2.0 and fly it with thumb controls. There is a settings menu where you can adjust sensitivities and configure mapping. The app is all open source and the code can be found here on Github.

Android Client

main_screen_with_app

Android joystick screen – Android app on Google Play

This is more or less the same as the client that has been available for the Crazyflie Nano Quadcopter, but now we have added Bluetooth LE support. Since this app has been manged by our community member Fred for a while it has more functionality then the iOS app, such as tilt control. One cool feature is that you can connect a gamepad with a USB-OTG cable to the phone to get better flight precision with real thumb sticks. The app is all open source and the code can be found here on github. Thanks to Fred Sauer the Crazyflie app has been available for a while now on the market, but now we have taken over the ownership of it. Due to a change in the certificate used to sign the app you will have to re-install the application to get the latest version (market link).

PC Client

The PC client written in Python has got some new features to support the Crazyflie 2.0. E.g. the bootloader in Crazyflie 2.0 is different as it now contains two MCU. It also has a EEPROM which needs new functionality, but other then that we are trying to keep things as common as we can to make things easier. The code is all open source and the code can be found here on Github. Edit: We have made a new tag (2014.12.1), source-code is available here and a windows installer is available here.

Crazyflie 2.0 Firmware – STM32

This firmware is based from the Crazyflie Nano Quadcopter firmware and the aim is to merge the old and new code, but we haven’t had the time to do it yet. Therefore it is now located in its on crazyflie2 branch on Github. We plan to merge them together but more work needs to be done before this is possible, a perfect job for the cold and dark winter months here in Sweden.

Crazyflie 2.0 Bootloader – STM32

This is the code that can flash new code into the STM32F405 MCU. Now the data comes from the nRF51 MCU over the uart, so the booatloader had to be updated. The code is all open source and will be released later this week on Github.

Crazyflie 2.0 Firmware – nRF51

This firmware is completely new and handles the radio communication (Bluetooth LE and Shockburst, compatible with Crazyradio). It also handles the power management and the expansion boards 1-wire memories. The code is all open source and will be released later this week on Github.

Crazyflie 2.0 Bootloader – nRF51

The program to load new code into the nRF51 over the radio link. It also boots the STM32 in bootloader mode and serves as a radio gateway to be able to flash it. The bootloader handles Bluetooth and shockburst so that not only the PC client but also future version of the mobile apps will be able to update the Cazyflie 2.0 firmware. The code is all open source and will be released later this week on Github.

Hardware

We have not yet had time to finalize the hardware files. We are reorganizing the kicad lib and we need to clean things up properly. The hardware projects therefor have to wait, but the schematics has been released if anyone needs to see how things are connected.

Winner of the expansion board naming contest

We have now done a local vote. We are almost hundred percent sure this voting was not tampered with. And the winner is… Flykit. So even though Flykit got a lot of “proxy” votes online it seems the local people liked the same thing. Deck finished second, strange, maybe the voters had read the online vote results… Anyway congratulations to Ramin who will receive a Crazyflie 2.0! We still have not decided if we should go with Flykit or Deck for the real expansion board name. As soon as we have decided we will let you all know.

We are sitting here at Doha airport in Qatar writing our Monday post after a very hectic week visiting Seeedstudio in Shenzhen, China. And it’s been really hectic week, I can honestly say I don’t think any of us has worked this many hours in 7 days in whole our lives. It’s been worth it though, because we did it! We got everything working and ready in time and production is up and running and it’s all on schedule. We have just seen to many kickstarters and pre-order campaigns deliver to late and we do not want to be one of them, and If nothing unexpectedly happens, we will deliver as scheduled.

As we think many of you know of, using internet in China can be a bit difficult. It is often refereed to as the “Great Fire Wall”. We had some clues about it before our visit and tried to take some measures but without much success. We are heavy users of Google services and most of them are either extremely slow or blocked. So is Twitter, Facebook, Youtube and similar social medias so our plan of posting frequent updates failed miserably. Next Monday post we plan on making a summery post of the trip when we organized all photos and when we are a bit more clear in our heads (sleeping on an airplane is not our specialty). Until then here is one photo of us in the Seeedstudio production floor and the new Crazyflie 2.0 box.

 

Another very interesting thing we have tired to follow (yes Bitcraze website has been blocked by the GTW as well) is the expansion board voting process. We’ve seen now that it has been a bit to easy to manipulate and we will use the following week to figure out what to do about it. You guys are just to clever and we see now that we should have done an investigation of good voting processes before we launched it. Well, it’s been exiting to follow and we are pretty happy to see it got people involved!