RFM12 library/en: Unterschied zwischen den Versionen

Aus LaborWiki
Wechseln zu: Navigation, Suche
(#define ... muss true sein in der neuen library version)
Keine Bearbeitungszusammenfassung
 
(21 dazwischenliegende Versionen von 7 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
The rfm12 library provides the ability to use RFM12(B) modules in conjunction with Atmel AVR microcontrollers.
{{ProjektInfoBox
|name        = rfm12lib
|status      = stable
|image      = Avr_rfm12.png
|description = The rfm12 library provides the ability to use RFM12(B) modules in conjunction with Atmel AVR microcontrollers
|author      = [[Benutzer:Hansinator|Hansinator]], [[Benutzer:Tixiv|Tixiv]], [[Benutzer:Soeren|Soeren]]
|username    =
|version    = 1.1.0
|update      =
|platform    = AVR
|license    = GPLv2 or later
|download    = [https://www.das-labor.org/storage/LaborLib/rfm12/ SVN] [http://www.das-labor.org/LaborLibTrac/browser/rfm12 browse]
}}


==Features==
== Library Features ==
=== Software & Hardware SPI ===
This mode is especially useful for controllers that don't have a hardware SPI interface or where the SPI interface is used for something else.


To enable software SPI, add the following to your '''rfm12_config.h''':
* Basic packet format, including:
  #define SPI_SOFTWARE 1
** An 8-bit (0..255) packet type or address field
** Packet length up to 255 bytes
** A simple header checksum
* Interrupt or polling based packet transfer handling
* Multiple frequency bands, depending on the used module (433, 868 and 915 MHz)
* Collision avoidance (carrier sense)
* Usage of synchronization patterns to start data reception
* Hardware or software SPI support
* Transmit only mode, to reduce the size of the binary
* Basic ASK (amplitude shift keying) receive and transmit functionality (for radio controlled outlets and the like)
* Low-battery detection feature (using the RFM12)
* Low-power Wakeup timer feature (using the RFM12)


==== Power-saving ====
You can make use of the RFM12's wakeup timer by adding the following line to your '''rfm12_config.h''':
  #define RFM12_USE_WAKEUP_TIMER 1


=== Raw transmissions ===
== Documentation ==
You can make use of raw transmission mode, meaning manually switching the transmitter on and off in software. This feature is especially useful if you want to control devices that don't support the RFM12's modulation (e.g. Radio controlled power Plugs).


In order to use the raw transmission feature, you have to set the variable '''RFM12_RAW_TX''' in '''rfm12_config.h'''. Before you can use the raw transmission mode, you'll have to tell the library to switch to raw mode using the function '''rfm12_rawmode(1)'''. The functions '''rfm12_tx_on()''' and '''rfm12_tx_off()''' will then manually switch the transmitter on and off.
Here's the online documentation for version 1.1.0:<br />
http://www.hansinator.de/rfm12lib/


Note that when being in raw transmission mode, the rfm12 interrupt is disabled as well as other library functions. You will not be able to receive or send data the "usual" way while raw transmission mode is on. To switch back to normal mode, execute '''rfm12_rawmode(0)'''.
A downloadable version can be found here:<br />
http://www.das-labor.org/files/rfm12lib_doc_1_0_0.zip


== Download ==
The lastest version can be found on Github [https://github.com/das-labor/librfm12 librfm12]


==== Example Code ====
The source of version 1.1.0 is available as a downloadable ZIP file [http://www.das-labor.org/files/rfm12lib-1.1.0.zip here] (MD5: 4545ad72782bf9465c1be109ecce9da5).
  ...
  rfm12_rawmode(1);  /* switch to raw mode          */
  rfm12_tx_on();      /* send a logical one...        */
  _delay_ms(1);      /* ...for 1 ms...               */
  rfm12_tx_off();    /* then disable the transmitter */
  rfm12_rawmode(0);  /* switch back to normal mode  */
  ...


==== Technical details ====
Alternatively, you could checkout the newest version from our subversion repository. You can [http://www.das-labor.org/LaborLibTrac/browser/rfm12 browse] the repository or directly check out the sources with the command:
In raw transmission mode, the RFM12 module's transmitter is simply turned on and off. While it is enabled it transmits the preamble in an endless loop.
  svn co https://www.das-labor.org/storage/LaborLib/rfm12/


The module doesn't seem to support modulation modes other than it's own, so sending a logical one actually means sending the preamble with the native modulation mode. "Dumb" devices (rf power-plugs, doorbells, etc.) may well recognize this as a high-peak and can be controlled this way.
== Using the Library ==
 
The file '''rfm12_config.h''' contains all the configuration as well as a pin assignment table. See the documentation for more info.
=== Collision prevention ===
Before a packet is actually sent, the RFM12's status register is read in order to measure the current signal strength. When the signal strength is above a treshold, it is assumed that there's a transmission underway. The library then waits some time until the "ether" is free and starts the transmission when the module hasn't seen any traffic for some time.
 
Collision prevention is enabled by default. You can disable it by adding '''#define RFM12_BE_RUDE''' to your rfm12_config.h.
 
=== Integrity checking ===
The library already provides a very small protocol to provide integrity for your transmissions. There are two additional bytes sent in per packet that contain the '''length''' of the payload and a "checksum" field, that simply is the byte-per-byte XOR'ed payload.
 
= Downloading the library =
The library is hosted in our subversion repository. You can [https://www.das-labor.org/trac/browser/microcontroller/src-atmel/lib/rfm12 browse] the repository or directly check out the sources with the command:
  svn co svn://www.das-labor.org/microcontroller/src-atmel/lib/rfm12
 
= Using the library =
The file '''rfm12_config.h''' contains all the configuration as well as a pin assignment table.


Here's an example how to use the library:
Here's an example how to use the library:
Zeile 55: Zeile 55:
  sei();
  sei();
   
   
  while (23)
  while (1)
  {
  {
     /* ... */
     /* ... */
Zeile 61: Zeile 61:
     rfm12_tick();  /* periodic tick function - call that one once in a while */
     rfm12_tick();  /* periodic tick function - call that one once in a while */
  }
  }
== Technical Details ==
=== Collision Prevention ===
Before a packet is actually sent, the RFM12's status register is read in order to measure the current signal strength. When the signal strength is above a treshold, it is assumed that there's a transmission underway. The library then waits some time until the "ether" is free and starts the transmission when the module hasn't seen any traffic for some time.
Collision prevention is enabled by default. You can disable it by defining this '''"#define RFM12_NOCOLLISIONDETECTION 1"''' in your rfm12_config.h.
[[category:Automatisierung]]
[[category:Datenfunk mit dem Microcontroller]]

Aktuelle Version vom 12. Juli 2014, 17:36 Uhr

           
rfm12lib

Release status: stable [box doku]

Avr rfm12.png
Description The rfm12 library provides the ability to use RFM12(B) modules in conjunction with Atmel AVR microcontrollers
Author(s)  Hansinator, Tixiv, Soeren
Last Version  1.1.0 ()
Platform  AVR
License  GPLv2 or later
Download  SVN browse




Library Features[Bearbeiten | Quelltext bearbeiten]

  • Basic packet format, including:
    • An 8-bit (0..255) packet type or address field
    • Packet length up to 255 bytes
    • A simple header checksum
  • Interrupt or polling based packet transfer handling
  • Multiple frequency bands, depending on the used module (433, 868 and 915 MHz)
  • Collision avoidance (carrier sense)
  • Usage of synchronization patterns to start data reception
  • Hardware or software SPI support
  • Transmit only mode, to reduce the size of the binary
  • Basic ASK (amplitude shift keying) receive and transmit functionality (for radio controlled outlets and the like)
  • Low-battery detection feature (using the RFM12)
  • Low-power Wakeup timer feature (using the RFM12)


Documentation[Bearbeiten | Quelltext bearbeiten]

Here's the online documentation for version 1.1.0:
http://www.hansinator.de/rfm12lib/

A downloadable version can be found here:
http://www.das-labor.org/files/rfm12lib_doc_1_0_0.zip

Download[Bearbeiten | Quelltext bearbeiten]

The lastest version can be found on Github librfm12

The source of version 1.1.0 is available as a downloadable ZIP file here (MD5: 4545ad72782bf9465c1be109ecce9da5).

Alternatively, you could checkout the newest version from our subversion repository. You can browse the repository or directly check out the sources with the command:

 svn co https://www.das-labor.org/storage/LaborLib/rfm12/

Using the Library[Bearbeiten | Quelltext bearbeiten]

The file rfm12_config.h contains all the configuration as well as a pin assignment table. See the documentation for more info.

Here's an example how to use the library:

uint8_t teststring[] = "teststring\r\n";
uint8_t packettype = 0xEE;
rfm12_init();  /* initialize the library */
sei();

while (1)
{
    /* ... */
    rfm12_tx (sizeof(teststring), packettype, teststring);
    rfm12_tick();  /* periodic tick function - call that one once in a while */
}

Technical Details[Bearbeiten | Quelltext bearbeiten]

Collision Prevention[Bearbeiten | Quelltext bearbeiten]

Before a packet is actually sent, the RFM12's status register is read in order to measure the current signal strength. When the signal strength is above a treshold, it is assumed that there's a transmission underway. The library then waits some time until the "ether" is free and starts the transmission when the module hasn't seen any traffic for some time.

Collision prevention is enabled by default. You can disable it by defining this "#define RFM12_NOCOLLISIONDETECTION 1" in your rfm12_config.h.