Introduction to Encoding and Decoding

Embed Size (px)

Citation preview

  • 7/28/2019 Introduction to Encoding and Decoding

    1/13

    Introduction to Encoding and Decoding. Making a simple Encoder-Decoder

    device

    Hey guys how are you, I am vkas and in our todays post I will introduce you with the concept of

    Encoding and Decoding and will show how to encode data at one end and decode it at anotherend. I will also go through the concept behind address lines in electronics actually means.

    In today's post I have made some animated content in flash for better understanding, in case ifyour connection is very slow, then may take a moment to load. If you face any bug in them

    please post about it in commentboxbelow. Yup, rest alright as always..let's start..

    What is Encoding and Decoding:

    In simple words, encoding is wrapping up thedata. The data could be anything like simplebinary data (in the form of 1's and 0's) or it could be an audio signal or it could be certain text.

    But here we are dealing with the encoding that is used for binary signals. The wrapped data is

    called as a Packet. This packet is sent through a medium (Through wire or wireless) to thedecoder part where it gets unwrapped or decoded. Yes, now what you are thinking is right, it is

    exactly similar to posting an envelope. Encoding is when you put the letter into envelope, the

    postman is medium to take the envelope to the recipient and when recipient opens the envelope

    then it is called decoding.

    So, essentially to apply encoding and decoding technique in our digital world we need three

    entities: (1). A sender or in electronics sense it is Transmitter. (2). To receive this sent data we

    need a receiver. (3). and of course we need an address of the receiver. The role of address inelectronics is played by address lines.

    HT12D and HT12E

    In todays episode, I am taking an Encoder-decoder IC pair. In market, it is available with thename as HT12E and HT12D. The 12 in the name means 8-address lines and 4-data lines while

    E and D letters represents Encoder and decoder respectively.

  • 7/28/2019 Introduction to Encoding and Decoding

    2/13

    HT12E(Transmitter side)

    Lets first take the Encoding side. The encoder has four input lines. Theses lines are used to giveinput which we want to encode. In encoding, we are wrappingup thedata which means if we

    want to send a binary signal 1001 to other end, we have to make data pins as 1001. Now, to

    make data pin like this, what we need to do is to give high or 5 volts (which in digital means 1)to pins D0 and D3 while we have to provide pins D1 and D2 with 0 volt. (Ground). This

    altogether gives us 1001 which is transmitted out from the Data out pin of the HT12E. The

    input given to data pin is in parallel form which is being transmitted into serial form from the

    data output pin. The figure below will clear this:

    http://www.gophoto.it/view.php?i=http://4.bp.blogspot.com/-3VlyYgIm5yE/T_WZAH8YTJI/AAAAAAAAAJk/QaJfIuZ34Sk/s1600/HTE.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    3/13

    Our data is now been encoded and will be transmitted. The transmission medium could be

    anything, it could be our regular wire, or wireless. In this tutorial, we are going to use our steadysingle core wire which we use to provide connections in breadboard (nothing fancy!).

    The data flows in serial form through the wire and reaches the other end i.e. to the receiver.

    Receiver now decodes this signal. So, lets see how decoder works:

    HT12D (Receiver side):

    Below is the pin diagram of HT12D decoder IC.

    http://www.gophoto.it/view.php?i=http://3.bp.blogspot.com/-zyQdrTyMuJo/T_WZI8AHoRI/AAAAAAAAAJs/pXlOGTZlJ0Q/s1600/HTEzoom.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    4/13

    Now neglect all the pins for this moment and just concentrate on Din (Data in) pin and the for

    Data lines pin. The encoded data which is coming from the transmitter side goes into the Data in

    (Din) pin. The data which was in serial order gets decoded and the output is generated at the fordata line pins in same order as that on transmitter pin.

    Yup also remember: When there is no input at the data in pin, the output pins i.e. data linesremains high.

    The figure below shows the decoding taking place in HT12D

    http://www.gophoto.it/view.php?i=http://3.bp.blogspot.com/-CxPgEcanueo/T_WZNaHMb3I/AAAAAAAAAJ0/9uYTjBFhjp4/s1600/HTD.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    5/13

    Role of Address Lines:

    When using a single pair of encoder-decoder IC, we generally leave the address pins as it is i.e.we do not connect them to either ground or VCC. But what if there is more than one decoder but

    only single encoder. In that case we need to give an address to the data that it might travel to

    specific decoder only and our data should not leak at unnecessary decoders. This is very useful inwireless communication.

    http://www.gophoto.it/view.php?i=http://4.bp.blogspot.com/-MFuDDa02fQg/T_WZR5MWK6I/AAAAAAAAAJ8/HjR2GgeYc-I/s1600/HTDzoom.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    6/13

    To define an address, what we need to do is to connect specific address pins to the ground on

    both encoder and decoder side; remember that the order of connecting the address pins to the

    ground must be same. See the animation below for; it will remove all the twists in your mind:

    Oscillator Pins:

    When we first hear the word oscillations, the first thing that comes in our mind is the to and frowaving motion, yup as always you are correct. The role of oscillator in digital electronics is to

    produce waves which are in Sine wave form or rectangular wave form. The device used to

    generate this waveform is called Oscillator. The waveform generated by the oscillator is calledas Pulses (like our heart beat). So, in digital world the oscillator works identical to our Heart.

    Unfortunately, we will not be able to see the oscillator device itself because in HT12D and

    HT12E, the oscillator comes inbuilt, what we have to do is to put a resistor between the

    oscillators pins. But, in our coming tutorial over microcontrollers, the need of oscillator is must,so we will learn about it in that tutorials only.

    VT Pin (Valid Transmission):

    The valid transmission pin in decoder shows that the transmitter address and the receiver addressare same and is ready to receive the data from the encoder side.

    During implementation of the circuit, we will see how to get notification about the valid

    transmission through this pin.

    So, now we are loaded with all the essentials needed to implement Encoder-Decoder circuit.

    Lets start implementing one:

  • 7/28/2019 Introduction to Encoding and Decoding

    7/13

    Components Required:

    1. IC- HT12E/HT12D (generally comes in pair).

    2. Breadboard with complete Power supply.

    3. LEDs (5)

    4. Resistors (Four 125 ohm for LEDs)

    (750k ohm for oscillator of Encoder)

    (27k ohm for oscillator of Decoder).

    5. Reset Switch (4).

    6. Battery (6-24 volts)

    7. Like always....your enthusiasm...

    Step1.

    Take the power supply circuit and insert the encoder and decoder ICs at some distance. Alsoprovide the VCC and ground to the pins (Pin number 9 ground and pin number 18 VCC for both

    the ICs). See the figure below:

    Step2.

    http://www.gophoto.it/view.php?i=http://4.bp.blogspot.com/-p50U1lpOQyo/T_WZnR_vgQI/AAAAAAAAAKE/STRnuSUSQC0/s1600/ht12d_1.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    8/13

    Now, we will first make the encoder part. Insert the 750k ohm resistor in pin number 15 and 16

    i.e. you have to short both the pins using this resistor. Connect the Transmission Enable pin(TE) to ground. This action will enable the IC to transmit the data through data out pin. Now

    connect four reset switches in data line. Remember, reset switch has two legs. One will go into

    the data line and the other one will go to ground. So, whenever you will press the switch, the pinwill get connected to the ground. See the figure below which how actually you have to connect

    the switches:

    Step3.

    Yup, our encoder part is completed. You are ready to encode yoursecret data. But there should

    be something which shows the reception of data at data output lines. We are using LEDs for thatpurpose. The LED will glow when data is received. So, lets put down hands over decoder

    circuit.

    Connect all for LEDs separately with the four data lines of decoder IC. To have a betterunderstanding, I am not showing the 125 ohm resistor. If you dont know how to connect resistor

    or having doubt over polarity, then click here to have quick tutorial.

    Also connect or short pin number 15 and 16 with 27k ohm resistor.

    http://letslearnelectronics.blogspot.in/2012/06/calculating-value-of-resistor-and.htmlhttp://www.gophoto.it/view.php?i=http://1.bp.blogspot.com/-vJcHTI7JAjE/T_WZ2hUaBvI/AAAAAAAAAKM/BdkRjC0cxnA/s1600/HT12E_connect+switch.jpghttp://letslearnelectronics.blogspot.in/2012/06/calculating-value-of-resistor-and.html
  • 7/28/2019 Introduction to Encoding and Decoding

    9/13

    Step4.

    Thats it, we are almost done. Now connect our last LED at the VT pin of the decoder. Whencircuit is given power, the LED at VT pin glows, it gives the indication that decoder address is

    matched with the encoder and ready to have Valid Transmission. At last connect the data out and

    data in of encoder and decoder respectively. The circuit will work in the same way as shown inthe window below.

    Click the button D0, D1, D2, or D3 at the encoder circuit to view the working of our

    encoding and decoding circuit

    .

    The complete circuit on breadboard will look like this. The bold blue line in centre of the

    breadboard connects the data in and data out pins. You can also do this with real breadboard bytaking the wire through the slot provided in centre of breadboard. This makes the circuit look

    less messy:

    http://www.gophoto.it/view.php?i=http://4.bp.blogspot.com/-f3la95kPWcQ/T_WaULVgiQI/AAAAAAAAAKU/K4KKZjFT6IE/s1600/HT12d_connect+led.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    10/13

    And this is how my own circuit looks (I am using single data line and two breadboards for

    Impression! ) My finger is pressing the switch at encoder part.

    http://www.gophoto.it/view.php?i=http://3.bp.blogspot.com/-K7E-n5BZbdo/T_WalOpU0DI/AAAAAAAAAKc/x0GcQHKpFag/s1600/final.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    11/13

    The Moral of the story i.e. circuit diagram is shown below:

    http://www.gophoto.it/view.php?i=http://1.bp.blogspot.com/-x0fpi5akF1g/T_WbTGpP7JI/AAAAAAAAAKk/r7jo7VtnX8k/s1600/04072012.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    12/13

    Now, whatever switch you are gonna press, exactly the same will turn on at the decoder part.This circuit have great importance when working with wireless RF device which I will surelycover in upcoming tutorials.

    http://www.gophoto.it/view.php?i=http://1.bp.blogspot.com/-A-Ru9x12_bI/T_Weby0MPeI/AAAAAAAAAK4/eE3SpMEA1g4/s1600/circuit+diagram.jpg
  • 7/28/2019 Introduction to Encoding and Decoding

    13/13