Download as pdf
Download as pdf
You are on page 1of 9
Electrical 4 U MCQ Basics ~ Power Systems ~ Machines ~ Electonics ~ Tools ~ Q. Recent Posts » SCADA Syste What Gray Code: Binary to Gray Code Converter (Supervisory Conti and Data Acquisition) Contents |= ‘Programmable Logi Conroe (PLCS) Basics, Types & Applications What is Gray Code? Diode: Dsiation Symbol and Type Gray code ~ also known as Cycle Code, Reflected! Binary Coe (RBC), Reflected Binary cf Diodes (BB) o¢ Grey code ~is defined as an oxdecing ofthe binary umber syst such that each spotv benno vase incremental value can only difer by one bt In gray code, while traversing from one tgp ta another sep only ane bit inthe code group changes. That so say that two adjacent code numbers difec fom each ater by only one Bit They Work » Ht Wee Recie Cit agra, Working Principle Gay code isthe most popular ofthe uit distance codes, but its not suitable for arithmetic Lena's Law of Eectromagtic ‘operations, Gray code has some applications in aalog to digital converters, as wel as being Induction: Definition & Format wed for ertorcoretion in digital commanication, Gray code can be dificult to understand, {nity bu becomes auch easier to understand when locking a the gray code tables boss Gray Code Table A table showing the conversion between binary’ code to gray code and decimal o gray code fsshown beowe: Binary to Gray Code Converter ‘ne gia rest nie converts me onary coa® to equsvatent gray cone 1s Known 3S binary to gray code converter An s-it gray code can be obtained by sellecting an 1 bt code shout an ani afer 2 snes and pling the MSB (Mort Significant Bit) of above the axis and the MSB of 1 below the axis. Reflection of Gray codes ie shown below, “The Lbitbinary to gray code conversion tables given below: 4 btBinay ait Gray Decimal Number binary 4 bite ABCD &0,0.04 o 0000 00 i 9001 00 3 oo10 00 5 0011 00 i 0100 arto é 0101 tat 3 o110 104 5 o14t 100 i 1000 1400 8 1001 = 140% 10 10101493 " 1011 1440 2 1100 1010 3 1401 044 1“ 1410 100% 15 141t 1000 ‘That means ind bit gray code, (1) or Lit codes rflected against the sue drat after the 2% or 5 sow. “Thebinary to gay code converter cect is shown below: Loge Greuit for Binary to Gray Code Convertor How to Convert Binary to Gray Code |. The MSB (Most Significant Bit ofthe gray code will be exactly aqua othe fest ito the given Binary aber, 2. The second bit of the code wil be excusive-or (NOR) ofthe first and secon bit ofthe given binary number iif both the bits are same the el willbe U and if they are ferent the esl wil be 23.The thie bit of gray code will be equal to the exclasve-oc (NOR) ofthe second and thie bit the given binary number. Thus the binary to gray code conversion goes con Am examples given belo tllustate there steps, Binary to Gray Code Conversion Example Say we have a binary umber 01001 which we wish te converte gray code, Lets go through an example of how we would pesto this conversion: 1. The MSB is kept the same, As the MSB of the binary s 0, the MSB af the gray code willbe O as wel ze gray Bit) 2. Next take the NOR ofthe stand the second binary bit The fist it and the second bits 1. The bits ave diferent so the sesltant gray bit willbe I (cond gray bi 3. Next take the NOR ofthe second and third binary it.The second Bit i andthe thied bite 0. These bite ae again diferent so the cesta gay bit will be 1 (hed geay bi) Now take the XOR of hid an fourth binary bit The thie itis 0, and the fourth bit 20. Ac these are the same, the ezultant gray bi wil be O (out gray Bt) 5 Lastly take the XOR of he fourth and ith binary bit The fourthbitis0, and the th itis 1, These bite ae diferent so the sesltan gray bit willbe 1 (8h gray bit) 6 Hlnce the eesult of binary to gray code conversion of O01 is complete and the cquivalent gray code ie O10 TPE Pee Gray to Binary Code Converter Jina gry te binary code converter the input i gray code and output iste equivalent inary cde “Let us consider 2 bit gray to binary code converter. Te design a Abit gray to binary code converts, we fist have to draw a gray code conversion tbl, as shown below: 4 bit Gray Code 4 bit Binary Code meee “Rees ue dane Vii jodie 1410 1011 i010 1100 1044 v101 1001 1110 1000 aaat ‘The gray code to binary converter circuit is shoven below: Logic Circuit for Gray to Binary Code Converter Gray Code to Binary Conversion Gray ode to binary conversion sagan avery simple an easy process. Following steps can sake your idea cles on this typ of conversions, | The MSB ofthe binary umber willbe equal tothe MSB of the given gray code. 2 Now ifthe sacond gray bit is0, then the second binary bit willbe the sameas the previous or the frst bit the gray bit is the second binary bit will alt Iitwas Lit ‘willbe O and iit wa Ot will be 1 23. This step i continued forall the bits to do Gray code to binary conversion. ‘One example given belo will make your idea cles Gray Code to Binary Conversion Example ‘The MSB of the binary will Be as the MSB of gray i 0. Now mave tothe ext gray bit Ait 451 the previous binagy bit wil alter Le it wi be I, thas the second binary bit will eI. Next, Took at the tied bit of the gray code. It is again I thus the previous biti the second binary ‘bi wil gain alter and the thi i ofthe binary number wil be O. Now, the dh hit ofthe sven gray i 20 the previou binary bt willbe unchanged, i dth binary bit will be D. Now again the 5th goey bits 1 hus the previous binary bit il ale, wil be from, Therefore ‘he equivalent binary umber in case of gray code tothe binary conversion will be (01001, (®) cp ABX 00 of 11 10 ABCD = AgRaceD Gray Code Example Sequence 1 Geay code can ony change one bit rom ts previous step tote next stp. The change of bit lays occur from the sight side tothe left side ie. from SB (Least Sigaiicant Bi towards the MSE (Most Signa Bit) 2. We know that for binary digit there re fro possible combinations -Oand I Following our rule, we fs taget the LSB (ight side) lence the Fis tae bits ase keep constant (00) and the fourth bit changes foun Oto 1. This isthe decimal cuivalent of. 8. Now move to the next it rom the L the 3nd bit, We now change this it frm 0 te which ie the decal equivalent for 2 (0011). Noe that wlike binary, we can ot 0 from 0001 to 0010, as this is changing both the 3d bit (to 1) and the hit (Ito 0) 4 Now to increment rom ODI we tat atthe LSB (sight side) and note that we have ‘net seen the combination 001050 fas. As such we keop the fst thee its constant and change the at bit rom 1 t0 0, Hence the gray code for decknal umber 3s 0010 5. Travers tothe next code, We cannot change the Sr or Sth bit as we have seen these combination before Hence we move on othe second bit and change that fom 2D 41. Tis gives the decinal number 4 as O11Din gray code. You may question why we ‘can't we change the hie bit gain which will also be aone-bit change rom the previous, But as changing the third bit would give the equivalent gray code C0 ‘which has occurred cole (decimal number), we canst do this Remember that number acusting previously cannot be sepeated, 6 Repeating our previous steps, we will eep the fist and second bit constant and nd the possible combinations ofthe third and the fourth bits by nly changing ony 1 bt nea steps Stat with he th bit a hiss the SB, “Thebite of it gray cade are considered ae GiG,G,G;, Now from conversion table, Ge=Sm06,9,10,1,12,18,14,18), G2= m4 5,6,7,8,9 10,11) =F m(2,,4,5,10,11,1818), C= F012, 56,9 101,14) “From above SOPs (Sums Of Psoducts) let us rane Karan sips Kempe for Gy Gy Ga andGy >) G, oo 01 11 10 00 ot " 10 G,=8C+BC=BaC > (S) cp ~~ ABN 00 o1 1110 00 i q 1 OF Ms ald Wh lh ad lt wo) gle lth G,=0b+0b=c@0 Application of Gray Code “The gray codes used in afew specie aplication. The main aplication inca being seein analog to digital converters, aswel as being used for ero conection in digital communication. Gray codes used to minmir errors in converting analog signal to dig Horak “Frank Gray ~ the peson Gray code was named after ~ patented a Pals Code Modulation (CM) tube, Tis PEM tbe was ae by Raymond W Sse of Ball Labs vocking with “rank Gray an Wiliam M. Goodall) who credited Gay fo the idea ofthe reflected binary cede (e.gay code), You can read this in elevsion by pulse code modiltion. Some ther applications of gray code: + Boolean circ minimization + Communication between clack domsine + Essar cotection + Genetic algorituns + Mathematical purzes + Poston encoders Advantages of Gray Code + Butes fr ertrmininization ia converting analog signal to digital signals 1 Reduces the ocustence of "Hamming Walls (an ndssrabe state) when used in + Canbe used toin to minimizes logic circuit 4 Useful in clock oman eres Disadvantages of Gray Code + Notaultable for athaetc operations + Lined poactcal use outside fa fw speci applications About EtectricalsU recuical is dedicated to the teaching and shaving ofl things elated to elec and lecronice engineering, oar Related Articles —eS ie) «UU s~UlUU VV Gray Code | Binary to Gray Binary to BCD Code Code.. Converter Electrical 4U Digital Electronics K Map or Karnaugh Map Leave a Comment fievy® request a specific

You might also like