• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Komunikacja 433MHz
#1
Witam,

Proszę o pomoc w rozwiązaniu problemu związanego z transmisją 433MHz opartą na bibliotece VirtualWire.
W odbiorniku opartym na Arduino UNO powinienem uzyskać świecenie diody L (pin 13 arduino), kiedy odbierze dane z nadajnika.
Mam ciszę... dioda cały czas wygaszona... Sad

Nadajnik i odbiornik 433MHz działaja jak widać na poniższym filmie, brak reakcji modułu Arduino UNO...
Arduino UNO jest sprawne, na nim programowałem nadajnik...

https://www.youtube.com/watch?v=LcUTz5GL6gk

Poniżej zamieszczam kody nadajnika i odbiornika.
Proszę o pomoc w rozwiązaniu problemu...


Kod nadajnika:

Kod:
// Transmiter
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

void setup()
{
 Serial.begin(9600);      // Debugging only
 Serial.println("setup");

 pinMode(13, OUTPUT); // Inicjacja pinu 13 jako wyjścia.
 
 // Initialise the IO and ISR
 vw_set_ptt_inverted(true); // Required for DR3100
 vw_setup(2000);     // Bits per sec
}

void loop()
{
 const char *msg = "hello";

 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(200);
}


Kod odbiornika:

Kod:
// Receiver
//
// 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 $

#include <VirtualWire.h>

void setup()
{
 Serial.begin(9600);    // Debugging only
 Serial.println("setup");

 pinMode(13, OUTPUT); // Inicjacja pinu 13 jako wyjścia.

 // Initialise the IO and ISR
 vw_set_ptt_inverted(true); // Required for DR3100
 vw_setup(2000);     // Bits per sec

 vw_rx_start();       // Start the receiver PLL running
}

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++)
   {
     Serial.print(buf[i], HEX);
     Serial.print(" ");
   }
   Serial.println("");
   digitalWrite(13, false);
 }
}
 
Odpowiedź
#2
w kodach nie masz zdefinowane jaki pin jest odbiornikiem i nadajnikiem
odbiornik
Kod:
// 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 $

#include <VirtualWire.h>

const int led_pin = 13;
const int transmit_pin = 12;
const int receive_pin = 11;
const int transmit_en_pin = 3;

void setup()
{
    delay(1000);
    Serial.begin(9600);    // Debugging only
    Serial.println("setup");

    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);     // Bits per sec

    vw_rx_start();       // Start the receiver PLL running

    pinMode(led_pin, 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(led_pin, HIGH); // 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++)
    {
        Serial.print(buf[i], HEX);
        Serial.print(' ');
    }
    Serial.println();
        digitalWrite(led_pin, LOW);
    }
}
nadajnik
Kod:
// transmitter.pde
//
// Simple example of how to use VirtualWire to transmit messages
// Implements a simplex (one-way) transmitter with an TX-C1 module
//
// See VirtualWire.h for detailed API docs
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2008 Mike McCauley
// $Id: transmitter.pde,v 1.3 2009/03/30 00:07:24 mikem Exp $

#include <VirtualWire.h>

const int led_pin = 11;
const int transmit_pin = 12;
const int receive_pin = 2;
const int transmit_en_pin = 3;

void setup()
{
    // Initialise the IO and ISR
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true); // Required for DR3100
    vw_setup(2000);       // Bits per sec
    pinMode(led_pin, OUTPUT);
}

byte count = 1;

void loop()
{
  char msg[7] = {'h','e','l','l','o',' ','#'};

  msg[6] = count;
  digitalWrite(led_pin, HIGH); // Flash a light to show transmitting
  vw_send((uint8_t *)msg, 7);
  vw_wait_tx(); // Wait until the whole message is gone
  digitalWrite(led_pin, LOW);
  delay(1000);
  count = count + 1;
}
to działające przykłady
 
Odpowiedź
#3
WIELKIE DZIĘKI !!!

W końcu coś drgnęło i uzyskałem odczyt przesyłanych danych na monitorze szeregowym Smile
Co prawda są błędy ale to juz inna bajka...

Teraz muszę tylko porównać moje niedziałające kody z tymi podanymi przez kolegę 'adix', któremu BARDZO DZIĘKUJĘ za tak szybką pomoc Smile
 
Odpowiedź
#4
jeśli masz błędy wina leży po stronie hardware bo ten przykład przerobiłem i sterowałem padem ps2 przez radio dwoma serwami
 
Odpowiedź
#5
Tak jak napisałeś, coś mi chyba nie łączyło dobrze na stykówce.
Wszystko ładnie smiga.

Pozdrawiam Smile
 
Odpowiedź
#6
To spoko
 
Odpowiedź
#7
Aby nie być gołosłownym podaję link do filmu pokazującego działanie nadajnika i odbiornika Smile

https://www.youtube.com/watch?v=Bp13kf3SYCo

Raz jeszcze podziękowania za kody dla adix'a Smile
 
Odpowiedź
#8
Ja wysyłałem 6 zmiennych na raz i się nie gubiło myślę ze przy 12 i więcej mogło by się coś mieszać


A nie ma za co po to tu jestem
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości