Cannot Receive Message (433Mhz) when Servo runs

Hello Guys,

i have a working system with 2x Arduino Uno. The first one sends continously values to the second one. It works fine (testing with Serial.print).

My Issue:
I want to write the values to servos. But if the servo begins to move, Arduino doesnt receive new message. It looks like he stuck in the function "myServo.write()".
For my application, it is necessary to receive as much as possible messages. So its not okay. Do you Guys know a solution?

P.s: I use "ServoTimer2.h" instead of "Servo.h" because of library-conflict with Virtualwire.

Necessary receive Code:

if (vw_get_message(buf, &buflen))   //Einlesen des Wertes und in buf speichern
    { 
        for (int i = 0; i < buflen; ++i) //Checking what the 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 this guy has the same issue:
http://forum.arduino.cc/index.php?topic=261310.0

Well, i build a 1 meter cable, so the servo is far away from the RX-Module. it doesnt make a difference to the normal 5cm cable.
So "electrical noise" can't be the reason..

The use of delay() won't help. Use millis() to manage timing without blocking as illustrated in Several Things at a Time

Why not separate the code for receiving data and the code for moving the servos into 2 separate functions. That way it may be easier to figure out the problem. See Planning and Implementing a Program

...R

A schematic would help.
Whats providing the supply voltage to the 433 Mhz receiver, and is the voltage stable when the servos are moving.

@mauried:
Hello,

The schematic is attached. I think you wanted such a drawing? I dont think that voltage could be a problem, the led blinks fine, also the on-board one.

@Robin2:
yes. The code is still in development, so i have to finish and make it more readable. but i dont think that write it in a seperate function will clear the problem :confused:
But thank you, i will have a look for your linked thread!

So any guys have some other Ideas?

Rachmaninow:
So any guys have some other Ideas?

From your diagram it looks like you are powering the servos from the Arduino 5v pin. That is almost certainly the problem. Give the servos a separate power supply with a common GND with the Arduino.

When the servos (or any motor) draw current they cause the Arduino 5v to drop and that prevents the Arduino performing properly.

...R

@Robin2

Okay thank you. I will try it with an extra voltage supply.