Mudanças entre as edições de "Código Gray"

De MediaWiki do Campus São José
Ir para navegação Ir para pesquisar
(9 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 1: Linha 1:
 +
==Tabela de códigos de 0 a 15==
 +
{| class="wikitable sortable"  border="1" cellpadding="3" cellspacing="0" style="text-align:center; font-size:100%" bgcolor="#efefef"
 +
! scope="col" style="text-align:center"  | Código decimal
 +
! scope="col" style="text-align:center"  | Código octal
 +
! scope="col" style="text-align:center"  | Código hexadecimal
 +
! scope="col" style="text-align:center"  | Código Binário
 +
! scope="col" style="text-align:center"  | Código Gray
 +
! scope="col" style="text-align:center"  | Código One Hot
 +
|-
 +
| 0 || 00 || 0 || 0000||0000 || 0000.0000.0000.0001
 +
|-
 +
| 1 || 01 || 1 || 0001||0001 || 0000.0000.0000.0010
 +
|-
 +
| 2 || 02 || 2 || 0010||0011 || 0000.0000.0000.0100
 +
|-
 +
| 3 || 03 || 3 || 0011||0010 || 0000.0000.0000.1000
 +
|-
 +
| 4 || 04 || 4 || 0100||0110 || 0000.0000.0001.0000
 +
|-
 +
| 5 || 05 || 5 || 0101||0111 || 0000.0000.0010.0000
 +
|-
 +
| 6 || 06 || 6 || 0110||0101 || 0000.0000.0100.0000
 +
|-
 +
| 7 || 07 || 7 || 0111||0100 || 0000.0000.1000.0000
 +
|-
 +
| 8 || 10 || 8 || 1000||1100 || 0000.0001.0000.0000
 +
|-
 +
| 9 || 11 || 9 || 1001||1101 || 0000.0010.0000.0000
 +
|-
 +
|10 || 12 || A || 1010||1111 || 0000.0100.0000.0000
 +
|-
 +
|11 || 13 || B || 1011||1110 || 0000.1000.0000.0000
 +
|-
 +
|12 || 14 || C || 1100||1010 || 0001.0000.0000.0000
 +
|-
 +
|13 || 15 || D || 1101||1011 || 0010.0000.0000.0000
 +
|-
 +
|14 || 16 || E || 1110||1001 || 0100.0000.0000.0000
 +
|-
 +
|15 || 17 || F || 1111||1000 || 1000.0000.0000.0000
 +
|}
 +
 
==Conversão de Binário para Gray==
 
==Conversão de Binário para Gray==
 
Conversão de um número binário de <math> N </math> bits em um número Gray pode ser feita considerando o um número binário inicial
 
Conversão de um número binário de <math> N </math> bits em um número Gray pode ser feita considerando o um número binário inicial
Linha 8: Linha 50:
  
 
Por exemplo para N = 4:
 
Por exemplo para N = 4:
:<math>\ g_{3} = b_{3} </math>
+
:<math>  g_{3} = b_{3} \oplus 0 </math>
:<math>  g_{2} = b_{3} \oplus b_{2} </math>
+
:<math>  g_{2} = b_{2} \oplus b_{3} </math>
:<math>  g_{1} = b_{2} \oplus b_{1} </math>
+
:<math>  g_{1} = b_{1} \oplus b_{2} </math>
:<math>  g_{0} = b_{1} \oplus b_{0} </math>
+
:<math>  g_{0} = b_{0} \oplus b_{1} </math>
  
 
==Conversão de Gray para Binário==
 
==Conversão de Gray para Binário==
Linha 19: Linha 61:
 
para <math>\  i = N-1,          b_{N-1} = g_{N-1} </math>
 
para <math>\  i = N-1,          b_{N-1} = g_{N-1} </math>
  
para <math>  i = [N-2, ..., 0],  b_{i} = g_{i+1} \oplus b_{i+1} </math>
+
para <math>  i = [N-2, ..., 0],  b_{i} = g_{i} \oplus b_{i+1} </math>
  
 
Por exemplo para N = 4:
 
Por exemplo para N = 4:
:<math>\ b_{3} = g_{3} </math>
+
:<math>  b_{3} = g_{3} \oplus 0 </math>
:<math>  b_{2} = g_{3} \oplus b_{3} </math>
+
:<math>  b_{2} = g_{2} \oplus b_{3} </math>
:<math>  b_{1} = g_{2} \oplus b_{2} </math>
+
:<math>  b_{1} = g_{1} \oplus b_{2} </math>
:<math>  b_{0} = g_{1} \oplus b_{1} </math>
+
:<math>  b_{0} = g_{0} \oplus b_{1} </math>
 +
 
 +
Ou expandindo:
 +
:<math>  b_{3} = g_{3} \oplus 0 </math>
 +
:<math>  b_{2} = g_{2} \oplus g_{3}  </math>
 +
:<math>  b_{1} = g_{1} \oplus g_{2} \oplus g_{3} </math>
 +
:<math>  b_{0} = g_{0} \oplus g_{1} \oplus g_{2} \oplus g_{3} </math>
  
==Tabela de conversão de 4 bits==
+
==Curiosidade==
{|class="prettytable"
+
*[https://patentimages.storage.googleapis.com/a3/d7/f2/0343f5f2c0cf50/US2632058.pdf PULSE CODE COMMUNICATION Patente US2632058] Depositante: Bell Labs,  Inventor: Frank Gray.  Essa patente descreve o código Gray.
!Código decimal
+
*[https://en.wikipedia.org/wiki/Gray_code História e usos do código Gray] [https://en-m-wikipedia-org.translate.goog/wiki/Gray_code?_x_tr_sl=auto&_x_tr_tl=pt&_x_tr_hl=pt-BR&_x_tr_pto=wapp]
!Código Binário
 
!Código Gray
 
|-
 
|0||0000||0000
 
|-
 
|1||0001||0001
 
|-
 
|2||0010||0011
 
|-
 
|3||0011||0010
 
|-
 
|4||0100||0110
 
|-
 
|5||0101||0111
 
|-
 
|6||0110||0101
 
|-
 
|7||0111||0100
 
|-
 
|8||1000||1100
 
|-
 
|9||1001||1101
 
|-
 
|10||1010||1111
 
|-
 
|11||1011||1110
 
|-
 
|12||1100||1010
 
|-
 
|13||1101||1011
 
|-
 
|14||1110||1001
 
|-
 
|15||1111||1000
 
|}
 

Edição das 18h27min de 7 de junho de 2022

Tabela de códigos de 0 a 15

Código decimal Código octal Código hexadecimal Código Binário Código Gray Código One Hot
0 00 0 0000 0000 0000.0000.0000.0001
1 01 1 0001 0001 0000.0000.0000.0010
2 02 2 0010 0011 0000.0000.0000.0100
3 03 3 0011 0010 0000.0000.0000.1000
4 04 4 0100 0110 0000.0000.0001.0000
5 05 5 0101 0111 0000.0000.0010.0000
6 06 6 0110 0101 0000.0000.0100.0000
7 07 7 0111 0100 0000.0000.1000.0000
8 10 8 1000 1100 0000.0001.0000.0000
9 11 9 1001 1101 0000.0010.0000.0000
10 12 A 1010 1111 0000.0100.0000.0000
11 13 B 1011 1110 0000.1000.0000.0000
12 14 C 1100 1010 0001.0000.0000.0000
13 15 D 1101 1011 0010.0000.0000.0000
14 16 E 1110 1001 0100.0000.0000.0000
15 17 F 1111 1000 1000.0000.0000.0000

Conversão de Binário para Gray

Conversão de um número binário de bits em um número Gray pode ser feita considerando o um número binário inicial , o número Gray correspondente pode ser obtido através de:

para

para

Por exemplo para N = 4:

Conversão de Gray para Binário

Conversão de um número Gray de bits em um número binário pode ser feita considerando o um número Gray inicial , o número binário correspondente pode ser obtido através de:

para

para

Por exemplo para N = 4:

Ou expandindo:

Curiosidade