Pages: [1] 2   Go Down
Author Topic: 433MHz RX/TX question, Manchester encoding  (Read 5180 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I have bought this 433MHz ASK transceiver link kit.
Now, with Arduino, I want to send signals with these modules.

At first, to analyse, I've built the following:
Receiver: Vcc to 5V, GND to GND, out-Data to pin10(shouldnt matter which pin to use)
Transmitter: Vcc to 5V, GND to GND, in-Data via a button to 5v and a in-data via a resistor to GND (look picture)

That means:
- I press the button: transmitter gets 5V as input
- I dont press the button: transmitter gets 0V as input

Then I wrote a simple program to check what is received (because it's ASK modulation, it should be 5V or 0V (proved with analog in))
I used "digitalRead" and  looked for changes, that means, in the loop , i have:
Code:
void loop()
{
  int nowstate = digitalRead(pin);

  if (nowstate != laststate)
  {
    Serial.println(micros());
    laststate = nowstate;
  }
}

The results are the x-values for a graph


Why is it always up and down when I send nothing?
How can I receive/send signals  and read them?

Thank you


« Last Edit: September 20, 2012, 10:13:17 am by karlok » Logged

using Arduino Uno Rev 3

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 179
Posts: 8067
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

16 mS cycle time is 62.5 Hz.  If the pulse width is actually 8.333... milliseconds instead of 8.0 then you are probably picking up interference from something running off 60Hz AC.

Because the receiver only detects "signal" or "no signal" it is sensitive to any noise in that frequency range.  That's the trouble with using $5 radio sets.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Look into using VirtualWire library to send/receive messages.
Works great with 433 MHz modules.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 44
Posts: 2808
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I suspect more likely that the OP's scope ground lead wasn't well connected. The 433 MHz radios are virtually un affected by 60HZ 'interference' and not quite AM but On Off Keying and the rF part of the receiver are relatively insensitive to anything more than 10 - 20 MHz away from the intended (Tuned) frequency. They are super-regenerative receivers with an RF stage to prevent the regen oscillator (detector) from radiating as much junk as a "normal" Super-regenerative receiver would. Although Extremely sensitive for the power radiated by the transmitter they suffer from being "Broad as a barn door" in other words while having 10uV sensitivity they also have 50 to 100 KHz wide detection windows especially if mistuned and that can be metal near the receiver coil and or antenna on some.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Australia
Offline Offline
Sr. Member
****
Karma: 9
Posts: 412
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

They also need regular data transitions in order for the receivers data slicer to be able to figure out what is a 1 and what is a 0.
Most that I have played around with need  a minimum transition rate of around 90 bps or more, otherwise the recievers AGC
thinks that there isnt any input signal , and starts winding the gain up.
The IF bandwidth seems to be 2 -3 Mhz wide on most.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Virtualwire takes care of all that.
The transmitter sends out bytes to give the receiver a chance to get in sync, then it sends the manchester encoded data.
Very nice library.
http://www.open.com.au/mikem/arduino/VirtualWire.pdf
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46042
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
in-Data via a button to 5v
This is supposed to be connected to the pin that is providing the data to transmit. Why is it connected this way?
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately, Virtualwire didnt work. The output was like this:
"
Sent
Timeout
"
So, it didnt receive an answer

However, I want to know HOW the signal is transmitted at all.

Quote
This is supposed to be connected to the pin that is providing the data to transmit. Why is it connected this way?
Thats what i did later, too. I wanted to test if a signal is transmitted
I expected that the receiver gives 5v at data out if 5v is supplied to transmitter's data in and receiver has 0v at data out if transmitter gets 0v at its data in (but it is NOT !??)

---
I tried the following:
rx/tx modules at one arduino (have only one) and the following code : (written myself)
Code:
// <CODE>; Freitag, 31. August 2012

#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 9); // RX, TX // i dont use rx=10 because I want to see how it looks like in a graph

int           pin       = 8;    // RX pin
int           ledpin    = 13;
int           laststate = 0;
unsigned long ausgabe;       // micros() nach 70min UEberlauf -> genug Zeit
unsigned long ausgabe_ = 0;
unsigned long micros_  = 0;
byte          i        = 0;
boolean       oddnow   = false;

void setup()
{
  Serial.begin(9600);
  Serial.println("pulse_in raw^2, <v2.4>;   31.8. - 23.9. 2012\n");

  pinMode(ledpin, OUTPUT);
  digitalWrite(ledpin, LOW);

  pinMode(pin, INPUT);
  //digitalWrite(pin, HIGH);//pullup

  mySerial.begin(9600);
  mySerial.println("Hello, world?");
}


void loop()
{
  unsigned long myc = micros();

  if (Serial.available())
    mySerial.write(Serial.read());

  if ((myc - micros_) / 100 >= 1000 * 1000 * 5)  // 5 Sekunden
  {
    micros_ = myc;
//    mySerial.write(i); //just test;dont execute
    i++;
  }

  int nowstate = digitalRead(pin);

  if (nowstate != laststate)
  {
    oddnow  = !oddnow;
    ausgabe = myc;

    Serial.println(ausgabe);

    if (oddnow) // only every second time
    {
      unsigned long diff = ausgabe - ausgabe_;
      if ((diff < 7000) || (diff > 12000)) // if dutycicle is MUCH different
      {
        //Serial.print("   D = ");
        //Serial.println(diff); // bewirkt anderen Duty-Cycle falls zu hauefig angewendet
        digitalWrite(ledpin, !digitalRead(ledpin));
      }
    }

    ausgabe_  = ausgabe;
    laststate = nowstate;
  }
}

So basically a led changes it state (on->off  /  off->on) if dutycyle(?) changed . AND it worked.
I know, that it is a very bad technique but it shows that it could work.

What happens here?:



Why does the receiver has an output 0V / 5V changing rapidly ?

« Last Edit: September 23, 2012, 04:32:05 pm by karlok » Logged

using Arduino Uno Rev 3

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 437
Posts: 23718
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Unfortunately, Virtualwire didnt work. ... I tried the following: rx/tx modules at one arduino (have only one)

I have never seen anyone getting seperate Tx and Rx components working on one arduino. They need to be on seperate Arduinos.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Australia
Offline Offline
Sr. Member
****
Karma: 9
Posts: 412
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Vitualwire Library only supports half duplex transmission.
ie you can only send or receive, but not both at the same time.
So you will need 2 Arduinos to implement vitualwire.
Its extremely hard to implement full duplex Manchester coding in software
in the one Microcontroller.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually, I don't know if the signal is Manchester encoded. The seller told me that it doesn't use encoding/decoding functions.
Does it has to use any kind of encoding or could I do it myself, that means: sending encoded data and receive and then decode it manually.?

I still want to know WHY there are these up and downs in what I recorded of the receiver (referring to the graph).
Logged

using Arduino Uno Rev 3

Australia
Offline Offline
Sr. Member
****
Karma: 9
Posts: 412
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

9600 bps is right at the upper limit of those receivers, and you would do better by trying 4800 bps or less.
Also, if the receiver and the transmitter are physically close to each other,  lime 1 M or less apart, the receiver will overload
from the transmission, so place them a bit further apart.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

or could I have to use a pull down(?) resistor to avoid a read from random data that is not actually given out by the rx?



So maybe if the receiver doesn't give me anything at its pin, there might be read a wrong voltage. (referring to "bouncing buttons") or is it very different between different modules?

By the way:
 I think, am really sure, that the up and downs in the raw read graph output were caused by the lack of a pulldown. I checked the following: read the value digitalRead(smiley-cool of pin 8 without anything but a cable put in pin8 - not more, thats all. Then touched the cable, moved it and the values changed rapidly (I think that is what is understood by "BOUNCING").

~
Logged

using Arduino Uno Rev 3

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46042
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Then touched the cable, moved it and the values changed rapidly (I think that is what is understood by "BOUNCING").
No, that is a floating pin.

Bouncing refers to switches making intermittent contact as they open and close.

Quote
or could I have to use a pull down(?) resistor to avoid a read from random data that is not actually given out by the rx?
No. The receiver is holding the pin HIGH or LOW as appropriate. Your issue is likely to be that your cheap transmitter and/or receiver are not immune from electrical interference - before or after the data is converted to over-the-air form and before or after it is converted back from over-the-air form.

That is why those radios have such low baud rates and range, and are generally not advised for serious transmission of critical information.
Logged

Germany
Offline Offline
Full Member
***
Karma: 0
Posts: 214
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, that sounds bad.
However, thank you for the explanation.

Have you any idea what could that be,  that is interferencing with the signal?

It is difficult to find simple remotes (ASK without encoding) that are reliable.
Logged

using Arduino Uno Rev 3

Pages: [1] 2   Go Up
Jump to: