Manchester code (phase encoding) library.

Dependents:   Manchester_Transmitter Manchester_Receiver

Manchester code (phase encoding) library

It implements Manchester code according to both IEEE 802.3 and G.E. Thomas' conventions.

  • A '0' is expressed by a high-to-low transition, a '1' by low-to-high transition in the IEEE 802.3 convention. The reverse is true in the G.E. Thomas' convention.
  • The transitions which signify '0' or '1' occur at the midpoint of a period.
  • Transitions at the start of a period are overhead and don't signify data.
  • Least significant bit is sent first
  • There are synchronization pulses (the number can be set) at the begin of transmission

    Select a convention to be used by commenting or uncommenting the line below in the Manchester.h header file.

Manchester.h

#define G_E_THOMAS 1

The IEEE 802.3 convention is used by default.

A Manchester encoded message (using G.E. Thomas' convention), with one sync pulse in the preamble, carrying four bytes:

/media/uploads/hudakz/manchester01.png

ACKNOWLEDGEMENT: The code in this library was based on this article published by Robert Guastella.

Import programManchester_Transmitter

Manchester transmitter demo.


Import programManchester_Receiver

Manchester receiver demo.

NOTE: To perform a simple test (without radio modules) connect the txPin on transmitter board to the rxPin on the receiver board and make sure that grounds are also connected one another.

Revision:
4:f2c392191c74
Parent:
2:de778df5892c
Child:
6:7454ad91f714
diff -r 03109c995123 -r f2c392191c74 ManchesterMsg.h
--- a/ManchesterMsg.h	Thu May 18 10:20:55 2017 +0000
+++ b/ManchesterMsg.h	Thu May 18 13:37:21 2017 +0000
@@ -40,7 +40,7 @@
     char*   data;   // Data field
     size_t  len;    // Length of data in bytes
 
-    /** Creates empty Manchester message of specified capacity.
+    /** Creates empty message of specified capacity.
      */
     ManchesterMsg(size_t max) : _max(max), data(new char[max]) { len = 0; }
 
@@ -58,7 +58,7 @@
      */
     void    clear(void)     { len = 0; memset(data, 0, _max); }
 
-    /** Inserter operator: Appends data (value) to Manchester message
+    /** Inserter operator: Appends data (value) to message
      */
     template<class T>
     ManchesterMsg &operator<<(const T val) {
@@ -75,7 +75,7 @@
         return *this;
     }
 
-    /** Inserter operator: Appends string of char to Manchester message
+    /** Inserter operator: Appends string of char to message
      */
     ManchesterMsg &operator<<(const char* str) {
         size_t  strLen = strlen(str);
@@ -93,7 +93,7 @@
         return *this;
     }
 
-    /** Extractor operator: Extracts data (value) from CAN message
+    /** Extractor operator: Extracts data (value) from message
      */
     template<class T>
     ManchesterMsg &operator>>(T& val) {
@@ -111,7 +111,7 @@
         return *this;
     }
 
-    /** Extractor operator: Extracts string of char from CAN message
+    /** Extractor operator: Extracts string of char from message
      */
     ManchesterMsg &operator>>(char* str) {
         size_t  strLen = strlen(data);