Cannot Receive Message (433Mhz) when Servo runs


hello guys,

i have working system 2x arduino uno. first 1 sends continously values second one. works fine (testing serial.print).

my issue:
i want write values servos. if servo begins move, arduino doesnt receive new message. looks stuck in function "myservo.write()".
for application, necessary receive as possible messages. not okay. guys know solution?


p.s: use "servotimer2.h" instead of "servo.h" because of library-conflict virtualwire.


necessary receive code:

code: [select]
if (vw_get_message(buf, &buflen))   //einlesen des wertes und in buf speichern
    {
        (int = 0; < buflen; ++i) //checking buffer holds
        {
         if(i<buflen-2)  //nur die ersten 4 zeichen auslesen; 2 weglassen (.0)
           {           
            rx_data = buf[i] - '0';           //umwandeln des ascii-wertes in reele zahl {z.b. '9' = 57(ascii), '0' = 48(ascii) --> rxdata = 57 - 48 = 9}
            value += rx_data * pow(10,3-i);   //potenzieren der einzelnen werte mit 10^3, 10^2, 10^1 bzw. 10^0
           }
        }

        //auswerten des streams
        value -= 2000;                        //2000 offset subtrahieren
        if(value <= 360)                      //abfrage ob compassdata
        {
          value_comp = value;                 //abspeichern in value_comp
        }
        else                                  //wenn nicht compassdata, dann neigungsdata
        {
          value -= 1000;                      //weitere 1000 offset subtrahieren, da sicher neigungsdata
          value_neig = value;                 //abspeichern in value_neig
        }

       
        //kompass-ausrichtung
        if(value_comp > -90 && value_comp <90){
          send_comp = map(value_comp, -90, 90, 750, 2250);    //servo skalierung

          if(oldcompass < send_comp){
            for(oldcompass; oldcompass <= send_comp; oldcompass+=5){
              servo1.write(oldcompass);
              delay(10);
            }
          }
          else if(oldcompass > send_comp){
            for(oldcompass; oldcompass >= send_comp; oldcompass-=5){
              servo1.write(oldcompass);
              delay(10);
            }
          }
        oldcompass = send_comp;
        }
        else if (value_comp <= -90){
          servo1.write(750);
        }
        else if (value_comp >= 90){
          servo1.write(2250);
        }
        else{
          servo1.write(750);
        }



i think guy has same issue:
http://forum.arduino.cc/index.php?topic=261310.0

well, build 1 meter cable, servo far away rx-module. doesnt make difference normal 5cm cable.
so "electrical noise" can't reason..

the use of delay() won't help. use millis() manage timing without blocking illustrated in several things @ time


why not separate code receiving data , code moving servos 2 separate functions. way may easier figure out problem. see planning , implementing program

...r


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > Cannot Receive Message (433Mhz) when Servo runs


arduino

Comments