Pages: 1 [2]   Go Down
Author Topic: Sychronization in virtuel wire  (Read 1545 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The VirualWire library uses three pins - 10, 11, and 12 by default. You can change which pins it uses for any of the three functions.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Forgive me for being a lot ignorant.

I know 12 is default tx,11 is rx.But 10 is a new information,please tell me more.
Logged

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

From VirtualWire.h:
Code:
    // Set the digital IO pin to be for transmit data
    // Defaults to 12
    extern void vw_set_tx_pin(uint8_t pin);

    // Set the digital IO pin to be for receive data
    // Defaults to 11
    extern void vw_set_rx_pin(uint8_t pin);

    // Set the digital IO pin to enable the transmitter (press to talk)
    // Defaults to 10
    extern void vw_set_ptt_pin(uint8_t pin);
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

Many of the simple RF RX/Tx devices do not need press to talk, they only send what shows up on the data pins,
so you may not need that for your device.
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: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
so you may not need that for your device.
If you don't set it, though, the default pin (10) will be messed with. You can set it to a non-valid pin number, though, like 99.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

So you got me wondering if I just got lucky with my RF remote control then:

I am using pin 10 as Slave Select with SPI to a MAX7221, I only made these statements for the receiver:
Code:
  // Initialise the Wireless Receiver IO and ISR
  // set Virtual Wire data input to Pin 9 from 11
  vw_set_rx_pin(9);  // found this in forum 25 Aug 09
  // set the Bits per sec
  vw_setup(2000);
  // Start the receive PLL running
  vw_rx_start();
and only this for the transmitter, with D10 being used as a Column pin for a keypad, and D11/D13 not used.
 
Code:
// Initialise the IO and ISR for VirtualWire
  vw_setup(4000);                       // Bits per sec - had to double from 2000 with 8MHz 3.3V Pro-Mini

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: 551
Posts: 46204
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
with D10 being used as a Column pin for a keypad, and D11/D13 not used.
As long as you don't try to read from the keypad while transmitting, you can get away with this. But, how can D11 to D13 not be used, if you are
Quote
with SPI to a MAX7221,
SPI uses 11 to 13, with 10 as the default slave select for many libraries.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

Only the reciever used SPI, hence the reassignment.
Didn't use any library, wrote my own MAX7221 code. Pretty simple, just SPI.transfers.

On the transmitter, code gets interrupted, reads the keypad, transmits. SPI not used, so no Rx/TX pin reassignment.
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.

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

Sorry for late reply.

I never defined pin 10 through any library,so virtual wire may be using it by default.

I am shifting the ptt pin to 15,which is undefined for uno.

I will update soon.


Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 441
Posts: 23834
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

"I am shifting the ptt pin to 15,which is undefined for uno."
15 is not undefined - it is the same as A1 (A0-A5 = D14-D19).
If you want undefined, I would go for >=20.
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.

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dear cross roads,

forgive me if its blunder...

Does it mean I can use the A0-A5 pins just like the others ?

functions like digital write,analog write etc can too be done there ??? 
Logged

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

Quote
functions like digital write,analog write etc can too be done there ??? 
digitalWrite() - yes.
analogWrite() - no - none of the analog as digital pins are PWM pins.
pinMode() - yes.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey myfaithnka can you post your fixed transmitter and receiver code after you fixed your synchronization problem. I am trying to send integer values from two sensors and I am having the same problem you had with the mixed up values, but I can't figure out what is wrong. Thanks in advance.
Logged

Pages: 1 [2]   Go Up
Jump to: