Instructables

Easy Android controllable, PC Interfaceable Relatively Cheap Mini Quadcopter (or Octocopter!) Drone...

Picture of Easy Android controllable, PC Interfaceable Relatively Cheap Mini Quadcopter (or Octocopter!) Drone...
Or how to become a drone developer without mortgaging your house.

Here is how to make a small, indoor/outdoor quadcopter that you can
fly with either:
* an android phone or tablet
* a legitimate remote
* via your own processing (http://processing.org) sketches on a PC
  (or Android device)

There are lots of optional steps in this project - for example, you
can skip building the quadcopter, and buy one instead - you will still
be to use the Arduino based radio to control it from your
phone/laptop/tablet.  However if you go this route you will miss the
satisfaction of combining the ancient chinese arts of bamboo lashing
and cheap mass manufactured electronic toys...

However you go about it, this is a reasonably cheap project, the most
expensive part other than my laptop and tablet is an Arduino DUE and a
cheaper device could be used if desired.

The ability to write your own code to fly the copter make this more of
a drone than many remote control projects, but you will need to
develop your own code to actually decide what throttle, rudder,
aileron and elevator commands to send it when - a work in progress
based upon a 'Ground station' camera tracking the copter from
underneath is included, but it doesn't fly it yet!

As a simpler exercise for the reader, you can also look into adding
forward/backward/left/right FLIP buttons to the android remote.

Taster video 1: Drone controlled by tablet:
https://www.dropbox.com/s/fesrc4n9tjhul1p/2013-06-27%2022.01.41.mp4

Taster video 2: Onboard footage from flipping (and crashing)
octo-droner:
https://www.dropbox.com/s/cy0xmmbytiqymw7/copter-fpv-flip-flipped.mp4

This work was inspired by the 18$ quadcopter thread on rcgroups
(http://www.rcgroups.com/forums/showthread.php?t=1710948) - take a
look at rcgroups for plenty more inspiration.

It also makes use of plenty of other people's work, but most
immediately the processing-serial-android library
(https://github.com/inventit/processing-android-serial/) and the
hubsan X4 and A7105 code from the deviation project
(http://www.deviationtx.com/)
 
Remove these adsRemove these ads by Signing Up
1-40 of 60Next »
VladB14 days ago

Thanks for DYI it is great,

i just don't understand why you need the resistor for 20K?

and can you please explain how to connect it to arduino nano/leonardo?

starflyer371 month ago

Thanks for the awesome project. I've managed to build it. I am interested in the android processing serial library you've used. I've tweaked your processing code to reverse the controls as they were backwards when using it on a Nook HD. I can't seem to get the app to connect to the Due. Having gone to inventit processing android serial github, i noticed you had had the same issue as well, but have hacked the library to get it working. I was wondered if you might be willing to share your hacked library. Thanks!

allowishus2 months ago

For those interested, i've just flown my Hubsan x4 with my laptop using this tutorial. But instead of the DUE i tried to make it work with the Sparkfun Arduino Micro Pro 3.3v which by comparison to the DUE is amazingly tiny, about the double the size of the A7105 radio,

And it seems to work, further testing is of course requiered and i will return with my finding. Now to wait 'till after exam to dig into the coding :P

Thanks for a great guide!

Isigo made it!5 months ago

Hi everyone !

Thanks to the awesome work of shinyshez, andy_m and drdanny, i've been able to control my hubsan x4 fpv version with my leap motion controller. Here's the link for the github repository : https://github.com/Isigo/LeapCopter

Bug report and pull request are of course welcome. Soft still buggy, and harsh to read ( have to improve this as well ), and remember that it's a work in progress ;)

DSC_0074.JPG
shinyshez (author)  Isigo4 months ago

That's awesome! Do you have any video of it in action?

Cheers

Shez

Isigo shinyshez4 months ago

For sure ! Got this one (throttle control is still buggy ^^) :

https://drive.google.com/file/d/0B4rfrvVIld3WQXI3S01adU50YVk/edit?usp=sharing

vahokif made it!5 months ago

Hi everyone. I've been working with andy_m but I've taken a different approach and used an MPSSE cable to interface directly with the A7105. I've got binding and control working quite reliably. You can find the code here: https://github.com/vahokif/hubsan Also included is an example script that uses an Xbox 360 controller to control the quadcopter. Bug reports/pull requests are welcome.

IMG_20140214_170318.jpg
andy_m6 months ago

My previous comment was a bit premature - I have encountered a
number of issues with this method, both with the wiring and the code.

Firstly,
I cannot get 3 wire SPI to work. When there are no resistors, the MOSI
holds the SDIO pin high, so that the MISO channel can't seize it to
transmit the contents of the register back - this is why we have been
reading 0s off the registers, they are just the 0 we are transmitting as
the second part of a read transaction. When I make the line high
impedance, however, the signal is getting garbled, and it is not being
parsed as a command, and this is resulting in garbage output - the 128s
and the 196s.

Then, with 4-wire SPI, it took a bit of
troubleshooting - in shez's code there is a commented out line saying to
write 0x06 to register 0x0b - this is incorrect, due to an unclear
piece of phrasing in the chip spec. In fact, we need to write 0x19 to
register 0x0b.

My current issue is that I am having problems getting the binding to work. I shall be putting some hours into that over the weekend and early next week.


I am currently refactoring the code and adding a
number of diagnostic functions, including a sniffer and a shouter for
testing packet transmission (I have two of these rigs, and am using each of them
to debug the other). I will let you know as and when I get somewhere. I
am developing this as part of an academic research project and we are against a deadline, so it would
be reasonable to expect some progress in the next two weeks. It is my intent to pull all this together into an arduino library, to make it easy for people who want to hack about with these chips to do so without having to mess about with raw opcodes and things.

Shez- if you are reading this, ignore my earlier messages, and thank you for all your hard work!

drdanny andy_m5 months ago

Hi Andy & Shez,

First off, thanks for the excellent instructable. I think you saved me many days of trial & error.

I am using a Due & XL7105 module with an off-the-shelf Estes Dart (aka Hubsan X4) device. I succeeded in getting the 3-wire SPI interface working with more or less the A7105 code from Shez. However I did figure out how to overcome a few problems on the way. Here are some notes on what I did:

  • you do need to experiment, perhaps radically, with the resistor. I was able to make 2.2K (Red-Red-Red) and 4.7K work, but not 10K or 22K.
  • timing is quite critical I think, so adding Serial.println debug statements was interfering with the binding. I tried using a circular buffer and delaying output for a while, but even the character processing to stuff the buffer could cause binding to fail. Often the quad would think it was bound (lights solid) but the code would not recognize this and would fall back to a lower state. Perhaps a LED tied to a Due pin that switches on when state is 8 or above would be a good idea? In the end I found the binding part was working anyway and my problems were elsewhere.
  • throttle values below 10 (YMMV) will not make the motors spin
  • there is a safety feature in the Quad software: nothing will happen unless the throttle is brought down to zero and held there for a bit (say 80 times round the loop) before raising it

Here is some code to insert before the "hubsanWait = hubsan_cb();" line in the loop to test:

rudder = aileron = elevator = 0x7F; // midpoints?
if (boundcnt >= 80 && throttle < 12) throttle += 1;
if (loopcnt > 280) throttle = 0; // end test
loopcnt += 1;
boundcnt = state >= 8 ? boundcnt + 1 : 0;

and, of course, declare loopcnt and boundcnt as "int"s and init to 0 before the while loop. You may need to play with the constants to get this to work. Remember to tie the beast down before you start testing!

I had quite a time trying to solder the tiny castellated connectors. After I wrecked my first module I upgraded my soldering skills using youtube, learned how to do reflow soldering by hand, and got myself some finer solder & wire (22 AVG). How did you manage to get such beautiful neat connections?

Raspberry Pi's also have 3.3V SPI, I think, and they cost about the same as a Due, so I may rewrite the code to work with one of those later on. Will post if I do.

Now to start in on the camera business!

andy_m drdanny5 months ago

Oh, thank you!

Now you have said that, it makes complete intuitive sense. I have liftoff now, revisions pushed to my git.

I was lucky with the soldering - one of the people on my team is an ex R&D bod, so we left it all to him. I do not envy you.

JohannesH andy_m5 months ago

Hey Andy, any chance of open source? Github?

andy_m JohannesH5 months ago

But of course! :-) I shall put a link to the repo at the end of this post.

I have managed to get the thing to bind - it is not yet taking commands, but I think this is because the timing and sequencing which the arduino is giving out does not match with the timing and sequencing of the Tx.

The code here is a bit of a dog's dinner - it is half refactored, and half commented - my style is a bit different from shez's, and I have been putting it all in my own, which is a lot more verbose. Things which it might be useful to look at include the new functions in a7105.ino include the scanchannels function, which takes an array of channel numbers and tells you what traffic is on each of them (bear in mind that if the ID does not match, you will get no packets or garbled packets) and eavesdrop() which is designed for use with the hubsan protocol.

eavesdrop() scans all the hubsan channels until it finds a Tx which is transmitting prebinding packets, prints the content and timing of those to serial, and extracts the forthcoming session ID and switches over to that. Once this has happened, you can turn on the quad and allow it to bind. You can then scroll back over and see the content and spacing of all the binding and control packets. It's quite fun, with autoscroll on, to twiddle the controls and see the packet contents change.

Anyway - the code is at https://github.com/andy-may/a7105

Enjoy, and let me know how you get on!

--A

shinyshez (author)  andy_m5 months ago

Hey Andy,

Sorry i've not been about to help, sounds like your doing great work! Glad you got 4 wire SPI working should be more reliable for others, looks like my spec reading skilz aren't as mad as they could be!

Cheers

Shez

andy_m shinyshez5 months ago

Also - it's not your spec reading skills, those bits are actually in the wrong order in the spec. I only spotted it after about 4 hours of staring blankly at the page. :)

andy_m shinyshez5 months ago

Hi Shez,

Good to have you back! Yes - the 4-wire SPI seems to be much happier. I cracked out an oscilloscope, and the signal degradation on the high-impedence bit of the 3-wire was so bad that nothing was getting through.

Anyway - there seems to be some stuff which is different between the V1s and the V2s, as detailed here -

http://www.deviationtx.com/forum/protocol-developm...

Anyway, the binding is going great, and it's sitting in the data cycle very happily, but the motors still won't start. What worked for you, can I ask? By my watch, the Tx is sending packets about every 6ms, and I have tried fiddling with the timing up and down a bit, and changing the packet payload to what a V2 would expect.

Sorry to be badgering you to death, by the way!

Isigo andy_m6 months ago
I am also working on this as a part of high school project, and therefore, we are against a deadline too. I work mostly on the PC software, but i have to get something that flies. Thus i hope you'll get your stuff done, thanks for the help, i am waiting for your librairy! ;)
andy_m Isigo5 months ago

See my comment in response to Johannes above - bear in mind that this is a work in progress!

Good luck with your project! What cool things are you trying to do?

Isigo andy_m5 months ago

I managed to get it bind. But it doesn't bind if the while(1) of the main.ino code is commented, and it binds if it is not commented. I don't understand that fact, since there's nothing related to binding in this parT. I must be wrong and have misunderstood that piece of the code...

andy_m Isigo5 months ago

The binding is all done by hubsan_cb(), line 33.

Sorry for leaving that bit commented - I have been having one arduino eavesdropping, and the other binding, so I just keep commenting and uncommenting.

Isigo andy_m5 months ago

Hey Andy, thank you for all the great work.

I am currently reading your updated code. If i understood, i have to wire gio1 on the chip to miso on the arduino in order to get 4 wire SPI to work ? Is the wiring totally different than the one Shez made ?

I am trying to control that quad with a LeapMotion controller. All the PC software is finished ( relatively ^^ ).

I based the code on GroundStation one, because it is always nice to start from somewhere ^^ the problem is that i couldn't have it working for real, because of that little SPI problem ^^

Expecting it to work with your code ( and some tweaks for it to be actually able to take commands ) !

andy_m6 months ago

Hi guys,

So, I have been mucking about with this for most of
today, and I have got to the stage where the transmitter has gone
through initialise() and is running through loop - the problem I am
currently wrestling with is that the transmitter thinks it has paired
with the X4, but the lights are still blinking away. I shall have a look
at this in the morning.

The reason I am posting is this - there
is an error in the instructable. According to the datasheet, SDIO needs
to take between 0.8 and 1.0 times the voltage that VDD is receiving -
this means that the register reads always come back as invalid values. I
have found that it works fine with a 10k resistor.

Isigo andy_m6 months ago

HI, andy_m,

How did you pull the prog on the arduino ?

I am building the a7105 one as the main one, but nothing is happening...

andy_m Isigo6 months ago

Be sure all the files are in the same folder, which is called a7105. Also, some teething problems with the hardware are to be expected. Is it compiling?

Isigo andy_m6 months ago

Yeah, i can pull the prog onto the arduino, but it doesn't work at all. I will test different resistor values, because i d'ont have one of 10K. Thanks for your help.

andy_m Isigo6 months ago

Yes - I am having some teething problems as well. Are you having a thing where you are getting 128 off all the registers? I found that I can only get 0 or 128 off them, depending on the resistance, but I cannot find any information about anybody else having this issue.

Isigo andy_m6 months ago

That's it, i am getting 128 off all the registers, using a 10kohms resistor. I had 196 for a 22kohms resistor.

andy_m Isigo6 months ago

See my above comment - things are not quite as simple as I thought!

Isigo6 months ago

Hey, that's really awesome !

I am waiting for my A7105 board, and i was wondering if, since the zip for arduino software is named a7105, i have to upload the a7105 file onto the arduino as the main file ?

Thanks for this awesome work, it's giving me some ideas :D

ishan5536 months ago

can you plz inform me about the total cost for the project (final expenditure)

plz plz plz plz

my email ID is ishanphansalkar@gmail.com

krekr10 months ago
Great guide and software!
However, is there any reason why this would not work on another type of arduino (e.g. fio or Mega with level shifter)? I've been at it for a few hours now... I can't get the quad to bind. Any ideas?
shinyshez (author)  krekr10 months ago
Hey,

None that I know of, but I haven't actually tried it myself, so don't have first hand experience.

The resister value may need changed - the values that work with the unshifted Due may not work with the level shifter. Note that as 3 wire SPI is being used the data pin is BI-directional - i.e. if your only level shifting the three wires you will need to make sure that the level shifter is bi-directional. I could give a schematic or diagram of the circuit a look see if that helps.

You can try reading from the A7105 registers (there's a few with known values in the data sheet) and see if you get the expected value - this will let you know if your talking to the A7105 succesfully or not.

Hope that helps!
Cheers
Shez
krekr shinyshez9 months ago
Hey, thanks for your reply! I'm using Adafruit's BSS138 bi-directional level shifter. I've tried both level-shifting on the 3-wire side ("before the resistor") and on the 4-wire side ("after the resistor").
I'll try to read the register values, but I'm not an EE so this is a little challenging :P

Good to know that this should work on another type of Arduino. You'll see it'll turn out to be a DOA module or something...
krekr krekr7 months ago
Just a quick update: I received a Due this week and decided I had some time to test if this worked. I had also received a new A7105 module about a month ago.
I still can't get it to work, with both modules. Assuming I don't have 2 DOA modules, I'm starting to think that my copter runs different firmware, uses another protocol or something.
Haven't had the time to dive into this properly (with logic analyser etc.) but I might some day :)

Shinyshez: could you post a dump of the SPI messages between your Due and the module, if that's not too much work? Would help a lot when debugging this! Thanks
shinyshez (author)  krekr7 months ago
Hey,

It may be worth trying different values for the pull up resistor - it took me some trial and error to find one that worked, and that may vary between different A7105 carrier boards. I'm grasping at straws a bit here!

Can you read any A7105 regsiters via SPI? That's an easier test of the A7105 board than binding. I've succesfully bound to and flown hubsan boards which support LED's, and ones which don't, so I do know it works with at least two different firmwares :/

I'll try and get a SPI dump up somewhere, at some point, but its a busy time of year for us all!

Thanks for the feedback, I will try and help out when I get the chance!
Cheers
Shez
krekr shinyshez7 months ago
Thanks for your reply! I'll try to read some registers but this is all quite new to me. The resistor value seems like an obvious problem; I'll look into that first :)
waltassault krekr9 months ago
Hello krekr,
I also tried to get this to Bind with another Arduino and was unsuccessful. I spoke though private messaging with Shiny and he explained what I missed in the 'ible about the 3V operating voltage. I'd think this is still possible and I am experimenting with different resistor values between the A7105 and the Arduino but I can't tell if I'm just unsuccessful each time or if I have blown the module so It's getting tedious. I'm ready to give in and buy a due knockoff just to get this thing off the ground.
krekr waltassault9 months ago
I already ordered and received a new module just in case the module was DOA. But, seeing another "lost soul", I think there's something about not using a Due. One thing that struck me is that one of the SPI pins gave ±7v on my oscilloscope, both on an Uno and a Mega.
I'll test the new module when I have some time. You could check the module like shinyshez says below (by reading the registers, though this is a little bit beyond me :)
meesteersmith7 months ago
Hi, are there any sites or processes you can link me to for installing a camera on this drone and sending a live feed to my tablet?
shinyshez (author)  meesteersmith7 months ago
Hi,

No bother: http://www.google.com/ ;)

The term for this kind of flying is 'FPV' = First Person View. searching for 'Micro FPV' is a good start. Here was the first hit I got: http://www.rcgroups.com/forums/showthread.php?t=1913318

Live feed to tablet probably won't happen - with this kind of flying it is very important that lag is kept to a minimum, and so because of this FPV equipment seems to be mostly analog. The additional steps of converting to digital, compressing etc adds a delay which makes flying this way difficult.

Warning, I've never done this, know nothing about it, and am generally a pretty useless and ignorant individual - everything I've just said may be wrong :D

Cheers
Shez
Thanks for the quick response!
1-40 of 60Next »