LusoRobótica - Robótica em Português
Sistemas específicos => Arduino / AVR => Tópico iniciado por: almamater em 09 de Junho de 2011, 00:06
-
Bem.. comprei este kit que consiste num receptor e num emissor:
433Mhz RF link kit
http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=27 (http://iteadstudio.com/store/index.php?main_page=product_info&cPath=7&products_id=27)
Aparentemente são de fácil ligação... mas como não estou a conseguir e como penso que estão estragados venho pedir a vossa ajuda.. ::)
A biblioteca que uso e que está na página da iteadstudio é a VirtualWire (http://iteadstudio.com/store/images/produce/Wireless/433Mhz_RF_link_kit/VirtualWire.pdf (http://iteadstudio.com/store/images/produce/Wireless/433Mhz_RF_link_kit/VirtualWire.pdf))
No módulo RX ligo ao GRND, aos 5v e um dos pinos DATA ligo ao pino que está definido para RX no Arduino.
No módulo TX ligo o GRND, 5v e o DATA ao pino definido pra TX noutro arduino.
Usei o seguinte código:
TX:
#include <VirtualWire.h> // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
// Initialise the IO and ISR
vw_set_ptt_inverted(true); // Required for RF Link module
vw_setup(2000); // Bits per sec
vw_set_tx_pin(1); // pin 1 is used as the transmit data out into the TX Link module, change this to suit your needs.
}
void loop()
{
const char *msg = "ALMAMATER"; // this is your message to send
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx(); // Wait for message to finish
delay(200);
}
Para o RX:
// RF Link using VirtualWire to receive messages
// simplex (one-way) receiver with a 315MHz RF Link Receiver module
#include <VirtualWire.h> // you must download and install the VirtualWire.h to your hardware/libraries folder
#undef int
#undef abs
#undef double
#undef float
#undef round
void setup()
{
Serial.begin(9600);
// Initialise the IO and ISR
// vw_set_ptt_inverted(true); // Required for RX Link Module
vw_setup(2000); // Bits per sec
vw_set_rx_pin(3);
vw_rx_start(); // Start the receiver
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // check to see if anything has been received
{
int i;
// Message with a good checksum received.
for (i = 0; i < buflen; i++)
{
Serial.print(buf[i]); // the received data is stored in buffer
}
Serial.println("");
}
}
O problema é que não recebo nada, já troquei os 5v por 12v na alimentação a ambos os módulos mas nada.. perguntei à iteadstuido e respondem:
Mail 1:
> Hi,
> Is it work on its working Voltage?
> Regars
> ITead Studio.
>> Hello, i bought the 433Mhz RF link kit but this modules don't
>> work... what can i do? Thank you
Mail 2:
Hi,
I'am sorry for my late reply.
Please check the signal you send fit to the level for the module.
Thanks
Eu acho que tou a fazer tudo bem.. está a escapar-me alguma coisa?
-
Não terás queimado os módulos com 12v?
Se estás a usar serial que não o nativo aconselho a que uses outros pinos que não o 0 e o 1 que estão ligados ao FTDI e isso pode dar chatices.
-
Penso que não.. na descrição diz "Transmitor Input Voltage: 3-12V (high voltage = more transmitting power)"
Inicialmente testei com 5v, só depois passei aos 12v :P
Penso que testei outros pinos tb que não o 0 e 1 mas vou ver de novo com outros pinos
-
Tenho esse kit, mas apenas uso o receptor. Para verificar se o receptor está a funcionar podes usar o exemplo "AnalogreadSerial" e o "DigitalreadSerial" (se tiver recebes 1 e 0, se não tiver a funcionar apenas irás ter 0). Acho que apenas suportam 5V..
Usa este código para verificar os pulses
/******* Sketch to test Input Capture interrupt handling *********************************
functionality: measure length of pulses on the ICP pin with precision of 0.5 microseconds
Show the min and max pulse widths in microseconds on the serial port
**************************************************************************************************************/
#include <stdio.h> // for verbose debugging using sprintf
#define icpPin 8 // ICP input pin on arduino
#define outPin 2 // output pin that will shadow the input, can be monitored with a scope
// some variables to help see that something is happening in the interrupt handlers
volatile unsigned int Value; // this stores the current ICR1 value
volatile unsigned int MinValue;
volatile unsigned int MaxValue;
volatile unsigned int Overflows;
volatile unsigned int PulseCount;
/* Overflow interrupt vector */
ISR(TIMER1_OVF_vect){ // here if no input pulse detected
Overflows++; // incriment overflow count
}
/* ICR interrupt vector */
ISR(TIMER1_CAPT_vect){
TCNT1 = 0; // reset the counter
if( bit_is_set(TCCR1B ,ICES1)){ // was rising edge detected ?
digitalWrite(outPin,HIGH ); // yes, set our output pin high to mirror the input
}
else { // falling edge was detected
Value = ICR1; // save the input capture value
digitalWrite(outPin,LOW ); // set our output pin low to mirror the input
PulseCount++;
if(Value < MinValue) // update min or max values as appropriate
MinValue = Value;
if (Value > MaxValue)
MaxValue = Value;
}
TCCR1B ^= _BV(ICES1); // toggle bit value to trigger on the other edge
}
void setup() {
Serial.begin (19200);
pinMode(outPin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(icpPin, INPUT); // ICP pin (digital pin 8 on arduino) as input
MinValue = 30000; // Initialise with extreme values
MaxValue = 0;
TCCR1A = 0 ; // this register set to 0!
TCCR1B =_BV(CS11); // NORMAL MODE!!, prescaller 8, rising edge ICP1 - this works
TCCR1B |= _BV(ICES1); // enable input capture
TIMSK1 = _BV(ICIE1); // enable input capture interrupt for timer 1
TIMSK1 |= _BV(TOIE1); // enable overflow interrupt to detect missing input pulses
Serial.print("Finished setup\r\n");
}
// this loop prints the number of pulses in the last second, showing min and max pulse widths
void loop() {
char buffer[80];
// show the captured data, divide pulse widths by 2 to display time in microseconds
sprintf(buffer,"Got %d pulses: min=%d, max=%d (%d timer overflows)\r\n", PulseCount, MinValue / 2, MaxValue / 2, Overflows);
Serial.print(buffer); // send the info to the serial port
/* reset variables ready for the next reading */
PulseCount = Overflows = 0; // reset counts
MinValue = 30000; // set values to extremes
MaxValue = 0;
delay(1000); // wait 1 second for next update [/font]
}
Deverás receber sempre ruído (de dezenas a centenas, se o receptor estiver a funcionar), programa o emissor para emitir a cada 10segundos e verificas a quantidade de pulses que o receptor recebe, se o número de pulses aumentar a cada 10segundos é porque o receptor/emissor está a funcionar.
-
Ok, comprei um kit novo (igual) e testei trocar o receptor pelo novo e funcionou... era o receptor marado! :( de outra forma nunca iria descobrir.. tive de comprar um novo. Agora vou.lhes dizer..pode ser que enviem um receptor :)
-
Li algures que esses módulos não podem estar muito perto uns dos outros para funcionar, experimenta afasta-los mais.
-
Li algures que esses módulos não podem estar muito perto uns dos outros para funcionar, experimenta afasta-los mais.
Por acaso estou a colocar um LCD para andar pela casa e testar mais longe.. :)
-
Nops.. com o novo módulo receptor dá mas com o outro não dá.. já lhes mandei um mail mas não devo ter muita sorte, também não foram caros!
433MHz RF with Arduino (http://www.youtube.com/watch?feature=player_embedded&v=UHsf2VtW6vo#)