315Mhz 2400 baud receiver/transmitter and erronous data

Hy Guys,

I have a KLP Module (transmitter/receiver) pair for sending and recieving bytes between two arduino boards. There was a lot of “noise” so i decided that I would send the same signal multiple times, and only concider it recieved if I recieved the same signal multiple times (I realize there are probably better ways of dooing this). The signals was going through with minimal loss and no noise, but ever 20th or so byte that I sent arrived completly wrong (ex, 1, 2, 3, 4, 5, 123, 6, 7) which led me to conclude that instead of the number 6 either the transmitter was sending 123 multiple times or the receiver was reading it incorrectly multiple times. I was reading other posts and I see that the receiver can take a couple of bytes to calibrate but in my expample im sending 9 and counting as recieved if i get 7 so I dont think this is my problem (at least not all of it).

Any idea what this might be/how I can solve it?

(I will also take suggestions on how to better ignore noise and make sure the signal goes through).

Using arduino decillima boards, code below (using their built in serial library):

Transmitter

byte counter;
byte count;
unsigned long time;

void setup(){
  Serial.begin(2400);
  counter = 0;
  count = 0;
  
  time = millis() + 100;
}

void loop(){
  
  
  if(millis() > time)
  {
    count = 0;
    while(count < 9)
    {
      Serial.print(counter);
      count++;
    }
    counter++;
    
    
    time = millis() + 100;
  }
}

Receiver

// temp var for storing the byte from serial.read
int incomingByte = 0;

// stores the multiple input we are waiting for
int currentByte = 0;

// stores the number of times the same input has been seen
int numCurrentBytes = 0;

void setup(){
  Serial.begin(2400);
}

void loop(){
  if(Serial.available() > 0){
    incomingByte = Serial.read();
    
    if(currentByte == incomingByte)
    {
      numCurrentBytes++;
      
      if(numCurrentBytes >= 7)
      {
        Serial.println(currentByte, DEC);
        numCurrentBytes = 0;
      }
    }
    else
    {
      numCurrentBytes = 1;
      currentByte = incomingByte;
    }
  }
}

I’m not a big RF guy, but it doesn’t look like you are using any encoding to DC balance the signal. The only work I’ve done with these cheap modules, I’ve used encoding to make sure 0’s and 1’s somewhat balance to prevent drift. Then I send in packets with CRC checks.

Otherwise, I have no idea. RF is a mad scientist realm.

send a 0x55, 0xAA first then your data.( equal amount of 1’s and 0’s)

the 0x55 = 0b01010101

the 0xAA = 0b10101010

that should synch the receiver enough to accept your data.

try it.

Poohshoes:
Hy Guys,

I have a KLP Module (transmitter/receiver) pair for sending and recieving bytes between two arduino boards. There was a lot of “noise” so i decided that I would send the same signal multiple times, and only concider it recieved if I recieved the same signal multiple times (I realize there are probably better ways of dooing this). The signals was going through with minimal loss and no noise, but ever 20th or so byte that I sent arrived completly wrong (ex, 1, 2, 3, 4, 5, 123, 6, 7) which led me to conclude that instead of the number 6 either the transmitter was sending 123 multiple times or the receiver was reading it incorrectly multiple times. I was reading other posts and I see that the receiver can take a couple of bytes to calibrate but in my expample im sending 9 and counting as recieved if i get 7 so I dont think this is my problem (at least not all of it).

Any idea what this might be/how I can solve it?

(I will also take suggestions on how to better ignore noise and make sure the signal goes through).

Using arduino decillima boards, code below (using their built in serial library):

Transmitter

byte counter;

byte count;
unsigned long time;

void setup(){
Serial.begin(2400);
counter = 0;
count = 0;

time = millis() + 100;
}

void loop(){

if(millis() > time)
{
count = 0;
while(count < 9)
{
Serial.print(counter);
count++;
}
counter++;

time = millis() + 100;

}
}




Receiver


// temp var for storing the byte from serial.read
int incomingByte = 0;

// stores the multiple input we are waiting for
int currentByte = 0;

// stores the number of times the same input has been seen
int numCurrentBytes = 0;

void setup(){
Serial.begin(2400);
}

void loop(){
if(Serial.available() > 0){
incomingByte = Serial.read();

if(currentByte == incomingByte)
{
  numCurrentBytes++;
  
  if(numCurrentBytes >= 7)
  {
    Serial.println(currentByte, DEC);
    numCurrentBytes = 0;
  }
}
else
{
  numCurrentBytes = 1;
  currentByte = incomingByte;
}

}
}

Greetings

Before your data, send some bytes to ensure the tx stability, ex. 0xcc,0xaa.

Also, implements an error detection routine, as CRC or something, so you can check data integrity in receiver side.

Best regards

The modules are notorious for dropping bits at the start.

As you are using Arduino, check out the VirtualWire library

http://www.open.com.au/mikem/arduino/VirtualWire.pdf

http://www.arduino.cc/cgi-bin/yabb2/YaB … 8473338/13

Manchester code is usually needed for sending data reliably with those modules.

Leon

Yeah, manchester is good idea.

Note that you are probably just seeing interference. There are lots of things transmitting in that frequency range. Even with a carefully balanced transmission encoding, you will see interference. You will NEVER get 100% reliable transmission via RF. Heck, it’s hard to get 100% with wired comm.

Your best bet is to put an error checking scheme in place. CRC or checksum is a very good idea. Then you can reject the error packets.

I don’t think he’s coming back.

I like that VirtualWire library. I’m trying to dissect it, as my own routines for this are not all that robust.