Vous êtes sur la page 1sur 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 another end. 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 if your connection is very slow, then may take a moment to load. If you face any bug in them please post about it in comment box below. Yup, rest alright as always..let's start..

What is Encoding and Decoding:


In simple words, encoding is wrapping up the data. The data could be anything like simple binary 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 the decoder 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 in electronics 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 the name 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.

HT12E(Transmitter side)

Lets first take the Encoding side. The encoder has four input lines. Theses lines are used to give input which we want to encode. In encoding, we are wrapping up the data 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:

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 steady single 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.

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 for data 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 lines remains high. The figure below shows the decoding taking place in HT12D

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 in wireless communication.

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 fro waving 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 called as 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 address are 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:

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. Also provide 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.

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 pin will 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 your secret data. But there should be something which shows the reception of data at data output lines. We are using LEDs for that purpose. 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 better understanding, 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.

Step4.
Thats it, we are almost done. Now connect our last LED at the VT pin of the decoder. When circuit 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 in the 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 by taking the wire through the slot provided in centre of breadboard. This makes the circuit look less messy:

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.

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

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 surely cover in upcoming tutorials.

Vous aimerez peut-être aussi