virtual_wire

Virtual Wire

Author Rob Jansen, Copyright © 2018..2019, all rights reserved.
Adapted-by
Compiler 2.5r2

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. See sources for more information
             on Virtual Wire.
             A standard 433 MHz transmitter and 433 MHz receiver was used
             for testing this driver using a maximum bitrate of 2000 bits/s.
             In order to use this driver the main program must have the
             following defined (this to make this driver PIC independent):
             -) An alias for the tranmission pin vw_tx_pin.
             -) An alias for the receive pin vw_rx_pin.
             -) Initializing a timer that is used for transmission and
                reception. The timer must run at 8 times the bitrate.
             -) An interrupt routine of the used timer which must call the
                vw_service() procedure.
             A transmitter only and receiver only version is also available
             to save data space and code space for use in smaller PICs.


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 maximum message length was reduced to 10 to save data space but can
   be changed by the user by setting VW_MAX_MESSAGE_LEN to another value.
*) 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 reception 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 defined by the user by initializing the used timer.


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_service()

    This is the service routine that must be called by the main program when the
    timer 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_tx_stop()

    Stop the transmitter, call when all bits are sent
    

  • vw_rx_stop()

    Disable the receiver
    

  • 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
    

  • vw_reset_rx_good_bad_count()

    Reset the good and bad received message count
    

  • vw_init()

    Initialize the virtual wire driver.
    

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
    


Functions

Private

Related samples

Here are the list of samples which use this library:

16f182516f1825_virtual_wire_receiver.jal
16f182516f1825_virtual_wire_transmitter.jal