SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old Jun 05, 2012, 03:39 PM
M Griffith
Ecuador, Tungurahua
Joined Jun 2012
57 Posts
Mini-HowTo
Arduino and HobbyKing Multi-Rotor Control Board V3.0 or KKmulticontroller v5.5

My first post. Hello everyone.

This should be interesting to those who are into Arduino and have either the HobbyKing Multi-Rotor Control Board V3.0 or KKmulticontroller v5.5.

Once set up (and with a usbasp programmer) you can use the Arduino IDE to code and upload directly to the controller board.

Great for those who want to roll their own controller software.

Instructions, example and pin mapping below:

More detailed instructions here : http://www.rchacker.com/diy/arduino-...v3-0-atmega328

Code:
/*

  Configuring arduino dev environment for the HobbyKing Multi-Rotor Control Board V3.0 (Atmega328 PA) 
  or KKmulticontroller v.5.5 “Blackboard”
  
  using arduino 1.01
  
  and a usbasp programmer, www.fischl.de  from hobbyking
  if you are running windows you will have to install the drivers for the usbasp programmer.
  

In osx, show package contents on arduino.app. Windows I'm not sure program files or such. 
add the new board to Contents/Resources/Java/hardware/arduino/boards.txt


##############################################################

hobbyking_v3.name=Hobbyking v3.0 ATmega328

hobbyking_v3.upload.protocol=arduino
hobbyking_v3.upload.maximum_size=30720
hobbyking_v3.upload.speed=57600

#hobbyking_v3.bootloader.low_fuses=0xFF
#hobbyking_v3.bootloader.high_fuses=0xDA
#hobbyking_v3.bootloader.extended_fuses=0x05
#hobbyking_v3.bootloader.path=atmega
#hobbyking_v3.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
#hobbyking_v3.bootloader.unlock_bits=0x3F
#hobbyking_v3.bootloader.lock_bits=0x0F

hobbyking_v3.build.mcu=atmega328p
hobbyking_v3.build.f_cpu=8000000L
hobbyking_v3.build.core=arduino
hobbyking_v3.build.variant=hobbyking_v3
##############################################################



 nagivate to Contents/Resources/Java/hardware/arduino/cores/arduino/variants/standard/pins_arduino.h 
 make a new variant based on the above.  hobbyking_v3/pins_arduino.h
 add the following.
  
  const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
  // .....
  // added the below lines
  PB, 
  PB, 
  
  const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
  // .....
  // added the below lines 
  _BV(6), 
  _BV(7), 
  

  now we have digital pins 20 and 21
  
  To program select your programmer and then use upload using programmer in the file menu.
  
  Marc Griffith, 2012
  
 */
 
//spare analog pads on back should just work. 
const unsigned int PAD_A6 = A6;
const unsigned int PAD_A7 = A7;

//spare digital pads on back.
const unsigned int PAD_RX = 0;   //PD0
const unsigned int PAD_D4 = 4;  //PD4  (PCINT20/XCK/T0)

//we could also use digital 11,12,13 (MOSI,MISO,SCK) as long as no low impedence loads 
const unsigned int PIN_MOSI_D11 = 11; //PB3
const unsigned int PIN_MISO_D12 = 12; //PB4
const unsigned int PIN_SCK_D13 = 13; //PB5

//and the rest...

const unsigned int PIN_LED = 20;  //PB6
const unsigned int PIN_AIL = 1;   //PD1 (TXD)
const unsigned int PIN_ELE = 2;   //PD2
const unsigned int PIN_THR = 3;   //PD3
const unsigned int PIN_RUD = 21;  //PB7
const unsigned int PIN_M6 = 5;  //PD5
const unsigned int PIN_M5 = 6;  //PD6
const unsigned int PIN_M4 = 7;  //PD7
const unsigned int PIN_M3 = 8;  //PB0
const unsigned int PIN_M2 = 9;  //PB1
const unsigned int PIN_M1 = 10;  //PB2
const unsigned int GYR_ROL = A2;  //PC2
const unsigned int GYR_PIT = A1;  //PC1
const unsigned int GYR_YAW = A0;  //PC0
const unsigned int POT_YAW = A5;  //PC5
const unsigned int POT_PIT = A4;  //PC4
const unsigned int POT_ROL = A3;  //PC3

//some example code:
#include <Servo.h>

Servo servoOne;
Servo servoTwo;
Servo servoThree;

int temp = 0;

void setup() {                
  servoOne.attach(PIN_M1);
  servoTwo.attach(PIN_M2);  
  
  pinMode(PIN_LED,OUTPUT);

  digitalWrite(PIN_LED,HIGH);   //I am alive
  delay(10);
  digitalWrite(PIN_LED,LOW);  
 
}

void loop() {
  temp = analogRead(GYR_ROL);  
  temp = map(temp,0,1023,0,179);
  servoOne.write(temp);
  
  temp = analogRead(POT_YAW);
  temp = map(temp,0,1023,0,179);
  servoTwo.write(temp);
       
}
pprioverde is offline Find More Posts by pprioverde
Last edited by pprioverde; Aug 11, 2012 at 09:24 PM. Reason: updated to Arduino 1.01
Reply With Quote
Sign up now
to remove ads between posts
Old Jun 15, 2012, 12:41 PM
Registered User
mcashatt's Avatar
United States, AZ, Gilbert
Joined May 2012
708 Posts
Thanks!

This is JUST what I was looking for!
mcashatt is offline Find More Posts by mcashatt
RCG Plus Member
Latest blog entry: SkullCopter Labs
Reply With Quote
Old Jun 16, 2012, 09:17 AM
M Griffith
Ecuador, Tungurahua
Joined Jun 2012
57 Posts
Updated.

Got it working with Arduino 1.01. Much cleaner and has its own entry in boards.txt. See changes above. Have fun.
pprioverde is offline Find More Posts by pprioverde
Reply With Quote
Old Jul 24, 2012, 12:08 PM
Registered User
Joined Jul 2012
1 Posts
Quote:
Originally Posted by pprioverde View Post
Got it working with Arduino 1.01. Much cleaner and has its own entry in boards.txt. See changes above. Have fun.
I'm fairly new to Arduino and I'm wondering if someone can help with this.
I'm having trouble getting this in to the IDE, there has to be a simpler way to get this to work. Maybe I'm missing something in the instructions.



FYI, I'm using Ver 1.01 and Win7

Thanks...
OregonThew is offline Find More Posts by OregonThew
Reply With Quote
Old Aug 07, 2012, 11:23 PM
M Griffith
Ecuador, Tungurahua
Joined Jun 2012
57 Posts
What have you done so far? You have to edit two text files, It does not get any simpler.
I have expanded on the instructions here,

http://www.rchacker.com/diy/arduino-on-the-hobbyking-multi-rotor-control-board-v3-0-atmega328


Let me know if you still have problems.
pprioverde is offline Find More Posts by pprioverde
Last edited by pprioverde; Aug 07, 2012 at 11:28 PM.
Reply With Quote
Old Sep 04, 2012, 08:35 AM
Registered User
Akcopter's Avatar
Joined Apr 2012
524 Posts
wow !!!!!! are you saying ....you have written some arduino code for the existing kk board design........for a multi-rotor.......if so then this is just awesome...this is just what I was looking for...
Akcopter is offline Find More Posts by Akcopter
Reply With Quote
Old Sep 05, 2012, 02:30 AM
M Griffith
Ecuador, Tungurahua
Joined Jun 2012
57 Posts
Not for a multirotor as such, just for using the Arduino IDE with the kk board. I have not gone much further than reading the sensors and flashing leds but I was thinking it would be useful for other projects.
pprioverde is offline Find More Posts by pprioverde
Reply With Quote
Old Sep 05, 2012, 02:21 PM
DART
Ukraine, L'vivs'ka, L'viv
Joined Aug 2012
28 Posts
subscribed
dart50 is offline Find More Posts by dart50
Reply With Quote
Old Sep 06, 2012, 11:59 AM
Registered User
Akcopter's Avatar
Joined Apr 2012
524 Posts
But just a very dumb and out of the blue question..Is it possible to write a multirotor firmware using the arduino libraries and syntax..for the hk kk board...keeping in mind the strict EEPROM memory constraints..if it can be written it will at-least provide a ray of hope for newbie coders wanting to develop their own firmware ...I know the multiwii and APM firmwares have been written keeping the arduino hardware in mind..but what about the kk board...I dont know but I am just asking roughly what is coming to my mind......
Akcopter is offline Find More Posts by Akcopter
Reply With Quote
Old Sep 06, 2012, 12:02 PM
Registered User
Akcopter's Avatar
Joined Apr 2012
524 Posts
also how does the 8Mhz internal oscillator be compatible with the programs written for a 16Mhz arduino hardware..
Akcopter is offline Find More Posts by Akcopter
Reply With Quote
Old Sep 06, 2012, 12:12 PM
DART
Ukraine, L'vivs'ka, L'viv
Joined Aug 2012
28 Posts
Quote:
Originally Posted by Akcopter View Post
But just a very dumb and out of the blue question..Is it possible to write a multirotor firmware using the arduino libraries and syntax..for the hk kk board...keeping in mind the strict EEPROM memory constraints..if it can be written it will at-least provide a ray of hope for newbie coders wanting to develop their own firmware ...I know the multiwii and APM firmwares have been written keeping the arduino hardware in mind..but what about the kk board...I dont know but I am just asking roughly what is coming to my mind......
EEPROM is not limiting factor here. For such case I'd say that the processor speed will limit you. So if MultoWii and/or APM have comparable processor it should be possible to write such firmware.
dart50 is offline Find More Posts by dart50
Reply With Quote
Old Sep 07, 2012, 12:01 AM
Registered User
Akcopter's Avatar
Joined Apr 2012
524 Posts
thats right but the ocsillator frequency is also a deciding factor for the speed of calculations..all the arduino boards as stated earlier have a 16Mhz external oscillator which is more stable than the 8 Mhz internal Osc on the HK kk 3.0 board..even though the processor is the same will this work for half the operating frequency
Akcopter is offline Find More Posts by Akcopter
Reply With Quote
Old Sep 07, 2012, 03:46 AM
DART
Ukraine, L'vivs'ka, L'viv
Joined Aug 2012
28 Posts
Quote:
all the arduino boards as stated earlier have a 16Mhz external oscillator which is more stable than the 8 Mhz internal Osc on the HK kk 3.0 board
I'm writing my own software for HK kk 3.0 for last 2 months. Never saw any problems with oscillator frequency or stability (can anyone explain me how oscillator instability can harm flight characteristics?).
I think it will be able to fly even with Arduino. However that software will never be a best performer (maybe there will be not enough CPU speed to handle accelerometer/Bluetooth/GPS/etc.) but it is not needed if you just want to learn programming.
And you can always rewrite your SW without Arduino libraries if you want to make it run faster.
dart50 is offline Find More Posts by dart50
Reply With Quote
Old Sep 07, 2012, 09:00 AM
M Griffith
Ecuador, Tungurahua
Joined Jun 2012
57 Posts
Quote:
Originally Posted by Akcopter View Post
But just a very dumb and out of the blue question..Is it possible to write a multirotor firmware using the arduino libraries and syntax..for the hk kk board..
Absolutely, ardupilot and ardupilot-mega run on the Atmega328 and 2650 respectively. They both use Arduino and do far more than just multirotor control.

As long as you avoid floats and divides your Arduino code should perform plenty fast enough. Use hardware PWM, not software PWM for the esc's and use interrupts to capture your rc data.
Ardupilot has good libraries for this, there is even a PID library with examples.
pprioverde is offline Find More Posts by pprioverde
Reply With Quote
Old Sep 07, 2012, 09:07 AM
M Griffith
Ecuador, Tungurahua
Joined Jun 2012
57 Posts
Quote:
Originally Posted by Akcopter View Post
also how does the 8Mhz internal oscillator be compatible with the programs written for a 16Mhz arduino hardware..
Arduino code takes care of that, original arduino's were also 8Mhz.
pprioverde is offline Find More Posts by pprioverde
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Help with HobbyKing Multi-Rotor Control Board V2.1 (Atmega168PA) rpscarlets2294 Multirotor Talk 3 Nov 04, 2013 01:29 AM
Discussion !!NEW!! HobbyKing Multi-Rotor Control Board V3.0 ishaan65 Multirotor Talk 8 Jul 25, 2012 04:36 AM
Question Quad Build Using HobbyKing Multi-Rotor Control Board V3.0 (Atmega328 PA) SJackson Multirotor Talk 27 Apr 30, 2012 08:51 PM
Discussion Direction of flight on quadrocopter with KKMulticontroller V5.5 Controller Board Darn Servo ! Multirotor Talk 4 Apr 17, 2012 09:31 PM