C H U B IE N : PTS D 6 K I M B A N G
i
/ A /
LY THUYET & UNG DUNG
Trang 2PTS DO KIM BANGBien soan'Mg f -1ky mm soZ7n rmJ□K y□mB< i i: ys; i iiA i K’jfljS M1EUKG TAM HQC U f 0
Trang 3LQ1 H 0 3 B & I
Ngay nay, ky thuat digital dUOc ap dung rong rai trong nhieu ITnh virc Cac mach digital dude dira vao sirdung trong hang loat cac san pham dien tif, nhi/ cac thiet bi vien thong, may ti'nh, ti_r dong hoa, cac do choi co mach dien tCr, cac he thong nghe nhin, do gia dung, dung cu do luting, dung cu y te va quan sir, cac tur dien dien tCr_
Sach Ky thuat digital - ly thuyet va Crng dung gidi thieu nhCrng kien thud co ban ve ky thuat digital va mot so irng dung trong doi song Be tiep thu cac kien thud de cap trong cuon sach nay, ban doc can co nhCrng kien thud pho thong ve toan va ve mach dien tir Ky thuat digital dude nghien ciru trutic hoac nghien cuti song song v6i mon hoc dien tir co ban vi cac kien thud ve linh kien ti'ch cifc rdi rac khong phai la dieu kien doi hoi trutic het.
Co the noi, cuon sach nay la ngirdi ban dong hanh cua cac ban ham thich dien ti!r digital, cua cac cong nhan nganh dien tu” - vien thong va may ti'nh cGng nhif cua cac cong nhan lanh nghe thuoc cac ITnh vu t co lien quan den cac mach dien tu1 digital Cuon sach nay dirpc xem nhir la tai lieu tham khao hCru dung vi ti'nh th u t dung va de hieu cua no doi vdi cac sinh vien cao dang va dai hoc nganh dien tCr - vien thong va may ti'nh.
Sach Ky thuat digital - ly thuyet va u"ng dung co 11 chirong Chi/ong 1 khai quat ve cac he thong so nhi phan, bat phan va thap luc phan, moi lien quan giCra cac he thong nay vdi he thong so thap phan, chi/Ong nay cGng gidi thieu tong quan cac ma diroc sCr dung trong ITnh vi/c vien thong va may tfnh Chutfng 2 gidi thieu ve dai so logic, phan tich va tong hop mach logic, cac djnh ly De Morgan, cac phifOng phap toi gian mach bang bang Karnaugh, bang cac dinh ly va dinh luat cua dai so logic Chi/dng 3 gidi thieu cac mach xir ly so lieu, de cap den cac bo ghep kenh, phan kenh, cac bo giai ma, ma hoa, bo tao va kiem tra bit chan le Noi dung Chi/ong 4 noi ve phep cong, phep trif so hoc, cac phep bu 1, bu 2 va cac bo niTa cong va cong day du, de tirdo, ta hieu di/Oc can ke cac bo cong va bo trir ChiTOng5 gidi thieu cac ho IC TTL va CMOS, noi dung de cap trong phan nay giup ta co cac kien th u t co ban de sCr dung co hieu qua va phoi ket hop di/oc cac ho IC TTL va CMOS trong cac mach digital Noi dung cac Chuting 6, ChiTOng 7 va ChGOng 8 di/oc u'ng dung nhieu trong cac mach dien tu1 digital thong thuting ChifOng 6 gidi thieu cac loai flip flop RS, RS dong bo tTnh, flip flop D, flip flop JK va flip flop JK Master-Slave; ngoai ra, con gidi thieu trigo Schmitt, loai trigo co dac ti'nh quan trong, dude su' dung de tao nen cac xung nhip; Chudng nay cung gidi thieu cac loai mach dao dong, mach tao xung nhip Noi dung ChUdng 7 thirc chat la cac u’ng
Trang 4dung dac ti'nh cua cac flip flop diroc ti'ch hap trong cac IC de thirc hien cac phep di chuyen so lieu Trong chirong 8, noi dung diroc de cap la cac loai bo dem va cac Mod dem; tir chirong nay, ta thay diroc cac cau true va cac iru nhiroc diem cua cac loai bo dem Chirong 9, bo nho ban dan va chirong 10, chuyen doi A/D va chuyen doi D/A, hai chirong nay gidi thieu ve nhCrng nguyen ly cau tao co ban va cac dac ti'nh cua cac bo nho ban dan, cac bo chuyen doi A/D va chuyen doi D/A, giup ta co the Crng dung cac bo kien nay trong cac mach dien tir digital Chirong 11 dira ra mot so mach Crng dung ky thuat digital, nhir trong dung cu dem tan, do do rong xung va trong dong ho digital Co the xem chirong 11 nhir la mot so bai tap Ion, Crng dung ky thuat digital, tir do, ta co the van dung ky thuat digital vao cac Crng dung khac trong doi song hang ngay.
Voi dung y cuon sach Ky thuat digital - ly thuyet va Crng dung diroc viet de pho cap rong rai kien thCrc ve digital, voi cach trinh bay de hieu, co nhieu vi du, nhieu bai tap va loi giai Tac gia rat mong cuon sach diroc dong dao cac cong nhan lanh nghe cung nhir cac sinh vien cao d in g va dai hoc nganh dien tir - vien thong va may ti'nh, cac ban yeu thi'ch ky thuat dien tir digital rut ra diroc nhCrng dieu bo ich tu” cuon sach nay.
Trong qua trinh bien soan va in an, cuon sach khong the tranh khoi con nhCrng thieu sot Chung toi rat mong ban doc thong cam va gop y xay diing, de trong Ian tai ban, cuon sach diroc hoan thien hon.
Chung toi xin gCri toi Ban Bien tap Nha Xuat ban Lao dong - Xa hoi loi cam on chan thanh ve sir giup do qui bau cua Qui Ban, de cuon sach s6m dGOc ra m§t ban doc.
DO KIM BANG
Trang 5CHUONG 1
HE THONG SO V A M A■
Hoc xong chuang nay, hoc vien co kha nang:
□ Hieu dwoc cac he dem thap phan, nhi phan,
bat phan va thap luc phan.
□ Chuyen doi d'uoc cac so tit he thap phan
sang cac he nhi phan, bat phan va thap luc phan va ngwoc lai.
□ Tinh d'L/oc cac gia tri cua cac so phan
nguyen va phan phan tit cac he nhi phan, bat phan va thap luc phan sang cac so tuong ditong cua he thap phan va ngitdc lai.
□ Hieu diroc cac cau true mot so ma thong
thudng dung trong ky thuat digital.
TONG QUAN
Khi noi den so dem, moi ngirdi deu nghT ngay den he thap phan v6i 10 con so: 0, 1,2, 3, 4, 5, 6, 7, 8, 9 May vi tinh hien dai khong xir ly so thap phan Thay vao do la he thong so nhi phan sir dung 2 con so: 1 va 0 Nhi/ng khi sir dung so nhi phan, muon the hien mot so thap phan co tri so tirong doi Ion bang so nhi phan thi so nhi phan do kha dai Do do, ngirdi ta thirdng sir dung cac so bat phan va thap luc phan de rut ngan chuoi so nhi phan.
Chirong nay trinh bay cac he nhi phan, bat phan va thap luc phan v6i muc di'ch khong chi dem diroc cac so theo cac he dem tren day ma con nghien ciru each chuyen doi tir he dem thap phan sang cac he dem nhi phan, bat phan va thap luc phan va ngiroc lai Chu’Ong nay cung de cap den cac ma nhi phan thirdng diroc su' dung trong cac he thong digital.
Trang 61.1 SO NHj PHAN
Cac may vi ti'nh va cac he thong digital deu dira tren co so hoat dong nhi
phan (2 trang thai) Vi du, khoa chuyen mach trong Hinh 1.1a co the diroc dong lai
hoac mo ra Do do, khoa chuyen mach la mot vi du ve thiet bi nhi phan don gian nhat.
Tranzito trong cac mach dien tir dung trong cac he thong va cac may tinh digital diroc thiet ke de hoat dong tirong hop v6i he thong nhi phan, do la hien tirong ngirng dan hoac dan bao hoa cua tranzito Ket qua la 6 ngo ra cua mach tranzito co mot trong hai trang thai mire dien ap cao hoac mire dien ap thap Khi quan sat tin hieu digital tren may hien song thay dien ap hoac 6 m u t thap hoac 6 mire cao Cac tin hieu digital nay thay doi mire dien ap khi may vi ti'nh hoat dong,
cac dien ap nay xuat hien nhir la cac xung (Hinh1.1b)
5V 5V+v o < ►cy +5v-+ Q I Q~r»- —#-o o-lov L_<a) b)
Hinh 1.1 Cac vi du ve sir dung so nhi phan
Tom lai, cac khoa chuyen mach, cac tranzito va cac linh kien digital khac deu dira tren co so he nhi phan Oieu do noi len rang so nhi phan rat thuan tien khi dung vao viec phan tich va tong hop cac mach digital Ngoai ra, can biet cach dem so nhi phan va chuyen doi so nhi phan ra thap phan va ngiroc lai.
1.2 CHUYEN DOI NHI PHAN - THAP PHAN
Co the bieu dien so nguyen bat ky thanh cac so don vi, chuc, tram, nghin Vi du, so thap phan 2945 co the viet thanh:
2945 = 2000 + 900 + 40 + 5
(1.1)
Bieu dien diroi dang luy thira cua co so 10, bieu thirc (1.1) co the viet lai la:2945 = 2.103 + 9 102 + 4 101 + 5 10°
(1.2) f
" t ^
Vi tri cac con so
Moi vi tri con so trong day so 2945 co mot trong so va he so.
Trang 7Cac luy thi/a co so 10 :103, 102, 101, 10° la cac trong so.Cac so 2, 9, 4 va 5 la cac he so.
Ti'ch trong so va he so cho gia tri cua moi vi tri con so.Tong tat ca cac ti'ch cho gia tri cua so thap phan do.
6 vi du tren, 2 nhan vdi trong so 1000, 9 nhan v6i trong so 100, 4 nhan vdi trong so 1, tong so la:
2000 + 900 + 40 + 5 = 2945
- Trong so nhj phan
Bang cach tirong tir, ta co the viet lai mot so nhi phan nao do voi cac trongso.
Vi du: so nhi phan 111 diroc viet la:111 = 100 + 10 + 1(1.3)
Bieu thirc (1.3) viet dirdi dang thap phan:
7 = 4 + 2 + 1
(1.4)
Khi viet so nhi phan nhir trong bieu thirc (1.3) ta se lam mot viec tirong tir phan doan so thap phan thanh don vi, 2s va 4s nhir trong bieu thirc (1.4).
So co trong so nho nhat diroc goi la LSD, so 1 6 ben phai, co trong so nho nhat; so co trong so I6n nhat diroc goi la MSD, so 4 6 ben trai day so co trong so Idn nhat.
Noi cach khac, moi vi tri so cua so nhi phan co mot trong so Vi tri thCr nhat 6 ben trai, so 1, (trong so nhoi nhat Vi tri thCr hai tir ben phai co trong so 2, so ben trai lien ben co trong so 4.
Cac trong so nay co so mu cua luy thira 2 tang len, do do, co the viet phirong trinh (1.4) nhir sau:
7 = 1 22 + 1 21 + 1 2°
Moi khi gap so nhi phan ta co the xac dinh diroc mot so thap phan tirong dirong nhir sau:
1 Khi co so 1 6 mot vi tri con so, hay cong trong so cua vi tri do.2 Khi co so 0 6 mot vi tri con so, bo qua trong so cua vi tri do.Vi du, so nhi phan 101 tirong dirong vdi so thap phan la:
4 + 0 + 1 = 5
Trang 8Phi/dng phap doi so nhj phan ra thap phan theo thu tuc sau:
1 Viet so nhi phan.
2 Viet tri/c tiep dirdi so nhi phan cac so 1, 2, 4, 8, 16 va viet tu1 phai qua trai.3 Neu co so 0 0 mot vi tri con so, xoa bo trong so 0 vi tri do.
4 Cong cac trong so con lai ta diroc so thap phan tirong dirong.
Vi du: Hay chuyen doi so nhi phan 101 thanh so thap phan tirong dirong:
Bl/oc 1: 1 0 1 Bl/oc 2:4 2 1 Bade 3: 4 (2) 1 Bl/Oc 4: 4 + 1 =5.
Vi du: Hay chuyen doi nhanh so nhi phan dirdi day thanh so thap phan ti/Ong dirong:
1 0 1 0 1
16 (8) 4 (2) 1 = 21
- Phan phan cua so nhj phan
Ta da nghien ciTu phan nguyen Vay phan phan cua so nhi phan diroc chuyen doi thanh so thap phan tirong dirong nhir the nao?
Vi du, so thap phan nao tirong dirong vdi so nhi phan 0, 101? Trong trirdng hop nay cac trong so cua cac vi tri tir phia phai dau phay cua so nhi phan la: 1/2; 1/4, 1/8, 1/16 v.v
Neu viet diroi dang luy thira cua 2, cac trong so la:2"1 , 2"2 , 2'3, , v.v
hoac dirdi dang thap phan la:
0,5; 0,25; 0,125; 0,0625; v.v
-> ^ f
O vi du nay, phan phan cua so nhi phan 0,101 la:
0 , 1 0 1
0,5 (0) 0,125 = 0,625 Vi du khac, so thap phan tirong dirong cua 0,1101 la:
0, 11 0 1
0,5 0,25 0 0,0625 = 0,8125
- So nhj phan hon hop
Trang 9v V 23 22 2 1 2°, 2~1 2 "2 2“3
/
dau phay nhi phan
9,
- Bieu do may vi tinh
Khi nghien cifu cac so nhi phan, ta hieu biet sau sac them ve cau tao ben
trong cua mot may vi tinh Hinh 1.2 la cac phan co ban cua mot may vi ti'nh diroc
gidi thieu nhir sau:
Ngo vao: la noi dira chirong trinh va so lieu vao may, 6 may vi tinh ngo vao bao gom ban phim de chuyen doi ky tir (chCr va so) thanh chuoi cac so lieu nhi phan.
Bo nhd: la noi chirong trinh va so lieu diroc liru trir trudc khi tinh toan Cung
vay, khi ti'nh toan, bo nhd liru tru” cac tra loi trung gian, tirong ti/ nhir cach ta v ln lam khi ti'nh toan Bo nhd cua may vi tinh gom co ROM (bo nhd chi doc) va RAM (bo nhd viet va doc).
Dieu khien: phan nay cua may vi ti'nh trong qua trinh ti'nh toan khong nhd con
ngirdi can thiep vao Phan dieu khien noi cho cac phan cua may vi ti'nh cach xir ly so lieu nhir the nao ^
Phep tinh so hoc va logic: phan nay la cong, trCr, nhan va chia Phan nay
cGng thirc hien cac phep tinh logic nhir OR, AND, NOR, NAND v.v
Ngo ra: la phan de chuyen Idi giai cuoi cung ra ben ngoai Phan ngo ra cua
may vi ti'nh la man hinh cho phep ngirdi sir dung thay diroc cac so lieu da diroc xir
iy-BO DIEU KHIEN
NGO VAO BO NH0 KHOI SO HOC VA LOGIC NGO RA
rr Tt v
Hinh 1.2: Cac phan co ban cua mot may vi ti'nh
Trang 10Trong bang dirdi day thong ke cac luy thira cua 2 va so thap phan tirong dirong cua chung, cung cac so K Ky hieu K thay cho 1024 Do do, 1K b ln g 1024 2K bang 2048 4K b ln g 4096 v.v Nhieu may vi tinh ca nhan (PC) co cac bo nho 64K, dieu do co nghla la chung co the liru trir 65.536 byte trong phan bo nhd chi ra 6 Hinh 1.2
Bang 1.1 Cac luy thira cua 2
CAC LUY THUA CUA 2
SO THAP PHAN TUUNG OUtfNG
CAC LUY THUTA CUA 2SO THAP PHAN TUtfNG BlTCfNGKY HIEU2°1 282562 1229512224 2'o 10241K238 2 i ’ 20482K2416 2« 40964K25322 1S81928K2s642 141638416K271282156553632K
1.3 CHUYEN DOI THAP PHAN - NHj PHAN
Cach chuyen doi so thap phan thanh so nhi phan tirong dirong la cach tien hanh ngiroc vdi cach chuyen doi da di/oc mo ta 0 tren.
+ Vi du, muon chuyen doi so thap phan 9 thanh so nhi phan tirong dirong, dieu can thirc hien la bieu thi diroc 9 la tong cua cac luy thira cua 2, roi viet 1 va 0 0 cac vi tri cua cac con so:
So thap phan ^ 9 = 8 + 0 + 0 + 1
So nhi phan ► 1 0 0 1
+ Mot vi du khac: Chuyen doi so thap phan 25 thanh so nhi phan tirong dirong:
So thap phan: ^ 25 = 16 + 8 + 0 + 1
So nhi phan: ► 1 1 0 1
- Phirong phap chia tuan tir cho 2
Phirong phap pho bien de chuyen doi cac so thap phan sang nhi phan la cach chia tuan tir so thap phan cho 2 viet so du” sau moi phep chia Cac so dir du'o'c slip xep theo thir tu ngu'dc se cho ta so nhi phan tuong dirong Cach tot nhat de hieu phirong phap nay la thirc hien vi du dudi day:
Cach chuyen doi so thap phan 53 ra so nhi phan nhir the nao?
Trang 11Thi/c hien chia 53:2 = 26 26:2 = 13 13:2 = 6 6:2 = 3 3:2 = 1 1:2 =■ 0
Ket qua la: 5310
Phan dir 1 0 1 0 1 1110101,
So co trong so nho nhat (LSD)
oo-♦oD'<&JZO
So co trong so Idn nhat (MSD)
- Phircfng phap trir
Be thirc hien viec chuyen doi so thap phan sang so nhi phan, ngoai phirong phap chia lien tiep so thap phan cho 2, con co phirong phap trir bang cach don gian viet cac gia tri cua cac so luy thira 2 cho den so co gia tri gan vdi so thap phan can chuyen doi Sau do, trir lien tiep so thap phan cho cac so luy thira 2 Neu phep trir di/oc thirc hien vi so luy thira nho hon so thap phan, ta viet so nhi phan 1 vao vi tri bit tirong Crng v6i so luy thira 2 Neu so luy thira I6n hon so thap phan 6 phan dir, ta viet so 0 vao vi tri tirong ting cua so luy thira do va tiep tuc thirc hien cac bu6c cho cac so luy thira 2 ke ben Oe biet cach chuyen doi so thap phan sang so nhi phan bang cach trir, tot hon het ta lam vi du sau day.
Vi du, hay chuyen doi so thap phan 50 sang so nhi phan So luy thira 2 Idn nhat nho hon so 50 la 32 Viet cac so luy thira 2 tir 25 tro xuong Phirong phap trCr diroc thirc hien nhir sau:
50 -22 18 l f i _ -232116140
Ket qua la: 5010 = 1100102
- Phan phan
Ta nhan phan phan cua so thap phan voi 2, ghi lai so nhd 6 vi tri nguyen Cac so nho doc theo chieu xuong la phan phan cua so nhi phan.
Trang 12Vi du: Chuyen doi so 0,95 ra so nhi phan nhir sau:0,95X2 - 1,9 = 0,9 vdi so nh6 la 10,9X2 = 1,8 = 0,8 1 O )c0,8X2= 1,6 = 0,61'<oaX0,6X2= 1,2 = 0,21 oo-♦o0,2X2= 0,4 = 0,40 '<0)0,4X2- 0,8 - 0,80 iJ Zr O0,8X2= 1,6 = 0,61
Doc cac so nhd theo chieu tCr tren xuong cho ta phan phan cua so nhi phan 0,1111001 Trong trirdng hop nay, ta dung phep chuyen doi sau khi nhan diroc 7 con so nhi phan Vi ly do do, Idi giai nay diroc xem la gan dung Neu can chi'nh xac hon nCra, ta tiep tuc nhan cho 2 den khi co nhieu con so va dat mire chi'nh xac can thiet.
Ket qua la: 0,9510 = 0,11110012
- Doi so nhj phan gom toan so 1
Khi nao mot so nhi phan co toan so 1, co the tim so thap phan tirong dirong bang cach dung cong thu’c sau: so thap phan = 2n - 1, 6 day n la so bit.
+ Vi du: 1111 co 4 bit, do do, so thap phan tirong dirong la:So thap phan 24 - 1 = 15.
Ket qua la: 11112 = 1510
+ Mot vi du khac: 1111 1111 co 8 bit, nen:
So thap phan tirong dirong = 28 - 1 = 255.Ket qua la: 111111112 = 25510
1 4 s o b A tp h a n
Co so cua mot he thong so bang so cac con so ma he thong do sir dung.He thong so thap phan co co so la 10 vi he thong nay co cac con so tir 0 den 9 He nhi phan co co so 2 vi no chi dung so 0 va so 1 He bat phan co co so 8 Ta co the sir dung 8 con so thong thirdng, do la 8 con so dau tien:
0, 1, 2, 3, 4, 5, 6, 7
(khong co con so 8 va 9 trong he thong so bat phan)
Cac con so trong he bat phan co cung y nghTa vat ly nhir cac so thap phan.
Trang 13- Sir chuyen doi bat phan - thap phan
Sir chuyen doi tir bat phan sang thap phan nhir the nao? Trong he bat phan moi vi tri con so tirong ung voi luy thtia co so 8 nhir sau:
83 82 8 1 8° , 8“ 1 8‘‘2 8~3
dau phay bat phan
Do do, de chuyen tu" bat phan sang thap phan, ta nhan moi so bat phan vdi trong so cua no va cong tat ca cac ti'ch iai:
Vi du: so bat phan 23 chuyen doi sang thap phan nhir sau:2 x (81) + 3 x (8°) = 16 + 3 = 19Mot vi du khac, doi so bat phan 257 thanh thap phan:
2 x (82) + 5 x (81) + 7 x (8°) = 128 + 40 + 7 = 175
- Chuyen doi thap phan sang bat phan
Sir chuyen doi thap phan - bat phan diroc thirc hien nhir the nao?
6 day, thay the cho phep chia cho 2, ta chia cho 8 (co so 8), ghi lai phan dir sau moi phep chia Cac so dir theo mot trat tir ngiroc tao nen so bat phan.
Vi du, chuyen doi sang bat phan so thap phan 175 nhir sau:0 2 (so dir thu* 3)
8) 2 5 (so du1 thu* 2)8)21 7 (so du* thu* nhat)8)175
Viet gon lai nhir sau:
0
2 21 8) 175
Ket qua la: 17810 = 2578
- Phan phan
Voi cac so phan cua he bat phan, phep nhan thay the cho phep chia va viet so nho vao phan nguyen Vi du, chuyen doi phan phan cua so thap phan 0,23 thanh phan phan cua so bat phan:
Trang 140,23 x 8 = 1,84 = 0,84 vdi so nh6 la 10,84 x 8 = 6,72 = 0, 72 vdi so nhd la 60,72 x 8 = 5,76 = 0,76 vdi so nhd la 5oo-*o'«DoV V
Cac so nhd doc theo chieu xuong cho phan phan cua so bat phan Neu doi hoi co do chi'nh xac cao hon, ta tiep tuc nhan se diroc nhieu con so bat phan hon.
Ket qua la: 0,2310 = 0,1658
? 9
- Chuyen doi bat phan - nhj phan
Vi 8 (co so cua he bat phan) la luy thira 3 cua 2 (co so cua he nhi phan), nen ta co the chuyen doi tir bat phan sang nhi phan bang cach chuyen moi so bat phan sang so nhi phan tirong dirong.
+ Vi du, chuyen so bat phan 43 thanh so nhi phan tirong dirong nhir sau:
So bat phan ► 4
l i
So nhi phan -► 100 011
O day, moi so bat phan chuyen sang nhi phan tirong dirong (4 tro thanh 100,3 tro thanh 011) So nhi phan 100 011 tirong dirong voi so bat phan 43 thirdng thi bo khoang trong giira cac nhom 3 bit, dieu do lam cho viec doc so nhi phan de dang hon.
+ Mot vi du khac, mot so bat phan diroc chuyen thanh nhi phan nhir sau:
So bat phan — ► 3 5 7 4
11
So nhi phan — ► 011101111100
Ket qua la: 35748 = 01 11 011 1 11002.
+ Mot vi du khac: khong kho khan gi khi chuyen so bat phan hdn hop (ca phan nguyen Ian phan phan) sang so nhi phan tirong dirong So bat phan 34.562 trd thanh:
So bat phan -► 3 4 5 62
1111I
So nhi phan -► 011100101110010
Ket qua la: 34,5628 = 011100.1011100102
- Chuyen doi nhi phan - bat phan
Chuyen doi tir nhi phan sang bat phan la thirc hien ngiroc lai thu tuc trirdc day De dang nhd lai rang moi nhom gom 3 bit, b£t dau tinh tir dau phay nhi phan roi chuyen moi nhom thanh so bat phan tu'Ong dirong (them so 0 vao moi dau cua
Trang 15day nhi phan cho day nhom neu can thiet) Vi du, so nhi phan 1011,01101 chuyen nhir sau:
1011 ,01101 "► 001011011010
111
-> 1 3 3 2
So bat phan hon hop
Bat dau tif dau phay nhi phan, thu’c hien theo hai hirdng, tach cac bit thanh nhom 3 Trong trirdng hop nay, them cac so 0 de cac nhom ben ngoai cung diroc day 3 bit Chuyen moi nhom thanh so bat phan tuting di/Ong.
Ket qua la: 1011,011012 = 13,328
Viec chuyen doi de dang tis bat phan thanh nhi phan va ngiroc lai co nhieu iru
viet vi lay tin ra hoac cho tin vao he thong digital it doi hoi ve cau true mach vi chung de dang doc va in ra so bat phan hon la so nhi phan.
Mot iru viet khac nira la cac so thap phan Idn diroc chuyen doi de dang sang nhi phan neu trirdc het chuyen sang bat phan, roi sau do chuyen sang nhi phan.
Vi du: chuyen doi so thap phan 363 thanh so nhi phan.Tri/dc het doi sang bat phan
05458) 363553oo-*o=3-<Q)_CO
Tiep theo, doi so bat phan 553 thanh so nhi phan tirong dirong:
So bat phan ► 5 5 3
So nhi phan * 101 101 011
Ket qua la: 36310 = 5538 = 1011010112
1.5 SO THAP LUC PHAN
So thap luc phan diroc sir dung rong rai doi vdi (iP Trirdc het, so thap luc phan ngan hon so thap phan Dieu do lam cho de viet va de nhd cac so thap luc phan Hon nura, ta co the nham moi khi chuyen sang he nhi phan
He thap luc phan co co so 16, co tat ca 16 con so tir so 0 den so 9, tir A den F Noi mot cach khac, sau khi dem den so 9 trong he thap luc phan, ta tiep tuc dem nhir sau:
A, B C, D, E, F
Trang 16- Chuyen doi thap luc phan - nhj phan
Muon chuyen doi mot so thap luc phan sang so nhi phan, ta chuyen doi moi con so thap luc phan thanh 4 bit tirong di/Cng khi dung ma ghi trong Bang 1.2: So thap luc phan va cac so thap phan, nhi phan tirong dirong"
Vi du, chuyen so thap luc phan 9 A F thanh nhi phan, ta thirc hien nhir sau:
9 A F so thap luc phan
i i i
100110101111 * so nhiphan
- Chuyen doi nhj phan - thap luc phan
Chuyen doi ngiroc lai, tir nhi phan sang thap luc phan, ta lai dung ma trong
Bang 1.2 O day co 2 vi du,
+ So nhi phan 1000 1100 chuyen sang thap luc phan nhir sau:
D001100
▼
8
▼C
+ So nhi phan: 1110 1000 0110 chuyen sang thap luc phan nhir sau:
1110 1000 1101 0110
I I I I
E 8 D 6
Trong 2 vi du tren, ta deu bat dau bang so nhi phan va ket thuc bang so thap luc phan tirong dirong.
Bang 1.2: So thap phan va
cac so thap luc phan, nhi phan tirong dirong
s 6 thApphans 6 thAplucphAns6 NHI phAn
Trang 17- Chuyen doi thap luc phan - thap phan:
Chuyen doi so thap luc phan sang thap phan nhir the nao? Trong he thap luc phan, moi vi tri con so ti/Ong ifng vdi luy thira c0 16 trong so cua cac vi tri so trong he thap luc phan nhir sau:
163 162 161 16° , 16“ 1 16~2 16-3
Dau phay thap luc phan
Do do, de chuyen doi tir thap luc phan sang thap phan, ta nhan moi con so thap luc phan vdi trong so cua no, roi cong tat ca cac ti'ch lai vdi nhau.
Vi du, so thap luc phan F 8 E 6 , 3 9 chuyen sang thap phan nhir sau:F 8 E 6 , 3 9 = F x (163) + 8 x (162) + E x (161) + 6 x (16°)+ 3 x (16~1)+ 9 x(16“2)
= 15 x (163) + 8 x (162) +14 x (161)+ 6 x (16°)+ 3 x (16~1)+ 9 x (16~2)= 61.440 + 2048 + 224 + 6 + 0,1875 + 0,0352 = 63.718,2227
- Chuyen doi thap phan - thap luc phan
Cach chuyen doi thap phan - thap luc phan bang cach chia lien tiep cho 16, ghi lai cac so dir tirong tir nhir cac cach doi thap phan sang nhi phan va bat phan tren day.
Vi du, chuyen doi so thap phan 2479 thanh so thap luc phan nhir sau:
09 — >• 9
910 — > A
15415 “> F▼
16)2479
Ket qua la: 247910 = 9AF16
oo-XD13•<gjO1.6 MA ASCII
De xuat nhap tin tir may vi ti'nh, ta can vai loai ma so alpha (loai ma cho cac chCr, cac so va cac ky tir khac) Co mot thdi, cac nha san xuat da dung cac ma so alpha rieng cua minh, dan den sir roi loan trong viec san xuat, vi nhieu loai ma khac nhau diroc dung vao viec xuat nhap tin Trong cong nghiep tin hoc, ngirdi ta da thong nhat dung ma ASCII (ASCII: American Standard Code for Information Interchange) Ma nay cho phep nha san xuat tieu chuan hoa phan cCrng cua mayvi ti'nh nhir ban phim, may in va man hinh.
Trang 18- Sur dung ma ASCII
Ma ASCII (doc la as-ki) la ma 7 bit x6, x5, x4, x5, x4, x3, x2, x1t x0, trong do x la so 0 hoac so 1 Vi du, chCr A di/pc ma hoa la: 1000001, de de doc, ta viet 100
0001.
Bang 1.3 gi6i thieu ma ASCII Doc Bang 1.3 tirong tir nhir doc bang graph
Vi du, chCr A co day bit x6 x5 x4 la 100 va day bit x3 x2 x1 xO la 0001 Do do, ma ASCII la: 100 0001 (A)
Bang 1.3 co so ma cho chCr thirdng ChCr a co ma la: 110 0001 (chuf a)
Cac vi du khac la: 110 0010 (chCr b); 110 0011 (chCr c) v.v
Trong BANG 1.3 cum SP thay cho khoang trang (space) Go vao thanh SP
cua ban phi'm ASCII la nap vao may vi tinh ma 010 0000 (space)
- Bit ch in le
Ma ASCII diroc dung de truyen tren dirong day dien thoai Nhir vay co the khi truyen dan gay ra sai loi Mot bit c h in le thirdng diroc sir dung de truyen dan cung vdi cac bit goc de phat hien cac sai loi Mot bo kiem tra bit chan le d dau thu co the kiem tra bit chan va bit le xem co trung hop vdi bit c h in bit le da dirpc sap xep trirdc d may phat va may thu hay khong.
Vi ma ASCII co 7 bit, them mot bit chan le de tao nen so lieu diroc truyen di la8 bit, co ki'ch cd sau:
x7 X6 X5 X4 X3 X2 Xtx0
/*
bit chin, bit le
Day la do dai ly tirong vi hau het thiet bi digital diroc xac lap de truyen di cac byte (8 bit) so lieu.
1.7 MA D J 3
Ma dir 3 la ma 4 bit quan trong, thirdng dupe dung vdi ma BCD De chuyen doi so thap phan nao do thanh dang ma dir 3, them 3 vao mdi con so thap phan, roi chuyen do’i tong do thanh so nhi phan 4 bit.
Vi du, chuyen do’ i so thap phan 12 thanh ma du1 3 Trirdc het cong them 3 vao moi con so thap phan:
1 2
+ 3 + 3
4 5
Trang 19BANG 1.3: MA ASCIIW AX*X,X40100111001011101110 0 0 0SP0 @ p P0 0 0 1 1 1A Q a q0 0 1 0 " 2BRbr0 0 1 1#3CScs0 1 0 0$4DTdt0 1 0 1%5EUeu0 1 1 0&6FVfV0 1 1 17Gww1 0 0 0 ( 8HXh X1 0 0 1 ) 9IYi V1 0 1 0 * JZ .i z1 0 1 1+Kk1 1 0 01<LI1 1 0 1 - = M m1 1 1 0>Nn1 1 1 1/ 7 Oo
Sau do, chuyen doi cac tong nay thanh ma BCD
4 5
^ I
0100 0101
Nhir vay, 0100 001 la ma dir 3 thay the cho so thap phan 12 Mot vi du khac, chuyen doi so 29 thanh ma du" 3:
2 9
+ 3 + 3
5 12
1
01011100
Sau khi da cong 9 vdi 3, khong nho 1 vao cot ben ma chuyen doi nhir da tien hanh d tren Do do, 0101 1100 la ma dir 3 thay the cho so thap phan 29.
Mach ti'ch hop dung de chuyen doi ma dir 3 thanh thap phan thirdng dirpc dung la 7443 IC TTL nay co 4 ngo vao cho ma dir 3 va 10 ngo ra cho so thap phan (xem thong so cua IC 7443)
1.8 MA G R A Y
Bang 1.4 gidi thieu ma GRAY, tirong Crng vdi so nhi phan Moi so cua ma
GRAY khac vdi so trudc 1 bit Vi du, d so thap phan tir 7 den 8, so ma GRAY thay
Trang 20doi tir 0100 den 1100, cac so nay chi khac 6 bit co trong so Idn nhat (MSB) Nhi/ trong mot vi du khac, so thap phan 13 va 14 dupe chuyen doi thanh ma GRAY la 1011 va 1001; cac so nay chi khac mot vi tri so (vi tri thu1 hai ke tir ben phai) Nhir vay, trong toan bo ma GRAY, moi so chi khac 1 bit v6i so trirdc.
Ngoai ma du” 3 va ma GRAY, con co nhieu loai dang ma nhi phan, nhir ma BCD, ma nay con dirpc goi la ma 8 4 2 1.
Bang 1.4: Ma Gray
THAP PHANMA GRAYNH|PHANTHAP PHANMAGRAYNHI PHAN