Jitter on a Relay Module when I turn on my 433 Mhz transmitter

Hi,

I am trying to control a remote control car with a relay module (4 relays), two arduino units, and a 433 Mhz transmitter using the VirtualWire library. It almost works however one of the relay modules jitters, for a reason I cannot figure out. Forward and reverse work fine, though they are a bit delayed, however left and right are not working well.

The relay is connected to two 5v regulators for power (one of them gets hot). When the transmitter is not on there is no jitter. When I turn the transmitter on, one of the two relays that controls left and right jitters on and off. I am using a paralax joystick to send the signals from the arduino to the transmitter.

Here is my code

/*James Stenquist
08/07/2014
arduino remote control for RC car etc*/
/*using paralax joystick
433 Mhz transmitter receiver modules*/

//VirtualWire library and example code used written by
//Mike McCauley (mikem@open.com.au)

//Using code edited by Kyle Fieldus
//https://www.youtube.com/watch?v=U839NZ78EOo

//libraries
#include <VirtualWire.h>

//pins
int leftRightIn = 0; //analog pin
int upDownIn = 1; //analog pin
int transmit = 12;

//global vars
int leftRight = 0;
int upDown = 0;
int count = 0;


void setup()
{
  Serial.begin(9600);	  // Debugging only
    Serial.println("setup");
  
  // Initialise the IO and ISR
  vw_set_tx_pin(transmit);          // Sets pin D12 as the TX pin
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	 // Bits per sec
}

void loop()
{
    leftRight = analogRead(leftRightIn);
    upDown = analogRead(upDownIn);
    
    char * msg = "hello";
    
    if(leftRight > 600)
    {msg[0] = '1';
    msg[1] = '1';}
    else if (leftRight < 470)
    {msg[0] = '1';
    msg[1] = '3';}
    else {
      msg[0] = '1';
      msg[1] = '2';}

    //digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    //digitalWrite(13, false);
    delay(50);
    
    Serial.print("leftRight ");
    Serial.print(msg[0]);
    Serial.println(msg[1]);
    
    if(upDown > 570)
    {msg[0] = '2';
    msg[1] = '1';
    }
    else if(upDown < 450)
    {msg[0] = '2';
    msg[1] = '3';
    }
    else{msg[0] = '2';
    msg[1] = '2';
    }
    
    //digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg, strlen(msg));
    vw_wait_tx(); // Wait until the whole message is gone
    //digitalWrite(13, false);
    delay(100);
    
    /*Serial.print("upDown ");
    Serial.print(msg[0]);
    Serial.println(msg[1]);
    
    count ++;
    Serial.println(count);
    delay(10);*/
}
// receiver.pde
//
// Simple example of how to use VirtualWire to receive messages
// Implements a simplex (one-way) receiver with an Rx-B1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: receiver.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

//edits by James Stenquist and previous edits by Kyle Feildus

#include <VirtualWire.h>

//pins
const int receiving = 12;
const int thf = 3;
const int thr = 5;
const int wr = 13;
const int wl = 6;

//global vars
int count;
char firstChar;
char secondChar;



void setup()
{
    Serial.begin(9600);	// Debugging only
    Serial.println("setup"); //Prints "Setup" to the serial monitor
    vw_set_rx_pin(12);       //Sets pin D12 as the RX Pin
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);	     // Bits per sec
    vw_rx_start();       // Start the receiver PLL running
    
    pinMode(thr, OUTPUT);
    pinMode(thf, OUTPUT);
    pinMode(wr, OUTPUT);
    pinMode(wl, OUTPUT);  
    
    
}

void loop()
{
    
    
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;
        digitalWrite(13, true);  // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
            char c = (buf[i]);
            Serial.print(c);
	    Serial.print(" ");
	}
        count++;
        Serial.print(count);
	Serial.println("");
        digitalWrite(13, false);
        
        /*James S main additions*/
        firstChar = buf[0];
        secondChar = buf[1];
    }
    
    Serial.print("second char is ");
    Serial.println(secondChar);
    
    //left and right
    if(firstChar == '1')
    {
     Serial.println("using first char");
     
      if(secondChar == '1')
       {
        digitalWrite(wr , HIGH);
        digitalWrite(wl, LOW);
        Serial.println("char 11 is working");
       }
      else if(secondChar == '2')
       {
        digitalWrite(wr, LOW);
        digitalWrite(wl, LOW);
        Serial.println("what is going on here?");
        }
      else if (secondChar == '3')
       {
         digitalWrite(wr, LOW);
         digitalWrite(wl, HIGH);  
         Serial.println("char 13 is working");      
       } 
    }
    //forward and reverse
    else if(firstChar == '2')
    {
      Serial.println("using second char");
      if(secondChar == '1')
       {
        digitalWrite(thf , HIGH);
        digitalWrite(thr, LOW);
         Serial.println("char 21 is working");   
       }
      else if(secondChar == '2')
       {
        digitalWrite(thf, LOW);
        digitalWrite(thr, LOW);
        }
      else if (secondChar == '3')
       {
         digitalWrite(thf, LOW);
         digitalWrite(thr, HIGH);
          Serial.println("char 23 is working");           
       } 
    }
    delay (1);
}

You need to isolate the relay jitter to hardware or software. If your arduino output pin that controls the relay with the jitter has a led connected to it (preferably driven by a transistor), then if the led blinks when the jitter occurs then the arduino output is turning on the relay causing the jitter. If you use a pulldown resistor on the output pin that controls the relay and the jitter goes away then it is probably software .

I can't help you with the software but I would recommend using electrolytic filter caps on your power bus. You haven't posted a schematic so we don't know how you are powering your transmitter. If you draw a schematic by hand and post a photo of it then we can discuss that.

Not sure how to insert an image, however the arduino is powered by a 9v battery. The arduino powers the joystick with 5v and the transmitter with 5v. The signals from the joystick go in pins a0 and a1. Pin 13 is the data pin for the transmitter.

Move the transmitter power to the 9V bus. The transmitter can operate up to 12V (but the receiver only 5V). Your transmitter may be loading down your 5V logic bus. Besides, moving the input voltage for the transmitter from 5V to 9V means in an increase in range which is almost double .

are you using antennas ?

There is an antenna on the receiver but not on the transmitter. I put a 4.7 k ohm resistor to ground on the offending relay and the jitter is still going, the light on the relay module is blinking on and off.

What is strange to me is forward and reverse are working fine however left is jittery and right is fine.

The person who had written the code before me had pin 13 going on then off when the car was receiving. This was one of the turning signals to the car too.

A transmitter without an antenna can damage itself esp. if run at max voltage. It can also pull far more current since the antenna is not matched to the output stage. 1/4 wavelength at 433MHz is 17.3cm

You can coil the Tx antenna but Rx should be straight.