HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Oct 18, 2010, 03:15 PM
Registered User
United Kingdom
Joined Nov 2008
2,035 Posts
Discussion
XXcontroller software for KKmulticopter

Hi All
as some of you will know, kapteinkuk provided the community with his KKmulticopter creation in this (now rather long) thread.
The copter is now well supported and is simple and therefore cheap to build.
The software can be found in this thread as well as on www.kkmulticopter.com where you can find a wealth of useful information.

The original software was written in assembly, and as such, has limited the number of enhancements made to it.

I have now analysed the code and converted (copied in some cases ) it into c on the post here.
This works with the original board and as such is an alternative for the tweakers among you.
The current board layout means that no external Xtal could be used, and this has now sparked an interest in providing a modified layout.

This thread is therefore meant as a placeholder (so as not to confuse late joiners to the thread original thread) for those who wish to make alternative layouts and develop enhanced versions of the software.

I won't be pursuing this line of development myself, but as a starter for those who do, here are the rules - as I understand - which they need to consider for the schematic:
  1. The gain pots and gyro outputs must go to pins ADC0->7
  2. The RxSignals need to use PinD2 (INT0), PinD3 (INT1) and then 2 more pins which need to be from different Ports (but one can be on PortD)

For the software:
  1. Check/change timers/timings
  2. Ensure variables do not overflow due to them holding larger numbers (nb no floating point vars used)



XXcontroller Software Post

Latest Versions

XXcontroller Versions with Sources:
V1.0j (Software-PWM )
V1.1a (Fast-PWM)

XXcontroller without sources:
V1.4d (Hardware-PWM) nb: limited compatibility with all ESC's

V1.4g (300Hz versions)
V1.4h (300Hz TRIcopter)

SimonK

CyCrow - with source
XXcontroller_CC_V1.2

XX_Kr versions with sources:
XXcontroller_KR_v1_5

Others posts:

KK board Diagnostic software

Creating a project in AVR-Studio4 and a problem compiling a project ?


Hobbywing/Turnigy-Plush ESC setup firmware for KK board


Updating Firmware on Sparkfun Serial LCD

Create eeProm hex file from c structure
Mike Barton is offline Find More Posts by Mike Barton
Last edited by Mike Barton; May 29, 2012 at 03:28 PM. Reason: tidy up
Reply With Quote
Sign up now
to remove ads between posts
Old Oct 18, 2010, 09:42 PM
Registered User
RCvertt's Avatar
Joined Aug 2007
4,247 Posts
Quote:
Originally Posted by Mike Barton View Post
I have now analysed the code and converted (copied in some cases ) it into c...


...I won't be pursuing this line of development myself, but as a starter for those who do...
Been hoping someone would put this in C form. Too bad you don't plan to suppot it But thanks for starting it
Any flight videos of your version or can you say if it it handles similar to the original KK quad?


Any chance you can humor a non-coding newb and explain what is taking place in this line... I'm curious why you times by 20 then divide by 23.
Code:
RxInRoll	= (RxInRoll * 20)/23;	//RxInRoll  *= 0.866;	// Sine 60
RCvertt is offline Find More Posts by RCvertt
RCG Plus Member
Last edited by RCvertt; Oct 18, 2010 at 10:22 PM.
Reply With Quote
Old Oct 19, 2010, 03:12 AM
Registered User
United Kingdom
Joined Nov 2008
2,035 Posts
Quote:
Originally Posted by RCvertt View Post
Been hoping someone would put this in C form. Too bad you don't plan to support it But thanks for starting it
Any flight videos of your version or can you say if it it handles similar to the original KK quad?


Any chance you can humour a non-coding newb and explain what is taking place in this line... I'm curious why you times by 20 then divide by 23.
Code:
RxInRoll	= (RxInRoll * 20)/23;	//RxInRoll  *= 0.866;	// Sine 60
Hi
I don't have a suitable cam-corder myself, but hopefully others will put their impressions on this forum.

The original code (for Tri/HexCopters) I converted multiplied by 0.866 (Sine 60 - this is because motors are not inline with gyro axis). Using x 20 / 23 gives a good approximation (0.87) without having to use floating point maths which would dramatically increase the hex size as well as taking more clock cycles. It could just as easily be x 4 / 5

Mike
Mike Barton is offline Find More Posts by Mike Barton
Reply With Quote
Old Oct 19, 2010, 03:42 AM
Registered User
RCvertt's Avatar
Joined Aug 2007
4,247 Posts
Quote:
Originally Posted by Mike Barton View Post
...The original code (for Tri/HexCopters) I converted multiplied by 0.866...
I see. Thanks for the explanation and converting this code.
RCvertt is offline Find More Posts by RCvertt
RCG Plus Member
Latest blog entry: Chupacabra sighting !!!
Reply With Quote
Old Oct 19, 2010, 04:12 AM
Strictly DIY
1.139749,103.96218
Joined Jul 2010
70 Posts
Quote:
Originally Posted by Mike Barton View Post
Hi
I don't have a suitable cam-corder myself, but hopefully others will put their impressions on this forum.

The original code (for Tri/HexCopters) I converted multiplied by 0.866 (Sine 60 - this is because motors are not inline with gyro axis). Using x 20 / 23 gives a good approximation (0.87) without having to use floating point maths which would dramatically increase the hex size as well as taking more clock cycles. It could just as easily be x 4 / 5

Mike
Nice trick to avoid floating point Mike.

Thanks to your XXcontroller now I can experimenting with bigger AVRs like ATMEGA32 and have more pins to play with. I'll try WiiMotionPlus connected to analog and later to I2C. We'll see which route is better. I'll post the result here when I'm done.

Vince
vinlee is offline Find More Posts by vinlee
Reply With Quote
Old Oct 19, 2010, 04:53 AM
Registered User
United Kingdom
Joined Nov 2008
2,035 Posts
Quote:
Originally Posted by vinlee View Post
Nice trick to avoid floating point Mike.

Thanks to your XXcontroller now I can experimenting with bigger AVRs like ATMEGA32 and have more pins to play with. I'll try WiiMotionPlus connected to analog and later to I2C. We'll see which route is better. I'll post the result here when I'm done.

Vince
Hi Vince, no problem.

A word of advice, I would avoid using ATmega32 as it's an older generation chip and only has 3 external interrupts (INT0,1,2) and importantly no pin-change interrupts.
This means that if you want to connect a std receiver (4 channels or more), you will have problems. I also made this mistake a while ago thinking all AVR's were the same....
Better off going for an ATmega324 which is available in both smd and thru-hole versions.
There's still some life left in the ATmega168/328 despite its lack of pins, you just have to think creatively

Good luck with the interfacing and I look forward to seeing the results

Mike
Mike Barton is offline Find More Posts by Mike Barton
Reply With Quote
Old Oct 19, 2010, 05:34 AM
Registered User
RCvertt's Avatar
Joined Aug 2007
4,247 Posts
Quote:
Originally Posted by vinlee View Post
...I'll try WiiMotionPlus connected to analog and later to I2C. We'll see which route is better. I'll post the result here when I'm done...
Sounds great.

Go for the ATmega328p or the ATmega1280. Then maybe we can get this running on an arduino
RCvertt is offline Find More Posts by RCvertt
RCG Plus Member
Latest blog entry: Chupacabra sighting !!!
Reply With Quote
Old Oct 19, 2010, 06:47 AM
jolly
Joined Dec 2009
6 Posts
Quote:
Originally Posted by RCvertt View Post
Sounds great.

Go for the ATmega328p or the ATmega1280. Then maybe we can get this running on an arduino


nice work dude
isrokavi is offline Find More Posts by isrokavi
Reply With Quote
Old Oct 19, 2010, 06:56 AM
Strictly DIY
1.139749,103.96218
Joined Jul 2010
70 Posts
Yes Mike, I just realized that ATmega32 does not have pin change interrupts. I'll be ordering 324, but for now I'm going to use 168. Let's see if I can cramp everything there.

RCvertt, I'd like to get WMP working then maybe add Nunchuck later. Do you want to co-develop that?

Vince
vinlee is offline Find More Posts by vinlee
Reply With Quote
Old Oct 19, 2010, 08:41 AM
Registered User
Brisbane, Australia
Joined Mar 2010
152 Posts
#ifdef QUAD_X_COPTER
RxInRoll = (RxInRoll * 20)/23; //RxInRoll *= 0.866; // Sine 60
MotorOut1 += RxInRoll;
MotorOut2 -= RxInRoll;
MotorOut3 -= RxInRoll;
MotorOut4 += RxInRoll;
#endif

This seems wrong for the X-Quad. Not sure where you would get a 60 degree angle on a quad. Maybe this should be sin(45deg) ?
OpticalFlow is offline Find More Posts by OpticalFlow
Reply With Quote
Old Oct 19, 2010, 09:07 AM
Registered User
United Kingdom
Joined Nov 2008
2,035 Posts
Quote:
Originally Posted by OpticalFlow View Post
#ifdef QUAD_X_COPTER
RxInRoll = (RxInRoll * 20)/23; //RxInRoll *= 0.866; // Sine 60
MotorOut1 += RxInRoll;
MotorOut2 -= RxInRoll;
MotorOut3 -= RxInRoll;
MotorOut4 += RxInRoll;
#endif

This seems wrong for the X-Quad. Not sure where you would get a 60 degree angle on a quad. Maybe this should be sin(45deg) ?
Just to remind, I have only tested the Quad+ config.

I do agree with what you have said.

The logic went as follows:
I did originally have it as a half (45 degree), since it is applying the adjustment to 2 motors (instead of 1 for Quad+).
But then I had a look Minsoo Kim's Quad-X V1.0 mod, and he has his x 1.5 (he briefly put up a V1_1 with this removed).
I queried the x 1.5 with him and he basically said it was better this way.
So not having a Quad-X to try out on, I took an in-between compromise.

But you're welcome to tweak to your hearts content

Mike
Mike Barton is offline Find More Posts by Mike Barton
Reply With Quote
Old Oct 19, 2010, 10:27 AM
Registered User
RCvertt's Avatar
Joined Aug 2007
4,247 Posts
Quote:
Originally Posted by vinlee View Post
...RCvertt, I'd like to get WMP working then maybe add Nunchuck later. Do you want to co-develop that?...
Wish I could but I'm no programmer. Though if you build it I'll help test fly it for you
RCvertt is offline Find More Posts by RCvertt
RCG Plus Member
Latest blog entry: Chupacabra sighting !!!
Reply With Quote
Old Oct 19, 2010, 11:23 AM
Strictly DIY
1.139749,103.96218
Joined Jul 2010
70 Posts
Quote:
Originally Posted by RCvertt View Post
Wish I could but I'm no programmer. Though if you build it I'll help test fly it for you
Fair enough RCvertt, I'll post the result here and have you test fly it.

Vince
vinlee is offline Find More Posts by vinlee
Reply With Quote
Old Oct 19, 2010, 12:02 PM
Tri-Quad-Hexa-Octo-copters!!
United States, TX, San Antonio
Joined Feb 2007
14,709 Posts
Mike,
Great work here! Added to the Mega Index.
Thanks for sharing!
Cheers,
Jim
Quadrocopter and Tricopter Mega Link Index
jesolins is offline Find More Posts by jesolins
Last edited by jesolins; Oct 19, 2010 at 12:09 PM.
Reply With Quote
Old Oct 19, 2010, 05:29 PM
throw new IOPilotException();
IceWind's Avatar
Ireland, County Dublin, Dublin
Joined Feb 2005
2,691 Posts
Quote:
Originally Posted by Mike Barton View Post
Hi All
as some of you will know, kapteinkuk provided the community with his KKmulticopter creation in this (now rather long) thread.
The copter is now well supported and is simple and therefore cheap to build.
The software can be found in this thread as well as on www.kkmulticopter.com where you can find a wealth of useful information.

The original software was written in assembly, and as such, has limited the number of enhancements made to it.

I have now analysed the code and converted (copied in some cases ) it into c on the post here.
This works with the original board and as such is an alternative for the tweakers among you.
The current board layout means that no external Xtal could be used, and this has now sparked an interest in providing a modified layout.

This thread is therefore meant as a placeholder (so as not to confuse late joiners to the thread original thread) for those who wish to make alternative layouts and develop enhanced versions of the software.

I won't be pursuing this line of development myself, but as a starter for those who do, here are the rules - as I understand - which they need to consider for the schematic:
  1. The gain pots and gyro outputs must go to pins ADC0->7
  2. The RxSignals need to use PinD2 (INT0), PinD3 (INT1) and then 2 more pins which need to be from different Ports (but one can be on PortD)

For the software:
  1. Check/change timers/timings
  2. Ensure variables do not overflow due to them holding larger numbers (nb no floating point vars used)

Thumbs up Mike!
You gave me back years of life!

I was going around learning avr asm to understand the original code but having it in C that's another thing.

I will give this one a try very soon.
Thanks again.
IceWind is online now Find More Posts by IceWind
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion best firmware/software for CC180? davidleitch High Performance 128 Jan 03, 2011 07:50 AM
Discussion Computer software for electronics design\schematics and simple drawing programs ken_nj Dock Talk 9 Sep 21, 2010 03:35 PM
Discussion FREE cad software for Windows 7? High Flyin' CAD/CAM 12 Sep 17, 2010 05:18 PM
Sold KKMulticopter controller BloomingtonFPV Aircraft - Electric - Helis (FS/W) 3 Aug 24, 2010 09:55 PM