tnx . i will be great because this code is just for one channel and im sure i f go to edit this i will screw the code and everything go wrong smiley-grin .

Sure I can write the pin-change-interrupt explanation, but I'm going to use my quadcopter code as an example (Arduino Leonardo).. Meaning it won't work on the UNO... If you only got 4 channels you can go with a Arduino Leonardo (it has 5 external interrupts) or Arduino Mega (has 6 external interrupts) and reuse my example code that I posted above... if you don't want to buy another board you can use this library which makes PC-Interrupts look like a walk in the park..The library for the pin-change-interrupts will simplify a lot and make the code look like the example I posted..Here is the library: https://code.google.com/p/arduino-pinchangeint/

But seriously, you clearly need to read and look at the different examples/tutorials in this forum and out there(internet of things).. I wouldn't mind writing the whole thing for you, but that won't teach you anything!

If you'd like, write your sketch and try it out and in-case it doesn't work and you've tried everything you can, post it here.. We would be more than happy to help you out..

void rxGoesHigh(){ pinMode (YOUR_OUTPUT_PIN, OUTPUT);/* As soon as we get into this function we measure the current time (with micros) and put that value in our variable rxPrev. After that we re-attach the same interrupt but this time we want it to fire when the pin goes low "FALLING". When that happens it will call the function rxGoesLow */ rxPrev=micros();

attachInterrupt(RX_INT_PIN_THROTTLE,rxGoesLow,FALLING);}void rxGoesLow(){/* As soon as we get into this function we measure the current time (with micros) and subtract the previous time (rxPrev). By doing that we will get the length of the pulse,from start to the end. We end this process by re-attaching the throttle pin to a RISING interrupt, which will repeat the process again... */ rxVal=micros()-rxPrev; attachInterrupt(RX_INT_PIN_THROTTLE,rxGoesHigh,RISING);

}

void setup(){attachInterrupt(RX_INT_PIN_THROTTLE,rxGoesHigh,RISING); /*We begin by attaching a interruptto the throttle pin. the interrupt will fire when the pin goes high "RISING" (meaning the start of the pulse). When that happens it will call the function rxGoesHigh.*/}void loop(){//Nothing to do here!int out = map(rxVal,1000,2000,0,255);analogWrite(YOUR_OUTPUT_PIN,out);}

i done this and i got some signals on pin 11 it is my ppm signal from receiver http://i44.tinypic.com/2v2ffb4.jpg

and it is what i got after your code combinationhttp://i44.tinypic.com/2qs9wcy.jpg

i was wrong after i change the throtle on radio and signal never changes and when i unpluged the receiver the signal i had signal from pin 11 still like befor showing on scope

ya because you changed the interrupt pin number.. And why did you put pinMode (YOUR_OUTPUT_PIN, OUTPUT); in the interrupt routine??? You only have 2 interrupts on the UNO.. They have the numbers 0 and 1 and are located on pins (2 and 3).. so in the code change the number 3 to a 1 and leave everything as is.. I've fixed the sketch for you... Here is the code, just copy paste and run it..

void rxGoesHigh(){/* As soon as we get into this function we measure the current time (with micros) and put that value in our variable rxPrev. After that we re-attach the same interrupt but this time we want it to fire when the pin goes low "FALLING". When that happens it will call the function rxGoesLow */ rxPrev=micros();

attachInterrupt(RX_INT_PIN_THROTTLE,rxGoesLow,FALLING);}void rxGoesLow(){/* As soon as we get into this function we measure the current time (with micros) and subtract the previous time (rxPrev). By doing that we will get the length of the pulse,from start to the end. We end this process by re-attaching the throttle pin to a RISING interrupt, which will repeat the process again... */ rxVal=micros()-rxPrev; attachInterrupt(RX_INT_PIN_THROTTLE,rxGoesHigh,RISING);

}

void setup(){pinMode (YOUR_OUTPUT_PIN, OUTPUT);attachInterrupt(RX_INT_PIN_THROTTLE,rxGoesHigh,RISING); /*We begin by attaching a interruptto the throttle pin. the interrupt will fire when the pin goes high "RISING" (meaning the start of the pulse). When that happens it will call the function rxGoesHigh.*/}void loop(){//Nothing to do here!int out = map(rxVal,1000,2000,0,255);analogWrite(YOUR_OUTPUT_PIN,out);}

Edit: If this still doesn't work for you, I need you to show me how you hooked everything up.. Just draw a simple schematic.. And can you give me the name of your receiver/transmitter??? Just want to check and make sure that it's really PPM we are talking about..

i tired your code this happend .... befor i connect receiver to pin1(tx) it has signal and after i connect signal it has change unormally and brushless motor dont work

i upload video of process ... befor and after i connect receiver to arduino uno

Looking at the video I see that the duty cycle is changing from zero to 100%.. That means that it was hooked right the first time.. Did you read what I wrote in the previous post? Why did you connect the receiver to pin 1?? The code is calling for interrupt 1.. And interrupt 1 is on PIN 3.. Forget about the brushless motor for a second.. Connect the output (pin 11) to the oscilloscope and connect the receiver signal to PIN 3 on the UNO.. Dont change anything in the code, and reupload and test it again.. If you get the same results as in the video, then connect the output (PIN 11) to the ESC input signal and try again.. (Dont forget to connect the GND of the ESC to the GND on arduino)..

When you first start up the ESC remember to put the throttle on 0% (stick all the way down) for at least 3-5 seconds before fiddling with it..

Edit: If you got propellers on then remove them.. We don't want you to lose a finger now do we..?

yummmyyyyyy it seem work fine in the scope .... its late here and i cant start esc's bbeeping in home tomorrow morning i will test it ..... if it works fine i will start study arduino tommorow hardly .... .... <3 <3

yummmyyyyyy it seem work fine in the scope .... its late here and i cant start esc's bbeeping in home tomorrow morning i will test it ..... if it works fine i will start study arduino tommorow hardly .... .... <3 <3

For those following this: I've updated the code.. Made the sketch run more efficiently and reduced code size.. With this change I managed to find better PID values and thus get better/faster stabilization.. For those interested I've added pictures of the main board and hardware setup (see first post)..

Now this question made me sad.. Because it means that you didn't read through my code correctly.. Let me explain how my closed-loop works..I got 2 loops, yes, one is as you called it position loop (angle loop) and the other one is the rate loop.. But I like to also call them the slow/outer loop (angle) and the fast/inner loop (rate)..I just drew a "map" in paint (MsPaint > PhotoShop =P) to make the process clear.. As you can see in the map, PID-rate is part of the inner loop which in turn controls the motors directly.. The reason for this is because of the update rate (400Hz) which is close to the motors PWM refresh rate (~480 to 500Hz)..The PID-angle is part of the outer loop (because it's slow approx. 50Hz), which corresponds to the receiver refresh rate which in fact is 50Hz also! So PID-angle is like an auto-pilot for the position of the copter.. So to answer your question: You have to tune the rate-PID before the angle-PID!.. If the rate-PID isn't stable you won't get a stable copter with the angle-PID!

Note: I didn't read or see your code (something wrong with github, keep getting errors when I try to open your files).. My answer above assumes that you have one inner loop and one outer loop! Two separate inner loops will only lead to a slow response from the quadcopter which in turn will lead to bad PID values, which in turn will make the quadcopter uncontrollable in harsh environments!

How did you actually do your tuning? Did you put your quad on some sort of ball joint ? Or did you hold it in your hand ?

A ball joint would be the safest way.. But because I don't have a ball joint, I used a FAN-stand, like the one on this: http://www.tradeindeed.com/images/Stand-Fan_482-700.gif And tied the copter to the stand top.. When I got the copter pretty stable, I took it out of the stand and held it in my hand during fine tuning (DON'T RECOMMEND THIS, I still got a bunch of scars all over my arms!)