virtual_wire

Virtual Wire

Author Rob Jansen, Copyright © 2018..2018, all rights reserved.
Adapted-by Rob Jansen, small bug fix in transmiter.
Compiler 2.4q6

Description

Library for sending and receiving data over an RF Link based
             on Virtual Wire. The driver implements a Phase Locked Loop to
             increase sensitivity and so extend the range of the connection.
             Next to that it uses a special encoding format for the bit
             pattern to stay DC neutral. Also see sources for more
             information on Virtual Wire.
             A standard 433 MHz transmitter and 433 MHz receiver was used
             for testing this driver.
             This driver was created and tested for the following PICs:
             -) 12F617     at 8 MHz
             -) 16F1823/25 at 32 MHz
             -) 16F1455    at 48 MHz
             -) 18F14K50   at 48 MHz
             In order to support more PICs, the _vw_timer_setup (Timer2)
             initialization routine has to be extended.
             Since the driver can be used for transmission or reception,
             a transmit only version and receive only version were extracted.


Sources

http://www.airspayce.com/mikem/arduino/VirtualWire.pdf


Notes

Changes to the original driver that was created for Arduino:
*) From C converted to JAL. This required an extra receive buffer because
   of the lack of pointers which could not pass a receive buffer.
*) The inverting of the output and input signal was removed.
*) The 6 to 4 conversion was changed into a look-up table to improve speed.
*) The variables and procedure that indicate the number of bad and good
   received messages were removed to save data space. This includes the
   message count which was also removed.
*) The maximum message length was reduced to 10 to save data space.
*) The transmission header was moved from data to constant as to decrease
   the size of the transmit buffer and so save data space.
*) The transmission buffer and receiption buffer were combined into one
   buffer to save data space. This can be done since the original driver does
   not support transmission and reception at the same time.
*) The bit rate is not ultimate flexible. Instead 2 values, 1000 bit/s and
   2000 bits/s, can be selected. For devices running at 8 MHz select the
   1000 bits/s bitrate. The lower the bitrate the higher the range.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions

Private

API details

Global variables/contants

Procedures

  • vw_rx_start()

    Enable the receiver. When a message becomes available, vw_rx_done flag
    is set, and vw_wait_rx() will return.
    

  • vw_setup(byte in bitrate)

    This procedure initialized the timer 2 that is used for creating the pulse
    time interrupt. This has to be VW_RX_SAMPLES_PER_BIT times the bit time.
    

  • vw_tx_stop()

    Stop the transmitter, call when all bits are sent
    

  • vw_rx_stop()

    Disable the receiver
    

  • timer2_interrupt()

    This is the interrupt service routine called when timer2 overflows
    Its job is to output the next bit from the transmitter (every 8 calls)
    and to call the PLL code if the receiver is enabled
    

  • vw_wait_rx()

    Wait for the receiver to get a message
    Busy-wait loop until the ISR says a message is available
    can then call vw_get_message()
    

  • vw_wait_tx()

    Wait for the transmitter to become available
    Busy-wait loop until the ISR says the message has been sent
    

Private
  • _vw_pll()

    Called 8 times per bit period by the timer interrupt routine
    Phase locked loop tries to synchronise with the transmitter so that bit
    transitions occur at about the time vw_rx_pll_ramp is 0
    Then the average is computed over each bit period to deduce the bit value
    

  • _vw_timer_setup(byte in bitrate)

    Intialize Timer 2 to generate the RF bit time.
    


Functions

Private

Related samples

No sample found