The Logic Analyzer instrument in WaveForms can be used to easily decode Manchester encoding signals. The following guide presents what Manchester encoding is, what are its advantages over unencoded digital signals and how to decode such a signal using the Logic Analyzer instrument in WaveForms and a Test & Measurement device in a simple loop-back configuration.
What is Manchester Encoding?
A Manchester code is a self-clocking binary code achieved by encoding every data bit with a transition from high to low, or from low to high. This type of encoding is used mainly in applications where galvanic isolation is needed, or where the number of lines available for communication is limited. There are two accepted standards of Manchester encoding: one in which HIGH values are represented by falling edges of the signal and LOW values by rising edges, and the inverse.
Why Use Manchester Coding? What is the Advantage?
One of the most important advantages of this code is the lack of a separate clock signal. By encoding the clock in the data signal, the number of channels needed for communication is reduced to one, making this code optimal in applications where galvanic isolation is needed between the transmitter and the receiver, or in wireless communication, like IR, RFID and NFC applications.
Another advantage is that this encoding scheme ensures that the resulting signal won’t remain at a logic HIGH or LOW level for a longer period of time, so the signal can be AC coupled, which means that the DC component of the signal can be eliminated. This type of filtering is not available in the case of unencoded digital signals, as a long, uninterrupted sequence of ones or zeros would result in the same voltage level after the decoupling capacitor. AC coupling offers some sort of protection against fault currents circulating in the circuit and can resolve common-mode range incompatibility in some cases.
What are the Disadvantages of Manchester Encoding?
The most important disadvantage of this encoding scheme is that data rate is only half of the bandwidth. In other words, to send one information bit, two logic states have to be sent, thus the frequency of the outgoing signal must be twice as large as the number of incoming information bits per second. If we consider the signal frequency constant (limited by the clock frequency of our device), the data rate is only half than in the case of the unencoded data signal.
Generating a Signal to Be Decoded
To demonstrate the usage of the Manchester decoder in the Logic Analyzer, we will need a signal to decode. For this we will use the Pattern Generator instrument from WaveForms and a digital I/O line of the selected Test & Measurement device in simple loop-back configuration (the same digital line is used both as input and output – no external connections are needed). As the Pattern Generator instrument can’t generate a Manchester code by default, a Python script will be used to create the binary data and to save it to a csv file, which can be imported later in WaveForms. You can follow the steps below to write your own script.
- First, define the parameters of the signal: which standard to use (HIGH = falling edge, or HIGH = rising edge), endianness and the number of data bits. Then import the necessary packages: in this script we will use NumPy to generate arrays and Pandas to export the result to a csv file.
- Get the input string, then convert it to binary. If necessary, you can invert the order of the octets.
- Double every bit (this way you make the data signal two times “slower”), then generate a clock signal: an array which contains alternating “1”-s and “0”-s and has the same length as the data signal.
- Convert the strings to arrays of integers, then get the Manchester code from the two arrays by applying a bitwise XOR (exclusive or) operator to the two arrays (element-by-element). Change “1”-s to “0” and “0”-s to one if you want to change the standard.
- Create a data frame from the generated code and export it as a csv file.
- Open WaveForms, connect it to your device, then open the Pattern Generator instrument. Add a new Signal and select DIO 0. Set the Output to PP (Push-Pull), the Type to Custom, then import the csv file, leaving every other setting on default.
- Set the Wait time to 10ms and the Run mode to auto by checking the respective box. Start the Pattern Generator.
Decoding a Manchester Code with the Logic Analyzer
One you’ve generated it, your Manchester code is easy to decode using WaveForm’s Logic Analyzer instrument. Just open Logic Analyzer, and go to “Add Manchester” under Adding Channels. Set the frequency to half of the frequency of the generated signal (500 Hz in this case). With the help of the respective drop-down lists, set the parameters of the encoding to the same as in the Python code. Set the Format to ASCII, to make the message readable.
At Trigger settings, set up a protocol trigger to the first value of your message: in this guide the message “Hello!” is encoded, so the trigger will be set to the value 48[H], where 48 is the hexadecimal code of the ASCII character “H”.
The last thing to do is simply to start the instrument. Set the time base and the position in a way, to make the message visible. Voila! You’ve just decoded a Manchester Code.