SMALL - espritmodel.com SMALL - Telemetry SMALL - Radio
Reply
Thread Tools
Old May 07, 2012, 11:37 AM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
Help!
Programing my Arduino to listen my receiver

Hello,

I just bought a Arduino duemilanove, I'm a very-beginner in C++ and micro-controller too, but I have serious experience with managing technical projects.

So I'd like too share my project with everyone and hope some "Big Boss" will kindly help me, if they wants.

Here is my current code :

Code:
#include <Servo.h> 
#include <EEPROM.h> 

// Attribution des N° de PIN
const int ledO =  13, ledR =  12,buttonPin = 7;
const int Ch1 = 2, Ch2 = 3, Ch3 = 4;

// Delais de la boucle MAIN
const int freq= 0;

// Déclaration du servo et ses variables
Servo myservo;
const unsigned int ServMin = 45, ServMax= 135;
unsigned int ServPos;

// Variable pour faire clignoter la LED
int ledState = LOW, buttonState = LOW;     
unsigned long MillDeb, MillFin, LoopPer, previousMillis = 0;

//Structure Channel
struct Limits {
  unsigned int Min;
  unsigned int Center;
  unsigned int Max;
};

// Variables lié au signaux radio
unsigned int Ch1Pos=1500, Ch2Pos=1500, Ch3Pos=1500;
int val;

//lecture des paramètres dans l'EEPROM
Limits Cha1 = { 
  word(EEPROM.read(0),EEPROM.read(1)),word(EEPROM.read(2),EEPROM.read(3)), word(EEPROM.read(4),EEPROM.read(5))                           };
Limits Cha2 = { 
  word(EEPROM.read(6),EEPROM.read(7)),word(EEPROM.read(8),EEPROM.read(9)), word(EEPROM.read(10),EEPROM.read(11))                         };
Limits Cha3 = { 
  word(EEPROM.read(12),EEPROM.read(13)),word(EEPROM.read(14),EEPROM.read(15)), word(EEPROM.read(16),EEPROM.read(17))                            };

// Fonction pour fait clignoter une seule LED au choix
void BlinkLed(const int BLed,int BDelay)
{
  int Bdelay;
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > BDelay) {
    previousMillis = currentMillis;   
    if (ledState == LOW) ledState = HIGH;
    else       ledState = LOW;
    digitalWrite(BLed, ledState);
  }
}

void setup() 
{ 
  //Déclaration des entrées/sorties
  pinMode(ledO, OUTPUT);
  pinMode(ledR, OUTPUT);
  pinMode(buttonPin, INPUT);

  myservo.attach(9);
  Serial.begin(38400);

  //On lit une fois le canal 1
  buttonState = digitalRead(buttonPin);

  //Ici on rentre en parametrage si le bouton est appuyé au démarrage
  if (buttonState ==LOW)  {
    while  (buttonState == LOW) {
      BlinkLed(ledR,50);
      buttonState = digitalRead(buttonPin);
    }
    digitalWrite(ledR, LOW);

    // Ici on entre dans une phase de calibrage des min/max des 3 canaux
    // Il faudra presser le bouton

    while (buttonState ==HIGH)
    {
      buttonState = digitalRead(buttonPin);
      Ch1Pos = pulseIn(Ch1, HIGH, 20000);
      Ch2Pos = pulseIn(Ch2, HIGH, 20000);
      Ch3Pos = pulseIn(Ch3, HIGH, 20000);

      val = Ch1Pos;
      if (val > Cha1.Max) Cha1.Max = val;
      if (val<Cha1.Min) Cha1.Min=val;
      val = Ch2Pos;
      if (val > Cha2.Max) Cha2.Max = val;
      if (val<Cha2.Min) Cha2.Min=val;
      val = Ch3Pos;
      if (val > Cha3.Max) Cha3.Max = val;
      if (val<Cha3.Min) Cha3.Min=val;

      // On envoi les valeurs MIN & MAX sur le port Série pendant toute la phase calibrage
      Serial.print(Cha1.Min);
      Serial.print("\t");
      Serial.print(Cha1.Max);
      Serial.print("\t");
      Serial.print(Cha2.Min);
      Serial.print("\t");
      Serial.print(Cha2.Max);
      Serial.print("\t");
      Serial.print(Cha3.Min);
      Serial.print("\t");
      Serial.println(Cha3.Max);

      // La LED orange clignote rapidement pendant cette phase
      BlinkLed(ledO,50);
    }

    // Centrage de voies
    while  (buttonState == LOW) {
      BlinkLed(ledR,50);
      buttonState = digitalRead(buttonPin);
    }
    digitalWrite(ledR, LOW);
    while (buttonState ==HIGH)
    {
      buttonState = digitalRead(buttonPin);
      Ch1Pos = pulseIn(Ch1, HIGH, 20000);
      Ch2Pos = pulseIn(Ch2, HIGH, 20000);
      Ch3Pos = pulseIn(Ch3, HIGH, 20000);
      Cha1.Center = Ch1Pos;
      Cha2.Center = Ch2Pos;
      Cha3.Center = Ch3Pos;

      // On envoi les valeurs Centrage sur le port Série pendant toute la phase calibrage
      Serial.print(Cha1.Center);
      Serial.print("\t");
      Serial.print(Cha2.Center);
      Serial.print("\t");
      Serial.println(Cha3.Center);

      // La LED orange clignote rapidement pendant cette phase
      BlinkLed(ledO,50);
    }

    // Ecriture des paramètres dans l'EEPROM
    Serial.println("Parametre ecrits dans l'EEPROM");

    EEPROM.write(0,(Cha1.Min >> 8) & 0xff);
    EEPROM.write(1,Cha1.Min & 0xff);
    EEPROM.write(2,(Cha1.Center >> 8) & 0xff);
    EEPROM.write(3,Cha1.Center & 0xff);
    EEPROM.write(4,(Cha1.Max >> 8) & 0xff);
    EEPROM.write(5,Cha1.Max & 0xff);
    
    EEPROM.write(6,(Cha2.Min >> 8) & 0xff);
    EEPROM.write(7,Cha2.Min & 0xff);
    EEPROM.write(8,(Cha2.Center >> 8) & 0xff);
    EEPROM.write(9,Cha2.Center & 0xff);
    EEPROM.write(10,(Cha2.Max >> 8) & 0xff);
    EEPROM.write(11,Cha2.Max & 0xff);
    
    EEPROM.write(12,(Cha3.Min >> 8) & 0xff);
    EEPROM.write(13,Cha3.Min & 0xff);
    EEPROM.write(14,(Cha3.Center >> 8) & 0xff);
    EEPROM.write(15,Cha3.Center & 0xff);
    EEPROM.write(16,(Cha3.Max >> 8) & 0xff);
    EEPROM.write(17,Cha3.Max & 0xff);

  }
  else { 

    Serial.println("Parametre lu dans l'EEPROM");

  }

  Serial.print("\t");
  Serial.print(Cha1.Min);
  Serial.print("\t");
  Serial.print(Cha1.Center);
  Serial.print("\t");
  Serial.println(Cha1.Max);
  Serial.print("\t");
  Serial.print(Cha2.Min);
  Serial.print("\t");
  Serial.print(Cha2.Center);
  Serial.print("\t");
  Serial.println(Cha2.Max);
  Serial.print("\t");
  Serial.print(Cha3.Min);
  Serial.print("\t");
  Serial.print(Cha3.Center);
  Serial.print("\t");
  Serial.println(Cha3.Max);

  delay(1000);

}


void loop() 
{ 
  //On regarde la montre
  MillDeb = millis();

  // Om mesure les 3 canaux
  Ch1Pos = pulseIn(Ch1, HIGH, 20000);
  Ch2Pos = pulseIn(Ch2, HIGH, 20000);
  Ch3Pos = pulseIn(Ch3, HIGH, 20000);

  // Si la valeur du canal 1 est délirante (hors de la plage 500-2500), on allume la LED rouge et met le Servo à 90
  if (Ch1Pos<500||Ch1Pos>2500) {
    digitalWrite(ledR  , HIGH);
    ServPos=90;
    myservo.write(ServPos);
  }
  else {
    // Sinon, on éteint la LED rouge et on mappe la valeur du Servo en fonction du canal 2
    digitalWrite(ledR  , LOW);
    ServPos=map(Ch2Pos,Cha2.Min,Cha2.Max,ServMin,ServMax);
    ServPos=constrain(ServPos,ServMin,ServMax); // on contrain la valeur aux max du servos
    myservo.write(ServPos); // On positionne le servo
  }

  // On envoi les valeurs de canaux et la position du Servo sur le port série
  Serial.print(Ch1Pos);   
  Serial.print("\t");     
  Serial.print(Ch2Pos);   
  Serial.print("\t");     
  Serial.print(Ch3Pos);      
  Serial.print("\t");        
  Serial.print(ServPos);  

  // Petit délais, plutot pour faire des tests.
  delay (freq);

  // On fait clignoter la LED lentement (BlinkLow)
  BlinkLed(ledO,500);

  //On regarde la montre et on mesure le temps de la boucle
  MillFin = millis();
  LoopPer = MillFin - MillDeb;

  // On envoi la durée de la boucle sur le port série
  Serial.print("\t");         
  Serial.print(LoopPer);    
  Serial.println("\t");
}
Here some graphics made with the serial-printed values :

Please add 1400 to have the real channel values

I don't understand why my values are moving like that !!

What I'm currently studying :
- Try to listen receiver with some Timer and PIND, and forgot the pulseIn command

PS : Sorry for my poor english and for the french comments in the code, I was not prepared for international
unisev is offline Find More Posts by unisev
Reply With Quote
Sign up now
to remove ads between posts
Old May 07, 2012, 04:12 PM
どうもありがとうミスターロボット
Wrend's Avatar
United States, IL
Joined Jul 2009
3,063 Posts
You might find this link helpful: http://rcarduino.blogspot.com/2012/0...iver-with.html
Wrend is offline Find More Posts by Wrend
Reply With Quote
Old May 09, 2012, 06:21 AM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
New orientation

Yes it is !!

I read lots of things, and Miru explain some others by MP, so my new orientation is :

Quote:
Var declaration :
Set volatile var : Up[x] and ChannelValue[x] where x is the pin where receiver are connected.
- We can directely initialise ChannelValue[4, 5 & 6] to 1500

Interrupt param :
- Enable a Interrupt services on many pins on PORTD (4 ,5 & 6 as example)

Main code :
Checking if ChannelValue are (500< <2500) AND Up is not too old
Use ChannelValue as you want
else activate "failsafe" function
Interrupt code :
If pin[x]==HIGH Up[x]=micros()
else ChannelValue[x]=micros()-Up(x)

Failsage function :
Activate a RED LED
PUT all channels to middle
Does the interrupt code know the port that as triggered it ? (x in my example)

This is just an idea, not the code, does it seems possible ?
unisev is offline Find More Posts by unisev
Reply With Quote
Old May 09, 2012, 10:25 AM
Registered User
Joined May 2012
14 Posts
Reading Multiple RC Channels With Micro Controller

Hi,
Why not just do it like this -

http://rcarduino.blogspot.com/2012/0...els-draft.html

Duane B

rcarduino.blogspot.com
DuaneB is offline Find More Posts by DuaneB
Reply With Quote
Old May 09, 2012, 11:25 AM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
I'm currently trying this beautiful code, but my motivations are :
  • To use a single interruption routine --> hope it will be lighter for the processor...
  • I don't understand the flag utility... so I prefer to do not use it for the moment
  • In case of wrong value because of a read/write access to variable at the same time, prefer to "forget" a bad mesured value than use "detachinterrupt"

Not good reasons ?
unisev is offline Find More Posts by unisev
Reply With Quote
Old May 09, 2012, 12:48 PM
Registered User
Joined May 2012
14 Posts
Hi,

Not really good reasons, they won't make anything faster or safer. As you mention you are a beginner I won't bore you with the reasons, other than to say I have considered most of the alternatives on the way to arriving at this code and as one of the comments from someone using my code states -

Quote:
I really like your code and I think you did a great job and it works perfectly.
I can post an expanded version of the code which includes error handling I would suggest that you never 'forget' bad values in an autonomous project, you don't want to watch as 100's of dollars and hours of your project time smashes itself to pieces because you never told it not to.

If you keep the code as it is on my blog, you can replace the contents of loop from this comment onwards with whatever you need your project to do. If you don't want to use the flags you don't need to but dont take them out of the other parts of the code.

Replace after this with whatever you want -
Quote:
// do any processing from here onwards
// only use the local values unAuxIn, unThrottleIn and unSteeringIn, the shared
// variables unAuxInShared, unThrottleInShared, unSteeringInShared are always owned by
// the interrupt routines and should not be used in loop
Duane B.

rcarduino.blogspot.com
DuaneB is offline Find More Posts by DuaneB
Reply With Quote
Old May 09, 2012, 07:17 PM
どうもありがとうミスターロボット
Wrend's Avatar
United States, IL
Joined Jul 2009
3,063 Posts
Hey Duane. Welcome to RCG!

Small world for us hobbyists, isn't it?

...

Oh, minor spelling error I found on your page there: "How do but flags work ?"

Thanks for all your efforts. They're both educational and very useful for me, and I'm sure many others as well.
Wrend is offline Find More Posts by Wrend
Last edited by Wrend; May 09, 2012 at 08:29 PM.
Reply With Quote
Old May 10, 2012, 03:44 AM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
Hey Duane, I just test your code and this pretty good job !
I'm experiencing high response time, except on the Aux channel, is there a reason ?

I've try to move INPUT PIN to another "known worked well" pin, but this always the AuxChannel that is lagging, I don't find anything in the code that can explain that.
unisev is offline Find More Posts by unisev
Reply With Quote
Old May 10, 2012, 11:08 AM
Registered User
Joined May 2012
14 Posts
Hi,
To anyone else that is interested, I am continuing this discussion with unisev on the original blog post in order that anyone else using the code now or in the future can follow.

Duane B
DuaneB is offline Find More Posts by DuaneB
Reply With Quote
Old May 10, 2012, 02:38 PM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
Thank you Duane,

I've posted on your blog but my serialoutput is too long, so I put it here :

UpTHro =ulThrottleStart
CalcThro=unThrottleInShared
UpAux=ulAuxStart
CalcAux=unAuxInShared

Code:
UpThro:	0	CalcThro:	0	UpAux:	0	CalcAux:	972
	UpThro:	0	CalcThro:	1468	UpAux:	3410548	CalcAux:	1472
	UpThro:	3451984	CalcThro:	1968	UpAux:	3453980	CalcAux:	1472
	UpThro:	3516356	CalcThro:	1972	UpAux:	3518380	CalcAux:	1472
	UpThro:	3580756	CalcThro:	1968	UpAux:	3582780	CalcAux:	1472
	UpThro:	3645156	CalcThro:	1968	UpAux:	3647180	CalcAux:	1468
	UpThro:	3709556	CalcThro:	1972	UpAux:	3711580	CalcAux:	1468
	UpThro:	3773956	CalcThro:	1968	UpAux:	3775980	CalcAux:	1468
	UpThro:	3838356	CalcThro:	1972	UpAux:	3840384	CalcAux:	1468
	UpThro:	3902760	CalcThro:	1972	UpAux:	3904780	CalcAux:	1468
	UpThro:	3967156	CalcThro:	1972	UpAux:	3969184	CalcAux:	1468
	UpThro:	4031560	CalcThro:	1972	UpAux:	4033584	CalcAux:	1468
	UpThro:	4095960	CalcThro:	1960	UpAux:	4097984	CalcAux:	1472
	UpThro:	4160360	CalcThro:	1968	UpAux:	4162384	CalcAux:	1468
	UpThro:	4224760	CalcThro:	1972	UpAux:	4226788	CalcAux:	1472
	UpThro:	4289164	CalcThro:	1968	UpAux:	4291192	CalcAux:	1468
	UpThro:	4353564	CalcThro:	1972	UpAux:	4355588	CalcAux:	1468
	UpThro:	4417964	CalcThro:	1968	UpAux:	4419988	CalcAux:	1472
	UpThro:	4482364	CalcThro:	1968	UpAux:	4484388	CalcAux:	1468
	UpThro:	4546764	CalcThro:	1972	UpAux:	4548792	CalcAux:	1468
	UpThro:	4611168	CalcThro:	1968	UpAux:	4613188	CalcAux:	1476
	UpThro:	4675568	CalcThro:	1968	UpAux:	4677592	CalcAux:	1468
	UpThro:	4739972	CalcThro:	1968	UpAux:	4741992	CalcAux:	1468
	UpThro:	4804368	CalcThro:	1968	UpAux:	4806392	CalcAux:	1472
	UpThro:	4868768	CalcThro:	1968	UpAux:	4870792	CalcAux:	1452
	UpThro:	4933168	CalcThro:	1972	UpAux:	4935196	CalcAux:	1468
	UpThro:	4997572	CalcThro:	1956	UpAux:	4999596	CalcAux:	1468
	UpThro:	5061972	CalcThro:	1972	UpAux:	5063996	CalcAux:	1468
	UpThro:	5126376	CalcThro:	1972	UpAux:	5128400	CalcAux:	1468
	UpThro:	5190788	CalcThro:	1968	UpAux:	5192800	CalcAux:	1468
	UpThro:	5255176	CalcThro:	1968	UpAux:	5257200	CalcAux:	1472
	UpThro:	5319576	CalcThro:	1968	UpAux:	5321600	CalcAux:	1468
	UpThro:	5383976	CalcThro:	1968	UpAux:	5386004	CalcAux:	1468
	UpThro:	5448380	CalcThro:	1968	UpAux:	5450404	CalcAux:	1472
	UpThro:	5512780	CalcThro:	1972	UpAux:	5514808	CalcAux:	1472
	UpThro:	5577184	CalcThro:	1964	UpAux:	5579208	CalcAux:	1472
	UpThro:	5641592	CalcThro:	1956	UpAux:	5643608	CalcAux:	1472
	UpThro:	5705996	CalcThro:	1952	UpAux:	5708008	CalcAux:	1460
	UpThro:	5770400	CalcThro:	1944	UpAux:	5772408	CalcAux:	1468
	UpThro:	5834812	CalcThro:	1936	UpAux:	5836812	CalcAux:	1468
	UpThro:	5899216	CalcThro:	1932	UpAux:	5901212	CalcAux:	1468
	UpThro:	5963624	CalcThro:	1928	UpAux:	5965612	CalcAux:	1472
	UpThro:	6028028	CalcThro:	1924	UpAux:	6030012	CalcAux:	1468
	UpThro:	6092432	CalcThro:	1912	UpAux:	6094412	CalcAux:	1472
	UpThro:	6156848	CalcThro:	1900	UpAux:	6158816	CalcAux:	1468
	UpThro:	6221260	CalcThro:	1900	UpAux:	6223216	CalcAux:	1472
	UpThro:	6285660	CalcThro:	1888	UpAux:	6287620	CalcAux:	1468
	UpThro:	6350072	CalcThro:	1880	UpAux:	6352020	CalcAux:	1468
	UpThro:	6414476	CalcThro:	1872	UpAux:	6416432	CalcAux:	1468
	UpThro:	6478900	CalcThro:	1872	UpAux:	6480832	CalcAux:	1472
	UpThro:	6543308	CalcThro:	1876	UpAux:	6566720	CalcAux:	1468
	UpThro:	6607716	CalcThro:	1848	UpAux:	6609632	CalcAux:	1468
	UpThro:	6672124	CalcThro:	1832	UpAux:	6674032	CalcAux:	1468
	UpThro:	6736540	CalcThro:	1816	UpAux:	6738436	CalcAux:	1468
	UpThro:	6800956	CalcThro:	1808	UpAux:	6802836	CalcAux:	1468
	UpThro:	6865372	CalcThro:	1796	UpAux:	6867236	CalcAux:	1468
	UpThro:	6929780	CalcThro:	1788	UpAux:	6931640	CalcAux:	1468
	UpThro:	6994180	CalcThro:	1780	UpAux:	6996040	CalcAux:	1472
	UpThro:	7058592	CalcThro:	1772	UpAux:	7060440	CalcAux:	1468
	UpThro:	7122996	CalcThro:	1764	UpAux:	7124840	CalcAux:	1468
	UpThro:	7187404	CalcThro:	1760	UpAux:	7189240	CalcAux:	1468
	UpThro:	7251812	CalcThro:	1748	UpAux:	7253640	CalcAux:	1468
	UpThro:	7316224	CalcThro:	1744	UpAux:	7318040	CalcAux:	1472
	UpThro:	7380628	CalcThro:	1748	UpAux:	7403920	CalcAux:	1472
	UpThro:	7445044	CalcThro:	1736	UpAux:	7446840	CalcAux:	1472
	UpThro:	7509448	CalcThro:	1728	UpAux:	7511240	CalcAux:	1468
	UpThro:	7573856	CalcThro:	1716	UpAux:	7575636	CalcAux:	1468
	UpThro:	7638260	CalcThro:	1716	UpAux:	7640036	CalcAux:	1468
	UpThro:	7702668	CalcThro:	1708	UpAux:	7704436	CalcAux:	1468
	UpThro:	7767068	CalcThro:	1704	UpAux:	7768836	CalcAux:	1468
	UpThro:	7831476	CalcThro:	1696	UpAux:	7833232	CalcAux:	1468
	UpThro:	7895884	CalcThro:	1688	UpAux:	7940560	CalcAux:	1472
	UpThro:	7960308	CalcThro:	1688	UpAux:	7962032	CalcAux:	1468
	UpThro:	8024692	CalcThro:	1688	UpAux:	8026432	CalcAux:	1468
	UpThro:	8089092	CalcThro:	1688	UpAux:	8090832	CalcAux:	1468
	UpThro:	8153488	CalcThro:	1688	UpAux:	8155232	CalcAux:	1472
	UpThro:	8217896	CalcThro:	1704	UpAux:	8241120	CalcAux:	1468
	UpThro:	8282288	CalcThro:	1688	UpAux:	8284032	CalcAux:	1472
	UpThro:	8346688	CalcThro:	1692	UpAux:	8348428	CalcAux:	1472
	UpThro:	8411084	CalcThro:	1692	UpAux:	8412828	CalcAux:	1472
	UpThro:	8475484	CalcThro:	1688	UpAux:	8477224	CalcAux:	1468
	UpThro:	8539884	CalcThro:	1692	UpAux:	8541624	CalcAux:	1472
	UpThro:	8604280	CalcThro:	1688	UpAux:	8606020	CalcAux:	1468
	UpThro:	8668680	CalcThro:	1692	UpAux:	8670420	CalcAux:	1460
	UpThro:	8733080	CalcThro:	1692	UpAux:	8734820	CalcAux:	1468
	UpThro:	8797476	CalcThro:	1688	UpAux:	8799216	CalcAux:	1468
	UpThro:	8861880	CalcThro:	1688	UpAux:	8863620	CalcAux:	1468
	UpThro:	8926276	CalcThro:	1692	UpAux:	8928020	CalcAux:	1468
	UpThro:	8990676	CalcThro:	1688	UpAux:	8992416	CalcAux:	1468
	UpThro:	9055072	CalcThro:	1688	UpAux:	9056816	CalcAux:	1468
	UpThro:	9119472	CalcThro:	1692	UpAux:	9121216	CalcAux:	1468
	UpThro:	9183872	CalcThro:	1692	UpAux:	9185612	CalcAux:	1468
	UpThro:	9248272	CalcThro:	1688	UpAux:	9250012	CalcAux:	1468
	UpThro:	9312668	CalcThro:	1688	UpAux:	9314412	CalcAux:	1468
	UpThro:	9377068	CalcThro:	1692	UpAux:	9378808	CalcAux:	1468
	UpThro:	9441468	CalcThro:	1692	UpAux:	9443208	CalcAux:	1468
	UpThro:	9505864	CalcThro:	1688	UpAux:	9507608	CalcAux:	1468
	UpThro:	9570264	CalcThro:	1692	UpAux:	9572008	CalcAux:	1472
	UpThro:	9634664	CalcThro:	1692	UpAux:	9636408	CalcAux:	1468
	UpThro:	9699064	CalcThro:	1692	UpAux:	9700808	CalcAux:	1468
	UpThro:	9763464	CalcThro:	1692	UpAux:	9765204	CalcAux:	1468
	UpThro:	9827864	CalcThro:	1692	UpAux:	9829600	CalcAux:	1472
	UpThro:	9892260	CalcThro:	1688	UpAux:	9894000	CalcAux:	1460
	UpThro:	9956660	CalcThro:	1672	UpAux:	9958400	CalcAux:	1468
	UpThro:	10021056	CalcThro:	1692	UpAux:	10022800	CalcAux:	1468
	UpThro:	10085452	CalcThro:	1688	UpAux:	10087196	CalcAux:	1464
	UpThro:	10149848	CalcThro:	1692	UpAux:	10151596	CalcAux:	1468
	UpThro:	10235760	CalcThro:	1692	UpAux:	10215992	CalcAux:	1468
	UpThro:	10300160	CalcThro:	1692	UpAux:	10280392	CalcAux:	1464
	UpThro:	10364556	CalcThro:	1692	UpAux:	10344788	CalcAux:	1468
	UpThro:	10428956	CalcThro:	1692	UpAux:	10409188	CalcAux:	1464
	UpThro:	10493352	CalcThro:	1692	UpAux:	10473584	CalcAux:	1468
	UpThro:	10557752	CalcThro:	1692	UpAux:	10537980	CalcAux:	1464
	UpThro:	10622156	CalcThro:	1692	UpAux:	10666788	CalcAux:	1468
	UpThro:	10686556	CalcThro:	1692	UpAux:	10731184	CalcAux:	1468
	UpThro:	10750952	CalcThro:	1692	UpAux:	10795580	CalcAux:	1472
	UpThro:	10815348	CalcThro:	1692	UpAux:	10859980	CalcAux:	1472
	UpThro:	10901192	CalcThro:	1688	UpAux:	10924376	CalcAux:	1468
	UpThro:	10965588	CalcThro:	1692	UpAux:	10988792	CalcAux:	1468
	UpThro:	11029988	CalcThro:	1692	UpAux:	11053172	CalcAux:	1468
	UpThro:	11094384	CalcThro:	1692	UpAux:	11117568	CalcAux:	1468
	UpThro:	11158780	CalcThro:	1692	UpAux:	11181968	CalcAux:	1472
	UpThro:	11223180	CalcThro:	1688	UpAux:	11246364	CalcAux:	1472
	UpThro:	11287576	CalcThro:	1692	UpAux:	11310764	CalcAux:	1472
	UpThro:	11351976	CalcThro:	1692	UpAux:	11375164	CalcAux:	1492
	UpThro:	11416376	CalcThro:	1688	UpAux:	11439560	CalcAux:	1468
	UpThro:	11480772	CalcThro:	1688	UpAux:	11525440	CalcAux:	1472
	UpThro:	11566616	CalcThro:	1688	UpAux:	11568356	CalcAux:	1472
	UpThro:	11631016	CalcThro:	1688	UpAux:	11632756	CalcAux:	1468
	UpThro:	11695412	CalcThro:	1684	UpAux:	11697156	CalcAux:	1468
	UpThro:	11759816	CalcThro:	1676	UpAux:	11761552	CalcAux:	1468
	UpThro:	11824220	CalcThro:	1660	UpAux:	11825952	CalcAux:	1468
	UpThro:	11888624	CalcThro:	1668	UpAux:	11890352	CalcAux:	1468
	UpThro:	11953028	CalcThro:	1664	UpAux:	11954752	CalcAux:	1472
	UpThro:	12017432	CalcThro:	1664	UpAux:	12062080	CalcAux:	1472
	UpThro:	12081828	CalcThro:	1664	UpAux:	12083548	CalcAux:	1472
	UpThro:	12146228	CalcThro:	1660	UpAux:	12147948	CalcAux:	1464
	UpThro:	12232140	CalcThro:	1660	UpAux:	12212344	CalcAux:	1468
	UpThro:	12296548	CalcThro:	1660	UpAux:	12276744	CalcAux:	1468
	UpThro:	12360944	CalcThro:	1656	UpAux:	12341144	CalcAux:	1464
	UpThro:	12425344	CalcThro:	1652	UpAux:	12405540	CalcAux:	1468
	UpThro:	12489748	CalcThro:	1652	UpAux:	12469940	CalcAux:	1464
	UpThro:	12554144	CalcThro:	1648	UpAux:	12534336	CalcAux:	1468
	UpThro:	12618544	CalcThro:	1652	UpAux:	12663132	CalcAux:	1468
	UpThro:	12682948	CalcThro:	1648	UpAux:	12727536	CalcAux:	1468
	UpThro:	12747344	CalcThro:	1648	UpAux:	12791936	CalcAux:	1468
	UpThro:	12811748	CalcThro:	1644	UpAux:	12856332	CalcAux:	1468
	UpThro:	12897588	CalcThro:	1648	UpAux:	12920728	CalcAux:	1472
	UpThro:	12961988	CalcThro:	1644	UpAux:	12985128	CalcAux:	1468
	UpThro:	13026388	CalcThro:	1640	UpAux:	13049528	CalcAux:	1468
	UpThro:	13090788	CalcThro:	1640	UpAux:	13113924	CalcAux:	1468
	UpThro:	13155188	CalcThro:	1636	UpAux:	13178324	CalcAux:	1472
	UpThro:	13219592	CalcThro:	1632	UpAux:	13242724	CalcAux:	1468
	UpThro:	13283996	CalcThro:	1628	UpAux:	13307120	CalcAux:	1468
	UpThro:	13348396	CalcThro:	1628	UpAux:	13371520	CalcAux:	1468
	UpThro:	13412792	CalcThro:	1628	UpAux:	13435924	CalcAux:	1472
	UpThro:	13477192	CalcThro:	1628	UpAux:	13500316	CalcAux:	1468
	UpThro:	13563036	CalcThro:	1624	UpAux:	13564716	CalcAux:	1468
	UpThro:	13627432	CalcThro:	1620	UpAux:	13629108	CalcAux:	1464
	UpThro:	13691832	CalcThro:	1620	UpAux:	13693508	CalcAux:	1468
	UpThro:	13756236	CalcThro:	1616	UpAux:	13757904	CalcAux:	1468
	UpThro:	13820636	CalcThro:	1608	UpAux:	13822300	CalcAux:	1468
	UpThro:	13885032	CalcThro:	1604	UpAux:	13886700	CalcAux:	1472
	UpThro:	13949436	CalcThro:	1608	UpAux:	13994016	CalcAux:	1472
	UpThro:	14013836	CalcThro:	1604	UpAux:	14015492	CalcAux:	1472
	UpThro:	14078232	CalcThro:	1604	UpAux:	14079888	CalcAux:	1488
	UpThro:	14142628	CalcThro:	1600	UpAux:	14144284	CalcAux:	1468
	UpThro:	14228548	CalcThro:	1596	UpAux:	14208684	CalcAux:	1464
	UpThro:	14292944	CalcThro:	1588	UpAux:	14273084	CalcAux:	1464
	UpThro:	14357356	CalcThro:	1580	UpAux:	14337476	CalcAux:	1464
	UpThro:	14421764	CalcThro:	1572	UpAux:	14401876	CalcAux:	1468
	UpThro:	14486164	CalcThro:	1580	UpAux:	14509200	CalcAux:	1464
	UpThro:	14550568	CalcThro:	1564	UpAux:	14595068	CalcAux:	1468
	UpThro:	14614968	CalcThro:	1560	UpAux:	14659468	CalcAux:	1464
	UpThro:	14679372	CalcThro:	1556	UpAux:	14723868	CalcAux:	1468
	UpThro:	14743772	CalcThro:	1552	UpAux:	14788268	CalcAux:	1468
	UpThro:	14808172	CalcThro:	1548	UpAux:	14852664	CalcAux:	1468
	UpThro:	14894016	CalcThro:	1544	UpAux:	14917060	CalcAux:	1468
	UpThro:	14958412	CalcThro:	1540	UpAux:	14981460	CalcAux:	1468
	UpThro:	15022812	CalcThro:	1536	UpAux:	15045856	CalcAux:	1468
	UpThro:	15087212	CalcThro:	1552	UpAux:	15110320	CalcAux:	1468
	UpThro:	15151636	CalcThro:	1540	UpAux:	15110320	CalcAux:	1472
	UpThro:	15216032	CalcThro:	1532	UpAux:	15110320	CalcAux:	1472
	UpThro:	15280436	CalcThro:	1528	UpAux:	15110320	CalcAux:	1472
	UpThro:	15344828	CalcThro:	1528	UpAux:	15110320	CalcAux:	1468
	UpThro:	15409228	CalcThro:	1528	UpAux:	15110320	CalcAux:	1468
	UpThro:	15473628	CalcThro:	1528	UpAux:	15110320	CalcAux:	1468
	UpThro:	15559544	CalcThro:	1524	UpAux:	15110320	CalcAux:	1468
	UpThro:	15623944	CalcThro:	1520	UpAux:	15110320	CalcAux:	1460
	UpThro:	15688340	CalcThro:	1520	UpAux:	15110320	CalcAux:	1468
	UpThro:	15752740	CalcThro:	1520	UpAux:	15754272	CalcAux:	1468
	UpThro:	15817140	CalcThro:	1512	UpAux:	15754272	CalcAux:	1468
	UpThro:	15881536	CalcThro:	1512	UpAux:	15754272	CalcAux:	1468
	UpThro:	15945932	CalcThro:	1508	UpAux:	15754272	CalcAux:	1472
	UpThro:	16010332	CalcThro:	1508	UpAux:	15754272	CalcAux:	1468
	UpThro:	16074728	CalcThro:	1508	UpAux:	15754272	CalcAux:	1468
	UpThro:	16160572	CalcThro:	1508	UpAux:	15754272	CalcAux:	1468
	UpThro:	16224968	CalcThro:	1512	UpAux:	15754272	CalcAux:	1468
	UpThro:	16289368	CalcThro:	1508	UpAux:	15754272	CalcAux:	1468
	UpThro:	16353764	CalcThro:	1512	UpAux:	15754272	CalcAux:	1468
	UpThro:	16418160	CalcThro:	1512	UpAux:	15754272	CalcAux:	1472
	UpThro:	16482556	CalcThro:	1512	UpAux:	15754272	CalcAux:	1468
	UpThro:	16546956	CalcThro:	1508	UpAux:	15754272	CalcAux:	1468
	UpThro:	16611352	CalcThro:	1512	UpAux:	15754272	CalcAux:	1468
	UpThro:	16675748	CalcThro:	1512	UpAux:	16720240	CalcAux:	1472
	UpThro:	16740144	CalcThro:	1512	UpAux:	16720240	CalcAux:	1468
	UpThro:	16825984	CalcThro:	1512	UpAux:	16720240	CalcAux:	1472
	UpThro:	16890384	CalcThro:	1512	UpAux:	16720240	CalcAux:	1468
	UpThro:	16954780	CalcThro:	1512	UpAux:	16956320	CalcAux:	1468
	UpThro:	17019180	CalcThro:	1504	UpAux:	17020704	CalcAux:	1468
	UpThro:	17083576	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17147972	CalcThro:	1492	UpAux:	17020704	CalcAux:	1468
	UpThro:	17212372	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17276768	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17341168	CalcThro:	1512	UpAux:	17020704	CalcAux:	1472
	UpThro:	17405560	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17491476	CalcThro:	1512	UpAux:	17020704	CalcAux:	1472
	UpThro:	17555872	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17620268	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17684668	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17749064	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17813464	CalcThro:	1512	UpAux:	17020704	CalcAux:	1468
	UpThro:	17877860	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	17942260	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18006656	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18071056	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18156896	CalcThro:	1512	UpAux:	17879400	CalcAux:	1472
	UpThro:	18221296	CalcThro:	1512	UpAux:	17879400	CalcAux:	1472
	UpThro:	18285692	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18350088	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18414484	CalcThro:	1512	UpAux:	17879400	CalcAux:	1476
	UpThro:	18478884	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18543284	CalcThro:	1508	UpAux:	17879400	CalcAux:	1468
	UpThro:	18607684	CalcThro:	1512	UpAux:	17879400	CalcAux:	1468
	UpThro:	18672080	CalcThro:	1512	UpAux:	18716568	CalcAux:	1484
	UpThro:	18736476	CalcThro:	1512	UpAux:	18716568	CalcAux:	1472
	UpThro:	18822316	CalcThro:	1512	UpAux:	18716568	CalcAux:	1468
	UpThro:	18886716	CalcThro:	1512	UpAux:	18716568	CalcAux:	1468
	UpThro:	18951112	CalcThro:	1512	UpAux:	18716568	CalcAux:	1468
	UpThro:	19015512	CalcThro:	1512	UpAux:	18716568	CalcAux:	1468
	UpThro:	19079908	CalcThro:	1512	UpAux:	18716568	CalcAux:	1472
	UpThro:	19144304	CalcThro:	1532	UpAux:	19167360	CalcAux:	1468
	UpThro:	19208700	CalcThro:	1512	UpAux:	19167360	CalcAux:	1468
	UpThro:	19273100	CalcThro:	1512	UpAux:	19167360	CalcAux:	1468
	UpThro:	19337496	CalcThro:	1512	UpAux:	19167360	CalcAux:	1472
	UpThro:	19401896	CalcThro:	1512	UpAux:	19167360	CalcAux:	1468
	UpThro:	19487804	CalcThro:	1516	UpAux:	19167360	CalcAux:	1472
	UpThro:	19552204	CalcThro:	1512	UpAux:	19167360	CalcAux:	1468
	UpThro:	19616604	CalcThro:	1508	UpAux:	19167360	CalcAux:	1468
	UpThro:	19681000	CalcThro:	1508	UpAux:	19167360	CalcAux:	1468
	UpThro:	19745400	CalcThro:	1512	UpAux:	19167360	CalcAux:	1472
	UpThro:	19809796	CalcThro:	1512	UpAux:	19167360	CalcAux:	1472
	UpThro:	19874192	CalcThro:	1512	UpAux:	19167360	CalcAux:	1472
	UpThro:	19938588	CalcThro:	1508	UpAux:	19167360	CalcAux:	1468
	UpThro:	20002988	CalcThro:	1508	UpAux:	19167360	CalcAux:	1472
	UpThro:	20067384	CalcThro:	1508	UpAux:	19167360	CalcAux:	1468
	UpThro:	20153228	CalcThro:	1508	UpAux:	19167360	CalcAux:	1460
	UpThro:	20217628	CalcThro:	1500	UpAux:	19167360	CalcAux:	1464
	UpThro:	20282028	CalcThro:	1500	UpAux:	19167360	CalcAux:	1468
	UpThro:	20346424	CalcThro:	1500	UpAux:	19167360	CalcAux:	1464
	UpThro:	20410820	CalcThro:	1500	UpAux:	19167360	CalcAux:	1464
	UpThro:	20475220	CalcThro:	1500	UpAux:	19167360	CalcAux:	1464
	UpThro:	20539616	CalcThro:	1500	UpAux:	19167360	CalcAux:	1468
	UpThro:	20604016	CalcThro:	1500	UpAux:	19167360	CalcAux:	1480
	UpThro:	20668412	CalcThro:	1500	UpAux:	19167360	CalcAux:	1468
	UpThro:	20732808	CalcThro:	1500	UpAux:	20777280	CalcAux:	1468
	UpThro:	20818644	CalcThro:	1500	UpAux:	20777280	CalcAux:	1472
	UpThro:	20883044	CalcThro:	1500	UpAux:	20777280	CalcAux:	1468
	UpThro:	20947444	CalcThro:	1500	UpAux:	20927520	CalcAux:	1468
Maybe the "GoingUp Aux signal" is "masked" by the "GoingDown Throttle signal", is this possible ?
unisev is offline Find More Posts by unisev
Last edited by unisev; May 11, 2012 at 05:45 AM.
Reply With Quote
Old May 12, 2012, 07:36 AM
Registered User
Joined May 2012
14 Posts
Hi,
I have replied on my blog but to keep anyone else up to date, I was able to reproduce your problem on a breadboard set up. The Aux channel would sometimes respond immediately, at other times there would be a two second or more delay. After some investigation I narrowed this down to a bad connection on my breadboard. This is also consistent with the serial output you have provided where there are periods during which no incoming signal is being received.

Duane B

http://rcarduino.blogspot.com
DuaneB is offline Find More Posts by DuaneB
Reply With Quote
Old May 14, 2012, 04:29 AM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
I'll check connections.

Here is the video.
unisev is offline Find More Posts by unisev
Reply With Quote
Old May 15, 2012, 04:56 PM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
Hey Duane, you were totally right from the begining !!

My 3ch Rx has a very strange 3rd channel, I've done a test with the original 8ch Rx and everything is okay... the strange thing is that this funny channel perfectly works with a servo.

I now can understand why I crashed my plane (Radjet 800) with this kind of receiver...

Thank you for all your help.

Sev
unisev is offline Find More Posts by unisev
Reply With Quote
Old May 16, 2012, 03:35 PM
Registered User
Joined May 2012
14 Posts
Arduino RC Code In Action

Hi,
Here is a very simple RC Robot I have put together using the code from my blog.

http://rcarduino.blogspot.com/2012/0...ino-robot.html

As you can see I have added features to the code to drive an L293DNE motor driver IC and also added mappings to drive the tracked vehicle in one of three steering modes depending on the level of throttle input.

I will put the code up tomorrow or over the weekend.

Duane B

rcarduino.blogspot.com
DuaneB is offline Find More Posts by DuaneB
Reply With Quote
Old Jun 04, 2012, 05:58 PM
Registered User
unisev's Avatar
Joined Sep 2011
54 Posts
Some news...

Hello,

First, here is a new data analysis of my code (taken from DuaneB code without flag management) :

1400 have been stolen on each channel

The 4µs resolution is clearely visible.

This is really more precise than PulseIn AND this code lets the arduino works when there is no Rx events.

The only problem for me is the 4µs precision from the micros() command, this is making some kind of "leap year" problem.

I'm designing my project, here is the needed background :


I hope there is no conflict between micros() command and servo library.

But in order to solve the 4µs precision problem, I'm thinking about to use my own timer (2MHz or 1MHz), greatly Miru inspirated :


I hope my timer will let the servo library works... maybe I should not use servo library and make my own servo management.

In order to do that, I need to learn more about Arduino register (I should write Atmega register), maybe the datasheet will be my next book to eat.

Sev
unisev is offline Find More Posts by unisev
Reply With Quote
Reply


Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Question Program/configure ESC with Arduino bogophan Multirotor Talk 12 Jun 28, 2012 07:28 PM
Help! 1st Arduino nano quad copter build need help programming thorek Multirotor Talk 6 Mar 26, 2012 04:54 PM
Discussion Multiwii Arduino Programming dyarrow Multirotor Talk 3 Mar 07, 2012 11:50 AM
Discussion Engine Run In program using Arduino board cadzilla DIY Electronics 4 Aug 16, 2010 09:21 PM