Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 17
61  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: November 28, 2013, 06:20:50 pm
First off, I want to apologize for the people waiting for the UNO/MEGA versions of this code.. I have a lot going on right now and simply not a lot of free time to work with this.. But I'm still open to answer any questions when I have time, so if any volunteers want to take a shot "like Elmardus" and write a UNO/MEGA version, then please go ahead, and I'll try to help along as much as I possibly can..

@Elmardus: I took a quick look around the code you wrote/changed.. And I have some feedback... First off, I'm happy that it didn't arm because if it did, that would have been dangerous.. The reason? Is the delay(3000) you put in "BlueCopter.ino" under setup().. If you want to initiate something and throw something out through serial and follow up with a delay then please do it before the following line: tp=millis(); or move tp=millis(); down to the very last line in the setup() section.. tp=millis() defines the start time-point for all of the PID's in the system... So if you follow up with a delay and the quadcopter moves/shakes or whatever when it's about to leave that delay, that will result in a huge controller output (which in a worst case scenario equals to the quadcopter running the motors at the current speed plus approx. 30-40%)..

Now as I said, I didn't read the whole thing, but just skipped through to the important parts.. I will assume that you know your way around timers, so I skipped checking the initializing part.. Now the reason it didn't arm can be many.. Let me start by asking you a couple of questions:

- Did you get your receiver code to work properly?
- If it is working, does the values that is in rxVal hit the proper configured intervals?? If you don't know which intervals I'm talking about then look in "Config.h" under RX Config, section.. You'll see for example, THROTTLE_RMIN, THROTTLE_RMAX, which means throttle read minimum and throttle read maximum.. Which corresponds to the minimum and maximum values possible in rxVal.. You'll have to read the RAW data coming from your controller with your code "of course" and type these values in the corresponding macro-variables..
- When all your controller macro-variables is set try to arm it again.. If it still doesn't work then try reading the output of the throttle during run-time.. Because the SAFE procedure uses the throttle value to arm/un-arm the quadcopter.. The arming procedure is in FlightCtrl.ino and Motor.ino and looks like this:

#ifdef SAFE

So as you see if the throttle raw value is under 1100ms then the quadcopter won't start! You can change these values if you'd like, or try to tune your controller output to somewhere in that range..

Edit: One more question, is your ESC calibrated for the PWM range of 125 to 254?? What ESC are you using?? Do they support PWM at a frequency of 480-500Hz??

62  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: November 04, 2013, 07:10:27 pm
For the rate, I can go up to 450Hz now.
Getting the angles, integrating the gyro rates, using atan2 for acc values and finally using a complementary filter takes most of my loop time. I think you did a pretty good optimasation job in your code!

For reading the acc, I think I will read it at 450Hz too but then use a low-pass filter and use the filtered data in the Angle Control Loop at 50Hz only.

All sounds good! Hope you have a video for us with the first-flight soon =)!

63  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: November 03, 2013, 02:30:10 pm
hey you seem pretty well knowledged with this topic. I was wondering if the pin layout would be same for an Arduino Uno.

Hey, this code only works on the arduino leonardo (for the moment).. I'm working on a version for the UNO.. Stay tuned!

I am not that experienced on this stuff, i can not order the parts yet. If I have an Arduino Uno as an interface board (seperate from control board of quadcopter) what type of signal will it have to put out to control the quadcopter.

Would it be PPM?

There is no such feature in the code.. It is really up to you and what you want to implement..

64  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: November 03, 2013, 01:11:09 pm
hey you seem pretty well knowledged with this topic. I was wondering if the pin layout would be same for an Arduino Uno.

Hey, this code only works on the arduino leonardo (for the moment).. I'm working on a version for the UNO.. Stay tuned!

65  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: November 03, 2013, 10:19:38 am
I was also thinking, could I use PPM? I have a dragonlink receiver that can output 12ch PPM or so. I have been looking how to implement that into your code, but I haven't managed to do that yet. Would then PPM only use 1 interrupt instead of 4?

Would that be an easier solution?

My code already use PPM.. I think what you meant is PPM-sum.. Which means that you have all the channel-signals sent with one wire... Well, it is easy to program, but I'm going to re-use as much as I can of the existing code.. So I'm not going to write it, sorry  smiley-roll-blue .. Maybe something for you to work out smiley-wink?

66  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: November 03, 2013, 08:55:42 am
Is it a lot of work for you to rewrite? I was looking at MultiWii, but the code is not very easy to understand.


Well, I'm not very sure, didn't look directly at the differences.. But from the top of my head, I know that the receiving end needs a rewrite.. Everything else, I believe can be left as is.. I need to map all the available ports and see what needs to be changed.. I'll report back when I have something! =)

MultiWii, isnt meant to be understood =P! it's more a software LEGO.. Where you give it your available hardware (in config).. And everything else will be generated (macros) based on your choices... It's simple really..

67  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 31, 2013, 06:55:25 pm
I don't understand. These are only the times for reading the RAW values for the IMU. It is normal that it takes the same time to read 3 RAW gyro values or 3 RAW acc values!?

Well, I wasn't talking about the time it takes to make an actual read.. If you want to read the data with 100, 400 or 1000 kHz is up to you and what the hardware can handle.. But what I meant is the time between each read, and that should be 1/50 seconds for the acc. and 1/800 for the rate..

68  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 31, 2013, 05:30:58 pm
Woow that's fast..  (I am a bit jealous since we use the same microcontroller  smiley ). But ESCs refresh update rate are generally around 500Hz, so more than 500Hz is unnecessary?

The rate update rate is 800Hz, going through a moving average filter which slows the update to 400Hz smiley-wink.. Which is a bit slower than the maximum update rate for the ESC.. You see what I did there smiley-wink!?

1140 microsec to read either the 3 gyro values or the 3 acc values => 880Hz
1980 microsec to read the six values => 505Hz
Do you have something like that?

The micros sounds about right, for the gyro that is.. For the acc. it should be slower.. You shouldn't read the acc. more than 50 times per second (50Hz).. So it is not only the "angle-PID" calculations that you do 50 times per second, but actually the reading of the acc. itself also! Reading the acc. more than 50 times per second will lead to a lot of "gibberish" numbers..

If you want to keep reading the acc. that fast then i'd suggest that you put some kind of filter in code (I myself am using a first order low pass filter), just to smooth the output..

The MPU6050 is a good gyro+acc.. Actually better than what I'm using L3G4200D+ADXL345.. Are you doing all the math in your code, or are you using something included in the library (you know calculating angles and such)?


69  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 31, 2013, 11:20:03 am
Thanks for the quick answer again!

So ok you update your rate values at 300Hz and your angle values at 50Hz. When I looked at the main arduino loop:

Yes, the angle update freq. is 50Hz.. The rate update rate is 800Hz, reread the code smiley-wink

It appears to me that you run FlightControl() even if the values (rates or angles) haven't change. I find this kinda strange.

Strong point there! If you think of it, it's both dumb and smart at the same time smiley.. The reason it is dumb is that you, as you said, run it even when the values haven't changed yet.. The reason it's smart: You save code space! Because it takes a few extra lines of code, to make the same "time check" procedure for the flightcontrol.. And I chose to optimize my code based on size, both to make it simple for the reader to follow along and to kind of compete with the exiciting open source solutions smiley-wink...What if I put a "time check" there, what will I gain? Maybe better accuracy in the scale of microseconds.. But believe me, you don't need that kind of accuracy for perfectly stable flight!

Another thing, so let's say you rate update frequency is 300Hz and angle frequency is 50Hz. So you will update like this:

update rate 1

In my case the update angle takes some times (reading the accelero values) and I am not too sure if between update rate 6 and update rate 7 there will be really 1/300Hz = 3 mili sec. Did you have the same problem? Like when you update your angle, your rate update frequency will be a bit slower.

I hope this makes sense for you!

You shouldn't have that kind of delay.. Did you initialize your accelerometer right? Because, the accelerometer will update its values once each 1/50 seconds.. But the communication between the accelerometer and Arduino has a speed of atleast 100kHz (I2C)... So you should not get that kind of delay.. I don't know if you read my last post, but I gave you a tip to use micros() instead of millis() for the rate loop, when it comes to the "time-check".. So instead of 1000/FREQ, you'll have 1000000/FREQ..

If you don't figure out the reason for the problem, please post your code, so I can take a look at it.. Also, what kind of IMU are you using?

70  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 30, 2013, 07:00:12 pm
So my problem is that, for now, both loops run at the same frequency (around 200Hz). The inner loop could run alone at (I guess) around 300Hz. And I would like the outer loop to run at around 50Hz. But I don't know how to structure my code to obtain this. I looked at your code, but it's not very clear to me how you do it.


Well I do it by reading millis() and comparing that to the value 1000/FREQ (which equals to the duration of each loop in milliseconds).. For example:


#define RATE_FREQ  300 //Hz
#define ANGLE_FREQ  50 //Hz

long prevRate=millis();
long prevAngle=millis();

void updateValues(){

    //Run rate specific function
    prevRate = millis();

    //Run Angle specific function
    prevAngle = millis();


void setup() {               


void loop() {

if you want to see it in my code, then look in the Sensor.ino (

On lines 15 (rate) and 19(angle)...

If you have further questions feel free to ask =)!

Edit: Just a small tip.. Use Micros for things with high frequency, like the rate loop.. Just to get better accuracy when it comes to timing =)!

71  Using Arduino / Microcontrollers / Re: About to give up using TQFP atmega's, they just don't work! on: October 24, 2013, 11:56:47 am
Sorry for the late reply. The pcb is powered from my arduino so it's the same ground. I have pads connected to TX, RX and RST with a hole through them, wires are soldered to these pads and connected directly to my arduino. I don't have a rst cap, but I've honestly never had a problem with this before (my DIP chips don't need them at least)..

You need the reset cap.. without it the mcu will stay in the reset state (because serial is pulling the reset low while it is open! )... The cap will allow the the reset pin to go low for a brief moment (until it is charged via the 10K resistor connected to Vcc and rst) before it gets charged and goes high..

Try this to test if the missing cap is the problem: disconnect the DTR pin and manually reset the mcu before uploading.. did it work? In that case put the cap where it belongs smiley

72  Topics / Science and Measurement / Re: 9 Degree of Freedom on: October 23, 2013, 06:03:54 am
Hi Baselsw,
do you have any example code or libraries for this sensor?

Sure thing.. Here is my library..

You'll also find example code in the library =).. The library doesn't support the BMP085 yet.. So you can get the values from the accelerometer, gyrometer and magnetometer.. The reason for the lack of support for the BMP085 is that I haven't had any use for it yet.. Maybe in the future =)!

73  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 18, 2013, 09:22:04 am
    I am sankha. i made qudocopter using Arduino mega board. i am trying to make that using this code. but this code has compiling errors and i cant to find circuit diagram..... please help me to bild ub this qudo copter..... thank you.   


I've provided the circuit for the different connections in the attachment of my first post.. So go back and look at it.. The code is written for the arduino leonardo/micro.. And won't work out of the box with the mega..

I've got a lot of private messages like this, where people have tried getting this code running on boards other than leonardo/micro..
I'll rewrite/add the missing pieces, to the code in-order for it to work with the UNO and MEGA if I can get any volunteers that can test the code for me on their quadcopters..

74  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 15, 2013, 03:02:21 pm
i can unchange the pins but the uno dont have more than 13 pins ...

4 pins for the motors, 4 for the receiver, and 2 for the I2C.. that's 10 pins.. how many do you need??

75  Community / Exhibition / Gallery / Re: BlueCopter - Arduino Quadcopter on: October 15, 2013, 03:14:03 am
i changed the motors to 3 9 10 11 pins
and throttle to pin 2 and other 3channel to 4 5 6
i think the interupt of arduino is pins 3 isnt it ?

I'm currently at work.. But i'll look at it as soon as I get home.. Will you be so kind and post all your code changes so I can take a look at them??? Just zip the whole project and post it here...

Edit: Just got back from work.. i looked over your pin choices.. Well yes the interrupts are on pin 2 and 3.. So that also means that you can't use pin 3 for one of the motors.. Why not leave the motor pins as is??? Did you write a new interrupt routine for the receiver? Because the current one won't work on the UNO..

Pages: 1 ... 3 4 [5] 6 7 ... 17