Page 1

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í ¤ÍÁ¾ÔÇàµÍÏ¡ºÑ ÍØ»¡Ã³ÀÒ¹͡ ¼‹Ò¹¾Íϵ¢¹Ò¹ PC-Parallel port Interfacing text-lab manual 2nd edition àÃÕºàÃÕ§â´Â ÍÃö¾Å ºØ­ÂÐâÀ¤Ò ªÑÂÇѲ¹ ÅÔÁé ¾Ã¨ÔµÃÇÔäÅ

(C) Innovative Experiment Co.,Ltd. àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 1


PC-Parallel port Interfacing text-lab manual (2nd edition)

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ (©ºÑº»ÃѺ»Ãا¤ÃÑ§é ·Õè 2) ISBN 974 - 90348 - 8 - 0

àÃÕºàÃÕ§â´Â ÍÃö¾Å ºØ­ÂÐâÀ¤Ò ªÑÂÇѲ¹ ÅÔÁé ¾Ã¨ÔµÃÇÔäÅ ã¤Ã¤ÇÃ㪌˹ѧÊ×ÍàŋÁ¹Õé 1. ¹Ñ¡àÃÕ¹ ¹ÔÊµÔ ¹Ñ¡ÈÖ¡ÉÒ áÅкؤ¤Å·ÑÇè ä»·ÕÁè ¤Õ ÇÒÁʹã¨ã¹¡ÒÃàÃÕ¹ÃÙ¡Œ ÒùíÒ¤ÍÁ¾ÔÇàµÍÏÊNj ¹ºØ¤¤Åàª×Íè Á µ‹Í¡ÑºÍØ»¡Ã³ÀÒ¹͡à¾×Íè ·íÒ¡ÒÃáÅ¡à»ÅÕÂè ¹¢ŒÍÁÙÅËÃ×ͤǺ¤ØÁ¡Ò÷íÒ§Ò¹ 2. ʶҺѹ¡ÒÃÈÖ¡ÉÒ âçàÃÕ¹ ÇÔ·ÂÒÅÑ ÁËÒÇÔ·ÂÒÅÑ ·ÕÁè ¡Õ ÒÃແ´¡ÒÃàÃÕ¹¡ÒÃÊ͹ÇÔªÒÍÔàÅç¡·Ã͹ԡʏËÃ×Í ÀÒ¤ÇÔªÒÇÔÈÇ¡ÃÃÁÍÔàÅç¡·Ã͹ԡʏáÅФÍÁ¾ÔÇàµÍÏ 3. ¤³Ò¨ÒÏ·ÁÕè ¤Õ ÇÒÁµŒÍ§¡ÒÃÈÖ¡ÉÒ áÅÐàµÃÕÂÁ¡ÒÃàÃÕ¹¡ÒÃÊ͹ÇÔªÒ¡ÒÃàª×Íè Áµ‹Í¤ÍÁ¾ÔÇàµÍÏ¡ºÑ ÍØ»¡Ã³ÀÒ ¹Í¡ (Computer Interfacing) 4. ˹‹Ç§ҹàÍ¡ª¹·ÕÁè ¡Õ ÒþѲ¹Ò¼ÅÔµÀѳ±´ÒŒ ¹ÍÔàÅç¡·Ã͹ԡʏáÅФÍÁ¾ÔÇàµÍÏ ´íÒà¹Ô¹¡ÒèѴ¾ÔÁ¾áÅШíÒ˹‹ÒÂâ´Â ºÃÔÉ·Ñ ÍÔ¹â¹àǵտ àÍç¡à¾ÍÃÔàÁ¹µ ¨íÒ¡Ñ´ 3133/53 «.ÊØ¢ÁØ ÇÔ· 101/2 ¶.ÊØ¢ÁØ ÇÔ· á¢Ç§ºÒ§¹Ò ࢵºÒ§¹Ò ¡ÃØ§à·¾Ï 10260 â·ÃÈѾ· 0-2747-7001-4 â·ÃÊÒà 0-2747-7005

ÃÒÂÅÐàÍÕ´·Õ»è ÃÒ¡¯ã¹Ë¹Ñ§Ê×ÍàÃÕ¹ÃÙጠÅл¯ÔºµÑ ¡Ô ÒÃàª×Íè Áµ‹Í¤ÍÁ¾ÔÇàµÍÏ¡ºÑ ÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ (©ºÑº»ÃѺ»Ãا¤ÃÑ§é ·Õè 2) 䴌¼Ò‹ ¹¡ÒõÃǨ·Ò¹Í‹ҧÅÐàÍÕ´áÅжŒÇ¹¶Õè à¾×Íè ãˌÁ¤Õ ÇÒÁÊÁºÙóáÅж١µŒÍ§ÁÒ¡ ·ÕèÊØ´ ÀÒÂ㵌à§×è͹ä¢áÅÐàÇÅÒ·Õè¾Ö§ÁÕ¡‹Í¹¡ÒèѴ¾ÔÁ¾à¼Âá¾Ã‹ ¤ÇÒÁàÊÕÂËÒÂÍѹÍÒ¨à¡Ô´¨Ò¡¡ÒùíÒ¢ŒÍÁÙÅ㹠˹ѧÊ×ÍàŋÁ¹Õäé »ãªŒ ºÃÔÉ·Ñ ÍÔ¹â¹àǵտ àÍç¡à¾ÍÃÔàÁ¹µ ¨íÒ¡Ñ´ ÁÔ䴌ÁÀÕ ÒÃÐ㹡ÒÃÃѺ¼Ô´ªÍºáµ‹»ÃСÒÃã´ ¤ÇÒÁ ¼Ô´¾ÅÒ´¤ÅÒ´à¤Å×Íè ¹·ÕÍè Ò¨ÁÕáÅÐä´ŒÃºÑ ¡ÒèѴ¾ÔÁ¾à¼Âá¾Ã‹ÍÍ¡ä»¹Ñ¹é ·Ò§ºÃÔÉ·Ñ Ï ¨Ð¾ÂÒÂÒÁªÕáé ¨§áÅÐá¡Œä¢ ã¹¡ÒèѴ¾ÔÁ¾¤ÃÑ§é µ‹Íä» àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 2


¤í Ò ¹í Ò ¡ÒÃ㪌§Ò¹¤ÍÁ¾ÔÇàµÍÏã¹Çѹ¹ÕéäÁ‹ä´ŒÁÕà¾Õ§¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×èÍ»ÃÐÁÇżÅã¹àÃ×èͧ¢Í§°Ò¹¢ŒÍÁÙÅ (database) ¡ÒùíÒàʹͼŧҹ (presentation) ËÃ×ͧҹ´ŒÒ¹¡ÒÃÍ͡Ẻ¡ÃÒ¿¡ (graphic design) ÁÕ¼¤ÙŒ ¹ ¨íҹǹÁÒ¡ÁÒ·յè ͌ §¡ÒùíÒ¤ÍÁ¾ÔÇàµÍÏä»ãªŒ§Ò¹ã¹ÍÕ¡´ŒÒ¹Ë¹Ö§è ·ÕÊè ÒÁÒöàª×Íè Áµ‹Í¡ÑºÍØ»¡Ã³ÀÒ¹͡·Õäè Á‹ãª‹ à¤Ã×Íè §¾ÔÁ¾ËÃ×ÍÊ᡹à¹ÍÏ Ëҡ໚¹¡ÒùíÒ¤ÍÁ¾ÔÇàµÍÏ令Ǻ¤ØÁÃкº ແ´»´ÍØ»¡Ã³ ÃѺÊÑ­­Ò³ä¿¿‡Ò·Õäè ´Œ ÁÒ¨Ò¡¡ÒÃá»Å§»ÃÔÁÒ³·Ò§¿Ê¡Ô ʏ äÁ‹Çҋ ¨Ð໚¹áç´Ñ¹ä¿¿‡Ò ÍسËÀÙÁÔ à»š¹µŒ¹ ¾Íϵ¢¹Ò¹ (parallel port) ໚¹ª‹Í§·Ò§Ë¹Ö§è ·ÕÊè ÒÁÒö¹íÒÍØ»¡Ã³ÀÒ¹͡ÁÒµ‹Í¡Ñº¤ÍÁ¾ÔÇàµÍÏà¾×Íè ÃѺʋ§¢ŒÍÁÙšѹ á·¹·Õ¨è Ð㪌§Ò¹¾Íϵ¢¹Ò¹à¾Õ§¡Òõ‹Íà¤Ã×Íè §¾ÔÁ¾ ¼Ù㌠ªŒ§Ò¹ÊÒÁÒö㪌§Ò¹¾Íϵ¢¹Ò¹¹Õãé ¹¡Òà ¤Çº¤ØÁÃкºËÃ×ÍÃѺÊѭҳ俿‡Ò¨Ò¡ÀÒ¹͡䴌 ´ŒÇÂÇÔ¸¡Õ Ò÷Õäè Á‹ÂÒ¡ áÅЫѺ«ŒÍ¹Í‹ҧ·ÕËè ÅÒÂæ ¤¹à¢ŒÒ㨠´ŒÇ ¢ŒÍÁÙÅ·ÕÁè ¡Õ ÒÃà¼Âá¾Ã‹Í‹ҧÁÒ¡ÁÒ ´ŒÇÂâÁ´ÙÅ·Ò§«Í¿µáÇÏ·©Õè ÅÒ´ áÅдŒÇ¡ÒþѲ¹Ò´ŒÒ¹ÀÒÉҢͧâ»Ãá¡ÃÁ ·íÒãˌ¡ÒÃ㪌§Ò¹¤ÍÁ¾ÔÇàµÍÏà¾×Íè àª×Íè Áµ‹Í¡ÑºÍØ»¡Ã³ÀÒ¹͡ ·íÒ䴌§Ò‹ ¢ֹé ÁÕû٠Ẻ·ÕÊè ǧÒÁ áÅЪ‹ÇÂãˌ㪌§Ò¹ 䴌§Ò‹ ¢ֹé ã¹Ë¹Ñ§Ê×ÍàŋÁ¹Õé·íÒ˹ŒÒ·Õè㹡ÒÃàʹ͢ŒÍÁÙÅ㹡ÒÃ㪌§Ò¹¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏà¾×èÍàª×èÍÁµ‹Í¡Ñº ÍØ»¡Ã³ÀÒ¹͡«Öè§ÁÕ´ŒÇ¡ѹËÅÒ¡ËÅÒÂÃٻẺ àÃÔèÁµŒ¹¨Ò¡¢ÑºËÅÍ´ä¿áÊ´§¼Å ÃѺ¢ŒÍÁÙÅ´Ô¨ÔµÍÅÍ‹ҧ§‹ÒÂæ ¨Ò¡ÊÇÔµª ¡ÒÃʋ§¢ŒÍÁÙÅà¾×Íè ¢ÑºâËÅ´¡ÃÐáÊÊÙ§¼‹Ò¹ÃÕàŏ ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ ¢ÑºµÑÇàÅ¢áÊ´§¼Å ¢Ñº¨ÍáÊ´§ ¼ÅẺ´ÍµàÁµÃÔ¡«à¾×èÍáÊ´§¢ŒÍ¤ÇÒÁ «Öè§ÍØ»¡Ã³·Õè¡Å‹ÒÇÁÒ¹Õé ÊÒÁÒö·íÒ¤ÇÒÁࢌÒã¨ä´ŒäÁ‹ÂÒ¡¨Ò¡â»Ãá¡ÃÁ µÑÇÍ‹ҧ·Õàè ¢Õ¹¢Ö¹é ¨Ò¡ Visual BASIC Íѹ໚¹â»Ãá¡ÃÁ¾Ñ²¹Ò·Õäè ´ŒÃºÑ ¤ÇÒÁ¹ÔÂÁÊÙ§ áÅмÙ㌠ªŒ§Ò¹ÊÒÁÒöËÒ¢ŒÍÁÙÅ à¾×Íè ¾Ñ²¹Òâ»Ãá¡ÃÁ䴌äÁ‹ÂÒ¡ ËÅѧ¨Ò¡¹Ñ¹é ¨Ðà¾ÔÁè ¤ÇÒÁ«Ñº«ŒÍ¹¢Ö¹é ´ŒÇ¡ÒâÂÒ¤ÇÒÁÊÒÁÒö¢Í§¾Íϵ¢¹Ò¹ ¼‹Ò¹ÃкººÑʾÔàÈÉ·Õàè ÃÕÂ¡Ç‹Ò ºÑÊ I2C Íѹ¨Ð·íÒãˌÊÒÁÒö㪌§Ò¹¾Íϵ¢¹Ò¹ã¹¡ÒõԴµ‹Í¡ÑºÍØ»¡Ã³·ÁÕè ¤Õ ÇÒÁ ËÅÒ¡ËÅÒÂÁÒ¡¢Öé¹ äÁ‹Ç‹Ò¨Ð໚¹¡ÒâÂÒ¨íҹǹ¾ÍϵÍÔ¹¾ØµàÍÒµ¾Øµ ¡ÒÃÃѺÊÑ­­Ò³ä¿¿‡Ò·Õè໚¹ÍйÒÅÍ¡ áÅСÒÃÇÑͳ Ø ËÀÙÁÔ á¹‹¹Í¹Ç‹Ò·Ø¡µÑÇÍ‹ҧ¡ÒÃ㪌§Ò¹¨ÐÁÕ·§Ñé µÑÇÍ‹ҧǧ¨Ã ÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ áÅÐá¹Ð¹íÒ à¤Ã×Íè §Á×ͪ‹ÇÂ㹡Ò÷´ÅͧÍ‹ҧÊÁºÙó ˹ѧÊ×ÍàÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹àŋÁ¹Õé ÍÒ¨ ¡Å‹ÒÇ䴌NjÒ໚¹àÊÁ×͹˹Ö觤ًÁ×Í੾ÒзҧÊíÒËÃѺ¹Ñ¡·´Åͧ·Ò§ÎÒÏ´áÇÏ ÊíÒËÃѺÎÒÏ´áÇÏ·Õè͌ҧ¶Ö§¹Õé໚¹ªØ´ ·´ÅͧÃع‹ NX-2000 ¢Í§ºÃÔÉ·Ñ ÍÔ¹â¹àǵտ àÍç¡à¾ÍÃÔàÁ¹µ ¨íÒ¡Ñ´ ·íÒãˌÁ¹Ñè ã¨ä´ŒÇҋ ¼ÙàŒ ÃÕ¹¨ÐÊÒÁÒö·íÒ¤ÇÒÁà¢ŒÒ ã¨ã¹à·¤â¹âÅÂմҌ ¹¹Õäé ´ŒÍ‹ҧ¤Ãº¶ŒÇ¹ÊÁºÙó ¼Ùʌ ¹ã¨ÊÒÁÒö´ÙÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ ´ÒµŒÒªÕµ¢ŒÍÁÙÅÍØ»¡Ã³ ¾ÃŒÍÁ·Ñ§é âÁ´ÙÅ«Í¿µáÇÏ䴌¨Ò¡á¼‹¹ «Õ´ÕÃÍÁ·Õè¨Ñ´ÁҾÌÍÁ¡ÑºË¹Ñ§Ê×ÍàŋÁ¹Õé ËÃ×ÍÊÒÁÒö´ÒǹâËÅ´«Í¿µáÇÏã¹àÇÍϪÑè¹ãËÁ‹·ÕèÍÒ¨ÁÕ䴌¨Ò¡ http:// inex.ipfox.com ¢Íãˌ¹Ñ¡·´Åͧ·Ø¡·‹Ò¹Ê¹Ø¡¡Ñº¡ÒÃàÃÕ¹Ãٌà¾×è͹íÒ¤ÍÁ¾ÔÇàµÍÏä»ãªŒ§Ò¹ã¹ÍÕ¡á¹Ç·Ò§Ë¹Ö觷ÕèÍÒ¨à¤Â Áͧ¢ŒÒÁËÃ×ͤԴNjÒÁѹÂÒ¡à¡Ô¹ä» ÍÃö¾Å ºØ­ÂÐâÀ¤Ò ªÑÂÇѲ¹ ÅÔÁé ¾Ã¨ÔµÃÇÔäÅ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 3


ÊÒÃºÑ ­ º··Õè 1 ¤ÇÒÁÃÙàŒ º×Íé §µŒ¹à¡ÕÂè ǡѺ¾Íϵ¢¹Ò¹ ......................................................................7 º··Õè 2 ¡ÒÃà¢Õ¹â»Ãá¡ÃÁµÔ´µ‹Í¡Ñº¾Íϵ¢¹Ò¹ ...............................................................17 º··Õè 3 ¡ÒõԴµ‹ÍÃÐËNjҧ¾Íϵ¢¹Ò¹¡ÑºÍØ»¡Ã³Í¹Ô ¾ØµàÍÒµ¾µØ Í‹ҧ§‹Ò ....................23 P-Board : ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ ................................................. 24 EX-01 : ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ .............................................. 26 EX-03 : ºÍÏ´ÊÇÔµªÍ¹Ô ¾Øµ ................................................................ 27 ¡Ò÷´Åͧ·Õè 1 ¡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ ·Ò§¾Íϵ Data .............. 29 ¡Ò÷´Åͧ·Õè 2 ¡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ ·Ò§¾Íϵ Control .......... 31 ¡Ò÷´Åͧ·Õè 3 ¡ÒÃ͋ҹ¤‹Ò¨Ò¡ÍÔ¹¾Øµ¼‹Ò¹¾Íϵ Status .......... 33 º··Õè 4 ¡ÒâѺÍØ»¡Ã³àÍÒµ¾µØ ¡ÃÐáÊÊÙ§¼‹Ò¹¾Íϵ¢¹Ò¹ ............................................... 37 ¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍÏ¢ºÑ ..................................................................... 37 ¡ÒÃ㪌äÍ«Õ¢ºÑ ................................................................................... 39 ¡ÒâѺâËÅ´â´Â㪌Íͻⵌ¤»Ñ à»ÅÍÏ .................................................. 39 ¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè ¢ÑºÃÕàŏ͋ҧ§‹Ò´ŒÇ Visual BASIC................ 43 EX-06 : ºÍÏ´¢ÑºÃÕàŏ 7 ª‹Í§ ............................................................ 43 ¡Ò÷´Åͧ·Õè 4 ¢ÑºÃÕàŏ´ÇŒ ºÍÏ´ EX-06 .................................. 45 º··Õè 5 ¡ÒâѺÊàµç»à»ÍÏÁÍàµÍϴnj ¾Íϵ¢¹Ò¹ .......................................................... 49 Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ ...................................................... 49 ¡ÒáÃеعŒ áÅФǺ¤ØÁ¡ÒÃËÁع¢Í§Êàµç»à»ÍÏÁÍàµÍÏ .......................50 EX-05 : ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ ...................................................52 ¡Ò÷´Åͧ·Õè 5 ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺ˹֧è à¿Ê ............ 53 ¡Ò÷´Åͧ·Õè 6 ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺÊͧà¿Ê ............ 56 ¡Ò÷´Åͧ·Õè 7 ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺÎÒŏ¿Êàµç» ....... 58 º··Õè 6 LED µÑÇàÅ¢ 7 ʋǹáÅСÒâѺẺÁÑŵÔà¾Åç¡« ................................................. 61 ¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹẺËÅÑ¡à´ÕÂè Ç ..........................................62 ¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡« .......................................64 ¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹâ´Â㪌ºÍÏ´ EX-02 ................................... 65 ¡Ò÷´Åͧ·Õè 8 ¢Ñº LED µÑÇàÅ¢ 7 ʋǹẺà´ÕÂè Ç ..................67 ¡Ò÷´Åͧ·Õè 9 ¢Ñº LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡« .......69 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 4


º··Õè 7 ¡ÒâѺ LED Ẻ´ÍµàÁµÃÔ¡«¼Ò‹ ¹¾Íϵ¢¹Ò¹ .................................................. 73 EX-04A : ºÍÏ´ LED Ẻ´ÍµàÁµÃÔ¡« 20x7 ¨Ø´ ............................. 76 ¡Ò÷´Åͧ·Õè 10 ¢Ñº LED ´ÍµàÁµÃÔ¡« 20x7 ¨Ø´ .................. 80 º··Õè 8 ¡ÒâÂÒ¤ÇÒÁÊÒÁÒö¢Í§¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C ................................. 91 ¤Ø³ÊÁºÑµâÔ ´Â·ÑÇè 仢ͧºÑÊ I2C ........................................................ 91 ËÅÑ¡¡ÒâͧºÑÊ I2C ......................................................................... 92 ¡Ò÷íÒ§Ò¹¢Í§ºÑÊ I2C ...................................................................... 94 ¡Òõ‹ÍÍØ»¡Ã³ÃкººÑÊ I2C ¡Ñº¾Íϵ¢¹Ò¹¼‹Ò¹ P-Board .................. 96 ¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè ÊÌҧÊÑ­­Ò³µ‹Ò§æ ÊíÒËÃѺºÑÊ I2C ................. 97 ¡ÒâÂÒ¨íҹǹ¾Íϵ´ŒÇ PCF8574A ............................................ 99 ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ¤Çº¤ØÁ PCF8574A ´ŒÇ Visual BASIC ............... 101 EX-07 : ºÍÏ´¢ÂÒ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 16 ºÔµ¼‹Ò¹ÃкººÑÊ I2C ...... 102 ¡Ò÷´Åͧ·Õè 11 ¢ÂÒ¾ÍϵÍÔ¹¾ØµàÍÒµ¾Øµ¢Í§¾Íϵ¢¹Ò¹ ¼‹Ò¹ÃкººÑÊ I2C ...........................................104 º··Õè 9 ¡ÒÃàª×Íè Áµ‹Í¡ÑºÊÑ­­Ò³ÍйÒÅÍ¡¢Í§¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C ...............107 ¢ŒÍÁÙÅàº×Íé §µŒ¹¢Í§ PCF8591 ........................................................... 107 ÃÒÂÅÐàÍÕ´¿˜§¡ª¹Ñè µ‹Ò§æ ¢Í§ PCF8591 ........................................... 109 EX-08 : ºÍÏ´ ADC/DAC ¼‹Ò¹ÃкººÑÊ I2C ...................................... 112 ¡Ò÷´Åͧ·Õè 12 ¡ÒûÃÐÁÇżÅÊÑ­­Ò³ÍйÒÅÍ¡¢Í§ ¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C ....................... 113 º··Õè 10 ¡ÒâÂÒ¾ÍϵàÍÒµ¾µØ ¼‹Ò¹¡ÒÃÊ×Íè ÊÒÃ͹ءÃÁẺ«Ô§â¤Ã¹ÑÊ ........................121 ËÅÑ¡¡ÒÃàº×Íé §µŒ¹ ...............................................................................121 EX-09 : ºÍÏ´¢ÂÒ¾ÍϵàÍÒµ¾µØ Ẻ«Ô§â¤Ã¹ÑÊ .................................124 ¡Ò÷´Åͧ·Õè 13 ¢ÂÒ¾ÍϵàÍÒµ¾µØ ãˌᡋ¾Íϵ¢¹Ò¹ .........125 ¡Ò÷´Åͧ·Õè 14 ¢ÑºÊàµç»à»ÍÏÁÍàµÍϼҋ ¹ºÍÏ´ EX-09 ........128 º··Õè 11 ¾Íϵ¢¹Ò¹¡Ñº¡ÒÃÇÑ´ÍسËÀÙÁ¼Ô ҋ ¹ÃкººÑÊ I2C .............................................133 DS1621 äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ºº´Ô¨µÔ ÍÅ ................................................ 135 EX-10 : ºÍÏ´ÇÑ´ÍسËÀÙÁáÔ ÅÐà·ÍÏâÁʵѵ¼‹Ò¹ÃкººÑÊ I2C ................142 ¡Ò÷´Åͧ·Õè 15 ¾Íϵ¢¹Ò¹¡Ñº¡ÒÃÇÑ´ÍسËÀÙÁÔ¼‹Ò¹ÃкººÑÊ I2C...146 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 5


àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 6


º··Õè 1 ¤ÇÒÁÃٌàº×éͧµŒ¹à¡ÕèÂǡѺ ¾Íϵ¢¹Ò¹ ¡ÒûÃÐÁǿތÍÁÙÅà¾×Íè §Ò¹¤Çº¤ØÁ¹Ñ¹é ÊÔ§è áá¨ÐµŒÍ§ÁÕÊNj ¹¢Í§ÊÑ­­Ò³ÍÔ¹¾Øµ «Ö§è ÍÒ¨¨Ð ÁÒ¨Ò¡µÑǵÃǨ¨Ñºµ‹Ò§ æ ¼‹Ò¹Ç§¨ÃÀҤ˹ŒÒà¾×Íè à»ÅÕÂè ¹ÃٻẺÊÑ­­Ò³ÍÔ¹¾ØµãˌàËÁÒÐÊÁ¡Ñº¡Òà àª×èÍÁµ‹Í¡Ñº¤ÍÁ¾ÔÇàµÍÏ àÁ×èÍ¢ŒÍÁÙÅÍÔ¹¾Øµ¶Ù¡Ê‹§à¢ŒÒÊً¤ÍÁ¾ÔÇàµÍÏáÅŒÇ ¤ÍÁ¾ÔÇàµÍϨзíÒ¡Òà »ÃÐÁǿތÍÁÙÅ·Õè䴌ÁÒàËŋҹÑé¹ãˌÍÂًã¹ÃٻẺ·ÕèàËÁÒÐÊÁ¡‹Í¹·Õè¨Ðʋ§ÍÍ¡ä»ÂѧÀÒ¹͡¼‹Ò¹ ÍØ»¡Ã³àÍÒµ¾µØ «Ö§è ÍÒ¨¨Ð໚¹¡ÒÃʋ§ÍÍ¡ä»Âѧ¨ÍÀÒ¾ ËÃ×Íʋ§ÍÍ¡ä»Âѧ¨Ø´àª×Íè Áµ‹ÍÍ×¹è æ à¾×Íè ¤Çº ¤ØÁÍØ»¡Ã³àÍÒµ¾µØ µ‹Íä» ¡ÒÃàª×Íè Áµ‹ÍÃÐËNjҧ¤ÍÁ¾ÔÇàµÍÏ¡ºÑ ÍØ»¡Ã³ÀÒ¹͡·Ñ§é ʋǹ¢Í§ÀÒ¤ÍÔ¹¾ØµáÅÐÀÒ¤àÍÒµ¾Øµ ÊÒÁÒö·íÒ䴌ËÅÒÂÇÔ¸´Õ §Ñ ¹Õé l àª×Í è Áµ‹Í¼‹Ò¹·Ò§¡ÒÏ´ÍÔ¹¾ØµàÍÒµ¾µØ «Ö§è ãªŒÇ¸Ô ¡Õ ÒÃàÊÕºËÃ×͵ԴµÑ§é ¡Òϴŧã¹ÊÅç͵ÀÒ ã¹à¤Ã×Íè §¤ÍÁ¾ÔÇàµÍÏ l àª×Í è Áµ‹Í¼‹Ò¹·Ò§¾Íϵ͹ءÃÁ l àª×Í è Áµ‹Í¼‹Ò¹·Ò§¾Íϵ¢¹Ò¹ l àª×Í è Áµ‹Í¼‹Ò¹ÃкºÁҵðҹÍ×¹è æ ઋ¹ ¾Íϵ USB (Universal Serial Bus), ¾Íϵ SCSI ËÃ×;Íϵ GAME ໚¹µŒ¹

·íÒäÁ¶Ö§àÅ×͡㪌§Ò¹¾Íϵ¢¹Ò¹ àÁ×èÍà·Õº¡Ñº¡ÒÃ㪌§Ò¹¡ÒÏ´ÍÔ¹¾ØµàÍÒµ¾Øµ·Õ赌ͧµÔ´µÑé§ÍÂًÀÒÂã¹à¤Ã×èͧ¤ÍÁ¾ÔÇàµÍÏáÅŒÇ ¾Íϵ¢¹Ò¹Áբ͌ 䴌à»ÃÕºÍÂÙˋ ÅÒ»ÃСÒôѧ¹Õé ã¹´ŒÒ¹¤ÇÒÁ»ÅÍ´ÀÑ ¡Ò÷յè ͌ §¶Í´½Òà¤Ã×Íè §¤ÍÁ¾ÔÇàµÍÏÍÍ¡ÁÒà¾×Íè àÊÕº¡ÒÏ´àª×Íè Á µ‹Íŧã¹ÊÅç͵¢Í§¤ÍÁ¾ÔÇàµÍÏ ÍÒ¨¨Ð·íÒãˌà¡Ô´¤ÇÒÁàÊÕÂËÒ¡ѺʋǹÍ×¹è æ ¢Í§¤ÍÁ¾ÔÇàµÍÏ䴌 ¶ŒÒ¼ÙŒ·Õè㪌§Ò¹äÁ‹ÁÕ¤ÇÒÁªíÒ¹Ò­ËÃ×Íà¡Ô´¡Òõ‹Íǧ¨Ã·Õè¼Ô´¾ÅÒ´ ã¹´ŒÒ¹¡ÒÃࢌҡѹ䴌¡ºÑ ¤ÍÁ¾ÔÇàµÍÏÊNj ¹ãË­‹ ¡ÒÃàª×Íè Áµ‹Íâ´Â㪌¡ÒÏ´·Õàè ÊÕºŧã¹ÊÅç͵ äÁ‹ÊÒÁÒö㪌¡ºÑ ¤ÍÁ¾ÔÇàµÍÏ㹻˜¨¨Øº¹Ñ 䴌·¡Ø Ãع‹ ¡µÑÇÍ‹ҧ ¤ÍÁ¾ÔÇàµÍÏ⹌µºØ¡ ¨ÐäÁ‹ÁÊÕ Åç͵àÊÕº ᵋ¨ÐÁÕ·àÕè ÊÕº¡ÒÏ´ PCMCIA á·¹ ã¹¢³Ð·Õ¾è Íϵ¢¹Ò¹¨ÐÁÕµ´Ô µÑ§é ÍÂÙ㋠¹¤ÍÁ¾ÔÇàµÍÏ·¡Ø à¤Ã×Íè § ·Ñ§é ¹Õàé ¾×Íè 㪌㹡ÒõԴµ‹Í¡Ñºà¤Ã×Íè §¾ÔÁ¾ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 7


¢ŒÍ¨íÒ¡Ñ´´ŒÒ¹¾×¹é ·Õè ¤ÍÁ¾ÔÇàµÍϺҧà¤Ã×Íè §ÁÕ¡ÒÃàÊÕº¡ÒÏ´àª×Íè Áµ‹ÍµÑÇÍ×¹è æ ÍÂÙá‹ ÅŒÇ ÍÒ·Ô ¡ÒÏ´àÊÕ§ ¡ÒÏ´âÁà´çÁ ໚¹µŒ¹ ¨¹äÁ‹ÁÊÕ Åç͵àËÅ×;ÍÊíÒËÃѺ¡ÒÃàÊÕº¡ÒÏ´àª×Íè Áµ‹Íà¾ÔÁè àµÔÁ ¤ÇÒÁÊдǡ㹡ÒÃ㪌§Ò¹ ¡ÒÃàª×èÍÁµ‹Í·Ò§¾Íϵ¢¹Ò¹ÊÒÁÒö·íÒ䴌§‹ÒÂæ à¾Õ§µ‹ÍÊÒ ÊíÒËÃѺàª×Íè Áµ‹ÍࢌҡѺ¤Í¹à¹ç¡àµÍÏ DB-25 ¢Í§¾Íϵ¢¹Ò¹ ¨íҹǹª‹Í§ÊÑ­­Ò³ÍÔ¹¾ØµàÍÒµ¾µØ ¾Íϵ¢¹Ò¹ÁÕ¨Òí ¹Ç¹¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ ÁÒ¡à¾Õ§¾Í ·Õ¨è йíÒä»ãªŒ§Ò¹µ‹Ò§ æ áÅÐÂѧÊÒÁÒö¢ÂÒÂãˌÁ¨Õ Òí ¹Ç¹¾Íϵà¾ÔÁè ¢Ö¹é 䴌 â´Â¾Íϵ¢¹Ò¹»¡µÔÁÕ ¨íҹǹ¢ÒàÍÒµ¾µØ 12 ¢Ò áÅТÒÍÔ¹¾Øµ 5 ¢Ò ¤ÇÒÁàÃçÇ㹡ÒÃÊ×Íè ÊÒâŒÍÁÙšѺ¾Íϵ¢¹Ò¹ ÁÕ¤ÇÒÁàÃçÇ෋ҡѺ¡ÒõԴµ‹Í¡ÑºÃкººÑÊâ´Â µÃ§ áÅÐÁÕ¤ÇÒÁàÃçÇÁÒ¡¡Ç‹Ò¡ÒõԴµ‹Í¼‹Ò¹·Ò§¾Íϵ͹ءÃÁ ÍÐäËŋáÅЪԹé ʋǹ»ÃСͺ ¤Í¹à¹ç¡àµÍÏáÅÐÊÒÂàª×èÍÁµ‹Íµ‹Ò§æ ¢Í§¡ÒÃàª×èÍÁµ‹Í¼‹Ò¹ ·Ò§¾Íϵ¢¹Ò¹ ËÒ䴌§Ò‹ ÂáÅÐÃÒ¤ÒäÁ‹á¾§ ËÃ×ͨÐÊÌҧ¢Ö¹é àͧ¡çÊÒÁÒö·íÒ䴌Í‹ҧ§‹Ò´Ò ¨Ò¡¤Ø³ÊÁºÑµÔ´Ñ§·Õè䴌¡Å‹ÒÇÁÒáŌǹÑé¹·íÒãˌ¾Íϵ¢¹Ò¹àËÁÒÐÍ‹ҧÂÔ觷Õè¨Ð¹íÒÁÒ㪌㹠¡ÒÃàª×Íè Áµ‹Í¤ÍÁ¾ÔÇàµÍÏ¡ºÑ ÍØ»¡Ã³ÀÒ¹͡à¾×Íè ¤Çº¤ØÁËÃ×ÍÃѺÊÑ­­Ò³¢ŒÍÁÙÅ ¹Í¡¨Ò¡¹Ñ¹é ËÒ¡ ¹íҤسÊÁºÑµ¢Ô ͧ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ§‹ÒÂæ ¼‹Ò¹Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´Çʏ´ÇŒ Ââ»Ãá¡ÃÁ Visual BASIC ¡ç¨ÐÊÒÁÒöÊÌҧÃкº¡ÒÃàª×èÍÁµ‹Í·ÕèÊÁºÙóáÅÐ㪌§Ò¹§‹ÒÂ䴌äÁ‹ÂÒ¡

¤ÇÒÁÃٌàº×éͧµŒ¹¢Í§¾Íϵ¢¹Ò¹ ¾Íϵ¢¹Ò¹ (Parallel port) ÊÒà˵طÁÕè ªÕ Í×è ¹Õé à¹×Íè §¨Ò¡¡Òö‹Ò·ʹ¢ŒÍÁÙŢͧ¾Íϵ¹Õàé »š¹ Ẻ¢¹Ò¹ ÊíÒËÃѺª×Íè àÃÕ¡ÍÕ¡ª×Íè ¢Í§¾Íϵ¢¹Ò¹¤×Í ¾Íϵà¤Ã×Íè §¾ÔÁ¾ (Printer port) à¹×Íè §¨Ò¡ ¾Íϵ¹Õãé ªŒÊÒí ËÃѺµ‹Íà¤Ã×Íè §¾ÔÁ¾¹¹Ñè àͧ ´ŒÇ¡Òö‹Ò·ʹ¢ŒÍÁÙÅẺ¢¹Ò¹¹Õàé ͧ ·íÒãˌ¾Íϵ¢¹Ò¹ÁÕ굄 ÃÒ¡Òö‹Ò·ʹ¢ŒÍÁÙÅÊÙ§¡Ç‹Ò ¡Òö‹Ò·ʹ¢ŒÍÁÙÅẺ͹ءÃÁ»ÃÐÁÒ³ 8-10 à·‹Ò áÅСÒûÃÐÁǿތÍÁÙÅʋǹãË­‹¨ÐÁÕ¢¹Ò´ 8 ºÔµ ´Ñ§¹Ñ¹é ¾Íϵ¢¹Ò¹¨Ö§ÊÒÁÒöÃͧÃѺ¡Òö‹Ò·ʹ¢ŒÍÁÙÅ 8 ºÔµä´Œâ´ÂäÁ‹µÍŒ §µ‹Íʋǹà¾ÔÁè àµÔÁ ã´æ

Åѡɳзҧ¡ÒÂÀÒ¾¢Í§¾Íϵ¢¹Ò¹ à¾×Íè ãˌࢌÒ㨶֧¡ÒùíÒàÍÒ¾Íϵ¢¹Ò¹ä»ãªŒ§Ò¹ ¡‹Í¹Í×¹è µŒÍ§ÁÒ·íÒ¤ÇÒÁࢌÒ㨡‹Í¹Ç‹Ò »¡µÔ¹¹Ñé ¡ÒÃÊÑ觾ÔÁ¾§Ò¹¨Ò¡¤ÍÁ¾ÔÇàµÍÏä»Âѧ¾Íϵ¢¹Ò¹¹Ñé¹ÁÕÃٻẺ¡Ò÷íÒ§Ò¹ÀÒÂã¹Í‹ҧäà ã¹ÃÙ»·Õè 1-1 áÊ´§ä´ÍÐá¡ÃÁàÇÅҢͧµÔ´µ‹ÍÃÐËNjҧ¾Íϵ¢¹Ò¹¡Ñºà¤Ã×Íè §¾ÔÁ¾ «Ö§è ¨ÐàËç¹ä´ŒÇҋ ÁÕÊ­ Ñ ­Ò³ ·Õè㪌§Ò¹¨ÃÔ§æ ÁÕäÁ‹ÁÒ¡ àÃÔèÁ¨Ò¡ÊÑ­­Ò³¾Íϵ Data ¶Ù¡Ê‹§ÍÍ¡ä»Âѧà¤Ã×èͧ¾ÔÁ¾ ¾ÃŒÍÁ·Ñé§Ê‹§ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 8


Strobe Ack Busy Data

ä´ŒÃºÑ ¢ŒÍÁÙÅ

ÃÙ»·Õè 1-1 áÊ´§ä´ÍÐá¡ÃÁàÇÅҢͧ¡ÒÃʋ§¢ŒÍÁÙÅä»Âѧà¤Ã×Íè §¾ÔÁ¾ ÊÑ­­Ò³ Strobe ÍÍ¡ä»´ŒÇ à¾×Íè ãˌà¤Ã×Íè §¾ÔÁ¾ÃºÑ ÃÙnj ҋ ÁÕ¡ÒÃʋ§¢ŒÍÁÙÅãËÁ‹ÁÒ·Õ¢è Ò Data áÅŒÇ ¨Ò¡¹Ñ¹é ¤ÍÁ¾ÔÇàµÍϨеŒÍ§ÃÍ¡Òõͺ¡ÅѺ¨Ò¡à¤Ã×Íè §¾ÔÁ¾ ¹Ñ¹è ¤×Íà¤Ã×Íè §¾ÔÁ¾¨ÐÊÌҧÊÑ­­Ò³ Busy ËÃ×Í à¾×Íè ºÍ¡Ç‹Òà¤Ã×Íè §¾ÔÁ¾Â§Ñ äÁ‹¾ÃŒÍÁ·Õ¨è ÐÃѺ¢ŒÍÁÙÅãËÁ‹ ¨¹¡Ãзѧè àÁ×Íè à¤Ã×Íè §¾ÔÁ¾¾ÃŒÍÁ à¤Ã×Íè §¾ÔÁ¾ ¨ÐÊÌҧÊÑ­­Ò¹ ACK ʋ§ä»Âѧ¤ÍÁ¾ÔÇàµÍÏà¾×Íè ᨌ§Ç‹Ò ¾ÃŒÍÁ·Õ¨è ÐÃѺ¢ŒÍÁÙÅãËÁ‹áÅŒÇ ÊÑ­­Ò³¢ŒÍÁÙÅ¢¹Ò´ 8 ºÔµ, ÊÑ­­Ò³ Strobe áÅÐÊÑ­­Ò³ ACK (acknowledge) ໚¹ ÊÑ­­Ò³·ÕÊè Òí ¤Ñ­ã¹¡ÒÃʋ§¢ŒÍÁÙŨҡ¤ÍÁ¾ÔÇàµÍÏä»Âѧà¤Ã×Íè §¾ÔÁ¾ ¹Í¡¨Ò¡ÊÑ­­Ò³·Ñ§é ÊÒÁáÅŒÇ Ê‹Ç¹ãË­‹¡ÒõԴµ‹Í¡Ñºà¤Ã×èͧ¾ÔÁ¾ÂѧµŒÍ§ÁÕÊÑ­­Ò³Í×è¹æ ËÇÁ´ŒÇ à¹×èͧ¨Ò¡à¤Ã×èͧ¾ÔÁ¾µŒÍ§·íÒ Ë¹ŒÒ·Õ¶è §Ö 3 Í‹ҧ´ŒÇ¡ѹ¤×Í ÃѺ¢ŒÍÁÙŨҡ¤ÍÁ¾ÔÇàµÍÏ, ¾ÔÁ¾¢ÍŒ ÁÙÅ·ÕÃè ºÑ à¢ŒÒÁÒ áÅеͺʹͧµ‹Í ¡ÒÃ㪌§Ò¹¢Í§¼Ù㌠ªŒ ઋ¹ ¡ÒÃà»ÅÕÂè ¹¿Í¹µ ໚¹µŒ¹ ºÒ§¤Ãѧé ÍÒ¨à¡Ô´à˵ءÒó·äÕè Á‹»¡µÔ ઋ¹ ºÑ¿à¿ÍÏ ÊíÒËÃѺÃѺ¢ŒÍÁÙÅàµçÁ (à¹×Íè §¨Ò¡à¤Ã×Íè §¾ÔÁ¾à»š¹ÍØ»¡Ã³··Õè Òí §Ò¹·Ò§¡Å‹ÍÁ·íҧҹ䴌ªÒŒ ¡Ç‹Ò¡ÒÃʋ§ ¢ŒÍÁÙŢͧ¤ÍÁ¾ÔÇàµÍÏ) à¤Ã×Íè §¾ÔÁ¾¨ÐµŒÍ§á¨Œ§ä»Âѧ¤ÍÁ¾ÔÇàµÍÏÇҋ ãˌËÂشʋ§¢ŒÍÁÙŪÑÇè ¤ÃÒÇ à¹×Íè § ¨Ò¡äÁ‹ÊÒÁÒöÃѺ¢ŒÍÁÙÅÁÒ¡¡Ç‹Ò¹Õé䴌áÅŒÇ ÊÑ­­Ò³·Õèʋ§¨Ò¡à¤Ã×èͧ¾ÔÁ¾ä»Âѧ¤ÍÁ¾ÔÇàµÍϤ×Í ÊÑ­­Ò³ Busy áÅÐàÁ×Íè à¤Ã×Íè §¾ÔÁ¾à¡Ô´¢ŒÍ¼Ô´¾ÅÒ´ ઋ¹ ¡ÃдÒɵԴ à¤Ã×Íè §¾ÔÁ¾¨ÐµŒÍ§á¨Œ§ä»Âѧ ¤ÍÁ¾ÔÇàµÍÏઋ¹¡Ñ¹ â´ÂÊÑ­­Ò³·Õáè ¨Œ§ä»Âѧ¤ÍÁ¾ÔÇàµÍÏàÃÕ¡NjÒÊÑ­­Ò³ Error ¹Í¡¨Ò¡¹Õàé Á×Íè ¤ÍÁ¾ÔÇàµÍϵ͌ §¡ÒÃÃÕ૵à¤Ã×Íè §¾ÔÁ¾ ¤ÍÁ¾ÔÇàµÍϨеŒÍ§Ê‹§ÊÑ­­Ò³ Reset ä»Âѧà¤Ã×Íè §¾ÔÁ¾à¾×Íè ÃÕ૵à¤Ã×Íè §¾ÔÁ¾´ÇŒ  ÊÒÁÒöÊÃØ»¢ÒÊÑ­­Ò³·Õ¨è Òí ໚¹ÊíÒËÃѺ¡ÒõԴµ‹Í´Ñ§ã¹µÒÃÒ§·Õè 1-1 ¨Ò¡µÒÃÒ§·Õè 1-1 ¨ÐàËç¹ä´ŒÇҋ ¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÃÂ§Ñ á¡‹ÍÂÍ͡໚¹ÍÕ¡ 3 ¾Íϵ 䴌ᡋ ¾ÍϵàÍÒµ¾Øµ·Õè·íÒ˹ŒÒ·Õèʋ§¢ŒÍÁÙŨҡ¤ÍÁ¾ÔÇàµÍÏä»Âѧà¤Ã×èͧ¾ÔÁ¾ ¾ÍϵàÍÒµ¾Øµ ÊíÒËÃѺÊÑ­­Ò³ Strobe áÅÐ Reset ¾ÍϵÍÔ¹¾ØµÊíÒËÃѺ¡ÒÃ͋ҹ¤‹ÒÊÑ­­Ò³ Acknowledge, Busy áÅÐÊÑ­­Ò³ Error ¨Ò¡à¤Ã×Íè §¾ÔÁ¾ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 9


ÊÑ­­Ò³ ¢ŒÍÁÙÅ 8 ºÔµ Strobe

˹ŒÒ·Õ¡è Ò÷íÒ§Ò¹ ¢ŒÍÁÙÅ·Õèʋ§¨Ò¡¤ÍÁ¾ÔÇàµÍÏä»Âѧà¤Ã×èͧ¾ÔÁ¾ ᨌ§à¤Ã×èͧ¾ÔÁ¾¶Ö§¢ŒÍÁÙÅ·Õèʋ§ÁÒãËÁ‹

·ÔÈ·Ò§ ¤ÍÁ¾ÔÇàµÍÏ ¤ÍÁ¾ÔÇàµÍÏ

Acknowledge à¤Ã×èͧ¾ÔÁ¾á¨Œ§ÁÒÂѧ¤ÍÁ¾ÔÇàµÍÏNjÒ䴌ÃѺ¢ŒÍÁÙÅáÅŒÇ Busy ᨌ§Ê¶Ò¹ÐNjÒà¤Ã×èͧ¾ÔÁ¾äÁ‹Ç‹Ò§·Õè¨ÐÃѺ¢ŒÍÁÙÅãËÁ‹

à¤Ã×èͧ¾ÔÁ¾ à¤Ã×èͧ¾ÔÁ¾

Error

ᨌ§Ê¶Ò¹ÐNjÒà¤Ã×èͧ¾ÔÁ¾à¡Ô´¢ŒÍ¼Ô´¾ÅÒ´

à¤Ã×èͧ¾ÔÁ¾

Reset

ÃÕ૵à¤Ã×èͧ¾ÔÁ¾

¤ÍÁ¾ÔÇàµÍÏ

µÒÃÒ§·Õè 1-1 ÊÑ­­Ò³ÊíÒ¤Ñ­æ ¢Í§¾Íϵ¢¹Ò¹·Õãè ªŒµ´Ô µ‹Í¡Ñºà¤Ã×Íè §¾ÔÁ¾ â´Â»¡µÔ¾Íϵ¢¹Ò¹Í͡ẺÁÒãˌÁÊÕ ÒÂÊÑ­­Ò³ÍÂÙ·‹ §Ñé ËÁ´ 17 àʌ¹ ÊÒÂÊÑ­­Ò³àËÅ‹Ò¹Ñ¹é ¨ÐÁÕÃ¨Õ ÊÔ àµÍÏ 3 µÑǤǺ¤ØÁ¡Ò÷íÒ§Ò¹´Ñ§¹Õé 1. ¾ÍϵàÍÒµ¾µØ ÊíÒËÃѺÊÑ­­Ò³¢ŒÍÁÙÅ 8 àʌ¹ ÁÕÃ¨Õ ÊÔ àµÍÏ Data ¤Çº¤ØÁ 2. ¾ÍϵÍÔ¹¾ØµÊíÒËÃѺ¡ÒÃ͋ҹ¤‹Òʶҹе‹Ò§æ ¨Ò¡ÀÒ¹͡ÁÕÍÂÙ´‹ nj ¡ѹ 5 àʌ¹ ãªŒÃ¨Õ ÊÔ àµÍÏ Status 㹡ÒäǺ¤ØÁ 3. ¾ÍϵàÍÒµ¾µØ ÊíÒËÃѺʋ§ÊÑ­­Ò³¤Çº¤ØÁä»ÂѧÍØ»¡Ã³ÀÒ¹͡ ÁÕÍÂÙ´‹ nj ¡ѹ 4 àʌ¹ 㪌 ÃÕ¨ÊÔ àµÍÏ Control 㹡ÒäǺ¤ØÁ ºÅçÍ¡ä´ÍÐá¡ÃÁã¹ÃÙ»·Õè 1-2 áÊ´§ÃкººÑʢͧ¤ÍÁ¾ÔÇàµÍÏÊÒí ËÃѺ¡ÒõԴµ‹Í¡Ñº¾Íϵ ¢¹Ò¹ ÊÑ­­Ò³àÍÒµ¾Øµ¨Ò¡¾Íϵ¢¹Ò¹¨Ð¶Ù¡Ê‹§ä»Âѧ¤Í¹à¹ç¡àµÍÏẺ DB-25 ÊíÒËÃѺ ¤ÍÁ¾ÔÇàµÍÏÊNj ¹ãË­‹ã¹»˜¨¨Øº¹Ñ ¾Íϵ¢¹Ò¹¨ÐÁÕÁҾÌÍÁ¡ÑºàÁ¹ºÍÏ´ äÁ‹¨Òí ໚¹µŒÍ§ãªŒ¡ÒÏ´àÊÕº à¾ÔÁè àµÔÁàËÁ×͹ã¹Í´Õµ ¾ÃŒÍÁ·Ñ§é ÁÕ¿§˜ ¡ª¹Ñ ¡Ò÷íÒ§Ò¹·Õ«è ºÑ «ŒÍ¹¢Ö¹é áµ‹Â§Ñ ¤§Ê¹ÑºÊ¹Ø¹¡Ò÷íÒ§Ò¹¢Í§ ¾Íϵ¢¹Ò¹ã¹ÃٻẺÁҵðҹ (SPP) ÍÂً àÁ×Íè ´Ù¨Ò¡ÃÙ»·Õè 1-1 à·Õº¡Ò÷íÒ§Ò¹â´Â·ÑÇè 仡Ѻ¡ÒÃàª×Íè Áµ‹Í¼‹Ò¹¡ÒÏ´·Õàè ÊÕºŧã¹ÊÅç͵¢Í§ ¤ÍÁ¾ÔÇàµÍÏáÅŒÇ ¾Íϵ¢¹Ò¹¨ÐÁÕÅ¡Ñ É³Ðã¡ÅŒà¤Õ§¡Ñ¹ â´Â¡ÒõԴµ‹Í¡Ñº¾Íϵ¢¹Ò¹¨ÐµŒÍ§ÁÕ¡Òà ͌ҧáÍ´à´ÃÊ µíÒá˹‹§áÍ´à´ÃÊ·Õãè ªŒÍҌ §¶Ö§¨Ð໚¹µíÒá˹‹§ A0-A9 áÅÐ㪌¢Ò IOR áÅÐ IOW ÊíÒËÃѺ ໚¹µÑÇàÅ×͡NjҵŒÍ§¡ÒÃ͋ҹËÃ×Íà¢Õ¹ÃÕ¨ÊÔ àµÍϵÇÑ ã´ ¨Ò¡¡ÒôÕ⤌´áÍ´à´ÃÊ A0-A9 ¹Õàé ͧ·íÒãˌ䴌 ÊÑ­­Ò³ÍÍ¡ÁÒà¾×Íè 令Ǻ¤ØÁËÃ×ÍàÍç¹àÍàºÔÅǧ¨ÃºÑ¿à¿Íϵҋ §æ ´Ñ§¹Õé DataWrite ÊÑ­­Ò³àÍç¹àÍàºÔÅÊíÒËÃѺ¹íÒ¢ŒÍÁÙÅ·ÕÍè ÂÙ㋠¹ºÑÊ Data ä»ÍÍ¡·Õ¢è Ò Data ¢Í§¾Íϵ ¢¹Ò¹ DataRead ÊÑ­­Ò³àÍç¹àÍàºÔÅÊíÒËÃѺ͋ҹ¢ŒÍÁÙŨҡ¢Ò Data ¢Í§¾Íϵ¢¹Ò¹ÁÒà¡çºänj㹠ºÑÊ Data àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 10


¤Í¹à¹ç¡àµÍÏ DB25 ´Õ⤌´ ¤íÒÊѧè

ºÑ¿à¿ÍÏ 1

áŵª 1

ºÔµ Data

¾Íϵ Data (8 ºÔµ)

OE

ºÔµ Control

IOR*,IOW*

´Õ⤌´ ¤íÒÊѧè Data Write Data Read Control Write

áŵª 2

ÍÕ¹ÒàºÔÅ IRQ

ä´ÃàÇÍÏ ¤ÍÅàÅç¡àµÍÏ ແ´

¾Íϵ Control (4 ºÔµ)

Control Read ºÔµ Address

A0 ¶Ö§ A9

Status Read

ºÑ¿à¿ÍÏ 2 OE

IRQ5/IRQ7 ÃкººÑʢͧ ¤ÍÁ¾ÔÇàµÍÏ

ºÑ¿à¿ÍÏ 3

¾Íϵ Status (5 ºÔµ)

ºÑ¿à¿ÍÏÊÒÁʶҹРOE

ÃÙ»·Õè 1-2 áÊ´§ÃкººÑÊÀÒÂ㹢ͧ¾Íϵ¢¹Ò¹ ControlWrite ÊÑ­­Ò³àÍç¹àÍàºÔÅÊíÒËÃѺ¹íÒ¢ŒÍÁÙÅ·ÕèÍÂً㹺ÑÊ Data ä»ÍÍ¡·Õè¢Ò Control ¢Í§¾Íϵ¢¹Ò¹ ÊíÒËÃѺ¾Íϵ¹Õé¹Í¡¨Ò¡¨Ðʋ§¢ŒÍÁÙÅÍÍ¡ä»Âѧ¾Íϵ¢¹Ò¹áÅŒÇ Âѧ·íÒ˹ŒÒ·ÕèÍÕ¹ÒàºÔÅ¡ÒÃÍÔ¹àµÍÃÃ»Ñ µ¢Í§¡ÒÃà»ÅÕÂè ¹á»Å§ÊÑ­­Ò³·Õ¾è Íϵ Status ÍÕ¡´ŒÇ ControlRead ÊÑ­­Ò³àÍç¹àÍàºÔÅÊíÒËÃѺ͋ҹ¤‹Ò¢ŒÍÁÙŨҡ¢Ò Control ÁÒà¡çºänj㹺ÑÊ Data StatusRead ÊÑ­­Ò³àÍç¹àÍàºÔÅÊíÒËÃѺ͋ҹ¤‹Ò¢ŒÍÁÙŨҡ¢Ò¾Íϵ Status ÁÒà¡çºänj㹺ÑÊ Data µÒÃÒ§·Õè 1-2 áÊ´§ª×Íè áÅÐ˹ŒÒ·Õ¡è Ò÷íÒ§Ò¹¢Í§µíÒá˹‹§¢Òµ‹Ò§æ º¹¾Íϵ¢¹Ò¹ ʋǹ㹠µÒÃÒ§·Õè 1-3 áÊ´§áÍ´à´Ãʢͧ¾Íϵ¢¹Ò¹ «Ö§è ¡íÒ˹´änj 3 µíÒá˹‹§¤×Í LPT1, LPT2 áÅÐ LPT3

¾Íϵ´ÒµŒÒ (Data Port) ¨Ò¡ÃÙ»·Õè 1-3 áÊ´§ãˌàËç¹Ç‹Ò¾Íϵ Data »ÃСͺ仴ŒÇºѿà¿ÍÏ 1 µÑÇáÅÐäÍ«ÕáŵªÍ¡Õ 1 µÑÇ àÁ×Íè ¤ÍÁ¾ÔÇàµÍϵ͌ §¡ÒÃʋ§¢ŒÍÁÙÅä»Âѧà¤Ã×Íè §¾ÔÁ¾ ¤ÍÁ¾ÔÇàµÍϨÐà¢Õ¹¢ŒÍÁÙÅä»ÂѧäÍ«Õ áŵª 1 ·Ñ§é 8 ºÔµ àÍÒµ¾µØ ¢Í§äÍ«Õáŵª 1 ¤×Í D0-D7 «Ö§è àÍÒµ¾µØ ¹Õ¨é Ðä»»ÃÒ¡¯ÍÂÙ·‹ ¾Õè Íϵ ¢¹Ò¹ã¹µíÒá˹‹§¢Ò 2 ¶Ö§¢Ò 9 áÅзբè ÒàÍÒµ¾µØ ¹ÕÊé ­ Ñ ­Ò³ Data ¨Ðʋ§¡ÅѺä»à»š¹ÍÔ¹¾Øµ¢Í§ ºÑ¿à¿ÍÏ 1 ´ŒÇ ·íÒãˌ¤ÍÁ¾ÔÇàµÍÏÊÒÁÒö͋ҹ¤‹Òʶҹл˜¨¨Øº¹Ñ ·Õàè ¡Ô´¢Ö¹é ¡Ñº¾Íϵ Data 䴌 àÁ×èͤÍÁ¾ÔÇàµÍÏʋ§¢ŒÍÁÙÅ ¢ŒÍÁÙŨж١ʋ§ÁÒ¨Ò¡ºÑÊ¢ŒÍÁÙŢͧ¤ÍÁ¾ÔÇàµÍϼ‹Ò¹ä»ãˌ¡Ñº äÍ«Õ 74LS374 «Ö§è ໚¹äÍ«Õáŵª¢ÍŒ ÁÙÅ áÅÐàÁ×Íè µŒÍ§¡ÒÃãˌ¢ÍŒ ÁÙÅ»ÃÒ¡¯·Õàè ÍÒµ¾µØ ¤ÍÁ¾ÔÇàµÍÏ ¨Ðʋ§ÊÑ­­Ò³ DataWrite ÍÍ¡ä»·Õ¢è Ò CLK ¢Í§ 74LS374 àÍÒµ¾µØ ¨Ò¡ 74LS374 ¨Ð¶Ù¡¡Ãͧ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 11


´ŒÇÂǧ¨Ã RC «Ö§è »ÃСͺ´ŒÇµÑǵŒÒ¹·Ò¹¤‹Ò 27Ω áÅеÑÇà¡çº»ÃÐ¨Ø 0.0022µF à¾×Íè ãˌªÇ‹ §àÇÅÒ·Õè à»ÅÕÂè ¹¨Ò¡Åͨԡ “0” ໚¹Åͨԡ “1” ËÃ×ͨҡÅͨԡ “1” ໚¹Åͨԡ “0” ໚¹ä»Í‹ҧªŒÒæ à¹×Íè § ¨Ò¡¡ÒÃà»ÅÕÂè ¹áç´Ñ¹·ÕÃè Ç´àÃçÇ·íÒãˌà¡Ô´ÊÑ­­Ò³Ãº¡Ç¹à˹ÕÂè ǹíÒ¢ŒÒÁä»Âѧ¢ŒÍÁÙźԵÍ×¹è æ 䴌 ·íÒãˌ ¢ŒÍÁÙÅ·ÕÊè §‹ ÍÍ¡ä»Áբ͌ ¼Ô´¾ÅÒ´ ¨Ò¡¤‹ÒµÑǵŒÒ¹·Ò¹áÅеÑÇà¡çº»ÃШØã¹Ç§¨Ã·íÒãˌà¡Ô´¡ÒÃ˹‹Ç§àÇÅÒ ä»»ÃÐÁÒ³ 60 ¹Òâ¹ÇÔ¹Ò·Õ ¨Ò¡Ç§¨Ãã¹ÃÙ»·Õè 1-3 ·íÒãˌàÍÒµ¾µØ ¢Í§¾Íϵ Data ÁÕ¤³ Ø ÊÁºÑµ´Ô §Ñ ¹Õé l ¡ÃÐáÊ«Ô§¡Ê§Ù ÊØ´ 24mA l ¡ÃÐáÊ«ÍÏÊÊÙ§ÊØ´ 2.6mA l ÃдѺáç´Ñ¹¢Í§Åͨԡ “1” µèÒí Êش෋ҡѺ 2.4V l ÃдѺáç´Ñ¹ÊÙ§ÊØ´ÊíÒËÃѺÅͨԡ “0” ෋ҡѺ 0.5V ÊíÒËÃѺºÑ¿à¿ÍÏÊíÒËÃѺ¡ÒÃ͋ҹ¢ŒÍÁÙÅ¡ÅѺ䴌ᡋàºÍÏ 74LS244 «Öè§àÁ×è͵ŒÍ§¡ÒÃ͋ҹ¤‹Ò ¤ÍÁ¾ÔÇàµÍϨÐʋ§ÊÑ­­Ò³ DataRead ÍÍ¡ÁÒà¾×Íè àÍç¹àÍàºÔÅäÍ«Õ 74LS244 ÊíÒËÃѺ¾Íϵ¢¹Ò¹ ẺÁҵðҹ (Standard Parallel Port : SPP ) ¾Íϵ Data ¨ÐµŒÍ§ãªŒà¾×Íè ¡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ ෋ҹѹé ᵋÊÒí ËÃѺ¾Íϵ¢¹Ò¹·ÕÁè ¡Õ ÒÃÊ×Íè ÊÒÃÊͧ·ÔÈ·Ò§ (Bidirectional Parallel Port ) ÊÒÁÒö ͋ҹ¤‹Ò¨Ò¡¾Íϵ Data 䴌´ÇŒ  ᵋ¡Í‹ ¹·Õ¨è Ð͋ҹ¤‹ÒµŒÍ§¨íÒänjàÊÁÍNjҨеŒÍ§»‡Í¹¤‹ÒàÍÒµ¾µØ ãˌ Áդҋ Åͨԡ “1” ·Ñ§é ËÁ´¡‹Í¹ ¢Ò¢Í§¾Íϵ¢¹Ò¹ ÃÕ¨ÊÔ àµÍÏ

·ÔÈ·Ò§

µíÒá˹‹§ºÔµ ª×Íè ¢ÒÊÑ­­Ò³

˹ŒÒ·Õ¡è Ò÷íÒ§Ò¹

1

Control

Out

C0

STROBE

áÍ¡µÕ¿ "0" ʋ§¤‹ÒÍÍ¡ä»à¾×èÍºÍ¡Ç‹Ò ·Õè¢Ò´ÒµŒÒÁÕ¢ŒÍÁÙÅáŌÇ

2-9

Data

Out

D0-D7

DATA0-DATA7

ÊíÒËÃѺ¾Íϵ¢¹Ò¹Áҵðҹà´ÔÁ¢Ò¹Õé ·íÒ˹ŒÒ·Õè໚¹¢Òʋ§¢ŒÍÁÙÅàÍÒµ¾Øµà·‹Ò¹Ñé¹ ÊíÒËÃѺ㹻˜¨¨ØºÑ¹¢Ò¹ÕéÃѺ¢ŒÍÁÙÅÍÔ¹¾Øµä´Œ´ŒÇÂ

10

Status

In

S6

nACK

໚¹¾ÑÅʏÅͨԡ "0" ·Õèʋ§ÁÒ¨Ò¡à¤Ã×èͧ¾ÔÁ¾ à¾×èͺ͡NjÒ䴌ÃѺ¢ŒÍÁÙÅ·Õèʋ§ä»áŌÇ

11

Status

In

S7

BUSY

໚¹ÊÑ­­Ò³á¨Œ§ÁÒ¨Ò¡à¤Ã×èͧ¾ÔÁ¾Ç‹Ò ÂѧäÁ‹¾ÃŒÍÁÃѺ¢ŒÍÁÙÅ

12

Status

In

S5

PE

ᨌ§¡ÃдÒÉËÁ´

13

Status

In

S4

SELECT

ᨌ§Ç‹Òà¤Ã×èͧ¾ÔÁ¾µ‹ÍÍÂً

14

Control

Out

C1

AUTO FEED

ÊÑè§à¤Ã×èͧ¾ÔÁ¾ãˌàÅ×è͹ºÑ¹·Ñ´

15

Status

In

S3

ERROR

ÊÑ­­Ò³¨Ò¡à¤Ã×èͧ¾ÔÁ¾ÁÒÂѧ¤ÍÁ¾ÔÇàµÍÏ à¾×èÍáÊ´§¢ŒÍ¼Ô´¾ÅÒ´¨Ò¡¡ÒþÔÁ¾

16

Control

Out

C2

INIT

ÃÕ૵à¤Ã×èͧ¾ÔÁ¾â´ÂãˌÅͨԡ "0"

17

Control

Out

C3

SELECT-IN

ʋ§ÊÑ­­Ò³ä»Âѧà¤Ã×èͧ¾ÔÁ¾à¾×èÍᨌ§Ç‹Ò µŒÍ§¡ÒÃàÅ×Í¡à¤Ã×èͧ¾ÔÁ¾à¤Ã×èͧ¹Õé

GND

¡ÃÒÇ´

18-25

µÒÃÒ§·Õè 1-2 áÊ´§ÊÑ­­Ò³·Ñ§é ËÁ´·ÕÍè ÂÙº‹ ¹¾Íϵ¢¹Ò¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 12


¢Ò¢Í§¾Íϵ¢¹Ò¹ ºÑÊ Data ¢Í§ ¤ÍÁ¾ÔÇàµÍÏ

D0

74LS374

OE Clock

27Ω x 8

2

D1

3

D2

4

D3

5

D4

6

D5

7

D6

8

D7

9

Data Write

74LS244

OE

0.0022/50V x8

Data Read

ÃÙ»·Õè 1-3 ǧ¨ÃÀÒÂ㹢ͧ¾Íϵ Data

¾Íϵ Control

¾Íϵ Control 㪌ÊÒí ËÃѺ¤ÍÁ¾ÔÇàµÍϤǺ¤ØÁà¤Ã×Íè §¾ÔÁ¾ ¨Ò¡µÒÃÒ§·Õè 1-2 ¨ÐàËç¹Ç‹Ò¾Íϵ Control »ÃСͺ仴ŒÇºԵàÍÒµ¾µØ 4 ºÔµ·Õµè ͋ ÍÍ¡ä»Âѧà¤Ã×Íè §¾ÔÁ¾ ʋǹºÔµàÍç¹àÍàºÔÅÍÔ¹àµÍÏ ÃÑ»µäÁ‹ä´Œ¶¡Ù µ‹ÍÍÍ¡ä» ÃÙ»·Õè 1-4 áÊ´§ºÅçÍ¡ä´ÍÐá¡ÃÁ¢Í§¾Íϵ Control ¨ÐàËç¹Ç‹ÒàÍÒµ¾µØ ¢Í§ ¾Íϵ Control ÁÕÍ¹Ô àÇÍÏàµÍÏẺ¤ÍÅàÅç¡àµÍÏແ´µ‹ÍËÇÁÍÂً â´ÂàÍÒµ¾µØ àËŋҹըé ж١¾ÙÅÍÑ» änj´ÇŒ µÑǵŒÒ¹·Ò¹¤‹Ò 4.7kΩ ÊíÒËÃѺºÔµ C2 ¨Ð¼‹Ò¹ÍÔ¹àÇÍÏàµÍ϶§Ö ÊͧµÑÇ·íÒãˌ·àÕè ÍÒµ¾µØ ¢Í§ ºÔµ C2 äÁ‹Á¡Õ ÒáÅѺʶҹÐÅͨԡ ʶҹТͧ¾Íϵ Control ÊÒÁÒö͋ҹ¡ÅѺ䴌áÅдŒÇ¡ÒÃ㪌º¿Ñ à¿ÍÏàºÍÏ 74LS240 «Ö§è ·Õàè ÍÒµ¾µØ ÁÕÍ¹Ô àÇÍÏàµÍϵ͋ ÍÂÙÀ‹ ÒÂã¹ ·íÒãˌ¤Ò‹ ·ÕÍè ҋ ¹ä´ŒµÃ§¡Ñº¤‹Ò·ÕÊè §‹ ÍÍ¡ä» ¡ÒäǺ¤ØÁ¡ÒÃ͋ҹ áÅÐà¢Õ¹¢ŒÍÁÙšѺ¾Íϵ Control ¤ÍÁ¾ÔÇàµÍϨÐʋ§¢ŒÍÁÙÅÁÒ·Õ¢è Ò Control Write áÅÐ Control Read à¹×Íè §¨Ò¡àÍÒµ¾µØ ¢Í§¾Íϵ Control ໚¹áºº¤ÍÅàÅç¡àµÍÏແ´ ´Ñ§¹Ñ¹é ¼Ù㌠ªŒ§Ò¹ÊÒÁÒö㪌 ¾Íϵ¹Õãé ¹¡ÒÃ͋ҹ¤‹ÒÊÑ­­Ò³ÍÔ¹¾Øµ¨Ò¡ÀÒ¹͡䴌 â´Â¡‹Í¹·Õ¨è Ð͋ҹ¤‹Ò¨ÐµŒÍ§·íÒãˌ¢Ò¾Íϵ·Õµè ͌ § ¡ÒÃ͋ҹ¤‹ÒÁÕÅͨԡ “1” àÊÕ¡‹Í¹

¾ÍϵáÊ´§Ê¶Ò¹ÐËÃ×;Íϵ Status

¾Íϵ Status ໚¹¾Íϵ·Õ¤è ÍÁ¾ÔÇàµÍÏ㪌ÊÒí ËÃѺ¡ÒÃ͋ҹ¤‹ÒʶҹШҡà¤Ã×Íè §¾ÔÁ¾ ÃÙ»·Õè 1-5 áÊ´§ÃÒÂÅÐàÍÕ´ÀÒÂ㹢ͧ¾Íϵ Status ¨ÐÊѧࡵ䴌Çҋ ÁÕ¢ÒÊÑ­­Ò³ÍÂÙ·‹ §Ñé ËÁ´ 5 ÊÑ­­Ò³ ´ŒÇ¡ѹáÅШÐàÃÕ¡ª×Íè ໚¹ S3,S4,S5,S6 áÅÐ S7 «Ö§è µÑÇàÅ¢¹Ñ¹é ËÁÒ¶֧µíÒá˹‹§ºÔµ¢Í§¢ÒàËŋҹÕé àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 13


+5V

¢Ò¢Í§¾Íϵ¢¹Ò¹ 4.7k x 4

0.0022/50V

27

D1

C1

OC

D2

ÃкººÑʢͧ¤ÍÁ¾ÔÇàµÍÏ

C0

OC

D0

C2

OC

74LS174

D3

C3

OC

ÍÕ¹ÒàºÔÅÍÔ¹àµÍÏÃÑ»µ

D4 CLOCK

D0 D1

74LS240

D2 D3

OE

D4

74LS126

Control Write Control Read

´Õ⤌´¤íÒÊѧè

ÃÙ»·Õè 1-4 ǧ¨ÃÀÒÂ㹢ͧ¾Íϵ Control ¢Ò¢Í§¾Íϵ¢¹Ò¹ S7

ÃкººÑʢͧ¤ÍÁ¾ÔÇàµÍÏ

D0

S6

D1 D2

S5

74LS240

S4

D3

S3 OE

74LS126

D4

¨Ò¡¾Íϵ CONTROL ºÔµ 4 IRQ5 or IRQ7 56)6754A=@

´Õ⤌´¤íÒÊÑè§

ÃÙ»·Õè 1-5 áÊ´§Ç§¨ÃÀÒÂ㹢ͧ¾ÍϵáÊ´§Ê¶Ò¹Ð àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 14

BUSY ACK PE SELECT ERROR


ÀÒÂã¹ÃÕ¨ÊÔ àµÍÏ Status ¹Ñ¹è àͧ ÊíÒËÃѺºÔµ S7 ¨ÐÁբ͌ ᵡµ‹Ò§¨Ò¡ºÔµÍ×¹è æ ·Õàè Á×Íè ÊÑ­­Ò³¨Ò¡ ÀÒ¹͡ʋ§à¢ŒÒÁÒáŌǨÐäÁ‹¼‹Ò¹ÍÔ¹àÇÍÏàµÍÏ ã¹¢³Ð·Õè¢ÒÍ×è¹æ ¼‹Ò¹ÍÔ¹àÇÍÏàµÍÏ·Ñé§ËÁ´ ´Ñ§¹Ñé¹ àÁ×Íè ¢ŒÍÁÙż‹Ò¹¨Ò¡¢ÒÍÔ¹¾Øµä»Âѧ 74LS240 «Ö§è àÍÒµ¾µØ ÁÕ¡ÒáÅѺʶҹзíÒãˌºµÔ S7 ໚¹ºÔµà´ÕÂÇ ·ÕèÁÕ¡ÒáÅѺʶҹР¹Í¡¨Ò¡¹Õé㹡ÒÃ㪌§Ò¹¶ŒÒµŒÍ§¡ÒÃãˌÁÕ¡ÒÃÊÌҧÊÑ­­Ò³ÍÔ¹àµÍÏÃÑ»µ¨Ò¡ ¢Íº¢Ò¢Ö¹é ¢Í§¢Ò S6 ÊÒÁÒö¡íÒ˹´¤‹Ò䴌¨Ò¡¾Íϵ Control ºÔµ 4

¡ÒùíÒ¾Íϵ¢¹Ò¹ä»ãªŒ§Ò¹ ÊíÒËÃѺ¾Íϵ¢¹Ò¹áººÁҵðҹ ¼Ù㌠ªŒ§Ò¹ÊÒÁÒö¹íÒ¾ÍϵÍÔ¹¾Øµ 5 ºÔµ (¾Íϵ Status) ¾ÍϵàÍÒµ¾µØ 4 ºÔµ (¾Íϵ Control) áÅоÍϵàÍÒµ¾µØ ÍÕ¡ 8 ºÔµ (¾Íϵ Data) ä»ãªŒ§Ò¹ä´Œ â´ÂµÃ§ â´Â·Õè 4 ºÔµ¢Í§¾ÍϵàÍÒµ¾ØµËÃ×;Íϵ Control ¹Ñé¹ÊÒÁÒö´Ñ´á»Å§ãˌ㪌§Ò¹à»š¹ ¾ÍϵÍÔ¹¾Øµ¢¹Ò´ 4 ºÔµä´Œ´ÇŒ ´ѧ¹Ñ¹é ¼Ù㌠ªŒ§Ò¹¨Ö§ÊÒÁÒö¹íÒÊÑ­­Ò³¨Ò¡¾Íϵ¢¹Ò¹·ÕÁè ÁÕ Ò¡¶Ö§ 17 àʌ¹ä»ãªŒ§Ò¹ã¹¡ÒäǺ¤ØÁâ´Â㪌ÃдѺÊÑ­­Ò³ TTL

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 15


àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 16


º··Õè 2 ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ µÔ´µ‹Í¡Ñº¾Íϵ¢¹Ò¹ ¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍϨÐÁÕÅ¡Ñ É³Ðઋ¹à´ÕÂǡѺÍØ»¡Ã³Í¹Ô ¾ØµàÍÒµ¾µØ µÑÇÍ×¹è æ ¤×Í àÁ×Íè µŒÍ§¡ÒõԴµ‹Í¨ÐµŒÍ§¡íÒ˹´áÍ´à´ÃÊ·Õµè ͌ §¡ÒõԴµ‹Í´ŒÇ µÒÃÒ§·Õè 2-1 áÊ´§áÍ´à´Ãʢͧ¾Íϵ ¢¹Ò¹ â´Âẋ§Í͡໚¹ 3 µíÒá˹‹§¤×Í áÍ´à´ÃʢͧÃÕ¨ÔÊàµÍÏ Data , ÃÕ¨ÔÊàµÍÏ Status áÅÐ ÃÕ¨ÊÔ àµÍÏ Control â´ÂáÍ´à´Ãʹըé ÐÁÕÍÂÙ·‹ §Ñé ËÁ´ 3 ªØ´ ÊíÒËÃѺ¾Íϵ¢¹Ò¹ 3 ªØ´¤×Í LPT1, LPT2 áÅÐ LPT3 àÁ×è͵ŒÍ§¡ÒõԴµ‹Í¡Ñº¾Íϵ¢¹Ò¹ã¹µíÒá˹‹§ã´ ¡çãˌʋ§¤‹Ò¢ŒÍÁÙÅÍÍ¡ä»·Õè¾Íϵ¢¹Ò¹ã¹ µíÒá˹‹§¹Ñ¹é æ ¡µÑÇÍ‹ҧ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ´ŒÇ QBASIC à¾×èÍʋ§¤‹ÒÅͨԡ “1” ÍÍ¡ä»·Ø¡ºÔµ ¢Í§¾Íϵ Data ¢Í§ LPT1 ¨ÐµŒÍ§à¢Õ¹â»Ãá¡ÃÁ´Ñ§¹Õé OUT

&H378,&HFF

â´Â·Õè à¤Ã×Íè §ËÁÒ &H ·Õáè Ê´§¹Ñ¹é ËÁÒ¶֧µÑÇàÅ¢°Ò¹ÊԺˡ ¤íÒÊѧè

OUT

໚¹¡ÒÃʋ§¤‹Ò¢ŒÍÁÙÅÍÍ¡àÍÒµ¾µØ ¢Í§¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ

¤‹Ò 378 ໚¹áÍ´à´ÃʢͧÃÕ¨ÊÔ àµÍÏ Data ÊíÒËÃѺ LPT1 ¤‹Ò¢ŒÍÁÙÅ FF ໚¹¢ŒÍÁÙÅàÅ¢°Ò¹ÊԺˡ «Öè§ËÁÒ¶֧¡ÒÃãˌºÔµ·Ø¡ºÔµ¢Í§ÃÕ¨ÔÊàµÍÏ Data ÁÕ Åͨԡ໚¹ “1” ¹Ñ¹è àͧ ʋǹ¡ÒÃ͋ҹ¤‹Ò¨Ò¡¾Íϵ¢¹Ò¹ÁÒÂѧ¤ÍÁ¾ÔÇàµÍϼ‹Ò¹·Ò§¾Íϵ Status ¢Í§ LPT1 ÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ´ŒÇ QBASIC 䴌´§Ñ ¹Õé ª×Íè ¾Íϵ

LPT1

LPT2

LPT3

°Ò¹ÊÔº

°Ò¹ÊԺˡ

°Ò¹ÊÔº

°Ò¹ÊԺˡ

°Ò¹ÊÔº

°Ò¹ÊԺˡ

DATA

888

378H

956

3BCH

632

278H

STATUS

889

379H

957

3BDH

633

279H

CONTROL

890

37AH

958

3BEH

634

27AH

µÒÃÒ§·Õè 2-1 áÊ´§áÍ´à´Ãʢͧ¾Íϵ¢¹Ò¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 17


Temp =

â´Â·Õè ¤íÒÊѧè

INP(&H379)

INP(_)

໚¹¤íÒÊѧè ÊíÒËÃѺ¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙÅ

¤‹Ò 379 ໚¹µíÒá˹‹§áÍ´à´ÃʢͧÃÕ¨ÊÔ àµÍÏ STATUS ÊíÒËÃѺ LPT1 ã¹µÑÇàÅ¢°Ò¹ÊԺˡ µÑÇá»Ã

Temp

໚¹µÑÇá»Ã·Õãè ªŒà¡çº¢ŒÍÁÙÅ·ÕÍè ҋ ¹ä´Œ¨Ò¡¾Íϵ¢¹Ò¹

ÊíÒËÃѺâ»Ãá¡ÃÁÍ×¹è æ ઋ¹ áÍÊà«ÁºÅÕ,é à·ÍÏ⺻ÒʤÒÅ ËÃ×Íà·ÍÃâº«Õ ¨ÐÁÕû٠Ẻ¡Òà à¢Õ¹â»Ãá¡ÃÁ·Õèᵡµ‹Ò§¡Ñ¹ºŒÒ§´Ñ§¹Õé

áÍÊà«ÁºÅÕé ¡ÒÃʋ§¤‹Ò¢ŒÍÁÙÅÍÍ¡ä»Âѧ¾Íϵ¢¹Ò¹ mov dx,378h mov al,ffh out dx,al

¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙŨҡ¾Íϵ¢¹Ò¹ mov dx,379h in al,dx

à·ÍÏ⺻ÒʤÒÅ ¡ÒÃʋ§¤‹Ò¢ŒÍÁÙÅÍÍ¡ä»Âѧ¾Íϵ¢¹Ò¹ Port[378H] := FFH

¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙŨҡ¾Íϵ¢¹Ò¹ Temp := Port[379H]

à·ÍÃâº«Õ ¡ÒÃʋ§¤‹Ò¢ŒÍÁÙÅÍÍ¡ä»Âѧ¾Íϵ¢¹Ò¹ outportb

(0x378,0xff)

¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙŨҡ¾Íϵ¢¹Ò¹ temp = inportb(0x379)

Í‹ҧäáçµÒÁâ»Ãá¡ÃÁ·Ø¡µÑǵ‹Ò§¡çãªŒÇ¸Ô ¡Õ ÒÃà´ÕÂǡѹ¤×Í ¡íÒ˹´áÍ´à´ÃÊ·Õ¨è зíÒ¡ÒõԴµ‹Í ¨Ò¡¹Ñ¹é ¨Ö§µÔ´µ‹Í¡ÑºáÍ´à´ÃÊàËÅ‹Ò¹Ñ¹é ´ŒÇ¤íÒÊѧè ÊíÒËÃѺ¡ÒÃ͋ҹËÃ×Íà¢Õ¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 18


¡ÒÃà¢Õ¹â»Ãá¡ÃÁµÔ´µ‹Í¡Ñº¾Íϵ¢¹Ò¹´ŒÇ Visual BASIC ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ´ŒÇ Visual BASIC ªØ´¤íÒÊѧè ʋǹãË­‹¨ÐÁÕû٠Ẻã¡ÅŒà¤Õ§¡Ñº QBASIC ᵋ Visual BASIC ¨ÐäÁ‹Á¤Õ Òí Êѧè ÊíÒËÃѺ¡ÒõԴµ‹Í¡Ñº¾Íϵâ´ÂµÃ§¤×Í ¤íÒÊѧè Inp() áÅФíÒÊѧè OUT àËÁ×͹¡Ñº QBASIC ´Ñ§¹Ñ¹ é à¾×Íè ãˌÊÒÁÒöµÔ´µ‹Í¡Ñº¾Íϵ¢¹Ò¹ä´Œ¨§Ö ¨íÒ໚¹µŒÍ§à¾ÔÁè â»Ãá¡ÃÁ ºÒ§µÑÇࢌÒä» â´Ââ»Ãá¡ÃÁ·Õàè ¾ÔÁè ࢌÒ仹ըé ÐÍÂÙ㋠¹ÃÙ»¢Í§ DLL (Dynamic Linked Library) ä¿Å DLL ¹Õ·é ¹Õè Òí ÁÒá¹Ð¹íÒã¹Ë¹Ñ§Ê×ÍàŋÁ¹Õ¤é Í× io.dll â´ÂÊÒÁÒö㪌䴌¡ºÑ Ãкº»¯ÔºµÑ ¡Ô Òà ·Õàè »š¹ 32 ºÔµ«Ö§è ¡ç¤Í× ÇÔ¹â´Çʏ 95 ¢Ö¹é ä» «Ö§è ¡ç¤Í× ÇÔ¹â´Çʏ 95/98/ME/2000/NT/XP ÊíÒËÃѺµíÒá˹‹§·Õãè ªŒà¡çºä¿Å io.dll ¹Ñ¹é ¨ÐµŒÍ§à¡çºänj·äÕè ´àáµÍÃÕè SYSTEM «Ö§è ÍÂÙÀ‹ Ò ã¹ä´àáµÍÃÕ·è àÕè ¡çºâ»Ãá¡ÃÁÇÔ¹â´Çʏ â´ÂʋǹãË­‹¨ÐÁÕªÍ×è ໚¹ Windows ¡ÒáíÒ˹´¤‹Òã¹â»Ãá¡ÃÁà¾×Íè àÃÕ¡㪌§Ò¹ä¿Å DLL ÁÕû٠Ẻ¡ÒáíÒ˹´¤‹Ò´Ñ§¹Õé Public Declare Function Inp Lib “io.dll” _ Alias “PortIn” (ByVal PortAddress As Integer) As Byte Public Declare Sub Out Lib “io.dll” _ Alias “PortOut” (ByVal PortAddress As Integer, ByVal Value As Byte)

àÁ×Íè ÁÒ¶Ö§µÃ§¹Õé ÍÒ¨à¡Ô´¤íÒ¶ÒÁ¢Ö¹é Ç‹Ò ·íÒäÁäÁâ¤Ã«Í¿µ¼¾ÙŒ ² Ñ ¹Ò«Í¿µáÇÏ Visual BASIC ¨Ö§äÁ‹ÃÇÁ¤íÒÊѧè Inp áÅФíÒÊѧè Out änjã¹â»Ãá¡ÃÁ Visual BASIC à¹×Íè §¨Ò¡Ç‹Ò¡ÒÃà¢Õ¹áÅÐ͋ҹ ¢ŒÍÁÙÅä»Âѧ¾ÍϵËÃ×Í˹‹Ç¤ÇÒÁ¨íÒâ´ÂµÃ§¹Ñ¹é ÍÒ¨·íÒãˌà¡Ô´ÁÕ»­ ˜ ËÒáΧ¡ËÃ×Í·íÒ§Ò¹¼Ô´¾ÅҴ䴌 áÅÐ Visual BASIC ໚¹Ãкº»¯ÔºµÑ ¡Ô Ò÷շè Òí §Ò¹º¹ÇÔ¹â´Çʏ«§Öè ÁÕ¡Ò÷íҧҹẺÁÑŵԷÒÏʡԧé (multitasking) ÁÕâ»Ãá¡ÃÁËÅÒÂæ µÑÇ·íÒ§Ò¹ÍÂÙ¾‹ ÌÍÁ¡Ñ¹ ´Ñ§¹Ñ¹é àÁ×Íè à¡Ô´¤ÇÒÁàÊÕÂËÒ¡Ѻâ»Ãá¡ÃÁµÑÇË¹Ö§è ¡çÍÒ¨¨Ðʋ§¼Åãˌâ»Ãá¡ÃÁ·Õ·è Òí §Ò¹ÍÂÙ·‹ §Ñé ËÁ´àÊÕÂËÒÂ䴌 ¹Í¡¨Ò¡¹Õ¡é ÒÃà¢Õ¹¢ŒÍÁÙÅâ´ÂµÃ§ä»Âѧ ¾Íϵ ÍÒ¨¨Ð价Ѻ«ŒÍ¹¡Ñºâ»Ãá¡ÃÁÍ×è¹æ ·ÕèÁÕ¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ¾Íϵઋ¹à´ÕÂǡѹ ʋ§¼Åãˌ â»Ãá¡ÃÁ·íÒ§Ò¹¼Ô´¾ÅÒ´ ÊíÒËÃѺÃкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´Çʏ 95 ¢Ö¹é ä» ¹Í¡¨Ò¡¨ÐÊÒÁÒö㪌§Ò¹ DLL 㹡ÒõԴµ‹Í ¡Ñº¾Íϵâ´ÂµÃ§áÅŒÇ ÂѧÊÒÁÒö㪌§Ò¹â»Ãá¡ÃÁ»ÃÐàÀ· Visual Device Driver (Vxd) 㹡Òà µÔ´µ‹Í¡ÑºÍØ»¡Ã³Í¹Ô ¾ØµàÍÒµ¾µØ â´Â Vxd ¨ÐµÑ´»˜­ËÒàÃ×Íè §¡ÒÃࢌҶ֧¾Íϵ¾ÃŒÍÁ¡Ñ¹¢Í§â»Ãá¡ÃÁ ËÅÒÂæ µÑÇ䴌 ᵋÊÒí ËÃѺâ»Ãá¡ÃÁÊѹé æ ઋ¹ â»Ãá¡ÃÁ͋ҹ¤‹ÒÍسËÀÙÁÔ â»Ãá¡ÃÁ¤Çº¤ØÁÍØ»¡Ã³ ÍÔ¹¾ØµàÍÒµ¾µØ »¡µÔ«§Öè äÁ‹Á¡Õ ÒõԴµ‹Í¡Ñº¾ÍϵÍÂÙµ‹ ÅÍ´àÇÅÒ ¤íÒÊѧè Inp áÅÐ Out ã¹ DLL ¡ç处 ·íҧҹ䴌´ÕáÅÐÁÕÃٻẺ¡ÒÃ㪌§Ò¹·Õ觋Ò¡NjÒ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 19


ÃÒÂÅÐàÍÕ´à¾ÔÁè àµÔÁà¡ÕÂè ǡѺ io.dll io.dll ¾Ñ²¹Ò¢Ö¹é â´Ââ»Ãá¡ÃÁàÁÍϹÃÔ ¹ÒÁ·Õãè ªŒªÍ×è Ç‹Ò Fred «Ö§è ÁÕ¤ÇÒÁàªÕÂè Ǫҭ´ŒÒ¹¡ÒþѲ¹Ò Ãкº¡ÒÃàª×Íè Áµ‹Í¤ÍÁ¾ÔÇàµÍÏ¡ºÑ ÍØ»¡Ã³ÀÒ¹͡ â´Âä¿Å io.dll ¹Õ¼é àٌ ¢Õ¹â»Ãá¡ÃÁà¼Âá¾Ã‹â´Â äÁ‹¤´Ô ÁÙŤ‹Ò «Ö§è ¼Ùʌ ¹ã¨ÊÒÁÒö´ÒǹâËÅ´àÇÍϪ¹Ñè ãËÁ‹·ÍÕè Ò¨ÁÕ䴌·Õè http://www.geekhideout.com ä¿Å dll µÑǹÕÁé »Õ ÃÐ⪹Í‹ҧÁÒ¡ÊíÒËÃѺ¹Ñ¡¾Ñ²¹Ò·Õµè ͌ §¡ÒõԴµ‹Í¡Ñº¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ ¢Í§¤ÍÁ¾ÔÇàµÍÏ â´Â੾ÒÐÍ‹ҧÂÔ§è ¡Ñº¾Íϵ¢¹Ò¹ã¹Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´Çʏ «Ö§è ã¹»˜¨¨Øº¹Ñ ¡Òà µÔ´µ‹Í¾Íϵ¡ÃзíÒ䴌ÂÒ¡¢Ö¹é ᵋ´ÇŒ ¡ÒÃ㪌ä¿Å dll µÑǹըé Ъ‹ÇÂãˌÊÒÁÒöࢌҶ֧áÅФǺ¤ØÁ䴌§Ò‹  áÅзç»ÃÐÊÔ·¸ÔÀÒ¾ io.dll ÊÒÁÒö㪌§Ò¹ä´Œ¡ÑºÃкº»¯ÔºÑµÔ¡ÒÃÇÔ¹â´Çʏ 95/98/2000/NT ËÃ×Í¡ÃзÑè§ XP ¨Ö§ª‹ÇÂÅ´àÇÅÒáÅÐ¢Ñ¹é µÍ¹ã¹¡ÒþѲ¹Òâ»Ãá¡ÃÁµÔ´µ‹Í¾Íϵ·ÕÃè ¹Ñ º¹ÇÔ¹â´Çʏ䴌Í‹ҧÁÒ¡

¿˜§¡ª¹Ñè ·ÕÁè ÍÕ ÂÙ㋠¹ io.dll 㪌ʧ‹ ¢ŒÍÁÙÅ¢¹Ò´ 1 亵ä»Âѧ¾Íϵ·Õ¡è Òí ˹´ PortWordOut 㪌ʧ‹ ¢ŒÍÁÙÅ 1 àÇÔô (16 ºÔµ) ä»Âѧ¾Íϵ·Õ¡è Òí ˹´ PortDWordOut 㪌ʧ‹ ¢ŒÍÁÙŴѺàºÔÅàÇÔô (32 ºÔµ) ä»Âѧ¾Íϵ·Õ¡è Òí ˹´ PortIn 㪌Íҋ ¹¢ŒÍÁÙÅ¢¹Ò´ 1 亵¨Ò¡¾Íϵ·Õ¡è Òí ˹´ PortWordIn 㪌Íҋ ¹¢ŒÍÁÙÅ 1 àÇÔô (16 ºÔµ) ¨Ò¡¾Íϵ·Õ¡è Òí ˹´ PortDWordIn 㪌Íҋ ¹¢ŒÍÁÙŴѺàºÔÅàÇÔô (32 ºÔµ) ¨Ò¡¾Íϵ·Õ¡è Òí ˹´ SetPortBit 㪌૵¢ŒÍÁÙÅã¹ÃдѺºÔµ¢Í§¾Íϵ·Õ¡è Òí ˹´ ClrPortBit 㪌à¤ÅÕÂϢ͌ ÁÙÅã¹ÃдѺºÔµ¢Í§¾Íϵ·Õ¡è Òí ˹´ NotPortBit 㪌¡ÅѺ¢ŒÍÁÙÅã¹ÃдѺºÔµ¢Í§¾Íϵ·Õ¡è Òí ˹´ GetPortBit 㪌Íҋ ¹Ê¶Ò¹Ð¢Í§ºÔµ·Õ¡è Òí ˹´ RightPortShift 㪌àÅ×Í è ¹¢ŒÍÁÙŢͧ¾Íϵ价ҧ¢ÇÒ ¨Ð䴌¤Ò‹ ¢Í§ºÔµ LSB ¡ÅѺÁÒ LeftPortShift 㪌àÅ×Í è ¹¢ŒÍÁÙŢͧ¾Íϵ价ҧ«ŒÒ ¨Ð䴌¤Ò‹ ¢Í§ºÔµ MSB ¡ÅѺÁÒ IsDriverInstalled 㪌µÃǨÊͺ¡ÒõԴµÑ§é ä¿Å io.dll â´Â¶ŒÒËÒ¡ÁÕ¡ÒõԴµÑ§é ä¿Å ¨Ð䴌¤Ò‹ “1” ËÃ×Í “non-zero” ¡ÅѺÁÒ PortOut

µÑÇÍ‹ҧ¡ÒÃ㪌ä¿Å io.dll 㹡ÒÃà¢Õ¹â»Ãá¡ÃÁ´ŒÇÂÀÒÉÒµ‹Ò§æ ÁÕ´§Ñ ¹Õé

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 20


¡ÒÃ㪌§Ò¹ã¹ÀÒÉÒ C void PortOut(short int Port, char Data); void PortWordOut(short int Port, short int Data); void PortDWordOut(short int Port, int Data); char PortIn(short int Port); short int PortWordIn(short int Port); int PortDWordIn(short int Port); void SetPortBit(short int Port, char Bit); void ClrPortBit(short int Port, char Bit); void NotPortBit(short int Port, char Bit); short int GetPortBit(short int Port, char Bit); short int RightPortShift(short int Port, short int Val); short int LeftPortShift(short int Port, short int Val); short int IsDriverInstalled();

¡ÒÃ㪌§Ò¹ã¹ Delphi procedure PortOut(Port : Word; Data : Byte); procedure PortWordOut(Port : Word; Data : Word); procedure PortDWordOut(Port : Word; Data : DWord); function PortIn(Port : Word) : Byte; function PortWordIn(Port : Word) : Word; function PortDWordIn(Port : Word) : DWord; procedure SetPortBit(Port : Word; Bit : Byte); procedure ClrPortBit(Port : Word; Bit : Byte); procedure NotPortBit(Port : Word; Bit : Byte); function GetPortBit(Port : Word; Bit : Byte) : WordBool; function RightPortShift(Port : Word; Val : WordBool) : WordBool; function LeftPortShift(Port : Word; Val : WordBool) : WordBool; function IsDriverInstalled : Boolean;

¡ÒÃ㪌§Ò¹ã¹ Visual BASIC Private Declare Sub PortOut Lib “IO.DLL” (ByVal Port As Integer, ByVal Data As Byte) Private Declare Sub PortWordOut Lib “IO.DLL” (ByVal Port As Integer, ByVal Data As Integer) Private Declare Sub PortDWordOut Lib “IO.DLL” (ByVal Port As Integer, ByVal Data As Long)

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 21


Private Declare Function PortIn Lib “IO.DLL” (ByVal Port As Integer) As Byte Private Declare Function PortWordIn Lib “IO.DLL” (ByVal Port As Integer) As Integer Private Declare Function PortDWordIn Lib “IO.DLL” (ByVal Port As Integer) As Long Private Declare Sub SetPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal Bit As Byte) Private Declare Sub ClrPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal Bit As Byte) Private Declare Sub NotPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal Bit As Byte) Private Declare Function GetPortBit Lib “IO.DLL” (ByVal Port As Integer, ByVal Bit As Byte) As Boolean Private Declare Function RightPortShift Lib “IO.DLL” (ByVal Port As Integer, ByVal Val As Boolean) As Boolean Private Declare Function LeftPortShift Lib “IO.DLL” (ByVal Port As Integer, ByVal Val As Boolean) As Boolean Private Declare Function IsDriverInstalled Lib “IO.DLL” As Boolean

ÊíÒËÃѺä¿Å io.dll ¨ÐºÃèØÍÂÙ㋠¹á¼‹¹«Õ´ÃÕ ÍÁ PC interface : Parallel port experiment «Ö§è ¨Ñ´ÁҾÌÍÁ¡ÑºË¹Ñ§Ê×ÍàŋÁ¹Õé â´ÂºÃèØÍÂÙ㋠¹ä´àÃ硵ÍÃÕè Software\Dll 㹺·µ‹Í仨ÐàÃÔèÁµŒ¹¡ÒÃ㪌§Ò¹¤ÍÁ¾ÔÇàµÍÏ㹡ÒÃàª×èÍÁµ‹Í¡ÑºÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹·Ò§ ¾Íϵ¢¹Ò¹ â´Â㪌ª´Ø ·´Åͧ NX-2000 «Ö§è »ÃСͺ´ŒÇºÍÏ´·´Åͧ‹ÍÂÁÒ¡ÁÒ â´Â¨Ð·ÂÍ ¡Å‹ÒǶ֧àÁ×Íè ÁÕ¡ÒÃàÃÕ¹ÃÙጠÅз´Åͧ ʋǹâ»Ãá¡ÃÁ·Õãè ªŒÍҌ §Íԧ㹡Ò÷´Åͧ¹Ñ¹é ¼ÙàŒ ÃÕ¹µŒÍ§à¢Õ¹¢Ö¹é àͧ â´Â㪌â»Ãá¡ÃÁ Visual BASIC â´Âã¹áµ‹ÅСÒ÷´Åͧ䴌àµÃÕÂÁâ»Ãá¡ÃÁµÑÇÍ‹ҧänjãˌ à¾×Íè ãˌ¼àٌ ÃÕÂ¹ä´ŒÈ¡Ö ÉÒáÅзíÒ¡Ò÷´ÅÍ§ã¹¢Ñ¹é µŒ¹¡‹Í¹ ¨Ò¡¹Ñ¹é ¨Ö§àÃÔÁè à¢Õ¹â»Ãá¡ÃÁ´ŒÇµ¹àͧ¨Ò¡ §‹ÒÂ仨¹¶Ö§â»Ãá¡ÃÁ·ÕÁè ¤Õ ÇÒÁ«Ñº«ŒÍ¹à¾ÔÁè ÁÒ¡¢Ö¹é ¹Í¡¨Ò¡¹Ñ¹é ¼ÙàŒ ÃÕ¹ÂÑ§ä´ŒÃºÑ ¢ŒÍÁÙŤÇÒÁÃÙàŒ ¡ÕÂè Ç ¡ÑºÍØ»¡Ã³ÍàÔ Åç¡·Ã͹ԡʏ·ãÕè ªŒã¹áµ‹ÅСÒ÷´Åͧà¾ÔÁè àµÔÁä»´ŒÇÂ㹤ÃÒÇà´ÕÂǡѹ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 22


º··Õè 3 ¡ÒõԴµ‹ÍÃÐËNjҧ¾Íϵ¢¹Ò¹ ¡ÑºÍØ»¡Ã³Í¹Ô ¾ØµàÍÒµ¾µØ Í‹ҧ§‹Ò ¨Ò¡·ÄÉ®Õ㹺··Õè 1 ÊÒÁÒöẋ§ÃÕ¨ÊÔ àµÍϢͧ¾Íϵ¢¹Ò¹Í͡䴌໚¹ 3 ÃÕ¨ÊÔ àµÍÏ ¤×Í 1. ÃÕ¨ÊÔ àµÍÏ Data ·íÒ˹ŒÒ·Õàè »š¹àÍÒµ¾µØ 2. ÃÕ¨ÊÔ àµÍÏ Status ·íÒ˹ŒÒ·Õàè »š¹ÍÔ¹¾Øµ 3. ÃÕ¨ÊÔ àµÍÏ Control ·íÒ˹ŒÒ·Õàè »š¹àÍÒµ¾µØ ´Ñ§¹Ñ¹é ¶ŒÒ¼Ù㌠ªŒ§Ò¹µŒÍ§¡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ ¡ç¨ÐµŒÍ§ãªŒÃ¨Õ ÊÔ àµÍÏ Data ËÃ×ÍÃÕ¨ÊÔ àµÍÏ Control ʋǹ¶ŒÒµŒÍ§¡ÒÃÃѺ¤‹Ò¨Ò¡ÍÔ¹¾Øµ ¼Ù㌠ªŒ§Ò¹µŒÍ§ãªŒÃ¨Õ ÊÔ àµÍÏ Status 㹡ÒÃ͋ҹ¤‹ÒÍÔ¹¾Øµ ¡ÒèÐ͌ҧ¶Ö§ ÃÕ¨ÊÔ àµÍÏᵋÅеÑÇ¹Ñ¹é ¼Ù㌠ªŒ§Ò¹¨ÐµŒÍ§ãªŒµÒí á˹‹§áÍ´à´ÃÊ໚¹µÑÇ͌ҧ ´Ñ§ÁÕÃÒÂÅÐàÍÕ´áÊ´§ã¹µÒÃÒ§ ·Õè3-1 â´Â»¡µÔáÅŒÇ Visual BASIC äÁ‹Á¤Õ Òí Êѧè OUT àËÁ×͹¡Ñº QBASIC ´Ñ§¹Ñ¹é à¾×Íè ãˌ Visual BASIC ÊÒÁÒö㪌¤íÒÊÑ觹Õé䴌¨íÒ໚¹µŒÍ§à¾ÔèÁä¿Å inpout32.bas ࢌÒä»ã¹¼Ñ§§Ò¹ËÃ×Íâ»Ãà¨ç¡µ (Project) ¢Í§ Visual BASIC ·Õ¡è Òí Åѧ㪌§Ò¹ÍÂً â´ÂµŒÍ§·íÒµÒÁ¢Ñ¹é µÍ¹´Ñ§¹Õé 1. ä»·Õàè Á¹Ù Project àÃÕ¡¤íÒÊѧè Add File áŌÇà¾ÔÁè ä¿Å inpout32.bas ŧä»ã¹ Project ·ÕËè ¹ŒÒµ‹Ò§ Project ¨Ð»ÃÒ¡¯ä¿Å inpout32.bas ´Ñ§áÊ´§ã¹ÃÙ»·Õè 3-1 2. àÁ×Íè àÅ×Í¡ªÕ·é äÕè ¿Å inpout32.bas áŌÇ㪌¤Òí Êѧè View Code à¾×Íè ´ÙÃÒÂÅÐàÍÕ´ÀÒÂã¹ ¢Í§ä¿Å inpout32.bas ´Ñ§ã¹ÃÙ»·Õè 3-2 ÃÕ¨ÊÔ àµÍÏ DATA STATUS CONTROL

LPT1 378H 379H 37AH

LPT2 3BCH 3BDH 3BEH

LPT3 278H 279H 27AH

µÒÃÒ§·Õè 3-1 áÊ´§áÍ´à´ÃÊÃÕ¨ÊÔ àµÍϢͧ ¾Íϵ¢¹Ò¹ ÃÙ»·Õè 3-1 ¡ÒÃàÃÕ¡ä¿Å inpout32.bas àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 23


ÃÙ»·Õè 3-2 ÃÒÂÅÐàÍÕ´¢Í§ä¿Å inpout32.bas 3. ÊíÒËÃѺä¿Å inpout32.bas ¹Ñ¹é ¨Ð仡íÒ˹´¤íÒÊѧè INP áÅÐ OUT ãˌ¡ºÑ Visual BASIC â´Â¨ÐµŒÍ§ÁÕä¿Å io.dll ºÃèØÍÂÙ㋠¹ä´àáµÍÃÕè SYSTEM ÍÂÙ¡‹ ͋ ¹ «Ö§è 䴌¡Å‹ÒÇänjáŌÇ㹺··Õè 2 4. àÁ×Íè ¶Ö§¢Ñ¹é µÍ¹¹Õ¼é ãٌ ªŒ§Ò¹ÊÒÁÒö㪌¤Òí Êѧè INP áÅÐ ¤íÒÊѧè OUT ã¹â»Ãá¡ÃÁà¾×Íè ÃѺáÅРʋ§¤‹Ò¡Ñº¾Íϵ¢¹Ò¹ä´ŒáÅŒÇ ã¹¡Ò÷´Åͧà¾×èÍÃѺáÅÐʋ§¤‹Ò¼‹Ò¹¾Íϵ¢¹Ò¹¨Ð㪌à¤Ã×èͧÁ×Í·Õè䴌ÃѺ¡ÒÃÍ͡ẺÁÒà¾×èÍ ÍíҹǤÇÒÁÊдǡ㹡ÒÃàÃÕ¹ÃÙጠÅз´Åͧ ¹Ñ¹è ¤×ͪش·´Åͧ NX-2000 â´Â㪌ºÍÏ´àª×Íè Áµ‹Í¾Íϵ ¢¹Ò¹ËÃ×Í P-Board ໚¹ºÍÏ´ËÅÑ¡ áÅкÍÏ´ EX series ÊíÒËÃѺ໚¹µ‹Í¾‹Ç§à¾×Íè ·´Åͧã¹àÃ×Íè § µ‹Ò§æ «Ö§è ¨Ð䴌·ÂÍÂá¹Ð¹íÒàÁ×Íè ¶Ö§àÇÅÒ㪌§Ò¹ ÊíÒËÃѺ㹺·¹Õ¢é Íá¹Ð¹íÒ 3 ºÍÏ´áᡋ͹¤×Í P-Board ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹, EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ áÅÐ EX-03 ºÍÏ´ÊÇÔµªÍ¹Ô ¾Øµ

P-Board ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ ǧ¨Ã¢Í§ P-Board áÊ´§ã¹ÃÙ»·Õè 3-3 â´ÂàÃÔÁè ¨Ò¡¤Í¹à¹ç¡àµÍÏ K002 Ẻ DB-25 µÑÇàÁÕ Íѹ໚¹¨Ø´·Õãè ªŒµÍ‹ àª×Íè Á¡Ñº¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏ «Ö§è ä´ŒÃºÑ ¡ÒèѴÊÃÃÍ͡໚¹ 3 ʋǹ¤×Í 1. ¾Íϵ Data ÁÕµÒí á˹‹§ÍÂÙ·‹ ¢Õè Ò 2 ¶Ö§¢Ò 9 㪌·Òí ˹ŒÒ·Õàè »š¹¢ÒàÍÒµ¾µØ ÊÑ­­Ò³¢ŒÍÁÙŨР¶Ù¡Ê‹§à¢ŒÒÊÙä‹ Í«Õº¿Ñ à¿ÍÏàºÍÏ 74HC541 à¾×Íè ¢ÂÒ¡ÃÐáÊãˌ¡ºÑ ¢ÒàÍÒµ¾µØ D0-D7 ·Ñ§é 8 ¢Ò ¹Í¡ ¨Ò¡¹Ñ¹é Âѧ·íÒ˹ŒÒ·Õàè »š¹µÑÇ»‡Í§¡Ñ¹¤ÇÒÁàÊÕÂËÒ·ÕÍè Ò¨¨Ðà¡Ô´¡Ñº¾Íϵ¢¹Ò¹ÍÕ¡´ŒÇ àÍÒµ¾µØ ¨Ò¡äÍ«Õ 74HC541 ¨Ðʋ§ÍÍ¡ä»Âѧ¤Í¹à¹ç¡àµÍÏ DATA BUS «Ö§è ÁÕ¡ÒèѴ¢ÒµÒÁÁҵðҹ UIC-10 áÅРʋ§ÍÍ¡ä»ÃÇÁ¡Ñº¤Í¹à¹ç¡àµÍÏ P-BUS â´Â¤Í¹à¹ç¡àµÍÏ DATA BUS áÅÐ P-BUS ¨Ð㪌㹡Òà àª×Íè Áµ‹Í¡ÑººÍÏ´ EX-series «Ö§è ໚¹ºÍÏ´ÊíÒËÃѺ·´Åͧ¡ÒÃàª×Íè Áµ‹Í¡ÑºÍØ»¡Ã³ÀÒ¹͡ 2. ¾Íϵ Control 㪌µÒí á˹‹§¢Ò 1, 14, 16 áÅÐ 17 â´Âµ‹ÍࢌҡѺäÍ«Õ 74HC541 à¾×Íè ¢ÂÒ¡ÃÐáÊáÅл‡ Í §¡Ñ ¹ ¤ÇÒÁàÊÕ Â ËÒ·Õè ¨ Ðà¡Ô ´ ¡Ñ º ¾ÍÏ µ ¢¹Ò¹ áŌ Ç µ‹ Í ä»à¢Œ Ò ¤Í¹à¹ç ¡ àµÍÏ CONTROL ¨ÐàËç¹Ç‹Ò㪌੾ÒÐ¢Ò C0-C3 ¾ÃŒÍÁ¡Ñ¹¹Ñ¹é Âѧä»ÃÇÁ¡Ñ¹·Õ¤è ͹à¹ç¡àµÍÏ P-BUS ´ŒÇ ¹Í¡¨Ò¡¹Õ¾é Íϵ Control Âѧ¶Ù¡ãªŒ§Ò¹à¾×Íè ໚¹¢ÒàÍÒµ¾µØ ÊíÒËÃѺ¡ÒõԴµ‹ÍÊ×Íè ÊÒôŒÇ ÃкººÑÊẺ I2C ´ŒÇ â´Â¨Ð㪌¢Ò C1 㹡ÒÃÊÌҧÊÑ­­Ò³ SCL (ÊÑ­­Ò³¹Ò́¡Ò) áÅÐ¢Ò C0 㹡ÒÃÊÌҧÊÑ­­Ò³ SDA (ʋ§¢ŒÍÁÙÅ) â´Â㪌¢Ò S7 «Ö§è ÍÂÙ㋠¹Ê‹Ç¹¢Í§¾Íϵ Status ÃѺ¢ŒÍÁÙÅ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 24


D001-D004 1N4001x4

IC001 7805

K001 DC 9-12V

+5V C004 0.1/50

C002 0.1/50V

K002 PARALLEL PORT (DB-25)

C001 220/16V

C003 10/50

+5V

16 17 18

2

9

3

8

4

7

5

6 D4 5 D3 4 D2 3 D1 2 D0

6

19

7

20

8

21

9

22

10

23

11

24 25

12

+5V

LED001 POWER

K004 DATA BUS (UIC-10)

20

1

14 15

C005 0.1/50V

R001 220

D7

Q7

D6

Q6

D5

Q5

13

14 Q4 15 Q3 16 Q2 17 Q1 18 Q0

D0 D2 D4 D6

D1 D3 D5 D7

+5V

13

C006 0.1/50V

20 2 3 4 5

D0

Q0

D1

Q1

D2

Q2

D3

Q3

+5V

D0 D2 D4 D6 C0 C2 S4 S6

1 10 19

IC002 74HC541

18 17

VR001 10k Brightness

+5V

11 12

K003 P-BUS

(IDC-20)

C3 C0

D1 D3 D5 D7 C1 C3 S3 S5 S7

LCD connector

K005 CONTROL +5V

+5V

C0 C2

C1 C3

16 15

S001 I2C SELECT

R003 2k7

(DIP SW-3)

R002

IC003 74HC541 1 10 19

10k C007 0.1/50V

R004 3k3

+5V

Q3 14 Q4 13 Q5 12 Q6 11 Q7

D3

Q001 BC547

5

6 D4 7 D5 8 D6 9 D7

S4 S6

IC004 74HC541 1 10 19

+5V

S3 S5 S7

K007 I2C BUS (RJ11-4)

R005 10k

K006 STATUS

+5V SDA SCL

+5V

20 15

R/W RS D4 D5 D6 D7

R007 3k3

R006 2k7

Q002 BC547

ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ËÃ×Í P-Board

àª×Íè Áµ‹Í¡Ñº¤ÍÁ¾ÔÇàµÍÏ·Ò§¾Íϵ¢¹Ò¹ l ÁÕǧ¨ÃºÑ¿à¿ÍÏ»Í ‡ §¡Ñ¹¾Íϵ¢¹Ò¹ l ÁÕǧ¨Ãá»Å§ÊÑ­­Ò³à»š¹ÃкººÑÊ I2C l ¤Í¹à¹ç¡àµÍÏÊÒí ËÃѺ¢ÂÒÂÃкºáº‹§à»š¹ÍÔ¹¾Øµ, àÍÒµ¾µ Ø , DATA BUS áÅÐ P-BUS ÊíÒËÃѺàª×Íè Áµ‹ÍºÍÏ´ EX-Series l 㪌ä¿àÅÕÂ é § 9-16V ¼‹Ò¹·Ò§á¨¡ÍÐá´»àµÍÏ º¹ºÍÏ´ÁÕ Ç§¨Ã¤Çº¤ØÁä¿àÅÕÂé §¤§·Õ·è Õè +5V l

ÃÙ»·Õè 3-3 ǧ¨ÃÊÁºÙó¢Í§ P-Board ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 25


¨Ò¡ SDA ¡ÒÃ㪌§Ò¹ÃкººÑÊ I2C ¨ÐàÅ×Í¡¼‹Ò¹´Ô»ÊÇÔµª à¹×Íè §¨Ò¡µŒÍ§¡ÒÃãˌÊÒÁÒö㪌§Ò¹¢Ò ¾Íϵ Control áÅоÍϵ Status 㹧ҹ»¡µÔ䴌 àÁ×Íè äÁ‹Á¡Õ ÒÃ㪌§Ò¹ÃкººÑÊ I2C ǧ¨Ã¢Í§Ê‹Ç¹àª×Íè Áµ‹ÍÃкººÑÊ I2C ¢Í§ P-board ¨Ð㪌·ÃÒ¹«ÔÊàµÍÏ 2 µÑǵ‹Íã¹ÅѡɳР¤ÍÅàÅç¡àµÍÏແ´ «Ö§è 㹪‹Ç§·Õäè Á‹ä´Œ»Í‡ ¹Åͨԡ “1” ãˌ ·ÃÒ¹«ÔÊàµÍϨÐäÁ‹·Òí §Ò¹ áÅÐàÍÒµ¾µØ ¢Í§¢Ò SDA áÅÐ SCL ¨ÐÁÕÅͨԡ “1” ¨Ò¡µÑǵŒÒ¹·Ò¹¾ÙÅÍÑ»¤‹Ò 2.7kΩ ·Õµè ͋ àÍÒänj «Ö§è ¨ÐàÃÕ¡ÊÀÒÇйÕé Ç‹Ò ºÑÊNjҧ áÅÐàÁ×Íè µŒÍ§¡ÒõԴµ‹Í¡ÑººÑÊ I2C ¨ÐµŒÍ§»‡Í¹Åͨԡ “1” ãˌ·ÃÒ¹«ÔÊàµÍÏ·Òí §Ò¹ áÅÐ ãˌàÍÒµ¾Øµ¢Í§ºÑÊ I2C ÍÍ¡ÁÒ໚¹ “0” à¹×èͧ¨Ò¡·ÃÒ¹«ÔÊàµÍϨзíÒ¡ÒÃÅѴǧ¨Ã¢ÒàÍÒµ¾ØµÅ§ ¡ÃÒÇ´ ÊíÒËÃѺÃÒÂÅÐàÍÕ´¡ÒÃ㪌§Ò¹Ãкº ºÑÊ I2C ¨Ð¡Å‹ÒǶ֧ÍÕ¡¤Ãѧé ã¹ÀÒÂËÅѧ 3. ¾Íϵ Status 㪌µÒí á˹‹§¢Ò 15,13,12,10 áÅÐ 11 ¢Í§¾Íϵ¢¹Ò¹ â´Â¢ÒàËŋҹÕàé »š¹ ¢ÒÍÔ¹¾Øµ ´Ñ§¹Ñ¹é äÍ«Õº¿Ñ à¿ÍÏ·¹Õè Òí ÁÒµ‹Í´ŒÇ¨Ð໚¹¡ÒÃÃѺÊÑ­­Ò³ÍÔ¹¾Øµ¨Ò¡ÀÒ¹͡áÅÐʋ§ÊÑ­­Ò³ ä»ãˌ¡ºÑ ¾Íϵ¢¹Ò¹ «Ö§è µÃ§¢ŒÒÁ¡Ñº 2 ¾Íϵáá äÍ«Õº¿Ñ à¿ÍÏ·ãÕè ªŒÂ§Ñ ໚¹àºÍÏ 74HC541 ʋǹ ÍÔ¹¾Øµ¢Í§¾Íϵ Status ¨Ðµ‹Íàª×Íè Á¡Ñº¤Í¹à¹ç¡àµÍÏ STATUS ·Õ¨è ´Ñ ¢ÒµÒÁÁҵðҹ UIC-10 ઋ¹ ¡Ñ¹ â´Â㪌§Ò¹à¾Õ§ 5 µíÒá˹‹§à·‹Ò¹Ñ¹é ¤×Í S3, S4, S5, S6 áÅÐ S7 â´Â¢Ò S7 ໚¹¢ÒÍÔ¹¾Øµãˌ¡ºÑ ºÑÊ I2C ´ŒÇ ¢Ò¾Íϵ Status ·Ñ§é ËÁ´ËÅѧ¨Ò¡¼‹Ò¹ºÑ¿à¿ÍϨÐä»ÃÇÁ¡Ñ¹·Õ¤è ͹à¹ç¡àµÍÏ P-BUS ¹Í¡¨Ò¡¹Õé P-Board 䴌àµÃÕÂÁ¤Í¹à¹ç¡àµÍÏÊÒí ËÃѺàª×Íè Áµ‹Í¡ÑºâÁ´ÙÅ LCD ẺÍÑ¡¢ÃÐ ¢¹Ò´ 16 µÑÇÍÑ¡Éà 1 ËÃ×Í 2 ºÃ÷ѴàÍÒänj â´Â¡íÒ˹´âËÁ´¡ÒõԴµ‹Í¡ÑºâÁ´ÙÅ LCD ໚¹áºº 4 ºÔµ «Ö§è 㪌ÊÒÂÊÑ­­Ò³ D4-D7 ¨Ò¡¾Íϵ Data ¨Ðµ‹ÍࢌҡѺ¢Ò D4-D7 ¢Í§âÁ´ÙÅ LCD ʋǹ¢Ò C0 ¢Í§¾Íϵ Control ¨Ðµ‹ÍࢌҡѺ¢Ò E ¢Í§âÁ´ÙÅ LCD ¢Ò C3 ¢Í§¾Íϵ Control ¨Ðµ‹ÍࢌҡѺ¢Ò RS ¢Í§âÁ´ÙÅ LCD áÅÐà¹×Íè §¨Ò¡¡ÒõԴµ‹Í¡ÑºâÁ´ÙÅ LCD ¨Ð໚¹¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Í‹ҧà´ÕÂÇ ´Ñ§¹Ñ¹é ¢Ò R/W ¢Í§âÁ´ÙÅ LCD ¨Ö§äÁ‹µÍŒ §ãªŒ§Ò¹¢Ò¹Õé ãˌµÍ‹ ŧ¡ÃÒÇ´ P-Board 㪌ä¿àÅÕ駨ҡÀÒ¹͡»‡Í¹à¢ŒÒÁҷҧᨍ¡ÍÐá´»àµÍÏ ¼‹Ò¹ä´âÍ´«Ö觵‹Í¡Ñ¹ã¹ ÅѡɳкÃÔ´¨à¾×Íè ¨Ñ´¢ÑÇé ¢Í§ä¿àÅÕÂé §º¹ P-Board ãËÁ‹ ¨Ò¡¹Ñ¹é ¨Ðʋ§¼‹Ò¹ä»Âѧǧ¨ÃàáÙàÅàµÍÏà¾×Íè á»Å§ áç´Ñ¹ãˌ෋ҡѺ +5V ÊíÒËÃѺ໚¹ä¿àÅÕÂé §ÍØ»¡Ã³º¹ºÍÏ´ áÅÐ໚¹ä¿àÅÕÂé §ãˌ¡ºÑ ǧ¨Ãµ‹Í¾‹Ç§ µ‹Ò§æ ·Õàè ª×Íè Áµ‹Í¡Ñ¹¼‹Ò¹¤Í¹à¹ç¡àµÍÏ P-BUS , DATA BUS áÅкÑÊ I2C

EX-01 : ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ ºÍÏ´ EX-01 áÊ´§Ç§¨Ã´Ñ§ã¹ÃÙ»·Õè 3-4 ÊÒÁÒöàª×Íè Áµ‹Í¡Ñº P-Board ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ P-BUS áÅÐ DATA BUS º¹ºÍÏ´ÁÕ LED ÍÂÙ·‹ §Ñé ËÁ´ 16 ´Ç§ ẋ§Í͡໚¹ 2 ªØ´ ªØ´ÅÐ 8 ´Ç§ ¢Ñºãˌ·Òí §Ò¹¼‹Ò¹·Ò§äÍ«Õº¿Ñ à¿ÍÏàºÍÏ 74HC541 â´Âä´ŒÃºÑ ä¿àÅÕÂé §ÁÒ¨Ò¡ÃкººÑÊ ÊíÒËÃѺ»ÃÐ⪹¢Í§ºÍÏ´ EX-01 ¤×Í㪌áÊ´§¼ÅàÍÒµ¾µØ µ‹Ò§æ ¢Í§ P-Board àÁ×Íè ä´ŒÃºÑ ¡Òà ÊÑ§è §Ò¹¨Ò¡¤ÍÁ¾ÔÇàµÍÏ â´Â¡ÒÃàª×Íè Áµ‹ÍÃÐËNjҧºÍÏ´ EX-01 ¡Ñº P-Board ¨Ð㪌ÊÒ 2 ÃٻẺ ¤×Í ÊÒÂàª×Íè Áµ‹ÍẺ IDC-10 áÅÐÊÒÂàª×Íè Áµ‹ÍẺ IDC-20 ¢Ö¹é ÍÂÙ¡‹ ºÑ NjҵŒÍ§¡ÒÃàª×Íè Áµ‹Í¡ÑººÍÏ´ EX-01 ã¹ÃٻẺ㴠àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 26


K102

K103

DATA BUS #1

DATA BUS #2

(UIC-10)

EX-01 LED display board

(UIC-10)

+5V D0 D2 D4 D6

+5V D0 D2 D4 D6

D1 D3 D5 D7

D1 D3 D5 D7

K101

P-BUS (IDC-20)

,% 3%

10

3$ 3# 3" 3! 3

R108

2 3 4 5 6 7 8 9

3 3

3%

19

C0 C1 C2 C3

20 C102 0.1/50V

18 17 16 15 14 13 12 11

R101

+5V

,$ ,# ," ,! ,

IC101 74HC541 1

, ,

,%

10

9

3$ 3# 3" 3! 3

C101 0.1/50V

2 3 4 5 6 7 8 ,$ ,# ," ,! ,

D1 D3 D5 D7 C1 C3

20

3 3

D0 D2 D4 D6 C0 C2

+5V

, ,

+5V

R116

R109

LED108

D0 D1 D2 D3 D4 D5 D6 D7

IC102 74HC541

18 17 16 15 14 13 12 11

R101-R108 220 x8 LED101

1 19

R109-R116 220 x8 LED109

LED116

D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 C2 C3

EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§

LED áÊ´§¼Åẋ§à»š¹ 2 ʋǹ ʋǹÅÐ 8 ª‹Í§ l ÁÕǧ¨ÃºÑ¿à¿ÍÏÊÒí ËÃѺ¢Ñº LED l ¤Í¹à¹ç¡àµÍÏ P-BUS áÅÐ DATA BUS ÊíÒËÃѺ àª×Íè Áµ‹Í¡Ñº P-Board áÅÐ S-Board l

ÃÙ»·Õè 3-4 ǧ¨ÃÊÁºÙó¢Í§ EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§

EX-03 : ºÍÏ´ÊÇÔµªÍ¹Ô ¾Øµ ºÍÏ´ EX-03 ÁÕǧ¨ÃáÊ´§´Ñ§ÃÙ»·Õè 2-5 º¹ºÍÏ´ EX-03 ÁÕÊÇÔµª¡´µÔ´»Å‹Í´ѺáÅдԻ ÊÇÔµªÍ‹ҧÅÐ 8 ¨Ø´ ã¹ÊÀÒÇл¡µÔ·äÕè Á‹ä´Œ¡´ÊÇÔµªËÃ×ÍàÅ×Íè ¹´Ô»ÊÇÔµªãˌ ON Åͨԡ·Õàè ÍÒµ¾µØ ¢Í§ ÊÇÔµª¨Ð໚¹Åͨԡ “1” à¹×Íè §¨Ò¡µ‹ÍµÑǵŒÒ¹·Ò¹¤‹Ò 10kΩ ¾ÙÅÍÑ»àÍÒänj àÁ×Íè ÁÕ¡Òá´ÊÇÔµª¨Ð໚¹ ¡Òõ‹Í¢Ò¢Í§ÊÇÔµªÅ§¡ÃÒÇ´ ·íÒãˌÁÊÕ ¶Ò¹ÐÅͨԡàÁ×Íè ¡´ÊÇÔµªà·‹Ò¡Ñº “0” ºÍÏ´ EX-03 Í͡ẺÁÒãˌ㪌ÊÒí ËÃѺÊÌҧÊÑ­­Ò³´Ô¨µÔ ÍÅÍÔ¹¾Øµà¾×Íè ʋ§à¢ŒÒä»Âѧ¾Íϵ ¢Í§¤ÍÁ¾ÔÇàµÍÏ â´ÂÅѡɳТͧÊÑ­­Ò³ÍÔ¹¾ØµÁÕ 2 ÅѡɳФ×Í à»š¹ÊÑ­­Ò³¢ŒÍÁÙŤ§·Õáè ÅÐ໚¹ ÊÑ­­Ò³¾ÑÅʏ â´Â´Ô»ÊÇÔµªº¹ºÍÏ´ EX-03 ¨Ð·íÒ˹ŒÒ·ÕÊè Ìҧ¢ŒÍÁÙÅ¢¹Ò´ 8 ºÔµ·Õ¤è §·Õè ¨¹¡Ç‹Ò¨ÐÁÕ ¡ÒÃà»ÅÕÂè ¹á»Å§ ã¹¢³Ð·ÕÊè ÇÔµª¡´µÔ´»Å‹Í´Ѻ¨Ðãˌʭ Ñ ­Ò³ÍÔ¹¾Øµà»š¹áºº¾ÑÅʏ ¡Å‹ÒǤ×Í àÁ×Íè ¡´áÅлŋÍÂÊÇÔµª ¨Ðà¡Ô´¾ÑÅʏ 1 ÅÙ¡ ʋ§ÍÍ¡ä»ÂѧàÍÒµ¾µØ ¢Í§ºÍÏ´µ‹Íä» àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 27


S301 D0 S302 D1 S303 D2 S304 D3 S305 D4 S306 D5 S307 D6

R301 10k*8

+5V K301 DATA BUS

S309 DIP SW.-8

(UIC-10)

+5V R302 10k*8

K302 DATA BUS (UIC-10)

+5V D0 D2 D4 D6

D1 D3 D5 D7

+5V D0 D2 D4 D6

D1 D3 D5 D7

S308 D7 EX-03 Switch input board

EX-03 ºÍÏ´ÊÇÔµª 16 ª‹Í§

´Ô»ÊÇÔµª 8 ª‹Í§ ¾ÃŒÍÁµÑǵŒÒ¹·Ò¹¾ÙÅÍÑ» l ÊÇÔµª¡´µÔ´»Å‹Í´Ѻ 8 ª‹Í§¾ÃŒÍÁµÑǵŒÒ¹·Ò¹¾ÙÅÍÑ» l ¤Í¹à¹ç¡àµÍÏ DATA BUS ÊíÒËÃѺàª×Í è Áµ‹Í¡Ñº PBoard áÅÐ S-Board l

ÃÙ»·Õè 3-5 ǧ¨Ã¢Í§ EX-03 ºÍÏ´ÊÇÔµªÍ¹Ô ¾Øµ ºÍÏ´ EX-03 Áդ͹à¹ç¡àµÍÏÊÒí ËÃѺʋ§ÊÑ­­Ò³ÍÍ¡ 2 ªØ´ ¨Ñ´¢ÒãˌࢌҡѺ¤Í¹à¹ç¡àµÍÏ DATA BUS ¢Í§ P-Board áÅкÍÏ´Í×¹è æ 㹪ش·´Åͧ NX-2000 ºÍÏ´ EX-03 ¨Ð¶Ù¡¹íÒÁÒ㪌㹠¡Ò÷´Åͧ·Õè 3 àÃ×Íè §¡ÒÃ͋ҹ¤‹ÒÍÔ¹¾Øµ´ŒÇ¤íÒÊѧè INP

ÊÃØ»

¡ÒõԴµ‹Í¡Ñº¾Íϵ¢¹Ò¹àº×Íé §µŒ¹¹Ñ¹é ¼Ù㌠ªŒ§Ò¹ÊÒÁÒö㪌¤Òí ÊÑ§è ¾×¹é °Ò¹ã¹ Visual BASIC ÁÒ ª‹ÇÂ㹡ÒõԴµ‹Í䴌 áÅÐà¾×Íè ãˌÊÒÁÒö㪌§Ò¹ä´ŒÍ‹ҧÁÕ»ÃÐÊÔ·¸ÔÀÒ¾ ¤íÒÊÑ§è ¡Ò÷íÒ§Ò¹·Ò§ÅͨԡÁÕ »ÃÐ⪹Í‹ҧÁҡ㹡ÒáíÒ˹´¢ŒÍÁÙÅã¹ÃдѺºÔµ à¾×Íè ãˌ䴌¼ÅÅѾ¸µÒÁµŒÍ§¡ÒÃ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 28


¡Ò÷´Åͧ·Õè 1 ¡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ ·Ò§¾Íϵ Data ´ŒÇ¤íÒÊѧè OUT ¨Ò¡ Visual BASIC ¼‹Ò¹·Ò§ P-Board à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. ÊÒÂàª×Íè Áµ‹Í IDC-10 1 àʌ¹

¡Ò÷´Åͧ 1.1 㪌ÊÒÂàª×Íè Áµ‹Í¨Ò¡¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏࢌҡѺ P-Board 1.2 㪌ÊÒ IDC-10 àª×Íè Áµ‹Í DATA BUS ¢Í§ P-Board ࢌҡѺ DATA BUS ¢Í§ºÍÏ´ EX-01 1.3 ແ´â»Ãá¡ÃÁ Visual BASIC ¢Ö¹é ÁÒ㪌§Ò¹ 1.4 ä»·Õàè Á¹Ù Project àÃÕ¡¤íÒÊѧè Add File áŌÇà¾ÔÁè ä¿Å INPOUT32.BAS «Ö§è ÍÂÙ㋠¹á¼‹¹«Õ´ÃÕ ÍÁ PC interface : Parallel port Experiment ŧä»ã¹ Project ·ÕËè ¹ŒÒµ‹Ò§ Project ¨Ð»ÃÒ¡¯ä¿Å INPOUT32.BAS 1.5 ·Õâè »Ãá¡ÃÁ Visual BASIC ãˌÇÒ§ Command Button ŧ价Õè Form1 2 µíÒá˹‹§ ´Ñ§áÊ´§ ã¹ÃÙ»·Õè P1-1 1.6 ´ÑºàºÔéŤÅÔé¡·Õè Command1 à¾×èÍࢌÒÊًàÁ¹Ù View Code áŌÇà¢Õ¹â»Ãá¡ÃÁãˌ¡Ñºà˵ءÒó Command1_Click ´Ñ§¹Õé Private Sub Command1_Click() Out &H378, &HFF End Sub

1.7 ´ÑºàºÔÅé ¤ÅÔ¡é ·Õè Command2 áŌÇà¢Õ¹«ÍÃÊ â»Ãá¡ÃÁãˌ¡Ñºà˵ءÒó Command2_Click ´Ñ§¹Õé

ÃÙ»·Õè P1-1 ¡ÒÃÇÒ§ Command Button

Private Sub Command2_Click() Out &H378, 0 End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 29


ÃÙ»·Õè P1-2 ˹ŒÒµ‹Ò§ Device Manager ÊíÒËÃѺ ÃÙ»·Õè P1-3 ˹ŒÒµ‹Ò§ Resource áÊ´§áÍ´µÃǨÊͺÎÒÏ´áÇÏ à´Ãʢͧ¾Íϵ¢¹Ò¹ 1.8 ·íÒ¡Òè‹ÒÂä¿ãˌ¡ºÑ P-Board 1.9 Ãѹâ»Ãá¡ÃÁ·Õàè ¢Õ¹¢Ö¹é ¨Ò¡¹Ñ¹é ·íÒ¡Òá´»ØÁ† Command1 ÊѧࡵؼšÒÃà»ÅÕÂè ¹á»Å§·Õàè ¡Ô´¢Ö¹é ·Õè LED º¹ºÍÏ´ EX-01 ¶ŒÒâ»Ãá¡ÃÁ·íÒ§Ò¹¶Ù¡µŒÍ§ LED ·Ñ§é 8 ´Ç§¨ÐµÔ´ÊNjҧ·Ñ§é ËÁ´ 1.10 ·íÒ¡Òá´»ØÁ† Command2 Êѧࡵ¼Å¡ÒÃà»ÅÕÂè ¹á»Å§·Õàè ¡Ô´¢Ö¹é ·Õè LED ¶ŒÒâ»Ãá¡ÃÁ·íÒ§Ò¹ ¶Ù¡µŒÍ§ LED ¨Ð´Ñº·Ñ§é ËÁ´ 1.11 ¶ŒÒâ»Ãá¡ÃÁ·íÒ§Ò¹äÁ‹¶¡Ù µŒÍ§ãˌµÃǨÊͺ´ÙÇҋ ¾Íϵ¢¹Ò¹·Õãè ªŒÍÂÙ¹‹ ¹Ñé ÁÕµÒí á˹‹§áÍ´à´ÃÊÍÂÙ·‹ Õè 378H ઋ¹à´ÕÂǡѺµÑÇÍ‹ҧ¹ÕËé Ã×ÍäÁ‹ â´Â㪌àÁÒʏ¤ÅÔ¡é ·Õè My Computer ¨Ò¡¹Ñ¹é ¤ÅÔ¡é àÁÒʏ¢ÇÒáÅŒÇ àÅ×Í¡ Property áÅÐàÅ×Í¡ä»·Õáè ·ç» Device Manager ¨Ð»ÃÒ¡®Ë¹ŒÒµ‹Ò§´Ñ§áÊ´§ã¹ÃÙ»·Õè P1-2 àÅ×Í¡·Õè Printer Port áŌǤÅÔé¡·Õè»Ø†Á Property àÅ×Í¡á·ç»ä»·Õè Resource ¨Ð»ÃÒ¡¯Ë¹ŒÒµ‹Ò§´Ñ§ áÊ´§ã¹ÃÙ»·Õè P1-3 1.12 ã¹Ë¹ŒÒµ‹Ò§¹Õ¨é ÐáÊ´§µíÒá˹‹§áÍ´à´Ãʢͧ¾Íϵ¢¹Ò¹·Õãè ªŒ§Ò¹ÍÂÙ㋠¹¢³Ð¹Ñ¹é µíÒá˹‹§áÍ´ à´ÃʵÑÇàÅ¢´ŒÒ¹Ë¹ŒÒÊØ´ (0378) ໚¹µíÒá˹‹§áÍ´à´Ãʢͧ¾Íϵ DATA «Ö§è ¶ŒÒµíÒá˹‹§áÍ´à´ÃÊ ¢Í§¼Ù㌠ªŒà»š¹µíÒá˹‹§Í×¹è æ àÇÅÒà¢Õ¹â»Ãá¡ÃÁ¨ÐµŒÍ§ÃкصÒí á˹‹§áÍ´à´ÃÊàËŋҹѹé ãˌµÃ§´ŒÇ ¨Ö§¨ÐÊÒÁÒöàË繡ÒÃà»ÅÕÂè ¹á»Å§·Õàè ¡Ô´¢Ö¹é ·Õè LED º¹ºÍÏ´ Ex-01 䴌 1.13 ¶ŒÒâ»Ãá¡ÃÁáÊ´§¢ŒÍ¼Ô´¾ÅÒ´´Ñ§ã¹ÃÙ»·Õè P1-4 ¹Ñè¹ËÁÒ¤ÇÒÁNjҼٌ㪌§Ò¹ÂѧäÁ‹ä´Œ·íÒ¡Òà ¤Ñ´ÅÍ¡ä¿Å io.dll ¨Ò¡á¼‹¹«Õ´ÃÕ ÍÁ PC interface : Parallel port Experiment ä»änjã¹â¿Åà´ÍÏ SYSTEM ¢Í§ÇÔ¹â´Çʏ «Ö§è ·íÒãˌâ»Ãá¡ÃÁËÒä¿Å¹äÕé Á‹¾ºáÅÐàÃÕ¡㪌§Ò¹¤íÒÊѧè OUT äÁ‹ä´Œ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 30


ÃÙ»·Õè P1-4 ˹ŒÒµ‹Ò§áÊ´§¤ÇÒÁ ¼Ô´¾ÅÒ´àÁ×Íè ¤Œ¹ËÒä¿Å io.dll äÁ‹¾º 1.14 ¶ŒÒâ»Ãá¡ÃÁ·íÒ§Ò¹»¡µÔ ãˌ¼ãٌ ªŒ§Ò¹·´Åͧʋ§¤‹ÒÍ×¹è æ Í͡仺ŒÒ§ ઋ¹ ʋ§¤‹Ò &H55 ÍÍ¡ä» (OUT &H378,&H55 ) ¨ÐàËç¹ LED µÔ´áÅдѺÊÅѺ¡Ñ¹ à¹×Íè §¨Ò¡¤‹ÒµÑÇàÅ¢°Ò¹Êͧ¢Í§ 55H ¤×Í 01010101 «Ö§è ¡ÒÃʋ§¤‹Ò “1” Í͡仡ç໚¹¡Ò÷íÒãˌ LED µÔ´ÊNjҧ¹Ñ¹è àͧ ʋǹ¤‹Ò “0” ¡ç໚¹ ¡Ò÷íÒãˌ LED ´Ñº ÊíÒËÃѺÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ·´Åͧ·ÕÊè ÁºÙó´äÙ ´Œ¨Ò¡ä¿Å LAB01.VBP

¡Ò÷´Åͧ·Õè 2 ¡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ ·Ò§¾Íϵ Control à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. ÊÒÂàª×Íè Áµ‹Í IDC-10 1 àʌ¹

·ÄÉ®Õ ¡ÒÃʋ§¤‹ÒÍÍ¡·Õ¾è Íϵ Control ÁÕÅ¡Ñ É³Ð¤ÅŒÒ¡Ѻ¡ÒÃʋ§¤‹ÒÍÍ¡·Õ¾è Íϵ Data ᵡµ‹Ò§¡Ñ¹ ·Õ¾è Íϵ Control ÁÕáÍ´à´ÃÊÍÂÙˋ ҋ §¨Ò¡áÍ´à´Ãʢͧ¾Íϵ Data 2 µíÒá˹‹§ ¶ŒÒ¾Íϵ Data ÁÕ áÍ´à´ÃÊ෋ҡѺ 378H ¾Íϵ Control ¨ÐÁÕáÍ´à´ÃÊÍÂÙ·‹ Õè 37AH ¢ŒÍᵡµ‹Ò§ÍÕ¡»ÃСÒÃË¹Ö§è ¤×Í ¾Íϵ Control ÁÕ¢ÒÊíÒËÃѺµÔ´µ‹Íà¾Õ§ 4 ¢Ò ᵡµ‹Ò§¡Ñº¾Íϵ Data ·ÕÁè ¶Õ §Ö 8 ¢Ò â´Â¢Ò¢Í§¾Íϵ Control ¨ÐÍÂÙ·‹ Õè 4 ºÔµÅ‹Ò§ àÃÕ¡ºÔµàËŋҹÕÇé ҋ ºÔµ C0,C1,C2 áÅÐ C3 àÁ×Íè ¹íÒ ºÍÏ´ EX-01 ÁÒµ‹Í àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 31


ࢌҡѺ¾Íϵ Control ¨ÐÁÕ¡ÒÃáÊ´§¼Åà¾Õ§ 4 ºÔµÅ‹Ò§à·‹Ò¹Ñ¹é ¹Í¡¨Ò¡¹Õºé µÔ C0,C1 áÅÐ C3 Âѧ ÁÕ¡ÒáÅѺʶҹдŒÇ ·íÒãˌàÁ×Íè ÁÕ¡Òû‡Í¹ “1” ÍÍ¡ä»·Õºè µÔ àËŋҹդé ҋ ·Õáè Ê´§¨Ð໚¹¤‹ÒµÃ§¡Ñ¹¢ŒÒÁ ¤×Í LED ¨Ð´Ñºá·¹ ᵋàÁ×Íè »‡Í¹ “0” ÍÍ¡ä» LED ¨Ö§µÔ´ ʋǹºÔµ C2 ¹Ñ¹é äÁ‹Á¡Õ ÒáÅѺʶҹÐã´ æ

¡Ò÷´Åͧ 2.1 àª×èÍÁµ‹Í¤Í¹à¹ç¡àµÍÏ CONTROL BUS ¢Í§ P-BOARD ¡Ñº¤Í¹à¹ç¡àµÍÏ DATA BUS ¢Í§ºÍÏ´ EX-01 ´ŒÇÂÊÒÂàª×Íè Áµ‹Í IDC-10 2.2 ᡌä¢â»Ãá¡ÃÁ¢Í§ Command1_Click ໚¹ Private Sub Command1_Click() Out &H37A, &HF4 End Sub

2.3 ᡌä¢â»Ãá¡ÃÁ¢Í§ Command2_Click ໚¹ Private Sub Command1_Click() Out &H37A, &HB End Sub

2.4 Ãѹâ»Ãá¡ÃÁ ·´Åͧ¡´»ØÁ† Command1 áÅÐ Command2 áŌÇÊѧࡵ¼Å¡Ò÷íÒ§Ò¹ àÁ×èÍ ¡´»ØÁ† Command2 ¨ÐàËç¹ LED º¹ºÍÏ´ EX-01 ´Ñº·Ø¡´Ç§ ·Ñ§é ·Õ»è ͇ ¹¤‹Ò 0BH ·Ñ§é ¹Õàé ¹×Íè §¨Ò¡ ÁÕ¡ÒáÅѺʶҹТͧºÔµ C0, C1 áÅÐ C3 ÍÂً áÅÐ àÁ×Íè ¡´·Õè Command1 LED ¨ÐµÔ´à¾Õ§ 4 ´Ç§à·‹Ò¹Ñ¹é à¹×Íè §¨Ò¡¢Ò·Õµè ͋ 㪌§Ò¹¢Í§¾Íϵ Control ÁÕà¾Õ§ 4 µíÒá˹‹§ ÊíÒËÃѺÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ·´Åͧ·ÕÊè ÁºÙó´äÙ ´Œ¨Ò¡ä¿Å LAB02.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 32


¡Ò÷´Åͧ·Õè 3 ¡ÒÃ͋ҹ¤‹Ò¨Ò¡ÍÔ¹¾Øµ¼‹Ò¹¾Íϵ Status ´ŒÇ¤íÒÊѧè INP º¹ Visual BASIC à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board

1 Ἃ¹

2. EX-03 ºÍÏ´ÊÇÔµªÍ¹Ô ¾Øµ

1 Ἃ¹

3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. ÊÒÂàª×Íè Áµ‹Í IDC-10

1 àʌ¹

¡Ò÷´Åͧ 3.1 àª×Íè Áµ‹ÍÊÒ IDC10 ¨Ò¡ P-Board ã¹Ê‹Ç¹¢Í§ STATUS BUS ä»Âѧ¤Í¹à¹ç¡àµÍÏ DATA BUS º¹ºÍÏ´ EX-03 â´Âµ‹ÍࢌҡѺ´ŒÒ¹¢Í§´Ô»ÊÇÔµª 3.2 ã¹â»Ãá¡ÃÁ Visual BASIC ãˌ·íÒ¡ÒÃÊÌҧ Form áÅÐÇÒ§»Ø†Á Command áÅÐ Textbox ´Ñ§áÊ´§ã¹ÃÙ»·Õè P3-1 «Ö§è Text1 ¹Ñ¹é ¨Ðänj㪌ÊÒí ËÃѺ¡ÒÃáÊ´§¤‹Ò·ÕÍè ҋ ¹ä´Œ¨Ò¡ÊÇÔµª 3.3 ·íÒ¡ÒÃà¾ÔÁè ä¿Å INPOUT32.BAS ࢌÒä»ã¹â»Ãá¡ÃÁà¾×Íè ãˌÊÒÁÒö㪌§Ò¹¤íÒÊѧè Inp áÅФíÒ Êѧè Out 䴌 3.4 ·íÒ¡ÒÃà¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ Command1 ´Ñ§¹Õé Text1.Text = Inp(&H379)

3.5 ·´ÅͧÃѹâ»Ãá¡ÃÁãˌ·Òí §Ò¹´Ù¤Ò‹ ¡ÒÃà»ÅÕÂè ¹á»Å§·Õè Text1

ÃÙ»·Õè P3-1 ÇÒ§»ØÁ† Command áÅÐ Textbox

3.6 ¨ÐÊѧࡵ䴌Çҋ àÁ×Íè ·íÒ¡ÒÃà»ÅÕÂè ¹á»Å§ ÊÇÔµªã¹µíÒá˹‹§µÑ§é ᵋ 3-7 ¤‹ÒµÑÇàÅ¢·ÕÍè ҋ ¹ 䴌¨ÐÁÕ¡ÒÃà»ÅÕè¹á»Å§ ÊíÒËÃѺµíÒá˹‹§ ÊÇÔµªµíÒá˹‹§ 0-2 ¹Ñé¹äÁ‹ÁÕ¡ÒÃà»ÅÕè¹á»Å§ à¹×èͧ¨Ò¡·Õè¾Íϵ Status äÁ‹ÁÕµíÒá˹‹§¾Íϵ ¢Í§ºÔµàËŋҹÕÍé Âً ·Ñ§é ¹Õàé ¹×Íè §¨Ò¡¾Íϵ Status ÁÕºµÔ 㪌§Ò¹à¾Õ§ 5 ºÔµ¤×Í ºÔµ S3-S7 ෋ҹѹé â´Â·Õºè µÔ S7 ¨ÐÁÕ¡ÒáÅѺʶҹÐÍÂً

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 33


3.7 ¡ÒÃ͋ҹ¤‹Òâ´Â㪌¤Òí Êѧè Text1.Text = Inp(&H379) ¹Ñ¹é ÍÒ¨·íÒãˌ¤Ò‹ ·ÕÍè ҋ ¹ä´Œ·Òí ¤ÇÒÁࢌÒ㨠䴌ÂÒ¡à¹×Íè §¨Ò¡¤‹Ò·ÕÍè ҋ ¹ä´Œà»š¹µÑÇàÅ¢°Ò¹ÊÔº à¾×Íè ãˌÍҋ ¹à¢ŒÒã¨ä´Œ§Ò‹ µÑÇàÅ¢·ÕÍè ҋ ¹¤ÇÃ໚¹µÑÇàÅ¢ °Ò¹ÊԺˡ ´Ñ§¹Ñ¹é ãˌ·Òí ¡ÒÃᡌä¢â»Ãá¡ÃÁâ´Âà¾ÔÁè ¤íÒÊѧè Hex$ ࢌÒä»â´Âãˌ·Òí ¡ÒÃᡌä¢â»Ãá¡ÃÁ ´Ñ§¹Õé Text1.Text = Hex$(Inp(&H379))

3.8 ¤‹Ò·ÕÍè ҋ ¹ä´ŒËÅѧ¨Ò¡·Õáè ¡Œä¢â»Ãá¡ÃÁä»áŌǨÐ໚¹àÅ¢°Ò¹ÊԺˡ ᵋÍ‹ҧäáçµÒÁ¤‹ÒµÑÇàÅ¢ ·ÕÍè ҋ ¹ä´Œ¡Âç §Ñ ÁÕºµÔ ·Õäè Á‹ä´ŒãªŒ§Ò¹¤×ͺԵ S2,S1,S0 ¼ÊÁÍÂÙ´‹ nj  㹡ÒÃ͋ҹ¤‹ÒᵋÅФÃÑ§é ·íÒãˌ¤Ò‹ ·Õè ͋ҹ䴌äÁ‹¶¡Ù µŒÍ§µÒÁ¤ÇÒÁ໚¹¨ÃÔ§ ´Ñ§¹Ñ¹é ãˌ·Òí ¡ÒÃᡌä¢â»Ãá¡ÃÁÍÕ¡¤Ãѧé â´Â㪌¤Òí ÊÑ§è ·Ò§Åͨԡ ࢌÒÁÒª‹Ç â´Â·íÒ¡ÒÃᡌä¢â»Ãá¡ÃÁ´Ñ§¹Õé Text1.Text = Hex$(Inp(&H379) And &HF8 )

3.9 ¨Ò¡¡ÒÃᡌä¢â»Ãá¡ÃÁ ·íÒãˌ¤Ò‹ ·ÕÍè ÂÙ㋠¹ºÔµ S2,S1,S0 Áդҋ ໚¹ 0 ·Ñ§é ËÁ´à¹×Íè §¨Ò¡¡Òà AND ºÔµàËŋҹմé nj  0 ¹Ñ¹è àͧ â´Â¤‹Ò F8 àÁ×Íè à»ÅÕÂè ¹à»š¹àÅ¢°Ò¹Êͧ¡ç¤Í× 11111000 ¹Ñ¹è àͧ ·íÒãˌ¤Ò‹ ·Õáè Ê´§·Õè Text1 ¨Ö§à»š¹¤‹Ò·Õäè ´Œ¨Ò¡¡Òá´ÊÇÔµª¨ÃÔ§ æ 3.10 ËÅѧ¨Ò¡·Õ·è Òí ¡ÒÃᡌä¢áÅŒÇ ¨ÐÊѧࡵàËç¹Ç‹Ò·Õºè µÔ S7 ÂѧÁÕ¡ÒÃà»ÅÕÂè ¹á»Å§·Õäè Á‹¶¡Ù µŒÍ§ à¹×Íè §¨Ò¡ºÔµ S7 ¹Ñ¹é ¶Ù¡¡ÅѺʶҹÐänj ¶ŒÒµŒÍ§¡ÒÃãˌÍҋ ¹¤‹Ò䴌¶¡Ù µŒÍ§ÁÒ¡¡Ç‹Ò¹Õ¨é еŒÍ§¡ÃзíÒ ¡Ò÷ҧÅͨԡÍÕ¡¤Ãѧé â´Âᡌä¢â»Ãá¡ÃÁ´Ñ§¹Õé Text1.Text = Hex$(Inp(&H379) And &HF8 Xor &H80)

3.11 àÁ×Íè ·íÒ¡ÒÃᡌä¢â»Ãá¡ÃÁáÅŒÇ ºÔµ S7 ¨Ð¶Ù¡¡ÅѺʶҹÐãˌÁÊÕ ¶Ò¹ÐµÃ§¡Ñ¹¢ŒÒÁà¹×Íè §¨Ò¡ ¤íÒÊѧè Xor â´Â¶ŒÒ໚¹¡Òà Xor ¤‹Òã´ æ ¡Ñº¤‹Ò·Õàè »š¹ “1” ¤‹Ò¢Í§µÑÇàÅ¢·Õºè µÔ ¹Ñ¹é ¨Ð͋ҹ¤‹ÒÍÍ¡ÁÒ ä´Œà»š¹¤‹ÒµÃ§¡Ñ¹¢ŒÒÁ 3.12 ãˌ·Òí ¡Ò÷´Åͧà»ÅÕÂè ¹á»Å§¤‹Ò·Õ´è »Ô ÊÇÔµªà¾×Íè ´ÙÇҋ ¤‹Ò·ÕÍè ҋ ¹ä´Œ¹¹Ñé ¶Ù¡µŒÍ§ËÃ×ÍäÁ‹ ËÅѧ¨Ò¡ à»ÅÕÂè ¹á»Å§¤‹ÒÍÒ¨¨Ð¾ºÇ‹Ò µŒÍ§¡´ÊÇÔµª Command1 ·Ø¡æ ¤Ãѧé à¾×Íè ͋ҹ¤‹Ò «Ö§è äÁ‹Êдǡ¹Ñ¡ ÊíÒËÃѺÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ·´Åͧ·ÕÊè ÁºÙó¢Í§¡Ò÷´Åͧ¢ŒÍ·Õè 3.1-3.12 ´Ù䴌¨Ò¡ ä¿Å LAB03A.VBP 3.13 ÁÕÇ¸Ô ·Õ ¨Õè зíÒãˌâ»Ãá¡ÃÁ͋ҹ¤‹ÒÍ‹ҧµ‹Íà¹×Íè §ä´Œ¤Í× ãªŒä·àÁÍÏÁÒª‹ÇÂ㹡ÒÃ͋ҹ¤‹Ò â´Â ãˌ¼ãٌ ªŒ§Ò¹à¾ÔÁè ä·àÁÍÏࢌÒä»ã¹â»Ãá¡ÃÁ´Ñ§ÃÙ»·Õè P3-2 3.14 ¨Ò¡¹Ñ¹é à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ ä·àÁÍÏ´§Ñ ¹Õé Private Sub Timer1_Timer() Text1.Text = Hex$(Inp(&H379) And &HF8 Xor &H80) End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 34


ÃÙ»·Õè P3-2 à¾ÔÁè ä·àÁÍÏà¾×Íè ª‹ÇÂãˌÊÒÁÒö ÃÙ»·Õè P3-3 ᡌ䢤‹Ò Interval ã¹ Timer1 à¾×Íè ·íҧҹ䴌Í‹ҧµ‹Íà¹×Íè § ¡íÒ˹´¤ÇÒÁàÃçÇ㹡Òõͺʹͧµ‹Í¡Òà à»ÅÕÂè ¹á»Å§¢Í§ÍÔ¹¾Øµ 3.15 ¨Ò¡¹Ñ¹é ·íÒ¡ÒÃᡌ䢤‹Ò Interval ¢Í§ Timer1 ã¹Ê‹Ç¹ Property ãˌÁ¤Õ ҋ ෋ҡѺ 500 ´Ñ§áÊ´§ ã¹ÃÙ»·Õè P3-3 «Ö§è ËÁÒ¶֧ àÁ×Íè â»Ãá¡ÃÁ·íÒ§Ò¹ä»ä´Œ 0.5 ÇÔ¹Ò·Õ ¨Ð¡ÃÐâ´´ÁÒ·íÒ§Ò¹·Õâè »Ãá¡ÃÁ ‹Í Timer1_Timer() áÅзíÒ¡ÒÃ͋ҹ¤‹ÒÊÇÔµªÍ¹Ô ¾Øµ ¶Ö§µÍ¹¹Õ¶é Ҍ ÁÕ¡ÒÃà»ÅÕÂè ¹á»Å§¤‹Ò·ÕÊè ÇÔµª ÍÔ¹¾Øµ ·ÕËè ¹ŒÒ¨Í¢Í§¤ÍÁ¾ÔÇàµÍÏ¡¨ç Ðà»ÅÕÂè ¹á»Å§¤‹ÒµÑÇàÅ¢µÒÁ·Ñ¹·Õ ¶ŒÒµŒÍ§¡ÒÃãˌ¡ÒÃà»ÅÕÂè ¹ á»Å§·íÒ䴌àÃçǡNjҹÕé ÊÒÁÒö·íÒ䴌â´Âà»ÅÕÂè ¹¤‹Ò Interval ¢Í§ä·àÁÍÏãˌ¹ÍŒ Âŧ 3.16 ¡ÒÃ͋ҹ¤‹Òâ´Â㪌¤Òí Êѧè Inp ¹Ñ¹é ÊÒÁÒö㪌§Ò¹¡Ñº¾Íϵ Data áÅоÍϵ Control 䴌´ÇŒ  ¶ŒÒ¼Ù㌠ªŒ§Ò¹¡íÒ˹´âËÁ´¡ÒÃàª×Íè Áµ‹Í¢Í§¾Íϵ¢¹Ò¹änj໚¹áºº 2 ·ÔÈ·Ò§ (â´Â¾Íϵ¢¹Ò¹¢Í§ ¤ÍÁ¾ÔÇàµÍϨеŒÍ§à»š¹áºº EPP ´ŒÇÂ) ᵋ¡ÒÃ㪌§Ò¹ã¹ÅѡɳйÕäé Á‹¢Íá¹Ð¹íÒ à¹×Íè §¨Ò¡äÁ‹ »ÅÍ´Àѵ‹Í¾Íϵ¢¹Ò¹àͧ à¹×Íè §¨Ò¡ºÒ§¤ÃÑ§é ¶ŒÒ¡íÒ˹´ãˌ¾Íϵ Data ËÃ×;Íϵ Control ໚¹ àÍÒµ¾µØ ÍÂً áŌÇʋ§¤‹ÒÍÍ¡ÁÒ໚¹Åͨԡ “0” ã¹¢³Ðà´ÕÂǡѹÁÕ¡Òû‡Í¹áç´Ñ¹Åͨԡ “1” ࢌҷվè Íϵ ¹Õàé ¾×Íè µŒÍ§¡ÒáíÒ˹´ãˌ໚¹ÍÔ¹¾Øµ ¨Ð·íÒãˌÀÒ¤ä´ÃàÇÍϢͧ¾Íϵ¢¹Ò¹àÊÕÂËÒÂ䴌 ´Ñ§¹Ñ¹é 㹡Òà Í͡Ẻ¡ÒÃàª×èÍÁµ‹Í¾Íϵ¢¹Ò¹¡ÑºÍØ»¡Ã³ÀÒ¹͡µŒÍ§¤íÒ¹Ö§¶Ö§Ê‹Ç¹¹Õ鴌Ç ÊíÒËÃѺ P-Board ·Õãè ªŒã¹¡Ò÷´Åͧ¹Ñ¹é ¨Ð¡íÒ˹´ãˌ¾Íϵ Data áÅоÍϵ Control ·íÒ˹ŒÒ·Õàè »š¹àÍÒµ¾µØ à·‹Ò¹Ñ¹é ¶ŒÒµŒÍ§¡ÒÃ㪌§Ò¹ÍÔ¹¾ØµµŒÍ§ãªŒ¾Íϵ Status ÁÒª‹Ç ÊíÒËÃѺÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ·´Åͧ·ÕÊè ÁºÙó¢Í§¡Ò÷´Åͧ¢ŒÍ·Õè 3.13-3.16 ´Ù䴌¨Ò¡ ä¿Å LAB03B.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 35


..


º··Õè 4 ¡ÒâѺÍØ»¡Ã³àÍÒµ¾µØ ¡ÃÐáÊÊÙ§ ¼‹Ò¹¾Íϵ¢¹Ò¹ â´Â¤ÇÒÁÊÒÁÒö¾×é ¹ °Ò¹¢Í§¾ÍÏ µ ¢¹Ò¹áŌ Ç äÁ‹ Ê ÒÁÒö¹í Ò ä»¢Ñ º ÍØ » ¡Ã³ à ÍÒµ ¾Ø µ â´ÂµÃ§ä´Œ à¹×èͧ¨Ò¡¢ŒÍ¨íÒ¡Ñ´´ŒÒ¹¤ÇÒÁÊÒÁÒö㹡Òè‹Ò¡ÃÐáÊ ´Ñ§¹Ñ鹶ŒÒµŒÍ§¡ÒùíÒàÍÒ¾Íϵ ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏ仢ѺÍØ»¡Ã³ÀÒ¹͡¨ÐµŒÍ§ÁÕǧ¨ÃºÑ¿à¿ÍÏ·Òí ˹ŒÒ·Õ¨è ҋ ¡ÃÐáÊãˌà¾Õ§¾Í ᡋ¤ÇÒÁµŒÍ§¡ÒâͧÍØ»¡Ã³àÍÒµ¾Øµ¹Ñé¹ Í‹ҧäáçµÒÁã¹Ê‹Ç¹¢Í§Ç§¨ÃºÑ¿à¿ÍϹÑ鹡çÁÕ¢Õ´¤ÇÒÁ ÊÒÁÒö㹡Òè‹Ò¡ÃÐáÊ䴌ÃдѺ˹֧è à·‹Ò¹Ñ¹é ¡Ã³Õ·µÕè ͌ §¡Òè‹Ò¾Åѧ§Ò¹ÊÙ§¨ÐµŒÍ§ÁÕÍ»Ø ¡Ã³··Õè Òí ˹ŒÒ·Õ訋ÒÂáç´Ñ¹áÅСÃÐáÊÊÙ§â´Â੾ÒÐ àÃÕ¡ÍØ»¡Ã³àËŋҹÕéÇ‹Ò ÍØ»¡Ã³¢Ñº ËÃ×Í ä´ÃàÇÍÏ (driver) «Ö§è ã¹·Õ¹è ¹Õé Òí ÁÒ͸ԺÒ·ѧé ÊÔ¹é 3 ÃٻẺ¤×Í ãªŒ·ÃÒ¹«ÔÊàµÍÏ¢ºÑ , 㪌äÍ«Õ¢ºÑ áÅÐãªŒÍ»Ø ¡Ã³ àª×Íè Á⧷ҧáʧËÃ×ÍÍͻⵌ¤»Ñ à»ÍÏ (opto-coupler) ÊíÒËÃѺâËÅ´·Õµè ͌ §¡ÒáÃÐáÊÊÙ§ÁÒ¡æ ·íÒãˌ µŒÍ§ÁÕ¡ÒÃá¡Ãкº¡ÃÒÇ´¢Í§Ãкº¤ÍÁ¾ÔÇàµÍÏÍÍ¡¨Ò¡Ç§¨ÃàÍÒµ¾Øµ à¾×èÍÅ´ÊÑ­­Ò³Ãº¡Ç¹ áÅл‡Í§¡Ñ¹¡ÒÃŒ͹¡ÅѺ¢Í§áç´Ñ¹áÅСÃÐáÊÊÙ§·ÕèÍҨࢌÒÁÒ·íÒ¤ÇÒÁàÊÕÂËÒÂᡋ¾Íϵ¢¹Ò¹

¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍϢѺ Áմnj ¡ѹ 3 ÃٻẺ¤×Í ãªŒ¢ºÑ Ẻà´ÕÂè Ç, Ẻ¤ÒÊऴ áÅÐẺ´ÒÃÅ§Ô µÑ¹

¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍÏ¢ºÑ Ẻà´ÕÂè Ç ¡ÒâѺâ´ÂÇÔ¸¹Õ àÕé ËÁÒÐÊÁÊíÒËÃѺâËÅ´·ÕÁè ¤Õ ÇÒÁµŒÍ§¡ÒáÃÐáʻҹ¡ÅÒ§ µÑ§é ᵋ 30-200 mA ÍÒ·Ô ÃÕàŏ¡Òí ÅѧµèÒí 仨¹¶Ö§»Ò¹¡ÅÒ§·ÕÁè ¤Õ Ò‹ ¤ÇÒÁµŒÒ¹·Ò¹¢Í§¢´ÅÇ´ÀÒÂã¹ÃÕàŏäÁ‹µÒèí ¡Ç‹Ò 100 Ω, ËÅÍ´ä¿¡íÒÅѧµèÒí áÅÐÁÍàµÍÏ俵碹ҴàÅç¡ ÁÕǧ¨ÃµÑÇÍ‹ҧµÒÁÃÙ»·Õè 4-1 ã¹ÃÙ»·Õè 4-1 ໚¹¡Òõ‹Í·ÃÒ¹«ÔÊàµÍÏࢌҡѺ¢Ò¾Íϵ Data ºÔµ D0 â´ÂÁÕµÇÑ µŒÒ¹·Ò¹ R1 ·íÒ˹ŒÒ·Õ¨è Òí ¡Ñ´¡ÃÐáÊ·Õäè ËÅࢌҢÒàºÊ¢Í§·ÃÒ¹«ÔÊàµÍÏ Q1 «Ö§è ¨Ð·íÒ§Ò¹¡çµÍ‹ àÁ×Íè ºÔµ D0 ÁÕʶҹРÅͨԡ໚¹ “1” àÁ×Íè Q1 ·íÒ§Ò¹ ¡ç¨Ðà¡Ô´¡ÃÐáÊäËż‹Ò¹ RL «Ö§è ໚¹âËÅ´µ‹ÍÍÂÙ·‹ Ò§àÍÒµ¾µØ ·Õ¢è Ò ¤ÍÅàÅç¡àµÍϢͧ Q1 ¡ÃÐáÊâËÅ´ÊÙ§ÊØ´ (ILmax) Áդҋ ෋ҡѺ 12V/300Ω = 40mA ¶Ö§áÁŒÇҋ Q1 àºÍÏ 2N3904 Áդҋ ¡ÃÐáʤÍÅàÅç¡àµÍÏʧ٠ÊØ´¶Ö§ 100 mA ᵋ㹷ҧ»¯ÔºµÑ ¨Ô ÃÔ§äÁ‹¤ÇÃÍ͡Ẻ ãˌ·ÃÒ¹«ÔÊàµÍÏ·íÒ§Ò¹¶Ö§¾Ô¡Ñ´ÊÙ§ÊØ´ ‹ҹ»ÅÍ´ÀÑ¢ͧ·ÃÒ¹«ÔÊàµÍϤÇÃÍÂًäÁ‹à¡Ô¹¤ÃÖè§Ë¹Ö觢ͧ ÍѵÃÒ¡Ò÷¹ä´ŒÊ§Ù ÊØ´ ´ŒÇ¡ÒèѴǧ¨ÃµÒÁÃÙ»·Õè 4-1 ÊÒÁÒö㪌ʭ Ñ ­Ò³¨Ò¡Ç§¨ÃºÑ¿à¿ÍÏÀÒÂã¹ ¾Íϵ¢¹Ò¹¡ÃеعŒ ãˌ·ÃÒ¹«ÔÊàµÍÏ·Òí §Ò¹à¾×Íè ¢ÑºÃÕàŏ¢¹Ò´àÅç¡ä´ŒÍ‹ҧ»ÅÍ´ÀÑ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 37


+12V

+12V

RL 300Ω (min)

R1 1k

IC 40mA (max)

D0 Q1 2N3904

+12V RL 120Ω (min)

RL 300Ω R1 1k D0 Q1 2N3904

Q2 TIP31

IC 600mA (max)

ÃÙ»·Õè 4-1 ¡ÒâѺâËÅ´â´Â㪌·ÃÒ¹«ÔÊàµÍÏ ÃÙ»·Õè 4-2 ¡ÒâѺâËÅ´â´Â㪌·ÃÒ¹«ÔÊàµÍÏ µÑÇà´ÕÂÇ µ‹Í¡Ñ¹áºº¤ÒÊऴ

¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍÏ¢ºÑ Ẻ¤ÒÊऴ à¹×Íè §¨Ò¡¢ŒÍ¨íÒ¡Ñ´¢Í§·ÃÒ¹«ÔÊàµÍÏ¢¹Ò´àÅç¡ ·íÒãˌäÁ‹ÊÒÁÒö¢ÑºâËÅ´·Õµè ͌ §¡ÒáÃÐáÊÊ٧䴌 ¨Ö§µŒÍ§ãªŒ·ÃÒ¹«ÔÊàµÍÏ·ÕèÁÕÍѵÃÒ¡Ò÷¹¡ÃÐáʤÍÅàÅç¡àµÍÏ·ÕèÊÙ§¢Öé¹ÁÒ㪌¢Ñº ᵋ·ÃÒ¹«ÔÊàµÍÏ·Õè ÊÒÁÒö¢ÑºâËÅ´¡íÒÅѧ»Ò¹¡Åҧ仨¹¶Ö§¡íÒÅѧÊÙ§ ¨ÐÁÕ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹ªŒÒ¡Ç‹Ò·ÃÒ¹«ÔÊàµÍÏ ¡íÒÅѧµèÒí ã¹Ãкº¤ÍÁ¾ÔÇàµÍÏ·ÁÕè ¤Õ ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹ÊÙ§àÁ×Íè µŒÍ§¡ÒùíÒÁҢѺâËÅ´¡íÒÅѧ»Ò¹¡ÅÒ§ ¨Ö§µŒÍ§ãªŒ¡ÒâѺẺ¤ÒÊऴ â´Âãˌ¤ÍÁ¾ÔÇàµÍÏ¡Ãе،¹·ÃÒ¹«ÔÊàµÍÏ¡íÒÅѧµèíÒ·íÒ§Ò¹à¾×èÍ仢Ѻ ·ÃÒ¹«ÔÊàµÍÏ¡Òí Åѧ§Ò¹»Ò¹¡ÅÒ§µ‹Íä» ´Ñ§áÊ´§Ç§¨Ãã¹ÃÙ»·Õè 4-2 ¨Ò¡Ç§¨ÃàÁ×èÍ·ÃÒ¹«ÔÊàµÍÏ Q1 ·íÒ§Ò¹´ŒÇ¡Òû‡Í¹Åͨԡ “1” ÍÍ¡·Ò§ºÔµ D0 ¢Í§ ¾Íϵ Data ¨Ðà¡Ô´¡ÃÐáÊäËż‹Ò¹ R2 ä»à¢ŒÒÂѧàºÊ¢Í§·ÃÒ¹«ÔÊàµÍÏ Q2 à¾×Íè ¡ÃеعŒ ãˌ Q2 ·íÒ§Ò¹ à¡Ô´¡ÃÐáÊäËż‹Ò¹âËÅ´ RL ÁÕ¤‹Ò෋ҡѺ 600mA ·íÒãˌÊÒÁÒö¹íÒ仢ѺÁÍàµÍÏ俵çËÃ×Í Êàµç»à»ÍÏÁÍàµÍÏ¢¹Ò´àÅç¡ä´Œ +12V RL 16Ω (min)

¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍÏẺ´ÒÃÅ§Ô µÑ¹ ¢ÑºâËÅ´¡ÃÐáÊÊÙ§

¨Ò¡¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍϵ͋ ¡Ñ¹áºº¤ÒÊR1 ऴà¾×Íè à¾ÔÁè ¤ÇÒÁÊÒÁÒö㹡ÒâѺ¡ÃÐáÊãˌʧ٠1k IC ¢Öé¹ ¹íÒÁÒÊً¡ÒÃ㪌·ÃÒ¹«ÔÊàµÍÏÍաẺ˹Ö觷Õè D0 750mA ºÃèطÃÒ¹«ÔÊàµÍÏ 2 µÑǵ‹Í¡Ñ¹áºº´ÒÏÅÔ§µÑ¹ (max) Q1 ÀÒÂ㵌µÑǶѧà´ÕÂǡѹ ·íÒãˌÊÒÁÒö¢Ñº¡ÃÐáÊ 2N6387 àÍÒµ¾µØ 䴌ʧ٠áÅÐÁÕ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹ÊÙ§´ŒÇ â´Â㪌ÍØ»¡Ã³à¾Õ§µÑÇà´ÕÂÇ Ê‹§¼Åãˌ¢¹Ò´¢Í§ ÃÙ»·Õè 4-3 ¡ÒâѺâËÅ´â´Â㪌·ÃÒ¹«ÔÊàµÍÏ ǧ¨ÃàÅç¡Å§ ´Ñ§áÊ´§Ç§¨ÃµÒÁÃÙ»·Õè 4-3 Ẻ´ÒÃÅ§Ô µÑ¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 38


VL(max) +50V

+5V 9 D6 D5 D4 D3 D2

ULN2003

7

10

6

11

5

12

4

13

3

14

2

15

1

16

Q6

IL(max) 500mA

Q5 Q4 Q3 Q2

¨Ò¡Ç§¨Ã Q1 «Ö§è ໚¹·ÃÒ¹«ÔÊàµÍÏẺ ´ÒÏÅÔ§µÑ¹ÊÒÁÒö¢Ñº¡ÃÐáÊàÍÒµ¾Øµä´ŒÊÙ§¶Ö§ 750mA ´ŒÇ¡Òõ‹ÍࢌҡѺ¢Ò¾Íϵ¢¹Ò¹â´Â ¼‹Ò¹µÑǵŒÒ¹·Ò¹¨íÒ¡Ñ´¡ÃÐáÊà¾Õ§µÑÇà´ÕÂÇáÅÐäÁ‹ µŒÍ§µ‹Í·ÃÒ¹«ÔÊàµÍÏẺ¤ÒÊऴ ·íÒãˌÁ¤Õ ÇÒÁ àÃçÇ㹡Ò÷íÒ§Ò¹ÊÙ§ µÅÍ´¨¹ÊÒÁÒö¢Ñº¡ÃÐáÊ àÍÒµ¾Øµä´ŒÊÙ§¾ÍÊÁ¤ÇÃ

¡ÒÃ㪌äͫբѺ

äÍ«Õ·Õè㪌㹡ÒâѺâËÅ´¡ÃÐáÊÊÙ§ÁÑ¡¨Ð D0 Q1 ÁÕǧ¨Ã·Ò§àÍÒµ¾Øµà»š¹áºº¤ÍÅàÅç¡àµÍÏແ´ ·íÒãˌÊÒÁÒö㪌¡ºÑ áç´Ñ¹ÊÙ§ ÊíÒËÃѺäÍ«Õ¢ºÑ ËÃ×Í 8 äÍ«Õä´ÃàÇÍÏ·ÂÕè ¡ÁÒ͸ԺÒ¤×ÍàºÍÏ ULN2003 ໚¹äÍ«Õ·ÕèÀÒÂ㹺ÃèØÍÔ¹àÇÍÏàµÍÏࡵ 7 µÑÇ ÃÙ»·Õè 4-4 ¡ÒèѴ¢Ò¢Í§äÍ«ÕàºÍÏ ULN2003 ÊíÒËÃѺÃÒÂÅÐàÍÕ´¢Í§ ULN2003 ÁÕ´§Ñ ¹Õé ULN2003 ÁÕÃٻẺ¡ÒèѴ¢ÒáÅÐǧ¨ÃÀÒÂã¹áÊ´§ã¹ÃÙ»·Õè 4-4 ÀÒÂã¹ ULN2003 ºÃèØÍ¹Ô àÇÍÏàµÍÏࡵẺ¤ÍÅàÅç¡àµÍÏແ´ 7 µÑÇ ãªŒ¡ºÑ áç´Ñ¹ä´ŒÊ§Ù ÊØ´ +50V ¡ÃÐáÊàÍÒµ¾µØ ÊÙ§ÊØ´ã¹áµ‹ÅТÒ෋ҡѺ 500mA ·Ñ§é ¹Õ¢é ¹Öé ÍÂÙ¡‹ ºÑ ¤ÇÒÁÊÒÁÒö㹡Òè‹Ò¡ÃÐáʢͧáËŋ§¨‹ÒÂä¿´ŒÇ ¹Í¡¨Ò¡¹Ñ¹é Âѧµ‹Íä´âÍ´»‡Í§¡Ñ¹áç´Ñ¹ÂŒÍ¹¡ÅѺ¨Ò¡ÍØ»¡Ã³àÍÒµ¾µØ ·ÕÁè âÕ ¤Ã§ÊÌҧ໚¹¢´ÅÇ´änj·Õè ·Ø¡¢ÒàÍÒµ¾µØ ·íÒãˌÊÒÁÒö¢ÑºâËÅ´·Õàè »š¹¢´ÅÇ´ ÍÒ·Ô ÃÕàŏ ËÃ×ÍÁÍàµÍÏ俵碹ҴàÅ硶֧¢¹Ò´ ¡Åҧ䴌·¹Ñ ·Õ䴌·¹Ñ ·Õ «Ö§è 㹪ش·´Åͧ NX-2000 â´ÂºÍÏ´ EX-06 «Ö§è ໚¹ºÍÏ´¢ÑºÃÕàŏ¨Ð㪌äÍ«Õ àºÍÏ ULN2003 µÑǹÕàé »š¹ÍØ»¡Ã³ËÅÑ¡ D1

Q1

¡ÒâѺâËÅ´â´Â㪌Íͻⵌ¤»Ñ à»ÅÍÏ 㹧ҹ·Õµè ͌ §ãªŒ¤ÍÁ¾ÔÇàµÍϤǺ¤ØÁâËÅ´·Õµè ͌ §¡ÒÃáç´Ñ¹áÅСÃÐáÊä¿¿‡ÒÊÙ§ÁÒ¡æ ËÃ×Í à»š¹âËÅ´·Ò§ä¿ÊÅѺ Ëҡ㪌¾Íϵ¢¹Ò¹à¢ŒÒ令Ǻ¤ØÁâ´ÂµÃ§ÍҨʋ§¼ÅàÊÕµ‹ÍÃкº¤ÍÁ¾ÔÇàµÍÏ 䴌 à¹×Íè §¨Ò¡·Õâè ËÅ´¡íÒÅѧ俿‡ÒÊÙ§¹Ñ¹é àÁ×Íè àÃÔÁè µŒ¹ËÃ×ÍÊÔ¹é ÊØ´¡Ò÷íÒ§Ò¹¨Ðà¡Ô´¡ÒÃà»ÅÕÂè ¹á»Å§¢Í§ ÃдѺáç´Ñ¹áÅСÃÐáÊä¿¿‡ÒÍ‹ҧÁÒ¡ÁÒ¡áÅÐÃÇ´àÃçÇ «Ö§è ÍÒ¨·íÒÍѹµÃÒµ‹ÍÃкº¤ÍÁ¾ÔÇàµÍÏ䴌 ·íÒãˌ¡ÒâѺâËÅ´àËÅ‹Ò¹Õ¨é §Ö µŒÍ§ÍÒÈÑÂÍØ»¡Ã³¢ºÑ ÍÕ¡áººË¹Ö§è ·ÕÊè ÒÁÒöá¡Ãкº¡ÃÒÇ´·Ò§ä¿¿‡Ò ¢Í§¤ÍÁ¾ÔÇàµÍÏÍÍ¡¨Ò¡âËŴ䴌 ·íÒãˌ¤ÍÁ¾ÔÇàµÍÏ»ÅÍ´ÀѨҡ俿‡Ò¡ÃЪҡËÃ×Í·ÃÒ¹à«Õ¹µ (transient) áÅÐâËÅ´·Õäè ǵ‹ÍÊÑ­­Ò³ÃºÃǹ¡çÊÒÁÒö·íҧҹËÇÁ¡Ñº¤ÍÁ¾ÔÇàµÍÏ䴌 ÍØ»¡Ã³¢ºÑ µÑÇ ¹Õ¤é Í× ÍØ»¡Ã³àª×Íè Á⧷ҧáʧ ËÃ×Í Íͻⵌ¤»Ñ à»ÅÍÏ (opto-coupler) àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 39


(¢) Íͻⵌ¤»Ñ à»ÅÍÏẺ (¡) Íͻⵌ¤»Ñ à»ÅÍÏẺ àÍÒµ¾µØ ໚¹â¿âµŒ´ÒÃÅ§Ô µÑ¹ àÍÒµ¾µØ ໚¹â¿âµŒ·ÃÒ¹«ÔÊàµÍÏ ·ÃÒ¹«ÔÊàµÍÏ

(§) Íͻⵌ¤»Ñ à»ÅÍÏẺ àÍÒµ¾µØ ໚¹â¿âµŒàÍÊ«ÕÍÒÏ

(¤) Íͻⵌ¤»Ñ à»ÅÍÏẺ àÍÒµ¾µØ ໚¹â¿âµŒä´áÍ¡

(¨) Íͻⵌ¤»Ñ à»ÅÍÏẺ àÍÒµ¾µØ ໚¹â¿âµŒÅͨԡࡵ

ÃÙ»·Õè 4-5 ÊÑ­Åѡɳ¢Í§Íͻⵌ¤»Ñ à»ÅÍÏã¹áººµ‹Ò§æ Íͻⵌ¤»Ñ à»ÅÍÏ ໚¹ÍØ»¡Ã³·ÁÕè ¡Õ ÒÃẋ§Ê‹Ç¹ÍÔ¹¾ØµáÅÐàÍÒµ¾µØ ÍÍ¡¨Ò¡¡Ñ¹·Ò§ä¿¿‡ÒÍ‹ҧ ÊÔ¹é àªÔ§ ¡Òö‹Ò·ʹÊÑ­­Ò³ÃÐËNjҧʋǹÍÔ¹¾ØµáÅÐàÍÒµ¾µØ ¨Ð㪌¡ÒÃàª×Íè Á⧷ҧáÊ§à·‹Ò¹Ñ¹é ·íÒãˌ ¡ÃÒÇ´¢Í§ÍÔ¹¾ØµáÅÐàÍÒµ¾µØ äÁ‹àª×Íè Áµ‹Í¡Ñ¹ ´Ñ§¹Ñ¹é ¨Ö§ÊÒÁÒö¡íÒ˹´ãˌ·Ò§ÍÔ¹¾Øµà»š¹Ç§¨Ãä¿¿‡Ò ¡ÃÐáʵç áÅÐǧ¨Ã·Ò§àÍÒµ¾µØ ໚¹Ç§¨Ãä¿¿‡Ò¡ÃÐáÊÊÅѺ䴌 ÀÒ¤ÍÔ¹¾Øµ¢Í§Íͻⵌ¤»Ñ à»ÅÍÏ â´ÂʋǹãË­‹¨Ð໚¹ LED ÍÔ¹¿ÃÒàô ʋǹÀÒ¤àÍÒµ¾µØ ¨Ð໚¹ÍØ»¡Ã³ÊÒÃ¡Ö§è µÑǹíÒ·Õ·è Òí §Ò¹àÁ×Íè 䴌àÁ×Íè ÁÕáʧÁÒµ¡¡Ãзº ઋ¹ â¿âµŒ·ÃÒ¹«ÔÊàµÍÏ, â¿âµŒ ´ÒÏÅÔ§µÑ¹, â¿âµŒÅͨԡ áÅÐâ¿âµŒä´áÍ¡ËÃ×Íâ¿âµŒä·ÃÔÊàµÍÏ ´Ñ§áÊ´§ÊÑ­Åѡɳ¢Í§Íͻⵌ ¤Ñ»à»ÅÍÏẺµ‹Ò§æ ã¹ÃÙ»·Õè 4-5 ¡Ò÷íÒ§Ò¹¨ÐàÃÔèÁµŒ¹´ŒÇ¡Òè‹ÒÂáç´Ñ¹äºáÍʵçãˌᡋ LED ÍÔ¹¿ÃÒàôÀÒÂã¹Íͻⵌ ¤Ñ»à»ÅÍÏ àÁ×èÍ LED ¹íÒ¡ÃÐáÊ ¡ç¨Ð¡íÒà¹Ô´áʧÍÔ¹¿ÃÒàôʋͧ仵¡¡Ãзº·Õè¢ÒàºÊ¢Í§â¿âµŒ ·ÃÒ¹«ÔÊàµÍÏ (㹡óշÕèÀÒ¤àÍÒµ¾Øµà»š¹â¿âµŒ·ÃÒ¹«ÔÊàµÍÏËÃ×Íâ¿âµŒ´ÒÏÅÔ§µÑ¹) ·íÒãˌâ¿âµŒ ·ÃÒ¹«ÔÊàµÍϹÒí ¡ÃÐáÊà¡Ô´¡ÃÐáÊäËż‹Ò¹¨Ò¡¢Ò¤ÍÅàÅç¡àµÍÏÁÒÂѧÍÔÁµÔ àµÍÏ â´ÂáËŋ§¨‹ÒÂáç ´Ñ¹·Ò§àÍÒµ¾µØ ÊÒÁÒö·Õ¨è Ð㪌ᡡѺ·Ò§ÍÔ¹¾Øµä´ŒÍ‹ҧÍÔÊÃÐ äÁ‹µÍŒ §µ‹Í¡ÃÒÇ´¶§Ö ¡Ñ¹ ¨Ö§ÊÒÁÒö µ‹Í¡ÑºáËŋ§¡íÒà¹Ô´áç´Ñ¹ÊÙ§ËÃ×ÍáËŋ§¡íÒà¹Ô´ä¿ÊÅѺ䴌 â´ÂäÁ‹Á¡Õ ÒÃú¡Ç¹ÂŒÍ¹¡ÅѺÁÒ·Ò§ÍÔ¹¾Øµ Í‹ҧà´ç´¢Ò´ áÅÐÂѧÊÒÁÒö»‡Í§¡Ñ¹¡ÒÃú¡Ç¹¨Ò¡ÍÔ¹¾Øµâ´Â¼‹Ò¹·Ò§ÊÒ¡ÃÒÇ´ä´Œ´ÇŒ  àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 40


+12V

+12V

R1 330 D0

R2 10k 1

D1 1N4001

4

Q1 2N3904

(¡)

R2 10k

R1 330 D0

5

IC1 4N25 2

RY1 RELAY12V

1

5

2

4

IC1 4N25 +5V

RY1 RELAY12V

D1 1N4001

Q1 2N3904

(¢)

ÃÙ»·Õè 4-6 (¡) ¡ÒÃ㪌Íͻⵌ¤»Ñ à»ÅÍÏ¢ºÑ âËÅ´´ŒÇÂÅͨԡ]1^ (¢) ¡ÒÃ㪌Íͻⵌ¤»Ñ à»ÅÍÏ¢ºÑ âËÅ´´ŒÇÂÅͨԡ]0^ ã¹ÃÙ»·Õè 4-6 ໚¹Ç§¨ÃµÑÇÍ‹ҧ¢Í§¡ÒùíÒ¾Íϵ¢¹Ò¹¢ÑºÍͻⵌ¤»Ñ à»ÅÍÏà¾×Íè ·íÒ¡ÒâѺâËÅ´ ÃÕàŏ¡Òí Åѧ俿‡ÒÊÙ§ ¨ÐàËç¹ä´ŒÇҋ ¡ÒÃ㪌¤ÍÁ¾ÔÇàµÍÏ¡ÃеعŒ ãˌÍͻⵌ¤»Ñ à»ÅÍÏ·Òí §Ò¹ÊÒÁÒö·íÒ ä´Œ 2 ÃٻẺ¤×Í ãªŒÅͨԡ “1” ´Ñ§áÊ´§ã¹ÃÙ»·Õè 4-6 (¡) áÅÐ㪌Åͨԡ “0” ´Ñ§ã¹ÃÙ»·Õè 4-6 (¢) ¢ŒÍ¤ÇèíÒ㹡ÒÃ㪌¾Íϵ¢¹Ò¹Ã‹ÇÁ¡ÑºÍͻⵌ¤Ñ»à»ÅÍÏ ¨ÐµŒÍ§µ‹ÍµÑǵŒÒ¹·Ò¹à¾×èͨíÒ¡Ñ´ ¡ÃÐáÊä¿¿‡Ò·Õäè Ëż‹Ò¹ LED ·Ò§Ê‹Ç¹ÍÔ¹¾Øµ¢Í§Íͻⵌ¤»Ñ à»ÅÍϴnj ÂàÊÁÍ ¡ÃÐáÊ·Ò§ÍÔ¹¾ØµÊÙ§ ÊØ´äÁ‹¤ÇÃÁÒ¡¡Ç‹Ò 15mA

µÑÇÍ‹ҧ¡ÒÃ㪌§Ò¹ÍØ»¡Ã³ä´ÃàÇÍÏ ¤Çº¤ØÁÃÕàŏâ´Â㪌·ÃÒ¹«ÔÊàµÍÏ ÃÕàŏ໚¹ÍØ»¡Ã³áÁ‹àËÅç¡ä¿¿‡ÒáººË¹Ö§è ·Õãè ªŒã¹¡ÒõѴµ‹Íǧ¨Ã ÁÕÊ­ Ñ ÅѡɳáÊ´§µÒÁÃÙ»·Õè 4-7 àÁ×Íè ¢´ÅÇ´ÃÕàŏÁ¡Õ ÃÐáÊä¿¿‡ÒäËż‹Ò¹ ¨Ðà¡Ô´Ê¹ÒÁáÁ‹àËÅç¡¢Ö¹é ·íÒãˌ˹ŒÒÊÑÁ¼ÑÊâÅËÐ·Õ»è ¡µÔ ແ´Ç§¨Ãᡨҡ¡Ñ¹ÍÂً ¶Ù¡´Ù´µÔ´¡Ñ¹ à¡Ô´¡Òõ‹Íǧ¨Ã¢Ö¹é ʋǹ˹ŒÒÊÑÁ¼ÑÊ·Õ»è ¡µÔµÍ‹ ǧ¨ÃÍÂÙ¡‹ ¨ç Ðá¡ ÍÍ¡¨Ò¡¡Ñ¹ à¡Ô´¡ÒÃແ´Ç§¨Ã¢Ö¹é á·¹ ÃÕàŏâ´Â·ÑÇè 仨ÐÁÕ˹ŒÒÊÑÁ¼ÑÊ·Ò§àÍÒµ¾µØ 2 Ẻ·ÕÁè ¤Õ ÇÒÁà¡ÕÂè Ç¢ŒÍ§¡Ñ¹¤×Í Ë¹ŒÒÊÑÁ¼ÑÊ»¡µÔ µ‹Íǧ¨ÃËÃ×Í NC (Normaly Closed) áÅÐ˹ŒÒÊÑÁ¼ÑÊ»¡µÔແ´Ç§¨ÃËÃ×Í NO (Normally Opened) 㹡óբͧ˹ŒÒÊÑÁ¼ÑÊ»¡µÔµÍ‹ ǧ¨Ã àÁ×Íè ÃÕàŏ·Òí §Ò¹ ˹ŒÒÊÑÁ¼Ñʪش¹Õ¨é Ðᡨҡ¡Ñ¹ ¡ÅÒÂ໚¹à»´ ǧ¨Ã ˹ŒÒÊÑÁ¼Ñʪش¹Õ¨é §Ö 㪌¡µç ͋ àÁ×Íè ÁÕ¨´Ø »ÃÐʧ¤ãˌÃàÕ Å·Òí ¡ÒõѴǧ¨ÃàÁ×Íè ·íÒ§Ò¹ ʋǹ˹ŒÒÊÑÁ¼ÑÊ »¡µÔແ´Ç§¨ÃàÁ×Íè ÃÕàŏ·Òí §Ò¹ ˹ŒÒÊÑÁ¼Ñʪش¹Õ¨é е‹Í¡Ñ¹ ¡ÅÒÂ໚¹»´Ç§¨Ã ´Ñ§¹Ñ¹é ¨Ö§ãªŒË¹ŒÒÊÑÁ¼ÑÊ ªØ´¹Õ¡é µç ͋ àÁ×Íè µŒÍ§¡ÒÃãˌÃàÕ ÅµÍ‹ ǧ¨ÃàÁ×Íè ·íÒ§Ò¹ ´Ñ§¹Ñ¹é ˹ŒÒÊÑÁ¼ÑÊÃÕàŏ 1 ªØ´¨Ö§àÊÁ×͹¡ÑºÊÇÔµª 2 ·Ò§ËÃ×Í DPST (Double Pole Single Throw) àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 41


NC C NO

ÃÙ»·Õè 4-7 ÊÑ­Åѡɳ¢Í§ÃÕàŏ

ÃÕàŏ·ÁÕè ¨Õ Òí ˹‹ÒÂÍÂÙ·‹ ÇÑè ä»ÁÕ¢´ÅÇ´ 1 ªØ´ ã¹¢³Ð ·ÕËè ¹ŒÒÊÑÁ¼ÑÊÁÕµ§Ñé ᵋ 1 ªØ´ (˹ŒÒÊÑÁ¼ÑÊ 1 ªØ´ »ÃСͺ ´ŒÇÂ¢Ò NO : Normally Open ËÃ×Í¢Ò»¡µÔແ´Ç§¨Ã áÅÐ ¢Ò NC : Normally Close ËÃ×Í¢Ò»¡µÔµÍ‹ ǧ¨Ã) ¨íҹǹ 5 ¢Ò 仨¹¶Ö§ 4 ªØ´ 14 ¢Ò ʋǹÍѵÃÒ¡Ò÷¹¡íÒÅѧ俿‡Ò ¢Í§Ë¹ŒÒÊÑÁ¼ÑÊÁÕãˌàÅ×Í¡ÁÒ¡ÁÒ ¶ŒÒ໚¹¢¹Ò´¢Í§áç ´Ñ¹¨ÐÁÕµÑé§áµ‹ 30V ¢Öé¹ä»¨¹¶Ö§ 1,000 V ʋǹ¢¹Ò´ ¢Í§¡ÃÐáÊÁÕµ§Ñé ᵋäÁ‹¡áÕè ÍÁ»Šä»¨¹¶Ö§ËÅÒÂæ ÊÔºáÍÁ»Š

ǧ¨Ã¢ÑºÃÕàŏâ´Â㪌·ÃÒ¹«ÔÊàµÍÏÊÒÁÒö¹íÒǧ¨Ã¢Ñºã¹ÃÙ»·Õè 4-2 ÁÒ㪌䴌 â´Âµ‹Í¢Ò¾Íϵ Data ºÔµ D0 ࢌҡѺ¢ÒàºÊ¢Í§·ÃÒ¹«ÔÊàµÍÏ·ãÕè ªŒ¢ºÑ ÃÕàŏ¼Ò‹ ¹µÑǵŒÒ¹·Ò¹«Ö§è ·íÒ˹ŒÒ·Õ¨è Òí ¡Ñ´¡ÃÐáÊ àºÊãˌᡋ·ÃÒ¹«ÔÊàµÍÏ ¢´ÅÇ´ÃÕàŏ¨Ðµ‹Íࢌҷդè ÍÅàÅç¡àµÍÏ â´ÂÁÕä´âÍ´µ‹Í¤Ã‹ÍÁ¢´ÅÇ´ÃÕàŏ à¾×Íè »‡Í§¡Ñ¹¡ÃÐáÊäËÅŒ͹¡ÅѺ¨Ò¢´ÅÇ´ÃÕàŏÁÒࢌҷÃÒ¹«ÔÊàµÍÏ àÁ×Íè ÃÕàŏËÂØ´·íÒ§Ò¹ àÁ×Íè µŒÍ§¡ÒÃãˌÃàÕ Å·Òí §Ò¹ µŒÍ§à¢Õ¹â»Ãá¡ÃÁʋ§Åͨԡ “1” ÍÍ¡ä»·Ò§¢Ò D0 ·ÃÒ¹«ÔÊàµÍÏ ¨Ð¹íÒ¡ÃÐáÊ ·íÒãˌà¡Ô´¡ÃÐáÊäËż‹Ò¹¢´ÅÇ´ÃÕàŏ ÃÕàŏ¨§Ö ·íÒ§Ò¹ àÁ×Íè µŒÍ§¡ÒäǺ¤ØÁãˌÃàÕ ÅËÂØ´ ·íÒ§Ò¹ ·íÒ䴌â´Â¡ÒÃà¢Õ¹¢ŒÍÁÙÅ “0” ÍÍ¡ä»·Ò§¢Ò D0 ÍÕ¡¤ÃÑ§é ·ÃÒ¹«ÔÊàµÍÏ ¡ç¨ÐËÂØ´¹íÒ¡ÃÐáÊ ·íÒãˌÃÕàŏËÂØ´·íÒ§Ò¹

¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè ¢ÑºÃÕàŏ͋ҧ§‹Ò´ŒÇ Visual BASIC

ÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ´ŒÇ Visual BASIC ãˌ¡ºÑ »ØÁ† Command1 à¾×Íè 㪌㹡ÒáÃеعŒ ãˌ ÃÕàŏ·íҧҹ䴌´Ñ§¹Õé Private Sub Command1_Click() Out &H378, 1 End Sub

ÊíÒËÃѺâ»Ãá¡ÃÁµÑÇÍ‹ҧà¾×Íè ËÂØ´¡Ò÷íÒ§Ò¹¢Í§ÃÕàŏâ´Â㪌»Á؆ Command2 ÁÕ´§Ñ ¹Õé Private Sub Command2_Click() Out &H378, 0 End Sub

¨Ò¡â»Ãá¡ÃÁµÑÇÍ‹ҧ¨ÐàËç¹Ç‹ÒµŒÍ§ãªŒ Command ¶Ö§ 2 µÑÇ㹡ÒäǺ¤ØÁÃÕàŏà¾Õ§µÑÇà´ÕÂÇ áÅСÒÃà¢Õ¹â»Ãá¡ÃÁã¹Åѡɳйշé Òí ãˌºµÔ ·Õäè Á‹à¡ÕÂè Ç¢ŒÍ§ÁÕ¡ÒÃà»ÅÕÂè ¹á»Å§ä»´ŒÇ «Ö§è ºÒ§¤Ãѧé ã¹ §Ò¹¤Çº¤ØÁäÁ‹µŒÍ§¡ÒÃãˌºÔµ·ÕèäÁ‹à¡ÕèÂÇ¢ŒÍ§àËŋҹÑé¹à¡Ô´¡ÒÃà»ÅÕè¹á»Å§ ¼ÙŒãªŒ§Ò¹ÊÒÁÒÃ¶á¡Œä¢ â»Ãá¡ÃÁãˌÁ¤Õ ÇÒÁ¡ÃЪѺ¢Ö¹é â´Â㪌¡ÒÃ͋ҹ¤‹Ò¡ÅѺáÅÐ㪌¤Òí Êѧè XOR ࢌÒÁÒª‹ÇÂ䴌´§Ñ ¹Õé Private Sub Command1_Click() Out &H378, Inp(&H378) Xor &H1 End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 42


¨Ò¡â»Ãá¡ÃÁµÑ Ç Í‹ Ò §¢Œ Ò §µŒ ¹ ¹Õé ¨Ð㪌 Command1 à¾Õ  §µÑ Ç à´Õ  Ç㹡ÒäǺ¤Ø Á ¡Òà ·íÒ§Ò¹¢Í§ÃÕàŏ â´Â¨Ð·íÒ¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙÅà´ÔÁ·Õàè ÍÒµ¾µØ ¢Í§¾Íϵ Data ÍÍ¡ÁÒ¡‹Í¹ ¨Ò¡¹Ñ¹é 㪌 ¤íÒÊѧè XOR 㹡ÒÃÊÅѺºÔµ â´Â¨Ð·íÒ¡ÒÃÊÅѺ੾ÒкԵ D0 à¾Õ§ºÔµà´ÕÂÇ෋ҹѹé

¤Çº¤ØÁÃÕàŏâ´Â㪌 ULN2003 ÊÒÁÒö·íÒ䴌Í‹ҧ§‹ÒÂæ ´Ñ§áÊ´§Ç§¨Ãã¹ÃÙ»·Õè 4-8 µ‹Í¢Ò¾Íϵ Data ºÔµã´ºÔµË¹Ö§è ÁÒà¢ŒÒ ·Õ¢è ÒÍÔ¹¾Øµ¢Í§ ULN2003 «Ö§è ¨Ò¡Ç§¨Ãµ‹Í¢Ò D0 ʋǹ·Õàè ÍÒµ¾µØ ¢Í§ ULN2003 ãˌµÍ‹ ࢌҡѺ¢Ò ¢´ÅÇ´¢Í§ÃÕàŏ¢Òã´¢Ò˹֧è ʋǹÍÕ¡¢Ò·Õàè ËÅ×ÍãˌµÍ‹ ¡Ñºä¿àÅÕÂé §¢´ÅÇ´ÃÕàŏ à˵ؼŷյè ͌ §µ‹ÍẺ ¹Õàé ¹×Íè §¨Ò¡ËÒ¡µŒÍ§¡ÒâѺÃÕàŏãˌ·Òí §Ò¹â´ÂäÁ‹ÊÌҧÀÒÃÐãˌᡋǧ¨Ã¨‹ÒÂä¿àÅÕÂé §¢Í§¾Íϵ¢¹Ò¹¤Çà µ‹ÍáËŋ§¨‹ÒÂä¿ÊíÒËÃѺÃÕàŏᡵ‹Ò§ËÒ¡ àÁ×èÍ໚¹àª‹¹¹Õé¨Ö§µŒÍ§¡íÒ˹´ãˌ ULN2003 ·íÒ¡Òà ¨‹Ò¡ÃÐáÊã¹ÅѡɳСÃÐáÊ«Ô§¡ (sink current) ¡Íû¡ÑºÀÒÂã¹ ULN2003 ໚¹ÍÔ¹àÇÍÏàµÍÏ ËÃ×͹͵ࡵ àÁ×Íè µŒÍ§¡ÒÃÊѧè ãˌÃàÕ Å·Òí §Ò¹µŒÍ§Ê‹§¢ŒÍÁÙÅ “1” ÁÒ·ÕÍè ¹Ô ¾Øµ¢Í§ ULN2003 ¡ç¨Ðà¡Ô´ ¡ÒáÅѺÅͨԡ໚¹ “0” ·íÒãˌà¡Ô´¡Òäú§¨Ã ÁÕ¡ÃÐáÊä¿¿ÒäËŨҡáËŋ§¨‹ÒÂ俢ͧÃÕàŏ¼Ò‹ ¹¢´ ÅÇ´ÃÕàŏÁҤúǧ¨Ã·Õ¢è ÒàÍÒµ¾µØ ¢Í§ ULN2003 «Ö§è ã¹¢³Ð¹Õàé »š¹Åͨԡ “0” ÊÒÁÒöà·Õº໚¹ ¡ÃÒÇ´ä´Œ àÁ×Íè à¡Ô´¡ÃÐáÊä¿¿‡ÒäËż‹Ò¹¢´ÅÇ´ÃÕàŏ䴌 ÃÕàŏ¡¨ç зíÒ§Ò¹

+V

RY1 RELAY 12V

NO C NC

9 D0

1 2

D0

Q0

D1

Q1

3 D2 4 D3 5 D4 6 D5 7 D6 8

Q2

16 15 14 13

Q3 12 Q4 11 Q5 10 Q6 IC1 ULN2003

ÃÙ»·Õè 4-8 ǧ¨Ã¢ÑºÃÕàŏ 12V Í‹ҧ§‹ÒÂâ´Â㪌äÍ«Õ¢ºÑ àºÍÏ ULN2003 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 43


EX-06 7 Channel Relay board

+V

RY601 RELAY 12V

K602 RELAY OUT #1

K601

NO C NC

DATA BUS (UIC-10)

+5V D0 D2 D4 D6

JP601

D1 D3 D5 D7 JP607

9 1 2 3 4 5

D0 D1

D2 D3 D4 6 D5 7 D6 8

16 Q0 15 Q1 14 Q2 13 Q3 12 Q4 11 Q5 10 Q6

RY602-RY607 with K602-K608

IC601 ULN2003

EX-06 ºÍÏ´¢ÑºÃÕàŏ 7 ª‹Í§ l ¢ÑºÃÕàŏ¢¹Ò´ 12V ¾Ô¡´ Ñ Ë¹ŒÒÊÑÁ¼ÑÊ 220Vac 5A l 㪌áËŋ§¨‹ÒÂä¿ +12V 1A ÊíÒËÃѺÃÕàŏᡠµ‹Ò§ËÒ¡ l àÅ×Í¡¢ÑºÃÕàŏ䴌 7 µÑÇ´ŒÇ¡ÒÃ㪌¨Á Ñê à»ÍÏ l ¤Í¹à¹ç¡àµÍÏ DATA BUS ÊíÒËÃѺàª×Í è Áµ‹Í ¡Ñº P-Board áÅÐS-Board

ÃÙ»·Õè 4-9 ǧ¨ÃÊÁºÙó¢Í§ EX-06 ºÍÏ´ÃÕàŏ 7 ª‹Í§ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 44


EX-06 ºÍÏ´¢ÑºÃÕàŏ 7 ª‹Í§ ÊíÒËÃѺ㹪ش·´Åͧ NX-2000 ÁÕºÍÏ´µ‹Í¾‹Ç§ÊíÒËÃѺ·´Åͧ¡ÒâѺÃÕàŏÍÂÙ¤‹ Í× EX-06 ºÍÏ´¢ÑºÃÕàŏ 7 ª‹Í§ â´Âº¹ºÍÏ´¨ÐÁÕÃàÕ Åãˌ㪌§Ò¹ÁÒ¡¶Ö§ 7 µÑÇ ãªŒäÍ«Õ ULN2003 㹡ÒâѺ â´Âǧ¨Ã¢Í§ºÍÏ´ EX-06 áÊ´§ã¹ÃÙ»·Õè 4-9 ·íÒ˹ŒÒ·Õàè »š¹Ç§¨Ã¢Ñº â´Â¶ŒÒ¼Ù㌠ªŒ§Ò¹µŒÍ§¡ÒÃ㪌§Ò¹ ÃÕàŏµÇÑ ã´¡çãˌ㪌¨ÁÑê à»Íϵ͋ ã¹µíÒá˹‹§¹Ñ¹é ¡ÒäǺ¤ØÁÃÕàŏãˌ·Òí §Ò¹ÊÒÁÒö㪌¾Íϵ Data ËÃ×Í ¾Íϵ Control ¡ç䴌 ¶ŒÒ㪌§Ò¹¾Íϵ Data ¢Ò·Õãè ªŒã¹¡ÒäǺ¤ØÁ¨Ð㪌¢ Ò D0-D6 à¹×Íè §¨Ò¡Ç‹ÒÁÕÃàÕ Å ·Ñ§é ËÁ´ 7 µÑÇ ÊíÒËÃѺ¾Íϵ Control ·ÕÁè ¢Õ ÒàÍÒµ¾µØ 4 ¢Ò¡çÊÒÁÒö¢ÑºÃÕàŏ䴌à¾Õ§ 4 µÑÇà·‹Ò¹Ñ¹é ¤×Í ÃÕàŏµÇÑ ·Õè 1-4 â´ÂµŒÍ§¾Ô¨ÒóҶ֧¡ÒáÅѺʶҹÐÅͨԡ¢Í§ºÔµµ‹Ò§æ ÀÒÂã¹¾Íϵ Control ´ŒÇ ËÑÇ㨢ͧºÍÏ´¹Õ¤é Í× ULN2003 «Ö§è ໚¹äÍ«ÕÍ¹Ô àÇÍÏàµÍÏä´ÃàÇÍÏ 7 µÑÇ ¢ÒÍÔ¹¾Øµ·Ñ§é ËÁ´ µ‹Í¡Ñº¨ÑêÁà»ÍÏ JP601-JP607 à¾×èÍ㪌㹡ÒÃàÅ×͡NjҵŒÍ§¡ÒäǺ¤ØÁÃÕàŏµÑÇã´ â´Â JP601 㪌 àÅ×Í¡µÔ´µ‹Í¡ÑºÃÕàŏ RY601 ËÃ×ÍÃÕàŏµÇÑ ·Õè 1 àÃÕ§ÅíҴѺ仨¹¶Ö§ JP607 㣌àÅ×Í¡¡ÒõԴµ‹Í¡Ñº RY607 ËÃ×ÍÃÕàŏµÇÑ ·Õè 7 ÍÕ¡´ŒÒ¹Ë¹Ö§è ¢Í§¨ÑÁê à»ÍϨе‹ÍࢌҡѺ¤Í¹à¹ç¡àµÍÏ DATA BUS à¾×Íè àª×Íè Áµ‹Í¡Ñº P-Board à¾×Íè ·íÒ¡ÒäǺ¤ØÁµ‹Íä»

ÊÃØ» µÑÇÍ‹ҧ¡ÒùíÒ¾Íϵ¢¹Ò¹ÁҤǺ¤ØÁ¡Ò÷íÒ§Ò¹¢Í§ÃÕàŏ¹Õé ª‹ÇÂãˌ¼ÙŒãªŒ§Ò¹ÊÒÁÒö¹íÒä» »ÃÐÂØ¡µãªŒ¤ÍÁ¾ÔÇàµÍϤǺ¤ØÁÍØ»¡Ã³ä¿¿‡Ò¡ÃÐáÊÊÅѺµ‹Ò§æ 䴌â´Â§‹Ò ¡µÑÇÍ‹ҧ ÊÒÁÒö¹íÒ ËÅÑ¡¡ÒùÕÊé ÌҧÃкººŒÒ¹Íѵâ¹ÁѵÁÔ ¡Õ Òû´à»´Ãкºä¿¿‡ÒÀÒÂ㹺ŒÒ¹àͧµÒÁàÇÅÒ·Õ¡è Òí ˹´ ໚¹ µŒ¹ â´ÂÍÒ¨ÁÕ¡ÒÃà¾ÔÁè àµÔÁÍØ»¡Ã³ÎÒÏ´áÇÃÍ¡Õ à¾Õ§àÅ硹ŒÍÂ෋ҹѹé

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 45


¡Ò÷´Åͧ·Õè 4 ¢ÑºÃÕàŏ´ÇŒ ºÍÏ´ EX-06 à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-06 ºÍÏ´¢ÑºÃÕàŏ 7 ª‹Í§ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. áËŋ§¨‹ÒÂ俵ç +12V 1A ÊíÒËÃѺºÍÏ´ EX-06 5. ÊÒÂàª×Íè Áµ‹Í IDC-10 1 àʌ¹

ËÅÑ¡¡Òà ÇÔ¸Õ¡Ò÷Õ觋Ò·ÕèÊش㹡ÒâѺ¡ç¤×Í¡ÒÃ㪌¾Íϵ Data à¹×èͧ¨Ò¡Ç‹ÒäÁ‹µŒÍ§ÁÕ¡ÒáÅÑºÊ¶Ò¹Ð ã´ æ ¡ÒäǺ¤ØÁãˌ·Òí §Ò¹¹Ñ¹é ¡ç¨ÐàËÁ×͹¡Ñº¡ÒâѺ´ŒÇ·ÃÒ¹«ÔÊàµÍÏ ¤×Í»‡Í¹Åͨԡ “1” ÍÍ¡ä» ·ÃÒ¹«ÔÊàµÍϨзíÒ§Ò¹áÅе‹ÍÃÕàŏŧ¡ÃÒÇ´ ·íÒãˌÃàÕ Å·Òí §Ò¹ ¡ÒâѺÃÕàŏËÅÒÂæ µÑÇ ãˌ·Òí §Ò¹¹Ñ¹é ¨Ð㪌»Á؆ Command ෋ҡѺ¨íҹǹÃÕàŏáÅÐà¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ Command µ‹Ò§ æ ´Ñ§¹Õé Private Sub Command1_Click() Out &H378,Inp(&H378) Xor &H1 End Sub Private Sub Command2_Click() Out &H378,Inp(&H378) Xor &H2 End Sub Private Sub Command3_Click() Out &H378,Inp(&H378) Xor &H4 End Sub Private Sub Command4_Click() Out &H378,Inp(&H378) Xor &H8 End Sub Private Sub Command5_Click() Out &H378,Inp(&H378) Xor &H10 End Sub Private Sub Command6_Click() Out &H378,Inp(&H378) Xor &H20 End Sub Private Sub Command7_Click() Out &H378,Inp(&H378) Xor &H40 End Sub

¨ÐàËç¹Ç‹Ò¡Ò÷íÒ§Ò¹¢Í§â»Ãá¡ÃÁ‹Íµ‹Ò§ æ àËŋҹշé Òí §Ò¹àËÁ×͹¡Ñ¹ ᵡµ‹Ò§¡Ñ¹·Õºè µÔ ·Õ¨è Ð ·íÒ¡ÒÃÊÅѺ¤‹Ò෋ҹÑé¹ â´Â¼ÙŒãªŒ§Ò¹ÊÒÁÒö´Ñ´á»Å§â»Ãá¡ÃÁãˌÊÑé¹Å§ä´Œâ´Â¡ÒÃ㪌 Array ËÃ×Í Index ÁÒª‹Ç ´Ñ§áÊ´§ã¹¡Ò÷´Åͧ¹Õé àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 46


ÃÙ»·Õè P4-1 áÊ´§Ë¹ŒÒµ‹Ò§Êͺ¶ÒÁ¡ÒÃÊÌҧ ARRAY ¢Í§ Command1 ·Ñº¢Í§à´ÔÁ

¡Ò÷´Åͧ 4.1 ·íÒ¡ÒÃź»ØÁ† Command ·Ñ§é ËÁ´·Ô§é áŌÇÊÌҧ»ØÁ† Command ¢Ö¹é ÁÒãËÁ‹ µÑ§é ª×Íè Ç‹Ò Com-mand1 ¨Ò¡¹Ñ¹é 㪌àÁÒʏàÅ×Í¡·Õè Command1 áŌÇ㪌¤Òí Êѧè Edit -> Copy à¾×Íè ¤Ñ´ÅÍ¡ Command1 ä»änj·¤Õè ÅÔ»ºÍÏ´ ¨Ò¡¹Ñ¹é 㪌¤Òí Êѧè Edit -> Paste à¾×Íè ¤Ñ´ÅÍ¡ Command1 ¨Ò¡¤ÅÔ»ºÍÏ´ÁÒÇÒ§º¹ Form1 4.2 â»Ãá¡ÃÁ¨Ðᨌ§Ç‹Òª×Íè Command1 ໚¹ª×Íè «éÒí µŒÍ§ ¡ÒèШÐÊÌҧ ARRAY ¢Í§ Command1 ËÃ×ÍäÁ‹ ãˌ µÍº YES à¾×èÍÊÌҧ ARRAY ´Ñ§áÊ´§ã¹ÃÙ»·Õè P4-1 ¨Ò¡¹Ñ¹é 㪌¤Òí Êѧè Paste «éÒí à¾×Íè ÊÌҧ ARRAY ãˌ¤Ãº 7 »Ø†Á 4.3 ¨ÐàËç¹Ç‹Ò»ØÁ† ·Ñ§é ËÁ´¨ÐÁÕªÍ×è ໚¹ COMMAND1 ᵋ ãËŒÊ§Ñ à¡µ·ÕÊè Nj ¹ PROPERTY ¢Í§ COMMAND ᵋÅÐ µÑ Ç ¨ÐàËç ¹ Nj Ò COMMAND1 ᵋ Å ÐµÑ Ç ¨ÐÁÕ Ç §àÅç º (INDEX) ÍÂً ´Œ Ò ¹ËÅÑ § ã¹Ç§àÅç º ¢Í§ COMMAND1 COMMAND1 ᵋÅеÑǨÐÁÕ¤‹Ò INDEX ·ÕèäÁ‹à·‹Ò¡Ñ¹´Ñ§ áÊ´§ã¹ÃÙ»·Õè P4-2 â´Â COMMAND1 µÑÇáá¨ÐÁÕ INDEX ໚¹ 0 ¶Ñ´ÁÒ໚¹ 1 仨¹¶Ö§µÑÇÊØ´·ŒÒÂ໚¹ 6 àÁ×Íè ´ÑºàºÔéŤÅÔé¡·Õè COMMAND1 µÑÇã´µÑÇ˹Öè§à¾×èÍà¢Õ¹ â»Ãá¡ÃÁ¨Ð໚¹¡ÒÃà¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ COMMAND1 ·Ñé§ËÁ´ 4.4 ·ÕËè ÇÑ ¢Í§â»Ãá¡ÃÁ‹Í¨Ð͌ҧ¶Ö§µÑÇá»Ã INDEX àÍÒ änj´ŒÇÂà¾×èÍ¡íÒ˹´Ç‹ÒµŒÍ§¡ÒÃ͌ҧ¶Ö§ COMMAND1 µÑÇã´ â´Â¼ÙŒãªŒ§Ò¹ÊÒÁÒö¹íÒàÍҤسÊÁºÑµÔ¹ÕéÁÒ㪌㹠¡ÒÃà¢Õ¹â»Ãá¡ÃÁ䴌´§Ñ ¹Õé ÃÙ»·Õè P4-2 áÊ´§¤‹Ò INDEX ¢Í§ COMMAND1

Private Sub Command1_Click(Index As Integer) Out &H378, Inp(&H378) Xor 2 ^ Index End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 47


4.5 ¨ÐàËç¹Ç‹Ò¡ÒäǺ¤ØÁÃÕàŏ·§Ñé 7 µÑǹѹé 㪌¤Òí Êѧè à¾Õ§ ºÃ÷Ѵà´ÕÂÇ෋ҹѹé â´Â 2^Index ¹Ñ¹é ËÁÒ¶֧ºÔµ·Õµè ͌ § ¡ÒèРON ËÃ×Í OFF â´Â·Õè 2^Index ¨Ðãˌ¤Ò‹ ¡íÒÅѧ¢Í§ ᵋÅкԵ¢Í§¾Íϵ Data «Ö觶ŒÒÁÕ¡Òᴻ؆Á Com-mand1 ã¹µíÒá˹‹§·ÕÁè ¤Õ Ò‹ Index ෋ҡѺ 0 ¤‹Ò 2^Index ¨ÐÁդҋ ෋ҡѺ 1 ËÁÒ¤ÇÒÁNjÒÁÕ¡ÒáÅÑºÊ¶Ò¹Ð·Õºè µÔ 0 ¶ŒÒÁÕ¡Òá´»ØÁ† Command1 ã¹µíÒá˹‹§·ÕÁè ¤Õ Ò‹ Index ෋ҡѺ 6 ¤‹Ò 2^Index ¨ÐÁÕ෋ҡѺ 40 (°Ò¹ÊԺˡ) «Ö§è ¡ç¨ÐËÁÒ¶֧¡ÒáÅÑºÊ¶Ò¹Ð·Õºè µÔ D6 ¹Ñ¹è àͧ 4.6 㹡óշµÕè ͌ §¡Ò÷ÃҺʶҹСÒ÷íÒ§Ò¹¢Í§ÃÕàŏ ÍÒ¨¨ÐãªŒÇ¸Ô àÕ »ÅÕÂè ¹¤‹Ò Caption ¢Í§ Command1 ¡ç䴌 â´Âãˌà¢Õ¹â»Ãá¡ÃÁà¾ÔÁè àµÔÁ´Ñ§¹Õé

ÃÙ»·Õè P4-3 àÁ×Íè ¡íÒ˹´ Caption ¢Í§ COMMAND1 ¤Ãº·Ñ§é 7 »ØÁ†

Private Sub Command1_Click(Index As Integer) Out &H378, Inp(&H378) Xor 2 ^ Index If (Inp(&H378) And 2 ^ Index) = 2 ^ Index Then Command1(Index).Caption = “ON” Else Command1(Index).Caption = “OFF” End If End Sub

4.7 ¡ÒÃ㪌¤Òí Êѧè IF THEN à¾×Íè µÃǨÊͺ¤‹Ò¢Í§Åͨԡ¢Í§ºÔµáµ‹ÅкԵNjÒÁդҋ ໚¹ “1” ËÃ×ÍäÁ‹ ¶ŒÒÁÕ¤‹Ò໚¹ “1” ¡çãˌ¢ŒÍ¤ÇÒÁ·Õè»Ø†Á Command1 áÊ´§¤íÒÇ‹Ò ON ᵋ¶ŒÒºÔµ¹Ñé¹ÁÕÅͨԡ໚¹ “0” ¢ŒÍ¤ÇÒÁ·Õè Command1 ã¹µíÒá˹‹§·Õ¡è Òí ˹´¨ÐáÊ´§¤íÒÇ‹Ò OFF 4.8 ¹Í¡¨Ò¡¹Õ¡é ͋ ¹¡ÒÃÃѹâ»Ãá¡ÃÁãˌ·Òí §Ò¹ µŒÍ§¡íÒ˹´¤‹ÒÃÕàŏãˌ OFF ·Ñ§é ËÁ´¡‹Í¹â´Â¡Òà ÃкؤÒí Êѧè ŧ㹠Form1 ´Ñ§¹Õé Private Sub Form_Load() Out &H378, 0 End Sub

4.9 ·Õè Caption ¢Í§ Command1 ·Ø¡ æ µÑÇãˌ¡Òí ˹´à»š¹ OFF àÍÒänjà¾×Íè NjÒã¹¢³ÐàÃÔÁè µŒ¹â»Ãá¡ÃÁ ¨Ð䴌໚¹ OFF àËÁ×͹¡Ñ¹·Ñ§é ËÁ´ ´Ñ§áÊ´§ã¹ÃÙ»·Õè P4-3 ÃÒÂÅÐàÍÕ´·Ñ§é ËÁ´¢Í§â»Ãá¡ÃÁ·´Åͧ¹ÕÊé ÒÁÒö´Ù䴌¨Ò¡ä¿Å LAB04.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 48


º··Õè 5 ¡ÒâѺÊàµç»à»ÍÏÁÍàµÍÏ ´ŒÇ¾Íϵ¢¹Ò¹ Êàµç»à»ÍÏÁÍàµÍÏ (stepper motor) ໚¹ÁÍàµÍÏ·ÕèÁÕÅѡɳСÒ÷íҧҹᵡµ‹Ò§¨Ò¡ ÁÍàµÍÏ·ÇÑè ä» à¾ÃÒШеŒÍ§»‡Í¹ÊÑ­­Ò³à»š¹¾ÑÅʏãˌᡋ¢´ÅÇ´¢Í§ÁÍàµÍÏ໚¹¨Ñ§ËÇÐÍ‹ҧàËÁÒÐ ÊÁ áÅСÒÃËÁع¢Í§ÁÍàµÍϪ¹Ô´¹Õ¨é ÐËÁع໚¹¨Ñ§ËÇеÒÁ¾ÑÅʏ·»Õè ͇ ¹à¢ŒÒÁÒ äÁ‹ËÁعµ‹Íà¹×Íè §àËÁ×͹ ¡ÑºÁÍàµÍϸÃÃÁ´Ò ·íÒãˌ¼¤ÙŒ Ǻ¤ØÁÊÒÁÒöàÅ×Í¡µíÒá˹‹§·Õµè ͌ §¡ÒÃãˌÁÍàµÍÏËÂØ´ËÁع䴌 ¨Ñ§ËÇÐ ¡ÒÃËÁع¢Í§Êàµç»à»ÍÏÁÍàµÍÏàÃÕÂ¡Ç‹Ò Êàµç» (step) ¤ÇÒÁÅÐàÍÕ´¢Í§ÁÍàµÍÏ¡Òí ˹´à»š¹Í§ÈÒ ·ÕËè Áعä»ã¹Ë¹Ö§è Êàµç» ËÒ¡ÁÍàµÍÏÁ¨Õ Òí ¹Ç¹Í§ÈÒµ‹ÍÊàµç»ÁÒ¡ ËÁÒ¤ÇÒÁÇ‹Ò ÁÍàµÍϵÇÑ ¹ÕÁé ¤Õ ÇÒÁ ÅÐàÍÕ´¢Í§¡ÒÃËÁعµèÒí ¡µÑÇÍ‹ҧ ¡ÒÃËÁع¤Ãº 1 Ãͺ෋ҡѺ 360 ͧÈÒ ËÒ¡ÁÍàµÍÏÁÊÕ àµç» ¡ÒÃËÁع෋ҡѺ 7.5 ͧÈÒµ‹ÍÊàµç» ÁÍàµÍϵÇÑ ¹ÕÁé ¤Õ ÇÒÁÅÐàÍÕ´¢Í§¡ÒÃËÁع෋ҡѺ 48 µíÒá˹‹§ ᵋ¶ÒŒ ËÒ¡ÁÕÊàµç»¡ÒÃËÁع¡Ñº 1.8 ͧÈÒµ‹ÍÊàµç» ¤ÇÒÁÅÐàÍÕ´¢Í§¡ÒÃËÁع෋ҡѺ 200 ¨ÐàËç¹ ä´ŒÇҋ ÁÍàµÍϵÇÑ ËÅѧÁÕ¤ÇÒÁÅÐàÍÕ´ÊÙ§¡Ç‹ÒµÑÇááÁÒ¡ ·íÒãˌ¹Òí ÁÒ㪌㹧ҹ·Õµè ͌ §¡ÒáíÒ˹´µíÒá˹‹§ 䴌´¡Õ Ç‹Ò áÁ‹¹ÂíÒ¡Ç‹Ò ¼¹Ç¡à¢ŒÒ¡ÑºÇ§¨Ã¢Ñºáºº¤ÃÖ§è Êàµç» («Ö§è ¨Ð¡Å‹ÒǶ֧µ‹Íä») ¤ÇÒÁÅÐàÍÕ´¢Í§ ¡ÒÃËÁع¨Ðà¾ÔÁè ¢Ö¹é ÍÕ¡ 2 à·‹Ò ·íÒãˌÁ¤Õ ÇÒÁÅÐàÍÕ´¢Í§¡ÒÃËÁع¡ÅÒÂ໚¹ 400 µíÒá˹‹§ ¢¹Ò´¢Í§Êàµç»à»ÍÏÁÍàµÍÏ·ÁÕè ¡Õ ÒüÅÔµáÅШíÒ˹‹ÒÂã¹·ŒÍ§µÅÒ´ ÁÕµ§Ñé ᵋ¢¹Ò´áç´Ñ¹µèÒí 3 V 仨¹¶Ö§ 24 V ʋǹ¢¹Ò´¢Í§¡ÃÐáÊÁÕµ§Ñé ᵋäÁ‹¡ÊÕè ºÔ ÁÔÅÅÔáÍÁ»ŠÍ¹Ñ ໚¹Êàµç»à»ÍÏÁÍàµÍϵÇÑ àÅç¡ä»¨¹¶Ö§à»š¹ÊÔºáÍÁ»Š «Ö§è ṋ¹Í¹¢¹Ò´¢Í§ÁÍàµÍÏÂ͋ ÁµŒÍ§ãË­‹âµ¢Ö¹é µÒÁÅíҴѺ ÃÒ¤ÒÍÂÙ㋠¹ ËÅѡ໚¹ÃŒÍºҷ¢Ö¹é ä»ÊíÒËÃѺ¢Í§ãËÁ‹

Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹Ôâ¾Å‹ÒÏ Êàµç»à»ÍÏÁÍàµÍÏ䴌ÃѺ¡ÒþѲ¹ÒÁÒÍ‹ҧµ‹Íà¹×èͧ ¨¹ã¹»˜¨¨ØºÑ¹Êàµç»à»ÍÏÁÍàµÍÏ·Õè ¹ÔÂÁ㪌Í‹ҧá¾Ã‹ËÅÒÂÁÒ¡·ÕèÊØ´áÅÐËÒ䴌§‹Ò¤×Í Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ (uni-polar stepper motor) ÁÕÅ¡Ñ É³Ð¡Òþѹ¢´ÅÇ´¢Í§ÁÍàµÍÏáÊ´§ã¹ÃÙ»·Õè 5-1 Êàµç»à»ÍÏÁÍàµÍÏẺ¹ÕÁé ¡Õ Òþѹ¢´ÅÇ´ 2 ¢´º¹áµ‹ÅТÑÇé áÁ‹àËÅ硢ͧÊàµàµÍÏ ᵋÅТ´ ẋ§à»š¹ 2 à¿Ê ÃÇÁÁÍàµÍÏ·§Ñé µÑǨÐÁÕ 4 à¿Ê¤×Í à¿Ê 1,2,3 áÅÐ 4 ÁÕ¡Òõ‹ÍÊÒÂÍÍ¡ÁÒ¨Ò¡¢´ ÅǴᵋÅТ´à¾×Íè ¨‹ÒÂä¿àÅÕÂé § ·íÒãˌÊàµç»à»ÍÏÁÍàµÍÏẺ¹ÕÁé ·Õ §Ñé Ẻ 5 ÊÒÂáÅÐ 6 ÊÒ ¶ŒÒ໚¹ Ẻ 5 ÊÒ ¨Ð໚¹¡ÒùíÒÊÒÂä¿àÅÕÂé §¢Í§¢´ÅÇ´·Ñ§é ÊͧÁÒµ‹ÍÃÇÁ¡Ñ¹à»š¹ÊÒÂà´ÕÂÇ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 49


P1

¡ÒáÃеعŒ à¾×Íè ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ

P1

ÊÒÁÒö·íÒ䴌â´Â¡Òè‹Ò¾Åѧ§Ò¹ä¿¿‡Ò ä»Âѧ¢´ÅǴᵋÅТ´º¹á¡¹áÁ‹àËÅ硤§·Õè «Öè§ +V µŒÍ§»‡Í¹à»š¹ÅíҴѺµÒÁÃٻẺ·Õè¶Ù¡µŒÍ§ â´Â +V P3 P4 P3 P4 ÊÒÁÒöẋ§ä´Œ 3 ÃٻẺ¤×Í ¿ÙÅÊàµç» 1 à¿Ê Ẻ 5 ÊÒ 4 à¿Ê Ẻ 6 ÊÒ 4 à¿Ê (full-step 1 phase), ¿ÙÅÊàµç» 2 à¿Ê (full-step ÃÙ»·Õè 5-1 â¤Ã§ÊÌҧ¾×¹é °Ò¹¢Í§Êàµç»à»ÍÏ 2 phase) áÅÐÎÒŏ¿Êàµç» (half step) ÁÍàµÍϪ¹Ô´ÂÙ¹âÔ ¾Å‹ÒÏ·§Ñé Ẻ 5 áÅÐ 6 ÊÒ Ẻ¿ÙÅÊàµç» 1 à¿Ê ໚¹¡ÒáÃе،¹ +V

P2

P2

·Õ§è ҋ ·ÕÊè ´Ø â´Â¡ÃеعŒ ¢´ÅÇ´·ÕÅТ´äŋàÃÕ§¡Ñ¹ ä» àª‹¹ àÃÔÁè µŒ¹·Õ¢è ´·Õè 1, 2, 3, 4 áŌÇǹ¡ÅѺÁÒ ¢´·Õè 1 ËÃ×ÍàÃÔÁè ·Õ¢è ´·Õè 1 áŌÇŒ͹ä»Âѧ¢´·Õè 4, 3, 2 áŌǡÅѺÁÒÂѧ¢´·Õè 1 ÍÕ¡¤ÃÑ§é ·íÒãˌ·ÈÔ ·Ò§ ¡ÒÃËÁعÊǹ¡Ñ¹ 㹡ÒáÃеعŒ Ẻ¹Õ¨é §Ö ÁÕ¢´ÅÇ´ µÒÃÒ§·Õè 5-1 áÊ´§ÃٻẺ¡ÒâѺÊàµç»à»ÍÏ à¾Õ§¢´à´ÕÂÇã¹àÇÅÒ˹Ö觷Õè¶Ù¡¡Ãе،¹à·‹Ò¹Ñé¹ ÁÍàµÍÏẺ¿ÙÅÊàµç» 1 à¿Ê ¡ÒáÃеعŒ Ẻ¹ÕÁé ÃÕ Ò¤Ò¶Ù¡áÅЧ‹Ò ÊÃØ»¢Ñ¹é µÍ¹ ¡Ò÷íÒ§Ò¹áÊ´§´Ñ§ã¹µÒÃÒ§·Õè 5-1 Êàµç»·Õè à¿Ê·Õè 1 à¿Ê·Õè 2 à¿Ê·Õè 3 à¿Ê·Õè 4 Ẻ¿ÙÅÊàµç» 2 à¿Ê ¨Ð¡ÃеعŒ â´Â¨‹Ò 1 ·íÒ§Ò¹ ·íÒ§Ò¹ áç´Ñ¹ä»·Õ¢è ´ÅÇ´ 2 ¢´·ÕÍè ÂÙ㋠¡ÅŒ¡¹Ñ ã¹àÇÅÒà´ÕÂÇ 2 ·íÒ§Ò¹ ·íÒ§Ò¹ 3 ·íÒ§Ò¹ ·íÒ§Ò¹ ¡Ñ¹áÅÐàÃÕ§¶Ñ´¡Ñ¹ä» ¢´ÅÇ´ªØ´áá·Õ¶è ¡Ù ¡ÃеعŒ 4 ·íÒ§Ò¹ ·íÒ§Ò¹ ¨Ð໚¹¢´·Õè 1 áÅÐ 2 µÒÁ´ŒÇ¡ÒáÃеعŒ ¢´·Õè µÒÃÒ§·Õè 5-2 áÊ´§ÃٻẺ¡ÒâѺÊàµç»à»ÍÏ 2 áÅÐ 3 µ‹Íä»à»š¹¢´·Õè 3 áÅÐ 4 ¶Ñ´ä»à»š¹¢´ ·Õè 4 áÅÐ 1 áŌǡÅѺÁÒ·Õ¢è ´·Õè 1 áÅÐ 2 Ç¹ä» ÁÍàµÍÏẺ¿ÙÅÊàµç» 2 à¿Ê µÒÁÅíҴѺઋ¹¹Õé ËÃ×ÍàÃÔÁè ·Õ¢è ´ 1 áÅÐ 4 µÒÁ´ŒÇ Êàµç»·Õè à¿Ê·Õè 1 à¿Ê·Õè 2 à¿Ê·Õè 3 à¿Ê·Õè 4 ¢´·Õè 4 áÅÐ 3 ¶Ñ´ä»à»š¹¢´·Õè 3 áÅÐ 2 µ‹Íä» 1 ·íÒ§Ò¹ ໚¹¢´·Õè 2 áÅÐ 1 áŌÇǹ¡ÅѺÁÒ·Õ¢è ´·Õè 1 áÅÐ 2 ·íÒ§Ò¹ ·íÒ§Ò¹ 4 ·ÔÈ·Ò§¡ÒÃËÁع¨ÐÊǹ¡Ñ¹ ´Ñ§áÊ´§¢Ñ¹é µÍ¹ 3 ·íÒ§Ò¹ ¡ÒáÃе،¹ã¹µÒÃÒ§·Õè 5-2 ¡ÒáÃе،¹áºº¹Õé 4 ·íÒ§Ò¹ ·íÒ§Ò¹ ÊÒÁÒöà¾ÔÁè áçºÔ´ä´ŒÁÒ¡¡Ç‹ÒẺ 1 à¿Ê ᡹ 5 ·íÒ§Ò¹ 6 ·íÒ§Ò¹ ·íÒ§Ò¹ áÁ‹àËÅç¡à¤Å×Íè ¹·ÕÀè ÒÂã¹ÁÍàµÍϨÐà¤Å×Íè ¹·Õ´è nj  7 ·íÒ§Ò¹ áç´Ö§Í‹ҧàµçÁáç¨Ò¡ 2 ¢´ÅÇ´·Õè¶Ù¡¡Ãе،¹ 8 ·íÒ§Ò¹ ·íÒ§Ò¹ ¾ÃŒÍÁ¡Ñ¹ áÅÐËÁعµ‹Íä»´ŒÇÂáç´Ö§¨Ò¡ÍÕ¡ 2 µÒÃÒ§·Õè 5-3 áÊ´§ÃٻẺ¡ÒâѺÊàµç»à»ÍÏ ¢´ÅÇ´¶Ñ´ä» ÊíÒËÃѺ¢ŒÍàÊÕ¤×Í µŒÍ§ãªŒ¡Òí ÅÑ§ä¿ ¿‡ÒÁÒ¡¢Ö¹é ÁÍàµÍÏẺÎÒŏ¿Êàµç» Êàµç»·Õè 1 2 3 4

à¿Ê·Õè 1 ·íÒ§Ò¹ -

à¿Ê·Õè 2 ·íÒ§Ò¹ -

à¿Ê·Õè 3 ·íÒ§Ò¹ -

à¿Ê·Õè 4 ·íÒ§Ò¹

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 50


+V

R501 510 1

5

2

4

IC501 4N25

K501 DATA BUS (UIC-10)

D0 D2

D501 1N4001 R506 1k

Q501 BD139

R505 1k

+5V D1 D3

+V

R502 510 1

5

IC502 4N25 2

4

D502 1N4001 +V

R508 1k

Q502 BD139

R507 1k

P3 P4 K502

+V

R503 510 1

5

2

4

IC503 4N25

P1 P2

STEPPER MOTOR D503 1N4001

R510 1k

Q503 BD139

R509 1k

+V

R504 510 1

5

2

4

IC504 4N25

EX-05 Stepper motor driver board

D504 1N4001 R512 1k

Q504 BD139

R511 1k

EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ l ¢Ñ º Êàµç » à»ÍÏ Á ÍàµÍÏ á ººÂÙ ¹Ô ⠾ŋ Ò Ã

䴌µ§Ñé ᵋ5-24V ¡ÃÐáÊÊÙ§ÊØ´ 1.5A l 㪌 á Ëŋ § ¨‹ Ò Âä¿Êí Ò ËÃÑ º ÁÍàµÍÏ á ¡ µ‹Ò§ËÒ¡ â´ÂÁÕ¡ÒÃá¡¡ÃÒÇ´¢Í§ÊÑ­­Ò³ ¤Çº¤ØÁ¡Ñºä¿àÅÕÂé §ÁÍàµÍÏÍÍ¡¨Ò¡¡Ñ¹´ŒÇ Íͻⵌ¤»Ñ à»ÅÍÏ l ¤Í¹à¹ç¡àµÍÏ DATA BUS ÊíÒËÃѺàª×Í èÁ µ‹Í¡Ñº P-Board áÅÐ S-Board

ÃÙ»·Õè 5-2 ǧ¨ÃÊÁºÙó¢Í§ EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 51


ẺÎÒŏ¿Êàµç» ໚¹ÃٻẺ·Õ¼è ÊÁ¼ÊÒ¹ÃÐËNjҧ¡ÒáÃеعŒ Ẻ 1 áÅÐ 2 à¿Ê à¾×Íè à¾ÔÁè ¨íҹǹ¢Í§Êàµç»µ‹ÍÃͺÍա෋ҵÑÇ˹֧è ã¹Ãкº¹Õ¨é СÃеعŒ ¢´ÅÇ´àÃÕ§¡Ñ¹ä»à»š¹ÅíҴѺ´Ñ§¹Õé àÃÔÁè ¨Ò¡ ¢´ÅÇ´·Õè 1, 1 áÅÐ 2, 2, 2 áÅÐ 3, 3, 3 áÅÐ 4, 4, 4 áÅÐ 1 áŌÇǹ¡ÅѺÁÒÂѧ¢´ÅÇ´·Õè 1 ´Ñ§áÊ´§ã¹µÒÃÒ§·Õè 5-3 áçºÔ´·Õäè ´Œ¨Ò¡¡ÒáÃеعŒ Ẻ¹Õ¨é Ðà¾ÔÁè ÁÒ¡¢Ö¹é à¹×Íè §¨Ò¡ª‹Ç§¢Í§¡ÒÃà¤Å×Íè ¹ ·Õãè ¹áµ‹ÅÐÊàµç»ÁÕÃÐÂÐÊѹé ŧ ᵋÅÐÊàµç»à¡Ô´áç´Ö§¨Ò¡¢´ÅÇ´ 2 ¢´·Õ¶è ¡Ù ¡ÃеعŒ ¾ÃŒÍÁ¡Ñ¹ ¤ÇÒÁ ¶Ù¡µŒÍ§¢Í§µíÒá˹‹§ÁÕà¾ÔÁè ÁÒ¡¢Ö¹é ᵋµÍŒ §¾Ö§ÃÐÇÑ§Ç‹Ò àÁ×Íè ¡ÃеعŒ ãˌ·Òí §Ò¹ã¹ÃٻẺ¹Õ¨é еŒÍ§ËÁع ¶Ö§ 2 Êàµç» ¨Ö§¨Ð䴌෋ҡѺÃÐÂÐ෋ҡѺ¡ÒáÃеعŒ Ẻ¿ÙÅÊàµç» 1 Êàµç» ÊíÒËÃѺáËŋ§¨‹Ò¡íÒÅѧ ä¿¿‡ÒµŒÍ§ãªŒ¢¹Ò´à·‹Ò¡Ñºáºº 2 à¿Ê໚¹Í‹ҧ¹ŒÍ ¨Ö§¨Ðà¾Õ§¾Í

EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ ¡Ò÷´Åͧ㹺·¹Õ¨é Ð㪌 EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ»ÃСͺ㹡Òà ·´Åͧà¾×Íè ¢ÑºÊàµç»à»ÍÏÁÍàµÍϼҋ ¹·Ò§¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏ â´ÂºÍÏ´ EX-05 ÁÕ¡ÒÃá¡ ¡ÃÒÇ´·Ò§ä¿¿‡Ò¢Í§Ê‹Ç¹ÍÔ¹¾Øµ·Õàè ª×Íè Áµ‹Í¡Ñº¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏáÅÐàÍÒµ¾µØ ·Õàè ª×Íè Áµ‹Í¡Ñº Êàµç»à»ÍÏÁÍàµÍÏÍÍ¡¨Ò¡¡Ñ¹ áŌÇ㪌¡ÒÃàª×Íè Áµ‹Í·Ò§áʧâ´ÂÍØ»¡Ã³·àÕè ÃÕÂ¡Ç‹Ò Íͻⵌ¤»Ñ à»ÅÍÏ 㹡Òö‹Ò·ʹÊÑ­­Ò³¤Çº¤ØÁ ǧ¨Ã¢Í§ºÍÏ´ EX-05 áÊ´§ã¹ÃÙ»·Õè 5-2 ÊÑ­­Ò³ÍÔ¹¾ØµÁÒ¨Ò¡ ¤Í¹à¹ç¡àµÍÏ DATA BUS «Ö§è àª×Íè Áµ‹ÍࢌҡѺ P-Board áŌÇʋ§ä»¢Ñº LED ÍÔ¹¿ÃÒàô«Ö§è ÍÂÙÀ‹ Ò ã¹Íͻⵌ¤»Ñ à»ÅÍÏ IC501-IC504 â´Â¼‹Ò¹µÑǵŒÒ¹·Ò¹ R501-R504 à¾×Íè ¨íÒ¡Ñ´¡ÃÐáÊãˌ¡ºÑ LED ã¹¢³Ð·Õàè ÍÒµ¾µØ ¢Í§Íͻⵌ¤»Ñ à»ÅÍϨе‹ÍࢌҡѺ·ÃÒ¹«ÔÊàµÍÏ Q501-Q504 àºÍÏ BD139 à¾×Íè ¢ÑºÁÍàµÍϵ͋ ä» àÁ×Íè »‡Í¹Åͨԡ “1” ãˌ¡ºÑ Íͻⵌ¤»Ñ à»ÅÍÏ ¨Ð·íÒãˌ LED ÀÒÂã¹Íͻⵌ¤»Ñ à»ÅÍÏ ·íÒ§Ò¹ ¡ÃеعŒ ãˌâ¿âµŒ·ÃÒ¹«ÔÊàµÍÏÀÒÂã¹Íͻⵌ¤»Ñ à»ÅÍÏ·Òí §Ò¹ à¡Ô´áç´Ñ¹¼‹Ò¹µÑǵŒÒ¹·Ò¹»‡Í¹ ࢌҷբè ÒàºÊ¢Í§·ÃÒ¹«ÔÊàµÍÏ ·íÒãˌ·ÃÒ¹«ÔÊàµÍÏ BD139 ¹íÒ¡ÃÐáÊ àÊÁ×͹NjҢ´ÅÇ´´ŒÒ¹Ë¹Ö§è ¶Ù¡ µ‹Íŧ¡ÃÒÇ´ ¨Ö§à¡Ô´¡ÃÐáÊäËż‹Ò¹¢´ÅÇ´ ·íÒãˌà¡Ô´¡ÒÃËÁع¢Ö¹é ¡ÒÃËÁع¢Í§Êàµç»à»ÍÏÁÍàµÍÏ ¨Ð໚¹Í‹ҧäà ¢Ö¹é ÍÂÙ¡Ž ºÑ ¢ŒÍÁÙÅ·Õ»è ͇ ¹ãˌᡋǧ¨Ã¢Ñºº¹ºÍÏ´ EX-05 ¹Õé ÊíÒËÃѺä¿àÅÕ駢ͧÊàµç»à»ÍÏÁÍàµÍϨÐá¡ÍÍ¡¨Ò¡Ç§¨ÃÍÔ¹¾Øµ·Õèàª×èÍÁµ‹Í¡Ñº P-Board â´ÂµŒÍ§»‡Í¹áç´Ñ¹µÒÁ¾Ô¡´Ñ ¢Í§ÁÍàµÍÏ·µÕè ͌ §¡ÒâѺ ᵋÁ¢Õ ͌ ¨íҡѴNjҵŒÍ§Áդҋ äÁ‹à¡Ô¹ 30V ¡ÃÐ áÊä¿¿‡Ò»ÃÐÁÒ³ 1A ºÍÏ´ EX-05 ໚¹ºÍÏ´µÑÇÍ‹ҧ·Õãè ªŒªÇ‹ Â㹡ÒùíÒ¤ÍÁ¾ÔÇàµÍÏ仢ѺÊàµç»à»ÍÏÁÍàµÍÏ ¶ŒÒ¼ÙŒ 㪌§Ò¹µŒÍ§¡ÒâѺÊàµç»à»ÍÏÁÍàµÍÏËÅÒÂæ µÑÇ㹤ÃÒÇà´ÕÂÇ¡çÊÒÁÒö·íÒ䴌 â´Â¹íÒ¢Ò¾Íϵ Data ·Ñ§é 8 ºÔµÁÒ㪌 ·íÒãˌÊÒÁÒö¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ䴌 2 µÑÇáÅжŒÒ㪌¾Íϵ Control ÁÒª‹Ç¡ç¨ÐÊÒ ÁÒö¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ䴌㹤ÃÒÇà´ÕÂǶ֧ 3 µÑÇ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 52


¡Ò÷´Åͧ·Õè 5 ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺ 1 à¿Ê à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. áËŋ§¨‹ÒÂ俵ç +12V 2A ËÃ×ÍÁÒ¡¡Ç‹Ò 1 à¤Ã×Íè § 5. Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ ¢¹Ò´ 12V 100Ω 7.5 ͧÈÒµ‹ÍÊàµç» ËÃ×Í´Õ¡Ç‹Ò 1 µÑÇ 6. ÊÒÂàª×Íè Áµ‹Í IDC-10

1 àʌ¹

¡Ò÷´Åͧ ÃٻẺ¡ÒâѺẺ 1 à¿Ê¨Ò¡ã¹µÒÃÒ§·Õè 5-1 ¢Í§Ê‹Ç¹·ÄÉ®Õ àÁ×Íè á»Å§à»š¹¡Òû‡Í¹Åͨԡ ¡Òû‡Í¹¤‹Ò¨Ð໚¹ 1,2,4,8 ÊíÒËÃѺ¡ÒÃËÁع·Ç¹à¢çÁ¹Ò́¡ÒËÃ×ÍËÁع«ŒÒÂáÅл‡Í¹ 8,4,2,1 ÊíÒËÃѺ ¡ÒÃËÁعµÒÁà¢çÁ¹Ò́¡ÒËÃ×ÍËÁع¢ÇÒ â´ÂÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ¤Çº¤ØÁÍ‹ҧ§‹ÒÂ䴌´§Ñ ¹Õé 5.1 ÊíÒËÃѺ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ Visual BASIC à¾×Íè ¢ÑºÊàµç»à»ÍÏÁÍàµÍϴnj ºÍÏ´ EX-05 ãˌËÁع ·Ò§´ŒÒ¹«ŒÒ¨Ð㪌»Á؆ Command1 «Ö§è à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ Command1 䴌´§Ñ ¹Õé Private Sub Command1_Click() Lefts = False Rights = True Do DoEvents Out &H378, 1 Call delay Out &H378, 2 Call delay Out &H378, 4 Call delay Out &H378, 8 Call delay Loop Until Lefts = True End Sub

5.2 àª×Íè Áµ‹Í P-Board ¡ÑººÍÏ´ EX-05 ´ŒÇÂÊÒ IDC-10 ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ DATA BUS áÅÐ µ‹ÍÊàµç»à»ÍÏÁÍàµÍÏࢌҡѺºÍÏ´ EX-05 â´ÂµŒÍ§Êѧࡵà¿Ê¢Í§ÁÍàµÍÏãˌ¶¡Ù µŒÍ§´ŒÇ 5.3 ¨‹ÒÂä¿ãˌ P-Board áÅÐ EX-05 ¨Ò¡¹Ñ¹é Ãѹâ»Ãá¡ÃÁ·Õàè ¢Õ¹¢Ö¹é ã¹¢ŒÍ 5.1 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 53


5.4 ¡´»ØÁ† Command1 â»Ãá¡ÃÁ¨Ðʋ§¤‹Ò 1,2,4,8 â´Â¨Ð¤Ñ¹è ´ŒÇÂâ»Ãá¡ÃÁ‹ÍÂ˹‹Ç§àÇÅÒ (delay) áÅÐǹÅÙ»ä»àÃ×Íè  æ â´Â 㪌¤Òí Êѧè Do...... Loop Until «Ö§è ¨Ð¤ÍµÃǨÊͺNjÒÁÕ¡Òá´ Command2 ËÃ×ÍäÁ‹ Êѧࡵ¡Ò÷íÒ§Ò¹¢Í§Êàµç»à»ÍÏÁÍàµÍÏ 5.5 ÊíÒËÃѺâ»Ãá¡ÃÁ˹‹Ç§àÇÅÒ ÁÕÇ¸Ô ¡Õ ÒÃà¢Õ¹䴌ËÅÒÂÇÔ¸Õ ÇÔ¸áÕ Ã¡¤×Í ¡ÒÃ㪌 Timer «Ö§è ໚¹°Ò¹ àÇÅÒ㹤ÍÁ¾ÔÇàµÍÏ ÊíÒËÃѺÇÔ¸¹Õ äÕé Á‹Çҋ ¨Ð㪌¤ÍÁ¾ÔÇàµÍÏù؋ ã´ã¹¡Ò÷´Åͧ ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹ ¢Í§â»Ãá¡ÃÁ˹‹Ç§àÇÅҢͧ¤ÍÁ¾ÔÇàµÍÏᵋÅÐà¤Ã×Íè §¡ç处 ¤§à·‹Òà´ÔÁ ᵋ¢ÍŒ àÊÕ¤×Í ¤ÇÒÁàÃçÇÊÙ§ÊØ´ ·Õâè »Ãá¡ÃÁ·íÒ䴌ÍÒ¨äÁ‹à¾Õ§¾Íµ‹Í¤ÇÒÁµŒÍ§¡Òà à¹×Íè §¨Ò¡¤‹ÒµèÒí ÊØ´¢Í§¡ÒùѺÁդҋ ෋ҡѺ 0.01 ÇÔ¹Ò·Õ෋ҹѹé ÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ䴌´§Ñ ¹Õé Sub delay() Times = Timer Do DoEvents Loop Until Timer >= Times + 0.01 End Sub

â»Ãá¡ÃÁ¹Õ¨é зíÒ¡ÒõÃǨÊͺNjҤ‹Ò Timer «Ö§è ໚¹¤‹ÒµÑÇàÅ¢àÇÅÒÀÒÂã¹à¤Ã×Íè §¤ÍÁ¾ÔÇàµÍÏ ¹Ñ¹é Áդҋ ÁÒ¡¡Ç‹Ò ¤‹Ò Times +0.01 «Ö§è ໚¹¤‹ÒµÑÇá»Ã·ÕÁè ¡Õ ÒáíÒ˹´änj¡Í‹ ¹Ç¹ÅÙ»ËÃ×ÍÂѧ ¶ŒÒàÇÅÒ à´Ô¹ä»¨¹Áդҋ ÁÒ¡¡Ç‹ÒËÃ×Í෋ҡѺ Times +0.01 áÅŒÇ â»Ãá¡ÃÁ¨ÐÍÍ¡¨Ò¡ÅÙ»¡ÒÃ˹‹Ç§àÇÅÒ â´Â·Õè ¤íÒÊѧè Doevents ໚¹¤íÒÊÑ§è ·Õªè Nj Âãˌâ»Ãá¡ÃÁÊÒÁÒö·íÒ§Ò¹ã¹â»Ãá¡ÃÁʋǹÍ×¹è æ 仾ÌÍÁ¡Ñ¹ 䴌 ઋ¹ ÊÒÁÒö¡´»ØÁ† Command2 ã¹¢³Ð·Õ¡è ÒÃÅѧǹÍÂÙ㋠¹Åٻ䴌໚¹µŒ¹ ¼Ù㌠ªŒ§Ò¹ÍÒ¨·´Åͧ äÁ‹ãʋ¤Òí Êѧè Doevents à»ÃÕºà·Õº¡Ñº¡ÒÃãʋ¤Òí ÊÑ§è ¹Õäé njã¹â»Ãá¡ÃÁáÅŒÇ Êѧࡵ´Ù¤ÇÒÁᵡµ‹Ò§ 5.6 ¨Ò¡â»Ãá¡ÃÁ˹‹Ç§àÇÅÒã¹ÃٻẺáá㹡Ò÷´Åͧ¢ŒÍ 5.5 ÍÒ¨ãˌ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹äÁ‹ ÁÒ¡¹Ñ¡ ´Ñ§¹Ñ¹é â»Ãá¡ÃÁ˹‹Ç§àÇÅÒã¹ÃٻẺ·Õè 2 ¨Ðãˌ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹·ÕÁè Ò¡¡Ç‹Ò â´Âã¹ ÃٻẺ¹Õé ¤ÇÒÁàÃçǨТֹé ÍÂÙ¡‹ ºÑ ¤ÇÒÁàÃçǢͧ¤ÍÁ¾ÔÇàµÍÏ â´ÂÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ䴌´§Ñ ¹Õé Sub delay() For i = 1 To HScroll1.Value DoEvents Next i End Sub

¡ÒÃà¢Õ¹â»Ãá¡ÃÁã¹ÃٻẺ¹Õé¨Ð㪌¤íÒÊÑè§ For...Next áÅÐ㪌ᶺàÅ×è͹ Hscroll 㹡Òà »ÃѺ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹ áÅÐ㹡óշÕèÁÕ¡ÒÃǹÅÙ»·ÕèÂÒǹҹáÅÐäÁ‹µŒÍ§¡ÒÃãˌâ»Ãá¡ÃÁ “ËÂØ´¤ŒÒ§” ¡çµÍŒ §á·Ã¡¤íÒÊѧè Doevents ࢌÒä»ÃÐËNjҧÅÙ» 5.7 ÊíÒËÃѺ¡ÒÃËÁع价ҧ´ŒÒ¹¢ÇÒ ¨ÐµŒÍ§ÊÌҧ»ØÁ† Command2 ¢Ö¹é â´Â¡‹Í¹·Õ¨è ÐÊѧè ãˌÊàµç»à»ÍÏ ÁÍàµÍÏËÂØ´¡ÒÃËÁع¡‹Í¹ â´Â㹡ÒÃà¢Õ¹â»Ãá¡ÃÁ¨Ð㪌µÇÑ á»Ã Lefts áÅÐ Rights ´Ñ§â»Ãá¡ÃÁ µÑÇÍ‹ҧµ‹Í仹Õé àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 54


Private Sub Command2_Click() Lefts = True Rights = False Do DoEvents Out &H378, 8 Call delay Out &H378, 4 Call delay Out &H378, 2 Call delay Out &H378, 1 Call delay Loop Until Rights = True End Sub

¡Ò÷íÒ§Ò¹¢Í§â»Ãá¡ÃÁ¨ÐàËÁ×͹¡Ñº¡ÒÃËÁع«ŒÒ ᵋ¨Ðᵡµ‹Ò§¡Ñ¹·ÕÃè »Ù áºº¢Í§¢ŒÍÁÙÅ¡Òà ËÁع¨Ð໚¹ 8,4,2,1 á·¹ â´ÂàÁ×Íè Ãѹâ»Ãá¡ÃÁµÑÇÍ‹ҧ¨Ð»ÃÒ¡¯ÃٻẺ¢Í§Ë¹ŒÒ¨Í´Ñ§ÃÙ»·Õè P5-1 Í‹ҧäáçµÒÁÊÒÁÒö´ÙÃÒÂÅÐàÍÕ´·Ñé§ËÁ´¢Í§â»Ãá¡ÃÁáÅз´Åͧ㪌§Ò¹ä´Œ¨Ò¡ä¿Å LAB05.VBP

ÃÙ»·Õè P5-1 ˹ŒÒ¨Í¢Í§â»Ãá¡ÃÁ·Õè à¢Õ¹¢Öé¹ã¹¡Ò÷´Åͧ·Õè 5 ¹Õé 㪌 ÊíÒËÃѺ»ÃѺ¤ÇÒÁàÃçÇáÅзÔÈ·Ò§ ¡ÒÃËÁع¢Í§Êàµç»à»ÍÏÁÍàµÍÏ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 55


¡Ò÷´Åͧ·Õè 6 ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺÊͧà¿Ê à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. áËŋ§¨‹ÒÂ俵ç +12V 2A ËÃ×ÍÁÒ¡¡Ç‹Ò 1 à¤Ã×Íè § 5. Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ ¢¹Ò´ 12V 100Ω 7.5 ͧÈÒµ‹ÍÊàµç» ËÃ×Í´Õ¡Ç‹Ò 1 µÑÇ 6. ÊÒÂàª×Íè Áµ‹Í IDC-10

1 àʌ¹

¡Ò÷´Åͧ 6.1 ¡ÒäǺ¤ØÁÊàµç»à»ÍÏÁÍàµÍÏãˌ·Òí §Ò¹à»š¹áºº 2 à¿Ê¹Ñ¹é ÁÕû٠Ẻ¡ÒâѺáÊ´§ã¹µÒÃÒ§·Õè 4-2 ã¹Ê‹Ç¹¢Í§·ÄÉ®Õ â´Â¨ÐµŒÍ§»‡Í¹¤‹Ò 9,3,6,12 ÊíÒËÃѺ¡ÒÃËÁع´ŒÒ¹«ŒÒÂáÅÐ 12,6,3,9 ÊíÒËÃѺ ¡ÒÃËÁع·Ò§´ŒÒ¹¢ÇÒã¹â»Ãá¡ÃÁ â´ÂÊÒÁÒÃ¶á¡Œä¢ Command1 áÅÐ Command2 ¨Ò¡â»Ãá¡ÃÁ 㹡Ò÷´Åͧ·Õè 5 䴌´§Ñ ¹Õé Dim i As Integer Dim Lefts, Rights As Boolean Private Sub Command1_Click() Lefts = False Rights = True Do DoEvents Out &H378, 9 Call delay Out &H378, 3 Call delay Out &H378, 6 Call delay Out &H378, 12 Call delay Loop Until Lefts = True End Sub Private Sub Command2_Click() Lefts = True Rights = False

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 56


Do DoEvents Out &H378, 12 Call delay Out &H378, 6 Call delay ut &H378, 3 Call delay Out &H378, 9 Call delay Loop Until Rights = True End Sub

6.2 àª×Íè Áµ‹Í P-Board ¡ÑººÍÏ´ EX-05 ´ŒÇÂÊÒ IDC-10 ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ DATA BUS áÅÐ µ‹ÍÊàµç»à»ÍÏÁÍàµÍÏࢌҡѺºÍÏ´ EX-05 â´ÂµŒÍ§Êѧࡵà¿Ê¢Í§ÁÍàµÍÏãˌ¶¡Ù µŒÍ§´ŒÇ 6.3 ¨‹ÒÂä¿ãˌ P-Board áÅÐ EX-05 ¨Ò¡¹Ñ¹é Ãѹâ»Ãá¡ÃÁ·Õàè ¢Õ¹¢Ö¹é ã¹¢ŒÍ 6.1 6.4 ÊÑ § ࡵ¡ÒÃËÁØ ¹ ¢Í§Êàµç » à»ÍÏ Á ÍàµÍÏ à »ÃÕ Â ºà·Õ  º¡Ñ º 㹡Ò÷´Åͧ·Õè 5 ¨Ð¾ºÇ‹ Ò ¡ÒâѺãˌÊàµç»à»ÍÏÁÍàµÍÏËÁعã¹áººÊͧà¿Ê¨ÐãˌáçºÔ´·ÕèÁÒ¡¡Ç‹Ò ᵋ¡ç¨Ð¡Ô¹ ¡íÒÅѧ§Ò¹ÁÒ¡¡Ç‹ÒẺ˹֧è à¿Ê໚¹ 2 ෋ҴŒÇÂઋ¹¡Ñ¹ ÊíÒËÃѺÃÒÂÅÐàÍÕ´·Ñé§ËÁ´¢Í§â»Ãá¡ÃÁ·´Åͧ¹ÕéÊÒÁÒö´ÙáÅз´Åͧ㪌§Ò¹ä´Œ¨Ò¡ä¿Å LAB06.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 57


¡Ò÷´Åͧ·Õè 7 ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏẺÎÒŏ¿Êàµç» à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. áËŋ§¨‹ÒÂ俵ç +12V 2A ËÃ×ÍÁÒ¡¡Ç‹Ò 1 à¤Ã×Íè § 5. Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾Å‹ÒÏ ¢¹Ò´ 12V 100Ω 7.5 ͧÈÒµ‹ÍÊàµç» ËÃ×Í´Õ¡Ç‹Ò 1 µÑÇ 6. ÊÒÂàª×Íè Áµ‹Í IDC-10 1 àʌ¹

¡Ò÷´Åͧ 7.1 ¡ÒâѺÊàµç»à»ÍÏÁÍàµÍÏã¹ÃٻẺ¹Õé ¨Ðãˌ¤ÇÒÁÅÐàÍÕ´㹡ÒâѺ໚¹ 2 ෋ҢͧẺ¿ÙÅ Êàµç»¨Ò¡¡Ò÷´Åͧ·Õè 5 áÅÐ 6 ´Ñ§¹Ñ¹é ¡Òû‡Í¹¤‹Ò¨Ö§µŒÍ§»‡Í¹´ŒÇ¤‹Ò·Õáè µ¡µ‹Ò§¡Ñ¹¶Ö§ 8 ¤‹Ò´ŒÇ ¡Ñ¹¤×Í ¨Ð»‡Í¹¢ŒÍÁÙÅẺ 1 à¿ÊÊÅѺ¡ÑºáººÊͧà¿Ê ÊíÒËÃѺ¡ÒÃËÁع«ŒÒ¨еŒÍ§»‡Í¹¤‹Ò෋ҡѺ 9,1,3,2,6,4,12,8 ʋǹ¡ÒÃËÁع¢ÇÒµŒÍ§»‡Í¹¤‹Ò෋ҡѺ 8,12,4,6,2,3,1,9 «Öè§ÊÒÁÒöà¢Õ¹ â»Ãá¡ÃÁ䴌´§Ñ ¹Õé Private Sub Command1_Click() Lefts = True Rights = False Do DoEvents Out &H378, 9 Call delay Out &H378, 1 Call delay Out &H378, 3 Call delay Out &H378, 2 Call delay Out &H378, 6 Call delay Out &H378, 4 Call delay Out &H378, 12 Call delay Out &H378, 8

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 58


Call delay Out &H378, 0 Call delay Loop Until Rights = True End Sub Private Sub Command2_Click() Lefts = False Rights = True Do DoEvents Out &H378, 8 Call delay Out &H378, 12 Call delay Out &H378, 4 Call delay Out &H378, 6 Call delay Out &H378, 2 Call delay Out &H378, 3 Call delay Out &H378, 1 Call delay Out &H378, 9 Call delay Out &H378, 0 Call delay Loop Until Lefts = True End Sub

7.2 àª×Íè Áµ‹Í P-Board ¡ÑººÍÏ´ EX-05 ´ŒÇÂÊÒ IDC-10 ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ DATA BUS áÅÐ µ‹ÍÊàµç»à»ÍÏÁÍàµÍÏࢌҡѺºÍÏ´ EX-05 â´ÂµŒÍ§Êѧࡵà¿Ê¢Í§ÁÍàµÍÏãˌ¶¡Ù µŒÍ§´ŒÇ 7.3 ¨‹ÒÂä¿ãˌ P-Board áÅÐ EX-05 ¨Ò¡¹Ñ¹é Ãѹâ»Ãá¡ÃÁ·Õàè ¢Õ¹¢Ö¹é ã¹¢ŒÍ 7.1 7.4 Êѧࡵ¡ÒÃËÁع¢Í§Êàµç»à»ÍÏÁÍàµÍÏ ¨Ð¾ºÇ‹Ò Êàµç»à»ÍÏÁÍàµÍϨÐËÁعªŒÒ¡Ç‹Ò¡Òà ÊÑ§è §Ò¹ã¹¡Ò÷´Åͧ·Õè 5 áÅÐ 6 ᵋãˌ¤ÇÒÁÅÐàÍÕ´㹡Ò÷íÒ§Ò¹ÁÒ¡¡Ç‹Ò «Ö§è ¡ç¢¹Öé ÍÂÙ¡‹ ºÑ ¼ÙŒãªŒ§Ò¹Ç‹ÒµŒÍ§¡ÒÃ㪌§Ò¹¤Çº¤ØÁã¹ÃٻẺ㴡çÊÒÁÒö¹íÒÃٻẺ¹Ñé¹ä»ãªŒã¹¡ÒäǺ¤ØÁ䴌 ÊíÒËÃѺâ»Ãá¡ÃÁµÑÇÍ‹ҧ¼ÙŒãªŒ§Ò¹ÊÒÁÒö´ÙÃÒÂÅÐàÍÕ´áÅз´Åͧ㪌§Ò¹ä´Œ¨Ò¡ä¿Å LAB07.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 59


..


º··Õè 6 ¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹ ´ŒÇ¾Íϵ¢¹Ò¹ LED µÑÇàÅ¢ 7 ʋǹ»ÃСͺ¢Ö¹é ¨Ò¡ LED ¨íҹǹ 7 µÑÇ·Õºè ÃèØÍÂÙ㋠¹µÑǶѧà´ÕÂǡѹáÅÐ䴌 ÃѺ¡ÒèѴàÃÕ§໚¹ÃÙ»µÑÇàÅ¢ LED ᵋÅеÑǨж١àÃÕÂ¡Ç‹Ò Ê‹Ç¹ ËÃ×Í à«¡àÁ¹µ (segment) ᵋÅРʋǹËÃ×Íà«¡àÁ¹µÁªÕ Í×è àÃÕ¡ᵡµ‹Ò§¡Ñ¹µÒÁµíÒá˹‹§·Õäè ´ŒÃºÑ ¡ÒèѴÇÒ§¤×Í a, b, c, d, e, f áÅÐ g ´Ñ§áÊ´§ã¹ÃÙ»·Õè 6-1 ʋǹ dp ໚¹ LED ÍÕ¡ 1 µÑÇ·Õºè ÃèØÍÂÙ㋠¹ LED µÑÇàÅ¢ 7 ʋǹ¹Õãé ªŒà»š¹µÑÇáÊ´§ ¨Ø´·È¹ÔÂÁ㹡óշÁÕè ¡Õ ÒÃáÊ´§¼Åã¹ÅѡɳÐàÅ¢·ÕÁè ·Õ È¹ÔÂÁ LED ·Ø¡µÑÇ·Õºè ÃèØÍÂÙ㋠¹ LED µÑÇàÅ¢ 7 ʋǹ¹ÕÁé ¢Õ Òµ‹ÍËÇÁ¡Ñ¹ «Ö§è ¡çÁ·Õ §Ñé Ẻµ‹Í¢Òá¤â·´ ËÇÁ¡Ñ¹àÃÕÂ¡Ç‹Ò áººá¤â·´Ã‹ÇÁ (common cathode) ´Ñ§áÊ´§ã¹ÃÙ»·Õè 6-2 (¡) áÅÐẺµ‹Í¢Ò áÍ⹴ËÇÁ¡Ñ¹àÃÕÂ¡Ç‹Ò áººáÍ⹴ËÇÁ (common anode) ´Ñ§áÊ´§ã¹ÃÙ»·Õè 6-2 (¢) ¡ÒâѺãˌ LED µÑÇàÅ¢ 7 ʋǹẺá¤â·´Ã‹ÇÁÊNjҧ¨ÐµŒÍ§¨‹ÒÂä¿Åºà¢ŒÒ·Õ¢è ÒËÇÁ áŌǨ‹ÒÂ俺ǡࢌҷբè ÒáÍ â¹´ «Ö§è ¡ç¤Í× ¢Ò¢Í§áµ‹ÅÐà«¡àÁ¹µ¹¹Ñè àͧ ã¹¢³Ð·Õè LED µÑÇàÅ¢ 7 ʋǹẺáÍ⹴ËÇÁ¨ÐµŒÍ§¨‹Ò 俺ǡࢌҷբè ÒËÇÁ áŌǨ‹ÒÂä¿Åºà¢ŒÒ·Õ¢è Òá¤â·´ «Ö§è ໚¹¢Ò¢Í§áµ‹ÅÐà«¡àÁ¹µ C

=

B

> ?

A

@F @

b

a b

c d e

c d e

f g dp

f g dp

a

common (¡) á¤â·´Ã‹ÇÁ

common (¢) áÍ⹴ËÇÁ

ÃÙ»·Õè 6-1 ¡ÒáíÒ˹´ª×Íè ¢Í§áµ‹ÅÐà«¡àÁ¹µ ÃÙ»·Õè 6-2 â¤Ã§ÊÌҧ¾×¹é °Ò¹¢Í§ LED µÑÇàÅ¢ ¢Í§ LED µÑÇàÅ¢ 7 ʋǹ 7 ʋǹ·Ñ§é Ẻá¤â·´Ã‹ÇÁáÅÐáÍ⹴ËÇÁ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 61


LED µÑÇàÅ¢ 7 ʋǹÁÕ¨Òí ˹‹Ò·ѧé ẺµÑÇ à´ÕÂè Ç, µÑǤً áÅÐẺ·ÕÁè ÁÕ Ò¡¡Ç‹Ò 2 ËÅÑ¡ ᵋ·Õè ¹ÔÂÁ㪌§Ò¹ÁÕ 2 Ẻ¤×Í áººµÑÇà´ÕÂè ÇáÅÐẺ µÑǤً â´ÂÁÕ¡ÒèѴ¢Ò´Ñ§ã¹ÃÙ»·Õè 6-3 LED µÑÇàÅ¢ 7 ʋǹẺµÑÇà´ÕÂè ÇÁÕ¢Òµ‹Í㪌§Ò¹ 10 ¢Ò¤×Í ¢Ò a, b, c, d, e, f, g, dp áÅТÒËÇÁ (common) 2 ¢Ò ¶ŒÒ໚¹áººµÑǤÙÁ‹ ¢Õ Òµ‹Í㪌§Ò¹ 20 ¢Ò ẋ§à»š¹ ¢Ò a, b, c, d, e, f, g áÅÐ dp Í‹ҧÅÐ 2 ¢ÒÃÇÁ (¡) (¢) 16 ¢Ò áÅТÒËÇÁÍÕ¡ËÅÑ¡ÅÐ 2 ¢Ò ¡Òõ‹Í¢ÒËÇÁ ÃÙ»·Õè 6-3 ¡ÒèѴ¢Ò¢Í§ LED µÑÇàÅ¢ 7 ʋǹ ¢Í§áµ‹ÅÐËÅÑ¡ÊÒÁÒöµ‹Íà¾Õ§¢Òà´ÕÂÇ䴌 à¹×Íè § (¡) ẺµÑÇà´ÕÂè Ç (¢) ẺµÑǤً ¨Ò¡ã¹â¤Ã§ÊÌҧÀÒÂã¹¢ÒËÇÁ¹Õµé ͋ ¶Ö§¡Ñ¹ÍÂÙá‹ ÅŒÇ g

f com a

b

e

d com c dp

f2 g2 com2 a2

b2 f1 g1 com1 a1 b1

e2 d2 com2 c2 dp2 e1 d1 com1 c1 dp1

¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹẺËÅÑ¡à´ÕÂè Ç µŒÍ§µ‹Í¢Ò¾ÍϵàÍÒµ¾Øµ«Öè§ã¹·Õè¹Õé¤×;Íϵ Data ࢌҡѺ¢Òà«¡àÁ¹µ¢Í§ LED â´Â¼‹Ò¹ äÍ«Õº¿Ñ à¿ÍÏà¾×Íè ª‹ÇÂã¹àÃ×Íè §¡Òè‹Ò¡ÃÐáÊ áÅеŒÍ§µ‹ÍµÑǵŒÒ¹·Ò¹Í¹Ø¡ÃÁࢌÒä»à¾×Íè ¨íÒ¡Ñ´¡ÃÐáÊ ãˌᡋ LED ´Ñ§ã¹ÃÙ»·Õè 6-4 ÊíÒËÃѺ¢ÒËÇÁÍҨ㪌¢Ò¾Íϵ Control ¢Òã´¢Ò˹֧è ÁÒª‹ÇÂËÃ×͵‹Íŧ ¡ÃÒÇ´¡äç ´Œ (㹡óÕ㪌 LED Ẻá¤â·´Ã‹ÇÁ) ¡ÒáíÒ˹´ãˌ LED áÊ´§¢ŒÍÁÙÅ໚¹µÑÇàÅ¢ËÃ×Í à»š¹ÊÑ­Åѡɳã´æ ¡çµÒÁ µŒÍ§¡íÒ˹´ÃٻẺ¡ÒÃáÊ´§¼Å¢Í§µÑÇàÅ¢ãˌ¡Ñºà«¡àÁ¹µµ‹Ò§æ ´ŒÇ ¢ŒÍÁÙÅᵋÅкԵ¢Í§¾Íϵ¢¹Ò¹ ´Ñ§ÊÃØ»änj㹵ÒÃÒ§·Õè 6-1 ¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè ¢Ñº LED µÑÇàÅ¢ ¨Ð¡íÒ˹´¤‹Òã¹µÒÃÒ§ä»à¡çºänj㹵ÑÇá»ÃẺÍÒàÏ (array) «Ö§è àÁ×Íè ͌ҧ¶Ö§µÑÇàÅ¢µÑÇã´¡çÊÒÁÒö¹íÒ àÍÒ¢ŒÍÁÙÅã¹ÍÒàϹ¹Ñé ÁÒ㪌䴌·¹Ñ ·Õ

¨Ò¡¾Íϵ Data ¢Í§¾Íϵ¢¹Ò¹

+5V

C1 0.1/50V

20 D0 D1 D2 D3 D4 D5 D6 D7

2 3

D0

Q0

D1

Q1

4 D2 5 D3 6 D4 7 D5 8 D6 9 D7

Q2

a b c d e f g dp

18 17 16

15 Q3 14 Q4 13 Q5 12 Q6 11 Q7

IC1 74HC541 1 10 19

DSP1

R1-R8 100x8

common

C0

¨Ò¡¾Íϵ Control ¢Í§¾Íϵ¢¹Ò¹

ÃÙ»·Õè 6-4 ǧ¨Ã¢Ñº LED µÑÇàÅ¢ 7 ʋǹµÑÇà´ÕÂè Çâ´Â㪌¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 62


¢ŒÍÁÙÅ´Ô¨µÔ ÍÅàÍÒµ¾µØ ÊíÒËÃѺ¢Ñº LED µÑÇàÅ¢ 7 ʋǹ ¢ŒÍÁÙÅáÊ´§¼Å¢Í§ ¤‹ÒµÑÇàÅ¢·Õáè Ê´§ ·Õè LED µÑÇàÅ¢ LED µÑ Ç àÅ¢ 7 ʋ Ç ¹ ,% ,$ ,# ," ,! , , , 7 ʋǹ 















0!.

















0$

















0#*

















0".

















0$$

















0$,

















0%,

















0%

















0%.

















0$.

















0%%

















0%+

















0!'

















0#-

















0%'

















0%

















0..

&Hxx 㹪‹Í§¤‹Ò¢ŒÍÁÙÅáÊ´§¼Å ÁÕ¤ÇÒÁËÁÒÂÇ‹Ò ¢ŒÍÁÙÅ·Õµè ͋ ËÅѧ &H ¹Õàé »š¹¢ŒÍÁÙÅàÅ¢°Ò¹ÊԺˡ

µÒÃÒ§·Õè 6-1 µÒÃÒ§¢ŒÍÁÙÅ¡ÒÃáÊ´§¼Å¢Í§ LED µÑÇàÅ¢ 7 ʋǹ àÁ×Íè 㪌Ẻá¤â·´Ã‹ÇÁ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 63


DSP4

DSP3

DSP2

DSP1

a b c d e f g dp

D0 D1 D2 D3 D4 D5 D6 D7 R1-R8 100x8

common

common

common

common

C3 C2 C1 C0

ÃÙ»·Õè 6-5 ǧ¨Ã¢Ñº LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡« 4 ËÅÑ¡â´Â㪌¾Íϵ¢¹Ò¹¢Í§ ¤ÍÁ¾ÔÇàµÍÏ ·ÕÊè Ò D0-D7 ¤Çõ‹ÍäÍ«Õº¿ Ñ à¿Íϴnj Âà¾×Íè à¾ÔÁè ¤ÇÒÁÊÒÁÒö㹡Òè‹Ò¡ÃÐáÊ

¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡« 㹡óշµÕè ͌ §¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹÁÒ¡¡Ç‹Ò 1 ËÅÑ¡â´Â㪌¨Òí ¹Ç¹ÊÒ¢ŒÍÁÙÅ·Õ¨è Òí ¡Ñ´ ¹Ñ¹é ·íÒ䴌â´Â㪌¡ÒâѺẺÁÑŵÔà¾Åç¡« «Ö§è ¹Í¡¨Ò¡¨Ð»ÃÐËÂÑ´ÊÒÂÊÑ­­Ò³áŌÇÂѧ»ÃÐËÂÑ´¾Åѧ§Ò¹ 㹡ÒâѺ LED µÑÇàÅ¢ÍÕ¡´ŒÇ à¹×Íè §¨Ò¡¡ÒâѺẺÁÑŵÔà¾Åç¡« LED ¨ÐµÔ´·ÕÅÐËÅÑ¡´ŒÇÂÍѵÃÒàÃçÇ ·Õµè ҢͧÁ¹ØɏäÁ‹ÊÒÁÒöµÃǨ¨Ñºä´Œ·¹Ñ ¨Ö§´ÙàËÁ×Í¹Ç‹Ò LED ·Ø¡ËÅÑ¡µÔ´ÊNjҧã¹àÇÅÒà´ÕÂǡѹ ¡ÒÃáÊ´§¼ÅẺÁÑŵÔà¾Åç¡«¹ÁÕé »Õ ÃÐ⪹´§Ñ ¹Õé 1. Å´¾Åѧ§Ò¹ä¿¿‡Ò·Õãè ªŒ ·íÒãˌ¢¹Ò´¢Í§Ãкºâ´ÂÃÇÁàÅç¡Å§´ŒÇ 2. 㪌¨Òí ¹Ç¹ÊÒÂÊÑ­­Ò³¹ŒÍ â´Â·Õ¶è Ҍ ¢Ñº LED µÑÇàÅ¢ 7 ʋǹ 1 ËÅÑ¡¨Ð㪌ÊÒÂÊÑ­­Ò³ 8 àʌ¹¶ŒÒ¢Ñº 2 ËÅÑ¡à¾ÔÁè ໚¹ 9 àʌ¹ËÃ×ͶŒÒ¢Ñº 4 ËÅÑ¡¡ç㪌ÊÒÂÊÑ­­Ò³à¾Õ§ᤋ 11 àʌ¹ 3. Å´¨íҹǹµÑǵŒÒ¹·Ò¹·Õãè ªŒã¹¡ÒèíÒ¡Ñ´¡ÃÐáʢͧ LED ã¹áµ‹ÅÐà«¡àÁ¹µ ¡µÑÇÍ‹ҧ LED µÑÇàÅ¢ 7 ʋǹ˹֧è ËÅÑ¡µŒÍ§ãªŒµÇÑ µŒÒ¹·Ò¹¨íÒ¡Ñ´¡ÃÐáÊ 8 µÑÇ ¶ŒÒËÒ¡¢Ñº LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡â´ÂµÃ§ µŒÍ§ãªŒµÇÑ µŒÒ¹·Ò¹ÁÒ¡¶Ö§ 32 µÑÇ ã¹¢³Ð·ÕËè ҡ㪌¡ÒÃáÊ´§¼ÅẺÁÑŵÔà¾Åç¡« Âѧ ¤§ãªŒµÇÑ µŒÒ¹·Ò¹à¾×Íè ¨íÒ¡Ñ´¡ÃÐáÊã¹áµ‹ÅÐà«¡àÁ¹µà¾Õ§ 8 µÑÇäÁ‹Çҋ ¨Ð¢Ñº LED µÑÇàÅ¢¡ÕËè ÅÑ¡¡çµÒÁ ÊíÒËÃѺ¢ŒÍàÊÕÂ㹡ÒÃ㪌§Ò¹ LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡«º¹¤ÍÁ¾ÔÇàµÍϤÍ× 1. µŒÍ§¤ÍµԴµ‹Íà¾×Íè ʋ§¢ŒÍÁÙÅãˌᡋ LED ÍÂÙµ‹ ÅÍ´àÇÅÒ à¾×Íè ãˌà¡Ô´¡ÒÃáÊ´§¼ÅÍ‹ҧµ‹Í à¹×Íè § ·íÒãˌ¡Ò÷íÒ§Ò¹ã¹Ê‹Ç¹Í×¹è æ ·íÒ䴌ªÒŒ 2. ¡Ò÷íÒ§Ò¹º¹ÇÔ¹â´Çʏ¹¹Ñé ໚¹¡Ò÷íҧҹẺÁÑŵԷÒÊ¡Ô§é «Ö§è ¨ÐµŒÍ§·íÒ§Ò¹¡Ñºâ»Ãá¡ÃÁ Í×¹è æ ¤Çº¤Ùä‹ »´ŒÇ ·íÒãˌªÇ‹ §àÇÅÒ㹡ÒÃÊ᡹¨Ðà¡Ô´µÔ´¢Ñ´ã¹ºÒ§¤Ãѧé áÅÐàË繡ÒáоÃÔº¢Í§ LED àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 64


¡ÒâѺ LED µÑÇàŢẺÁÑŵÔà¾Åç¡«¨Ðµ‹Í¢Ò¢Í§áµ‹ÅÐà«¡àÁ¹µÃ‹ÇÁ¡Ñ¹¤×Í à«¡àÁ¹µ a ¢Í§·Ø¡ËÅÑ¡¨Ðµ‹Í¶Ö§¡Ñ¹äŋàÃÕ§仨¹¶Ö§à«¡àÁ¹µ g 㹺ҧ§Ò¹·Õµè ͌ §ãªŒ¨´Ø dp ¡çµÍŒ §µ‹Í¢Ò¢Í§¨Ø´ dp ÃÇÁ¡Ñ¹´ŒÇ ʋǹ¢ÒËÇÁ¢Í§áµ‹ËÅÑ¡ãˌµÍ‹ ࢌҡѺ¢Ò¾Íϵ Control ´Ñ§áÊ´§ã¹ÃÙ»·Õè 6-5 Í‹ҧäà ¡çµÒÁ·Õ¢è Òà«¡àÁ¹µ¢Í§ LED ¤Çõ‹Í¼‹Ò¹äÍ«Õº¿Ñ à¿ÍÏáÅеÑǵŒÒ¹·Ò¹¨íÒ¡Ñ´¡ÃÐáÊ àËÁ×͹¡Ñº¡Òà ¢Ñº LED µÑÇà´ÕÂè Ç ¡ÒäǺ¤ØÁãˌ LED µÑÇàÅ¢ 7 ʋǹËÅÑ¡ã´µÔ´ÊNjҧ ·íÒ䴌â´Â¡Òè‹ÒÂä¿à¢ŒÒ·Õ¢è ÒËÇÁ¢Í§ LED µÑÇàÅ¢ 7 ʋǹËÅÑ¡¹Ñ¹é æ ¡µÑÇÍ‹ҧËÒ¡ LED µÑÇàÅ¢ 7 ʋǹ·Õãè ªŒà»š¹áººá¤â·´Ã‹ÇÁ ËÒ¡µŒÍ§¡Òà ãˌ LED µÑÇàÅ¢ 7 ʋǹËÅÑ¡·Õè 3 µÔ´ÊNjҧ¡çãˌµÍ‹ ¢ÒËÇÁ¢Í§ËÅÑ¡·Õè 3 ŧ¡ÃÒÇ´ËÃ×ͨ‹ÒÂä¿Åº LED µÑÇàÅ¢ 7 ʋǹËÅÑ¡·Õè 3 ¡ç¨ÐµÔ´ÊNjҧµÒÁ¢ŒÍÁÙÅ·ÕÊè §‹ ࢌÒÁÒÂѧ¢Ò¢Í§áµ‹ÅÐà«¡àÁ¹µ

¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹâ´Â㪌ºÍÏ´ EX-02 㹡Ò÷´Åͧà¾×Íè ¢Ñº LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡«â´Â㪌¾Íϵ¢¹Ò¹ ¨Ð㪌 P-Board ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹Ã‹ÇÁ¡Ñº EX-02 ºÍÏ´ LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡ â´Âǧ¨Ã¢Í§ºÍÏ´ EX-02 áÊ´§ã¹ÃÙ»·Õè 5-4 LED µÑÇàÅ¢ 7 ʋǹ·Ñ§é 4 ËÅÑ¡¨Ðµ‹Í¢Òà«¡àÁ¹µ¢Í§áµ‹ÅÐËÅѡࢌҴŒÇ¡ѹ +5V +5V

D1 D3 D5 D7 C1 C3

D0 D2 D4 D6 C0 C2

20 2 3 4

D0

Q0

D1

Q1

D2

Q2

5 D3 6 D4 7 D5 8 D6 9 D7

DSP204

DSP203

DSP202

DSP201

a b c d e f g dp

18 17 16

15 Q3 14 Q4 13 Q5 12 Q6 11 Q7

IC201 74HC541 1 10 19

DSP201-DSP204 : LED 7 SEGMENTS COMMON CATHODE

C201 0.1/50V

R201-R208 100x8

common

common

common

common

K201

P-BUS

EX-02 ºÍÏ´ LED µÑÇàÅ¢ 7 ʋǹ

l LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡µ‹ÍẺ

ÁÑŵÔà¾Åç¡« l ÁÕǧ¨ÃºÑ¿à¿ÍϾÌÍÁµÑǵŒÒ¹·Ò¹ ¨íÒ¡Ñ´¡ÃÐáÊ l ¤Í¹à¹ç¡àµÍÏ P-BUS ÊíÒËÃѺàª×Íè Á µ‹Í¡Ñº P-Board ÃÙ»·Õè 6-6 ǧ¨ÃÊÁºÙó¢Í§ EX-02 ºÍÏ´¢Ñº LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 65


·Ñ§é ËÁ´áŌǵ‹ÍࢌҡѺäÍ«Õº¿Ñ à¿ÍÏ 74HC541 «Ö§è ·íÒ˹ŒÒ·Õãè ¹¡ÒâѺ LED ãˌÊNjҧ à¹×Íè §¨Ò¡¢Ò ¾Íϵ Data äÁ‹ÊÒÁÒö¢Ñºãˌ LED ÊNjҧ䴌â´ÂµÃ§ ¢ÒÍÔ¹¾Øµ¢Í§äÍ«Õ 74HC541 ¨Ðµ‹ÍࢌҡѺ ¤Í¹à¹ç¡àµÍÏ P-BUS ã¹¢³Ð·Õ¢è ÒËÇÁ¢Í§ LED ᵋÅÐËÅÑ¡¨Ðµ‹ÍࢌҡѺ¢Ò C0-C3 ·Õ¤è ͹à¹ç¡àµÍÏ P-BUS ¹Ñ¹è ¤×Í㹡ÒâѺ LED ·Ñ§é 4 ËÅÑ¡¨Ð㪌¾Íϵ Data 㹡ÒÃʋ§¢ŒÍÁÙŢͧᵋÅÐà«¡àÁ¹µ ¼‹Ò¹ äÍ«Õ 74HC541 áÅШíÒ¡Ñ´¡ÃÐáÊ·Õ»è ͇ ¹ãˌ¡ºÑ LED ´ŒÇµÑǵŒÒ¹·Ò¹¤‹Ò 100Ω áÅÐ㪌¾Íϵ Control 㹡ÒâѺᵋÅÐËÅÑ¡â´ÂµÃ§ LED µÑÇàÅ¢ 7 ʋǹ·Õãè ªŒº¹ºÍÏ´ EX-02 ໚¹áººá¤â·´Ã‹ÇÁ ´Ñ§¹Ñ¹é 㹡Òû‡Í¹ÊÑ­­Ò³ ãˌᡋ¢ÒÃÇÁ¢Í§ LED ¨ÐµŒÍ§»‡Í¹ÊÑ­­Ò³Åͨԡ “0” à¾×Íè ãˌ·Òí §Ò¹ áÅл‡Í¹¢ŒÍÁÙÅÅͨԡ “1” ãˌ¡Ñºà«¡àÁ¹µ·Õ赌ͧ¡ÒÃãˌµÔ´ÊNjҧ à¹×Íè §¨Ò¡¾Íϵ Control ¹Ñ¹é ÁÕºµÔ ¶Ö§ 3 ºÔµ·Õ¡è ÅѺʶҹÐÅͨԡÍÂÙ¤‹ Í× ºÔµ C0,C1 áÅÐ C3 ´Ñ§¹Ñ¹é á·¹·Õ¨è еŒÍ§»‡Í¹Åͨԡ “0” ãˌºµÔ àËŋҹշé Òí §Ò¹ ¡ÅѺµŒÍ§»‡Í¹Åͨԡ “1” á·¹ÊíÒËÃѺºÔµ C2 ¹Ñ¹é äÁ‹Á¡Õ ÒáÅѺʶҹÐÅͨԡ ¨Ö§ÊÒÁÒö»‡Í¹ÊÑ­­Ò³Åͨԡ䴌µÒÁ»¡µÔ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 66


¡Ò÷´Åͧ·Õè 8 ¢Ñº LED µÑÇàÅ¢ 7 ʋǹẺà´ÕÂè Ç à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-02 ºÍÏ´ LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. ÊÒÂàª×Íè Áµ‹Í IDC-20 1 àʌ¹

¡Ò÷´Åͧ 8.1 ÊÌҧʋǹ¡ÒÃà¡çº¢ŒÍÁÙÅ¡ÒÃáÊ´§¼Å¢Í§ LEDµÑÇàÅ¢ 7 ʋǹàÍÒänj㹵ÑÇá»ÃÍÒÏàϡ͋ ¹ â´Â ÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ䴌´§Ñ ¹Õé Dim Number(0 To 9) As Integer Private Sub Form_Load() Number(0) = &H3F Number(1) = &H6 Number(2) = &H5B Number(3) = &H4F Number(4) = &H66 Number(5) = &H6D Number(6) = &H7D Number(7) = &H7 Number(8) = &H7F Number(9) = &H6F End Sub

¨Ò¡â»Ãá¡ÃÁ¨ÐàËç¹Ç‹Ò¨ÐµŒÍ§¨Í§¾×¹é ·ÕËè ¹‹Ç¤ÇÒÁ¨íÒänj·µÕè ÇÑ á»Ãª×Íè Number ¡‹Í¹â´Â㪌 ÇÔ¸¡Õ ÒûÃСÒȤ‹ÒµÑÇá»Ã¨Ò¡¤íÒÊѧè DIM «Ö§è ¨ÐÍÂÙ·‹ ÊÕè Nj ¹ËÑǢͧâ»Ãá¡ÃÁ ËÅѧ¨Ò¡¹Õàé Á×Íè µŒÍ§¡Òà ¹íÒ¤‹ÒµÑÇá»Ã µÑÇã´ä»áÊ´§ ¡çÊÒÁÒö㪌¡ÒÃ͋ҹ¤‹Ò¨Ò¡µíÒá˹‹§¹Ñ¹é æ 䴌 8.2 µŒÍ§¡ÒÃãˌàÁ×Íè ÁÕ¡Òá´·Õ»è Á؆ Command1 áŌÇÁÕ¡ÒÃáÊ´§¤‹ÒµÑÇàÅ¢áÅÐà¾ÔÁè ¤‹ÒµÑÇàÅ¢¢Ö¹é ·Ø¡ ¤ÃÑ§é ·ÕÁè ¡Õ Òá´ â´Â¨Ð¡íÒ˹´ãˌáÊ´§¼Å·Õè LED µÑÇàÅ¢ 7 ʋǹËÅÑ¡¢ÇÒÊØ´à¾Õ§ËÅÑ¡à´ÕÂÇ ÊÒÁÒö à¢Õ¹â»Ãá¡ÃÁ䴌´§Ñ ¹Õé Dim Index As Integer Private Sub Command1_Click() If Index < 10 Then Out &H378, Number(Index)

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 67


Index = Index + 1 Else Index = 0 End If Out &H37A, &H5 End Sub

â»Ãá¡ÃÁ¹Õ¨é лÃСÒȤ‹ÒµÑÇá»Ã Index ¢Ö¹é ÁÒà¾×Íè 㪌㹡ÒÃ͌ҧ¶Ö§¢ŒÍÁÙŢͧ LED µÑÇàÅ¢ 7 ʋǹ·Õ¡è Òí ˹´ â´Â¨Ð¡íÒ˹´¤‹Ò¢Í§ Index änjÇҋ ¨ÐµŒÍ§Áդҋ ÍÂÙË ÐËNjҧ 0-9 ¨Ò¡¹Ñ¹é 㪌¤Òí Êѧè Out à¾×Íè ʋ§¤‹Ò¢ŒÍÁÙŢͧ LED µÑÇàÅ¢ 7 ʋǹÍÍ¡ä» áÅÐÊѧè ãˌ LED µÑÇàÅ¢ 7 ʋǹã¹ËÅÑ¡·Õµè ͌ §¡ÒÃãˌ áÊ´§¼ÅÁÕÅͨԡ໚¹ “0” ᵋà¹×Íè §¨Ò¡¢ÒËÇÁ¢Í§ LED µÑÇàÅ¢ 7 ʋǹ ËÅÑ¡¢ÇÒÊØ´º¹ºÍÏ´ EX-02 µ‹Íänj¡ºÑ ¢Ò C0 «Ö§è ÁÕ¡ÒáÅѺʶҹÐÅͨԡÍÂً ´Ñ§¹Ñ¹é ¡Òû‡Í¹¤‹Òãˌ·Òí §Ò¹¨Ö§µŒÍ§»‡Í¹¤‹ÒÅͨԡ “1” ÍÍ¡ä» áÅÐÊÒà˵طµÕè ͌ §»‡Í¹¤‹Ò෋ҡѺ “5” à¹×Íè §¨Ò¡Ç‹ÒäÁ‹µÍŒ §¡ÒÃãˌ LED µÑÇàÅ¢ 7 ʋǹËÅÑ¡ Í×è¹áÊ´§¼Å 8.2 àª×Íè Áµ‹Í P-Board ¡ÑººÍÏ´ EX-02 ´ŒÇÂÊÒ IDC-20 ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ P-BUS 8.3 ¨‹ÒÂä¿ãˌºÍÏ´·´Åͧ·Ñé§Êͧ ¨Ò¡¹Ñé¹Ãѹâ»Ãá¡ÃÁ·Õèà¢Õ¹¢Öé¹ã¹¢ŒÍ 8.1 Êѧࡵ¡ÒÃáÊ´§¼Å ¢Í§ LED º¹ºÍÏ´ EX-02 8.4 ·´Åͧᡌä¢â»Ãá¡ÃÁ à¾×Íè ãˌ LED ã¹ËÅÑ¡Í×¹è æ áÊ´§¼ÅºŒÒ§ â´Â»‡Í¹¤‹Ò´Ñ§¹Õé ¶ŒÒµŒÍ§¡ÒÃãˌËÅÑ¡·Õè 2 µÔ´ µŒÍ§»‡Í¹¢ŒÍÁÙŢͧ¢ÒËÇÁ´ŒÇ¤‹Ò &H6 ¶ŒÒµŒÍ§¡ÒÃãˌËÅÑ¡·Õè 3 µÔ´ µŒÍ§»‡Í¹¢ŒÍÁÙŢͧ¢ÒËÇÁ´ŒÇ¤‹Ò &H0 ¶ŒÒµŒÍ§¡ÒÃãˌËÅÑ¡·Õè 4 µÔ´ µŒÍ§»‡Í¹¢ŒÍÁÙŢͧ¢ÒËÇÁ´ŒÇ¤‹Ò &HC ¶ŒÒµŒÍ§¡ÒÃãˌ·¡Ø ËÅÑ¡´Ñº·Ñ§é ËÁ´µŒÍ§»‡Í¹¢ŒÍÁÙŢͧ¢ÒËÇÁ෋ҡѺ &H4 ¶ŒÒµŒÍ§¡ÒÃãˌ·¡Ø ËÅÑ¡µÔ´¾ÃŒÍÁ¡Ñ¹¨ÐµŒÍ§»‡Í¹¢ŒÍÁÙŢͧ¢ÒËÇÁ෋ҡѺ &HB ÊíÒËÃѺâ»Ãá¡ÃÁµÑÇÍ‹ҧ¼ÙŒãªŒ§Ò¹ÊÒÁÒö´ÙÃÒÂÅÐàÍÕ´áÅз´Åͧ㪌§Ò¹ä´Œ¨Ò¡ä¿Å LAB08.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 68


¡Ò÷´Åͧ·Õè 9 ¢Ñº LED µÑÇàÅ¢ 7 ʋǹẺÁÑŵÔà¾Åç¡« à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board

1 Ἃ¹

2. EX-02 ºÍÏ´ LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡ 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. ÊÒÂàª×Íè Áµ‹Í IDC-20

1 àʌ¹

¡Ò÷´Åͧ ËÅѧ¨Ò¡·ÕÊè ÒÁÒöʋ§¤‹ÒµÑÇàÅ¢ÍÍ¡ä»Âѧ LED µÑÇàÅ¢ 7 ʋǹã¹áµ‹ÅÐËÅѡ䴌áÅŒÇ ã¹¡Òà ·´Åͧ¹Õ¨é ÐÈÖ¡ÉÒ¶Ö§¡ÒâѺ LED µÑÇàÅ¢ 7 ʋǹᵋÅÐËÅÑ¡º¹ºÍÏ´ EX-02 µÔ´áÅдѺÊÅѺ¡Ñ¹ ´ŒÇ¤ÇÒÁàÃçÇ·ÕÊè §Ù ·ÕÊè ´Ø ·Õ¤è ÍÁ¾ÔÇàµÍÏÊÒÁÒö¨Ð·íҧҹ䴌 «Ö§è ¡ç¤Í× ¡ÒâѺẺÁÑŵÔà¾Åç¡«¹¹Ñè àͧ 9.1 à¢Õ¹â»Ãá¡ÃÁ·´Åͧ´Ñ§¹Õé Private Sub Command3_Click() Exits = False Do Out &H378, Number(1) Out &H37A, &H5 Call delay Out &H378, Number(2) Out &H37A, &H6 Call delay Out &H378, Number(3) Out &H37A, &H0 Call delay Out &H378, Number(4) Out &H37A, &HC Call delay Out &H37A, &H4 Loop Until Exits = True End Sub

â»Ãá¡ÃÁ¹Õ¨é ÐáÊ´§µÑÇàÅ¢ 1,2,3,4 ã¹áµ‹ÅÐËÅÑ¡¢Í§ LED µÑÇàÅ¢ 7 ʋǹ â´ÂàÃÔÁè ¨Ò¡Ê‹§¤‹Ò µÑÇàÅ¢ã¹ËÅÑ¡·Õè 1 Í͡仡‹Í¹ ¨Ò¡¹Ñ¹é ¡íÒ˹´ãˌËÅÑ¡·Õè 1 µÔ´ (ËÅÑ¡«ŒÒÂÊØ´) â´Â¡ÒÃʋ§Åͨԡ “0” ä»·Õè¢Ò¤ÍÁÁ͹¢Í§ËÅÑ¡·Õè 1 ¨Ò¡¹Ñé¹Ë¹‹Ç§àÇÅÒä»ÃÐÂÐ˹Öè§à¾×èÍãˌ LED µÑÇàÅ¢ 7 ʋǹ¤§¡Òà áÊ´§¼ÅàÍÒänj¡‹Í¹·ÕèáÊ´§¼Åã¹ËÅÑ¡µ‹Íä» â´ÂàÁ×èÍáÊ´§ã¹ËÅÑ¡¶Ñ´ä» ¡çãˌ»´¡ÒÃáÊ´§¼Åã¹ ËÅÑ¡¡‹Í¹Ë¹ŒÒ´ŒÇÂà¾×èÍãˌ¡ÒÃáÊ´§¤‹ÒµÃ§¡ÑºµíÒá˹‹§·Õè¶Ù¡µŒÍ§ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 69


ÊíÒËÃѺâ»Ãá¡ÃÁ˹‹Ç§àÇÅÒ¹Ñ¹é ¨Ð㪌¡ÒûÃѺ¨Ò¡Ê¡ÍÅŏºÒÏ à¹×Íè §¨Ò¡à¤Ã×Íè §¤ÍÁ¾ÔÇàµÍÏ àᵋÅÐà¤Ã×Íè §¨ÐÁÕ¤ÇÒÁàÃçÇ㹡Ò÷íÒ§Ò¹·Õäè Á‹à·‹Ò¡Ñ¹ ¡ÒáíÒ˹´¤‹Ò·Õàè ËÁÒÐÊÁ¨Ð·íÒãˌÁͧàË繡Òà ¡ÃоÃÔº·Õè LED µÑÇàÅ¢ 7 ʋǹ¹ŒÍ·ÕÊè ´Ø áÅÐÁÕ¤ÇÒÁÊNjҧÁÒ¡·ÕÊè ´Ø â´ÂÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ䴌 ´Ñ§¹Õé Sub delay() For i = 1 To HScroll1.Value DoEvents Next i End Sub

¹Ñ¹è ¤×ͤÇÒÁàÃçÇ㹡ÒÃ˹‹Ç§àÇÅÒ¢Ö¹é ÍÂÙ¡‹ ºÑ ¤‹Ò¢Í§Ê¡ÍÅŏºÒÏ ᵋ¶ÒŒ ¼Ù㌠ªŒ§Ò¹ÊÒÁÒöËÒ¤‹Ò ¤ÇÒÁàÃçÇ·Õµè ͌ §¡ÒÃ䴌áÅŒÇ ÊÒÁÒöà»ÅÕÂè ¹¤íÒÊѧè For i = 1 To Hscroll1.Value ໚¹ For I = 1 To “¤‹Ò·Õ赌ͧ¡ÒÔ ËÅѧ¨Ò¡·Õèãˌâ»Ãá¡ÃÁ·íÒ§Ò¹¨¹¤ÃºÃͺ˹Ö觤ÃÑé§áŌÇâ»Ãá¡ÃÁ¨ÐǹÅÙ»à¾×èÍ·íÒ¡ÒÃÊ᡹ LED µÑÇàÅ¢ 7 ʋǹÍÕ¡¤ÃÑ§é ¨¹¡Ç‹Ò¨ÐÁÕ¡Ò÷íÒãˌ¤Ò‹ µÑÇá»Ã Exits ໚¹¨ÃÔ§ (True) â´ÂµÑÇá»Ã Exits ¨Ð໚¹¨Ãԧ䴌à¹×Íè §¨Ò¡¡ÒᴤՏ Exit à¾×Íè ÍÍ¡¨Ò¡â»Ãá¡ÃÁ 9.2 àª×Íè Áµ‹Í P-Board ¡ÑººÍÏ´ EX-02 ´ŒÇÂÊÒ IDC-20 ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ P-BUS 9.3 ¨‹ÒÂä¿ãˌºÍÏ´·´Åͧ·Ñ§é Êͧ ¨Ò¡¹Ñ¹é Ãѹâ»Ãá¡ÃÁ·Õàè ¢Õ¹¢Ö¹é ã¹¢ŒÍ 9.1 Êѧࡵ¡ÒÃáÊ´§¼Å¢Í§ LED º¹ºÍÏ´ EX-02 9.4 ·´Åͧᡌä¢â»Ãá¡ÃÁ‹ÍÂ˹‹Ç§àÇÅÒà¾×Íè ãˌ¡ÒÃáÊ´§¼Å¢Í§ LED ´Õ·ÊÕè ´Ø à·‹Ò·Õ¨è ÐÊÒÁÒö·íÒ䴌

¹Ò́¡Ò¨Ò¡¤ÍÁ¾ÔÇàµÍÏáÊ´§¼Å·Õè LED µÑÇàÅ¢ 7 ʋǹ ¡ÒÃáÊ´§¼ÅµÑÇàÅ¢º¹ LED µÑÇàÅ¢ 7 ʋǹ ¼ÙŒãªŒ§Ò¹ÍÒ¨ÁͧNjÒäÁ‹ãª‹ÊÔ觨íÒ໚¹à¹×èͧ¨Ò¡ ¡ÒÃ㪌§Ò¹¤ÍÁ¾ÔÇàµÍϹ¹Ñé ¨ÐÁÕ¨ÍÀÒ¾ÊíÒËÃѺ¡ÒÃáÊ´§¼Å¤‹Òµ‹Ò§æ ÍÂÙá‹ ÅŒÇ áµ‹ã¹¡Ã³Õ·µÕè ͌ §¡Òà 㪌¤ÍÁ¾ÔÇàµÍÏ㹧ҹ¤Çº¤ØÁ੾ÒÐÍ‹ҧ«Ö§è ºÒ§¤Ãѧé äÁ‹¨Òí ໚¹µŒÍ§µ‹Í¨ÍÁ͹ÔàµÍÏänj ¡çÊÒÁÒö 㪌§Ò¹¤ÍÁ¾ÔÇàµÍÏãˌ¤Çº¤ØÁ¡Ò÷íҧҹ䴌 ´Ñ§µÑÇÍ‹ҧ·Õ¨è ÐÁÒ¹íÒàÊ¹Í à»š¹¡ÒùíÒàÍÒ°Ò¹àÇÅÒ ã¹¤ÍÁ¾ÔÇàµÍÏä»áÊ´§·Õè¨ÍáÊ´§¼Å LED µÑÇàÅ¢ 7 ʋǹ «Ö觷íÒãˌÊÒÁÒöÁͧàËç¹àÇÅÒ䴌㹠ÃÐÂзҧ·Õäè ¡Å¡Ç‹Ò¡ÒÃÁͧ·Õ¤è ÍÁ¾ÔÇàµÍÏâ´ÂµÃ§ áÅÐÊÒÁÒö¢ÂÒ¢¹Ò´¢Í§ LED µÑÇàÅ¢ 7 ʋǹ 䴌µÒÁµŒÍ§¡Òà ¹Í¡¨Ò¡¹ÕéÊíÒËÃѺ¡ÒÃ㪌§Ò¹à¾×èͤǺ¤ØÁ ¡çÊÒÁÒöÊÌҧà§×è͹䢢ͧàÇÅÒãˌÁÕ ¡ÒÃແ´»´ÍØ»¡Ã³ä¿¿‡ÒµÒÁ¨Ø´»ÃÐʧ¤·¡Õè Òí ˹´ä´ŒÍ¡Õ ´ŒÇ «Ö§è ¢Ö¹é ÍÂÙ¡‹ ºÑ ¼Ù㌠ªŒ§Ò¹¨Ðà¢Õ¹â»Ãá¡ÃÁ ¡ÒÃÊÌҧ¹Ò́¡Ò¨Ð㪌¡ÒÃáÊ´§¼Å·Õè¤ÍÁ¾ÔÇàµÍϤǺ¤Ù‹ä»´ŒÇ ´Ñ§¹Ñé¹·Õè¤ÍÁ¾ÔÇàµÍϨÐ㪌 à·ç¡«ºÍç ¡ Text1 㹡ÒÃáÊ´§¤‹ÒàÇÅÒ ÊíÒËÃѺ¡ÒÃá»Å§¤‹ÒàÇÅÒ¹Ñ¹é ¨Ð㪌 Timer2 ·íÒ¡ÒÃá»Å§ ¤‹ÒàÇÅÒãˌÍÂÙ㋠¹ÃٻẺ·ÕÊè ÒÁÒöʋ§ÍÍ¡ä»·Õè LED µÑÇàÅ¢ 7 ʋǹ䴌 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 70


9.5 à¢Õ¹â»Ãá¡ÃÁ·´Åͧº¹ Visual BASIC ´Ñ§¹Õé Private Sub Timer2_Timer() Text1.Text = Format(Now, “hh:mm:ss”) Index1 = Asc(Right(Text1.Text, 1)) - &H30 Index2 = Asc(Mid(Text1.Text, 7, 1)) - &H30 Index3 = Asc(Mid(Text1.Text, 5, 1)) - &H30 Index4 = Asc(Mid(Text1.Text, 4, 1)) - &H30 End Sub

¨Ò¡â»Ãá¡ÃÁ㹺Ã÷Ѵáá໚¹¡ÒáíÒ˹´¤‹ÒàÇÅÒ»˜¨¨ØºÑ¹ãˌ¡Ñº Text1 â´Â¡íÒ˹´ÃÙ» Ẻ¡ÒÃáÊ´§¼Å໚¹ ªÑÇè âÁ§,¹Ò·ÕáÅÐÇÔ¹Ò·Õ ºÃ÷Ѵ·Õè 2 ໚¹¡Òô֧¤‹Ò੾ÒеÑÇÍÑ¡ÉâÇÒÊØ´¢Í§ Text1 ÍÍ¡ÁÒã¹·Õè¹Õé¡ç¤×ÍËÅѡ˹‹Ç ¢Í§ÇÔ¹Ò·Õ¹¹Ñè àͧ â´Â㪌¤Òí Êѧè Right ¨Ò¡¹Ñ¹é ¡ç·Òí ¡ÒÃá»Å§µÑÇÍÑ¡ÉÃ·Õ´è §Ö ÍÍ¡ÁÒãˌ໚¹ÃËÑÊáÍÊ¡Õé «Öè§ÃËÑÊáÍÊ¡Õé¢Í§µÑÇàÅ¢¨ÐÁÕ¤‹ÒµÑé§áµ‹ &H30-&H39 ´Ñ§¹Ñé¹à¾×èÍãˌ䴌¤‹ÒµÑÇàÅ¢·Õè¶Ù¡µŒÍ§¨ÐµŒÍ§ ·íÒ¡ÒÃź¤‹ÒÃËÑÊáÍÊ¡Õ´é nj  &H30 ¡‹Í¹ ¤‹ÒµÑÇá»Ã Index1 ¡ç¨ÐÁդҋ ໚¹¤‹ÒµÑÇàÅ¢ 0-9 «Ö§è ¨ÐµŒÍ§ ¹íÒä»à»´µÒÃÒ§¢Í§ LED µÑÇàÅ¢ 7 ʋǹÍÕ¡¤Ãѧé ˹֧è ÊíÒËÃѺºÃ÷Ѵ·Õè 3-5 ¡ç໚¹ÅѡɳСÒ÷íÒ§Ò¹·Õ¤è ŌÒÂæ ¡Ñ¹ µ‹Ò§¡Ñ¹·Õµè Òí á˹‹§·Õ¨è д֧µÑÇÍÑ¡Éà ÍÍ¡ÁÒ¹Ñé¹à»š¹µíÒá˹‹§¶Ñ´¨Ò¡¤íÒÊÑè§áá àÁ×èÍ䴌¤‹ÒµÒÁµŒÍ§¡ÒÃáÅŒÇ ¤‹Ò·ÕèµÑÇàÅ¢¨Ð¶Ù¡à¡çºänj㹠Index1-Index4 ÊíÒËÃѺ¡ÒùíÒ¤‹ÒÍÍ¡ÁÒáÊ´§¹Ñ¹é ¨ÐãªŒÇ¸Ô ¡Õ ÒÃà´ÕÂǡѹ¡ÑºµÑÇÍ‹ҧáá ᵋ᷹·Õ¨è Ðãʋ¤Ò‹ µÑÇ àÅ¢¢Í§µíÒá˹‹§ÍÒÏàÏࢌÒ仵ç æ ¡çãˌ¹Òí ¤‹Ò Index1-Index4 ·Õ¤è Òí ¹Ç³àÍÒänjÁÒãʋࢌÒä»á·¹ â´ÂÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ䴌´§Ñ ¹Õé Private Sub Command3_Click() Exits = False Do Out &H378, Number(Index1) Out &H37A, &H5 Call delay Out &H378, Number(Index2) Out &H37A, &H6 Call delay Out &H378, Number(Index3) Out &H37A, &H0 Call delay Out &H378, Number(Index4) Out &H37A, &HC Call delay Out &H37A, &H4 Loop Until Exits = True End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 71


ÃÙ»·Õè P9-1 ˹ŒÒµ‹Ò§¢Í§â»Ãá¡ÃÁ·Õàè ¢Õ¹¢Ö¹é à¾×Íè ÊÌҧ¹Ò́¡ÒáÊ´§¼Å´ŒÇ LED µÑÇàÅ¢ 7 ʋǹ 4 ËÅÑ¡º¹ºÍÏ´ EX-02 㹡Ò÷´Åͧ·Õè 9 ¨Ò¡â»Ãá¡ÃÁ¨ÐàËç¹Ç‹Ò ʋǹ·Õàè »ÅÕÂè ¹á»Å§¡ç¤Í× ¡ÒÃãʋ¤Ò‹ µÑÇá»Ãŧä»ã¹ÍÒÏàÏ Number ã¹µÑÇÍ‹ҧ¹Õé໚¹¡ÒùíÒàÍÒ¤‹ÒàÇÅÒ ¹Ò·ÕáÅÐÇÔ¹Ò·ÕÁÒáÊ´§ ¼ÙŒãªŒ§Ò¹ÊÒÁÒö´Ñ´á»Å§ãˌáÊ´§ ໚¹ªÑèÇâÁ§¡Ñº¹Ò·Õ¡ç䴌 â´Âᡌä¢ã¹Ê‹Ç¹ Timer2 ÊíÒËÃѺ Timer2 ¹Ñé¹ãˌ¡íÒ˹´¤‹Ò Interval änj »ÃÐÁÒ³ 100-1000 ÁÔÅÅÔÇ¹Ô Ò·Õ â´Â˹ŒÒµÒ¢Í§â»Ãá¡ÃÁ áÊ´§ã¹ÃÙ»·Õè P9-1 áÅÐâ»Ãá¡ÃÁµÑÇÍ‹ҧ ÊÒÁÒöàÃÕ¡㪌§Ò¹ä´Œ¨Ò¡â»Ãá¡ÃÁ LAB09.VBP 9.6 Âѧ¤§àª×èÍÁµ‹Í P-Board ¡ÑººÍÏ´ EX-02 ·íÒ¡ÒÃÃѹâ»Ãá¡ÃÁ·Õèà¢Õ¹¢Öé¹ã¹¢ŒÍ·Õè 9.5 Êѧࡵ ¡ÒÃáÊ´§¼Å¢Í§ LED µÑÇàÅ¢ 7 ʋǹº¹ºÍÏ´ EX-02

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 72


º··Õè 7 ¡ÒâѺ LED Ẻ´ÍµàÁµÃÔ¡« ´ŒÇ¾Íϵ¢¹Ò¹

»˜¨¨Øº¹Ñ ºÍÏ´ EX-04A ·Õãè ªŒã¹º·¹Õäé ´ŒËÂØ´¡ÒüÅÔµ ´Ñ§¹Ñ¹é ¢ŒÍÁÙÅ㹺·¹Õ¨é §Ö ໚¹¡ÒùíÒàʹÍà¾×Íè ໚¹¤ÇÒÁÃÙàŒ ·‹Ò¹Ñ¹é

LED Ẻ´ÍµàÁµÃÔ¡« (dot-matrix LED) ໚¹¡ÒùíÒàÍÒ LED ÁÒµ‹ÍËÇÁã¹áºº·Ñ§é á¹Ç µÑ§é áÅÐá¹Ç¹Í¹ â´ÂáÊ´§¡Òõ‹Í LED Ẻ´ÍµàÁµÃÔ¡« ´Ñ§ÃÙ»·Õè 7-1 LED ´ÍµàÁµÃÔ¡«ÊÒí ËÃѺ ¡ÒÃáÊ´§µÑÇÍÑ¡ÉÃÀÒÉÒÍѧ¡ÄÉ 1 µÑǹѹé ʋǹãË­‹¨ÐÁÕ LED ã¹á¹Ç¹Í¹ 5 µÑÇáÅÐã¹á¹ÇµÑ§é 7 µÑÇ ´Ñ§¹Ñ¹é ¡ÒùíÒàÍÒ LED ´ÍµàÁµÃÔ¡« ÁÒáÊ´§¼Å¢ŒÍÁÙÅ 1 ËÅÑ¡¨ÐµŒÍ§ãªŒ·àÕè ¡çº¢ŒÍÁÙÅÍ‹ҧ¹ŒÍ 5 亵 ´Ñ§áÊ´§¡Òô֧¢ŒÍÁÙŢͧµÑÇÍÑ¡ÉÃᵋÅеÑÇã¹ÃÙ»·Õè 7-2 â´Â¢ŒÍÁÙÅã¹áµ‹ÅÐ亵¨ÐËÁÒ¶֧ ¼Å¡ÒõԴËÃ×ʹѺ¢Í§ LED ·Õáè Ê´§ ¡µÑÇÍ‹ҧ µŒÍ§¡ÒÃáÊ´§µÑÇÍÑ¡Éà “A” àÁ×Íè ¹íÒÁÒá¡໚¹ 亵áÅŒÇ ã¹á¶Çáá¨Ð䴌¤Ò‹ ෋ҡѺ 3FH ËÃ×Í 00111111 °Ò¹Êͧã¹á¶Ç·Õè 2 áÅÐá¶Ç·Õè 3 ¨Ð䴌 ¤‹Ò෋ҡѺ 48H ËÃ×Í 01001000 á¶Ç·Õè 4 ¨ÐÁդҋ ෋ҡѺ 3FH ઋ¹à´ÕÂǡѺá¶Çáá ʋǹá¶Ç·Õè 5 䴌¤Ò‹ ໚¹ 00H à¹×Íè §¨Ò¡äÁ‹µÍŒ §áÊ´§¤‹Òã´ æ ´Ñ§¹Ñ¹é ÊÃػ䴌Çҋ ÍÑ¡Éà “A” 1 µÑÇ ¨Ð»ÃСͺ´ŒÇ ¢ŒÍÁÙÅ 5 亵¤Í× 3FH,48H,48H,3FH,00H ÊíÒËÃѺµÑÇÍÑ¡ÉõÑÇÍ×¹è æ ¡çઋ¹à´ÕÂǡѹ ¨íÒ໚¹µŒÍ§ à¡çº´ŒÇ¢ŒÍÁÙÅ 5 亵àª‹¹à´ÕÂǡѹ â´ÂÇÔ¸¡Õ ÒÃà¡çº·Õ§è ҋ ·ÕÊè ´Ø ¹‹Ò¨Ð໚¹¡ÒÃ㪌µÇÑ á»ÃẺÍÒÏàÏ ¡ µÑÇÍ‹ҧ¡ÒÃà¡çºµÑÇÍÑ¡Éà “A” 䴌´§Ñ ¹Õé ,$ 4%

,# ,"

4$

,! 4#

4!

         

,

         

,

    

,

4"

         

亵5 = 00H 亵4 = 3FH 亵3 = 48H 亵2 = 48H 亵1 = 3FH

4 4 +

+

+!

+"

+#

ËÁÒÂà赯 ºÔµ D7 äÁ‹ãªŒ¡Òí ˹´à»š¹ "0"

ÃÙ»·Õè 7-1 áÊ´§Ç§¨ÃÀÒÂ㹢ͧ LED ´Íµ ÃÙ»·Õè 7-2 áÊ´§¡ÒáíÒ˹´¢ŒÍÁÙÅà¾×Íè áÊ´§µÑÇ àÁµÃÔ¡«¢¹Ò´ 7x5 ¨Ø´ ÍÑ¡Éâͧ LED ´ÍµàÁµÃÔ¡«¢¹Ò´ 7x5 ¨Ø´ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 73


Char(65,1) Char(65,2) Char(65,3) Char(65,4) Char(65,5)

= = = = =

&H3F &H48 &H48 &H3F &H0

¨Ò¡µÑÇÍ‹ҧ¹Õ¨é Ð㪌µÇÑ á»Ã Char áÅÐà¡çºà»š¹áººÍÒÏàÏ 2 ÁÔµÔ â´ÂàÅ¢´ŒÒ¹Ë¹ŒÒËÁÒ¶֧ ÃËÑÊáÍÊ¡Õ¢é ͧµÑÇÍÑ¡Éà àÅ¢ “65” áÊ´§¶Ö§µÑÇÍÑ¡Éà “A” µÑÇÍÑ¡É÷ÕÍè ÂÙ´‹ Ҍ ¹ËÅѧËÁÒ¶֧á¶Çᵋ ÅÐá¶Ç àÇÅÒàÃÕ¡㪌§Ò¹ÊÒÁÒö¹íÒÅíҴѺ¢Í§µÑÇÍÑ¡ÉÃáÅÐá¶Ç·Õµè ͌ §¡ÒùíÒä»áÊ´§¼Åä»ãªŒ§Ò¹ä´Œ «Ö§è ÍÒ¨¨ÐàÃÕ¡¡ÒÃà¡çº¹ÕÇé ҋ ¡ÒÃà¡çº¿Í¹µ¢Í§´ç͵àÁµÃÔ¡« «Ö§è ÁÕÃÒÂÅÐàÍÕ´´Ñ§¹Õé Sub init() ‘ A to Z Char(65,1)=&H3F:Char(65,2)=&H48:Char(65,3)=&H48:Char(65,4)=&H3F:Char(65,5)=&H0 Char(66,1)=&H7F:Char(66,2)=&H49:Char(66,3)=&H49:Char(66,4)=&H36:Char(66,5)=&H0 Char(67,1)=&H3E:Char(67,2)=&H41:Char(67,3)=&H41:Char(67,4)=&H22:Char(67,5)=&H0 Char(68,1)=&H7F:Char(68,2)=&H41:Char(68,3)=&H22:Char(68,4)=&H1C:Char(68,5)=&H0 Char(69,1)=&H7F:Char(69,2)=&H49:Char(69,3)=&H49:Char(69,4)=&H49:Char(69,5)=&H0 Char(70,1)=&H7F:Char(70,2)=&H48:Char(70,3)=&H48:Char(70,4)=&H48:Char(70,5)=&H0 Char(71,1)=&H3E:Char(71,2)=&H41:Char(71,3)=&H49:Char(71,4)=&H2E:Char(71,5)=&H0 Char(72,1)=&H7F:Char(72,2)=&H8:Char(72,3)=&H8:Char(72,4)=&H7F:Char(72,5)=&H0 Char(73,1)=&H0:Char(73,2)=&H41:Char(73,3)=&H7F:Char(73,4)=&H41:Char(73,5)=&H0 Char(74,1)=&H4E:Char(74,2)=&H41:Char(74,3)=&H7E:Char(74,4)=&H40:Char(74,5)=&H0 Char(75,1)=&H7F:Char(75,2)=&H14:Char(75,3)=&H22:Char(75,4)=&H41: Char(75,5)=&H0 Char(76,1)=&H7F:Char(76,2)=&H1:Char(76,3)=&H1:Char(76,4)=&H1:Char(76,5)=&H0 Char(77,1)=&H7F:Char(77,2)=&H20:Char(77,3)=&H10:Char(77,4)=&H20:Char(77,5)=&H7F Char(78,1)=&H7F:Char(78,2)=&H10:Char(78,3)=&H4:Char(78,4)=&H7F: Char(78,5)=&H0 Char(79,1)=&H3E:Char(79,2)=&H41:Char(79,3)=&H41:Char(79,4)=&H3E:Char(79,5)=&H0 Char(80,1)=&H7F:Char(80,2)=&H48:Char(80,3)=&H48:Char(80,4)=&H30:Char(80,5)=&H0 Char(81,1)=&H3E:Char(81,2)=&H41:Char(81,3)=&H45:Char(81,4)=&H3E:Char(81,5)=&H1 Char(82,1)=&H7F:Char(82,2)=&H4C:Char(82,3)=&H4A:Char(82,4)=&H31:Char(82,5)=&H0 Char(83,1)=&H32:Char(83,2)=&H49:Char(83,3)=&H49:Char(83,4)=&H26:Char(83,5)=&H0 Char(84,1)=&H40:Char(84,2)=&H40:Char(84,3)=&H7F:Char(84,4)=&H40:Char(84,5)=&H40 Char(85,1)=&H7E:Char(85,2)=&H1:Char(85,3)=&H1:Char(85,4)=&H7E:Char(85,5)=&H0 Char(86,1)=&H7C:Char(86,2)=&H2:Char(86,3)=&H1:Char(86,4)=&H2: Char(86,5)=&H7C Char(87,1)=&H7F:Char(87,2)=&H4:Char(87,3)=&H18:Char(87,4)=&H4:Char(87,5)=&H7F Char(88,1)=&H77:Char(88,2)=&H8:Char(88,3)=&H8:Char(88,4)=&H77:Char(88,5)=&H0 Char(89,1)=&H70:Char(89,2)=&H8:Char(89,3)=&H7:Char(89,4)=&H8:Char(89,5)=&H70 Char(90,1)=&H43:Char(90,2)=&H45:Char(90,3)=&H49:Char(90,4)=&H51:Char(90,5)=&H61 ‘ a to z Char(97,1)=&H17:Char(97,2)=&H15:Char(97,3)=&H15:Char(97,4)=&H1F:Char(97,5)=&H0 Char(98,1)=&H7E:Char(98,2)=&H11:Char(98,3)=&H11:Char(98,4)=&HE:Char(98,5)=&H0 Char(99,1)=&HE:Char(99,2)=&H11:Char(99,3)=&H11:Char(99,4)=&HA:Char(99,5)=&H0 Char(100,1)=&HE:Char(100,2)=&H11:Char(100,3)=&H11:Char(100,4)=&H7E:Char(100,5)=&H0 Char(101,1)=&HE:Char(101,2)=&H15:Char(101,3)=&H15:Char(101,4)=&HD:Char(101,5)=&H0

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 74


Char(102,1)=&H8:Char(102,2)=&H3F:Char(102,3)=&H48:Char(102,4)=&H20:Char(102,5)=&H0 Char(103,1)=&H39:Char(103,2)=&H45:Char(103,3)=&H45:Char(103,4)=&H3E:Char(103,5)=&H0 Char(104,1)=&H7F:Char(104,2)=&H10:Char(104,3)=&H10:Char(104,4)=&HF:Char(104,5)=&H0 Char(105,1)=&H0:Char(105,2)=&H0:Char(105,3)=&H5F:Char(105,4)=&H0:Char(105,5)=&H0 Char(106,1)=&H2:Char(106,2)=&H1:Char(106,3)=&H1:Char(106,4)=&H5E:Char(106,5)=&H0 Char(107,1)=&H7F:Char(107,2)=&H4:Char(107,3)=&HA:Char(107,4)=&H11:Char(107,5)= &H0 Char(108,1)=&H0:Char(108,2)=&H0:Char(108,3)=&H7F:Char(108,4)=&H0:Char(108,5)=&H0 Char(109,1)=&HF:Char(109,2)=&H10:Char(109,3)=&HF:Char(109,4)=&H10:Char(109,5)=&HF Char(110,1)=&H1F:Char(110,2)=&H8:Char(110,3)=&H10:Char(110,4)=&H1F:Char(110,5)=&H0 Char(111,1)=&HE:Char(111,2)=&H11:Char(111,3)=&H11:Char(111,4)=&HE:Char(111,5)=&H0 Char(112,1)=&H7F:Char(112,2)=&H44:Char(112,3)=&H44:Char(112,4)=&H38:Char(112,5)=&H0 Char(113,1)=&H38:Char(113,2)=&H44:Char(113,3)=&H44:Char(113,4)=&H7F:Char(113,5)=&H0 Char(114,1)=&H10:Char(114,2)=&HF:Char(114,3)=&H10:Char(114,4)=&H8:Char(114,5)=&H0 Char(115,1)=&H9:Char(115,2)=&H15:Char(115,3)=&H15:Char(115,4)=&H12:Char(115,5)=&H0 Char(116,1)=&H20:Char(116,2)=&H7E:Char(116,3)=&H21:Char(116,4)=&H2:Char(116,5)=&H0 Char(117,1)=&H1E:Char(117,2)=&H1:Char(117,3)=&H1:Char(117,4)=&H1E:Char(117,5)=&H0 Char(118,1)=&H1F:Char(118,2)=&H2:Char(118,3)=&H4:Char(118,4)=&H18:Char(118,5)=&H0 Char(119,1)=&H1F:Char(119,2)=&H2:Char(119,3)=&H4:Char(119,4)=&H2:Char(119,5)=&H1F Char(120,1)=&H1B:Char(120,2)=&H4:Char(120,3)=&H4:Char(120,4)=&H1B:Char(120,5)=&H0 Char(121,1)=&H79:Char(121,2)=&H5:Char(121,3)=&H5:Char(121,4)=&H7E:Char(121,5)=&H0 Char(122,1)=&H13:Char(122,2)=&H17:Char(122,3)=&H1D:Char(122,4)=&H19:Char(122,5)=&H0 ‘ 0 to 9 Char(48,1)=&H3E:Char(48,2)=&H41:Char(48,3)=&H41:Char(48,4)=&H3E:Char(48,5)=&H0 Char(49,1)=&H10:Char(49,2)=&H21:Char(49,3)=&H7F:Char(49,4)=&H1:Char(49,5)=&H0 Char(50,1)=&H6F:Char(50,2)=&H49:Char(50,3)=&H49:Char(50,4)=&H79:Char(50,5)=&H0 Char(51,1)=&H49:Char(51,2)=&H49:Char(51,3)=&H49:Char(51,4)=&H7F:Char(51,5)=&H0 Char(52,1)=&H78:Char(52,2)=&H8:Char(52,3)=&H8:Char(52,4)=&H7F:Char(52,5)=&H0 Char(53,1)=&H79:Char(53,2)=&H49:Char(53,3)=&H49:Char(53,4)=&H4F:Char(53,5)=&H0 Char(54,1)=&H7F:Char(54,2)=&H49:Char(54,3)=&H49:Char(54,4)=&H4F:Char(54,5)=&H0 Char(55,1)=&H40:Char(55,2)=&H47:Char(55,3)=&H48:Char(55,4)=&H70:Char(55,5)=&H0 Char(56,1)=&H7F:Char(56,2)=&H49:Char(56,3)=&H49:Char(56,4)=&H7F:Char(56,5)=&H0 Char(57,1)=&H79:Char(57,2)=&H49:Char(57,3)=&H49:Char(57,4)=&H7F:Char(57,5)=&H0 ‘ + - * / Char(43,1)=&H8:Char(43,2)=&H8:Char(43,3)=&H3E:Char(43,4)=&H8:Char(43,5)=&H8 Char(45,1)=&H8:Char(45,2)=&H8:Char(45,3)=&H8:Char(45,4)=&H8:Char(45,5)=&H8 Char(42,1)=&H22:Char(42,2)=&H14:Char(42,3)=&H8:Char(42,4)=&H14:Char(42,5)=&H22 Char(47,1)=&H22:Char(47,2)=&H4:Char(47,3)=&H8:Char(47,4)=&H10: Char(47,5)=&H22 ‘ < > [ ] ( ) Char(60,1)=&H8:Char(60,2)=&H14:Char(60,3)=&H22:Char(60,4)=&H41:Char(60,5)=&H0 Char(62,1)=&H41:Char(62,2)=&H22:Char(62,3)=&H14:Char(62,4)=&H8:Char(62,5)=&H0 Char(91,1)=&H0:Char(91,2)=&H7F:Char(91,3)=&H41:Char(91,4)=&H41:Char(91,5)=&H0 Char(93,1)=&H0:Char(93,2)=&H41:Char(93,3)=&H41:Char(93,4)=&H7F:Char(93,5)=&H0 Char(41,1)=&H0:Char(41,2)=&H1C:Char(41,3)=&H22:Char(41,4)=&H41:Char(41,5)=&H0 Char(42,1)=&H0:Char(42,2)=&H41:Char(42,3)=&H22:Char(42,4)=&H1C:Char(42,5)=&H0 ‘ “ : ; = _ Char(35,1)=&H0:Char(35,2)=&H60:Char(35,3)=&H0:Char(35,4)=&H60:Char(35,5)=&H0 Char(58,1)=&H0:Char(58,2)=&H36:Char(58,3)=&H36:Char(58,4)=&H0:Char(58,5)=&H0 Char(59,1)=&H0:Char(59,2)=&H31:Char(59,3)=&H36:Char(59,4)=&H0:Char(59,5)=&H0 Char(61,1)=&H0:Char(61,1)=&H14:Char(61,3)=&H14:Char(61,4)=&H14:Char(61,5)=&H0 Char(95,1)=&H1:Char(95,2)=&H1:Char(95,3)=&H1:Char(95,4)=&H1:Char(95,5)=&H0

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 75


‘ blank . , Char(33,1)=&H0:Char(33,2)=&H0:Char(33,3)=&H0:Char(33,4)=&H0:Char(33,5)=&H0 Char(46,1)=&H0:Char(46,2)=&H3:Char(46,3)=&H3:Char(46,4)=&H0:Char(46,5)=&H0 Char(44,1)=&H0:Char(44,2)=&H1:Char(44,3)=&H7:Char(44,4)=&H6:Char(44,5)=&H0

End Sub

¡ÒÃà¡çº¤‹Ò¿Í¹µµÇÑ ÍÑ¡Éà ¶ŒÒà¡çºãˌµÃ§¡ÑºÃËÑÊáÍÊ¡Õé ¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè àÃÕ¡¢ŒÍÁÙÅ ã¹ÍÒÏàÏ¡Êç ÒÁÒö·íÒ䴌äÁ‹ÂÒ¡ «Ö§è ¨Ð¡Å‹ÒÇã¹ÃÒÂÅÐàÍÕ´¡ÒÃàÃÕ¡㪌§Ò¹µ‹Íä»

EX-04A ºÍÏ´ LED Ẻ´ÍµàÁµÃÔ¡« 7x20 ¨Ø´ ºÍÏ´ EX-04A »ÃСͺ仴ŒÇ LED ·Õµè ͋ ÍÂÙà‹ »š¹áººàÁµÃÔ¡«¨Òí ¹Ç¹ 140 µÑÇ ÊÒÁÒö áÊ´§¼Å໚¹µÑÇÍÑ¡ÉÃ䴌 4 µÑÇ ã¹ÃÙ»·Õè 7-3 áÊ´§Ç§¨ÃÊÁºÙóáÅÐ˹ŒÒµÒµÅÍ´¨¹¤Ø³ÊÁºÑµ¢Ô ͧ ºÍÏ´ EX-04AÊÑ­­Ò³¤Çº¤ØÁ¡Ò÷íÒ§Ò¹·Ñ§é ËÁ´¨ÐÁÒ¨Ò¡¤Í¹à¹ç¡àµÍÏ MATRIX BUS «Ö§è ÁÕû٠Ẻ¡ÒèѴ¢ÒẺ UIC-10 ¨Ö§ÊÒÁÒöàª×Íè Áµ‹Í¡Ñº P-Board ¼‹Ò¹·Ò§ DATA BUS 䴌â´ÂµÃ§ ¡ÒÃÊ᡹ã¹á¹Ç¹Í¹¨Ð㪌 IC401 àºÍÏ 4017 µ‹ÍËÇÁ¡Ñº IC402 àºÍÏ ULN2003 áÅРǧ¨Ã¢Ñº«Ö§è ÊÌҧ¨Ò¡·ÃÒ¹«ÔÊàµÍÏ â´ÂÊÑ­­Ò³·Õãè ªŒ¤Çº¤ØÁ¡ÒÃÊ᡹·Ò§á¹Ç¹Í¹¤×Í ROW_CLK (RCK) áÅÐ ROW_RST (RRT) àÁ×Íè àÃÔÁè µŒ¹¨ÐÁÕÊ­ Ñ ­Ò³ ROW_RST ʋ§ÁÒ¡‹Í¹à¾×Íè ÃÕ૵¡Òà ·íÒ§Ò¹¢Í§ IC401 ¨Ò¡¹Ñ¹é ¨Ðʋ§ÊÑ­­Ò³ ROW_CLK à¾×Íè ãˌàÃÔÁè µŒ¹¡ÒÃÊ᡹·Ò§á¹Ç¹Í¹µ‹Íä» ¡ÒÃÊ᡹ã¹á¹ÇµÑ駫Öè§ÁÕ¨íҹǹá¶Ç¤‹Í¹¢ŒÒ§ÁÒ¡¹Ñé¹ ãªŒäÍ«ÕàºÍÏ 74HC595 «Öè§à»š¹äÍ«Õ ªÔ¿µÃÕ¨ÔÊàµÍÏà»ÅÕè¹ÃٻẺ¢ŒÍÁÙÅẺ͹ءÃÁãˌ໚¹áºº¢¹Ò¹ â´Â¨ÐµŒÍ§ãªŒäÍ«Õ 74HC595 ·Ñ§é ËÁ´ 3 µÑÇÁÒµ‹Í¾‹Ç§à¢ŒÒ´ŒÇ¡ѹà¾×Íè ãˌÊÒÁÒöʋ§ÊÑ­­Ò³áºº¢¹Ò¹ä´Œ·§Ñé ËÁ´ 20 ºÔµ ¡Òû‡Í¹ ÊÑ­­Ò³à¾×Íè ¢Ñºãˌª¿Ô µÃ¨Õ ÊÔ àµÍÏ·Òí §Ò¹ÁÒ¨Ò¡¤Í¹à¹ç¡àµÍÏ MATRIX BUS »ÃСͺ´ŒÇÂÊÑ­­Ò³ 5 àʌ¹´Ñ§¹Õé 1. ÊÑ­­Ò³¢ŒÍÁÙÅ COL_DIN (CD) ໚¹ÊÑ­­Ò³¢ŒÍÁÙÅ͹ءÃÁ·ÕÊè §‹ ÁÒ¨Ò¡¤ÍÁ¾ÔÇàµÍÏ ¼‹Ò¹ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ËÃ×Í͹ءÃÁ áŌÇʋ§µ‹ÍÁÒÂѧ 74HC595 µÑÇáá (IC406) 2. ÊÑ­­Ò³¹Ò́¡Ò COL_CLK (CCK) ໚¹ÊÑ­­Ò³¤Çº¤ØÁ¨Ñ§ËÇСÒ÷íÒ§Ò¹¢Í§ 74HC595 à¾×Íè ·íÒ¡ÒÃàÅ×Íè ¹¢ŒÍÁÙÅ ¨ÐàËç¹ä´ŒÇҋ µ‹ÍࢌҡѺ¢Ò CLK ¢Í§ 74HC595 ·Ø¡µÑÇ ·íÒãˌ äÍ«Õ·Ñé§ËÁ´ÁըѧËÇСÒ÷íÒ§Ò¹·ÕèµÃ§¡Ñ¹ 3. ÊÑ­­Ò³à¤ÅÕÂÏ COL_RST (CR) 㪌ÅҌ §¢ŒÍÁÙÅÀÒÂ㹪ԿµÃ¨Õ ÊÔ àµÍÏ·§Ñé ËÁ´ãˌ໚¹ “0” 4. ÊÑ­­Ò³áŵª COL_LE (CLE) 㪌´Òí çʶҹТŒÍÁÙÅ·Õ¢è ÒàÍÒµ¾µØ ¢Í§ 74HC595 à¾×èÍãˌ¢ŒÍÁÙÅáÊ´§¼Å·ÕèÂѧ¤§»ÃÒ¡¯ÍÂً áÁŒÇ‹Ò¨ÐÁÕ¡ÒÃà»ÅÕè¹á»Å§¢ŒÍÁÙÅãËÁ‹áŌǡçµÒÁ áÅÐàÁ×èÍ ¢ŒÍÁÙÅãËÁ‹·àÕè ¢ŒÒÁÒÁÕ¤ÇÒÁÊÁºÙóáÅеŒÍ§¡ÒÃà»ÅÕÂè ¹¢ŒÍÁÙÅ㹡ÒÃáÊ´§¼Å·Õè LED ´ÍµàÁµÃÔ¡« ãˌ ´ÔÊàÍàºÔÅÊÑ­­Ò³ COL_LE ¹Õé àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 76


15

13

14

Q1

RST

8

4

2

C401 0.1/50V

I1 3 I2 6 I3 7 I4 1 I5 4 I6 5 I7

2

IC401 CD4017

7 Q3 10 Q4 1 Q5 5 Q6 6 Q7

CLK EN Q2

CLK

16

+5V

14

11 Q3 10 Q4 16 Q5 13 Q6 12 Q7 R401-R407 8 1k x7

Q2

15

IC402 ULN2003

Q1

9

+5V

Q407 BD140

Q405 BD140

ÃÙ»·Õè 7-3 ǧ¨ÃÊÁºÙó¢Í§ EX-04A ºÍÏ´¢Ñº LED ´ÍµàÁµÃÔ¡«¢¹Ò´ 7x20 ¨Ø´

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 77 COL RST

COL D-IN COL OE ROW CLK

ROW RST

+5V COL LE

+5V

GND COL CLK

K401 MATRIX BUS

Q406 BD140

Q404 BD140

R428 220k*8

+5V

9

C402 0.1/50V

16

+5V

IC403 ULN2003

+5V

14

Q403 BD140

11 12

Q402 BD140

+5V

2

7

5,12 1

14 8

9

13 3 16 Q1 15 Q2 14 Q3 12 Q4 13 Q5 11 Q6 10 Q7 10 13

6 13

10

4 8

C403 0.1/50V

16

+5V

IC404 ULN2003

9

3

+5V

IC406 74HC595

8

R408-R414 100 x7

DSP401-DSP404 7x5 LED Dot-matrix x4

4

Q401 BD140

14

1 I1 2 I2 3 I3 5 I4 4 I5 6 I6 7

10 6 11 12

I7

13 3

10 13

15 S IN Q0 1 CLK Q1 2 LE Q2 3 RST Q3 4 OE Q4 5 Q5 6 Q6 SQH Q7 7 9

8

3 IC406 74HC595

8

C404 0.1/50V

16

IC407 74HC595 +5V

+5V 9

4 10 R415-R421 100 x7

4 10 6

1 I1 3 I2 2 I3 4 I4 6 I5 7 I6 I7

16 Q1 14 Q2 15 Q3 13 Q4 11 Q5 10 Q6 12 Q7 5

6 16 Q1 15 Q2 14 Q3 13 Q4 12 Q5 11

6

13

15 S IN Q0 1 CLK Q1 2 LE Q2 3 RST Q3 4 OE Q4 5 Q5 6 Q6 SQH Q7 7 9

Q6 1 I1 2 I2 3 I3 4 I4 5 I5 I6 14

IC405 ULN2003

8

IC408 74HC595

8

R422-R427 100 x7

OE 10 13

15 S IN Q0 1 CLK Q1 2 LE Q2 3 RST Q3 11 12

»˜¨¨Øº¹Ñ ºÍÏ´ EX-04A ·Õãè ªŒã¹º·¹Õäé ´ŒËÂØ´¡Òà ¼ÅÔµ ´Ñ§¹Ñ¹é ¢ŒÍÁÙÅ㹺·¹Õ¨é §Ö ໚¹¡ÒùíÒàʹÍà¾×Íè ໚¹¤ÇÒÁÃÙàŒ ·‹Ò¹Ñ¹é


EX-04A ºÍÏ´ LED ´ÍµàÁµÃÔ¡« 7x20 ¨Ø´ l 㪌ª¿ Ô µÃ¨Õ ÊÔ àµÍÏ㹡ÒÃʋ§¢ŒÍÁÙÅà¾×Íè áÊ´§

¼Å ¨Ö§ãªŒÊÒÂÊÑ­­Ò³¹ŒÍ l áÊ´§ä´Œ·§Ñé ¢ŒÍ¤ÇÒÁáÅÐÊÑ­Åѡɳ l ¤Í¹à¹ç¡àµÍÏ MATRIX BUS ÊíÒËÃѺ àª×Íè Áµ‹Í¡Ñº P-Board ¼‹Ò¹·Ò§ DATA BUS

ÃÙ»·Õè 7-4 ¤Ø³ÊÁºÑµáÔ ÅÐ˹ŒÒµÒ¢Í§ EX-04A ºÍÏ´¢Ñº LED ´ÍµàÁµÃÔ¡«¢¹Ò´ 7x20 ¨Ø´ »˜¨¨Øº¹Ñ ºÍÏ´ EX-04A ·Õãè ªŒã¹º·¹Õäé ´ŒËÂØ´¡ÒüÅÔµ ´Ñ§¹Ñ¹é ¢ŒÍÁÙÅ㹺·¹Õ¨é §Ö ໚¹ ¡ÒùíÒàʹÍà¾×Íè ໚¹¤ÇÒÁÃÙàŒ ·‹Ò¹Ñ¹é 5. ÊÑ­­Ò³áÊ´§¼ÅàÍÒµ¾µØ COL_OE (COE) 㪌àÍç¹àÍàºÔÅ¡ÒÃáÊ´§¼Å·Ò§àÍÒµ¾µØ ¢Í§ 74HC595 ·íÒ§Ò¹´ŒÇÂÅͨԡ “0” ¹Ñ¹è ¤×Í ËÒ¡ÊÑ­­Ò³¹Õàé »š¹ “1” ¨ÐäÁ‹Á¢Õ ͌ ÁÙÅ»ÃÒ¡¯ÍÍ¡ä»·Õ¢è Ò àÍÒµ¾µØ ¢Í§ 74HC595 ᵋ¶ÒŒ µŒÍ§¡ÒÃãˌ¢ÍŒ ÁÙÅ»ÃÒ¡¯µŒÍ§·íÒãˌʭ Ñ ­Ò³¹Õàé »š¹ “0” ÅíҴѺ¢Ñ¹é ¡ÒõԴµ‹Í¡ÑºªÔ¿µÃ¨Õ ÊÔ àµÍÏ ÁÕ´§Ñ ¹Õé 1. à¤ÅÕÂϤҋ ¢ŒÍÁÙÅà¾×Íè ãˌṋã¨Ç‹ÒàÇÅÒʋ§¤‹Ò¢ŒÍÁÙÅãËÁ‹ÍÍ¡ä» äÁ‹Á¢Õ ͌ ÁÙÅà´ÔÁµ¡¤ŒÒ§ 2. ·íÒ¡ÒÃàÍç¹àÍàºÔÅàÍÒµ¾µØ â´Âʋ§ÊÑ­­Ò³ COL_OE (áÍ¡µÕ¿Åͨԡ “0”) 3. ʋ§ÊÑ­­Ò³ COL_LE 1 ÅÙ¡ à¾×Íè ÃÑ¡ÉÒ¤‹ÒàÍÒµ¾µØ änj 4. ʋ§¢ŒÍÁÙÅ COL_DIN 1 ºÔµ 5. ʋ§ÊÑ­­Ò³¹Ò́¡ÒÍÍ¡ä» 1 ÅÙ¡à¾×Íè àÅ×Íè ¹¢ŒÍÁÙÅ 6. ·íÒµÒÁ¢ŒÍ 4 áÅÐ 5 ãËÁ‹Í¡Õ ¤ÃÑ§é ¨¹¡Ç‹Ò¢ŒÍÁÙŨÐʋ§Í͡价ѧé ËÁ´

¡ÒùíÒ¢ŒÍÁÙÅà¾×Íè áÊ´§¼Åº¹ºÍÏ´ EX-04A ÁÕ¢¹Ñé µÍ¹â´ÂÊÃØ»´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ COL_RESET áÅÐ ROW_RESET à¾×Íè à¤ÅÕÂϢ͌ ÁÙŷѧé ËÁ´ 2. ʋ§ÊÑ­­Ò³ COL_LE 1 ÅÙ¡ à¾×Íè ÃÑ¡ÉÒ¤‹ÒàÍÒµ¾µØ änj 3. ʋ§¢ŒÍÁÙÅ COL_DIN 1 ºÔµ 4. ʋ§ÊÑ­­Ò³¹Ò́¡ÒÍÍ¡ä» 1 ÅÙ¡à¾×Íè àÅ×Íè ¹¢ŒÍÁÙÅ 5. ·íÒµÒÁ¢ŒÍ 4 áÅÐ 5 ãËÁ‹Í¡Õ ¤ÃÑ§é ¨¹¡Ç‹Ò¢ŒÍÁÙŨÐʋ§Í͡价ѧé ËÁ´ 20 ËÅÑ¡ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 78


6. ·íÒ¡ÒÃàÍç¹àÍàºÔÅàÍÒµ¾µØ â´Âʋ§ÊÑ­­Ò³ COL_OE (áÍ¡µÕ¿Åͨԡ “0”) 7. ʋ§ÊÑ­­Ò³ ROW_CLK 1 ÅÙ¡à¾×Íè ãˌà¡Ô´¡ÒÃáÊ´§¼Å·Õáè ¶ÇËÃ×ÍâÃǏº¹ÊØ´ (á¶Ç·Õè 1) 8. ·íÒ¡ÒôÔÊàÍàºÔÅàÍÒµ¾µØ ·Ò§¤ÍÅÑÁ¹ â´Âʋ§ÊÑ­­Ò³ COL_OE Åͨԡ “1” 9. ʋ§ÊÑ­­Ò³ COL_RESET à¾×Íè à¤ÅÕÂϢ͌ ÁÙÅ·Ò§¤ÍÅÑÁ¹·§Ñé ËÁ´ 10. ¨Ò¡¹Ñ¹é ·íÒ¡ÒÃʋ§¢ŒÍÁÙÅã¹á¹Ç¤ÍÅÑÁ¹·§Ñé 20 ¨Ø´ÍÕ¡¤Ãѧé 11. ʋ§ÊÑ­­Ò³ ROW_CLK 1 ÅÙ¡ à¾×Íè àµÃÕÂÁ¡ÒÃáÊ´§¼Åã¹á¶Ç¶Ñ´ä» 12. ʋ§ÊÑ­­Ò³àÍç¹àÍàºÔÅàÍÒµ¾µØ ¨Ðà¡Ô´¡ÒÃáÊ´§¼Åã¹á¶Ç¶Ñ´ÁÒ 13. ·íÒµÒÁ¢Ñ¹é µÍ¹¢ŒÍ 8-11 ¨¹¤Ãº 7 ¤ÃÑ§é ¡ç¨Ð䴌¡ÒÃáÊ´§¼Åº¹ºÍÏ´ EX-04A ¤Ãº·Ñ§é 7N20 ¨Ø´ 14. ·íÒ¡ÒÃÃÕ૵¢ŒÍÁÙŷѧé ËÁ´áŌÇàÃÔÁè µŒ¹·íÒ§Ò¹ÃͺãËÁ‹

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 79


¡Ò÷´Åͧ·Õè 10 ¢Ñº LED ´ÍµàÁµÃÔ¡« 7x20 ¨Ø´ à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³

1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board ¾ÃŒÍÁÊÒÂàª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ 1 ªØ´ 2. EX-04A ºÍÏ´ LED ´ÍµàÁµÃÔ¡« 7x20 ¨Ø´ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. ÊÒÂàª×Íè Áµ‹Í IDC-10 1 àʌ¹ »˜¨¨Øº¹Ñ ºÍÏ´ EX-04A ·Õãè ªŒã¹º·¹Õäé ´ŒËÂØ´¡ÒüÅÔµ ´Ñ§¹Ñ¹é ¢ŒÍÁÙÅ㹺·¹Õ¨é §Ö ໚¹ ¡ÒùíÒàʹÍà¾×Íè ໚¹¤ÇÒÁÃÙàŒ ·‹Ò¹Ñ¹é

¡Ò÷´Åͧ¢Ñº LED ´ÍµàÁµÃÔ¡«àº×Íé §µŒ¹

10.1 àÅ×Í¡àÁ¹Ù Project à Components à Tab Controls ¨Ð»ÃÒ¡¯Ë¹ŒÒµ‹Ò§ãˌà¾ÔÁè àµÔÁ¤Í¹â·ÃÅ áŌÇàÅ×Í¡¤Í¹â·ÃÅ HighPerformanceCounter ´Ñ§ÃÙ»·Õè 10-1 ¶ŒÒäÁ‹¾ºª×èͤ͹â·ÃŹÕé ¡´»Ø†Á Browse áŌÇàÅ×Í¡ä¿Å HPCOUNT.OCX ã¹ä´àáµÍÃÕè Windows\System ᵋ¶ÒŒ ËÒ¡äÁ‹ÁÊÕ ÒÁÒö ¤Ñ´ÅÍ¡ä¿Å hpcount.ocx ¨Ò¡á¼‹¹«Õ´ÃÕ ÍÁ PC interface : Parallel port Experiment ã¹ä´àÃç¡ µÍÃÕè Software\ocx ä»à¡çºänj·Õè Windows\System ¨Ò¡¹Ñ¹é ¨ÐÊÒÁÒöàÃÕ¡㪌䴌·¹Ñ ·Õ 10.2 ÊÌҧ¿ÍÏÁ´Ñ§ÃÙ»·Õè 10-2 áÅÐà»ÅÕÂè ¹¤Ø³ÊÁºÑµ¢Ô ͧ CommandButton áÅÐ hpCounter µÒÁ·Õè ¡íÒ˹´ã¹ÃÙ» 10.3 à¢Õ¹â»Ãá¡ÃÁ‹ÍÂÊíÒËÃѺ¡ÒÃÊÌҧÊÑ­­Ò³µ‹Ò§æ·Õãè ªŒã¹¡ÒâѺ´ÍµàÁµÃÔ¡« ´Ñ§¹Õé

hpCounter Name

hp

CommandButton Name

cmdRun

Caption

Run

ÃÙ»·Õè P10-1 ¡ÒÃàÅ×Í¡ HighPerformance ÃÙ»·Õè P10-2 áÊ´§¡ÒÃÊÌҧ¿ÍÏÁÊíÒËÃѺ Counter à¾ÔÁè à¾×Íè 㪌ã¹â»Ãá¡ÃÁ·´Åͧ¢Ñº ¡Ò÷´Åͧ¾ÃŒÍÁ¡Ñº¡ÒáíÒ˹´¤Ø³ÊÁºÑµÔ LED ´ÍµàÁµÃÔ¡« ¢Í§¤Í¹â·Ãŵ‹Ò§æ ·Õãè ªŒ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 80


â»Ãá¡ÃÁ‹Í Initial ÊÑ­­Ò³ã¹¾Íϵ Private Sub InitialDatabus() Out &H378, &H18 End Sub

‘ Initial databus

â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³¹Ò́¡Òã¹á¹Ç¤ÍÅÑÁ¹ Private Sub ColCLK() Out &H378, Inp(&H378) Xor 1 Out &H378, Inp(&H378) Xor 1 End Sub

‘ Toggle column clock ‘ Toggle column clock

â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³¹Ò́¡Òã¹á¹Çá¶Ç (âÃǏ) Private Sub RowCLK() Out &H378, Inp(&H378) Xor &H40 Out &H378, Inp(&H378) Xor &H40 End Sub

‘ Toggle row clock ‘ Toggle row clock

â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³ÃÕ૵¢ŒÍÁÙŤÍÅÑÁ¹ Private Sub ColRST() Out &H378, Inp(&H378) Xor &H8 Out &H378, Inp(&H378) Xor &H8 End Sub

‘ Toggle column reset ‘ Toggle column reset

â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³ÃÕ૵¢ŒÍÁÙÅá¶Ç Private Sub RowRST() Out &H378, Inp(&H378) Xor &H80 Out &H378, Inp(&H378) Xor &H80

‘ Toggle row reset ‘ Toggle row reset

End Sub

â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³áŵª¢ÍŒ ÁÙŤÍÅÑÁ¹ Private Sub ColLE() Out &H378, Inp(&H378) Xor &H2 Out &H378, Inp(&H378) Xor &H2 End Sub

‘ Toggle column latch ‘ Toggle column latch

â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³¢ŒÍÁÙŤÍÅÑÁ¹ Private Sub ColDA(ByVal Logic As Boolean) If Logic Then Out &H378, Inp(&H378) Or &H4 ‘ Set column data to high Else Out &H378, Inp(&H378) And &HFB ‘ Set column data to low End If End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 81


â»Ãá¡ÃÁ‹ÍÂÊÌҧÊÑ­­Ò³àÍç¹àÍàºÔÅ¢ŒÍÁÙŤÍÅÑÁ¹ Private Sub ColOE(ByVal Logic As Boolean) If Logic Then Out &H378, Inp(&H378) Or &H10 ‘ Set column output enable to high Else Out &H378, Inp(&H378) And &HEF ‘ Set column output enable to low End If End Sub

â´Ââ»Ãá¡ÃÁ‹ Í ÂÊÌ Ò §ÊÑ ­ ­Ò³¹Ò́ ¡ Ò, ÊÑ ­ ­Ò³ÃÕ à «µ áÅÐÊÑ ­ ­Ò³áŵ« ¨ÐÊÌҧÊÑ­­Ò³à»š¹¾ÑÅʏ 1 ÅÙ¡ 10.4 à¢Õ¹â»Ãá¡ÃÁÊíÒËÃѺàµÃÕÂÁ DATA BUS à¾×Íè ʋ§¢ŒÍÁÙÅ·Õàè ˵ءÒó Form_Load ´Ñ§¹Õé Private Sub Form_Load() InitialDatabus RowRST ColRST ColLE End Sub

‘ ‘ ‘ ‘

Initial databus Reset row counter Reset column data Latch column data

¢Ñ¹é µÍ¹¡Ò÷íÒ§Ò¹ÁÕ´§Ñ ¹Õé 10.4.1 Initial data bus â´Âʋ§¢ŒÍÁÙÅ &H18 à¾×Íè ãˌ¾ÍϵÍÂÙ㋠¹ÊÀÒÇÐàÃÔÁè µŒ¹ 10.4.2 ʋ§ÊÑ­­Ò³ÃÕ૵á¶Ç à¾×Íè à¤ÅÕÂÏà¤Ò¹àµÍÏ 10.4.3 ʋ§ÊÑ­­Ò³ÃÕ૵¤ÍÅÑÁ¹ à¾×Íè à¤ÅÕϢ͌ ÁÙÅ㹪ԿµÃ¨Õ ÊÔ àµÍÏ ãˌ·¡Ø ¤ÍÅÑÁ¹à»š¹ 0 10.4.4 ʋ§ÊÑ­­Ò³áŵ« à¾×Íè áŵ«¢ÍŒ ÁÙŨҡªÔ¿µÃ¨Õ ÊÔ àµÍÏ 10.5 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdRun_Click à¾×Íè ·´Åͧ¡Ò÷íÒ§Ò¹¢Í§ºÍÏ´´Ñ§¹Õé Private Sub cmdRun_Click() Dim i As Integer Dim j As Integer ColOE False For i = 0 To 6 RowCLK For j = 19 To 0 Step -1 DoEvents ColDA True ColCLK ColLE hp.Delay_ms 100 Next j ColRST ColLE Next i RowRST ColOE True End Sub

‘ Column data output enable ‘ send row clock

‘ ‘ ‘ ‘

send data 1 to column data send column clock Latch column data Delay 100 ms

‘ Reset column data ‘ Latch column data ‘ Reset row counter ‘ Column data output disable

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 82


ÁÕ¢¹Ñé µÍ¹¡Ò÷íÒ§Ò¹´Ñ§¹Õé 10.5.1 àÍç¹àÍàºÔÅàÍÒµ¾µØ ¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏãˌáÊ´§¢ŒÍÁÙÅ㹺ѿà¿ÍϢͧªÔ¿µÃ¨Õ ÊÔ àµÍÏ 10.5.2 ÊÌҧÊÑ­­Ò³¹Ò́¡Òãˌà¤Ò¹àµÍÏ à¾×Íè àÃÔÁè áÊ´§¼Åã¹á¶Çáá ( á¶Çº¹ÊØ´ ) 10.5.3 ʋ§¢ŒÍÁÙÅÅͨԡ 1 ä»·Õºè ¿Ñ à¿ÍϢͧªÔ¿µÃ¨Õ ÊÔ àµÍÏ 10.5.4 ʋ§ÊÑ­­Ò³¹Ò́¡Òä»·Õªè ¿Ô µÃ¨Õ ÊÔ àµÍÏ à¾×Íè ÃѺ¢ŒÍÁÙÅࢌÒÊÙº‹ ¿Ñ à¿ÍÏ ÊØ´)

10.5.5 áŵ«¢ÍŒ ÁÙÅ㹺ѿà¿ÍÏ ¨ÐàËç¹ LED µÔ´·Õ¨è ´Ø º¹«ŒÒº¹´ÍµàÁµÃÔ¡«µÇÑ áá (µÑÇ«ŒÒ 10.5.6 ˹‹Ç§àÇÅÒ 100 ÁÔÅÅÔÇ¹Ô Ò·Õ

10.5.7 ·íÒ«éÒí ¢ŒÍ 10.5.3 ¨¹¶Ö§¢ŒÍ 10.5.6 ãˌ¤Ãº 20 Ãͺ à¾×Íè ʋ§¢ŒÍÁÙÅãˌ¤Ãº 20 ¤ÍÅÑÁ¹ ã¹áµ‹ÅÐÃͺ LED ¨ÐµÔ´à¾ÔÁè ¢Ö¹é ·ÕÅдǧ 10.5.8 ÃÕ૵ºÑ¿à¿ÍϢͧªÔ¿µÃ¨Õ ÊÔ àµÍÏ à¾×Íè àµÃÕÂÁ¡ÒÃʋ§¢ŒÍÁÙÅá¶Ç¶Ñ´ä» 10.5.9 áŵ«¢ÍŒ ÁÙÅ㹺ѿà¿ÍÏ 10.5.10 ·íÒ«éÒí ¢ŒÍ 10.5.1 ¨¹¶Ö§¢ŒÍ 10.5.10 ãˌ¤Ãº 7 Ãͺ à¾×Íè ʋ§¢ŒÍÁÙÅãˌ¤Ãº 7 á¶Ç 10.5.11 àÁ×Íè áÊ´§¢ŒÍÁÙŤú·Ø¡¤ÍÅÑÁ¹áÅÐá¶Ç ʋ§ÊÑ­­Ò³ÃÕ૵ãˌà¤Ò¹àµÍÏà¾×Íè àµÃÕÂÁ ¡ÒÃáÊ´§¼Å㹤ÃÑ駵‹Íä» 10.5.12 ´ÔÊàÍàºÔÅàÍÒµ¾µØ ¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏ ¼Å¡Ò÷íÒ§Ò¹¢Í§â»Ãá¡ÃÁ¹Õé ¨ÐáÊ´§¼Åº¹ LED ´ÍµàÁµÃÔ¡«µÔ´¤Ãº·Ø¡¤ÍÅÑÁ¹ ·ÕÅÐá¶Ç µÑÇÍ‹ҧ¢Í§â»Ãá¡ÃÁ´Ù䴌·äÕè ¿Å LAB10A .vbp

¡Ò÷´Åͧ¢Ñº LED ´ÍµàÁµÃÔ¡«ã¹ÅѡɳСíÒ˹´¨Ø´áÊ´§¼Å àÁ×èÍÊÒÁÒöáÊ´§¼Å䴌¤Ãº·Ø¡¨Ø´ ¡Ò÷´Åͧµ‹Í仨ÐáÊ´§¢ŒÍÁÙŵÒÁ·Õè¡íÒ˹´â´Â㪌 ¤Í¹â·ÃÅ MsFlexGrid 10.6 à¾ÔÁè ¤Í¹â·ÃÅ Microsoft FlexGrid Control 6.0 â´ÂàÅ×Í¡àÁ¹Ù Projecà Components à Tab Controls 10.7 àÅ×Í¡¤Í¹â·ÃÅ Microsoft FlexGrid Control 6.0 ¶ŒÒäÁ‹¾ºª×Íè ¤Í¹â·ÃŹÕé ¡´»ØÁ† Browse áŌÇàÅ×Í¡ä¿Å MSFLXGRD.OCX ã¹ä´àáµÍÃÕè Windows\System ´Ñ§ÃÙ»·Õè P10-3 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 83


10.8 ·í Ò ¡ÒÃà¾Ôè Á ¤Í¹â·ÃÅ FlexGrid áÅÐ CommandButton º¹¿ÍÏÁ´Ñ§ÃÙ»·Õè 10-4 ¾ÃŒÍÁ ·Ñ駡íÒ˹´¤Ø³ÊÁºÑµÔµÒÁ·ÕèáÊ´§ã¹ÃÙ»´ŒÇ 10.9 à¢Õ¹â»Ãá¡ÃÁ‹Í InitialFlexGrid à¾×Íè ¡í Ò Ë¹´¤Ø ³ ÊÁºÑ µÔ ¢ ͧ flx ãˌ à »š ¹ µÒÃÒ§ÊÕè àËÅÕèÂÁ¢¹Ò´ 7x20 ¨íÒÅͧ໚¹Ê‹Ç¹áÊ´§¼Å LED ´ÍµàÁµÃÔ¡«¢Í§ºÍÏ´ EX-04A ´Ñ§¹Õé ÃÙ»·Õè P10-3 ¡ÒÃàÅ×Í¡¤Í¹â·ÃÅ Microsoft FlexGrid Control 6.0 à¾×èÍ㪌ã¹â»Ãá¡ÃÁ ·´Åͧ¢Ñº LED ´ÍµàÁµÃÔ¡«

Private Sub InitialFlexGrid() Dim i As Integer For i = 0 To 6 flx.RowHeight(i) = 200 ‘ Set cell height = 200 Next i For i = 0 To 19 flx.ColWidth(i) = 200 ‘ Set cell width = 200 Next i End Sub

¡ÒÃ͌ҧµíÒá˹‹§º¹ FlexGrid ¨ÐÍÂÙ㋠¹ ÅѡɳеÒÃÒ§ ¡ÒÃà¡çº¢ŒÍÁÙŤÇÃ㪌µÑÇá»Ã·Õè FlexGrid CommandButton ໚¹ªØ´ÍÒÏàÏ ã¹·Õ¹è ¨Õé Ð㪌ÍÒÏàÏ 2 ÁÔµÔ ¢¹Ò´ 7x20 àÁ×Íè 㪌¤Çº¤Ù¡‹ ºÑ FlexGrid ¨Ð·íÒãˌ¡Ò÷íÒ §Ò¹§‹ÒÂ¢Ö¹é µÑÇá»Ã¹Õ¨é Ð㪌ã¹ÅѡɳеÑÇá»ÃÃÇÁ (Global variable) ÊÒÁÒöàÃÕ Â ¡ãªŒ ä ´Œ ·Ø ¡ â»Ãá¡ÃÁ‹ÍÂ㹿ÍÏÁ â´ÂµŒÍ§»ÃСÒȵÑÇá»Ã ·ÕÊè Nj ¹ General Declaration ¤×Íʋǹ·ÕÍè ÂÙº‹ ¹ÊØ´ ¢Í§â»Ãá¡ÃÁ ¡ÒûÃСÒȵÑÇá»Ã¨ÐµŒÍ§à¢Õ¹ ÃÙ»·Õè P10-4 áÊ´§¡ÒÃÊÌҧ¿ÍÏÁÊíÒËÃѺ â»Ãá¡ÃÁ´Ñ§¹Õé ¡Ò÷´Åͧ¾ÃŒÍÁ¡Ñº¡ÒáíÒ˹´¤Ø³ÊÁºÑµÔ Dim flgDot(0 To 19, 0 To 6) As ¢Í§¤Í¹â·ÃÅ FlexGrid áÅÐ Command Boolean Button ÊíÒËÃѺ¡Ò÷´Åͧ¢Ñº LED ´Íµ «Öè§ÊÒÁÒö¨íÒÅͧÅѡɳТͧµÑÇá»Ã àÁµÃÔ¡« 7x20 ¼‹Ò¹ºÍÏ´ EX-04A 䴌´Ñ§¹Õé Name

flx

Name

cmdRndData

Cols

20

Caption

Random

Rows

7

FixedCols

0

FixedRows

0

FocusRect

0-flexFocusNone

HighLight

0-flexHighlightNever

High

1455

Width

4000

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 84


0

1

2

...

19

flgDot(0,0)

flgDot(1,0)

flgDot(2,0)

...

flgDot(19,0)

flgDot(0,1)

flgDot(1,1)

flgDot(2,1)

...

flgDot(19,1)

flgDot(0,2)

flgDot(1,2)

flgDot(2,2)

...

flgDot(19,2)

...

...

...

...

...

flgDot(0,6)

flgDot(1,6)

flgDot(2,6)

...

flgDot(19,6)

10.10 àÃÕ¡㪌â»Ãá¡ÃÁ‹Í InitialFlexGrid áÅÐà¤ÅÕÂϤҋ µÑÇá»Ã flgDot ·Õàè ˵ءÒó Form_Load Private Sub Form_Load() Dim i As Integer Dim j As Integer InitialFlexGrid For i = 0 To 6 For j = 0 To 19 flgDot(j, i) = False Next j Next i InitialDatabus RowRST ColRST ColLE End Sub

‘ Clear all dot matrix buffer

‘ ‘ ‘ ‘

Initial databus Reset row counter Reset column data Latch column data

10.11 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó flx_Click Private Sub flx_Click() flx.Visible = False If flx.CellBackColor = vbRed Then flx.CellBackColor = vbWhite flgDot(flx.Col, flx.Row) = False ‘ Clear point dot matrix buffer Else flx.CellBackColor = vbRed flgDot(flx.Col, flx.Row) = True ‘ Set point dot matrix buffer End If flx.Visible = True End Sub

àÁ×èÍ㪌àÁÒʏ¤ÅÔé¡·Õè flx ¨ÐÁÕÊÕá´§µÔ´¢Öé¹ã¹ª‹Í§·Õè¤ÅÔé¡ àÁ×èͤÅÔé¡«éíÒ¨ÐÊÅѺ¡ÅÒÂ໚¹ ÊÕ¢ÒÇ ¾ÃŒÍÁ¡Ñºà¡çº¢ŒÍÁÙÅŧ㹵ÑÇá»Ã àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 85


10.12 à»ÅÕÂè ¹â»Ãá¡ÃÁã¹à˵ءÒó cmdRun_Click â´Âãˌʧ‹ ¢ŒÍÁÙŨҡµÑÇá»Ã flgDot á·¹ Åͨԡ “1” ´Ñ§¹Õé ¨Ò¡ ColDA True ໚¹ ColDA flgDot(j, i)áÅÐà»ÅÕÂè ¹¤‹Ò˹‹Ç§àÇÅÒ¨Ò¡ 100ms ãˌ໚¹ 1ms 10.13 ·´ÅͧÃѹâ»Ãá¡ÃÁ â´ÂÊØÁ‹ ¤ÅÔ¡é ·Õè flx ãˌà¡Ô´ÊÕá´§¡ÃШÒÂä»·ÑÇè áŌǡ´»ØÁ† Run ¨ÐàËç¹ à»š¹á¶ºÊÕá´§ à¹×Íè §¨Ò¡áÊ´§¼Åµ‹Íà¹×Íè §¡Ñ¹·íÒãˌàËç¹à»š¹á¶ºÊÕá´§ 10.14 »ÃСÒȵÑÇá»Ã flgRun ·ÕÊè Nj ¹ Declaration ÊíÒËÃѺǹÅÙ»à¾×Íè ãˌáÊ´§¼Åµ‹Íà¹×Íè §´Ñ§¹Õé Dim flgRun as Boolean

áÅÐᡌä¢â»Ãá¡ÃÁ´Ñ§¹Õé Private Sub cmdRun_Click() Dim i As Integer Dim j As Integer If flgRun Then flgRun = False cmdRun.Caption = “Run” Exit Sub Else flgRun = True cmdRun.Caption = “Stop” RowRST ColRST End If ColOE False For i = 0 To 6 RowCLK For j = 19 To 0 Step -1 DoEvents ColDA flgDot(j, i) ColCLK Next j ColLE hp.Delay_ms 1 ColRST ColLE Next i RowRST ColOE True End Sub

‘ Reset row counter ‘ Reset column data ‘ Column data output enable ‘ send row clock

‘ send data 1 to column data ‘ send column clock ‘ ‘ ‘ ‘

Latch Delay Reset Latch

column data 100 ms column data column data

‘ Reset row counter ‘ Column data output disable

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 86


10.15 à¾ÔÁè â»Ãá¡ÃÁ‹ÍÂÊíÒËÃѺÍÍ¡¨Ò¡â»Ãá¡ÃÁ¡ÒÃáÊ´§¼Å·Õàè ˵ءÒó Form_QueryUnload áÅÐ Form_Unload ´Ñ§¹Õé Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer) flgRun = False End Sub Private Sub Form_Unload(Cancel As Integer) End End Sub

10.16 à¢Õ¹â»Ãá¡ÃÁãˌ¡Ñºà˵ءÒó cmdRndData_Click ÊíÒËÃѺ¡ÒÃÊÌҧ¢ŒÍÁÙÅÊ؋Áº¹ flx à¾×èÍ㪌ÊíÒËÃѺ·´Êͺ¡ÒÃáÊ´§¼Å¡Ñº´ÍµàÁµÃÔ¡«´Ñ§¹Õé Private Sub cmdRndData_Click() Dim i As Integer Dim j As Integer Dim tmp As Double flx.Visible = False Randomize For i = 0 To 6 flx.Row = i For j = 0 To 19 flgDot(j, i) = CBool(Round(Rnd)) flx.Col = j If flgDot(j, i) Then flx.CellBackColor = vbRed Else flx.CellBackColor = vbWhite End If Next j Next i flx.Visible = True End Sub

ÃÒÂÅÐàÍÕ Â ´¢Í§â»Ãá¡ÃÁ ·´Åͧ¹Õé´Ù䴌¨Ò¡ä¿Å LAB10B.VBP ã¹ÃÙ»·Õè P10-5 áÊ´§¼Å¡Ò÷íÒ§Ò¹¢Í§ â»Ãá¡ÃÁ·´Åͧ¹Õé ÃÙ»·Õè P10-5 ¼Å¡Ò÷íÒ§Ò¹¢Í§â»Ãá¡ÃÁ·´Åͧ LAB10B.VBP àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 87


¡Ò÷´Åͧ¢Ñº LED ´ÍµàÁµÃÔ¡«º¹ºÍÏ´ EX-04A à¾×Íè áÊ´§µÑÇÍÑ¡Éà àÁ×Íè µŒÍ§¡ÒÃáÊ´§µÑÇÍÑ¡ÉèеŒÍ§à»ÅÕÂè ¹¨Ò¡µÑÇÍÑ¡ÉÃÁÒ໚¹µÒÃÒ§¢Í§¢ŒÍÁÙÅ ¨Ò¡¹Ñ¹é ¨Ö§ãªŒ ÇÔ¸ÕáÊ´§¼ÅẺà´ÕÂǡѺ·Õ輋ҹÁÒ 10.17 ÊÌҧ TextBox ÊíÒËÃѺ¾ÔÁ¾µÇÑ ÍÑ¡É÷յè ͌ §¡Òà áÅÐᡌ¤³ Ø ÊÁºÑµ¢Ô ͧ TextBox ´Ñ§ÃÙ»·Õè P10-6 TextBox Name

txt

MaxLength

4

ÃÙ»·Õè P10-6 µÑÇÍ‹ҧ¿ÍÏÁáÅСÒáíÒ˹´¤Ø³ÊÁºÑµÊÔ Òí ËÃѺ·´Åͧ¢Ñº LED ´ÍµàÁµÃÔ¡« ãˌáÊ´§µÑÇÍÑ¡Éà 10.18 »ÃСÒȵÑÇá»Ã·Õãè ªŒà¡çº¢ŒÍÁÙſ͹µ ã¹Ê‹Ç¹ General Declaration â´Â໚¹µÑÇá»ÃÍÒÏàÏ 2 ÁÔµÔ ´Ñ§¹Õé Dim Char(1 To 128, 1 To 5) As Integer

10.19 ÊÌҧ¿Í¹µÊÒí ËÃѺ LED ´ÍµàÁµÃÔ¡«´ÇŒ Ââ»Ãá¡ÃÁ‹Í BuildFontMap ´Ñ§áÊ´§änjáÅŒÇ ã¹Ê‹Ç¹¢Í§·ÄÉ®Õ 10.20 ÊÌҧâ»Ãá¡ÃÁ‹ÍÂÊíÒËÃѺÃѺµÑÇÍÑ¡Éèҡ txt ÁÒá»Å§à»š¹¢ŒÍÁÙÅã¹ÃٻẺ¢Í§¿Í¹µ áÅÐ ¹íÒä»à¡çºänj㹵ÑÇá»Ã flgDot à¾×Íè ¾ÃŒÍÁ㹡ÒÃáÊ´§¼Å·Õ´è ͵àÁµÃÔ¡« Private Sub ReadText() Dim i As Integer Dim j As Integer Dim k As Integer Dim tmpAsc As Integer Dim tCol As Integer Dim tRow As Integer Dim tmpstr As String tmpstr = txt.Text & “ “ flx.Visible = False For i = 0 To 3 tmpAsc = Asc(Mid(tmpstr, i + 1, 1))

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 88


For j = 0 To 4 flx.Col = (i * 5) + j tCol = (i * 5) + j For k = 0 To 6 flx.Row = 6 - k tRow = 6 - k If (Char(tmpAsc, j + 1) And (2 ^ k)) = (2 ^ k) Then flx.CellBackColor = vbRed flgDot(tCol, tRow) = True Else flx.CellBackColor = vbWhite flgDot(tCol, tRow) = False End If Next k Next j Next i flx.Visible = True End Sub

10.21 àÃÕ¡㪌â»Ãá¡ÃÁ‹Í BuildFontMap ·Õàè ˵ءÒó Form_Load Private Sub Form_Load() Dim i As Integer Dim j As Integer BuildFontMap InitialFlexGrid For i = 0 To 6 For j = 0 To 19 flgDot(j, i) = False Next j Next i InitialDatabus RowRST ColRST ColLE End Sub

‘ Clear all dot matrix buffer

‘ ‘ ‘ ‘

Initial databus Reset row counter Reset column data Latch column data

10.22 àÃÕ¡㪌â»Ãá¡ÃÁ‹Í ReadText ã¹ÅÙ»¢Í§¡ÒÃáÊ´§¼Å·Õ´è ͵àÁµÃÔ¡«à¾×Íè ·íÒ¡ÒÃ͋ҹ¤‹Ò ¨Ò¡ txt ¡‹Í¹¨Ð·íÒ¡ÒÃáÊ´§¼ÅÃͺãËÁ‹

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 89


ÃÙ»·Õè P10-7 ¼Å¡Ò÷íÒ§Ò¹¢Í§ â»Ãá¡ÃÁ·´Åͧ LAB10-3.VBP Do While flgRun ReadText For i = 0 To 6 RowCLK For j = 19 To 0 Step -1 DoEvents ColDA flgDot(j, i) matrix buffer to column data ColCLK Next j ColLE hp.Delay_ms 1 ColRST ColLE Next i RowRST Loop

‘ send row clock

send

data

from

dot

‘ send column clock ‘ ‘ ‘ ‘

Latch Delay Reset Latch

column data 100 ms column data column data

‘ Reset row counter

ÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ·´Åͧ¹Õ´é äÙ ´Œ¨Ò¡ä¿Å LAB13C.VBP ã¹ÃÙ»·Õè P10-7 áÊ´§¼Å¡Òà ·íÒ§Ò¹¢Í§â»Ãá¡ÃÁ·´Åͧ¹Õé

»˜¨¨Øº¹Ñ ºÍÏ´ EX-04A ·Õãè ªŒã¹º·¹Õäé ´ŒËÂØ´¡ÒüÅÔµ ´Ñ§¹Ñ¹é ¢ŒÍÁÙÅ㹺·¹Õ¨é §Ö ໚¹ ¡ÒùíÒàʹÍà¾×Íè ໚¹¤ÇÒÁÃÙàŒ ·‹Ò¹Ñ¹é

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 90


º··Õè 8 ¡ÒâÂÒ¤ÇÒÁÊÒÁÒö¢Í§ ¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C I2C ‹ÍÁÒ¨Ò¡ Inter-IC Communication ËÁÒ¶֧ ¡ÒõԴµ‹ÍÊ×Íè ÊÒÃÃÐËNjҧäÍ«Õ â´ÂºÑÊ I2C ¾Ñ²¹Ò¢Ö¹é â´Â¿Å»Ô ʏ (Philips) ´ŒÇ¨شÁا‹ ËÁÒÂËÅÑ¡¤×Í µŒÍ§¡ÒÃãˌäÍ«ÕËÃ×ÍâÁ´ÙÅÊÒÁÒöµÔ´µ‹Í ÊÑ觧ҹáÅФǺ¤ØÁÀÒÂ㵌ÊÒÂÊÑ­­Ò³à¾Õ§ 2 àʌ¹ àʌ¹Ë¹Ö觤×ÍÊÒ¢ŒÍÁÙÅ ÍÕ¡àʌ¹Ë¹Ö觤×ÍÊÒ ÊÑ­­Ò³¹Ò́¡Ò·Õãè ªŒã¹¡ÒáíÒ˹´¨Ñ§ËÇСÒ÷íÒ§Ò¹ ¡Òõ‹ÍËÇÁ¡Ñ¹¢Í§ÍØ»¡Ã³º¹ºÑÊ I2C ·íÒ䴌 §‹ÒÂÁÒ¡ à¾Õ§µ‹ÍÊÒ¢ŒÍÁÙÅáÅÐÊÒÂÊÑ­­Ò³¹Ò́¡Ò¢Í§ÍØ»¡Ã³áµ‹ÅеÑÇ¢¹Ò¹ËÃ×;‹Ç§¡Ñ¹ä» ʋǹ ¡ÒáíÒ˹´áÍ´à´ÃÊËÃ×͵íÒá˹‹§ÊíÒËÃѺµÔ´µ‹ÍÍØ»¡Ã³áµ‹ÅеÑÇ ¨Ð㪌ÃËÑÊ¢ŒÍÁÙÅáÅСÒáíÒ˹´ ÊÀÒÇÐÅͨԡ·Õè¢ÒáÍ´à´ÃʢͧÍØ»¡Ã³áµ‹ÅеÑÇ ÊÒ¢ŒÍÁÙź¹ºÑÊ I2C ÁÕªÍ×è àÃÕ¡Í‹ҧ໚¹·Ò§¡ÒÃÇ‹Ò ÊÒ¢ŒÍÁÙÅ͹ءÃÁËÃ×Í SDA (Serial Data line) ʋǹÊÒÂÊÑ­­Ò³¹Ò́¡ÒÁÕªÍ×è àÃÕÂ¡Ç‹Ò ÊÒÂÊÑ­­Ò³¹Ò́¡Ò͹ءÃÁËÃ×Í SCL (Serial Clock line) 㹡ÒÃ͸ԺÒµ‹Í仹ըé ÐàÃÕ¡ÊÒÂÊÑ­­Ò³·Ñ§é ÊÍ§Ç‹Ò ÊÒ SDA áÅÐ SCL

¤Ø³ÊÁºÑµâÔ ´Â·ÑÇè 仢ͧºÑÊ I2C ÊÒ SDA áÅÐ SCL ໚¹ÊÒÂÊÑ­­Ò³ 2 ·ÔÈ·Ò§ (bi-directional line) µŒÍ§ÁÕ¡Òõ‹ÍµÑǵŒÒ¹ ·Ò¹¾ÙÅÍÑ»¡Ñºáç´Ñ¹ +5V änjµÅÍ´àÇÅÒ à¾×Íè ãˌÊÒÂÁÕʶҹÐÅͨԡÊ٧㹢³Ð·Õäè Á‹Á¡Õ ÒÃ㪌§Ò¹ ·Ñ§é Âѧª‹ÇÂ㹡Òû‡Í§¡Ñ¹ÊÑ­­Ò³Ãº¡Ç¹·ÕÍè Ò¨ÁÕࢌÒÁÒã¹ÊÒÂÊÑ­­Ò³·Ñ§é Êͧ ǧ¨ÃàÍÒµ¾µØ ¢Í§ÍØ»¡Ã³ ·Õµè ͋ ÍÂÙº‹ ¹ºÑÊ I2C µŒÍ§ÁÕÅ¡Ñ É³Ð໚¹Ç§¨Ãà´Ã¹à»´ (open-drain) ËÃ×ͤÍÅàÅç¡àµÍÏແ´ (opencollector) ´Ñ§áÊ´§ÃÒÂÅÐàÍÕ´ã¹ÃÙ»·Õè 8-1 ÍѵÃÒ¡Òö‹Ò·ʹ¢ŒÍÁÙź¹ºÑÊ I2C ÊÙ§¶Ö§ 100 ¡ÔâźԵµ‹ÍÇÔ¹Ò·Õã¹âËÁ´»¡µÔ (standard mode) áÅÐÊÙ§¶Ö§ 400 ¡ÔâźԵµ‹ÍÇÔ¹Ò·Õã¹âËÁ´¤ÇÒÁàÃçÇÊÙ§ (fast mode) ÍØ»¡Ã³·µÕè ͋ ËÇÁÍÂÙº‹ ¹ ºÑÊ I2C ¨ÐµŒÍ§Áդҋ ¤ÇÒÁ¨Øä¿¿‡ÒÃÇÁ·Õàè ¡Ô´¢Ö¹é ÃÐËNjҧÊÒ SDA áÅÐ SCL äÁ‹à¡Ô¹ 400pF ¡ÒÃà¢ŒÒ ¶Ö§ÍØ»¡Ã³º¹ºÑÊ I2C ·íÒ䴌 2 Ẻ¤×Í 7 ºÔµ (7-bit addressing) áÅÐ 10 ºÔµ (10-bit addressing) ¢ŒÍഋ¹ÍÕ¡»ÃСÒÃ˹Ö觢ͧºÑÊ I2C ¤×Í ÊÒÁÒöàª×èÍÁµ‹ÍÍØ»¡Ã³·Õè㪌ä¿àÅÕé§äÁ‹à·‹Ò¡Ñ¹ãˌ ÊÒÁÒöµÔ´µ‹ÍÊ×Íè ÊÒáѹ䴌 â´ÂÍØ»¡Ã³º¹ºÑÊ I2C µÑÇ˹֧è ÍҨ㪌ä¿àÅÕÂé § +5V ã¹¢³Ð·ÕÍè ¡Õ µÑÇ˹֧è 㪌ä¿àÅÕÂé § +12V ¡Òõ‹ÍËÇÁ¡Ñ¹º¹ºÑÊ I2C ÊÒÁÒö¡ÃзíÒ䴌ã¹ÅѡɳÐà´ÕÂǡѺ¡Ã³Õ·ÍÕè »Ø ¡Ã³ ·Ñ§é Êͧ㪌ä¿àÅÕÂé §à·‹Ò¡Ñ¹ ¡Å‹ÒǤ×Í ãˌµÍ‹ ÊÒ SDA áÅÐ SCL ¢Í§ÍØ»¡Ã³áµ‹ÅеÑÇࢌҴŒÇ¡ѹ áÅÐ µŒÍ§µ‹ÍµÑǵŒÒ¹·Ò¹¾ÙÅÍÑ» (RP) ࢌҡѺáç´Ñ¹ +5V änj´ÇŒ ÂàÊÁÍ ´Ñ§áÊ´§ã¹ÃÙ»·Õè 8-2 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 91


+5V

R2

SDA (Serial Data line)

R2

SCL (Serial Clock line)

SCLKN1 OUT

DATAN1 OUT

SCLKN2 OUT

DATAN2 OUT

SCLK IN

DATA IN

SCLK IN

DATA IN

ÍØ»¡Ã³ I C ºÑÊ µÑÇ·Õè 1

ÍØ»¡Ã³ I C ºÑÊ µÑÇ·Õè 2

ÃÙ»·Õè 8-1 ǧ¨ÃàÍÒµ¾µØ ¢Í§ÍØ»¡Ã³º¹ÃкººÑÊ I2C 㹡óշÕèÍÒ¨ÁÕáç´Ñ¹ä¿¡ÃЪҡ¢¹Ò´ãË­‹»Ð»¹à¢ŒÒÁÒ㹺ÑÊ I2C ·Õè¢Ò SDA áÅÐ SCL ¢Í§ÍØ»¡Ã³áµ‹ÅеÑǵŒÍ§µ‹ÍµÑǵŒÒ¹·Ò¹Í¹Ø¡ÃÁ¡Ñº¢Ò SDA áÅÐ SCL àÃÕÂ¡Ç‹Ò RS ¡‹Í¹µ‹ÍࢌÒÊÙº‹ ÊÑ I2C ´Ñ§áÊ´§ã¹ÃÙ»·Õè 8-3

ËÅÑ¡¡ÒâͧºÑÊ I2C

ºÑÊ I2C »ÃСͺ´ŒÇÂÊÒÂÊÑ­­Ò³ 2 àʌ¹ ´Ñ§·Õäè ´Œ¡Å‹ÒÇÁÒáŌǤ×Í SDA áÅÐ SCL ÍØ»¡Ã³ ·Õµè ͋ ¾‹Ç§º¹ºÑÊÊÒÁÒöÁÕ䴌ÁÒ¡ÁÒ ´Ñ§¹Ñ¹é ¨Ö§µŒÍ§ÁÕ¡ÒáíÒ˹´ÃٻẺ¢Í§¡ÒõԴµ‹Íº¹ºÑÊ ËÃ×Í àÃÕÂ¡Ç‹Ò â»ÃⵤÍÅ (protocol) à¾×Íè ãˌ¼ãٌ ªŒ§Ò¹·ÃÒºÇ‹Ò ¢³Ð¹ÕÍé »Ø ¡Ã³ã´µÔ´µ‹Í¡Ñ¹ÍÂً áÅÐÍØ»¡Ã³ µÑÇã´à»š¹µÑÇÃѺËÃ×͵ÑÇʋ§ µ‹Í仹ըé ТÍ͸ԺÒÂÅѡɳР˹ŒÒ·Õè áÅйÔÂÒÁ¢Í§ÍØ»¡Ã³·µÕè ͋ ÍÂÙº‹ ¹ºÑÊ I2C à¾×Íè ໚¹¢ŒÍµ¡Å§¾×¹é °Ò¹¡‹Í¹·Õ¨è Ð͸ԺÒ¡Ò÷íÒ§Ò¹¢Í§ºÑÊ I2C µ‹Íä» ÍØ»¡Ã³·àÕè »š¹¼Ùʌ Ìҧ¢ŒÍÁÙÅËÃ×Íʋ§¢ŒÍÁÙÅ àÃÕÂ¡Ç‹Ò µÑÇʋ§ (transmitter) ÍØ»¡Ã³·àÕè »š¹¼ÙÌ ºÑ ¢ŒÍÁÙÅ àÃÕÂ¡Ç‹Ò µÑÇÃѺ (receiver) ÍØ»¡Ã³º¹ºÑÊ I2C ÊÒÁÒö໚¹ä´Œ·§Ñé µÑÇÃѺáÅеÑÇʋ§ ÍØ»¡Ã³··Õè Òí ˹ŒÒ·Õè ¤Çº¤ØÁ¨Ñ§ËÇСÒõԴµ‹Íº¹ºÑÊ I2C àÃÕÂ¡Ç‹Ò ÁÒÊàµÍÏ (master) ÍØ»¡Ã³·¶Õè ¡Ù ¤Çº¤ØÁËÃ×ÍÍØ»¡Ã³ ·Õµè ͋ ¾‹Ç§à¢ŒÒ仺¹ºÑÊ I2C àÃÕÂ¡Ç‹Ò ÊàÅ¿ (slave)

R2

R2

+5V

+9V

+12V

+12V

ÍØ»¡Ã³ 1 + ºÑÊ ª¹Ô´ NMOS

ÍØ»¡Ã³ 1 + ºÑÊ ª¹Ô´ BICMOS

ÍØ»¡Ã³ 1 + ºÑÊ ª¹Ô´ CMOS

ÍØ»¡Ã³ 1 + ºÑÊ ª¹Ô´ BIPOLAR

SDA SCL

ÃÙ»·Õè 8-2 ¡Òõ‹Í¾‹Ç§ÍØ»¡Ã³ÃкººÑÊ I2C ·Õãè ªŒä¿àÅÕÂé §äÁ‹à·‹Ò¡Ñ¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 92


R2 SDA

R2

+5V

+5V

ÍØ»¡Ã³ 1 + ºÑÊ

ÍØ»¡Ã³ 1 + ºÑÊ

R5

R5

R5

R5

SCL

ÃÙ»·Õè 8-3 ¡Òõ‹ÍµÑǵŒÒ¹·Ò¹Í¹Ø¡ÃÁ¡Ñº¢ÒÊÑ­­Ò³¢Í§ÍØ»¡Ã³º¹ÃкººÑÊ I2C à¾×èÍÅ´ ÊÑ­­Ò³Ãº¡Ç¹ ¢ŒÍ¡íÒ˹´ 2 »ÃСÒÃÊíҤѭ¢Í§¡ÒõԴµ‹Íº¹ºÑÊ I2C ¤×Í (1) ¡Òö‹Ò·ʹ¢ŒÍÁÙŨÐà¡Ô´¢Ö¹é 䴌àÁ×Íè ºÑÊNjҧ෋ҹѹé (2) ã¹ÃÐËNjҧ¡Òö‹Ò·ʹ¢ŒÍÁÙÅ àÁ×Íè ã´¡çµÒÁ·ÕÊè Ò SCL ÁÕʶҹÐ໚¹ÅͨԡÊÙ§ ÊÒ¢ŒÍÁÙÅ µŒÍ§ÃÑ¡ÉÒ¢ŒÍÁÙÅänj Í‹Òãˌà¡Ô´¡ÒÃà»ÅÕÂè ¹á»Å§¢Ö¹é à´ç´¢Ò´ Áԩйѹé ÊÑ­­Ò³·Õàè ¡Ô´¢Ö¹é ¨Ðä´ŒÃºÑ ¡Òà á»Å¤ÇÒÁËÁÒÂ໚¹ÊÑ­­Ò³¤Çº¤ØÁá·¹ ÊÀÒÇзÕàè ¡Ô´¢Ö¹é º¹ºÑÊ I2C Áմnj ¡ѹ 5 ÊÀÒÇÐ ´Ñ§¹Õé (1) ºÑÊNjҧ (Bus not busy) ÊÀÒÇйÕàé ¡Ô´¢Ö¹é àÁ×Íè ʶҹÐÅͨԡº¹ÊÒ SDA áÅÐ SCL ໚¹ ÅͨԡÊÙ§·Ñ§é ¤Ù‹ ¹Ñ¹è ËÁÒ¤ÇÒÁÇ‹Ò ¡Òö‹Ò·ʹ¢ŒÍÁÙÅÊÒÁÒöàÃÔÁè µŒ¹¢Ö¹é 䴌 (2) àÃÔÁè µŒ¹¶‹Ò·ʹ¢ŒÍÁÙÅ (start data transfer) à¡Ô´¢Ö¹é àÁ×Íè ÊÒ SDA ÁÕ¡ÒÃà»ÅÕÂè ¹á»Å§ Åͨԡ¨Ò¡Ê٧仵èÒí ã¹¢³Ð·ÕÊè Ò SCL ÁÕʶҹÐÅͨԡÊÙ§ àÃÕ¡ÊÀÒÇйÕÇé ҋ ÊÀÒÇÐàÃÔÁè µŒ¹ (START) (3) ËÂØ´¡Òö‹Ò·ʹ¢ŒÍÁÙÅ (stop data transfer) à¡Ô´¢Ö¹é àÁ×Íè ÊÒ SDA ÁÕ¡ÒÃà»ÅÕÂè ¹ á»Å§ÃдѺÅͨԡ¨Ò¡µèÒí ä»ÊÙ§ ã¹¢³Ð·ÕÊè Ò SCL ÁÕʶҹÐÅͨԡÊÙ§ àÃÕ¡ÊÀÒÇзÕàè ¡Ô´¢Ö¹é ¹ÕÇé ҋ ÊÀÒÇÐ ËÂØ´ (STOP) (4) ¢ŒÍÁÙÅ´íÒçÍÂÙº‹ ¹ºÑÊ (data valid) ÊÀÒÇйÕàé ¡Ô´¢Ö¹é ¶Ñ´¨Ò¡ÊÀÒÇÐàÃÔÁè µŒ¹ â´ÂʶҹРÅͨԡ·Õàè ¡Ô´¢Ö¹é º¹ÊÒ SDA ¡ç¤Í× ¢ŒÍÁÙÅ·Õ·è Òí ¡Òö‹Ò·ʹ àÁ×Íè ÊÒ SCL ໚¹ÅͨԡÊÙ§ ʶҹзÕÊè Ò SDA µŒÍ§¤§·Õè à¾×Íè ãËŒÍ»Ø ¡Ã³ÃºÑ ÃÙ¢Œ ͌ ÁÙÅ㹨ѧËÇйѹé Ç‹Ò à»š¹ “0” ËÃ×Í “1” ¢ŒÍÁÙÅÍÒ¨à¡Ô´¡Òà à»ÅÕÂè ¹á»Å§ä´Œã¹¢³Ð·ÕÊè Ò SCL ໚¹ÅͨԡµèÒí ᵋàÁ×Íè ã´¡çµÒÁ·Õµè ͌ §¡ÒÃãˌà¡Ô´¡Òö‹Ò·ʹ¢ŒÍÁÙÅ Í‹ҧÊÁºÙó ʶҹÐÅͨԡ·Õ¢è Ò SDA µŒÍ§¤§·Õµè ÅÍ´ª‹Ç§àÇÅÒ·ÕÊè Ò SCL ÁÕʶҹÐÅͨԡÊÙ§ ËÒ¡ à¡Ô´¡ÒÃà»ÅÕÂè ¹á»Å§Ê¶Ò¹ÐÅͨԡ㹢³Ð·ÕÊè Ò SCL ÁÕÅͨԡÊÙ§ÍÂÙ¹‹ ¹Ñé ÍØ»¡Ã³ÁÒÊàµÍÏ·¤Õè Ǻ¤ØÁ ¡Òö‹Ò·ʹ¢ŒÍÁÙŨÐá»Å¤ÇÒÁËÁÒÂ໚¹ÊÀÒÇÐËÂØ´ËÃ×ÍÊÀÒÇÐàÃÔÁè µŒ¹¡ç䴌 ·íÒãˌ¢ÍŒ ÁÙÅ·Õ¶è ҋ ·ʹ ¹Ñ¹é à¡Ô´¤ÇÒÁ¼Ô´¾ÅÒ´¢Ö¹é àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 93


SDA à»ÅÕÂè ¹¨Ò¡ "1" ໚¹ "0" ã¹¢³Ð·Õè SCL ໚¹ "1" ¹Õ¤è Í× ÊÀÒÇÐàÃÔèÁµŒ¹

SDA à»ÅÕÂè ¹¨Ò¡ "0" ໚¹ "1" ã¹¢³Ð·Õè SCL ໚¹ "1" ¹Õ¤è Í× ÊÀÒÇÐËÂØ´

SDA

SCL

SDA ¤§·Õ·è ÅèÕ Í¨Ô¡ "0" SDA ¤§·Õ·è ÅèÕ Í¨Ô¡ "1" ã¹¢³Ð·Õè SCL ໚¹ "1" ¶×Í໚¹ ã¹¢³Ð·Õè SCL ໚¹ "1" ¶×Í໚¹ ¡Òö‹Ò·ʹ¢ŒÍÁÙÅ "0" ¡Òö‹Ò·ʹ¢ŒÍÁÙÅ "1"

SDA ໚¹ "1" SCL ໚¹ "1" ÊÀÒÇкÑÊNjҧ

ÃÙ»·Õè 8-4 ä´ÍÐá¡ÃÁáÊ´§Ê¶Ò¹Ðµ‹Ò§æ º¹ÃкººÑÊ I2C (5) ÃѺÃÙ¢Œ ͌ ÁÙÅ (acknowledge) à¡Ô´¢Ö¹é ËÅѧ¨Ò¡·Õ¡è Òö‹Ò·ʹ¢ŒÍÁÙŨҡµÑÇʋ§ÁÒÂѧµÑÇÃѺ à¡Ô´¢Ö¹é Í‹ҧÊÁºÙó â´ÂµÑÇʋ§¨Ð·íÒ¡ÒÃʋ§¢ŒÍÁÙÅÁÒ 1 ºÔµàÃÕÂ¡Ç‹Ò ºÔµÃѺÃٌ (acknowledge bit) ÁÕ Ê¶Ò¹Ð໚¹ÅͨԡÊÙ§ ËÅѧ¨Ò¡Ê‹§¢ŒÍÁÙÅÁҤú¶ŒÇ¹ ʋǹÍØ»¡Ã³ÁÒÊàµÍϨзíÒ¡ÒÃʋ§ÊÑ­­Ò³ÃѺÃٌ ¾ÔàÈÉ«Öè§ÊÑÁ¾Ñ¹¸¡ÑºÊÑ­­Ò³¹Ò́¡Ò à¾×è͵ͺʹͧºÔµÃѺÃٌ·Õèʋ§ÁÒ¨Ò¡µÑÇʋ§ ·Ò§´ŒÒ¹µÑÇÃѺ¨Ðʋ§ ºÔµÃѺÃÙ·Œ ÁÕè ÊÕ ¶Ò¹ÐÅͨԡµèÒí ŧº¹ºÑÊ ÍØ»¡Ã³ÊàÅ¿·Õ¶è ¡Ù ͌ҧ¶Ö§ã¹¡ÒõԴµ‹ÍËÃ×Í¡íÒÅѧµÔ´µ‹ÍÍÂÙ㋠¹¢³Ð ¹Ñ¹é ¡ç¨Ð¡íÒà¹Ô´ºÔµÃѺÃÙàŒ ¾×Íè µÍºÊ¹Í§ãˌ·ÃҺNjÒä´ŒÃºÑ ¢ŒÍÁÙÅã¹áµ‹ÅÐ亵àÃÕºÌÍÂáÅŒÇ ã¹ÃÙ»·Õè 8-4 ໚¹ä´ÍÐá¡ÃÁàÇÅÒ·Õáè Ê´§¶Ö§¡ÒÃà¡Ô´ÊÀÒÇе‹Ò§æ º¹ºÑÊ I2C äÁ‹Çҋ ¨Ð໚¹ ÊÀÒÇкÑÊNjҧ,àÃÔÁè µŒ¹, ¶‹Ò·ʹ¢ŒÍÁÙÅ, ÃѺÃٌ áÅÐËÂØ´¡Òö‹Ò·ʹ¢ŒÍÁÙÅ

¡Ò÷íÒ§Ò¹º¹ºÑÊ I2C ¡‹Í¹·Õè¨ÐàÃÔèÁµŒ¹¡Òö‹Ò·ʹ¢ŒÍÁÙÅÃÐËNjҧÍØ»¡Ã³µ‹Ò§æ ·Õ赋ÍÍÂًº¹ºÑÊ µŒÍ§ÁÕ¡ÒÃ͌ҧ¶Ö§ àÊÕ¡‹Í¹ â´Â¡ÒÃ͌ҧ¶Ö§ÍØ»¡Ã³º¹ºÑÊ I2C ¹Ñ¹é ¨Ð㪌¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµËÃ×Í 10 ºÔµ 㹡óշÁÕè Õ ÍØ»¡Ã³µ‹ÍÍÂًº¹ºÑÊäÁ‹Áҡ㪌¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµ¡çà¾Õ§¾Í ᵋ¶ŒÒÁÕÍØ»¡Ã³µ‹ÍÍÂًº¹ºÑÊÁÒ¡ ¡Ç‹Ò 127 áÍ´à´ÃÊ ¨íÒ໚¹µŒÍ§ãªŒ¡ÒÃ͌ҧ¶Ö§áºº 10 ºÔµ ËÅѧ¨Ò¡·Õµè ´Ô µ‹ÍÍØ»¡Ã³áµ‹ÅеÑÇ䴌 àÃÕºÌÍÂáÅŒÇ ¡ç¨ÐàÃÔÁè µŒ¹¡Òö‹Ò·ʹ¢ŒÍÁÙšѹµ‹Íä» ´Ñ§¹Ñé¹ËÑÇã¨ÊíҤѭã¹Íѹ´Ñºáá¢Í§¡Ò÷íÒ§Ò¹º¹ºÑÊ I2C ¤×Í¡ÒÃ͌ҧ¶Ö§ÍØ»¡Ã³áµ‹ÅеÑÇ µ‹Í仹ըé Ð͸ԺÒÂÃÒÂÅÐàÍÕ´¢Í§¡ÒÃ͌ҧ¶Ö§·Ñ§é 2 ÃٻẺ

¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµ (7-bit addressing) ¢ŒÍÁÙÅ亵áá·Õàè ¡Ô´¢Ö¹é ËÅѧ¨Ò¡ÊÀÒÇÐàÃÔÁè µŒ¹¤×Í ¢ŒÍÁÙÅ·Õãè ªŒã¹¡ÒÃ͌ҧ¶Ö§ÍØ»¡Ã³·µÕè ͌ §¡Òà µÔ´µ‹ÍËÃ×Í ¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊ â´ÂÁÕû٠ẺáÊ´§ã¹ÃÙ»·Õè 8-5 ã¹ 7 ºÔµº¹ÃÇÁ·Ñ§é ºÔµ MSB ´ŒÇ¨Ð໚¹¢ŒÍÁÙÅáÍ´à´ÃʢͧÍØ»¡Ã³ÊàÅ¿·Õ赌ͧ¡ÒõԴµ‹Í â´Âẋ§à»š¹ºÔµ¡íÒ˹´áÍ´à´ÃÊ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 94


ºÔµ 7

ºÔµ 6

ºÔµ 5

ºÔµ 4

ºÔµ 3

ºÔµ 2

ºÔµ 1

ºÔµ 0

X

X

X

X

A2

A1

A0

R/W

ºÔµ¡íÒ˹´áÍ´à´ÃÊ â»Ãá¡ÃÁ䴌

ºÔµ¡íÒ˹´áÍ´à´Ãʤ§·Õè

ÃÙ»·Õè 8-5 ÃٻẺ¢Í§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃʢͧÍØ»¡Ã³º¹ÃкººÑÊ I2C ¤§·Õè (fixed address bit) ¨íҹǹ 4 ºÔµ «Ö§è ¢ŒÍÁÙŹÕÍé »Ø ¡Ã³áµ‹ÅеÑǨж١¡íÒ˹´ÁÒ¨Ò¡¼Ù¼Œ ÅÔµ äÁ‹ ÊÒÁÒöà»ÅÕè¹á»Å§á¡Œä¢ä´Œ ¶Ñ´ÁÒÍÕ¡ 3 ºÔµà»š¹ºÔµ¡íÒ˹´áÍ´à´ÃÊ·ÕèÊÒÁÒöâ»Ãá¡ÃÁ䴌 (programmable address bit) â´Â¼Ù㌠ªŒ§Ò¹µŒÍ§¡íÒ˹´Ê¶Ò¹ÐÅͨԡãˌᡋ¢Ò A0-A2 ¢Í§ÍØ»¡Ã³·Õè ÁÕ¡ÒÃàª×Íè Áµ‹ÍẺºÑÊ I2C ʋǹ㹺Ե LSB ໚¹ºÔµ·Õãè ªŒ¡Òí ˹´¡ÒÃ͋ҹËÃ×Íà¢Õ¹¢ŒÍÁÙšѺÍØ»¡Ã³ ÊàÅ¿µÑǹѹé æ ËÒ¡ºÔµ LSB ໚¹ “0” ËÁÒ¶֧µŒÍ§¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»ÂѧÍØ»¡Ã³¹¹Ñé ¶ŒÒ໚¹ “1” ¨Ð໚¹¡ÒÃ͋ҹ¢ŒÍÁÙŨҡÍØ»¡Ã³ÊàÅ¿ ¢ŒÍÁÙÅã¹äºµµÍ‹ ÁÒ¤×Í ¢ŒÍÁÙŤǺ¤ØÁ (control byte) ã¹ÍØ»¡Ã³áµ‹ÅеÑÇÁÕ¡ÒáíÒ˹´¢ŒÍÁÙÅ ¤Çº¤ØÁ·Õáè µ¡µ‹Ò§¡Ñ¹ä» ¡µÑÇÍ‹ҧ äÍ«Õ¢ÂÒ¾ÍϵÁբ͌ ÁÙŤǺ¤ØÁ·Õãè ªŒ¡Òí ˹´Ç‹Ò ºÔµã´à»š¹ÍÔ¹¾Øµ ºÔµã´à»š¹àÍÒµ¾µØ ã¹¢³Ð·Õäè Í«Õ ADC/DAC µŒÍ§¡ÒâŒÍÁÙŤǺ¤ØÁà¾×Íè ¡íÒ˹´ãˌ·Òí §Ò¹à»š¹Ç§¨Ã ADC ËÃ×Í DAC ໚¹µŒ¹ ¢ŒÍÁÙÅã¹äºµµÍ‹ ÁÒ¤×Í ¢ŒÍÁÙÅ·Õ·è Òí ¡Òö‹Ò·ʹ¨ÃÔ§ (data) ËÅѧ¨Ò¡·ÕÁè ¡Õ Òö‹Ò·ʹ¢ŒÍÁÙÅã¹áµ‹ÅÐ亵 ÍØ»¡Ã³ÊàÅ¿·Õäè ´ŒÃºÑ ¡ÒõԴµ‹ÍµŒÍ§Ê‹§ÊÑ­­Ò³ ÃѺÃÙµŒ ͺ¡ÅѺÁÒ´ŒÇ·ء¤Ãѧé à¾×Íè ãˌ¡Ãкǹ¡Òö‹Ò·ʹ¢ŒÍÁÙÅÂѧ¤§ÊÒÁÒö´íÒà¹Ô¹µ‹Íä»ä´Œ ã¹ÃÙ» ·Õè 8-6 áÊ´§ÃٻẺ¢ŒÍÁÙÅ͹ءÃÁ·Õàè ¡Ô´¢Ö¹é 㹡ÒõԴµ‹Íº¹ºÑÊ I2C ¢Í§¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµ

¡ÒÃ͌ҧ¶Ö§áºº 10 ºÔµ 㹡ÒÃ͌ҧ¶Ö§áºº¹Õé Âѧ¤§ãªŒÃ»Ù Ẻ¢ŒÍÁÙÅ͹ءÃÁ·Õàè ËÁ×͹¡Ñºáºº 7 ºÔµ Ëҡᵋ¨ÐÁբ͌ ÁÙÅ à¾ÔÁè àµÔÁ¢Ö¹é ÁÒàÅ硹ŒÍ â´Âã¹¢ŒÍÁÙÅ亵ááËÅѧ¨Ò¡à¡Ô´ÊÀÒÇÐàÃÔÁè µŒ¹ µŒÍ§¡íÒ˹´ãˌ 5 ºÔµº¹ÁÕ ¢ŒÍÁÙÅ໚¹ 11110 ʋǹÍÕ¡ 2 ºÔµ¶Ñ´ÁÒ໚¹ºÔµáÍ´à´ÃʢͧÍØ»¡Ã³·µÕè ͌ §¡ÒõԴµ‹Í 㹺Ե LSB ¢ŒÍÁÙÅ亵·èÕ 1 àÅ×Í¡áÍ´à´Ãʢͧ ÍØ»¡Ã³·µèÕ ÍŒ §¡ÒõԴµ‹Í áÅШشÁا‹ ËÁÒÂ㹡Òà µÔ´µ‹Í (͋ҹËÃ×Íà¢Õ¹)

àÃÔèÁµŒ¹

A6-A0

¢ŒÍÁÙÅ亵·èÕ 2 ʋ§¢ŒÍÁÙŤǺ¤ØÁ¡Òà ·íÒ§Ò¹¢Í§ÍØ»¡Ã³ ·Õµè ͌ §¡ÒõԴµ‹ÍËÃ×Í control word R/W=0

ÃѺÃٌ

C6-C0

ʋ§ÁÒ¨Ò¡ÍØ»¡Ã³ÊàÅ¿·Õ·è Òí ¡ÒõԴµ‹Í´ŒÇÂ

¢ŒÍÁÙÅ亵µÍ‹ ä» (n 亵) ¢ŒÍÁÙŨÃÔ§·Õµè ͌ §¡Òö‹Ò·ʹ R/W

ÃѺÃٌ

D7-D0

ʋ§ÁÒ¨Ò¡ÍØ»¡Ã³ÊàÅ¿·Õ·è Òí ¡ÒõԴµ‹Í´ŒÇÂ

ÃÙ»·Õè 8-6 ÃٻẺ¢Í§¢ŒÍÁÙÅ·Õãè ªŒã¹¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµ¢Í§ÃкººÑÊ I2C àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 95

ÃѺÃٌ

ËÂØ´


¢ŒÍÁÙÅ亵·èÕ 1 àÅ×Í¡¡ÒÃ͌ҧ¶Ö§áºº 10 ºÔµ (¢ŒÍÁÙŤ×Í 11110xx â´Â xx ¤×Í ºÔµáÍ´à´ÃÊ 2 ºÔµº¹)

àÃÔÁè µŒ¹

)')&

¢ŒÍÁÙÅ亵·èÕ 3 ʋ§¢ŒÍÁÙŤǺ¤ØÁ ¡Ò÷íÒ§Ò¹ ¢Í§ÍØ»¡Ã³·µèÕ ÍŒ §¡Òà µÔ´µ‹ÍËÃ×Í control word

¢ŒÍÁÙÅ亵·èÕ 2 ¢ŒÍÁÙÅáÍ´à´ÃÊ 8 ºÔµÅ‹Ò§

R/W=0 ÃѺÃٌ

A7-A0 ʋ§ÁÒ¨Ò¡ÍØ»¡Ã³ÊàÅ¿ ·Õ·è Òí ¡ÒõԴµ‹Í´ŒÇÂ

ÃѺÃٌ

C6-C0

¢ŒÍÁÙÅ亵µÍ‹ ä» (n 亵) ¢ŒÍÁÙŨÃÔ§·Õµè ͌ §¡Òà ¶‹Ò·ʹ

R/W

ÃѺÃٌ

D7-D0

ÃѺÃٌ ËÂØ´

ʋ§ÁÒ¨Ò¡ÍØ»¡Ã³ÊàÅ¿ ·Õ·è Òí ¡ÒõԴµ‹Í´ŒÇÂ

ÃÙ»·Õè 8-7 ÃٻẺ¢Í§¢ŒÍÁÙÅ·Õãè ªŒã¹¡ÒÃ͌ҧ¶Ö§áºº 10 ºÔµ¢Í§ÃкººÑÊ I2C ¢Í§¢ŒÍÁÙÅ亵ááÂѧ¤§à»š¹¡ÒáíÒ˹´Ç‹Ò µŒÍ§¡ÒÃ͋ҹËÃ×Íà¢Õ¹¢ŒÍÁÙšѺÍØ»¡Ã³ÊàÅ¿µÑÇ·Õµè ͌ §¡Òà µÔ´µ‹Í´ŒÇ ¢ŒÍÁÙÅ亵µÍ‹ ÁÒ໚¹¢ŒÍÁÙÅáÍ´à´ÃÊã¹äºµ·Õè 2 ¢Í§ÍØ»¡Ã³·µÕè ͌ §¡ÒõԴµ‹Í´ŒÇ ¢ŒÍÁÙŠ亵¶´Ñ 仨֧໚¹¢ŒÍÁÙŤǺ¤ØÁ ¢ŒÍÁÙÅËÅѧ¨Ò¡¹Ñ¹é ¡ç¨Ð໚¹¢ŒÍÁÙŨÃÔ§·Õãè ªŒã¹¡ÒõԴµ‹Í ઋ¹à´ÕÂǡѺ¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµ ËÅѧ¨Ò¡¶‹Ò·ʹ¢ŒÍÁÙŤú·Ø¡äºµ µŒÍ§ÁÕÊÀÒÇÐÃѺÃٌ à¡Ô´¢Öé¹ à¾×èÍãˌ¡Ãкǹ¡Òö‹Ò·ʹ¢ŒÍÁÙÅÊÒÁÒö´íÒà¹Ô¹µ‹Íä»ä´Œ ã¹ÃÙ»·Õè 8-7 áÊ´§ÃٻẺ ¢ŒÍÁÙÅ͹ءÃÁ¢Í§¡ÒÃ͌ҧ¶Ö§áºº 10 ºÔµ +5V

¡Òõ‹ÍÍØ»¡Ã³ÃкººÑÊ I2C ¡Ñº¾Íϵ¢¹Ò¹¼‹Ò¹ P-Board

à¾×è Í ãˌ ¾ ÍÏ µ ¢¹Ò¹ÊÒÁÒöµÔ ´ µ‹ Í ¡Ñ º SDA ÍØ»¡Ã³·ÁÕè ¡Õ ÒÃàª×Íè Áµ‹Í໚¹ºÑÊ I2C ¨ÐµŒÍ§ÊÌҧ Q001 BC547 R002 ǧ¨Ãàª×Íè Áµ‹Í¢Ö¹é ÁÒ ´Ñ§ã¹ÃÙ»·Õè 8-8 ·ÃÒ¹«ÔÊàµÍÏ 10k C0 Q001 áÅÐ Q002 ä´ŒÃºÑ ¡ÒèѴǧ¨ÃãˌÁÅÕ ¡Ñ ɳРR004 3.3k ໚¹Ç§¨ÃºÑ¿à¿ÍÏẺ¤ÍÅàÅç¡àµÍÏແ´µÒÁ¢ŒÍ ¡íÒ˹´¢Í§Ç§¨ÃàÍÒµ¾µØ ¢Í§ºÑÊ I2C â´Â Q001 S7 㪌¶‹Ò·ʹÊÑ­­Ò³¢Í§ÊÒ SDA ã¹¢³Ð·Õè +5V Q002 ·íÒ˹ŒÒ·Õ趋Ò·ʹÊÑ­­Ò³¢Í§ÊÒ SCL GND R006 ä¿àÅÕé  §¢Í§Ç§¨Ã¤× Í +5V ¨Ö § ÊÒÁÒö㪌 2.7k SCL ·ÃÒ¹«ÔÊàµÍÏ NPN ẺÁҵðҹàºÍÏ㴡ç䴌 Q002 BC547 R005 ·ÕÊè ÒÁÒöµÍºÊ¹Í§¤ÇÒÁ¶ÕÊè §Ù ÊØ´¶Ö§ 100 kHz 10k C1 R007 ÊíÒËÃѺ P-Board ·Õãè ªŒã¹¡Ò÷´Åͧ¹Õé 䴌 3.3k ¨Ñ´¡íÒ˹´ãˌ¢ÍŒ ÁÙŶ‹Ò·ʹÊÙʋ Ò SDA ¢Í§ºÑÊ I2C ¼‹Ò¹·Ò§¢Ò C0 áÅÐÃѺ¢ŒÍÁÙż‹Ò¹¢Ò S7 ʋǹ ÃÙ»·Õè 8-8 ǧ¨Ãàª×Íè Áµ‹Í¡ÑºÃкººÑÊ I2C ¢Í§ ÊÒÂÊÑ­­Ò³¹Ò́¡Ò¨Ð¶Ù¡Ê‹§ÍÍ¡ÁÒ·Ò§¢Ò C1 à¾×Íè ໚¹ÊÒ SCL ÊíÒËÃѺÃкººÑÊ I2C P-Board ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ R003 2.7k

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 96


¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè ÊÌҧÊÑ­­Ò³µ‹Ò§ æ ÊíÒËÃѺºÑÊ I2C à¾×Íè ãˌ§Ò‹ µ‹Í¡ÒÃàÃÕ¡㪌§Ò¹ ´Ñ§¹Ñ¹é ¡ÒõԴµ‹Í¡ÑººÑÊ I2C â´Â㪌¾Íϵ¢¹Ò¹¨Ö§µŒÍ§à¢Õ¹ â»Ãá¡ÃÁ‹ÍÂà¾×Íè ÊÌҧÊÀÒÇе‹Ò§æ ¢Í§ÃкººÑÊ I2C à¾×Íè ÊÌҧ໚¹âÁ´ÙÅÊíÒËÃѺµÔ´µ‹Í¡ÑººÑÊ I2C «Öè§ÁÕÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ´Ñ§¹Õé

ÊÑ­­Ò³ SDA “0” Private Sub SDA_L() Out &H37A, Inp(&H37A) And &HFE End Sub

‘SDA=0

ÊÑ­­Ò³ SDA “1” Private Sub SDA_H() Out &H37A, Inp(&H37A) Or 1 End Sub

‘SDA=1

ÊÑ­­Ò³ SCL “0” Private Sub SCL_L() Out &H37A, Inp(&H37A) And &HFD End Sub

‘SCL=0

ÊÑ­­Ò³ SCL “1” Private Sub SCL_H() Out &H37A, Inp(&H37A) Or 2 End Sub

‘SCL=1

͋ҹÊÑ­­Ò³¨Ò¡ SDA Private Function Rd_SDA() As Boolean SDA_H Rd_SDA = (Inp(&H379) And &H80) <> &H80 End Function

ÊÑ­­Ò³ Start Public Sub I2CStart() SDA_H SCL_H SDA_L SCL_L End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 97


ÊÑ­­Ò³ Stop Public Sub I2CStop() SDA_L SCL_H SDA_H End Sub

ʋ§¢ŒÍÁÙÅÅͨԡ “0” Public Sub Send0() SDA_L SCL_H SCL_L End Sub

ʋ§¢ŒÍÁÙÅÅͨԡ “1” Public Sub Send1() SDA_H SCL_H SCL_L End Sub

͋ҹÊÑ­­Ò³ Acknowledge Public Function Ack() As Boolean Ack = Not Rd_SDA SCL_H SCL_L End Function

¡ÒÃ͋ҹÊÑ­­Ò³ Acknowledge ¨Ò¡ÍØ»¡Ã³ Slave ¨Ðª‹ÇÂãˌµÃǨÊͺ䴌Çҋ ÍØ»¡Ã³·µÕè ´Ô µ‹Í¹Ñ¹é Âѧ·íÒ§Ò¹ÍÂÙˋ Ã×ÍäÁ‹

ʋ§ÊÑ­­Ò³ Master Acknowledge Public Sub MAck() SDA_L SCL_H SCL_L End Sub

ʋ§ÊÑ­­Ò³ Master Not Acknowledge Public Sub MNAck() SCL_H SCL_L End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 98


â»Ãá¡ÃÁ‹ÍÂÃѺʋ§ËÃ×Í͋ҹà¢Õ¹¢ŒÍÁÙÅ 8 ºÔµ 㹡ÒÃʋ§áÅÐÃѺ¢ŒÍÁÙÅ 8 ºÔµº¹ÃкººÑÊ I2C ÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ‹ÍÂ䴌´§Ñ ¹Õé

ʋ§¢ŒÍÁÙÅ 8 ºÔµ Public Sub Send8BIT(Data As Byte) Dim i As Integer For i = 7 To 0 Step -1 ‘ Loop 7 Cycle If (Data And 2 ^ i) = 2 ^ i Then ‘Test Bit 0 OR 1 Call Send1 Else Call Send0 End If Next i End Sub

͋ҹ¢ŒÍÁÙÅ 8 ºÔµ Public Function Read8Bit() As Byte Dim Dat1 As Integer Dim i As Integer For i = 7 To 0 Step -1 If Rd_SDA Then ‘Read SDA Dat1 = (2 ^ i) Or Dat1 End If SCL_H SCL_L Next i Read8Bit = Dat1 End Function

‘Data 8 Bit

͹֧è ÊíÒËÃѺâ»Ãá¡ÃÁ‹Í·ѧé ËÁ´·ÕÊè Ìҧ¢Ö¹é ໚¹âÁ´ÙÅÊíÒËÃѺµÔ´µ‹Íº¹ÃкººÑÊ I2C ÃÇÁàÍÒ änjã¹ä¿Å pari2c.bas ºÃèØÍÂÙ㋠¹«Õ´ÃÕ ÍÁ PC interface : Parallel port experiment «Ö§è ¨Ñ´ÁҾÌÍÁ ¡ÑºË¹Ñ§Ê×ÍàŋÁ¹Õé

¡ÒâÂÒ¨íҹǹ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ ´ŒÇÂäÍ«Õ PCF8574A ÊíÒËÃѺ¡ÒÃ㪌§Ò¹ÍÔ¹¾ØµàÍÒµ¾µØ ¨íҹǹÁÒ¡¹Ñ¹é ¢Ò¢Í§¾Íϵ¢¹Ò¹ÍÒ¨¨ÐÁÕ¨Òí ¹Ç¹äÁ‹ÁÒ¡ ¾Í·Õ¨è йíÒä»ãªŒã¹§Ò¹ä´Œâ´ÂµÃ§ ¨Ö§µŒÍ§µ‹ÍÍØ»¡Ã³à¾ÔÁè àµÔÁà¾×Íè ¢ÂÒ¨íҹǹ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ äÍ«Õ¢ÂÒ¾Íϵ¼‹Ò¹ÃкººÑÊ I2C ·Õàè Å×͡㪌¹¤Õé Í× àºÍÏ PCF8574A ·ÕÊè ÒÁÒö¢ÂÒ¾ÍϵÍÔ¹¾Øµ àÍÒµ¾µØ 䴌µÇÑ ÅÐ 8 ª‹Í§ áÅе‹Í¾‹Ç§¡Ñ¹ä´Œ 8 µÑÇ ·íÒãˌÊÒÁÒö¢ÂÒ¾Íϵ䴌ÁÒ¡¶Ö§ 64 ª‹Í§ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 99


A0 1

16

VCC

A1 2

15

SDA

A2 3

14

SCL

13

INT

12

P7

P2 6

11

P6

P3 7

10

P5

VSS 8

9

P4

P0 4 P1 5

2+.&#%" 2+.&#%")

ª×Íè

µíÒá˹‹§¢Ò

˹ŒÒ·Õè

A0

1

ÍÔ¹¾ØµáÍ´à´ÃʵÑÇ·Õè 1

A1

2

ÍÔ¹¾ØµáÍ´à´ÃʵÑÇ·Õè 2

A2

3

ÍÔ¹¾ØµáÍ´à´ÃʵÑÇ·Õè 3

P0

4

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 0

P1

5

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 1

P2

6

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 2

P3

7

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 3

V55

8

¡ÃÒÇ´

P4

9

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 4

P5

10

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 5

P6

11

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 6

P7

12

¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 2 ·ÔÈ·Ò§ºÔµ 7

INT

13

¢ÒàÍÒµ¾µØ ÍÔ¹àµÍÃÃ»Ñ µ(·íÒ§Ò¹·ÕÅè ͨԡ 0)

SCL

14

¢ÒÊÑ­­Ò³¹ÒÌÔ¡ÒÊíÒËÃѺ I C ºÑÊ

SDA

15

¢Ò¢ŒÍÁÙÅÊíÒËÃѺ I C ºÑÊ

V,,

16

ä¿àÅÕÂé §

ÃÙ»·Õè 8-9 ¡ÒèѴ¢ÒáÅЪ×Íè ¢Ò㪌§Ò¹¢Í§äÍ«Õ PCF8574A V,, ǧ¨Ã¨‹Ò¡ÃÐáʤ§·Õè 100 µA

ÊÑ­­Ò³ Write ¢ŒÍÁÙŨҡªÔ¿µÃ¨Õ ÊÔ àµÍÏ

+I ÊÑ­­Ò³ÃÕ૵ ¢³ÐàÃÔÁè ¨‹ÒÂä¿

Q

D

..

P0-P7

5 V55 Q

D

ÊÑ­­Ò³ Read

+I

.. 5 INT

¢ŒÍÁÙÅʋ§ä»Âѧ ªÔ¿µÃ¨Õ ÊÔ àµÍÏ

ÃÙ»·Õè 8-10 ÃÒÂÅÐàÍÕ´ǧ¨Ã¢Ò¾Íϵ¢Í§äÍ«Õ PCF8574A àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 100


¢ŒÍÁÙÅàº×Íé §µŒ¹¢Í§ PCF8574A ÁÕ´§Ñ ¹Õé l ·íÒ§Ò¹·ÕÃè дѺáç´Ñ¹µÑ§é ᵋ 2.5V ¶Ö§ 6V l ¡Ô¹¡ÃÐáÊã¹ÊÀÒÇÐÊáµ¹´ºÒµèÒí à¾Õ§ 10µA l 㪌¡ÒÃàª×Í è Áµ‹ÍẺºÑÊ I2C l ÁÕàÍÒµ¾µ Ø ÍÔ¹àµÍÃÃ»Ñ µáººà´Ã¹à»´ l àÍÒµ¾µ Ø ÊÒÁÒöáŵª¤Ò‹ 䴌 ¢Ñº¡ÃÐáÊ䴌 100µA ¶ŒÒµŒÍ§¡ÒâѺ LED â´ÂµÃ§µŒÍ§µ‹Í µÑǵŒÒ¹·Ò¹¾ÙÅÍÑ»¤‹Ò 4.7k Ω-10 k Ω ࢌҷբè Ò¾Íϵ·Õ¡è Òí ˹´ãˌ໚¹àÍÒµ¾µØ l ÊÒÁÒö¡íÒ˹´µíÒá˹‹§áÍ´à´ÃʢͧäÍ«Õ·Ò§ÎÒÏ´áÇϴnj Â¢Ò A0-A2 ·íÒãˌÊÒÁÒö µ‹Í¾‹Ç§¡Ñ¹ä´Œ¶§Ö 8 µÑÇ ¡ÒèѴ¢ÒáÅÐ˹ŒÒ·Õ¡è Ò÷íÒ§Ò¹¢Í§äÍ«Õ PCF8574A áÊ´§ã¹ÃÙ»·Õè 8-9 ¢Ò¾Íϵ·Ñ§é 8 ¢Ò¢Í§ PCF8574A ÊÒÁÒö¡íÒ˹´ãˌ໚¹ÍÔ¹¾ØµËÃ×ÍàÍÒµ¾µØ 䴌â´ÂÍÔÊÃÐ ÅѡɳÐǧ¨ÃÀÒÂ㹢ͧ¾Íϵ ÍÔ¹¾ØµàÍÒµ¾µØ áÊ´§ã¹ÃÙ»·Õè 8-10 àÁ×Íè ¨‹ÒÂä¿ãˌ¡ºÑ PCF8574A ¤Ãѧé áá ¢Ò¾Íϵ·Ñ§é 8 ¢Ò¨ÐÁÕ Åͨԡ໚¹ “1” «Ö§è ¨Ð໚¹¡Òè‹Ò¡ÃÐáÊÁÒ¨Ò¡áËŋ§¨‹Ò¡ÃÐáʤ§·ÕÀè ÒÂã¹µÑÇäÍ«Õ ·íÒãˌÁ¡Õ ÃÐáÊ ã¹¢³ÐÅͨԡ “1” ¹Õàé ¾Õ§ 100 µA ෋ҹѹé 㹡óշµÕè ͌ §¡ÒÃãˌÁ¡Õ Òè‹Ò¡ÃÐáÊÊÙ§æ ¨íÒ໚¹µŒÍ§ µ‹ÍµÑǵŒÒ¹·Ò¹¾ÙÅÍÑ»àÍÒänj·Õè¢Ò¾ÍϵàËŋҹÕ鴌Ç àÁ×Íè µŒÍ§¡ÒÃãˌ¢Ò¾ÍϵàËŋҹշé Òí ˹ŒÒ·Õàè »š¹ÍÔ¹¾Øµ¨ÐµŒÍ§Ê‹§ÊÑ­­Ò³ãˌ¢ÒàËŋҹÕÁé ÅÕ Í¨Ô¡ “1” àÊÕ¡‹Í¹ àÁ×Íè ¢ÒÍÔ¹¾Øµä´ŒÃºÑ ÊÑ­­Ò³¨Ò¡ÀÒ¹͡»‡Í¹à¢ŒÒÁÒ äÍ«Õ PCF8574A ¨ÐÊÌҧÊÑ­­Ò³ ÍÔ¹àµÍÃÃ»Ñ µ (INT) »‡Í¹ãˌ¤ÍÁ¾ÔÇàµÍÃÃºÑ ÃÙጠ·¹¡ÒõŒÍ§¤ÍµÃǨÊͺ¢ÒÍÔ¹¾ØµÍÂÙµ‹ ÅÍ´àÇÅÒ ÊÑ­­Ò³ÍÔ¹àµÍÃÃ»Ñ µ¹¨Õé ж١ÃÕ૵àÁ×Íè ÁÕ¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙÅËÃ×ÍÁÕ¡ÒÃà»ÅÕÂè ¹¤‹Ò¢Í§ÍÔ¹¾Øµä»ÊÙ¤‹ ҋ à´ÔÁ

¡ÒÃà¢Õ¹â»Ãá¡ÃÁ¤Çº¤ØÁ PCF8574A ´ŒÇ Visual Basic à¹×èͧ¨Ò¡ PCF8574A ÁÕ¡ÒÃàª×èÍÁµ‹Í໚¹áºººÑÊ I2C ´Ñ§¹Ñ鹡ÒõԴµ‹Í¨Ö§µŒÍ§ÍŒÒ§¶Ö§ â»Ãá¡ÃÁ‹Í´ѧ·Õ¡è ŋÒÇä»áŌÇ㹵͹µŒ¹ â´Â¨ÐµŒÍ§Ê‹§¢ŒÍÁÙÅáÍ´à´ÃÊà¾×Íè µÔ´µ‹Í¡Ñº PCF8574A ´Ñ§¹Õé ºÔµ 7 ºÔµ 6 ºÔµ 5 ºÔµ 4 ºÔµ 3 ºÔµ 2 ºÔµ 1 ºÔµ 0 0

1

1

1

A2

A1

A0

R/W

ºÔµ A0, A1, A2 㪌㹡ÒÃÃÐºØ PCF8574A ·Õãè ªŒº¹ºÍϴ㹡óշÁÕè ¡Õ Òõ‹Í PCF8574 ÁÒ¡¡Ç‹Ò 1 µÑÇ â´Â¤‹Ò¢Í§ A0-A2 ¨ÐÁÕ¤ÇÒÁᵡµ‹Ò§¡Ñ¹ä»ã¹áµ‹ÅеÑÇ ºÔµ R/W 㪌¡Òí ˹´Ç‹ÒµŒÍ§¡ÒÃ͋ҹËÃ×Íà¢Õ¹¢ŒÍÁÙšѺäÍ«Õ PCF8574 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 101


¨Ò¡¡ÒáíÒ˹´áÍ´à´ÃÊ A0-A2 ¨ÐãˌÊÒÁÒö¢ÂÒ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 䴌ÁÒ¡¶Ö§ 64 ¨Ø´ ¨Ò¡¡Òõ‹Í¾‹Ç§ PCF8574A ËÇÁ¡Ñ¹¤Ãº 8 µÑÇ µÑÇÍ‹ҧâ»Ãá¡ÃÁ‹Í Sendout µ‹Í仹ÕéáÊ´§ãˌàË繶֧¡ÒÃʋ§¤‹Òä»ÂѧàÍÒµ¾Øµ¢Í§ PCF8574A â´ÂÁÕÅÒí ´Ñº¢Ñ¹é µÍ¹´Ñ§¹Õé

â»Ãá¡ÃÁ‹Í Sendout à¾×Íè ʋ§¢ŒÍÁÙÅ 8 ºÔµ Private Sub Sendout(B As Byte) Call I2CStart ‘Start Call Send8BIT(&H70) ‘Send Address Word Call Ack ‘Acknowledge Call Send8BIT(B) ‘Send Data Call Ack ‘Acknowledge Call I2CStop ‘Stop End Sub

1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊ â´Âã¹·Õ¹è ¨Õé СíÒ˹´áÍ´à´Ãʢͧ PCF8574A änj·Õè 000 (¢Ò A0, A1, A2 µ‹Íŧ¡ÃÒÇ´·§Ñé ËÁ´) áÅÐãˌ·Òí §Ò¹ã¹âËÁ´à¢Õ¹¢ŒÍÁÙÅ â´Â¡Òû‡Í¹Åͨԡ “0” ãˌ ᡋºµÔ R/W 3. ÃÍÃѺÊÑ­­Ò³ ACK ËÃ×ÍÃÍÃѺ¡Òõͺ¡ÅѺ¨Ò¡ PCF8574A 4. ʋ§¢ŒÍÁÙÅä»ÂѧàÍÒµ¾µØ ¢Í§ PCF8574A â´Â¡ÒáíÒ˹´¤‹Òä»ÂѧµÑÇá»Ã B 5. ÃÍÃѺÊÑ­­Ò³ ACK ÍÕ¡¤Ãѧé 6. ʋ§ÊÑ­­Ò³ STOP

EX-07 ºÍÏ´¢ÂÒÂÍÔ¹¾ØµàÍÒµ¾µØ ¢¹Ò´ 16 ºÔµ¼‹Ò¹ÃкººÑÊ I2C ºÍÏ´ EX-07 ¨ÐÁÕäÍ«Õ PCF8574A ÍÂÙº‹ ¹ºÍÏ´·Ñ§é ËÁ´ 2 µÑÇ ·íÒãˌÊÒÁÒö¹íÒä»ãªŒã¹ ¡ÒâѺÍØ»¡Ã³àÍÒµ¾ØµËÃ×Í͋ҹ¤‹Ò¨Ò¡ÍØ»¡Ã³ÍÔ¹¾Øµä´ŒµÒÁµŒÍ§¡ÒÃÁÒ¡¶Ö§ 16 ª‹Í§ â´ÂÁÕÃÒ ÅÐàÍÕ´¢Í§Ç§¨ÃáÊ´§ã¹ÃÙ»·Õè 8-11 º¹ºÍÏ´ EX-07 ¨ÐÁÕ¨ÁÑê à»ÍÏÊÒí ËÃѺàÅ×Í¡áÍ´à´Ãʢͧ PCF8574A ᵋÅеÑÇ ã¹¡ÒÃ㪌§Ò¹¨ÐµŒÍ§¡íÒ˹´áÍ´à´ÃÊänj¤¹ÅеíÒá˹‹§¡Ñ¹ äÁ‹àª‹¹¹Ñ¹é ¨Ð ·íÒãˌà¡Ô´¡Ò÷íÒ§Ò¹·Õè·Ñº«ŒÍ¹¡Ñ¹«Öè§ÍҨʋ§¼Å¶Ö§¢Ñé¹äÍ«ÕàÊÕÂËÒÂ䴌 à¹×Íè §¨Ò¡ãªŒ¡ÒõԴµ‹Í໚¹ÃкººÑÊ I2C ·íÒãˌÊÒÁÒöµ‹ÍºÍÏ´ EX-07 ¾‹Ç§¡Ñ¹ä´ŒËÅÒÂæ ºÍÏ´à¾×Íè ¢ÂÒ¾ÍϵãˌÁ¨Õ Òí ¹Ç¹ÁÒ¡¢Ö¹é â´ÂÊÒÁÒöµ‹Í¾‹Ç§ä´ŒÊ§Ù ÊØ´ 8 ºÍÏ´ (ÃÇÁºÍÏ´àÃÔÁè µŒ¹´ŒÇÂ) áÅÐà¾×Íè ÍíҹǺ¤ÇÒÁÊдǡ㹡Òõ‹Í¾‹Ç§ º¹ºÍÏ´ EX-07 䴌¨´Ñ àµÃÕÂÁᨍ¡ÊíÒËÃѺàª×Íè Á µ‹Í໚¹áººâÁ´ÙÅҋ ÏËÃ×Í·Õàè ÃÕ¡¡Ñ¹·ÑÇè ä»Ç‹Ò ᨍ¡â·ÃÈѾ·¢¹Ò´ 4 ¢Ò¨íҹǹ 2 ªØ´¾ÃŒÍÁÊÒÂÊíÒËÃѺ àª×Íè Áµ‹Í àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 102


R701 R-network 4.7k x8

+5V

+5V K701

15 14 1

+5V K702

JP701

JP702 JP703

2

A0

A1

P7

SDA

P6 P5

SCL

P4

A0

P3 P2

A1

P0

A2

K703

DATA BUS (UIC-10)

P1 3

I C BUS CONNECTOR

16

IC701 PCF8574

+5V

12 11 10

D0 D2 D4 D6

9 7 6 5

D1 D3 D5 D7

4

8

A2

ADDRESS SELECT R702 R-network 4.7k x8

+5V

IC702 PCF8574 15 SDA 14 SCL 1 JP704

JP705

2 JP706

A1

A2

P7 P6 P5 P4

A0

P3 P2

A1

P0

A2

K704

DATA BUS (UIC-10)

P1 3

A0

16

+5V

12 11 10 9 7 6 5

D0 D2 D4 D6

D1 D3 D5 D7

4

8

ADDRESS SELECT

EX-07 ºÍÏ´¢ÂÒÂÍÔ¹¾ØµàÍÒµ¾Øµ¼‹Ò¹ ÃкººÑÊ I2C 㪌¡ÒÃàª×Íè Áµ‹ÍẺºÑÊ I2C ´ŒÇÂᨍ¡âÁ´ÙÅҋ Ï l ¢ÂÒ¾Íϵº¹ºÍϴ䴌 16 ºÔµ áÅе‹Í¾‹Ç§¡Ñ¹ à¾×Íè ¢ÂÒÂ䴌ʧ٠ÊØ´ÍÕ¡ 3 ºÍÏ´ ÃÇÁ 64 ºÔµ l àÅ×Í¡áÍ´à´ÃÊ㹡ÒõԴµ‹Íâ´Â¡ÒÃ㪌¨Á Ñê à»ÍÏ l ¤Í¹à¹ç¡àµÍÏ DATA BUS à¾×Í è àª×Íè Áµ‹Í¡ÑººÍÏ´ EX-series l

ÃÙ»·Õè 8-11 ǧ¨ÃÊÁºÙó¢Í§ EX-07 ºÍÏ´¢ÂÒ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ ¼‹Ò¹ÃкººÑÊ I2C ǧ¨ÃàÍÒµ¾µØ ¢Í§ PCF8574A ໚¹áºº¤ÍÅàÅç¡àµÍÏແ´ ´Ñ§¹Ñ¹é ·Õ¢è Ò¾Íϵ¢Í§ PCF8574A ¨ÐµŒÍ§µ‹ÍµÑǵŒÒ¹·Ò¹¾ÙÅÍÑ»à¾×èÍ¡íÒ˹´ãˌã¹ÀÒÇл¡µÔ ¢Ò¾ÍϵÁÕʶҹÐÅͨԡ “1” àÍÒµ¾Øµ ¢Í§ PCF8574A ¨Ðµ‹Í¡Ñº¤Í¹à¹ç¡àµÍÏ DATA BUS «Ö§è ÊÒÁÒö¹íÒ仵‹Í¡ÑººÍÏ´ EX-Series µÑÇÍ×¹è æ 㹪ش·´Åͧ NX-2000 䴌·¹Ñ ·Õ ઋ¹ µ‹Í¡Ñº EX-06 à¾×Íè ¢ÑºÃÕàŏ, µ‹Í¡ÑººÍÏ´ EX-01 à¾×Íè ¢Ñº LED áÊ´§¤‹Ò¢Í§¢ŒÍÁÙÅ ,µ‹Í¡ÑººÍÏ´ EX-03 à¾×Íè ÃѺ¤‹Ò¨Ò¡ÊÇÔµª ËÃ×͵‹Í¡Ñº EX-05 à¾×Íè ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ ໚¹µŒ¹ ä¿àÅÕÂé §·Õãè ªŒÊÒí ËÃѺºÍÏ´ EX-07 ÁÒ¨Ò¡ P-Board ¼‹Ò¹·Ò§á¨¡ I2C ´Ñ§¹Ñ鹨֧äÁ‹¨íÒ໚¹µŒÍ§¨Ñ´ËÒáËŋ§¨‹ÒÂä¿à¾ÔèÁàµÔÁ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 103


¡Ò÷´Åͧ·Õè 11 ¢ÂÒ¾Íϵ¢Í§¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³

1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-07 ºÍÏ´¢ÂÒ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ ¼‹Ò¹ÃкººÑÊ I2C 1 Ἃ¹ 3. EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ 1 Ἃ¹ 4. EX-03 ºÍÏ´ÊÇÔµªÍ¹Ô ¾Øµ 1 Ἃ¹ 5. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 6. ÊÒ I2C 1 àʌ¹ 7. ÊÒÂàª×Íè Áµ‹Í IDC-10 1 àʌ¹

¡Ò÷´Åͧ ¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×Íè µÔ´µ‹Í¡ÑººÍÏ´ EX-07 11.1 ãˌãʋ¨ÁÑê à»ÍÏà¾×Íè àÅ×Í¡áÍ´à´ÃÊ A2-A0 ¢Í§äÍ«Õ PCF8574A µÑÇ·Õè 1 º¹ºÍÏ´ EX-07 änj·Õè 000 ʋǹÍÕ¡µÑÇ˹֧è àÅ×Í¡áÍ´à´ÃÊänj·Õè 001 11.2 àª×Íè Áµ‹Í P-Board ¡Ñº EX-07 â´Â㪌ÊÒ I2C áÅÐàª×Íè Áµ‹Í¡ÑººÍÏ´ EX-01 ´ŒÇÂÊÒ IDC-10 ´Ñ§áÊ´§ã¹ÃÙ»·Õè P11-1 11.3 à¢Õ¹â»Ãá¡ÃÁà¾×èÍà¾ÔèÁâÁ´ÙÅ¡ÒõԴµ‹Í¡ÑººÑÊ I2C µÒÁ·ÕèáÊ´§ÃÒÂÅÐàÍÕ´änjã¹Ê‹Ç¹¢Í§ ·ÄÉ®Õ (˹ŒÒ·Õè 97) ËÃ×ÍàÃÕ¡㪌§Ò¹ä¿Å pari2c.bas 11.4 à¢Õ¹â»Ãá¡ÃÁʋ§¢ŒÍÁÙÅÍÍ¡·Ò§àÍÒµ¾µØ ¢Í§ PCF8574A à¾×Íè ¢Ñº LED º¹ºÍÏ´ EX-01 Private Sub Command1_Click() Sendout (&HAA) End Sub Private Sub Sendout(B As Byte) Call I2CStart ‘Start Call Send8BIT(&H70) ‘Send Address Word Call Ack ‘Acknowledge Call Send8BIT(B) ‘Send Data Call Ack ‘Acknowledge Call I2CStop ‘Stop End Sub

ÃٻËҧ˹ŒÒµÒ¢Í§â»Ãá¡ÃÁʋ§¤‹Ò¢ŒÍÁÙÅ·Õèà¢Õ¹¢Öé¹¹ÕéáÊ´§ã¹ÃÙ»·Õè P11-2 ʋǹâ»Ãá¡ÃÁ µÑÇÍ‹ҧÊÒÁÒöàÃÕ¡ÁÒ㪌§Ò¹ä´Œ¨Ò¡â»Ãá¡ÃÁ LAB11A.VBP ã¹á¼‹¹«Õ´ÃÕ ÍÁ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 104


ÃÙ»·Õè P11-1 áÊ´§¡ÒÃàª×Íè Áµ‹Í P-Board, ÃÙ»·Õè P11-2 ˹ŒÒµÒ¢Í§â»Ãá¡ÃÁ·´Åͧ ºÍÏ´ EX-07 áÅÐ EX-01 à¾×Íè ·íÒ¡Ò÷´Åͧ ʋ§¢ŒÍÁÙÅÍÍ¡·Ò§àÍÒµ¾µØ ¢Í§ PCF8574A ¢ÂÒ¾ÍϵàÍÒµ¾µØ ¼‹Ò¹ÃкººÑÊ I2C º¹ºÍÏ´ EX-07

¡ÒÃ͋ҹ¤‹ÒÍÔ¹¾Øµ¨Ò¡ÍØ»¡Ã³ÃкººÑÊ I2C

¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙŨҡºÑÊ I2C µŒÍ§¡íÒ˹´ãˌºÊÑ Ç‹Ò§¡‹Í¹ ᵋ¡Í‹ ¹Í‹Ò¹¤‹Ò¨ÐµŒÍ§ÃкØ㹺Ե ÊØ´·ŒÒ¢ͧáÍ´à´ÃÊ´ŒÇÂNjҵŒÍ§¡ÒÃ͋ҹ¢ŒÍÁÙÅâ´Â¡ÒÃ૵ºÔµ¹Ñ¹é ໚¹ “1” áŌǨ֧͋ҹ¢ŒÍÁÙÅࢌÒÁÒ ¡ÒÃà¢Õ¹â»Ãá¡ÃÁ´ŒÇ Visual BASIC à¾×Íè ͋ҹ¢ŒÍÁÙÅ 8 ºÔµ¨Ð㪌¿§˜ ¡ª¹Ñ Read8Bit â´Â㪌 ¡ÒÃǹÅÙ» 8 ¤Ãѧé áŌÇà»ÃÕºà·Õº¤‹Ò·ÕÍè ҋ ¹ä´ŒÇҋ ໚¹ 0 ËÃ×Í 1 àÁ×Íè àÃÕ¡㪌¿§˜ ¡ª¹Ñ Read8Bit ¿˜§¡ª¹Ñè ¹Õ¨é Ф׹¤‹Ò¢ŒÍÁÙÅ 8 ºÔµ·ÕÍè ҋ ¹ä´Œ¡ÅѺÁÒ ¨ÐàËç¹Ç‹ÒàÁ×Íè ͋ҹ¤‹Ò 1 ºÔµ µŒÍ§Ê‹§ÊÑ­­Ò³¹Ò́¡Ò 1 ÅÙ¡

¡ÒÃ͋ҹ¤‹ÒÍÔ¹¾Øµ¨Ò¡ºÍÏ´ EX-07 11.5 ¹Í¡¨Ò¡¨Ð㪌 ºÍÏ´ EX-07 㹡ÒÃʋ§¤‹ÒÍÍ¡àÍÒµ¾µØ áÅŒÇ Âѧ㪌Íҋ ¹¤‹Ò¡ÒÃà»ÅÕÂè ¹á»Å§·Õè ÍÔ¹¾Øµä´Œ´ÇŒ  â´Âã¹·Õ¹è ¨Õé Ð㪌ºÍÏ´ EX-03 «Ö§è ໚¹ºÍÏ´ÊÇÔµªàª×Íè Áµ‹ÍࢌҡѺ¤Í¹à¹ç¡àµÍÏ DATA BUS º¹ºÍÏ´ EX-07 ¨Ò¡¹Ñ¹é ·íÒ¡ÒÃà¾ÔÁè àµÔÁâ»Ãá¡ÃÁà¾×Íè ͋ҹ¤‹Ò¨Ò¡ÊÇÔµª â´Â㪌 Timer1 ´Ñ§¹Õé Private Sub Timer1_Timer() Call I2CStart ‘Start Call Send8BIT(&H71) ‘Send Control Word Call Ack ‘Acknowledge Text1.Text = Hex$(DAT) Call Ack Call I2CStop End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 105


¡ÒÃ͋ҹ¤‹Ò¨ÐµŒÍ§·íҴѧ¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§áÍ´à´Ãʢͧ PCF8574A ·Õ赌ͧ¡ÒõԴµ‹Í ¾ÃŒÍÁ·Ñé§ÃкØNjҵŒÍ§¡ÒÃ͋ҹ¢ŒÍÁÙÅ 3. ʋ§ÊÑ­­Ò³ Acknowledge 4. ͋ҹ¢ŒÍÁÙÅâ´Â¡ÒÃàÃÕ¡㪌§Ò¹¿˜§¡ª¹Ñ Read8Bit 5. ʋ§ÊÑ­­Ò³ Acknowledge µÒÁ´ŒÇÂÊÑ­­Ò³ ÃÙ»·Õè P11-3 ˹ŒÒµ‹Ò§¢Í§â»Ãá¡ÃÁ STOP ÃѺ¤‹ÒÍÔ¹¾Øµ¼‹Ò¹ÃкººÑÊ I2C ¨Ò¡·´Åͧ㪌 Timer 㹡Ò÷íÒ§Ò¹ ·íÒãˌ¡ÒÃ͋ҹ¤‹Ò໚¹ä»Í‹ҧµ‹Íà¹×Íè § ᵋ¨ÐµŒÍ§¡íÒ˹´ ¤‹Ò Interval ·Õàè ËÁÒÐÊÁ´ŒÇ â´Ââ»Ãá¡ÃÁ·´ÅÍ§ã¹¢Ñ¹é µÍ¹¹Õ¡é Òí ˹´¤‹Ò Interval ෋ҡѺ 100 ¤íÒÊѧè HEX$ ·Õãè ʋänj´ÒŒ ¹Ë¹ŒÒ¿˜§¡ª¹Ñè Read8Bit ª‹ÇÂãˌ¤Ò‹ ·ÕÍè ҋ ¹ä´Œà»š¹àÅ¢°Ò¹ÊԺˡ 11.6 Ãѹâ»Ãá¡ÃÁ·Õèà¢Õ¹¢Öé¹ ¨Ò¡¹Ñé¹·´Åͧ»‡Í¹¤‹Ò¨Ò¡ºÍÏ´ EX-03 â´Â¡Òá´ÊÇÔµª¡´µÔ´ »Å‹Í´Ѻ Êѧࡵ¼Å¤‹Ò·Õè˹ŒÒ¨Í«Öè§áÊ´§ÍÂً·Õè Text1 â´Â¶ŒÒ¡íÒ˹´¤‹Ò Interval ¢Í§ Timer1 àÍÒänj¹ŒÍ¼šÒÃà»ÅÕè¹á»Å§¤‹Ò¨Ò¡¡Òá´ÊÇÔµª¨Ðà¡Ô´¢Öé¹Í‹ҧÃÇ´àÃçÇ Ë¹ŒÒµÒ¢Í§â»Ãá¡ÃÁ ͋ҹ¤‹Ò¢ŒÍÁÙÅáÊ´§ã¹ÃÙ»·Õè P11-3 ʋǹâ»Ãá¡ÃÁÊÁºÙóÊÒÁÒöແ´ä´Œ¨Ò¡ä¿Å LAB11B.VBP

¡Ò÷´Åͧʋ§áÅÐ͋ҹ¤‹Ò¾ÃŒÍÁ¡Ñ¹¡ÑººÍÏ´ EX-07 11.7 ແ´â»Ãá¡ÃÁ LAB11C.VBP ã¹á¼‹¹«Õ´ÃÕ ÍÁ PC interface : Parallel port Experiment ¾ÃŒÍÁ ¡Ñºàª×Íè Áµ‹Í P-Board, EX-07, EX-01 áÅÐ EX-03 ࢌҴŒÇ¡ѹ ´Ñ§ã¹ÃÙ»·Õè P11-4 ¨Ð໚¹¡Ò÷´Åͧ㪌 §Ò¹ºÍÏ´ EX-07 ÃѺáÅÐʋ§¢ŒÍÁÙÅ㹤ÃÒÇà´ÕÂǡѹ â´ÂÁÕ˹ŒÒµÒ¢Í§â»Ãá¡ÃÁáÊ´§ã¹ÃÙ»·Õè P11-5 µ‹Í¡Ñº¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏ

EX-01

P-Board

EX-07

DIP SW. x8

ÃÙ»·Õè P11-5 ˹ŒÒµ‹Ò§¢Í§â»Ãá¡ÃÁ¤Çº¤ØÁ ÃÙ»·Õè P11-4 ¡ÒÃàª×Íè Áµ‹ÍºÍÏ´µ‹Ò§æ à¾×Íè ¾ÍϵÍÔ¹¾ØµàÍÒµ¾µØ 16 ª‹Í§¼‹Ò¹ÃкººÑÊ I2C â´Â㪌ºÍÏ´ EX-07 ·íÒ¡Ò÷´Åͧ㹢ŒÍ 11.7 EX-03

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 106


º··Õè 9 ¡ÒÃàª×Íè Áµ‹Í¡ÑºÊÑ­­Ò³ÍйÒÅÍ¡ ¢Í§¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C »¡µÔáŌǢŒÍÁÙÅ㹡ÒõԴµ‹Í¡Ñº¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍϹÑ鹨Ð໚¹ÊÑ­­Ò³´Ô¨ÔµÍÅ ·Ñ§é ÊÔ¹é ᵋàÁ×Íè ¹íÒÁÒàª×Íè Áµ‹Í¡ÑºÍØ»¡Ã³ÀÒ¹͡áÅŒÇ Â‹ÍÁµŒÍ§àª×Íè Áµ‹ÍáÅлÃÐÁÇżšѺÊÑ­­Ò³ ÍйÒÅÍ¡´ŒÇ 㹡ÒÃàª×Íè Áµ‹Í¡ÑºÊÑ­­Ò³ÍйÒÅÍ¡µŒÍ§ãªŒäÍ«Õ¾àÔ ÈÉ·Õ·è Òí ˹ŒÒ·Õãè ¹¡ÒÃá»Å§ÊÑ­­Ò³ ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅËÃ×Í·Õàè ÃÕÂ¡Ç‹Ò äÍ«Õ ADC (Analog to Digital Converter) 㹺·¹Õ¨é Ð໚¹¡Òà á¹Ð¹íÒáÅÐàÃÕ¹Ãٌà¾×èÍ㪌§Ò¹äÍ«Õ ADC àª×èÍÁµ‹Í¡Ñº¾Íϵ¢¹Ò¹ à¾×èÍãˌ¾Íϵ¢¹Ò¹ÊÒÁÒö͋ҹ ¤‹ÒÊÑ­­Ò³ÍйÒÅÍ¡¨Ò¡ÀÒ¹͡ࢌÒÁÒ»ÃÐÁÇżÅ䴌 â´ÂäÍ«Õ ADC ·Õãè ªŒà»š¹àºÍÏ PCF8591 «Ö§è ÁÕû٠Ẻ¡ÒÃàª×Íè Áµ‹ÍẺºÑÊ I2C

¢ŒÍÁÙÅàº×Íé §µŒ¹¢Í§ PCF8591 PCF8591 ໚¹äÍ«Õ·Òí ˹ŒÒ·Õáè »Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅáÅÐá»Å§ÊÑ­­Ò³´Ô¨µÔ ÍŠ໚¹ÍйÒÅÍ¡ã¹µÑÇà´ÕÂǡѹ ໚¹¼Å§Ò¹¢Í§¿Å»Ô ʏ à«ÁԤ͹´Ñ¡àµÍÏ ¼Ù¾Œ ² Ñ ¹ÒÃкººÑÊ I2C ¹Ñ¹è àͧ ´ŒÇ¤ÇÒÁÊÒÁÒö·ÕèÃÇÁàÍÒǧ¨Ã ADC áÅÐ DAC ࢌÒänjã¹äÍ«Õà¾Õ§µÑÇà´ÕÂÇ ·íÒãˌÊÒÁÒö¹íÒ PCF8591 ä»ãªŒ§Ò¹ä´Œ¡ÇŒÒ§¢ÇÒ§ â´Â¤Ø³ÊÁºÑµ·Ô ҧ෤¹Ô¤·ÕÊè Òí ¤Ñ­¢Í§ PCF8591 ÁÕ´§Ñ ¹Õé 1. ·íÒ§Ò¹´ŒÇ¤ÇÒÁÅÐàÍÕ´¢Í§¢ŒÍÁÙÅ´Ô¨µÔ ÍÅ¢¹Ò´ 8 ºÔµ 2. ÁÕǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅ (ADC) ¢¹Ò´ 8 ºÔµ 4 ª‹Í§ 3. ÁÕǧ¨Ãá»Å§ÊÑ­­Ò³´Ô¨µÔ ÍÅ໚¹ÍйÒÅÍ¡ (DAC) ¢¹Ò´ 8 ºÔµ 1 ª‹Í§ 4. ·íÒ§Ò¹â´Â㪌áËŋ§¨‹ÒÂ俪شà´ÕÂÇ µÑ§é ᵋ 2.5-6V 5. ¡Ô¹¡ÃÐáÊä¿¿‡Ò¢³ÐÍÂÙ㋠¹ÊÀÒÇÐÊáµ¹ºÒ´µÒèí 6. µÔ´µ‹Í¡ÑºäÁâ¤Ã¤ÍÁ¾ÔÇàµÍÏËÃ×ÍäÁâ¤Ã¤Í¹â·ÃÅàÅÍϼҋ ¹ÃкººÑÊ I2C 7. ÊÒÁÒöàÅ×Í¡µíÒá˹‹§áÍ´à´ÃÊ·Ò§ÎÒÏ´áÇϨҡ¢Ò A0, A1, A2 ·íÒãˌÊÒÁÒöµ‹Í¾‹Ç§ ¡Ñ¹ä´ŒÊ§Ù ÊØ´¶Ö§ 8 µÑÇ ¨Ö§¢ÂÒ¨íҹǹª‹Í§ÍÔ¹¾Øµ¢Í§ÊÑ­­Ò³ÍйÒÅ͡䴌ʧ٠¶Ö§ 32 ª‹Í§ áÅЪ‹Í§ àÍÒµ¾µØ ¢Í§ÊÑ­­Ò³ÍйÒÅÍ¡¨Ò¡Ç§¨Ã DAC ÊÙ§¶Ö§ 8 ª‹Í§ 8. ÍѵÃÒ¡ÒÃÊØÁ‹ ¢ŒÍÁÙÅ (samping) ¢Ö¹é ÍÂÙ¡‹ ºÑ ¤ÇÒÁàÃçǢͧÊÑ­­Ò³¹Ò́¡Òº¹ºÑÊ I2C àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 107


9. ǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨ÔµÍÅ (ADC) ÊÒÁÒöàÅ×Í¡¡Ò÷íҧҹ໚¹áºº ᡪ‹Í§ËÃ×Í·íҧҹ໚¹Ç§¨Ã´Ô¿à¿ÍàùàªÕÂÅ䴌 㹡óշ¡Õè Òí ˹´à»š¹´Ô¿à¿ÍàùàªÕÂÅ ¨íҹǹª‹Í§ ÍÔ¹¾Øµ¨ÐŴŧàËÅ×Í 2 ª‹Í§ 10. ¡ÒÃ͋ҹ¤‹ÒÊÒÁÒö¡íÒ˹´ãˌàÅ×Íè ¹ª‹Í§ÍÔ¹¾Øµâ´ÂÍѵâ¹ÁѵäÔ ´Œ 11. ÊÒÁÒöÃѺÊÑ­­Ò³ÍйÒÅÍ¡ÃдѺáç´Ñ¹µÑ§é ᵋ VSS 仨¹¶Ö§ VDD 12. ǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅ໚¹áºº«Ñ¡à«Ê«Õ¿áÍ»¾ÃçÍ¡«ÔàÁªÑ¹è PCF8591 ÊÒÁÒö·íÒ˹ŒÒ·Õàè »š¹äÍ«Õá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅ¢¹Ò´ 8 ºÔµ 4 ª‹Í§ áÅÐ໚¹äÍ«Õá»Å§ÊÑ­­Ò³´Ô¨µÔ ÍÅ໚¹ÍйÒÅ͡䴌㹤ÃÒÇà´ÕÂǡѹ ´ŒÇ¡ÒäǺ¤ØÁ¼‹Ò¹ÃкººÑÊ I2C ·íÒãˌÊÒÁÒöµ‹Í¾‹Ç§äÍ«Õ PCF8591 䴌ʧ٠ÊØ´ 8 µÑÇ ÃͧÃѺ¡ÒÃ͋ҹ¤‹ÒÊÑ­­Ò³ÍйÒÅÍ¡ÍÔ¹¾Øµ 䴌ʧ٠ÊØ´¶Ö§ 32 ª‹Í§ áÅÐʋ§ÊÑ­­Ò³ÍйÒÅÍ¡àÍÒµ¾µØ ÊÙ§Êش䴌 8 ª‹Í§´ŒÇ¡ÒáíÒ˹´áÍ´à´ÃÊ ¨Ò¡¢Ò A0, A1 áÅÐ A2 ¡ÒèѴ¢ÒáÅÐÃÒÂÅÐàÍÕ´µíÒá˹‹§¢Ò¢Í§ PCF8591 áÊ´§ã¹ÃÙ»·Õè 9-1 AN0 1

16

VDD

ª×èÍ

µíÒá˹‹§¢Ò

AN1 2

15

AOUT

AN0

1

ÍйÒÅÍ¡ÍÔ¹¾Øµª‹Í§·Õè 1

AN2

3

14

VREF

AN3

2

ÍйÒÅÍ¡ÍÔ¹¾Øµª‹Í§·Õè 2

13

AGND

AN1

4

12

EXT

AN2

3

ÍйÒÅÍ¡ÍÔ¹¾Øµª‹Í§·Õè 3

A1 6

11

OSC

AN3

4

ÍйÒÅÍ¡ÍÔ¹¾Øµª‹Í§·Õè 4

A2 7

10

SCL

A0

5

¢Ò¡íÒ˹´áÍ´à´ÃÊ·Ò§ÎÒÏ´áÇϺԵ 0

VSS 8

9

SDA

A1

6

¢Ò¡íÒ˹´áÍ´à´ÃÊ·Ò§ÎÒÏ´áÇϺԵ 1

A2

7

¢Ò¡íÒ˹´áÍ´à´ÃÊ·Ò§ÎÒÏ´áÇϺԵ 2

VSS

8

¡ÃÒÇ´

SDA

9

¢Ò¢ŒÍÁÙÅÊíÒËÃѺºÑÊ I C

SCL

10

¢ÒÊÑ­­Ò³¹ÒÌÔ¡ÒÊíÒËÃѺºÑÊ I C

OSC

11

¢ÒÍԾصàÍÒµ¾ØµÍÍÊ«ÔÅàÅàµÍÏ

EXT

12

¢ÒàÅ×Í¡ÍÍÊ«ÔÅàÅàµÍÏÀÒÂã¹ËÃ×ÍÀÒ¹͡

AGND

13

¡ÃÒÇ´ÍйÒÅÍ¡

V4-.

14

¢ÒÍÔ¹¾ØµÊíÒËÃѺáç´Ñ¹ÍŒÒ§ÍÔ§

AOUT

15

¢ÒÍйÒÅÍ¡àÍÒµ¾Øµ(ǧ¨Ã DAC)

VDD

16

ä¿àÅÕé§

A0 5

2+.&#'

˹ŒÒ·Õè

ÃÙ»·Õè 9-1 ¡ÒèѴ¢ÒáÅеÒÃÒ§áÊ´§ª×Íè ¢ÒÊÑ­­Ò³¢Í§ PCF8591 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 108


ÃÒÂÅÐàÍÕ´¿˜§¡ª¹Ñè µ‹Ò§æ ¢Í§ PCF8591 µíÒá˹‹§áÍ´à´ÃÊ

ã¹ÃкººÑÊ I2C ¡ÒõԴµ‹Í¡ÑºÍØ»¡Ã³áµ‹ÅеÑǵŒÍ§ÃкØáÍ´à´ÃʢͧÍØ»¡Ã³àËŋҹѹé Í‹ҧ ªÑ´à¨¹ ¶ŒÒ໚¹¡ÒÃ͌ҧ¶Ö§áºº 7 ºÔµ ¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊ 4 ºÔµº¹¨Ð໚¹¤‹ÒáÍ´à´ÃÊ੾ÒÐ ¢Í§ÍØ»¡Ã³µÑǹÑé¹æ ·Õè¡íÒ˹´ÁÒ¨Ò¡¼ÙŒ¼ÅÔµ ¼ÙŒãªŒ§Ò¹äÁ‹ÊÒÁÒöà»ÅÕè¹á»Å§ä´Œ ÊíÒËÃѺäÍ«Õ PCF8591 ¨ÐÁդҋ ෋ҡѺ 1001 (°Ò¹Êͧ) ¢ŒÍÁÙÅ 3 ºÔµ¶Ñ´ÁÒ¨Ð໚¹¤‹Ò¢Í§áÍ´à´ÃÊ·Õ¼è ãٌ ªŒ§Ò¹ ÊÒÁÒö¡íÒ˹´ä´Œ·Ò§ÎÒÏ´áÇÏà¾×èÍàÅ×Í¡äÍ«Õ PCF8591 ·Õ赌ͧ¡ÒõԴµ‹Í´ŒÇÂ㹡óշÕèÁÕ¡Òõ‹Í 㪌§Ò¹ PCF8591 ÁÒ¡¡Ç‹Ò 1 µÑÇ Ê‹Ç¹ºÔµ LSB 㪌㹡ÒáíÒ˹´Ç‹ÒµŒÍ§¡ÒÃ͋ҹËÃ×Íà¢Õ¹¢ŒÍÁÙšѺ äÍ«ÕµÇÑ ¹Ñ¹é æ â´ÂÁÕû٠Ẻ¡ÒáíÒ˹´¤‹Ò´Ñ§¹Õé µÑÇÍ‹ҧઋ¹ ¶ŒÒµŒÍ§¡Òà ͋ҹ¢ŒÍÁÙŨҡªÔ»·Õ¡è Òí ˹´áÍ´à´ÃÊänj໚¹ 000 ¨ÐµŒÍ§»‡Í¹¢ŒÍÁÙÅ áÍ´à´ÃÊ෋ҡѺ &H91 ໚¹µŒ¹

¢ŒÍÁÙŤǺ¤ØÁ ËÅѧ¨Ò¡Ê‹§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊãˌᡋ PCF8591 áÅŒÇ µŒÍ§Ê‹§¢ŒÍÁÙŤǺ¤ØÁµÒÁä»´ŒÇ à¾×Íè ¡íÒ˹´¤Ø³ÊÁºÑµ¢Ô ͧǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅáÅÐǧ¨Ãá»Å§ÊÑ­­Ò³´Ô¨µÔ ÍŠ໚¹ÍйÒÅÍ¡ÀÒÂã¹ PCF8591 â´ÂÁÕÃÒÂÅÐàÍÕ´¢Í§¢ŒÍÁÙÅã¹áµ‹ÅкԵ´Ñ§ã¹ÃÙ»·Õè 9-2 ºÔµ 6 ¢Í§¢ŒÍÁÙŤǺ¤ØÁ㪌ÊÒí ËÃѺ¡ÒÃàÍç¹àÍàºÔÅ¢ÒÍйÒÅÍ¡àÍÒµ¾µØ àÁ×Íè µŒÍ§¡ÒÃàÍç¹àÍàºÔÅ µŒÍ§¡íÒ˹´ãˌ¢Ò¹Õàé »š¹ “1” ºÔµ 4 áÅкԵ 5 ¢Í§¢ŒÍÁÙŤǺ¤ØÁ㪌ÊÒí ËÃѺ¡ÒáíÒ˹´ÃٻẺ¢Í§ÊÑ­­Ò³ÍйÒÅÍ¡ÍÔ¹¾Øµ ·Õ»è ͇ ¹ãˌᡋ PCF8591 ºÔµ 2 㪌ÊÒí ËÃѺàÅ×Í¡ÃٻẺ¡ÒÃ͋ҹ¢ŒÍÁÙŨҡ¢ÒÍÔ¹¾ØµÍйÒÅ͡NjҨÐ໚¹¡ÒÃ͋ҹ¨Ò¡à¾Õ§ ÍÔ¹¾Øµà´ÕÂÇËÃ×Í͋ҹẺàÃÕ§ÅíҴѺ·Ø¡ÍÔ¹¾Øµ ¶ŒÒµŒÍ§¡ÒÃàÅ×Í¡ãˌÍҋ ¹áººàÃÕ§ÅíҴѺµŒÍ§¡íÒ˹´ ãˌºµÔ ¹Õàé »š¹ “1” ºÔµ 0 áÅкԵ 1 㪌ÊÒí ËÃѺ¡íÒ˹´ª‹Í§¢Í§ÍÔ¹¾ØµÍйÒÅÍ¡·Õµè ͌ §¡ÒÃ͋ҹ ¶ŒÒ¡íÒ˹´ãˌ ºÔµ 2 ໚¹ “1” ËÅѧ¨Ò¡Í‹Ò¹¤‹Ò¢Í§ºÔµ “0”áÅкԵ “1” áÅŒÇ ã¹¡ÒÃ͋ҹ¤‹Ò¤ÃÑ§é µ‹Í仨Ð໚¹¡Òà ͋ҹ¤‹ÒÍÔ¹¾Øµ¨Ò¡ª‹Í§·Õè 1 ¢ŒÍÁÙŤǺ¤ØÁ·Ñ§é ËÁ´¨Ð¶Ù¡à¡çºänjã¹ÃÕ¨ÊÔ àµÍϤǺ¤ØÁÀÒÂã¹ PCF8591 àÁ×Íè ¨‹ÒÂä¿ãˌᡋ PCF8591 ¤Ãѧé áá ºÔµµ‹Ò§æ ¢ŒÍÁÙÅÀÒÂã¹ÃÕ¨ÊÔ àµÍϤǺ¤ØÁ¨Ð¶Ù¡¡íÒ˹´ ãˌ໚¹ “0” àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 109




:

:

:



:

:

:

ª‹Í§ÍÔ¹¾Øµ¢Í§ A/D ·Õ赌ͧ¡ÒõԴµ‹Í 00 ª‹Í§ 0 01 ª‹Í§ 1 10 ª‹Í§ 2 11 ª‹Í§ 3

¡íÒ˹´ÃٻẺ¢Í§ÍйÒÅÍ¡ÍÔ¹¾Øµ AN0 AN1 AN2 AN3

00 ÍÔ¹¾Øµáµ‹ÅЪ‹Í§á¡¡Ñ¹ÍÔÊÃÐ ª‹Í§ 0 ª‹Í§ 1 ª‹Í§ 2 ª‹Í§ 3 01 ÍÔ¹¾Øµáºº´Ô¿à¿ÍàùàªÕÂÅ 3 ª‹Í§

AN0

+ -

ª‹Í§ 0

AN1

+ -

ª‹Í§ 1

+ -

ª‹Í§ 2

AN2 AN3

10 ÍÔ¹¾Øµá¡¡Ñ¹ÍÔÊÃмÊÁ¡Ñº´Ô¿à¿ÍàùàªÕÂÅ 1 ª‹Í§ ª‹Í§ 0 ª‹Í§ 1

AN0 AN1 AN2 AN3

+ -

ª‹Í§ 2

11 ´Ô¿à¿ÍàùàªÕÂÅ 2 ÍÔ¹¾Øµ AN0 AN1 AN2 AN3

+ -

ª‹Í§ 0

+ -

ª‹Í§ 1

á¿Å¡àÍç¹àÍàºÔÅÍйÒÅÍ¡àÍÒµ¾Øµ (àÍç¹àÍàºÔŶŒÒ¡íÒ˹´ãˌ໚¹ "1" )

ÃÙ»·Õè 9-2 ÃÒÂÅÐàÍÕ´¢ŒÍÁÙŤǺ¤ØÁ¡Ò÷íÒ§Ò¹¢Í§ PCF8591 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 110


+5V +5V

IC801 PCF8591

K801

16

5 6 JP801

K802

JP802

JP803 7

ADDRESS SELECT A1

Aout

SDA

15

K803 ANALOG OUTPUT

SCL A0

Ain0

1

K804 ANALOG INPUT

2 Ain1 3 Ain2 4 Ain3 13 AGND EXT

A1

A2 8

A2

12

84&

+5V VR801

JP804 JP805 JP806

84&"

84&!

I C BUS CONNECTOR

A0

14 Vref

9

10

+5V

C801 0.1/50V

JP807 VR801-VR804 10k x4

EX-08 ºÍÏ´ ADC/DAC ¼‹Ò¹ÃкººÑÊ I2C 㪌¡ÒÃàª×Íè Áµ‹ÍẺºÑÊ I2C ´ŒÇÂᨍ¡âÁ´ÙÅҋ Ï l ǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µ Ô ÍÅ 8 ºÔµ 4 ª‹Í§ ÃѺáç´Ñ¹ÍÔ¹¾Øµä´Œ 0-5V l ǧ¨Ãá»Å§ÊÑ­­Ò³´Ô¨µ Ô ÍÅ໚¹ÍйÒÅÍ¡ 8 ºÔµ 1 ª‹Í§ àÍÒµ¾µØ ໚¹áç´Ñ¹ä¿µÃ§ 0-5V l ÁÕµÇÑ µŒÒ¹·Ò¹»ÃѺ¤‹Ò䴌ÊÒí ËÃѺ¨‹ÒÂáç´Ñ¹·´Êͺ 4 ª‹Í§ l ÊÒÁÒöµ‹Í¾‹Ç§¡Ñ¹à¾×Í è ¢ÂÒÂ䴌ʧ٠ÊØ´ÍÕ¡ 3 ºÍÏ´ l ÁÕà·ÍÏÁ¹ Ô ÍźÅçÍ¡ÊíÒËÃѺµ‹Í¡ÑºÊÑ­­Ò³ÍйÒÅÍ¡ ÀÒ¹͡ l

ÃÙ»·Õè 9-3 ǧ¨ÃÊÁºÙó¢Í§ EX-08 ºÍÏ´ ADC/DAC ¼‹Ò¹ÃкººÑÊ I2C àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 111


ÍÍÊ«ÔÅàÅàµÍÏ ǧ¨ÃÍÍÊ«ÔÅàÅàµÍÏÀÒÂã¹ PCF8591 ¨ÐÊÌҧÊÑ­­Ò³¹Ò́¡ÒÊíÒËÃѺ¡ÒÃá»Å§ÊÑ­­Ò³ ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅ àÁ×Íè µŒÍ§¡ÒÃ㪌ǧ¨ÃÍÍÊ«ÔÅàÅàµÍÏÀÒÂã¹ ¢Ò EXT µŒÍ§µ‹Íŧ¡ÃÒÇ´ ¶ŒÒµŒÍ§ ¡ÒÃ㪌ÍÍÊ«ÔÅàÅàµÍϨҡÀÒ¹͡¢Ò EXT µŒÍ§µ‹ÍࢌҡѺ俺ǡ áŌǻ‡Í¹ÊÑ­­Ò³¹Ò́¡Òࢌҷբè Ò OSC ¢Í§ PCF8591 â´Â¤ÇÒÁ¶Õ¢è ͧÊÑ­­Ò³¹Ò́¡ÒÊÙ§ÊØ´·Õ»è ͇ ¹ãˌ¡ºÑ ÍÍÊ«ÔÅàÅàµÍÏ෋ҡѺ 1.25 MHz

ºÍÏ´ EX-08 ºÍÏ´ ADC /DAC ¼‹Ò¹ÃкººÑÊ I2C ºÍÏ´ EX-08 ÁÕǧ¨ÃáÊ´§ã¹ÃÙ»·Õè 9-3 º¹ºÍÏ´ÁÕäÍ«Õ PCF8591 «Ö§è ÊÒÁÒö¡íÒ˹´µíÒá˹‹§ áÍ´à´ÃÊ·Ò§ÎÒÏ´áÇÏ䴌µÒÁµŒÍ§¡Òü‹Ò¹¨ÑÁê à»ÍÏ JP801-JP803 â´Â»¡µÔ¶ÒŒ 㪌 PCF8591 à¾Õ§ µÑÇà´ÕÂÇÁÑ¡¨Ð¡íÒ˹´¤‹ÒáÍ´à´ÃÊàÍÒänj෋ҡѺ 000 ¡ÒÃàª×Íè Áµ‹ÍºÍÏ´ EX-08 ¡Ñº P-Board ¨Ð㪌 ¡ÒÃàª×Íè Áµ‹Í¼‹Ò¹á¨¡â·ÃÈѾ·àª‹¹à´ÕÂǡѺºÍÏ´ EX-07 áÅÐÊÒÁÒöµ‹Í¾‹Ç§ºÍϴËÇÁ¡Ñ¹ä´ŒÁÒ¡ ¶Ö§ 8 ºÍÏ´¨Ò¡¡ÒáíÒ˹´áÍ´à´ÃʢͧᵋÅкÍÏ´¤¹ÅеíÒá˹‹§¡Ñ¹ ÍÔ¹¾ØµÍйÒÅÍ¡·Õ»è ͇ ¹ä» Âѧ PCF8591 ÁÕ·§Ñé ËÁ´ 4 ¨Ø´´ŒÇ¡ѹ ¼Ù㌠ªŒ§Ò¹ÊÒÁÒöàÅ×Í¡¡Òû‡Í¹ÍÔ¹¾ØµÍйÒÅÍ¡ 0-5V ¨Ò¡ ÀÒ¹͡ËÃ×Í㪌¡Òû‡Í¹¨Ò¡µÑǵŒÒ¹·Ò¹»ÃѺ¤‹Ò䴌«Öè§ãªŒ»ÃѺ¤‹Òáç´Ñ¹ÃÐËNjҧ 0-5V ¨Ò¡áËŋ§ ¨‹ÒÂä¿ÀÒÂ㹺ÍÏ´ â´Â¡ÒÃàÅ×Í¡¡ÒÃ͋ҹ¤‹Ò¨Ò¡µÑǵŒÒ¹·Ò¹»ÃѺ¤‹Ò䴌ËÃ×ͨҡÀÒ¹͡¹Ñ¹é ÁÒ¨Ò¡ ¨ÑÁê à»ÍÏ JP804-JP807 º¹µÑǺÍÏ´ ¹Í¡¨Ò¡¹Õé PCF8591 ÂѧÁÕàÍÒµ¾µØ ẺÍйÒÅÍ¡ÍÕ¡ 1 ¨Ø´à¾×Íè ʋ§áç´Ñ¹àÍÒµ¾µØ ÍÍ¡ä» â´Â¤‹Òáç´Ñ¹¨ÐÁդҋ à»ÅÕÂè ¹á»Å§ÃÐËNjҧ 0-5V ¢Ö¹é ÍÂÙ¡‹ ºÑ ¡ÒÃʋ§¢ŒÍÁÙÅÁҤǺ¤ØÁºÍÏ´ EX-08 áËŋ§¨‹ÒÂä¿·Õãè ªŒàÅÕÂé §ºÍÏ´ EX-08 ¨ÐÁÒ¨Ò¡¨Ø´µ‹ÍÃкººÑÊ I2C «Ö§è ໚¹á¨¡âÁ´ÙÅҋ Ï 4 ¢Ò ઋ¹ à´ÕÂǡѺºÍÏ´ EX-07

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 112


¡Ò÷´Åͧ·Õè 12 ¡ÒûÃÐÁÇżÅÊÑ­­Ò³Íйҹ͡¢Í§¾Íϵ¢¹Ò¹¼‹Ò¹ ÃкººÑÊ I2C à¤Ã×èͧÁ×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-08 ºÍÏ´ ADC/DAC ¼‹Ò¹ÃкººÑÊ I2C 1 Ἃ¹ 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 4. áËŋ§¨‹ÒÂ俵ç +5V 500mA 4 à¤Ã×Íè § (ËÃ×ÍÍ‹ҧ¹ŒÍ 1 à¤Ã×Íè §) 5. ´Ô¨µÔ ÍÅÁÑŵÔÁàÔ µÍϾÌÍÁÊÒÂÇÑ´ 1 à¤Ã×Íè § 1 àʌ¹ 6. ÊÒ I2C

¡Ò÷´Åͧ ¡ÒÃà¢Õ¹â»Ãá¡ÃÁà¾×èÍ͋ҹ¢ŒÍÁÙÅÍÔ¹¾ØµÍйÒÅ͡Ẻµ‹Íà¹×èͧ¨Ò¡ PCF8591 º¹ ºÍÏ´ EX-08 㹡ÒõԴµ‹Í¡Ñº PCF8591 ÁÕÃٻẺ¢Í§ÊÑ­­Ò³µÒÁÁҵðҹ¢Í§ÃкººÑÊ I2C «Öè§ÁÕ ÃÒÂÅÐàÍÕ´ÍÂً㹺··Õè 8 áÅСÒ÷´Åͧ·Õè 11 㹡Ò÷´Åͧ¹Õé¨Ö§äÁ‹¢Í¡Å‹ÒÇÃÒÂÅÐàÍÕ´«éíÒÍÕ¡ â´Â¡ÒõԴµ‹ÍÁÕÅíҴѺ¢Ñ鹵͹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊ ã¹·Õ¹è ¡Õé Òí ˹´áÍ´à´Ãʢͧ PCF8591 änj·Õè 000 (¢Ò A0, A1, A2 µ‹Íŧ¡ÃÒÇ´·§Ñé ËÁ´) áÅÐãˌ·Òí §Ò¹ã¹âËÁ´à¢Õ¹¢ŒÍÁÙÅ (»‡Í¹¢ŒÍÁÙÅ “0” ãˌᡋºµÔ R/W) 3. ÃÍÃѺÊÑ­­Ò³ ACK ËÃ×ÍÃÍÃѺ¡Òõͺ¡ÅѺ¨Ò¡ PCF8591 4. ʋ§¢ŒÍÁÙŤǺ¤ØÁä»Âѧ PCF8591 â´Â㪌¤Ò‹ 45H «Ö§è ໚¹¡ÒÃÍÕ¹ÒàºÔÅÍйÒÅÍ¡àÍÒµ¾Øµ, ¡íÒ˹´ãˌÍÔ¹¾ØµÍйÒÅÍ¡·íÒ§Ò¹ã¹âËÁ´«Ô§à¡ÔÅ, ¡íÒ˹´ãˌ㪌¡ÒÃàÅ×è͹͋ҹ¢ŒÍÁÙÅẺ µ‹Íà¹×Íè § áÅÐàÃÔÁè ͋ҹ¢ŒÍÁÙŨҡª‹Í§·Õè 1 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ PCF8591 6. ʋ§ÊÑ­­Ò³ STOP 7. ʋ§ÊÑ­­Ò³ START 8. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊÍÕ¡¤Ãѧé â´Â¤ÃÑ§é ¹Õ¡é Òí ˹´ãˌ໚¹âËÁ´Í‹Ò¹¢ŒÍÁÙÅ (ʋ§Åͨԡ “1” ãˌᡋºµÔ R/W) à¾×Íè àÃÔÁè µŒ¹Í‹Ò¹¤‹Ò¢ŒÍÁÙŨҡª‹Í§ÊÑ­­Ò³ÍйÒÅÍ¡ÍÔ¹¾Øµ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 113


9. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ PCF8591 10. ͋ҹ¤‹Ò¨Ò¡¢ÒÍÔ¹¾Øµ¢Í§Ç§¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍŪ‹Í§·Õè 1 11. ʋ§ÊÑ­­Ò³ MAck (Master Ack) ä»Âѧ PCF8591 12. ͋ҹ¤‹Ò¨Ò¡¢ÒÍÔ¹¾Øµ¢Í§Ç§¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍŪ‹Í§·Õè 2 13. ʋ§ÊÑ­­Ò³ MAck (Master Ack) ä»Âѧ PCF8591 14. ͋ҹ¤‹Ò¨Ò¡¢ÒÍÔ¹¾Øµ¢Í§Ç§¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍŪ‹Í§·Õè 3 15. ʋ§ÊÑ­­Ò³ MAck (Master Ack) ä»Âѧ PCF8591 16. ͋ҹ¤‹Ò¨Ò¡¢ÒÍÔ¹¾Øµ¢Í§Ç§¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍŪ‹Í§·Õè 4 17. ÃÍÃѺÊÑ­­Ò³ ACK 18. ʋ§ÊÑ­­Ò³ STOP ¨Ò¡¢Ñ¹é µÍ¹´Ñ§¡Å‹ÒÇÊÒÁÒöà¢Õ¹໚¹â»Ãá¡ÃÁ‹Í´ŒÇ Visual BASIC 䴌´§Ñ ¹Õé â»Ãá¡ÃÁ‹Í¡ÒÃ͋ҹ¤‹ÒÊÑ­­Ò³ÍйÒÅÍ¡ 4 ª‹Í§áººµ‹Íà¹×Íè §ÊíÒËÃѺ PCF8591 Private Sub Timer1_Timer() Call I2CStart Call Send8BIT(&H90) Call Ack Call Send8BIT(&H45) Call Ack Call I2CStop Call I2CStart Call Send8BIT(&H91) Call Ack Text1.Text = (Read8Bit * 5) Call MAck Text2.Text = (Read8Bit * 5) Call MAck Text3.Text = (Read8Bit * 5) Call MAck Text4.Text = (Read8Bit * 5) Call Ack Call I2CStop End Sub

/ 255 / 256 / 256 / 256

ËÁÒÂà赯 â»Ãá¡ÃÁ‹Í MAck ໚¹â»Ãá¡ÃÁ‹Í·Õãè ªŒÊ§‹ ÊÑ­­Ò³ Acknowledge «Ö§è ¨Ð ໚¹¡ÒÃʋ§ÊÑ­­Ò³ Acknowledge ¨Ò¡µÑÇÁÒÊàµÍÏËÃ×ͨҡ¤ÍÁ¾ÔÇàµÍϹ¹Ñè àͧ â´ÂÁÕÃÒ ÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ㹺··Õè 8 ÃÇÁ·Ñ§é â»Ãá¡ÃÁ‹Í I2CStart, Send8BIT, Ack áÅÐ I2CStop àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 114


¡ÒÃʋ§ÊÑ­­Ò³ MAck ¨Ðʋ§ãˌ¡ºÑ µÑÇÅÙ¡ (slave) º¹ÃкººÑÊ I2C 㹡óշÕè µÑÇáÁ‹ (master) ·íÒ¡ÒÃ͋ҹ¤‹Ò¢ŒÍÁÙŨҡµÑÇÅÙ¡àÃÕºÌÍÂáÅŒÇ «Ö§è ¨ÐµÃ§¡Ñ¹¢ŒÒÁ¡Ñº Ack «Ö§è ¨Ð໚¹¡Òõͺ¡ÅѺ¨Ò¡ µÑÇÅÙ¡à¾×èÍÂ×¹ÂѹãˌµÑÇáÁ‹ÃѺÃٌNjÒ䴌ÃѺ¢ŒÍÁÙÅáÅŒÇ â´Âã¹â»Ãá¡ÃÁ¨ÐµŒÍ§¡íÒ˹´ TextBox ¢Ö¹é ÁÒ 4 µÑÇà¾×èÍáÊ´§¤‹Ò¼ÅÅѾ¸·Õè͋ҹ䴌¢Í§¢ŒÍÁÙÅ·Ñé§ 4 ª‹Í§ µÑ駪×èÍ໚¹ Text1 , Text2 ,Text3 áÅÐ Text4 ¤‹Ò·ÕèáÊ´§ã¹ TextBox ໚¹¤‹Òáç´Ñ¹·Õè͋ҹ䴌¨Ò¡ÍÔ¹¾Øµ¢Í§ PCF8591 à¹×èͧ¨Ò¡à»š¹ ¡ÒùíÒ¢ŒÍÁÙÅ¢¹Ò´ 8 ºÔµ·ÕÍè ҋ ¹ä´ŒÁÒ¤íҹdzãËÁ‹ãˌÍÂÙ㋠¹ÃÙ»¢Í§áç´Ñ¹ â´Ââ»Ãá¡ÃÁ·Õãè ªŒ§Ò¹¨Ð ÁÕ˹ŒÒµÒ´Ñ§áÊ´§ã¹ÃÙ»·Õè P12-1 áÅÐÊÒÁÒöàÃÕ¡㪌§Ò¹â»Ãá¡ÃÁ䴌¨Ò¡ä¿Å LAB12A.VBP ¨Ò¡¤ÇÒÁÅÐàÍÕ´ 8 ºÔµ ¢Í§Ç§¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨µÔ ÍÅ¹Ñ¹é ·íÒãˌ¤Ò‹ ·ÕÍè ҋ ¹ 䴌Á¤Õ ÇÒÁÅÐàÍÕ´ÍÂÙ·‹ »Õè ÃÐÁÒ³ 20mV µ‹Í¡ÒÃà»ÅÕÂè ¹á»Å§¤‹Ò 1 ¤‹Ò «Ö§è ÊÒÁÒö¤íҹdz䴌¨Ò¡ ¤ÇÒÁÅÐàÍÕ´¡ÒÃÇÑ´ = ¤‹Òáç´Ñ¹àµçÁÊà¡Å / ¤‹ÒÊÙ§ÊØ´¢Í§µÑÇàÅ¢´Ô¨µÔ ÍÅ 8 ºÔµ =

5 256

=

0.0195V ËÃ×Í»ÃÐÁÒ³ 20mV

ʋǹ¡Òäíҹdz¤‹Òáç´Ñ¹¨Ò¡¤‹Ò¢ŒÍÁÙÅ·Õè͋ҹ䴌¨Ð䴌ÁÒ¨Ò¡Êٵà ¤‹Òáç´Ñ¹ = ¤‹Ò·ÕÍè ҋ ¹ä´Œ X ¤‹Òáç´Ñ¹àµçÁÊà¡Å / ¤‹ÒÊÙ§ÊØ´¢Í§µÑÇàÅ¢ 8 ºÔµ ÊÁÁµÔ ͋ҹ¤‹Ò¨Ò¡ PCF8591 䴌¤Ò‹ ෋ҡѺ 128 ¤‹Òáç´Ñ¹·Õáè ·Œ¨ÃÔ§·Õ»è ͇ ¹ãˌ¡ºÑ ÍÔ¹¾Øµ ¨ÐÁÕ ¤‹Ò෋ҡѺ

128 × 5 = 2.5V 256

ÃÙ»·Õè P12-1 ˹ŒÒµ‹Ò§¢Í§ä¿Å LAB12A.VBP ÃÙ»·Õè P12-2 ¡ÒÃàª×Íè Áµ‹Í P-Board ¡Ñº EX-08 à¾×Íè µÃǨÊͺ¡Ò÷íÒ§Ò¹¢Í§ PCF8591 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 115


EX-08

TEST TEST TEST TEST

ANALOG OUTPUT

CH-1 CH-2 CH-3 CH-4

+ -

CH-1 ANALOG INPUT

CH-2 CH-3 CH-4

¨Ò¡áËŋ§¨‹ÒÂ俵ç +5V

GND CH-1

CH-2

CH-3

CH-4

·íÒ¡ÒûÃѺ¤‹Òáç´Ñ¹·Õè µÑǵŒÒ¹·Ò¹¹Õé

ÃÙ»·Õè P12-3 áÊ´§¡ÒÃàµÃÕÂÁºÍÏ´ EX-08 à¾×Íè ·íÒ¡Ò÷´Åͧ㹢ŒÍ 12.4-12.7 12.1 ãˌãʋ¨ÁÑê à»ÍÏà¾×Íè àÅ×Í¡áÍ´à´ÃÊ A2-A0 ¢Í§äÍ«Õ PCF8591 º¹ºÍÏ´ EX-08 änj·Õè 000 12.2 àª×Íè Áµ‹Í P-Board ¡Ñº EX-08 â´Â㪌ÊÒ I2C ´Ñ§áÊ´§ã¹ÃÙ»·Õè P13-2 12.3 ແ´â»Ãá¡ÃÁ Visual BASIC àÃÕ¡ä¿Å LAB12A.VBP ¢Ö¹é ÁÒÃѹ ¨Ð»ÃÒ¡¯Ë¹ŒÒ¨Í´Ñ§ã¹ÃÙ» ·Õè P12-1 12.4 ãʋ¨ÁÑê à»ÍÏ·µÕè Òí á˹‹§ TEST CH-1 12.5 »‡Í¹áç´Ñ¹ +5V ࢌҷÕÍè ¹Ô ¾Øµ CH-1 ¢Í§ºÍÏ´ EX-08 áŌǻÃѺµÑǵŒÒ¹·Ò¹·Õè CH-1 ´Ñ§ã¹ÃÙ»·Õè P13-3 12.6 Êѧࡵ¡ÒÃà»ÅÕÂè ¹á»Å§¢Í§¤‹Òáç´Ñ¹ã¹ª‹Í§ Text1 12.7 ·íÒ¡Ò÷´ÅͧµÒÁ¢Ñ¹é µÍ¹ã¹¢ŒÍ 13.4 áÅÐ 13.5 â´Âà»ÅÕÂè ¹ª‹Í§ÍÔ¹¾Øµà»š¹ CH-2, CH-3 áÅÐ CH-4 µÒÁÅíҴѺ áŌÇÊѧࡵ¡ÒÃà»ÅÕÂè ¹á»Å§·Õè Text2 ÊíÒËÃѺ CH-2, Text3 ÊíÒËÃѺ CH-3 áÅÐ Text4 ÊíÒËÃѺ CH-4 12.8 ãʋ¨ÁÑê à»ÍÏ·µÕè Òí á˹‹§ TEST ¢Í§·Ø¡ª‹Í§ ¨Ò¡¹Ñ¹é »‡Í¹áç´Ñ¹¨Ò¡áËŋ§¨‹ÒÂä¿áµ‹ÅЪشࢌҷÕè ÍÔ¹¾ØµÍйÒÅÍ¡ CH-1 ¶Ö§ CH-4 ¢Í§ºÍÏ´ EX-08 12.9 ·´Åͧ»ÃѺ¤‹Ò¢Í§µÑǵŒÒ¹·Ò¹ã¹áµ‹ÅЪ‹Í§ Êѧࡵ¡ÒÃà»ÅÕÂè ¹á»Å§¢Í§¢ŒÍÁÙÅã¹áµ‹ÅЪ‹Í§ â´Â㹡Ò÷´Åͧ¢ŒÍ 12.8-12.9 ໚¹¡ÒÃáÊ´§ãˌàË繶֧¤ÇÒÁÊÒÁÒö㹡ÒÃ͋ҹ¤‹ÒÍÔ¹¾Øµ ÊÑ­­Ò³ÍйÒÅÍ¡¢Í§ PCF8591 ·Ñ§é 4 ª‹Í§¾ÃŒÍÁ¡Ñ¹áÅе‹Íà¹×Íè § àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 116


¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧǧ¨Ãá»Å§ÊÑ­­Ò³´Ô¨µÔ ÍÅ໚¹ÍйÒÅÍ¡¢Í§ PCF8591 PCF8591 ¹Í¡¨Ò¡¨ÐÁÕǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨ÔµÍÅáŌÇÂѧÁÕǧ¨Ãá»Å§ ÊÑ­­Ò³´Ô¨µÔ ÍÅ໚¹ÍйÒÅÍ¡ÍÂÙÀ‹ ÒÂã¹µÑÇ´ŒÇ ¡ÒÃʋ§¤‹Ò¢ŒÍÁÙÅÍÍ¡ä»Âѧ PCF8591 ¨Ð໚¹¡Òà ʋ§¤‹ÒÍÍ¡ä»Âѧǧ¨Ãá»Å§ÊÑ­­Ò³´Ô¨µÔ ÍÅ໚¹ÍйÒÅÍ¡ â´ÂµŒÍ§ÁÕû٠Ẻ㹡ÒÃʋ§¢ŒÍÁÙŴѧ¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´ÃÊâ´Âãˌ·Òí §Ò¹ã¹âËÁ´à¢Õ¹¢ŒÍÁÙÅ (ºÔµ R/W Áդҋ ໚¹Åͨԡ “0”) 3. ÃÍÃѺÊÑ­­Ò³ ACK 4. ʋ§¢ŒÍÁÙŤǺ¤ØÁ 44H ä»Âѧ PCF8591 à¾×Íè àÍç¹àÍàºÔÅÍйÒÅÍ¡àÍÒµ¾µØ 5. ÃÍÃѺÊÑ­­Ò³ ACK 6. ʋ§¢ŒÍÁÙÅä»ÂѧàÍÒµ¾µØ ÍйÒÅÍ¡ â´Â¤‹Ò·ÕÊè §‹ Í͡仨еŒÍ§Áդҋ ÍÂÙË ÐËNjҧ 0-255 7. ÃÍÃѺÊÑ­­Ò³ ACK 8. ʋ§ÊÑ­­Ò³ STOP ¨Ò¡¢Ñ¹é µÍ¹´Ñ§¡Å‹ÒÇ¢ŒÒ§µŒ¹ÁÒà¢Õ¹໚¹â»Ãá¡ÃÁ‹Í´ŒÇ Visual BASIC ´Ñ§¹Õé â»Ãá¡ÃÁ‹ÍÂʋ§¢ŒÍÁÙÅä»ÂѧÍйÒÅÍ¡àÍÒµ¾µØ Private Sub Text5_Change() If Val(Text5.Text) > 5 Then Text5.Text = 5 Call I2CStart Call Send8BIT(&H90) Call Ack Call Send8BIT(&H44) Call Ack Call Send8BIT(Val(Text5.Text) * 51.2) Call Ack Call I2CStop End Sub

â»Ãá¡ÃÁ‹Í¹ըé Ð㪌 TextBox ÍÕ¡µÑÇË¹Ö§è ¤×Í Text5 ÁÒ໚¹µÑÇ¡íÒ˹´¤‹Òáç´Ñ¹·Õ¨è Ðʋ§ä» ãˌ¡ºÑ PCF8591 â´Â¤‹Ò·Õ¨è Ðʋ§Í͡仹ըé еŒÍ§¹íÒÁÒ¤Ù³´ŒÇ 51.2 (µÑÇàÅ¢ 51.2 ÁÒ¨Ò¡ ¤‹Ò¢ŒÍÁÙÅ ÊÙ§ÊØ´ 8 ºÔµËÒôŒÇ¤‹Òáç´Ñ¹àµçÁÊà¡Å : 256/5 ) àÊÕ¡‹Í¹à¾×Íè à»ÅÕÂè ¹¤‹Òáç´Ñ¹·Õ¡è Òí ˹´Å§ä»ãˌ ໚¹¤‹Ò¢ŒÍÁÙÅ 8 ºÔµàÊÕ¡‹Í¹ àÁ×Íè ¼Ù㌠ªŒ§Ò¹à»ÅÕÂè ¹¤‹Ò¢ŒÍÁÙÅãˌ Text5 áŌÇãˌàÍÒÁÑŵÔÁàÔ µÍÏÁÒÇÑ´¤‹Ò áç´Ñ¹·ÕèàÍÒµ¾ØµÍйÒÅÍ¡¢Í§ PCF8591 ¨ÐàË繤‹Òáç´Ñ¹à»ÅÕè¹á»Å§ä»µÒÁ¤‹Ò·Õè»‡Í¹Å§ä» ËÃ×ÍÊÒÁÒö¹íÒàÍÒ¢ÒÍÔ¹¾Øµ¢Í§ PCF8591 µ‹Í¾‹Ç§¡Ñº¢ÒàÍÒµ¾µØ ¢Í§ PCF8591 à¾×Íè ͋ҹ¤‹ÒÍÍ¡ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 117


ÁÒâ´ÂµÃ§·Ò§¨ÍÀÒ¾¡ç䴌 â´Â˹ŒÒµÒ¢Í§â»Ãá¡ÃÁàÁ×Íè à¾ÔÁè Text5 ࢌÒä»áÊ´§ã¹ÃÙ»·Õè P12-4 ʋǹâ»Ãá¡ÃÁ·Õáè ¡Œä¢à¾ÔÁè àµÔÁàÃÕ¡㪌§Ò¹ä´Œ¨Ò¡ LAB12B.VBP ã¹á¼‹¹«Õ´ÃÕ ÍÁ 12.10 ãˌãʋ¨ÁÑê à»ÍÏà¾×Íè àÅ×Í¡áÍ´à´ÃÊ A2-A0 ¢Í§äÍ«Õ PCF8591 º¹ºÍÏ´ EX-08 änj·Õè 000 12.11 àª×Íè Áµ‹Í P-Board ¡Ñº EX-08 â´Â㪌ÊÒ I2C ´Ñ§áÊ´§ã¹ÃÙ»·Õè P13-2 12.12 ແ´â»Ãá¡ÃÁ Visual BASIC àÃÕ¡ä¿Å LAB12B.VBP ¢Ö¹é ÁÒ·íÒ¡ÒÃÃѹ ¨Ð»ÃÒ¡¯Ë¹ŒÒ¨Í ´Ñ§ã¹ÃÙ»·Õè P12-4 12.13 »‡Í¹¤‹Òáç´Ñ¹·Õµè ͌ §¡ÒÃŧ㹪‹Í§ Text5 â´ÂÁբ͌ ¨íҡѴNjҵŒÍ§äÁ‹à¡Ô¹ 5 12.14 㪌´¨Ô µÔ ÍÅÁÑŵÔàµÍÏàÅ×͡‹ҹÇÑ´áç´Ñ¹ä¿µÃ§ ÇÑ´·Õ¨è ´Ø ANALOG OUTPUT º¹ºÍÏ´ EX08 ´Ñ§ã¹ÃÙ»·Õè P12-5 à»ÃÕºà·Õº¤‹Òáç´Ñ¹·ÕÇè ´Ñ ä´Œ¡ºÑ ¤‹Ò·Õ»è ͇ ¹ã¹ª‹Í§ Text5 12.15 ·íÒ¡Òõ‹ÍÊÒ¨ҡ¨Ø´ ANALOG OUTPUT ࢌҷÕÍè ¹Ô ¾Øµ CH-1 º¹ºÍÏ´ EX-08 ´Ñ§ã¹ÃÙ»·Õè P12-6 12.16 »‡Í¹¤‹Òáç´Ñ¹·Õ赌ͧ¡ÒÃŧ㹪‹Í§ Text5 â´ÂÁÕ ¢ŒÍ¨íҡѴNjҵŒÍ§äÁ‹à¡Ô¹ 5 â´Â·´Åͧ»‡Í¹ËÅÒÂæ ¤‹Ò 12.17 Êѧࡵ¼Å¡ÒÃà»ÅÕÂè ¹á»Å§¢Í§¢ŒÍÁÙÅ㹪‹Í§ Text1 NjÒÊÍ´¤ÅŒÍ§¡Ñº¤‹Ò·Õ»è ͇ ¹ã¹ª‹Í§ Text5 ËÃ×ÍäÁ‹ ¡Ò÷´Åͧ㹢ŒÍ12.13 áÅÐ 12.14 ໚¹¡ÒõÃǨ Êͺ¤ÇÒÁÊÒÁÒö¢Í§ PCF89591 㹡ÒÃá»Å§¢ŒÍÁÙÅ ´Ô¨ÔµÍÅ໚¹ÍйÒÅÍ¡ â´Â¡ÒáíÒ˹´¢ŒÍÁÙÅ㹪‹Í§ Text5 â»Ãá¡ÃÁ¨Ð¹íÒ¢ŒÍÁÙŹѹé á»Å§à»š¹¢ŒÍÁÙÅ´Ô¨µÔ ÍÅ ¡‹Í¹ ¨Ò¡¹Ñ¹é ʋ§ä»Âѧ PCF8591 à¾×Íè á»Å§à»š¹ÊÑ­­Ò³ ÍйÒÅ͡ʋ§ÍÍ¡ÁÒ·Õàè ÍÒµ¾µØ ANALOG OUTPUT ʋǹ¡Ò÷´Åͧ㹢ŒÍ 12.15 -12.17 ໚¹¡ÒÃ㪌 §Ò¹Ç§¨Ã ADC áÅÐ DAC ÀÒÂã¹ PCF8591 ¾ÃŒÍÁ¡Ñ¹ ¡Å‹ÒǤ×Í â»Ãá¡ÃÁ¨Ðá»Å§¢ŒÍÁÙÅ㹪‹Í§ Text5 ໚¹ ¢ŒÍÁÙÅ´Ô¨µÔ ÍÅʋ§ä»ãˌ PCF8591 á»Å§à»š¹áç´Ñ¹Ê‹§ÍÍ¡ ä»ÂѧàÍÒµ¾µØ ÍйÒÅÍ¡ ¨Ò¡¹Ñ¹é áç´Ñ¹ÍйÒÅÍ¡¹Ñ¹é ¡ç¨Ð ÃÙ»·Õè P12-4 ˹ŒÒµ‹Ò§¢Í§â»Ãá¡ÃÁ ʋ§µ‹Íä»ÂѧÍÔ¹¾ØµÍйÒÅÍ¡ª‹Í§·Õè 1 ¢Í§ PCF8591 äÍ«Õ LAB12B.VBP à¾×è͵ÃǨÊͺ¡Òà PCF8591 ¡ç¨Ðá»Å§à»š¹¢ŒÍÁÙÅ´Ô¨µÔ ÍÅʋ§ä»ãˌâ»Ãá¡ÃÁ ·íÒ§Ò¹¢Í§ ADC áÅÐ DAC ¢Í§ »ÃÐÁÇżÅ໚¹¤‹Òáç´Ñ¹áÊ´§ÍÍ¡ÁÒ·Õªè ͋ § Text1 PCF8591¾ÃŒÍÁ¡Ñ¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 118


àª×Íè Áµ‹Í¡Ñº P-Board ´ŒÇÂÊÒ I C

DIGITAL METER

EX-08

TEST TEST TEST TEST

+

ANALOG OUTPUT

CH-1 CH-2 CH-3 CH-4

+

CH-1 ANALOG INPUT

CH-2 CH-3 CH-4 GND

CH-1

CH-2

CH-3

CH-4

ÃÙ»·Õè P12-5 ¡Òõ‹ÍÊÒÂà¾×Íè ·íÒ¡Ò÷´Åͧ㹢ŒÍ 12.14 àª×Íè Áµ‹Í¡Ñº P-Board ´ŒÇÂÊÒ I C EX-08

TEST TEST TEST TEST

ANALOG OUTPUT

CH-1 CH-2 CH-3 CH-4

+

CH-1 ANALOG INPUT

CH-2 CH-3 CH-4 GND

CH-1

CH-2

CH-3

CH-4

ÃÙ»·Õè P12-6 ¡Òõ‹ÍÊÒÂà¾×Íè ·íÒ¡Ò÷´Åͧ㹢ŒÍ 12.15

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 119

-


º··Õè 10

¡ÒâÂÒ¾ÍϵàÍÒµ¾µØ ãˌᡋ¾Íϵ¢¹Ò¹ â´Â㪌¡ÒÃÊ×Íè ÊÒÃ͹ءÃÁẺ«Ô§â¤Ã¹ÑÊ ¨Ò¡º··Õè 8 䴌͸ԺÒ¶֧¡ÒâÂÒ¾ÍϵàÍÒµ¾µØ ãˌᡋ¾Íϵ¢¹Ò¹¼‹Ò¹ÃкººÑÊ I2C â´Â 㪌äÍ«Õ PCF8574A ¹Ñ¹è ໚¹ÇÔ¸¡Õ ÒÃ˹֧è ÊíÒËÃѺ㹺·¹Õ¨é Ð͸ԺÒ¶֧¡ÒâÂÒ¾ÍϵàÍÒµ¾µØ ã¹ÍÕ¡ Ẻ˹֧è â´Â㪌¡ÒÃÊ×Íè ÊÒâŒÍÁÙÅ͹ءÃÁã¹áºº«Ô§â¤Ã¹ÑÊÁÒª‹Ç «Ö§è ÍØ»¡Ã³ËÅѡ㹡Ò÷íÒ§Ò¹¹Õ¤é Í× äÍ«Õª¿Ô µÃ¨Õ ÊÔ àµÍÏ (shift register)

ËÅÑ¡¡ÒÃàº×éͧµŒ¹ ã¹ÃÙ»·Õè 10-1 áÊ´§ä´ÍÐá¡ÃÁ¡Ò÷íÒ§Ò¹àº×éͧµŒ¹¢Í§¡ÒâÂÒ¾Íϵâ´Â㪌¡ÒÃÊ×èÍÊÒà ͹ءÃÁẺ«Ô§â¤Ã¹ÑÊ ¨ÐàËç¹ä´ŒÇҋ ÁÕÊÒ¢ŒÍÁÙÅ (data : DI) à¾Õ§ 1 àʌ¹ ´Ñ§¹Ñ¹é ¡ÒÃʋ§¼‹Ò¹¢ŒÍÁÙÅ ¨Ö§µŒÍ§¡ÃзíÒã¹ÅѡɳÐ͹ءÃÁ ʋǹ·Õàè »š¹áºº«Ô§â¤Ã¹ÑÊ (synchronous) ¡çà¹×Íè §¨Ò¡ÁÕ¡ÒÃ㪌ʭ Ñ ­Ò³ ¹Ò́¡Ò (CLK) ÁÒ¡íÒ˹´¨Ñ§ËÇСÒ÷íÒ§Ò¹ãˌÊÑÁ¾Ñ¹¸¡Ñ¹ÃÐËNjҧµÑÇʋ§¢ŒÍÁÙÅ («Öè§ã¹·Õè¹Õé¤×Í ¤ÍÁ¾ÔÇàµÍÏ) áÅеÑÇÃѺ¢ŒÍÁÙÅ («Ö§è ¡ç¤Í× äÍ«Õª¿Ô µÃ¨Õ ÊÔ àµÍÏ) ¹Í¡¨Ò¡¹Ñ¹é ¨ÐÁÕÊÒÂÊÑ­­Ò³¤Çº¤ØÁÍÕ¡ 2 àʌ¹¤×Í ÊÑ­­Ò³ RST «Ö§è ¡ç¤Í× ÊÑ­­Ò³ÃÕ૵ áÅÐÊÑ­­Ò³ LE ËÃ×ÍÊÑ­­Ò³áŵªÊÒí ËÃѺ¹íÒ¢ŒÍÁÙÅ ä»áÊ´§·ÕèàÍÒµ¾Øµ äÍ«Õª¿Ô µÃ¨Õ ÊÔ àµÍÏ·¹Õè Òí ÁÒ㪌¨Ð໚¹áºº¢ŒÍÁÙÅࢌÒ͹ءÃÁ-¢ŒÍÁÙÅÍ͡Ẻ¢¹Ò¹ (SIPO : Serial In Parallel Out) â´ÂàÁ×Íè àÃÔÁè µŒ¹¨ÐµŒÍ§ÃÕ૵ËÃ×Íà¤ÅÕÂϢ͌ ÁÙÅà´ÔÁãˌ໚¹ “0” ¡‹Í¹ ¨Ò¡¹Ñ¹é ʋ§¢ŒÍÁÙÅ ÁÒ·Õ¢è Ò DI áŌÇʋ§ÊÑ­­Ò³¹Ò́¡ÒÁÒ 1 ÅÙ¡ ¢ŒÍÁÙÅ¡ç¨Ð¶Ù¡àÅ×Íè ¹à¢ŒÒä»à¡çºã¹ªÔ¿µÃ¨Õ ÊÔ àµÍÏ ËÒ¡äÁ‹ ¢Ò¢ŒÍÁÙÅÍ͡Ẻ¢¹Ò¹¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏ·ÊèÕ ÒÁÒö㪌§Ò¹à»š¹¾ÍϵàÍÒµ¾µØ P7

DATA (DI) LATCH (LE) CLOCK (CLK)

P6

P5

P4

P3

P2

P1

P0

SERIAL DATA OUT (SO)

µ‹ÍࢌҡѺ¢Ò DI ËÃ×Í SERIAL DATA IN ¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏ㹪شµ‹Íä» à¾×Íè ¢ÂÒ¾ÍϵàÍÒµ¾µØ à¾ÔÁè ¢Ö¹é ÍÕ¡

RESET (RST)

µ‹ÍࢌҡѺ¢Ò LE, CLK áÅÐ RST ¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏ㹪شµ‹Íä» à¾×Íè ¢ÂÒ¾ÍϵàÍÒµ¾µØ à¾ÔÁè ¢Ö¹é ÍÕ¡

ÃÙ»·Õè 10-1 ¼Ñ§¡Ò÷íÒ§Ò¹àº×Íé §µŒ¹¢Í§¡ÒâÂÒ¾ÍϵẺ«Ô§â¤Ã¹ÑÊâ´Â㪌ª¿ Ô µÃ¨Õ ÊÔ àµÍÏ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 121


¢ŒÍÁÙÅ 8 ºÔµ DATA (DI)

¢ŒÍÁÙÅ 8 ºÔµ

1

0

0

1

1

1

0

1

1

0

0

0

1

1

1

0

1

0

0

1

1

1

0

1

1

0

0

0

1

1

1

0

1

0

0

1

1

1

0

1

CLOCK (CLK)

RESET (RST)

LATCH (LE)

SHIFT REGISTER

OUTPUT (P0-P7)

¢ŒÍÁÙÅ 8 ºÔµ

1

0

0

0

1

1

1

0

¢ŒÍÁÙÅ 8 ºÔµ

ÃÙ»·Õè 10-2 ä´ÍÐá¡ÃÁàÇÅÒáÊ´§¨Ñ§ËÇСÒ÷íÒ§Ò¹¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏà¾×Íè ¢ÂÒ¾ÍϵàÍÒµ¾µØ ÁÕ¡ÒÃʋ§ÊÑ­­Ò³áŵª ¢ŒÍÁÙÅàÍÒµ¾µØ ¨ÐÂѧ¤§à´ÔÁäÁ‹à»ÅÕÂè ¹á»Å§ ¨Ò¡¹Ñ¹é ·ÂÍÂʋ§¢ŒÍÁÙÅÁÒ¨¹¤Ãº 8 ºÔµ áŌǵÒÁ´ŒÇ¡ÒÃʋ§ÊÑ­­Ò³áŵª ¢ŒÍÁÙŷѧé ËÁ´·Õàè ¡çºänjã¹ÃÕ¨ÊÔ àµÍÏ¡¨ç ж١ʋ§ÍÍ¡ÁÒ·Õàè ÍÒµ ¾Øµ ´Ñ§ã¹ä´ÍÐá¡ÃÁàÇÅÒÃÙ»·Õè 10-2 ¨Ö§·íÒãˌ´àÙ ÊÁ×Í¹Ç‹Ò ãªŒÊÒÂÊÑ­­Ò³¢Í§¾Íϵ 3 àʌ¹ ·íÒãˌ à¡Ô´¾ÍϵàÍÒµ¾µØ 8 àʌ¹ à¾Õ§ᵋµÍŒ §ÁÕ¢¹Ñé µÍ¹áÅÐ㪌àÇÅÒ㹡ÒÃÃѺáÅÐàÅ×Íè ¹¢ŒÍÁÙÅàÅ硹ŒÍÂáÅÐ ¶ŒÒËÒ¡ªÔ¿µÃ¨Õ ÊÔ àµÍÏÁ¢Õ Ò¢ŒÍÁÙÅÍ͡Ẻ͹ءÃÁà¾ÔÁè àµÔÁ´ŒÇ ¨Ð·íÒãˌÊÒÁÒö¢ÂÒ¨íҹǹ¾ÍÏµÍ Í¡ä»ä´ŒÍ¡Õ â´Â¹íÒÊÑ­­Ò³¨Ò¡¢Ò¢ŒÍÁÙÅÍ͡Ẻ͹ءÃÁ (serial data output : SO) ÁÒࢌҷբè Ò ¢ŒÍÁÙÅÍÔ¹¾Øµ (DI) ¢Í§ªÔ¿µÃ¨Õ ÊÔ àµÍÏẺà´ÕÂǡѹÍÕ¡µÑÇË¹Ö§è ¨Ð·íÒãˌà¡Ô´¡ÒâÂÒ¾ÍϵÍÍ¡ä» ä´ŒÍ¡Õ ¨Ò¡ 8 ºÔµà»š¹ 16 ºÔµ, 24 ºÔµ, 32 ºÔµä»Í‹ҧµ‹Íà¹×Íè § Í‹ҧäáçµÒÁ´ŒÇÂá¹Ç·Ò§¹ÕéÍÒ¨·íÒãˌ¼ÙŒãªŒ§Ò¹¤Ô´Ç‹Ò ÊÒÁÒöà¾ÔèÁ¨íҹǹ¾ÍϵàÍÒµ¾Øµä´Œ Í‹ҧäÁ‹¨Òí ¡Ñ´ ã¹·Ò§»¯ÔºµÑ ÊÔ §Ôè ·Õàè ¡Ô´¢Ö¹é àÁ×Íè ¢ÂÒ¾ÍϵàÍÒµ¾µØ ÍÍ¡ä»à»š¹¨íҹǹÁÒ¡¤×Í 1. ¤ÇÒÁàÃçÇ㹡Ò÷íҧҹŴŧ à¹×èͧ¨Ò¡ãªŒ¡ÒÃàÅ×è͹¢ŒÍÁÙŢͧªÔ¿µÃÕ¨ÔÊàµÍÏ ´Ñ§¹Ñé¹ËÒ¡ ¨íҹǹ¢ŒÍÁÙÅ·Õµè ͌ §¡ÒÃàÅ×Íè ¹ÁÕÁÒ¡ àÇÅÒ·Õãè ªŒ¡¨ç ÐÁÒ¡¢Ö¹é 2. ¤ÇÒÁÊÒÁÒö㹡Òè‹Ò¡ÃÐáÊÃÇÁŴŧ 㹡óշ¢Õè ÂÒ¾ÍϵàÍÒµ¾µØ ÍÍ¡ä»â´ÂäÁ‹ä´Œ à¾ÔÁè ¤ÇÒÁÊÒÁÒö㹡Òè‹Ò¡ÃÐáÊä¿¿‡ÒãˌᡋáËŋ§¨‹ÒÂ俢ͧǧ¨Ã ¨Ð·íÒãˌ¾ÍϵàÍÒµ¾µØ ᵋÅÐ ºÔµÊÒÁÒö¨‹Ò¡ÃÐáÊ䴌ŴŧµÒÁ¨íҹǹ¾Íϵ·Õèà¾ÔèÁ¢Öé¹ 3. ÊÑ­­Ò³Ãº¡Ç¹ ËÒ¡¡ÒâÂÒÂ¹Ñ¹é µŒÍ§ãªŒÊÒÂÊÑ­­Ò³àª×Íè Á⧡ѹ ÂÔ§è ¶ŒÒËÒ¡ÁÕ¡ÒâÂÒ ÁÒ¡ ÊÒÂÊÑ­­Ò³·Õè㪌¡ç¨ÐµŒÍ§ÁÕ¤ÇÒÁÂÒÇà¾ÔèÁÁÒ¡¢Öé¹ Ê‹§¼ÅãˌÊÑ­­Ò³Ãº¡Ç¹ÊÒÁÒöࢌÒÁÒ Ãº¡Ç¹¡Ò÷íҧҹ䴌§‹Ò¢Öé¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 122


´Ñ§¹Ñ鹨íҹǹ¢Í§¾Íϵ·ÕèÊÒÁÒö¢ÂÒÂ䴌´ŒÇÂÇÔ¸Õ¡ÒùÕé¨Ö§¢Öé¹ÍÂً¡Ñº¤ÇÒÁÊÒÁÒö㹡Òà ¨‹Ò¡ÃÐáÊáÅФÇÒÁàÃçÇ໚¹»˜¨¨ÑÂËÅÑ¡ ËÒ¡áËŋ§¨‹ÒÂä¿ÁÕ¤ÇÒÁÊÒÁÒö㹡Òè‹Ò¡ÃÐáÊ䴌à¾Õ§¾Í ¤ÇÒÁàÃçǨ֧໚¹ÊÔ§è ·Õµè ͌ §¤íÒ¹Ö§¶Ö§à»š¹àÃ×Íè §µ‹ÍÁÒ ËÒ¡ÂÍÁÃѺ䴌 ¡çµÍŒ §Í͡Ẻǧ¨ÃáÅСÒÃàª×Íè Á µ‹Íãˌ´àÕ ¾×Íè »‡Í§¡Ñ¹ÊÑ­­Ò³Ãº¡Ç¹ ËÒ¡·íÒ䴌¤ÃºáÅÐÂÍÁÃѺ㹢ŒÍ¨íÒ¡Ñ´´ŒÒ¹¤ÇÒÁàÃçÇ䴌 ¡ç¨Ð ÊÒÁÒö¢ÂÒ¾ÍϵàÍÒµ¾Øµ´ŒÇÂÇÔ¸Õ¡ÒùÕé䴌Í‹ҧäÁ‹ÁÕ¢Õ´¨íÒ¡Ñ´ +5V

R901-R904 470k

+5V C901 0.1/50V

+5V

16 14

+5V

11

CLK

LE

12

DI

RST

10

9 K901 SHIFTIN

SI

Q0

15

D0

D0

D1

1

D1

D2 D4

D3 D5

D6

D7

SCK Q1 2 LE Q2 3 RST Q3 4 Q4 5 Q5 6 SO Q6 7 Q7 OE 13

8

D2 D3 D4 D5

K902 OUTL

D6 D7 IC901 74HC595A

+5V

C902 0.1/50V

+5V

16 14

+5V

11

CLK

LE

12

DO

RST

10

9 K904 SHIFTOUT

SI

Q0

SCK Q1 LE Q2 RST Q3 Q4 Q5 SO OE 13

Q6 Q7 8

15

D8

1

D9

2

D10 D11 D12

3 4 5 6

D13

7

D15

D8 D10

D9 D11

D12

D13

D14

D15

D14

K903 OUTH

IC902 74HC595A

EX-09 ºÍÏ´¢ÂÒ¾ÍϵàÍÒµ¾µØ ÊÒÁÒö¢ÂÒ¾ÍϵàÍÒµ¾µØ 8 ºÔµ 2 ªØ´ ÃÇÁ໚¹ 16 ºÔµ l 㪌äÍ«Õª¿ Ô µÃ¨Õ ÊÔ àµÍÏ㹡Ò÷íÒ§Ò¹ l ÊÒÁÒöµ‹Í¾‹Ç§à¾×Í è ¢ÂÒÂ䴌äÁ‹¨Òí ¡Ñ´ (á¹Ð¹íÒäÁ‹¤ÇÃà¡Ô¹ 4 ºÍÏ´µ‹Í P-Board 1 ºÍÏ´) l àª×Í è Áµ‹Í¡Ñº P-Board ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ DATA BUS l

ÃÙ»·Õè 10-3 ǧ¨ÃÊÁºÙó¢Í§ EX-09 ºÍÏ´¢ÂÒ¾ÍϵàÍÒµ¾µØ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 123


EX-09 ºÍÏ´¢ÂÒ¾ÍϵàÍÒµ¾µØ â´Â㪌¡ÒÃÊ×Íè ÊÒÃ͹ءÃÁẺ«Ô§â¤Ã¹ÑÊ ÁÕǧ¨ÃÊÁºÙóáÅФسÊÁºÑµáÔ Ê´§ã¹ÃÙ»·Õè 10-3 ºÍÏ´¹Õäé ´ŒÃºÑ ¡ÒÃÍ͡ẺãˌÊÒÁÒö¢ÂÒ ¾ÍϵàÍÒµ¾µØ 䴌ÁÒ¡¶Ö§ 16 ª‹Í§ (ËÃ×ͺԵ) µ‹ÍË¹Ö§è ºÍÏ´áÅÐÊÒÁÒöµ‹Í¾‹Ç§ä´ŒÍ‹ҧäÁ‹¨Òí ¡Ñ´ÀÒ 㵌à§×Íè ¹ä¢´Ñ§·Õäè ´Œ¡Å‹ÒÇÁÒáŌÇã¹ËÑÇ¢ŒÍ·Õ¼è ҋ ¹ÁÒ ËÑÇã¨ÊíҤѭ¤×Í äÍ«Õª¿Ô µÃ¨Õ ÊÔ àµÍÏàºÍÏ 74HC595 «Ö§è ໚¹ªÔ¿µÃ¨Õ ÊÔ àµÍÏẺÍ๡¡»ÃÐʧ¤ÊÒÁÒöÃѺ¢ŒÍÁÙÅࢌÒẺ͹ءÃÁ áÅÐʋ§¢ŒÍÁÙÅÍ͡䴌·§Ñé Ẻ¢¹Ò¹áÅÐ͹ءÃÁ ·Ñ§é ÂѧÊÒÁÒöµ‹Í¾‹Ç§ä´ŒäÁ‹Ã¨ÙŒ ºÍÕ¡´ŒÇ ÀÒÂã¹ 74HC595 ÁÕÃ¨Õ ÊÔ àµÍÏ¢¹Ò´ 8 ºÔµºÃèØÍÂً 1 µÑÇ ¨Ö§·íÒãˌÊÒÁÒö㪌§Ò¹¡Ñº¢ŒÍÁÙÅ¢¹Ò´ 8 ºÔµä´ŒÍ‹ҧàËÁÒÐÊÁ áÅÐàÁ×Íè ¹íÒÁÒ ¾‹Ç§¡Ñ¹´Ñ§·Õãè ªŒã¹ºÍÏ´ EX-09 ¡ç¨ÐÊÒÁÒöÃͧÃѺ¢ŒÍÁÙÅ䴌ÁÒ¡¶Ö§ 16 ºÔµ ÊÑ­­Ò³¢ŒÍÁÙÅ͹ءÃÁáÅФǺ¤ØÁ¨Ðʋ§¼‹Ò¹ÁÒ¨Ò¡¤Í¹à¹ç¡àµÍÏ SHIFT IN «Ö§è ÁÕ¡ÒèѴ¢Ò µÒÁÁҵðҹ UIC-10 ¨Ö§·íÒãˌÊÒÁÒöµ‹ÍࢌҡѺ¤Í¹à¹ç¡àµÍÏ DATA BUS ¢Í§ P-Board 䴌·¹Ñ ·Õ ¹Ñ¹è ¤×Í¢ÒÊÑ­­Ò³¹Ò́¡ÒËÃ×Í CLK ¨ÐµÃ§¡Ñº¢Ò D0, ¢Ò LE «Ö§è ໚¹¢ÒÊÑ­­Ò³áŵª¨ÐµÃ§¡Ñº¢Ò D1, ¢Ò¢ŒÍÁÙÅ͹ءÃÁËÃ×Í DI µÃ§¡Ñº¢Ò D2 áÅТÒÃÕ૵ RST ¨ÐµÃ§¡Ñº¢Ò D3 ÊÑ­­Ò³¨Ò¡¤Í¹ à¹ç¡àµÍÏ SHIFT IN ¨Ðʋ§à¢ŒÒä»Âѧ IC901 à¾×Íè ·íÒ¡ÒâÂÒ¾ÍϵàÍÒµ¾µØ 8 ºÔµÊ‹§ÍÍ¡ä»Âѧ¤Í¹ à¹ç¡àµÍÏ OUTL ¾ÃŒÍÁ¡Ñ¹¹Ñ¹é Âѧʋ§¢ŒÍÁÙÅ͹ءÃÁÍÍ¡ÁÒ·Ò§¢Ò SO ä»Âѧ¢Ò SI ¢Í§ IC902 à¾×Íè ¢ÂÒ¾Íϵà¾ÔÁè ÍÕ¡ 8 ºÔµ â´Â¢ŒÍÁÙÅ 8 ºÔµµ‹ÍÁÒ¨Ðʋ§ÍÍ¡·Ò§¤Í¹à¹ç¡àµÍÏ OUTH ·íÒãˌºÍÏ´ EX-09 ¹ÕÊé ÒÁÒö¢ÂÒ¾ÍϵàÍÒµ¾µØ à¾ÔÁè ໚¹ 16 ºÔµ¨Ò¡ÊÒÂÊÑ­­Ò³ DATA 4 àʌ¹¢Í§¾Íϵ ¢¹Ò¹áÅÐÂѧÊÒÁÒöà¾ÔÁè µ‹Íä»ä´ŒÍ¡Õ â´Â¢ÒÊÑ­­Ò³ LE, CLK áÅÐ RST ¨Ò¡¤Í¹à¹ç¡àµÍÏ SHIFT IN ¶Ù¡µ‹ÍÁÒÂѧ¤Í¹à¹ç¡àµÍÏ SHIFT OUT ¾ÃŒÍÁ¡Ñº¢Ò SO ¢Í§ IC902 ¨Ö§·íÒãˌÊÒÁÒöµ‹Í¾‹Ç§ ºÍÏ´ EX-09 ä´ŒÍ¡Õ Í‹ҧ§‹ÒÂæ à¾Õ§µ‹ÍÊÒ¨ҡ¤Í¹à¹ç¡àµÍÏ SHIFT OUT ¢Í§ EX-09 ºÍÏ´·Õè 1 ࢌҡѺ¤Í¹à¹ç¡àµÍÏ SHIFT IN ¢Í§ EX-09 ºÍÏ´¶Ñ´ä» ËÒ¡µ‹Í¾‹Ç§¡Ñ¹ 2 ºÍÏ´¡ç¨ÐÊÒÁÒö ¢ÂÒ¾ÍϵàÍÒµ¾µØ à¾ÔÁè ໚¹ 32 ª‹Í§ (ËÃ×ͺԵ) â´Â㪌¢ÒÊÑ­­Ò³à·‹Òà´ÔÁ¤×Í 4 àʌ¹ ã¹ÃÙ»·Õè 10-4 áÊ´§¡Òõ‹Í¾‹Ç§ºÍÏ´ EX-09 à¾×Íè à¾ÔÁè ¨íҹǹ¾ÍϵàÍÒµ¾µØ P-Board SHIFT IN

OUTL

EX-09

SHIFT OUT

OUTH

SHIFT IN

OUTL

EX-09

SHIFT OUT

OUTH

¾ÍϵàÍÒµ¾µØ ·Õ¢è ÂÒÂà¾ÔÁè àµÔÁ ¾ÍϵàÍÒµ¾µØ ·Õ¢è ÂÒÂà¾ÔÁè àµÔÁ ¨íҹǹ 16 ºÔµµ‹ÍºÍÏ´ ¨íҹǹ 16 ºÔµµ‹ÍºÍÏ´ ¾ÍϵàÍÒµ¾µØ ·Õ¢è ÂÒÂà¾ÔÁè àµÔÁÃÇÁ 32 ºÔµ

ÃÙ»·Õè 10-4 áÊ´§¡Òõ‹Í¾‹Ç§ºÍÏ´ EX-09 à¾×Íè à¾ÔÁè ¨íҹǹ¾ÍϵàÍÒµ¾µØ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 124


¡Ò÷´Åͧ·Õè 13 ¢ÂÒ¾ÍϵàÍÒµ¾Øµãˌᡋ¾Íϵ¢¹Ò¹¼‹Ò¹¡ÒÃÊ×èÍÊÒà ͹ءÃÁẺ«Ô§â¤Ã¹ÑÊ à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³ 1. P-Board ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ 1 Ἃ¹ 2. EX-01 ºÍÏ´ LED Á͹ÔàµÍÏ 16 ª‹Í§ 1 Ἃ¹ 3. EX-09 ºÍÏ´¢ÂÒ¾ÍϵàÍÒµ¾µØ Ẻ«Ô§â¤Ã¹ÑÊ 1 Ἃ¹ 4. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 5. ÊÒÂàª×Íè Áµ‹Í IDC-10 3 àʌ¹

¡Ò÷´Åͧ 13.1 µ‹ÍÊÒ IDC-1 0 ¨Ò¡¤Í¹à¹ç¡àµÍÏ DATA BUS ¢Í§ P-Board ä»Âѧ¤Í¹à¹ç¡àµÍÏ SHIFT IN ¢Í§ EX-09 áÅе‹ÍÊÒ¨ҡ¤Í¹à¹ç¡àµÍÏ OUTH áÅÐ OUTL ¢Í§ EX-09 ä»Âѧ¤Í¹à¹ç¡àµÍÏ DATA BUS1 áÅÐ 2 ¢Í§ºÍÏ´ EX-01 µÒÁÅíҴѺ 13.2 ÇÒ§¤Í¹â·Ãź¹¿ÍÏÁáÅÐà»ÅÕÂè ¹ª×Íè ´Ñ§ÃÙ»·Õè P13-1 áŌÇà¢Õ¹â»Ãá¡ÃÁ´Ñ§¹Õé Private Sub InitialShiftIn() Out &H378, &H8 End Sub Private Sub CLK() Out &H378, Inp(&H378) Xor &H1 Out &H378, Inp(&H378) Xor &H1 End Sub Private Sub RST() Out &H378, Inp(&H378) Xor &H8 Out &H378, Inp(&H378) Xor &H8 End Sub Private Sub LE() Out &H378, Inp(&H378) Xor &H2 Out &H378, Inp(&H378) Xor &H2 End Sub

ÃÙ»·Õè P13-1 ˹ŒÒµÒ¢Í§¿ÍÏÁ·ÕÊè Ìҧ ¢Ö¹é ¨Ò¡ä¿Å LAB13A.VBP à¾×Íè ¢ÂÒ ¨íҹǹ¾ÍϵàÍÒµ¾µØ â´Â㪌ºÍÏ´ EX-09 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 125


Private Sub DI(ByVal Logic As Boolean) If Logic Then Out &H378, Inp(&H378) Or &H4 Else Out &H378, Inp(&H378) And &HFB End If End Sub

13.4 à¢Õ¹â»Ãá¡ÃÁ‹ÍÂÊíÒËÃѺʋ§¢ŒÍÁÙÅ 8 ºÔµ Private Sub Shift8Bit(ByVal Data As Byte) Dim i As Integer For i = 7 To 0 Step -1 If (Data And (2 ^ i)) = (2 ^ i) Then DI True Else DI False End If CLK Next i End Sub

13.5 à¢Õ¹â»Ãá¡ÃÁãˌà˵ءÒó Form_Load , cmdReset_Click áÅÐ cmdOut_Click ´Ñ§¹Õé Private Sub Form_Load() InitialShiftIn RST LE End Sub Private Sub cmdReset_Click() RST LE End Sub Private Sub cmdOut_Click() Shift8Bit CByte(“&H” & txtOutH.Text) Shift8Bit CByte(“&H” & txtOutL.Text) LE End Sub

àÁ×Íè ÃѺ¢ŒÍÁÙŨҡ txtOutH ã¹ÃÙ»¢Í§àÅ¢°Ò¹ÊԺˡ ¹íÒ &H ÁÒµ‹Í¢ŒÒ§Ë¹ŒÒáŌÇá»Å§¤‹Òãˌ ໚¹äºµ ʋ§ä»Âѧâ»Ãá¡ÃÁ‹Í Shift8Bit à¾×èÍàÅ×è͹¢ŒÍÁÙÅÍÍ¡ä»ãˌ 74HC595 ¾ÃŒÍÁ¡ÑºÊ‹§ ÊÑ­­Ò³ Clock àÁ×Íè ¤Ãº 8 ºÔµ ¨Ð¹íÒ¢ŒÍÁÙŨҡ txtOutL ÁÒá»Å§à»š¹¤‹Ò亵 áÅÐʋ§ä»àÁ×Íè ʋ§ ¤Ãº·Ñ§é 16 ºÔµ ʋ§ÊÑ­­Ò³áŵ« LED º¹ºÍÏ´ EX-01 ¨ÐáÊ´§¼Å¢Í§¢ŒÍÁÙÅ â´Â·Õ¢è ͌ ÁÙŨҡ txtOutH ¨ÐÍÍ¡·Õ¾è Íϵ OUTH áÅТŒÍÁÙŨҡ txtOutL ¨ÐÍÍ¡·Õ¾è Íϵ OUTL µÑÇÍ‹ҧâ»Ãá¡ÃÁ ´Ù·äÕè ¿Å LAB13A.VBP àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 126


13.6 à¾ÔÁè ¤Í¹â·ÃÅáÅШѴ¿ÍÏÁ´Ñ§ÃÙ»·Õè P13-2 â´Âãˌ»Á؆ ໚¹¤Í¹â·ÃÅ Array â´ÂãˌᵋÅлØÁ† ÁÕ ª×Íè à´ÕÂǡѹᵋ Index äÁ‹«Òéí ¡Ñ¹µÑ§é ᵋ 0-15 ÇÔ¸ÊÕ ÃŒÒ§¤Í¹â·ÃÅ Array ´Ù䴌¨Ò¡¡Ò÷´Åͧ·Õè 4 13.7 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdD_Click(Index As Integer) ´Ñ§¹Õé Private Sub cmdD_Click(Index As Integer) Dim i As Integer Dim tmp As Byte If cmdD(Index).Caption = “OFF” Then cmdD(Index).Caption = “ON” Else cmdD(Index).Caption = “OFF” End If tmp = 0 For i = 0 To 7 If cmdD(i + 8).Caption = “ON” Then tmp = tmp + (2 ^ i) Next i txtOutH.Text = Hex(tmp) Shift8Bit tmp tmp = 0 For i = 0 To 7 If cmdD(i).Caption = “ON” Then tmp = tmp + (2 ^ i) Next i txtOutL.Text = Hex(tmp) Shift8Bit tmp LE End Sub

àÁ×Íè ¤ÅÔ¡é ·Õ»è Á؆ cmdD(Index) ã´æ â»Ãá¡ÃÁ¨ÐµÃǨÊÍºÇ‹Ò Caption ¢Í§»ØÁ† ¹Ñ¹é ໚¹¤íÒÇ‹Ò ON ËÃ×Í OFF áÅзíÒ¡ÒáÅѺ Caption ãˌ໚¹¤íҵç¡Ñ¹¢ŒÒÁ ¨Ò¡¹Ñ¹é ¨ÐµÃǨÊͺ Caption ¢Í§áµ‹ÅлØÁ† ·Õ¡è ÅØÁ‹ OUTH à¾×Íè ͋ҹ¤‹ÒᵋÅкԵ áŌÇá»Å§¤‹Òãˌ໚¹àÅ¢°Ò¹ÊԺˡáÊ´§ã¹ª‹Í§ txtOutH áÅÐʋ§¤‹ÒÍÍ¡ä»ãˌ¾Íϵ SHIFT IN º¹ºÍÏ´ EX-09 àÁ×Íè ʋ§¤Ãº 8 ºÔµ â»Ãá¡ÃÁ¨Ð ·íÒ§Ò¹¡Ñº¡ÅØÁ‹ OUTL àËÁ×͹¡Ñº¡ÅØÁ‹ OUTH àÁ×Íè ʋ§¤Ãº·Ñ§é 16 ºÔµáŌǨÐʋ§ÊÑ­­Ò³áŵ« ÍÍ¡ä» àÍÒµ¾µØ ¤‹Òà´ÔÁ¨Ð¶Ù¡·´á·¹â´Â¤‹ÒàÍÒµ¾µØ ãËÁ‹·ÊÕè §‹ ÍÍ¡ä» ÊíÒËÃѺÃÒÂÅÐàÍÕ´·Ñé§ËÁ´¢Í§â»Ãá¡ÃÁ·´Åͧ¹Õé´Ù䴌¨Ò¡ä¿Å LAB13B.VBP ÃÙ»·Õè P13-2 ˹ŒÒµÒ¢Í§¿ÍÏÁ·ÕÊè Ìҧ¢Ö¹é ¨Ò¡ â»Ãá¡ÃÁ·´Åͧ LAB13B.VBP ´ŒÇ¡ÒÃ㪌 à·¤¹Ô¤¡ÒÃÊÌҧ¤Í¹â·ÃÅ Array

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 127


¡Ò÷´Åͧ·Õè 14 ¡ÒâѺÊàµç»à»ÍÏÁÍàµÍϼҋ ¹ºÍÏ´ EX-09 à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 2. EX-05 ºÍÏ´¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ 1 Ἃ¹ 3. EX-09 ºÍÏ´¢ÂÒ¾ÍϵàÍÒµ¾µØ Ẻ«Ô§â¤Ã¹ÑÊ 1 Ἃ¹ 4. Êàµç»à»ÍÏÁÍàµÍÏẺÂÙ¹âÔ ¾ÅÒÏ¢¹Ò´ 12V 100Ω 7.5 ͧÈÒµ‹ÍÊàµç» 1 µÑÇ 5. áËŋ§¨‹ÒÂ俵ç +12V 2A ËÃ×ÍÁÒ¡¡Ç‹Ò 1 à¤Ã×Íè § 6. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 7. ÊÒÂàª×Íè Áµ‹Í IDC-10 3 àʌ¹

¡Ò÷´Åͧ 14.1 µ‹ÍÊÒ¨ҡ¤Í¹à¹ç¡àµÍÏ OUTL ¢Í§ºÍÏ´ EX-09 ä»Âѧ¤Í¹à¹ç¡àµÍÏ DATA BUS ¢Í§ºÍÏ´ EX-05 áŌǵ‹ÍÁÍàµÍÏáÅÐáËŋ§¨‹ÒÂä¿ãˌ¶¡Ù µŒÍ§ 14.2 ÊÌҧâ»Ãá¡ÃÁ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ â´Â¡ÒÃÇÒ§¤Í¹â·ÃÅ µÑ§é ª×Íè áÅСíÒ˹´¤‹Ò¤Ø³ÊÁºÑµÔ ´Ñ§ÃÙ»·Õè P14-1 14.3 ËÅÑ¡¡Òâͧ¡Ò÷íÒ§Ò¹â»Ãá¡ÃÁ¹Õé ¨Ð·íÒ¡ÒÃǹÅÙ»àÁ×Íè à¡Ô´à˵ءÒó cmdRun_click à¾×Íè ¤Çº¤ØÁÁÍàµÍÏ â´Â¨Ð㪌µÇÑ á»Ã㹡ÒáíÒ˹´ÅѡɳСÒâѺáÅеÑÇá»ÃÊíÒËÃѺ¡ÒÃǹÅٻ໚¹ ª¹Ô´ boolean »ÃСÒȵÑÇá»Ã·ÕÊè Nj ¹ General Declare ´Ñ§¹Õé Dim flgRun As Boolean Dim flgLeft As Boolean, flgRight As Boolean, flgFree As Boolean, flgBreak As Boolean Name

hsc

Max

4

Min

1

LargeChange

5

SmallChange

1

Value

100

ÃÙ»·Õè P14-1 ˹ŒÒµ‹Ò§¢Í§â»Ãá¡ÃÁ¢ÑºÊàµç»à»ÍÏÁÍàµÍÏ·ãÕè ªŒã¹¡Ò÷´Åͧ¹Õé ÊÒÁÒö ·´ÅͧáÅдÙÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ䴌¨Ò¡ä¿Å LAB14A.VBP àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 128


ÊÌҧâ»Ãá¡ÃÁ‹ÍÂÊíÒËÃѺ¡ÒÃà»ÅÕè¹ÅѡɳСÒâѺ·Õèà˵ءÒó cmdFree_Click, cmdBreak_Click, cmdLeft_Click áÅÐ cmdRight_Click ´Ñ§¹Õé Private Sub cmdBreak_Click() flgLeft = False flgRight = False flgBreak = True flgFree = False End Sub Private Sub cmdFree_Click() flgLeft = False flgRight = False flgBreak = False flgFree = True End Sub Private Sub cmdLeft_Click() flgLeft = True flgRight = False flgBreak = False flgFree = False End Sub Private Sub cmdRight_Click() flgLeft = False flgRight = True flgBreak = False flgFree = False End Sub

14.4 ÊÌҧâ»Ãá¡ÃÁ‹ÍÂÊíÒËÃѺ¡ÒÃ˹‹Ç§àÇÅÒâ´Â㪌¤Ò‹ ¨Ò¡ hsc áÅСÒÃʋ§¢ŒÍÁÙŷѧé 16 ºÔµ Private Sub Delay() Dim a As Single a = Timer Do While Timer < a + (hsc.Value / 100) DoEvents Loop End Sub Private Sub Shift16Bit(Optional ByVal OutH As Byte = 0, Optional ByVal OutL As Byte = 0) Shift8Bit OutH Shift8Bit OutL LE End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 129


14.5 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdRun_Click áÅÐ Form__Unload ´Ñ§¹Õé Private Sub cmdRun_Click() If flgRun Then flgRun = False cmdRun.Caption = “Run” Exit Sub Else flgRun = True cmdRun.Caption = “Stop” End If Do While flgRun If flgLeft Then Shift16Bit 0, 8 Delay Shift16Bit 0, 4 Delay Shift16Bit 0, 2 Delay Shift16Bit 0, 1 Delay ElseIf flgRight Then Shift16Bit 0, 1 Delay Shift16Bit 0, 2 Delay Shift16Bit 0, 4 Delay Shift16Bit 0, 8 Delay ElseIf flgBreak Then Shift16Bit 0, 3 Delay ElseIf flgFree Then Shift16Bit 0, 0 Delay End If Loop End Sub Private Sub Form_Unload(Cancel As Integer) Shift16Bit 0, 0 ‘ Release Motor End End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 130


14.6 Ãѹâ»Ãá¡ÃÁ àÁ×Íè ¤ÅÔ¡é »ØÁ† Run ¨ÐàËç¹Ç‹ÒÁÍàµÍÏäÁ‹·Òí §Ò¹à¹×Íè §¨Ò¡ µÑÇá»Ã·Õ¡è Òí ˹´ÅѡɳР¡ÒâѺÁÍàµÍÏ·¡Ø µÑÇÁդҋ àÃÔÁè µŒ¹à»š¹ False ¨Ö§äÁ‹Á¡Õ ÒÃʋ§¢ŒÍÁÙÅ à¾ÔÁè ⤌´·Õàè ˵ءÒó Form_Load ãˌ¡íÒ˹´·ÔÈ·Ò§àÃÔèÁµŒ¹ flgLeft = True

µÑÇÍ‹ҧâ»Ãá¡ÃÁ¹Õ´é ·Ù äÕè ¿Å LAB14A.VBP ¨Ò¡«ÍÏÊâ»Ãá¡ÃÁ Êѧࡵ䴌Çҋ ·Ø¡¤ÃÑ§é ·ÕÊè §‹ ¢ŒÍÁÙÅ令Ǻ¤ØÁÁÍàµÍÏ ¤‹Ò·Õ¾è Íϵ OUTH ໚¹ 0 ¶ŒÒ·Õè¾Íϵ OUTH ÁÕÍØ»¡Ã³ã´µ‹ÍÍÂً ã¹â»Ãá¡ÃÁÊÒÁÒöá·Ã¡¤‹ÒÊíÒËÃѺ¤Çº¤ØÁÍØ»¡Ã³ µÑǹÑé¹ä´Œã¹¡ÒÃʋ§¤‹Ò¤ÃÑé§à´ÕÂÇ «Öè§ã¹¡ÒÃà¢Õ¹â»Ãá¡ÃÁ¨ÐµŒÍ§ÁÕ¡ÒäíҹdzËÃ×Í¡íÒ˹´¤‹Ò¢Í§ ¾Íϵ OUTH áÅÐ OUTL änjÅNj §Ë¹ŒÒ¡‹Í¹Ê‹§¢ŒÍÁÙÅä» «Ö§è ¨ÐáÊ´§ãˌàËç¹ã¹¡Ò÷´Åͧµ‹Íä»

¡Ò÷´Åͧ¢ÑºÊàµç»à»ÍÏÁÍàµÍϾÌÍÁ¡Ñº¢Ñº LED ¼‹Ò¹ºÍÏ´ EX-09 14.7 à¾ÔÁè ¤Í¹â·ÃÅáÅФ͹â·ÃÅ Array ´Ñ§ÃÙ»·Õè P14-2 â´Â¡íÒ˹´ãˌ»Á؆ cmdD ÁÕ Index µÑ§é ᵋ 8 - 15 14.8 »ÃСÒȵÑÇá»ÃÊíÒËÃѺà¡çº¤‹Ò¾Íϵ OUTH áÅÐ OUTL ·ÕÊè Nj ¹ General Declaration Dim OutH As Byte, OutL As Byte

14.9 ᡌä¢â»Ãá¡ÃÁ·Õàè ˵ءÒó cmdRun_Click ãˌʧ‹ ʶҹТͧ¾Íϵ OUTH á·¹¤‹Ò 0 áÅÐÁÕ ¡ÒÃà¡çºÊ¶Ò¹Ð¢Í§¾Íϵ OUTL ËÅѧ¨Ò¡Ê‹§¢ŒÍÁÙÅÍ͡仢ѺÁÍàµÍÏ µÑÇÍ‹ҧºÒ§Ê‹Ç¹áÊ´§ä´Œ ´Ñ§¹Õé Shift16Bit OutH, 1 OutL = 1 Delay Shift16Bit OutH, 2 OutL = 2 Delay ....

ÃÙ»·Õè P14-2 ˹ŒÒµ‹Ò§¢Í§â»Ãá¡ÃÁ¢ÑºÊàµç»à»ÍÏÁÍàµÍϾÌÍÁ¡Ñº LED ·Õãè ªŒã¹¡Ò÷´Åͧ ¹Õé ÊÒÁÒö·´ÅͧáÅдÙÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ䴌¨Ò¡ä¿Å LAB14B.VBP àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 131


14.10 à¢Õ¹â»Ãá¡ÃÁ·Õàè ˵ءÒó cmdD_Click áÅÐ cmdReset_Click ´Ñ§¹Õé Private Sub cmdD_Click(Index As Integer) Dim i As Integer Dim tmp As Byte If cmdD(Index).Caption = “OFF” Then cmdD(Index).Caption = “ON” Else cmdD(Index).Caption = “OFF” End If tmp = 0 For i = 0 To 7 If cmdD(i + 8).Caption = “ON” Then tmp = tmp + (2 ^ i) Next i txtOutH.Text = Hex(tmp) OutH = tmp Shift16Bit OutH, OutL End Sub Private Sub cmdReset_Click() Dim i As Byte For i = 8 To 15 cmdD(i).Caption = “OFF” Next i txtOutH.Text = 0 OutH = 0 Shift16Bit OutH, OutL End Sub

14.11 Ãѹâ»Ãá¡ÃÁ ÊÑè§ãˌÁÍàµÍÏËÁع áÅÐແ´»´ LED ¡Ò÷íÒ§Ò¹¢Í§â»Ãá¡ÃÁ¨Ð㪌µÑÇá»Ã OUTH áÅÐ OUTL à¡çºÊ¶Ò¹Ð¢Í§¾Íϵänj·¡Ø ¤ÃÑ§é ·ÕÁè ¡Õ ÒÃà»ÅÕÂè ¹á»Å§ àÁ×Íè ÁÕ¡ÒÃʋ§¢ŒÍÁÙÅ¡ç¨Ð¹íÒ ¤‹ÒʶҹШҡµÑÇá»Ã·Ñ§é Êͧʋ§ÍÍ¡ä»´ŒÇ ʶҹзվè Íϵ·Ñ§é Êͧ¨Ö§¶Ù¡µŒÍ§ 㹡ÒÃ㪌§Ò¹ÊÒÁÒö ¹íÒÇÔ¸¡Õ ÒÃà¡çºáÅÐʋ§¢ŒÍÁÙÅä»»ÃÐÂØ¡µãªŒ¡ºÑ Ãкºµ‹Ò§æ 䴌ઋ¹¡Ñ¹ ÊíÒËÃѺÃÒÂÅÐàÍÕ´·Ñé§ËÁ´¢Í§â»Ãá¡ÃÁ·´Åͧ¹Õé´Ù䴌¨Ò¡ä¿Å LAB14B.VBP

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 132


º··Õè 11

¾Íϵ¢¹Ò¹¡Ñº¡ÒÃÇÑ´ÍسËÀÙÁÔ ¼‹Ò¹ÃкººÑÊ I2C ¡ÒÃàª×èÍÁµ‹Í¾Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍϡѺÊÑ­­Ò³ËÃ×Í»ÃÔÁÒ³·Ò§¿Êԡʏ໚¹ÊÔ觷Õè ä´ŒÃºÑ ¤ÇÒÁʹã¨Í‹ҧÁÒ¡ ¹Í¡à˹×Í仨ҡáç´Ñ¹ä¿¿‡Ò·Õäè ´Œ¡Å‹ÒǶ֧ä»áŌǡ‹Í¹Ë¹ŒÒ¹Õé »ÃÔÁÒ³·Ò§ ¿Ê¡Ô ÊÍ¡Õ µÑÇË¹Ö§è ·Õ¹è ҋ ʹ㨤×Í ÍسËÀÙÁÔ áÅдŒÇ¤ÇÒÁ¡ŒÒÇ˹ŒÒ㹡ÒþѲ¹ÒÍØ»¡Ã³ÍàÔ Åç¡·Ã͹ԡʏ ·íÒãˌÁ¡Õ ÒüÅÔµÍØ»¡Ã³¨Òí ¾Ç¡µÑǵÃǨ¨ÑºÍسËÀÙÁÍÔ Í¡ÁÒãˌ㪌§Ò¹¡Ñ¹ËÅÒÂÃٻẺ ઋ¹ à·ÍÏÁÊÔ àµÍÏ (thermister) ËÃ×Í µÑǵŒÒ¹·Ò¹á»Ã¤‹ÒµÒÁÍسËÀÙÁÔ à»š¹ÍØ»¡Ã³µÇÑ µÃǨ ¨ÑºÍسËÀÙÁ¾Ô ¹×é °Ò¹ ·Õè ³ ÍسËÀÙÁËÔ ÍŒ §¨ÐÁդҋ ¤ÇÒÁµŒÒ¹·Ò¹ä¿¿‡Ò¤‹Ò˹֧è àÁ×Íè ÍسËÀÙÁÃÔ ÍºµÑÇà·ÍÏ ÁÔÊàµÍÏà¡Ô´¡ÒÃà»ÅÕÂè ¹á»Å§ ¤‹Ò¤ÇÒÁµŒÒ¹·Ò¹ä¿¿‡Ò¢Í§Áѹ¨Ðà»ÅÕÂè ¹á»Å§µÒÁä»´ŒÇ «Ö§è ¨ÐÁÕ·§Ñé Ẻà¾ÔÁè ¤‹ÒàÁ×Íè ÍسËÀÙÁÊÔ §Ù ¢Ö¹é (PTC : Positive temperature co-efficient) áÅÐẺŴ¤‹ÒàÁ×Íè ÍسËÀÙÁÔ ÊÙ§¢Ö¹é (NTC : Negative temperature co-efficient) 㹡ÒÃ㪌§Ò¹µÑǵÃǨ¨Ñºáºº¹Õµé ͌ §ÁÕ¡Òõ‹Í ǧ¨ÃÍÔàÅç¡·Ã͹ԡʏªÇ‹  à¾×Íè à»ÅÕÂè ¹¡ÒÃà»ÅÕÂè ¹á»Å§¤‹Ò¤ÇÒÁµŒÒ¹·Ò¹à»š¹áç´Ñ¹ä¿¿‡Ò áŌÇʋ§µ‹Í ä»Âѧǧ¨Ãá»Å§áç´Ñ¹à»š¹¢ŒÍÁÙÅ´Ô¨µÔ ÍÅà¾×Íè ʋ§à¢ŒÒÊÙ¾‹ Íϵ¢¹Ò¹µ‹Íä» ´Ñ§áÊ´§ä´ÍÐá¡ÃÁ㹡Òà ·íÒ§Ò¹ã¹ÃÙ»·Õè 11-1 (¡) µÑǵÃǨ¨Ñºáºº¹Õ¨é ж١ú¡Ç¹ä´Œ§Ò‹  ᵋ¢ÍŒ ´Õ¤Í× ÃÒ¤Ò¶Ù¡áÅÐÊÒÁÒö »ÃÐÂØ¡µãËŒãªŒÇ´Ñ ÍسËÀÙÁäÔ ´ŒÂҋ ¹¡ÇŒÒ§ÁÒ¡ à·ÍÏâÁ¤Ñ»à»Å (thermocouple) ໚¹µÑǵÃǨ¨Ñº·ÕÁè àÕ Ê¶ÕÂÃÀҾ㹡Ò÷íÒ§Ò¹ÊÙ§ áÅйÔÂÁ 㪌㹧ҹÍصÊÒË¡ÃÃÁ ÁÕÂҋ ¹ÇÑ´ÍسÀÙÁ·Ô ÊÕè §Ù áÅСnjҧ¡Ç‹Òà·ÍÏÁÊÔ àµÍÏÁÒ¡ áÅСÒùíÒä»ãªŒ§Ò¹µŒÍ§ ÃÐÁÑ´ÃÐÇѧÍ‹ҧÁҡ㹨شàª×Íè Áµ‹Í¢Í§µÑǵÃǨ¨Ñº¡ÑºÊÒÂÊÑ­­Ò³ µÑǵÃǨ¨Ñºáºº¹Õµé ͌ §¡ÒÃǧ¨Ã »ÃѺÊÑ­­Ò³ËÃ×Í signal condition à¾×Íè ¢ÂÒÂÃдѺáÅСíÒ˹´ÍѵÃÒ¡ÒÃà»ÅÕÂè ¹á»Å§¢Í§áç´Ñ¹ àÁ×Íè à·Õº¡ÑºÍسËÀÙÁÔ áŌÇʋ§ä»Âѧǧ¨Ãá»Å§áç´Ñ¹à»š¹¢ŒÍÁÙÅ´Ô¨µÔ ÍÅà¾×Íè »ÃÐÁÇżŵ‹Íä» äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ººãˌ¼Å໚¹áç´Ñ¹ ໚¹ÍØ»¡Ã³·ÊÕè Ìҧ¢Ö¹é ¾ÔàÈÉ â´Âã¹µÑǢͧÁѹÁÕÊNj ¹ µÃǨ¨ÑºÍسËÀÙÁáÔ ÅŒÇà»ÅÕÂè ¹¤‹ÒÍسËÀÙÁ¹Ô ¹Ñé ʋ§à»š¹áç´Ñ¹ä¿¿‡ÒÍÍ¡ÁÒ â´Â»¡µÔ¨ÐÃдѺ¤‹Í¹¢ŒÒ§µèÒí áÅÐÁÕÍѵÃÒ¡ÒÃà»ÅÕè¹á»Å§áç´Ñ¹à·Õº¡ÑºÍسËÀÙÁÔ·Ñé§áººà»š¹àªÔ§àʌ¹áÅÐẺÅÍ¡ÒÃÔ¸ÖèÁ áÅÐ à·Õºã¹Ë¹‹ÇÂÁÔÅÅÔâÇŵµÍ‹ ͧÈÒà«Åà«ÕÂÊ (mV/ðC) ËÃ×ÍÁÔÅÅÔâÇŵµÍ‹ à¤ÅÇÔ¹ (mV/K) µÑǵÃǨ ¨¨Ñºáºº¹ÕÁé àÕ Ê¶ÕÂÃÀÒ¾¡Ò÷íÒ§Ò¹·Õ´è ¡Õ NjÒà·ÍÏÁÊÔ àµÍÏ ᵋÃÒ¤Òᾧ¡Ç‹ÒÁÒ¡ áÅÐÂѧ¤§µŒÍ§ãªŒÇ§¨Ã ¢ÂÒÂáç´Ñ¹áÅÐà»ÅÕÂè ¹áç´Ñ¹à»š¹¢ŒÍÁÙÅ´Ô¨µÔ ÍÅà¾×Íè ʋ§à¢ŒÒÊÙ¾‹ Íϵ¢¹Ò¹¢Í§¤ÍÁ¾ÔÇàµÍÏàËÁ×͹¡Ñ¹ ã¹ÃÙ»·Õè 11-1 (¢) áÊ´§¡Ò÷íÒ§Ò¹¢Í§µÑǵÃǨ¨Ñºáºº¹Õé àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 129


à·ÍÏÁÊÔ àµÍÏ

ǧ¨Ãà»ÅÕÂè ¹ ¤‹Ò¤ÇÒÁµŒÒ¹·Ò¹ ໚¹áç´Ñ¹ä¿¿‡Ò

T

ǧ¨Ãá»Å§áç´Ñ¹ ä¿¿‡Ò໚¹¢ŒÍÁÙÅ ´Ô¨µÔ ÍÅ

ʋ§ä»Âѧ¾Íϵ¢Í§¤ÍÁ¾ÔÇàµÍÏ

ǧ¨Ãá»Å§áç´Ñ¹ ä¿¿‡Ò໚¹¢ŒÍÁÙÅ ´Ô¨µÔ ÍÅ

ʋ§ä»Âѧ¾Íϵ¢Í§¤ÍÁ¾ÔÇàµÍÏ

(¡) +V Vout

äÍ«ÕÇ´Ñ ÍسËÀÙÁÔ àª‹¹ LM34, LM335

GND

ǧ¨Ã»ÃѺʶҹРËÃ×Í signal condition

(¢) +V

äÍ«ÕÇ´Ñ ÍسËÀÙÁÔ áºº´Ô¨µÔ ÍÅ

Dout GND

ǧ¨Ã¨Ñ´¡ÒâŒÍÁÙÅáÅÐàª×Íè Áµ‹Í¡Ñº ¾Íϵ¢Í§¤ÍÁ¾ÔÇàµÍÏ ÍÒ·Ô Ç§¨Ãàª×Íè Áµ‹ÍÃкººÑÊ I C

ʋ§ä»Âѧ¾Íϵ¢Í§¤ÍÁ¾ÔÇàµÍÏ

(¤)

ÃÙ»·Õè 11-1 ¡Ò÷íÒ§Ò¹àº×Íé §µŒ¹¢Í§µÑǵÃǨ¨ÑºÍسËÀÙÁáÔ ººµ‹Ò§æ à¾×Íè ʋ§¤‹ÒÁÒÂѧ¾Íϵ¢¹Ò¹ (¡) à·ÍÏÁÊÔ àµÍÏ (¢) äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ººãˌ¼Å໚¹áç´Ñ¹ (¤) äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ºº´Ô¨µÔ ÍÅ äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ººãˌ¼Å໚¹¢ŒÍÁÙÅ ËÃ×ÍàÃÕÂ¡Ç‹Ò äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ºº´Ô¨µÔ ÍŠ໚¹µÑǵÃǨ ¨Ñº·Õ©è ÅÒ´ÁÒ¡¢Ö¹é â´ÂµÑǵÃǨ¨Ñºáºº¹Õ¨é Ðãˌ¤Ò‹ ¢Í§ÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´ŒÍÍ¡ÁÒ໚¹¢ŒÍÁÙÅ´Ô¨µÔ Íŷѹ·Õ äÁ‹µÍŒ §ãªŒÍ»Ø ¡Ã³ËÃ×Íǧ¨Ãµ‹Í¾‹Ç§ÀÒ¹͡ à¾Õ§ᵋ¡ÒõԴµ‹Í¡ÑºµÑǵÃǨ¨Ñºáºº¹Õ¨é еŒÍ§ãªŒ¡Òà Ê×Íè ÊÒâŒÍÁÙÅẺ͹ءÃÁࢌҪ‹Ç ·íÒãˌµÍŒ §ãªŒÍ»Ø ¡Ã³¨Òí ¾Ç¡äÁâ¤Ã¤Í¹â·ÃÅàÅÍÏËÃ×ͤÍÁ¾ÔÇàµÍÏ ÁÒµÔ´µ‹Íà¾×Íè ͋ҹ¢ŒÍÁÙÅÍÍ¡¨Ò¡µÑǵÃǨ¨Ñº ´Ñ§¹Ñ¹é ËÒ¡µŒÍ§¡ÒÃÇÑ´ÍسËÀÙÁáÔ ÅŒÇʋ§¢ŒÍÁÙÅ¡ÅѺÁÒÂѧ ¤ÍÁ¾ÔÇàµÍÏ µÑǵÃǨ¨Ñºáºº¹Õ鹋ҨÐàËÁÒÐÊÁ·ÕèÊØ´ ËҡᵋµÑǵÃǨ¨Ñºáºº¹ÕéÁÕÃÒ¤Ò¤‹Í¹¢ŒÒ§ÊÙ§ áÅÐäÁ‹ÊÒÁÒö»ÃѺᵋ§ª´àªÂ䴌 ã¹ÃÙ»·Õè 11-1 (¤) áÊ´§¡Ò÷íÒ§Ò¹¢Í§µÑǵÃǨ¨Ñºáºº¹Õé ´Ñ§¹Ñé¹á¹Ç·Ò§¡ÒÃ㪌¤ÍÁ¾ÔÇàµÍÏà¾×èÍÇÑ´¤‹ÒÍسËÀÙÁÔã¹ÅѡɳзÕèÁÕ¤ÇÒÁ«Ñº«ŒÍ¹¹ŒÍ·ÕèÊØ´ ÊíÒËÃѺ¹Ñ¡·´Åͧ ¨Ö§àÅ×͡㪌äÍ«ÕµÃǨ¨ÑºÍسËÀÙÁáÔ ººãˌ¼Å໚¹¢ŒÍÁÙÅ ·Ñ§é ¹Õàé ¾×Íè Å´¢Ñ¹é µÍ¹ã¹¡Òà ÊÌҧǧ¨Ã»ÃѺÊÑ­­Ò³áÅÐǧ¨Ãá»Å§ÊÑ­­Ò³ÍйÒÅ͡໚¹´Ô¨ÔµÍÅ äÍ«Õ·ÕèàÅ×͡㪌¤×ÍàºÍÏ DS1621 «Ö§è 㪌¡ÒõԴµ‹Í¼‹Ò¹ÃкººÑÊ I2C àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 130


¢Ò·Õè ª×Íè ¢Ò SDA

1

SCL

2

TOUT 3 GND 4

8 +Vcc ,5$  Digital Tthermometer and thermostat

7

A0

6

A1

5

A2

˹ŒÒ·Õ/è ¡Ò÷íÒ§Ò¹

1

SDA

¢Ò¢ŒÍÁÙÅ͹ءÃÁÊíÒËÃѺàª×Íè Áµ‹Í¡ÑºÃкººÑÊ I C

2

SCL

¢ÒÊÑ­­Ò³¹ÒÌÔ¡ÒÊíÒËÃѺàª×èÍÁµ‹Í¡ÑºÃкººÑÊ I C

3

TOUT

"áÍ¡µÕ¿" àÁ×Íè ÍسËÀÙÁÊÔ §Ù ¶Ö§¨Ø´¡ÃеعŒ ÊÙ§ (TH) "ÃÕ૵" àÁ×èÍÍسËÀÙÁÔŴŧµíèҡNjҨش¡Ãе،¹µíèÒ (TL)

4

GND

¢Òµ‹Í¡ÃÒÇ´¢Í§Ç§¨Ã

5-7

A2-A0 ¢Ò¡íÒ˹´áÍ´à´Ãʢͧ DS1621 ËÒ¡ÁÕµÑÇà´ÕÂÇã¹Ãкº¤Çõ‹Íŧ¡ÃÒÇ´

8

+Vcc

¢Òµ‹Íä¿àÅÕÂé § +5V

ÃÙ»·Õè 11-2 ¡ÒèѴ¢ÒáÅСÒ÷íÒ§Ò¹¢Í§ DS1621 äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ºº´Ô¨µÔ ÍÅ

DS1621 äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ºº´Ô¨µÔ ÍÅ ¼Ù¼Œ ÅÔµ¤×Í Dallas Semiconductor ໚¹äÍ«ÕÇ´Ñ ÍسËÀÙÁ·Ô ãÕè ªŒ¡ÒõԴµ‹Í¼‹Ò¹ÃкººÑÊ I2C ã¹ ÃÙ»·Õè 11-2 áÊ´§¡ÒèѴ¢ÒáÅÐ˹ŒÒ·Õ¢è ͧᵋÅТҢͧäÍ«Õ DS1621 ÊíÒËÃѺ¤Ø³ÊÁºÑµ·Ô ÊÕè Òí ¤Ñ­¢Í§ DS1621 ÁÕ´§Ñ ¹Õé ÊÒÁÒöÇÑ´ÍسËÀÙÁäÔ ´Œµ§Ñé ᵋ -55ðC ¶Ö§ +125ðC â´ÂÁÕ¤ÇÒÁÅÐàÍÕ´㹡ÒÃÇÑ´ 0.5ðC à·Õº໚¹Ë¹‹Ç¢ͧ¿Òàùäεä´Œà·‹Ò¡Ñº -67ðF ¶Ö§ +257ðF ¤ÇÒÁÅÐàÍÕ´ 0.9ðF â´ÂäÁ‹µÍŒ §ãªŒ ÍØ»¡Ã³µ‹ÍËÇÁÀÒ¹͡ l

l

¤ÇÒÁÅÐàÍÕ´¢Í§¢ŒÍÁÙÅÍسËÀÙÁ´Ô ¨Ô µÔ ÍÅ 9 ºÔµ

l

㪌ä¿àÅÕÂé §ä´Œµ§Ñé ᵋ 2.7-5.5V

l

㪌àÇÅÒ㹡ÒÃÇÑ´ÍسËÀÙÁáÔ ÅŒÇá»Å§à»š¹¢ŒÍÁÙÅ´Ô¨µÔ ÍÅ 1 ÇÔ¹Ò·Õ

l

ÊÒÁÒö·íҧҹ໚¹à·ÍÏâÁʵѵ (thermostat) 䴌 ¾ÃŒÍÁ¢ÒàÍÒµ¾µØ 1 ¢Ò

ÊÒÁÒöµÑ§é ¤‹ÒÍسËÀÙÁ·Ô µÕè ͌ §¡ÒÃàÁ×Íè ·íҧҹ໚¹à·ÍÏâÁʵѵ䴌 â´ÂµÔ´µ‹Í¼‹Ò¹ÃкººÑÊ I2C áÅФ‹Ò·Õ¡è Òí ˹´¹Õ¨é Ф§ÍÂÙµ‹ ÅÍ´ä» áÁŒ»Å´ä¿àÅÕÂé §áŌǡçµÒÁ ÊÒÁÒöà»ÅÕÂè ¹á»Å§ä´Œâ´Â¡Òà ¡íÒ˹´·Ò§«Í¿µáÇÏ෋ҹÑé¹ l

l

ÊÒÁÒöµ‹Í¾‹Ç§¡Ñ¹ä´ŒÊ§Ù ÊØ´ 8 µÑÇ

¡Ò÷íÒ§Ò¹¢Í§ DS1621 ã¹ÃÙ»·Õè 11-3 áÊ´§¼Ñ§¡Ò÷íÒ§Ò¹ÃÇÁ¢Í§ DS1621 ËÑÇã¨ÊíҤѭÍÂÙ·‹ ÊÕè Nj ¹ÇÑ´ÍسËÀÙÁÔ àÁ×Íè DS1621 àÃÔÁè ·íÒ§Ò¹ ¨Ð·íÒ¡ÒÃÇÑ´ÍسËÀÙÁÔ â´ÂÀÒÂã¹äÍ«Õ¨ÐÁÕµÇÑ µÃǨ¨ÑºÍسËÀÙÁºÔ ÃèØÍÂً ¼Å¡Òà àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 131


ÃÕ¨ÊÔ àµÍϤǺ¤ØÁáÅÐáÊ´§Ê¶Ò¹Ð SCL SDA

A0 A1 A2

ʋǹ¡íÒ˹´ áÍ´à´ÃÊ áÅФǺ¤ØÁ ¢ÒÍÔ¹¾ØµàÍÒµ¾µØ

µÑǵÃǨÇÑ´ÍسËÀÙÁÔ ¨Ø´·ÃÔ¡ÍسËÀÙÁÊÔ §Ù (TH) ¨Ø´·ÃÔ¡ÍسËÀÙÁµÔ Òèí (TL)

ʋǹà»ÃÕºà·Õº¢ŒÍÁÙÅ´Ô¨µÔ ÍÅ

TOUT

ÃÙ»·Õè 11-3 ¼Ñ§¡Ò÷íÒ§Ò¹àº×Íé §µŒ¹â´ÂÃÇÁ¢Í§ DS1621 äÍ«ÕÇ´Ñ ÍسËÀÙÁáÔ ºº´Ô¨µÔ ÍÅ ÇÑ´¨Ðʋ§µ‹Íä»Âѧʋǹ¨Ñ´¡ÒÃáÍ´à´ÃÊáÅФǺ¤ØÁÍÔ¹¾ØµàÍÒµ¾µØ ã¹Ê‹Ç¹¹Õ¹é Òí ¢ŒÍÁÙÅÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´Œ ʋ§µ‹Íä»ÂѧºÑʼ‹Ò¹·Ò§¢Ò SDA â´Âä´ŒÃºÑ ¡ÒáíÒ˹´¨Ñ§ËÇСÒ÷íÒ§Ò¹¨Ò¡Ê‹Ç¹ÃÕ¨ÊÔ àµÍϤǺ¤ØÁáÅÐ áÊ´§Ê¶Ò¹Ð ËÒ¡ÁÕ¡ÒáíÒ˹´ãˌ·Òí §Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ ¢ŒÍÁÙÅ¡ÒÃÇÑ´¶Ù¡Ê‹§ä»à»ÃÕºà·Õº¡Ñº ¨Ø´¡ÃеعŒ ·Ò§ÊÙ§áÅеèÒí ·ÕÊè Nj ¹à»ÃÕºà·Õº¢ŒÍÁÙÅ´Ô¨µÔ ÍÅ ¼Å¡ÒÃà»ÃÕºà·Õº¨Ðʋ§ÍÍ¡·Ò§¢Ò TOUT à¹×Íè §¨Ò¡ DS1621 ÁÕ¢Ò¡íÒ˹´áÍ´à´ÃÊ 3 ¢Ò¤×Í A2-A0 ¨Ö§·íÒãˌÊÒÁÒöµ‹Í¾‹Ç§ DS1621 䴌ʧ٠ÊØ´ 8 µÑÇ â´ÂᵋÅеÑǵŒÍ§¡íÒ˹´Ê¶Ò¹ÐÅͨԡ·Õ¢è ÒáÍ´à´Ãʷѧé ÊÒÁãˌᵡµ‹Ò§¡Ñ¹ ʋǹ¨Ñ´¡Òà áÍ´à´ÃÊáÅФǺ¤ØÁÍÔ¹¾ØµàÍÒµ¾µØ ¢Í§ DS1621 ᵋÅеÑǨÐ໚¹µÑǨѴ¡ÒÃʋ§¢ŒÍÁÙŵÒÁ·ÕÍè »Ø ¡Ã³ ÁÒÊàµÍÏÌͧ¢Í ¤‹Ò¢Í§ÍسËÀÙÁÔ·ÕèÇѴ䴌¶Ù¡à¡çºÍÂًÃÙ»¢Í§ ¢ŒÍÁÙÅ´Ô¨µÔ ÍÅàÍÒµ¾µØ ¢ŒÍÁÙÅ´Ô¨µÔ ÍÅàÍÒµ¾µØ ¢ŒÍÁÙÅàÅ¢°Ò¹Êͧ¢¹Ò´ 9 ºÔµ ´Ñ§áÊ´§µÑÇÍ‹ҧ ÍسËÀÙÁÔ (àÅ¢°Ò¹Êͧ) (àÅ¢°Ò¹ÊԺˡ) ã¹µÒÃÒ§·Õè 11-1 ¢ŒÍÁÙÅ´Ô¨µÔ ÍÅàÍÒµ¾µØ ¨Ðẋ§ ð 7B00H +125 C 01111101 00000000 ð ໚¹ 2 ʋ ǹ 8 ºÔµº¹ËÃ× Í亵 ÊÙ § ¨Ð໚ ¹ ¤‹ Ò 00011001 00000000 1900H +25 C ð 00000001 00000000 0080H +0.5 C ÍسËÀÙÁÔ¨íҹǹàµçÁ â´ÂºÔµ MSB ¨Ð໚¹µÑÇ ð 00000000 00000000 0000H 0 C áÊ´§à¤Ã×èͧËÁÒÂÇ‹Ò ÍسËÀÙÁÔ໚¹ºÇ¡ËÃ×Íź ð 11111111 10000000 FF80H -0.5 C ð ËÒ¡ºÔµ MSB ໚¹ “1” áʴNjÒÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´Œ 11100111 00000000 E700H -25 C ð 11001001 00000000 C900H -55 C Áդҋ ໚¹Åº ã¹¢³Ð·Õè 8 ºÔµÅ‹Ò§ËÃ×Í亵Åҋ §¨Ð ¹ºÔµáÊ´§¤‹Ò¤ÇÒÁÅÐ µÒÃÒ§·Õè 11-1 áÊ´§ÃٻẺ¢ŒÍÁÙÅ´Ô¨µÔ ÍÅ ÁÕ㪌§Ò¹à¾Õ§ºÔµà´ÕÂǨÐ໚ ð µÑÇÍ‹ҧ¢Í§ÍسËÀÙÁÔ·ÕèÇѴ䴌¨Ò¡ DS1621 àÍÕ´ «Ö§è ෋ҡѺ 0.5 C àÁ×èÍÊÑè§ãˌ DS1621 ʋ§¢ŒÍÁÙÅÍسËÀÙÁÔ ¨ÐàËç¹ä´ŒÇҋ ¢ŒÍÁÙÅÍسËÀÙÁÍÔ ÂÙ·‹ Õè 8 ºÔµº¹ ʋǹ ÍÍ¡ÁÒ DS1621 ¨Ð㪌àÇÅÒäÁ‹à¡Ô¹ 1 ÇÔ¹Ò·Õ ¨Ö§¨Ð 8 ºÔµÅ‹Ò§áÊ´§¤‹Ò¤ÇÒÁÅÐàÍÕ´ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 132


ʋ§¢ŒÍÁÙÅÍÍ¡ÁÒ ´Ñ§¹Ñ¹é 㹡ÒäǺ¤ØÁ¡Ò÷íÒ§Ò¹¨Ö§µŒÍ§ÁÕ¡ÒÃ˹‹Ç§àÇÅÒ à¾×Íè ÃÍãˌ DS1621 ÇÑ´áÅÐ á»Å§¤‹ÒÍÍ¡ÁÒ໚¹¢ŒÍÁÙÅãˌàÃÕºÌÍÂàÊÕ¡‹Í¹

¡Ò÷íÒ§Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ ¹Í¡¨Ò¡ÇÑ´ÍسËÀÙÁáÔ ÅŒÇ DS1621 ÂѧÊÒÁÒö·íÒ§Ò¹ã¹áººà·ÍÏâÁʵѵËÃ×ÍãˌàÍÒµ¾µØ àÁ×Íè ÍسËÀÙÁµÔ Òèí ËÃ×ÍÊÙ§¶Ö§¨Ø´·Õ¡è Òí ˹´änj â´Â¼Ù㌠ªŒ§Ò¹ÊÒÁÒöâ»Ãá¡ÃÁ䴌µÒÁµŒÍ§¡ÒÃáÅФ‹Ò·Õâè »Ãá¡ÃÁ ¹Õ¨é ÐÍÂÙµ‹ Åʹ仨¹¡Ç‹Ò¨ÐÁÕ¡ÒÃᡌä¢áÁŒÇҋ ¨ÐµÑ´ä¿àÅÕÂé §ä»áŌǡçµÒÁ ¼Ù㌠ªŒ§Ò¹µŒÍ§¡íÒ˹´¤‹Ò¢Í§¨Ø´ ·ÃÔ¡ÍسËÀÙÁÊÔ §Ù (high temperature trigger : TH) áÅÐ ¨Ø´·ÃÔ¡ÍسËÀÙÁµÔ Òèí (low temperature trigger :TL) áÅÐàÅ×Í¡ÊÑ­­Ò³áÍ¡µÕ¿Ç‹Ò àÁ×Íè ÍسËÀÙÁÊÔ §Ù ÁÒ¶Ö§¨Ø´·Õ¡è Òí ˹´¨Ðãˌ¢ÒàÍÒµ¾µØ TOUT ʋ§ÊÑ­­Ò³ÅͨԡẺã´ÍÍ¡ä» ÊÒÁÒöàÅ×͡䴌 2 Ẻ¤×Í Åͨԡ “0” ËÃ×Í “1” àÁ×Íè ¡íÒ˹´¤‹ÒàÃÕºÌÍÂáÅŒÇ DS1621 ¨ÐÇÑ´ÍسËÀÙÁäÔ »àÃ×Íè Âæ ¨¹¡Ãзѧè àÁ×Íè ÍسËÀÙÁÊÔ §Ù ¨¹ ¶Ö§¨Ø´ TH ¢Ò TOUT ¡ç¨ÐáÍ¡µÕ¿·Ñ¹·Õ áÅÐáÍ¡µÕ¿¤ŒÒ§ÍÂÙà‹ ª‹¹¹Ñ¹é ¨¹¡Ç‹ÒÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´ŒÅ´µèÒí ŧ ¡Ç‹Ò¨Ø´ TL ´Ñ§¹Ñ¹é ¡ÒáíÒ˹´¤‹Ò¢Í§ TH áÅÐ TL ¨Ö§ÊíҤѭÁÒ¡ ËÒ¡¡íÒ˹´änj᤺ËÃ×ÍÁÕ¤ÇÒÁ TOUT "1" t

"0"

ÍسËÀÙÁÔ

¤‹ÒÇѴ䴌¨Ò¡ DS1621

TH

TL t1

t2

t3

ÍسËÀÙÁ¨Ô ÃÔ§à»ÅÕÂè ¹á»Å§ã¹ª‹Ç§ 59-60ðC (ÍÒ¨¶×Í䴌Çҋ ¤‹Í¹¢ŒÒ§¤§·Õ)è

t4

t5

t

,5$  TH=60 TL=59.5 active "1"

ÍسËÀÙÁ¨Ô ÃÔ§àÃÔÁè µŒ¹¨Ò¡ 0-60ðC áŌÇŴŧ¨Ò¡¹Ñ¹é ¨Ðà»ÅÕÂè ¹á»Å§ã¹ª‹Ç§ 50-60ðC

t6

TOUT

,5$  TH=59 TL=30 active "1"

TOUT

ÃÙ»·Õè 11-4 ÃٻẺ¡Ò÷íÒ§Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ¢Í§ DS1621 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 133


ᵡµ‹Ò§¡Ñ¹¹ŒÍÂà¡Ô¹ä» áÅÐÍسËÀÙÁ·Ô ÇÕè ´Ñ ¨ÃÔ§¹Ñ¹é ÁÕ¡ÒÃà»ÅÕÂè ¹á»Å§ã¹ª‹Ç§á¤ºæ ËÃ×ͨÃÔ§æ áŌǤ‹Í¹ ¢ŒÒ§¤§·Õè ¨Ð·íÒãˌàÍÒµ¾µØ ·Õ¢è Ò TOUT à¡Ô´ÊÑ­­Ò³Åͨԡ·Õäè Á‹¤§·Õè ¨¹¤ÅŒÒ¡Ѻ໚¹ÊÑ­­Ò³Ãº¡Ç¹ ʋ§¼Åãˌ¡ÒùíÒÊÑ­­Ò³ä»ãªŒ§Ò¹·íÒ䴌äÁ‹´Õ ᵋ¶ÒŒ ËÒ¡¡íÒ˹´änjËҋ §ËÃ×ÍÁÕ¤ÇÒÁᵡµ‹Ò§ÁÒ¡à¡Ô¹ä» ÍÒ¨·íÒãˌÁͧ䴌Çҋ ǧ¨Ãà·ÍÏâÁʵѵ¹ÕÁé ¤Õ ÇÒÁäÇ㹡Ò÷íÒ§Ò¹µèÒí à¾ÃÒСNjҨеѴàÍÒµ¾µØ µŒÍ§ÃÍ ãˌͳ Ø ËÀÙÁÅÔ ´¤‹ÒŧµèÒí ¡Ç‹Ò¨Ø´ TH ÁÒ¡æ «Ö§è ÍҨʋ§¼ÅàÊÕÂËÒ¡¡ÒÃŴŧ¢Í§ÍسËÀÙÁ·Ô àÕè ¡Ô´¢Ö¹é ¨ÃÔ§ ŧäÁ‹¶§Ö ¨Ø´ TL áµ‹Í»Ø ¡Ã³·µÕè ͌ §¡ÒùíÒÊÑ­­Ò³¹Õäé »ãªŒÁ¤Õ ÇÒÁÊÒÁÒö㹡Ò÷¹ÍسËÀÙÁãÔ ¹ª‹Ç§ÃÐ ËNjҧ TH áÅÐ TL 䴌äÁ‹¹Ò¹ ¡ç¨Ðʋ§¼Åãˌà¡Ô´¤ÇÒÁàÊÕÂËÒµ‹ÍÍØ»¡Ã³¹¹Ñé æ 䴌 ã¹ÃÙ»·Õè 11-4 áÊ´§ÃٻẺ¡Ò÷íÒ§Ò¹¢Í§ DS1621 ã¹âËÁ´à·ÍÏâÁʵѵ¹Õé

ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹¢Í§ DS1621 㹡ÒáíÒ˹´¤‹Ò TH áÅÐ TL ¢Í§ DS1621 µÅÍ´¨¹¡ÒÃàÅ×Í¡ÊÑ­­Ò³áÍ¡µÕ¿ã¹âËÁ´ à·ÍÏâÁʵѵÊÒÁÒö¡ÃзíÒ¼‹Ò¹ÃÕ¨ÔÊàµÍϵÑÇ˹Ö觷Õèª×èÍÇ‹Ò ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§ ʶҹР(Configuration/Status register) â´ÂÁѹÊÒÁÒö·íÒ˹ŒÒ·Õäè ´Œ 2 Í‹ҧ¤×Í ãªŒÊÒí ËÃѺ¡íÒ˹´ ¾ÒÃÒÁÔàµÍÏÊÒí ¤Ñ­àÁ×Íè ¡íÒ˹´ãˌ DS1621 ·íÒ§Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ áÅÐ㪌áÊ´§Ê¶Ò¹Ð¡ÒÃÇÑ´ áÅÐá»Å§¤‹ÒÍسËÀÙÁÔ â´ÂÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹¹ÕÁé ¢Õ ¹Ò´ 8 ºÔµ ÊÒÁÒöࢌҶ֧´ŒÇ¡Ãкǹ ¡ÒõԴµ‹Í¼‹Ò¹ÃкººÑÊ I2C ᵋÅкԵ¢Í§ÃÕ¨ÊÕ àµÍÏÁÃÕ ÒÂÅÐàÍÕ´´Ñ§¹Õé

ºÔµ 7

DONE

ºÔµ 6 THF

ºÔµ 5 TLF

ºÔµ 4 NVB

ºÔµ 3 1

ºÔµ 2 0

ºÔµ 1 POL

ºÔµ 0

1SHOT

DONE (Conversion done - ºÔµ 7) : ºÔµáÊ´§Ê¶Ò¹Ð¢Í§¡ÒÃá»Å§¢ŒÍÁÙÅÍسËÀÙÁÔ “0” - ÂѧÍÂÙ㋠¹ÃÐËNjҧ¡ÒÃá»Å§¢ŒÍÁÙÅ “1” - ¡ÒÃá»Å§¢ŒÍÁÙÅàÊÃç¨ÊÁºÙóáÅŒÇ THF (Temperature High Flag - ºÔµ 6) : ºÔµá¿Å¡á¨Œ§Ç‹ÒÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´ŒÊ§Ù ¡Ç‹Ò¨Ø´·ÃÔ¡ ÍسËÀÙÁÊÔ §Ù ËÃ×Í TH â´ÂàÁ×Íè à¡Ô´à˵ءÒ󏹢Õé ¹Öé ºÔµ¹Õ¨é Ð૵໚¹ “1” áÅдíÒçʶҹйÕäé nj¨¹¡Ç‹Ò ¨ÐÁÕ¡ÒÃà¢Õ¹¢ŒÍÁÙÅ “0” ÁÒÂѧºÔµ¹Õ´é nj ¡Ãкǹ¡Ò÷ҧ«Í¿µáÇÏ ËÃ×Íà¤ÅÕÂϴnj ¡ÒûŴä¿àÅÕÂé § ÍÍ¡¨Ò¡ DS1621 »ÃÐ⪹¢Í§ºÔµ¹Õ¤é Í× ËÒ¡ºÔµ¹Õàé «µ·Ñ¹·Õ·¨Õè ҋ Âä¿àÅÕÂé §ãËÁ‹ ¼Ù㌠ªŒ§Ò¹¡ç¨Ð·ÃÒº 䴌·¹Ñ ·Õàè ª‹¹¡Ñ¹Ç‹Ò ¢³Ð¹ÕÍé ³ Ø ËÀÙÁ·Ô ÇÕè ´Ñ ä´ŒÁ¤Õ ҋ ÊÙ§¡Ç‹Ò¨Ø´·ÃÔ¡ÍسËÀÙÁÔ TH ¼Ù㌠ªŒ§Ò¹ÊÒÁÒöàÅ×͡䴌¡Í‹ ¹ Ç‹Ò ¨Ðᡌ䢤‹ÒÍسËÀÙÁԢͧ¨Ø´ TH ËÃ×ÍäÁ‹ ËÃ×Íä»á¡Œä¢ã¹Ê‹Ç¹Í×è¹á·¹ ´Ñ§¹Ñé¹àÁ×èÍàÃÔèÁµŒ¹ãªŒ§Ò¹ DS1621 ¨Ö§¤ÇÃ͋ҹºÔµá¿Å¡¹Õ¡é ͋ ¹à¾×Íè µÃǨÊͺ à¾ÃÒкҧ·Õ¼ãٌ ªŒ§Ò¹äÁ‹·ÃÒºÁÒ¡‹Í¹Ç‹Ò¤‹Ò TH ¡‹Í¹Ë¹ŒÒ¹Õ¢é ͧ DS1621 ¶Ù¡¡íÒ˹´änj෋Òã´ TLF (Temperature Low Flag - ºÔµ 5) : ºÔµá¿Å¡á¨Œ§Ç‹ÒÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´Œà·‹Ò¡ÑºËÃ×͵èÒí ¡Ç‹Ò ¨Ø´·ÃÔ¡ÍسËÀÙÁµÔ Òèí ËÃ×Í TL â´ÂàÁ×Íè à¡Ô´à˵ءÒ󏹢Õé ¹Öé ºÔµ¹Õ¨é Ð૵໚¹ “1” áÅдíÒçʶҹйÕäé nj àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 134


¨¹¡Ç‹Ò¨ÐÁÕ¡ÒÃà¢Õ¹¢ŒÍÁÙÅ “0” ÁÒÂѧºÔµ¹Õ´é nj ¡Ãкǹ¡Ò÷ҧ«Í¿µáÇÏ ËÃ×Íà¤ÅÕÂϴnj ¡ÒûŴ ä¿àÅÕÂé §ÍÍ¡¨Ò¡ DS1621 »ÃÐ⪹¢Í§ºÔµ¹Õ¤é Í× ËÒ¡ºÔµ¹Õàé «µ·Ñ¹·Õ·¨Õè ҋ Âä¿àÅÕÂé §ãËÁ‹ ¼Ù㌠ªŒ§Ò¹¡ç ¨Ð·ÃҺ䴌·¹Ñ ·Õàè ª‹¹¡Ñ¹Ç‹Ò ¢³Ð¹ÕÍé ³ Ø ËÀÙÁ·Ô ÇÕè ´Ñ ä´ŒÁ¤Õ ҋ ෋ÒËÃ×͵èÒí ¡Ç‹Ò¨Ø´·ÃÔ¡ÍسËÀÙÁµÔ Òèí TL ¼Ù㌠ªŒ§Ò¹ ÊÒÁÒöàÅ×͡䴌¡Í‹ ¹Ç‹Ò ¨Ðᡌ䢤‹ÒÍسËÀÙÁ¢Ô ͧ¨Ø´ TL ËÃ×ÍäÁ‹ ËÃ×Íä»á¡Œä¢ã¹Ê‹Ç¹Í×¹è á·¹ ´Ñ§¹Ñ¹é àÁ×Íè àÃÔÁè µŒ¹ãªŒ§Ò¹ DS1621 ¨Ö§¤ÇÃ͋ҹºÔµá¿Å¡¹Õ¡é ͋ ¹à¾×Íè µÃǨÊͺ à¾ÃÒкҧ·Õ¼ãٌ ªŒ§Ò¹äÁ‹·ÃÒº ÁÒ¡‹Í¹Ç‹Ò¤‹Ò TL ¡‹Í¹Ë¹ŒÒ¹Õ¢é ͧ DS1621 ¶Ù¡¡íÒ˹´änj෋Òã´ NVB (Nonvolatile Memory Busy Flag - ºÔµ 4) : ºÔµá¿Å¡áÊ´§Ê¶Ò¹Ð¡ÒÃà¢Õ¹¢ŒÍÁÙÅŧ ã¹Ë¹‹Ç¤ÇÒÁ¨íÒÍÕÍ¾Õ ÃÍÁÀÒÂã¹ DS1621 à¾×Íè à¡çº¤‹Ò¾ÒÃÒÁÔàµÍÏ·¨Õè Òí ໚¹ »¡µÔ¨Ð㪌àÇÅÒ»ÃÐ ÁÒ³ 10 ÁÔÅÅÔÇ¹Ô Ò·Õ “0” - ÂѧÍÂÙË ÐËNjҧ¡ÒÃà¢Õ¹¢ŒÍÁÙÅ “1” - ¡ÒÃà¢Õ¹¢ŒÍÁÙÅàÊÃç¨ÊÁºÙó ºÔµ 3 : äÁ‹ãªŒ§Ò¹ ¡íÒ˹´ãˌ໚¹ “1” ºÔµ 2 : äÁ‹ãªŒ§Ò¹ ¡íÒ˹´ãˌ໚¹ “0” POL (Output Polarity Bit - ºÔµ 1) : ºÔµàÅ×͡ʶҹÐàÍÒµ¾µØ ¢Í§¢Ò TOUT àÁ×Íè ·íҧҹ㹠âËÁ´à·ÍÏâÁʵѵ àÁ×Íè àÅ×Í¡áŌǢŒÍÁÙŢͧºÔµ¹Õ¨é дíÒçÍÂÙä‹ »µÅÍ´áÁŒ»Å´ä¿àÅÕÂé §¡çµÒÁ ËÃ×ÍàÃÕ¡ Ç‹Ò ¹Í¹âÇÅÒä·Å (non-volatile) “0” - áÍ¡µÕ¿´ŒÇÂÅͨԡ “0” “1” - áÍ¡µÕ¿´ŒÇÂÅͨԡ “1” 1SHOT (One Shot Mode - ºÔµ 0) : ºÔµàÅ×Í¡ÇÔ¸¡Õ ÒÃÇÑ´áÅÐá»Å§¤‹ÒÍسËÀÙÁ¢Ô ͧ DS1621 àÁ×Íè àÅ×Í¡áŌǢŒÍÁÙŢͧºÔµ¹Õ¨é дíÒçÍÂÙä‹ »µÅÍ´áÁŒ»Å´ä¿àÅÕÂé §¡çµÒÁ ËÃ×ÍàÃÕÂ¡Ç‹Ò ¹Í¹âÇÅÒä·Å (non-volatile) “0” - ¡íÒ˹´ãˌ DS1621 ·íÒ¡ÒÃÇÑ´áÅÐá»Å§¤‹ÒÍ‹ҧµ‹Íà¹×Íè § “1” - ¡íÒ˹´ãˌ DS1621 àÃÔÁè ·íÒ¡ÒÃá»Å§¤‹ÒÍسËÀÙÁàÔ Á×Íè ä´ŒÃºÑ ÊÑ­­Ò³àÃÔÁè µŒ¹ â´Â»¡µÔáŌǤÇáíÒ˹´ãˌ DS1621 ·íÒ¡ÒÃÇÑ´áÅÐá»Å§¤‹ÒÍسËÀÙÁÍÔ Â‹Ò§µ‹Íà¹×Íè § ànj¹áµ‹ ÁÕ¤ÇÒÁµŒÍ§¡ÒäǺ¤ØÁ¡ÒÃ㪌¾Åѧ§Ò¹¢Í§ DS1621 à¾ÃÒÐËÒ¡ DS1621 äÁ‹ä´ŒÇ´Ñ ÍسËÀÙÁáÔ ÅÐ á»Å§¤‹Ò¨Ð㪌¾Åѧ§Ò¹ä¿¿‡ÒŴŧ

¤íÒÊѧè 㹡ÒÃ㪌§Ò¹ DS1621 ¡ÒÃ͋ҹáÅÐà¢Õ¹¢ŒÍÁÙšѺ DS1621 ÁÕû٠Ẻµ‹Ò§æ ¡Ñ¹ä»µÒÁÅѡɳТŒÍÁÙÅáÅФíÒÊÑ§è ´Ñ§ áÊ´§ã¹ÃÙ»·Õè 11-5 㹡ÒÃà¢Õ¹¢ŒÍÁÙÅËÃ×ͤíÒÊѧè ä»Âѧ DS1621 ÍØ»¡Ã³ÁÒÊàµÍÏ («Ö§è ã¹·Õ¹è ¤Õé Í× àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 135


à¢Õ¹¤íÒÊÑè§ã¹¡Å؋Á·ÕèäÁ‹µŒÍ§¡ÒâŒÍÁÙŠઋ¹ ¤íÒÊÑè§àÃÔèÁµŒ¹/ËÂØ´¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ SCL SDA

S 1 0 0 1 ) ) ) W A +% +$ +# +" +! + + + A

áÍ´à´ÃÊ START

P

¤íÒÊÑè§ DS1621 ACK

STOP

DS1621 ACK

à¢Õ¹¤íÒÊÑè§ã¹¡Å؋Á·Õ赌ͧ¡ÒâŒÍÁÙÅ 1 亵 ઋ¹ ¤íÒÊÑè§à¢ŒÒ¶Ö§ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð SCL SDA

S 1 0 0 1 ) ) ) W A +% +$ +# +" +! + + + A ,% ,$ ,# ," ,! , , , A

áÍ´à´ÃÊ START

¤íÒÊÑè§ DS1621 ACK

P

¢ŒÍÁÙÅ DS1621 ACK

DS1621 ACK

STOP

à¢Õ¹¤íÒÊÑè§ã¹¡Å؋Á·Õ赌ͧ¡ÒâŒÍÁÙÅ 2 亵 ઋ¹ ¤íÒÊÑè§à¢ŒÒ¶Ö§¤‹Ò TH áÅÐ TL SCL SDA

S 1 0 0 1 ) ) ) W A +% +$ +# +" +! + + + A ,% ,$ ,# ," ,! , , , A ,% ,$ ,# ," ,! , , , A

áÍ´à´ÃÊ START

¤íÒÊÑè§ DS1621 ACK

¢ŒÍÁÙÅ亵ÊÙ§ DS1621 ACK

DS1621 ACK

P

¢ŒÍÁÙÅ亵µíèÒ DS1621 ACK

STOP

͋ҹ¢ŒÍÁÙŨҡÃÕ¨ÔÊàµÍÏ·ÕèÁÕ¢¹Ò´ 1 亵 䴌ᡋ ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð, µÑǹѺ áÅеÑǹѺÊâÅ» SCL SDA

S 1 0 0 1 ) ) ) W A +% +$ +# +" +! + + + A

áÍ´à´ÃÊ START

R

1 0

¤íÒÊÑè§ DS1621 ACK

0 1 ) ) ) 4@ A ,% ,$ ,# ," ,! , , , N

áÍ´à´ÃÊ DS1621 ACK Repeat START

P

¢ŒÍÁÙÅ STOP MASTER NACK

DS1621 ACK

͋ҹ¢ŒÍÁÙŨҡÃÕ¨ÔÊàµÍÏ·ÕèÁÕ¢¹Ò´ 2 亵 䴌ᡋ ¤‹Ò¢Í§ TH, TL áÅФ‹ÒÍسËÀÙÁÔ SCL SDA

S 1 0 0 1 ) ) ) W A +% +$ +# +" +! + + + A

áÍ´à´ÃÊ START

R

1 0

¤íÒÊÑè§ DS1621 ACK

0 1 ) ) ) 4@ A ,% ,$ ,# ," ,! , , , A ,% ,$ ,# ," ,! , , , N

áÍ´à´ÃÊ DS1621 ACK Repeat START

¢ŒÍÁÙÅ DS1621 ACK

P

¢ŒÍÁÙÅ MASTER ACK

STOP MASTER NACK

ÃÙ»·Õè 11-5 ä´ÍÐá¡ÃÁàÇÅÒáÊ´§ÃٻẺ¡ÒõԴµ‹Íº¹ÃкººÑÊ I2C ¢Í§ DS1621 ¤ÍÁ¾ÔÇàµÍÏ) ¨Ð¡íÒ˹´¤‹ÒáÍ´à´Ãʢͧ DS1621 µÑÇ·Õµè ͌ §¡ÒõԴµ‹Í áŌǵÒÁ´ŒÇ¡ÒÃ૵ºÔµ R/W ¨Ò¡¹Ñ¹é ¨ÐÃÍ¡ÒõͺÃѺ¨Ò¡ÍØ»¡Ã³ÊàÅ¿ «Ö§è ¡ç¤Í× DS1621 àÁ×Íè ä´ŒÃºÑ ¡ÒõͺÃѺáÅŒÇ ÍØ»¡Ã³ ÁÒÊàµÍϨШѴàµÃÕÂÁ¤íÒÊѧè à¾×Íè 㪌§Ò¹ DS1621 µ‹Íä» â´Â·Ø¡¤ÃÑ§é ·ÕÁè ¡Õ ÒÃà¢Õ¹¤íÒÊѧè ä»Âѧ DS1621 µŒÍ§à¤ÅÕÂϺµÔ R/W ´ŒÇÂàÊÁÍ àÁ×Íè DS1621 ä´ŒÃºÑ ¤íÒÊÑ§è ¨Ò¡ÍØ»¡Ã³ÁÒÊàµÍÏ¡¨ç дíÒà¹Ô¹¡ÒõÒÁ ·Õ¡è Òí ˹´ÁÒ¨Ò¡ÍØ»¡Ã³ÁÒÊàµÍÏ áÅзء¤ÃÑ§é ¨ÐµŒÍ§Ê‹§ÊÑ­­Ò³ÃѺÃÙˌ Ã×͵ͺÃѺ¡ÅѺä»ÂѧÍØ»¡Ã³ ÁÒÊàµÍÏ ÊíÒËÃѺ¤íÒÊÑ§è ·Ñ§é ËÁ´¢Í§ DS1621 ÁÕ´§Ñ ¹Õé

¤íÒÊѧè ͋ҹÍسËÀÙÁÔ (Read Temperature : ¢ŒÍÁÙŤíÒÊѧè ໚¹ AAH) ໚¹¤íÒÊѧè ͋ҹ¤‹ÒÍسËÀÙÁÅÔ Ò‹ ÊØ´·Õè DS1621 ·íÒ¡ÒÃá»Å§àÊÃç¨ÊÁºÙó â´Â DS1621 ¨Ðʋ§ ¢ŒÍÁÙÅ¢¹Ò´ 2 亵·áÕè ·¹¤‹ÒÍسËÀÙÁ¡Ô ÅѺÁÒ (¨ÃÔ§æ áŌÇ㪌à¾Õ§ 9 ºÔµ) àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 136


¤íÒÊѧè ࢌҶ֧¤‹Ò TH (Access TH : ¢ŒÍÁÙŤíÒÊѧè ໚¹ A1H)

໚¹¤íÒÊÑè§ÊíÒËÃѺࢌҶ֧ËÃ×͵Դµ‹Í¡Ñº¤‹Ò¢Í§¨Ø´·ÃÔ¡ÍسËÀÙÁÔÊÙ§ËÃ×Í TH ¶ŒÒËÒ¡ºÔµ R/W ¶Ù¡¡íÒ˹´ãˌ໚¹ “0” ໚¹¡ÒÃÃкØÇҋ µŒÍ§¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 à¾×Íè ¡íÒ˹´¤‹ÒËÃ×ÍµÑ§é ¤‹Ò TH ãËÁ‹ â´Â¢ŒÍÁÙÅ·Õàè ¢Õ¹¹Ñ¹é ÁÕ¢¹Ò´ 2 亵 ᵋ¶ÒŒ ËÒ¡ºÔµ R/W ໚¹ “1” ¨Ð໚¹¡ÒÃࢌҶ֧à¾×Íè ͋ҹ¤‹Ò TH ã¹¢³Ð¹Ñ¹é ¢Í§ DS1621 á·¹

¤íÒÊѧè ࢌҶ֧¤‹Ò TL (Access TL : ¢ŒÍÁÙŤíÒÊѧè ໚¹ A2H)

໚¹¤íÒÊÑè§ÊíÒËÃѺࢌҶ֧ËÃ×͵Դµ‹Í¡Ñº¤‹Ò¢Í§¨Ø´·ÃÔ¡ÍسËÀÙÁÔµèíÒËÃ×Í TL ¶ŒÒËÒ¡ºÔµ R/W ¶Ù¡¡íÒ˹´ãˌ໚¹ “0” ໚¹¡ÒÃÃкØÇҋ µŒÍ§¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 à¾×Íè ¡íÒ˹´¤‹ÒËÃ×ÍµÑ§é ¤‹Ò TL ãËÁ‹ â´Â¢ŒÍÁÙÅ·Õàè ¢Õ¹¹Ñ¹é ÁÕ¢¹Ò´ 2 亵 ᵋ¶ÒŒ ËÒ¡ºÔµ R/W ໚¹ “1” ¨Ð໚¹¡ÒÃࢌҶ֧à¾×Íè ͋ҹ¤‹Ò TL ã¹¢³Ð¹Ñ¹é ¢Í§ DS1621 á·¹

¤íÒÊÑè§à¢ŒÒ¶Ö§ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð (Access Config : ¢ŒÍÁÙŤíÒÊѧè ໚¹ ACH)

໚¹¤íÒÊѧè ÊíÒËÃѺࢌҶ֧ËÃ×͵Դµ‹Í¡ÑºÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð (Config) ¶ŒÒËÒ¡ºÔµ R/W ¶Ù¡¡íÒ˹´ãˌ໚¹ “0” ໚¹¡ÒÃÃкØÇҋ µŒÍ§¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»ÂѧÃÕ¨ÊÔ àµÍÏà¾×Íè ¡íÒ˹´ ÅѡɳСÒ÷íÒ§Ò¹¢Í§ DS1621 â´Â¢ŒÍÁÙÅ·Õàè ¢Õ¹¹Ñ¹é ÁÕ¢¹Ò´ 1 亵 ᵋ¶ÒŒ ËÒ¡ºÔµ R/W ໚¹ “1” ¨Ð໚¹¡ÒÃࢌҶ֧à¾×Íè ͋ҹ¤‹Ò¢Í§ÃÕ¨ÊÔ àµÍÏà¾×Íè µÃǨÊͺʶҹСÒ÷íÒ§Ò¹¢Í§ DS1621

¤íÒÊѧè ͋ҹµÑǹѺ (Read Counter : ¢ŒÍÁÙŤíÒÊѧè ໚¹ A8H)

໚¹¤íÒÊѧè ÊíÒËÃѺ͋ҹ¤‹ÒµÑǹѺ·Õãè ªŒã¹¡ÒÃá»Å§¤‹ÒÍسËÀÙÁ¢Ô ͧ DS1621 㹡ÒÃ㪌¤Òí ÊÑ§è µŒÍ§ ¡íÒ˹´ãˌºµÔ R/W ໚¹ “1” ෋ҹѹé

¤íÒÊѧè ͋ҹ¤‹ÒµÑǹѺÅÐàÍÕ´ (Read Slope : ¢ŒÍÁÙŤíÒÊѧè ໚¹ A9H)

໚¹¤íÒÊѧè ÊíÒËÃѺ͋ҹ¤‹ÒµÑǹѺÅÐàÍÕ´ 㹡óշµÕè ͌ §¡ÒÃãˌáÊ´§ÃÒÂÅÐàÍÕ´¤‹Ò¢Í§ÍسËÀÙÁÔ «Ö§è à¡çºÍÂÙ㋠¹µÑǹѺÅÐàÍÕ´ (slope counter) 㹡ÒÃ㪌§Ò¹¤íÒÊÑ§è ¹Õµé ͌ §¡íÒ˹´ãˌºµÔ R/W ໚¹ “1”

¤íÒÊѧè àÃÔÁè µŒ¹á»Å§¤‹ÒÍسËÀÙÁÔ (Start Convert T : ¢ŒÍÁÙŤíÒÊѧè ໚¹ EEH) ໚¹¤íÒÊÑ§è ·Õ¡è Òí ˹´ãˌ DS1621 àÃÔÁè µŒ¹¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ

¤íÒÊѧè ËÂØ´¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ (Stop Convert T : ¢ŒÍÁÙŤíÒÊѧè ໚¹ 22H)

໚¹¤íÒÊÑ§è ·Õ¡è Òí ˹´ãˌ DS1621 ËÂØ´¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ ÁÑ¡¨Ð㪌àÁ×Íè µŒÍ§¡ÒÃãˌ DS1621 ËÂØ´·íÒ¡ÒÃÇÑ´áÅÐá»Å§¤‹ÒÍسËÀÙÁÍÔ Â‹Ò§µ‹Íà¹×Íè § ËÅѧ¨Ò¡·Õè DS1621 ¡ÃзíÒ¤íÒÊÑ§è ¹Õé ¤‹ÒÍسËÀÙÁÔ ·Õáè »Å§ä´ŒÅҋ ÊØ´¨ÐÂѧ¤§ÍÂً ¨¹¡Ç‹Ò¨ÐÁÕ¡ÒáíÒ˹´ãˌ DS1621 ¡ÅѺÁÒàÃÔÁè µŒ¹á»Å§¤‹ÒÍسËÀÙÁãÔ ËÁ‹ ã¹µÒÃÒ§·Õè 11-2 ໚¹µÒÃÒ§ÊÃØ»¤íÒÊѧè 㪌§Ò¹ DS1621 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 137


¤íÒÊÑè§

¢ŒÍÁÙŤíÒÊÑè§

¤íÒÊѧè à¡ÕÂè ǡѺ¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ Í‹Ò¹¤‹ÒÍسËÀÙÁÔ AAH ͋ҹ¤‹ÒµÑǹѺ A8H ͋ҹ¤‹ÒµÑǹѺÊâÅ» A9H àÃÔÁè µŒ¹á»Å§¤‹ÒÍسËÀÙÁÔ EEH ËÂØ´á»Å§¤‹ÒÍسËÀÙÁÔ 22H ¤íÒÊѧè ã¹âËÁ´à·ÍÏâÁʵѵ ࢌҶ֧ TH ࢌҶ֧ TL ࢌҶ֧ÃÕ¨ÊÔ àµÍÏ Config.

¡Ò÷íÒ§Ò¹ËÅѧʋ§¤íÒÊѧè ËÁÒÂàËµØ Í‹Ò¹¢ŒÍÁÙÅ 2 亵 ͋ҹ¢ŒÍÁÙÅ 1 亵 ͋ҹ¢ŒÍÁÙÅ 1 亵 ËÂØ´áÅÐàµÃÕÂÁ¾ÃŒÍÁàÃÔÁè µŒ¹ ËÂØ´áÅÐàµÃÕÂÁ¾ÃŒÍÁàÃÔÁè µŒ¹

1 1

à¢Õ¹¢ŒÍÁÙÅ 1 亵 à¢Õ¹¢ŒÍÁÙÅ 1 亵 à¢Õ¹¢ŒÍÁÙÅ 1 亵

2 2 2

A1H A2H ACH

ËÁÒÂà赯 1. ã¹âËÁ´¡ÒÃá»Å§¤‹ÒÍ‹ҧµ‹Íà¹×Íè § àÁ×Íè DS1621 ¡ÃзíÒ¤íÒÊѧè ËÂØ´¡ÒÃá»Å§¤‹Ò ¨Ð໚¹¡ÒáàÅÔ¡¡Òà á»Å§¤‹ÒÍ‹ҧµ‹Íà¹×Íè §·Ñ¹·Õ ËÒ¡µŒÍ§¡ÒÃãˌ DS1621 á»Å§¤‹ÒÍÕ¡¤ÃÑ§é µŒÍ§à¢Õ¹¤íÒÊѧè àÃÔÁè µŒ¹¡ÒÃá»Å§¤‹Ò ãˌᡋ DS1621 ãËÁ‹ 2. ¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»ÂѧÃÕ¨ÊÔ àµÍÏ DS1621 µŒÍ§¡ÒÃàÇÅÒ 10 ÁÔÅÅÔÇ¹Ô Ò·Õ໚¹Í‹ҧ¹ŒÍÂ㹡ÒÃà¢Õ¹¢ŒÍÁÙÅãˌ ÊÁºÙó

µÒÃÒ§·Õè 11-2 µÒÃÒ§ÊÃØ»¤íÒÊѧè ÊíÒËÃѺ㪌§Ò¹ DS1621

¨Ñ§ËÇСÒ÷íÒ§Ò¹¢Í§ DS1621 à¾×Íè ãˌÊÒÁÒöࢌÒ㨶֧ÅíҴѺ¡Ò÷íÒ§Ò¹ÃÇÁ¶Ö§Ê¶Ò¹Ðµ‹Ò§æ ¢Í§ DS1621 ¨Ö§ä´Œ·Òí ¡ÒÃÊÃØ» ʶҹТͧºÑÊ âËÁ´¡Ò÷íÒ§Ò¹¢Í§ DS1621 áÅЪ¹Ô´¢Í§¢ŒÍÁÙÅ·Õ»è ÃÒ¡¯änj㹵ÒÃÒ§·Õè 11-3

EX-10 ºÍÏ´ÇÑ´ÍسËÀÙÁ¼Ô ҋ ¹ÃкººÑÊ I2C ã¹ÃÙ»·Õè 11-6 áÊ´§Ç§¨ÃÊÁºÙó¢Í§ EX-10 ºÍÏ´ÇÑ´ÍسËÀÙÁáÔ ÅÐà·ÍÏâÁʵѵ·Õ·è Òí §Ò¹º¹ ÃкººÑÊ I2C ËÑÇã¨ÊíҤѭ¢Í§ºÍÏ´¹Õ¤é Í× IC1001 àºÍÏ DS1621 «Ö§è ໚¹äÍ«ÕÇ´Ñ ÍسËÀÙÁ·Ô ãÕè ªŒ ¡ÒõԴµ‹Í¼‹Ò¹ÃкººÑÊ I2C â´Â¢ÒÊÑ­­Ò³ SDA áÅÐ SCL ¢Í§ IC1001 ¨Ðµ‹ÍࢌҡѺ K1001 áÅÐ K1002 «Ö§è ໚¹¨Ø´àª×Íè Áµ‹ÍÃкººÑÊ I2C ¡Ñº P-Board â´Â㪌ᨍ¡âÁ´ÙÅҋ Ï·Òí ãˌ¡ÒÃàª×Íè Áµ‹Í ÊÒÁÒö·íÒ䴌§Ò‹ ÂáÅÐÁÕ¤ÇÒÁá¢ç§áç JP1001-JP1003 㪌ÊÒí ËÃѺ¡íÒ˹´¤‹ÒáÍ´à´ÃÊ·Ò§ÎÒÏ´áÇÏ ¢Í§ DS1621 ·íÒãˌÊÒÁÒöµ‹Í¾‹Ç§ºÍÏ´ EX-10 ¹Õäé ´ŒÊ§Ù ÊØ´ÃÇÁ 8 ºÍÏ´ â´Â¡ÒáíÒ˹´Ê¶Ò¹Ð·Õè àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 138


âËÁ´¡Ò÷íÒ§Ò¹¢Í§ ÍØ»¡Ã³ÁÒÊàµÍÏ

âËÁ´¡Ò÷íÒ§Ò¹¢Í§ DS1621

ÊÀÒÇÐáÅТŒÍÁÙÅ·Õè »ÃÒ¡¯º¹ºÑÊ

TX

RX

START

TX

RX

<ADDRESS,0>

ÃÒÂÅÐàÍÕ´ ¤ÍÁ¾ÔÇàµÍÏ¡íÒ˹´ÊÀÒÇÐàÃÔèÁµŒ¹ãˌà¡Ô´¢Ö鹺¹ºÑÊ ¤ÍÁ¾ÔÇàµÍÏʋ§¤‹ÒáÍ´à´Ãʢͧ DS1621 áÅСíÒ˹´ºÔµ R/W ໚¹ "0" DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏʋ§¤íÒÊÑè§à¢ŒÒ¶Ö§ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹ DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ

RX

TX

ACK

TX

RX

ACH

RX

TX

ACK

TX

RX

02H

¤ÍÁ¾ÔÇàµÍÏʋ§¢ŒÍÁÙÅà¾×èÍ¡íÒ˹´ãˌ DS1621 á»Å§¤‹ÒÍ‹ҧµ‹Í๠×èͧ áÅÐãˌàÍÒµ¾Øµà»š¹ÅͨԡÊÙ§àÁ×èÍÍسËÀÙÁÔ·ÕèÇÑ´ÊÙ§¶Ö§¨Ø´ TH DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ

RX

TX

ACK

TX

RX

START

TX

RX

<address,0>

RX

TX

ACK

TX

RX

A1H

RX

TX

ACK

TX

RX

28H

RX

TX

ACK

TX

RX

00H

RX

TX

ACK

TX

RX

START

TX

RX

<address,0>

RX

TX

ACK

TX

RX

A2H

RX

TX

ACK

TX

RX

0AH

RX

TX

ACK

TX

RX

00H

RX

TX

ACK

TX

RX

START

TX

RX

<address,0>

RX

TX

ACK

TX

RX

EEH

RX

TX

ACK

TX

RX

STOP

¤ÍÁ¾ÔÇàµÍÏ¡íÒ˹´ÊÀÒÇÐàÃÔèÁµŒ¹ãˌà¡Ô´¢Ö鹺¹ºÑÊÍÕ¡¤ÃÑé§ ¤ÍÁ¾ÔÇàµÍÏʋ§¤‹ÒáÍ´à´Ãʢͧ DS1621 áÅСíÒ˹´ºÔµ R/W ໚¹ "0" DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏʋ§¤íÒÊÑè§à¢ŒÒ¶Ö§ TH DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏà¢Õ¹¢ŒÍÁÙÅ亵ÊÙ§¢Í§¤‹Ò TH (¡íÒ˹´ãˌ෋ҡѺ +40 ðC) DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏà¢Õ¹¢ŒÍÁÙÅ亵µíèҢͧ¤‹Ò TH DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏ¡íÒ˹´ÊÀÒÇÐàÃÔèÁµŒ¹ãˌà¡Ô´¢Ö鹺¹ºÑÊÍÕ¡¤ÃÑé§ ¤ÍÁ¾ÔÇàµÍÏʋ§¤‹ÒáÍ´à´Ãʢͧ DS1621 áÅСíÒ˹´ºÔµ R/W ໚¹ "0" DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏʋ§¤íÒÊÑè§à¢ŒÒ¶Ö§ TL DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏà¢Õ¹¢ŒÍÁÙÅ亵ÊÙ§¢Í§¤‹Ò TL (¡íÒ˹´ãˌ෋ҡѺ +10 ðC) DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏà¢Õ¹¢ŒÍÁÙÅ亵µíèҢͧ¤‹Ò TL DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏ¡íÒ˹´ÊÀÒÇÐàÃÔèÁµŒ¹ãˌà¡Ô´¢Ö鹺¹ºÑÊÍÕ¡¤ÃÑé§ ¤ÍÁ¾ÔÇàµÍÏʋ§¤‹ÒáÍ´à´Ãʢͧ DS1621 áÅСíÒ˹´ºÔµ R/W ໚¹ "0" DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏʋ§¤íÒÊÑè§àÃÔèÁµŒ¹á»Å§¤‹ÒÍسËÀÙÁÔ DS1621 ʋ§ÊÑ­­Ò³ÃѺÃٌµÍº¡ÅѺ ¤ÍÁ¾ÔÇàµÍÏ¡íÒ˹´ÊÀÒÇÐËÂØ´ãˌà¡Ô´¢Ö鹺¹ºÑÊ à¾×èÍËÂØ´¡Ò÷íÒ§Ò¹

ËÁÒÂà赯 6:ËÁÒ¶֧ ·íÒ˹ŒÒ·Õè໚¹µÑÇʋ§, 4: ËÁÒ¶֧ ·íÒ˹ŒÒ·Õè໚¹µÑÇÃѺ, 0 ·ÕèÍÂًËÅѧ¢ŒÍÁÙÅ㪌áÊ´§Ç‹Ò ¢ŒÍÁÙŹÑé¹æ ໚¹¢ŒÍÁÙÅàÅ¢°Ò¹ÊԺˡ

µÒÃÒ§·Õè 11-3 áÊ´§µÑÇÍ‹ҧÅíҴѺ¡Ò÷íÒ§Ò¹ âËÁ´¡Ò÷íÒ§Ò¹¢Í§ÍØ»¡Ã³ÁÒÊàµÍÏ («Ö§è ã¹·Õ¹è ¤Õé Í× ¤ÍÁ¾ÔÇàµÍÏ) áÅÐ DS1621 µÅÍ´¨¹Ê¶Ò¹Ð¢Í§ºÑÊã¹¢³ÐµÔ´µ‹Í ¢Ò A2-A0 ¢Í§ DS1621 ãˌᵡµ‹Ò§¡Ñ¹´ŒÇ¨ÑÁê à»ÍÏ JP1001-JP1003 ÊíÒËÃѺàÍÒµ¾µØ ¢Í§ DS1621 «Ö§è 㪌áÊ´§¼Å¡Ò÷íÒ§Ò¹¢Í§Ç§¨Ãà·ÍÏâÁʵѵ¹Ñ¹é ¨Ðµ‹ÍࢌҡѺÍØ»¡Ã³ 2 Ẻ¤×Í ÅíÒ⾧ ໂÂâ«ÊíÒËÃѺáÊ´§¼Å´ŒÇÂàÊÕ§áÅÐǧ¨Ã¢ÑºÃÕàŏà¾×Íè ãˌ·Òí §Ò¹àËÁ×͹ÊÇÔµªµ´Ñ µ‹Í ¡ÒÃàÅ×Í¡ÍØ»¡Ã³ ·Õ¢è Ò TOUT ¢Í§ DS1621 ¹Ñ¹é µŒÍ§¡ÃзíÒ¼‹Ò¹ JP1004 áÅÐ JP1005 â´ÂÊÒÁÒöàÅ×Í¡ãˌáÊ´§ ¼Å´ŒÇÂàÊÕ§¾ÃŒÍÁ¡ÑºÃÕàŏ·íÒ§Ò¹¡ç䴌 ¹Í¡¨Ò¡¹Ñé¹ÂѧÁÕ¡ÒÃáÊ´§¼Å¡Ò÷íÒ§Ò¹¢Í§ DS1621 ã¹ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 139


+5V BUS

+5V BUS K1001

R1001 15k

JP1001-JP1003 ADDRESS A1 A0

R1003 4.7

R1010 470 1/2W

A2

I C BUS (RJ11-4)

5

SCL

A2 2 +5V BUS

1

SCL SDA

6 A1 IC1001 DS1621

A0 V,, Tout

8 3

SDA

Temperature Sensor

JP1004 SOUND

R1006 1k

JP1005 RELAY

R1004 10k Q1001 BC547

GND K1002 I C BUS (RJ11-4)

K1003 EXTERNAL 12V. INPUT

LED1001 ACTIVE ZD1001 5V1

7

+12V.

C1001 0.1/50V

"0"

SDA

D1002 1N4001

GND

"1"

R1002 15k

D1001 1N4001

SP1001 PIEZO SPEAKER

4

SCL

NC COM NO

Q1003 BC557

R1008 10k R1007 470k

R1005 10k

R1009 12

RY1001 RELAY 12V

K1004 RELAY CONTACT

Contact rating : 220V 5A

C1002 0.01/50V Q1004 BC547

Q1002 BC337

EX-10 ºÍÏ´ÇÑ´ÍسËÀÙÁáÔ ÅÐà·ÍÏâÁʵѵ¼‹Ò¹ÃкººÑÊ I2C 㪌äÍ«Õ DS1621 ·ÕÇè ´Ñ ÍسËÀÙÁäÔ ´Œµ§Ñé ᵋ -55ðC ¶Ö§ +125ðC ÊíÒËÃѺµÑǺÍÏ´ÊÒÁÒö㪌§Ò¹ã¹ª‹Ç§ 0-50 ðC l ʋ§¢ŒÍÁÙÅÍسËÀÙÁ¼ Ô Ò‹ ¹ÃкººÑÊ I2C l µÑ§é ¤‹Ò¨Ø´·ÃÔ¡ÍسËÀÙÁÊ Ô §Ù áÅеèÒí àÁ×Íè ·íÒ§Ò¹ã¹âËÁ´à·ÍÏâÁ ʵѵ䴌 l ÁÕàÍÒµ¾ØµáÊ´§¼Å¡Ò÷íÒ§Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ ¾ÃŒÍÁ ǧ¨Ã¢Ñº LED, ÅíÒ⾧ໂÂâ« áÅÐÃÕàŏ â´ÂàÅ×Í¡´ŒÇ¨ÑÁê à»ÍÏ l ÊÒÁÒöµ‹Í¾‹Ç§ä´ŒÃÇÁ 8 ºÍÏ´ l àª×Í è Áµ‹Í¡Ñº P-Board ¼‹Ò¹·Ò§¤Í¹à¹ç¡àµÍÏ I2C BUS l

ÃÙ»·Õè 11-6 ǧ¨Ã¢Í§ EX-10 ºÍÏ´ÇÑ´ÍسËÀÙÁáÔ ÅÐà·ÍÏâÁʵѵ¼‹Ò¹ÃкººÑÊ I2C âËÁ´à·ÍÏâÁʵѵÍÕ¡ÍÂ‹Ò§Ë¹Ö§è ¤×Í áÊ´§¼Å´ŒÇÂáʧ ¹Ñ¹è ¤×Í LED1001 ¨ÐµÔ´ÊNjҧàÁ×Íè ¤‹ÒÍسËÀÙÁÔ ·ÕÇè ´Ñ ÊÙ§¶Ö§¨Ø´ TH ÃÕàŏ RY1001 ·Õãè ªŒä´Œ¨´Ñ àµÃÕÂÁà·ÍÏÁ¹Ô ÍźÅçÍ¡ÊíÒËÃѺµ‹ÍÊÒÂà¾×Íè àª×Íè Áµ‹Í¡ÑºÍØ»¡Ã³ËÃ×Í ÊÑ­­Ò³ÀÒ¹͡änjàÃÕºÌÍ â´ÂÁÕ¾¡Ô ´Ñ ¢Í§Ë¹ŒÒÊÑÁ¼ÑÊÃÕàŏʧ٠Êش෋ҡѺ 220VAC 5A áÅÐËÒ¡ µŒÍ§¡ÒÃãˌÃàÕ Å·Òí §Ò¹ ¨ÐµŒÍ§¨‹ÒÂä¿àÅÕÂé § +12V ãˌᡋºÍÏ´ EX-10 á·¹¡ÒÃ㪌ä¿àÅÕÂé §¨Ò¡ I2C BUS ·ÕÁè Ò¨Ò¡¤Í¹à¹ç¡àµÍÏ K1001 ¹Ñ¹è ËÁÒ¤ÇÒÁÇ‹Ò ºÍÏ´ EX-10 ÊÒÁÒö㪌ä¿àÅÕÂé §ä´Œ¨Ò¡ 2 áËŋ§¤×Í ¨Ò¡¤Í¹à¹ç¡àµÍÏ K1001 «Ö§è ÁÒ¨Ò¡ I2C BUS ¢Í§ P-Board áÅШҡáËŋ§¨‹ÒÂ俵çÀÒ¹͡·ÕÁè ¤Õ Ò‹ äÁ‹à¡Ô¹ +12V àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 140


à¹×Íè §¨Ò¡º¹ºÍÏ´ÁÕäͫդǺ¤ØÁáç´Ñ¹ä¿àÅÕÂé §¤§·Õ·è Õè +5V àºÍÏ 78L05 ÍÂÙ´‹ nj  ¨Ö§ÊÒÁÒöÊÌҧ ä¿àÅÕÂé § +5V à¾×Íè ¨‹ÒÂãˌᡋ DS1621 áÅÐÍØ»¡Ã³·§Ñé ËÁ´ä´Œ ËÒ¡äÁ‹ãªŒä¿àÅÕÂé § +12V ÀÒ¹͡ ¡ç¨ÐäÁ‹ÊÒÁÒö㪌§Ò¹ÃÕàŏ䴌 áÅШеŒÍ§»Å´¨ÑÁê à»ÍÏ JP1005 ÍÍ¡´ŒÇÂàÊÁÍ Ëҡ㪌ä¿àÅÕÂé §¨Ò¡ I2C BUS ËÃ×ÍàÁ×Íè äÁ‹µÍŒ §¡ÒÃ㪌§Ò¹ÃÕàŏ ·Ñ§é ¹Õàé ¾×Íè Å´»ÃÔÁÒ³¡ÃÐáÊä¿¿‡Ò·Õãè ªŒ¢Í§ºÍÏ´ EX-10 Í‹ҧäáçµÒÁ ÍØ»¡Ã³àÍÒµ¾Øµ·Ñé§ËÁ´äÁ‹Ç‹Ò¨Ð໚¹áʧ¨Ò¡ LED àÊÕ§¨Ò¡ÅíÒ⾧ໂÂâ« ËÃ×ÍÃÕàŏ¨ÐÊÒÁÒöãˌ¼Å¡Ò÷íÒ§Ò¹·Õ¶è ¡Ù µŒÍ§¡çµÍ‹ àÁ×Íè ¡íÒ˹´ãˌ DS1621 ʋ§ÅͨԡÊÙ§ËÃ×ÍÅͨԡ “1” ÍÍ¡·Ò§¢Ò TOUT àÁ×Íè ÍسËÀÙÁÊÔ §Ù ¶Ö§¨Ø´ TH à·‹Ò¹Ñ¹é ¹Ñ¹è ¤×͵ŒÍ§à«µºÔµ POL ã¹ÃÕ¨ÊÔ àµÍÏ ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð¢Í§ DS1621 ãˌ໚¹ “1”

á¹Ç¡ÒûÃÐÂØ¡µãªŒ§Ò¹ ´ŒÇ¡ÒÃ㪌ºÍÏ´ EX-10 ¨Ðª‹ÇÂãˌ¤ÍÁ¾ÔÇàµÍÏÊÒÁÒö·íÒ§Ò¹ËÃ×Í»ÃÐÁÇżšѺ¢ŒÍÁÙÅ·Õè ໚¹¤‹ÒÍسËÀÙÁäÔ ´Œ§Ò‹ Â¢Ö¹é ·Ñ§é ÂѧÊдǡà¹×Íè §¨Ò¡äÁ‹µÍŒ §ãªŒÇ§¨ÃËÃ×ÍÍØ»¡Ã³µÃǨ¨Ñº·ÕÁè ¡Õ Ò÷íÒ§Ò¹«Ñº «ŒÍ¹ ËÒ¡ÁÕ¤ÇÒÁÊÒÁÒö´ŒÒ¹°Ò¹¢ŒÍÁÙÅ ¡ç¨ÐÊÒÁÒö»ÃÐÂØ¡µãªŒ P-Board ËÇÁ¡Ñº EX-10 㹡Òà ÊÌҧÃкººÑ¹·Ö¡¢ŒÍÁÙÅÍسËÀÙÁËÔ Ã×Í temperature logger Í‹ҧ§‹ÒÂæ 䴌 áÅжŒÒËÒ¡ÊÒÁÒöÈÖ¡ÉÒ ¡Ò÷íÒ§Ò¹¢Í§ DS1621 ä´ŒÅ¡Ö «Ö§é ÁÒ¡¢Ö¹é ¡ç¨ÐÊÒÁÒö¡íÒ˹´ãˌ DS1621 áÊ´§¤‹ÒÍسËÀÙÁ·Ô ÁÕè Õ ¤ÇÒÁÅÐàÍÕ´ÁÒ¡¢Öé¹ä´Œ áÅдŒÇ¡ÒÃà¾ÔÁè àµÔÁǧ¨Ã¢ÑºÍØ»¡Ã³àÍÒµ¾µØ ãˌᡋ DS1621 ·íÒãˌÊÒÁÒö»ÃÐÂØ¡µãªŒ§Ò¹ EX-10 ãˌ໚¹à·ÍÏâÁʵѵ·Õ·è Òí §Ò¹â´ÂÅíҾѧẺâ»Ãá¡ÃÁ䴌 â´ÂàÁ×Íè µŒÍ§¡ÒÃµÑ§é ¤‹ÒÍسËÀÙÁãÔ ËŒ·Òí ¡ÒÃàª×Íè Áµ‹Í EX-10 ࢌҡѺ P-Board áŌÇà¢Õ¹â»Ãá¡ÃÁà¾×Íè µÑ§é ¤‹Ò TH áÅÐ TL ¨Ò¡¹Ñ¹é »Å´ EX-10 ÍÍ¡¹íÒä»ãªŒ§Ò¹ä´Œ·¹Ñ ·Õ àÁ×Íè µŒÍ§¡ÒÃà»ÅÕÂè ¹¤‹Ò TH áÅÐ TL ¨Ö§¤‹Í¹íÒÁÒàª×Íè Áµ‹Í¡Ñº¤ÍÁ¾ÔÇàµÍÏ ãËÁ‹ ÍÕ¡á¹Ç·Ò§»ÃÐÂØ¡µãªŒ§Ò¹¤×Í ÊÌҧ໚¹à¤Ã×Í¢‹ÒÂÇÑ´¤‹ÒÍسËÀÙÁÔ à¹×Íè §¨Ò¡ DS1621 ÊÒÁÒö µ‹Í¾‹Ç§¡Ñ¹ä´ŒÃÇÁ 8 µÑÇ ¨Ö§·íÒãˌÊÒÁÒöµ‹Í¾‹Ç§ºÍÏ´ EX-10 䴌ÃÇÁ 8 ºÍÏ´´ŒÇÂઋ¹¡Ñ¹ ËÒ¡¹íÒ ºÍÏ´ EX-10 仵ԴµÑ§é ã¹¾×¹é ·Õµè ҋ §æ áŌǵ‹ÍÊÒÂàª×Íè Á⧡ѹµÒÁ¢ŒÍ¡íÒ˹´¢Í§ºÑÊ I2C áŌÇàª×Íè Á µ‹Í¡Ñº¤ÍÁ¾ÔÇàµÍϼҋ ¹ P-Board ¡ç¨Ð·íÒãˌÊÒÁÒöÊÌҧà¤Ã×Í¢‹Ò¡ÒõÃǨÊͺáÅÐÇÑ´¤‹ÒÍسËÀÙÁÔ ä´Œ ·Ñ§é ÂѧÊÒÁÒö¹íÒ¢ŒÍÁÙÅä»»ÃÐÁÇżŵ‹Í䴌Í‹ҧÍÕ¡´ŒÇÂ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 141


¡Ò÷´Åͧ·Õè 15 ¾Íϵ¢¹Ò¹¡Ñº¡ÒÃÇÑ´¤‹ÒÍسËÀÙÁ¼Ô ҋ ¹ÃкººÑÊ I2C à¤Ã×Íè §Á×ÍáÅÐÍØ»¡Ã³ 1. ºÍÏ´àª×Íè Áµ‹Í¾Íϵ¢¹Ò¹ P-Board 1 Ἃ¹ 1 Ἃ¹ 2. EX-10 ºÍÏ´ÇÑ´ÍسËÀÙÁ¼Ô ҋ ¹ÃкººÑÊ I2C 3. ¤ÍÁ¾ÔÇàµÍÏ·µÕè ´Ô µÑ§é Ãкº»¯ÔºµÑ ¡Ô ÒÃÇÔ¹â´ÇʏáÅÐ Visual BASIC Í‹ҧ¹ŒÍÂàÇÍϪ¹Ñ 5.0 1 àʌ¹ 4. ÊÒÂàª×Íè Áµ‹Í I2C

¡Ò÷´Åͧ

¡Ò÷´Åͧ͋ҹ¤‹ÒÍسËÀÙÁ¨Ô Ò¡ DS1621 ¡‹Í¹Í‹Ò¹¤‹Ò¨Ò¡ÃÕ¨ÊÔ àµÍÏ Temperature µŒÍ§Êѧè ãˌ DS1621 àÃÔÁè ¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ (Start Convert) «Ö§è ÁÕ¢¹Ñé µÍ¹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 3. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 4. ʋ§¤íÒÊѧè (Command) &HEE Êѧè ãˌàÃÔÁè ¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 6. ʋ§ÊÑ­­Ò³ STOP ¶ŒÒµŒÍ§¡ÒÃãˌ DS1621 ËÂØ´¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ (Stop Convert) ÁÕ¢¹Ñé µÍ¹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´ ¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 3. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 4. ʋ§¤íÒÊѧè (Command) &H22 Êѧè ãˌËÂØ´¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 6. ʋ§ÊÑ­­Ò³ STOP ¡ÒÃ͋ҹ¤‹Ò¨Ò¡ÃÕ¨ÊÔ àµÍÏ Temperature ÁÕ¢¹Ñé µÍ¹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 142


2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 3. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 4. ʋ§¤íÒÊѧè (Command) &HAA ÊíÒËÃѺ͋ҹ¤‹Ò¨Ò¡ÃÕ¨ÊÔ àµÍÏ Temperature ãˌ DS1621 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 6. ʋ§ÊÑ­­Ò³ START 7. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´ ¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 8. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 9. ͋ҹ¤‹Ò¨Ò¡ MSB ¢Í§ÃÕ¨ÊÔ àµÍÏ Temperature 10. ʋ§ÊÑ­­Ò³ Master ACK ãˌ DS1621 11. ͋ҹ¤‹Ò¨Ò¡ LSB ¢Í§ÃÕ¨ÊÔ àµÍÏ Temperature 12. ʋ§ÊÑ­­Ò³ Master Not ACK ãˌ DS1621 13. ʋ§ÊÑ­­Ò³ STOP ¨Ò¡¢Ñ¹é µÍ¹´Ñ§¡Å‹ÒÇÊÒÁÒöà¢Õ¹໚¹â»Ãá¡ÃÁ·´ÅͧµÒÁ¢Ñ¹é µÍ¹µ‹Í仹Õé 15.1 ÊÌҧ¿ÍÏÁáÅÐà»ÅÕÂè ¹ª×Íè ¤Í¹â·Ãŵ‹Ò§æ´Ñ§ÃÙ»·Õè P15-1

ÃÙ»·Õè P15-1 ˹ŒÒµÒ¿ÍÏÁ ¢Í§â»Ãá¡ÃÁ·´Åͧ͋ҹ¤‹Ò ÍسËÀÙÁÔ¨Ò¡äÍ«Õ DS1621 º¹ ºÍÏ´ EX-10 15.2 à»ÅÕÂè ¹¤Ø³ÊÁºÑµ¢Ô ͧ¤Í¹â·Ãŵ‹Ò§æ ´Ñ§¹Õé (pro1101.vsd) Name

cmdRdTemp

Name

txtTemp

Caption

Read Temp

Text

Name

cmdSTARTConv

Name

cmdSTOPConv

Caption

Start Convert

Caption

Stop Convert

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 143


15.3 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdSTARTConv_Click ´Ñ§¹Õé Private Sub cmdSTARTConvert_Click() I2CSTART Send8BIT &H90 Ack Send8BIT &HEE ‘Start Convert Temperature Command Ack I2CSTOP End Sub

15.4 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdSTOPConv_Click ´Ñ§¹Õé Private Sub cmdSTOPConvert_Click() I2CSTART Send8BIT &H90 Ack Send8BIT &H22 ‘Stop Convert Temperature Command Ack I2CSTOP End Sub

15.5 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdRdTemp_Click ´Ñ§¹Õé Private Sub cmdRdTemp_Click() Dim tmp As Double Dim datH As Integer Dim datL As Integer I2CSTART Send8BIT &H90 Ack Send8BIT &HAA ‘Read Temperature Command Ack I2CSTART Send8BIT &H90 + 1 Ack datH = Read8Bit ‘Read TH Register MAck datL = Read8Bit ‘Read TL Register MNAck I2CSTOP If (datL And &H80) = &H80 Then tmp = datH + 0.5 Else tmp = datH End If txtTemp.Text = tmp End Sub

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 144


15.6 ËÅѧ¨Ò¡ÊÔ¹é ÊØ´¡Ãкǹ¡ÒõԴµ‹Í¡Ñº DS1621 ¢ŒÍÁÙÅ·Õäè ´Œ¨ÐµŒÍ§¹íÒÁÒ¤íҹdzà¾ÔÁè àµÔÁâ´Â µÃǨÊͺNjҺԵ 7 ¢Í§¢ŒÍÁÙÅ亵Åҋ §¢Í§ÃÕ¨ÊÔ àµÍÏ Temperature Áդҋ ໚¹ “1” ËÃ×ÍäÁ‹ ¶ŒÒ໚¹ ãˌ¹Òí ¤‹Ò·Õäè ´Œ¨Ò¡¢ŒÍÁÙÅ亵º¹ËÃ×Í亵Ê§Ù ¢Í§ÃÕ¨ÊÔ àµÍÏ Temperature ºÇ¡´ŒÇ 0.5 ᵋ¶ÒŒ ໚¹µÃ§ ¢ŒÒÁ ¢ŒÍÁÙÅ亵Ê§Ù ¢Í§ÃÕ¨ÊÔ àµÍÏ Temperature ¡ç¤Í× ¤‹Ò¢Í§ÍسËÀÙÁ·Ô ÍÕè ҋ ¹ä´Œ 15.7 Ãѹâ»Ãá¡ÃÁáŌǷ´Åͧ¤ÅÔ¡é »ØÁ† Read Temp ¨ÐàËç¹Ç‹Ò¤‹Ò·ÕÍè ҋ ¹ä´Œà»š¹ 0 à¹×Íè §¨Ò¡Âѧ äÁ‹Á¡Õ ÒÃàÃÔÁè µŒ¹¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ ¤‹Ò·ÕÍè ҋ ¹ä´Œ¨Ò¡ÃÕ¨ÊÔ àµÍÏ Temperature ¨Ö§à»š¹ 0 15.8 ¤ÅÔ¡é »ØÁ† Start Convert à¾×Íè àÃÔÁè ¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ ¨Ò¡¹Ñ¹é ¤ÅÔ¡é ·Õ»è Á؆ Read Temp ÍÕ¡ ¤ÃÑ駨ÐÊÒÁÒö͋ҹ¤‹ÒÍسËÀÙÁÔ䴌 15.9 ·´Åͧ㪌¹ÔéÇËÃ×ÍÍØ»¡Ã³Í×è¹áµÐ·ÕèµÑÇ DS1621 ãˌÍسËÀÙÁÔà»ÅÕè¹ ¨Ò¡¹Ñ鹤ÅÔ须؆Á Read Temp ÍÕ¡¤ÃÑ§é ¶ŒÒäÁ‹Á¡Õ ÒÃà»ÅÕÂè ¹á»Å§ ÁÕÊÒà˵ؤÍ× µÑÇ DS1621 äÁ‹·Òí ¡ÒÃá»Å§¤‹ÒÍسËÀÙÁÔ Í‹ҧµ‹Íà¹×Íè § à¾ÃÒÐ·Õºè µÔ 1SHORT ã¹ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹ÐÁդҋ ໚¹ “1” «Ö§è ໚¹âËÁ´á»Å§¤‹ÒÍسËÀÙÁàÔ ¾Õ§¤Ãѧé à´ÕÂÇàÁ×Íè ä´ŒÃºÑ ÊÑ­­Ò³ Start Convert áÅÐËÂØ´¡Ò÷íÒ §Ò¹Íѵâ¹ÁÑµÔ ¶ŒÒà¡Ô´¡ÒÃà»ÅÕÂè ¹á»Å§¤‹Ò¢Ö¹é áÊ´§Ç‹Ò ·Õºè µÔ 1Shot Áդҋ ໚¹ “0” Íѹ໚¹âËÁ´ á»Å§¤‹Òµ‹Íà¹×Íè §àÁ×Íè ä´ŒÃºÑ ÊÑ­­Ò³ Start Convert ÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ·´Åͧ¹Õ´é äÙ ´Œ¨Ò¡ä¿Å LAB15A.VBP

¡Ò÷´ÅͧࢌҶ֧ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð (Config register) ¡ÒÃࢌҶ֧ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹ÐÊÒÁÒö·íÒ䴌â´Â㪌¤íÒÊÑè§ &HAC «Ö§è ÁÕ¢¹Ñé µÍ¹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 3. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 4. ʋ§¤íÒÊѧè (Command) &HAC à¾×Íè ࢌҶ֧ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 6. ʋ§ÊÑ­­Ò³ START 7. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “1” à¾×Íè ¡íÒ˹´¡ÒÃ͋ҹ¢ŒÍÁÙÅÍÍ¡¨Ò¡ DS1621 8. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 9. ÃѺ¤‹Ò¨Ò¡ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 145


10. ʋ§ÊÑ­­Ò³ Master Not ACK ãˌ DS1621 11. ʋ§ÊÑ­­Ò³ STOP ʋǹ¡ÒÃà¢Õ¹¢ŒÍÁÙÅŧÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð ·íÒ䴌â´Â㪌¤íÒÊÑè§ &HAC ÁÕ¢¹Ñé µÍ¹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´ ¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 3. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 4. ʋ§¤íÒÊѧè (Command) &HAC à¾×Íè ࢌҶ֧ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 6. ʋ§¢ŒÍÁÙÅÊíÒËÃѺÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð ä»·Õè DS1621 7. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 8. ʋ§ÊÑ­­Ò³ STOP ÊíÒËÃѺ¡ÒÃࢌҶ֧ÃÕ¨ÔÊàµÍÏ¡íÒ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹ÐÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ ·´Åͧ䴌´Ñ§µ‹Í仹Õé 15.10 ÊÌҧ»ØÁ† 2 »ØÁ† áÅÐ 1 TextBox à¾ÔÁè àµÔÁáÅÐà»ÅÕÂè ¹ª×Íè ´Ñ§ÃÙ»·Õè P15-2

ÃÙ»·Õè P15-2 ˹ŒÒµÒ¿ÍÏÁ¢Í§â»Ãá¡ÃÁ·´Åͧ͋ҹ¤‹ÒÍسËÀÙÁÔ¨Ò¡äÍ«Õ DS1621 º¹ ºÍÏ´ EX-10 ·ÕÁè ¡Õ ÒÃà¾ÔÁè ¤íÒÊѧè à¾×Íè ͋ҹáÅÐà¢Õ¹¤‹Ò¡ÑºÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹¢Í§ DS1621 àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 146


15.11 à»ÅÕÂè ¹¤Ø³ÊÁºÑµ¢Ô ͧ¤Í¹â·Ãŵ‹Ò§æ´Ñ§¹Õé Name

cmdRdConfig

Name

cmdWrConfig

Name

Caption

Read Config

Caption

Write Config

Text

txtConfig

15.12 à¾ÔÁè â»Ãá¡ÃÁ·Õàè ˵ءÒó cmdRdConfig_Click à¾×Íè ͋ҹ¢ŒÍÁÙŨҡÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Òà ·íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð Private Sub cmdRdConfig_Click() I2CSTART Send8BIT &H90 Ack Send8BIT &HAC Ack I2CSTART Send8BIT &H91 Ack txtConfig.Text = Hex(Read8Bit) MNAck I2CSTOP End Sub

15.13 à¾ÔÁè â»Ãá¡ÃÁ·Õàè ˵ءÒó cmdWrConfig_Click à¾×Íè à¢Õ¹¢ŒÍÁÙÅä»ÂѧÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Òà ·íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð Private Sub cmdWrConfig_Click() I2CSTART Send8BIT &H90 Ack Send8BIT &HAC Ack Send8BIT CByte(“&H” & txtConfig.Text) Ack I2CSTOP End Sub

15.14 ·´ÅͧµÑ§é ¤‹ÒºÔµ 1Shot ã¹ÃÕ¨ÊÔ àµÍÏ¡Òí ˹´¡Ò÷íÒ§Ò¹áÅÐáÊ´§Ê¶Ò¹Ð ãˌ໚¹ “0” à¾×Íè ࢌÒÊÙ⋠ËÁ´á»Å§¤‹Òµ‹Íà¹×Íè § â´Â¾ÔÁ¾àÅ¢ 8 ã¹ txtConfig ¨Ò¡¹Ñ¹é ¤ÅÔ¡é »ØÁ† Write Config áŌǤÅÔ¡é »ØÁ† Stop Convert (ãˌ DS1621 ËÂØ´¡Ò÷íÒ§Ò¹ à¾×Íè à»ÅÕÂè ¹âËÁ´¡ÒÃá»Å§¤‹Ò ) ¤ÅÔ¡é »ØÁ† Start Convert à¾×Íè àÃÔÁè ͋ҹÍسËÀÙÁÍÔ ¡Õ ¤Ãѧé ã¹âËÁ´¡ÒÃá»Å§¤‹ÒÍسËÀÙÁµÔ ͋ à¹×Íè § ÊÒÁÒö´ÙÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ¾ÃŒÍÁ·´Åͧ㪌§Ò¹ä´Œ¨Ò¡ä¿Å LAB15B.VBP àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 147


¡Ò÷´Åͧ㪌 DS1621 ·íÒ§Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ ¡ÒÃ͋ҹ¢ŒÍÁÙŨҡÃÕ¨ÊÔ àµÍÏ TH áÅÐ TL ¹Ñ¹é ÁÕ¢¹Ñé µÍ¹àËÁ×͹¡ÒÃ͋ҹÃÕ¨ÊÔ àµÍÏ Temperature ᵋ¤Òí Êѧè (Command) ᵡµ‹Ò§¡Ñ¹ ¤×Í¡ÒÃ͋ҹÃÕ¨ÊÔ àµÍÏ TH 㪌¤Òí Êѧè &HA1 ʋǹ TL 㪌¤Òí Êѧè &HA2 ʋǹ¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»ÂѧÃÕ¨ÊÔ àµÍÏ·§Ñé ÊͧÁÕ¢¹Ñé µÍ¹´Ñ§¹Õé 1. ʋ§ÊÑ­­Ò³ START 2. ʋ§¢ŒÍÁÙÅ¡íÒ˹´áÍ´à´Ãʺ¹ºÍÏ´ EX-10 ãˌ DS1621 â´ÂºÔµÊØ´·ŒÒÂ໚¹ “0” à¾×Íè ¡íÒ˹´¡ÒÃà¢Õ¹¢ŒÍÁÙÅä»Âѧ DS1621 3. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 4. ʋ§¤íÒÊѧè (Command) &HA1 à¾×Íè ࢌҶ֧ÃÕ¨ÊÔ àµÍÏ TH ËÃ×ͤíÒÊѧè &HA2 ÊíÒËÃѺ TL 5. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 6. ʋ§¢ŒÍÁÙÅ MSB ¢Í§ ÃÕ¨ÊÔ àµÍÏ TH / TL ä»·Õè DS1621 7. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 8. ʋ§¢ŒÍÁÙÅ LSB ¢Í§ ÃÕ¨ÊÔ àµÍÏ TH / TL ä»·Õè DS1621 9. ÃÍÃѺÊÑ­­Ò³ ACK ¨Ò¡ DS1621 10. ʋ§ÊÑ­­Ò³ STOP 㹡ÒõԴµ‹Í¡ÑºÃÕ¨ÊÔ àµÍÏ TH áÅÐ TL ÊÒÁÒöà¢Õ¹â»Ãá¡ÃÁ·´Åͧ䴌´§Ñ ¹Õé 15.15 à¾ÔÁè ¤Í¹â·ÃÅáÅÐà»ÅÕÂè ¹ª×Íè ´Ñ§ÃÙ»·Õè P15-3

ÃÙ»·Õè P15-3 ˹ŒÒµÒ¢Í§â»Ãá¡ÃÁ·´Åͧ͋ҹáÅÐµÑ§é ¤‹ÒÍسËÀÙÁ¡Ô ºÑ DS1621 àÁ×Íè ¡íÒ˹´ ãˌ·Òí §Ò¹ã¹âËÁ´à·ÍÏâÁʵѵ àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 148


15.16 à¾ÔÁè â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdRdTH_Click ´Ñ§¹Õé Private Sub cmdRdTH_Click() Dim tmp As Double Dim datH As Integer Dim datL As Integer I2CSTART Send8BIT &H90 Ack Send8BIT &HA1 ‘Access TH Register Command Ack I2CSTART Send8BIT &H91 Ack datH = Read8Bit ‘Read MSB TH Register MAck datL = Read8Bit ‘Read LSB TH Register MNAck I2CSTOP If (datL And &H80) = &H80 Then tmp = datH + 0.5 Else tmp = datH End If txtTH.Text = tmp End Sub

¨ÐàËç¹ä´ŒÇҋ â»Ãá¡ÃÁÊíÒËÃѺà˵ءÒó cmdRdTL_Click ¹Ñ¹é àËÁ×͹¡Ñº cmdRdTH_Click ᵋà»ÅÕÂè ¹ Command ໚¹ &HA2 áÅÐà¡çº¤‹Òŧ㹠txtTL.Text 15.17 à¢Õ¹â»Ãá¡ÃÁãˌ¡ºÑ à˵ءÒó cmdWrTH_Click ´Ñ§¹Õé Private Sub cmdWrTH_Click() Dim tmp As Double Dim datH As Byte Dim datL As Byte datH = Fix(txtTH.Text) tmp = Val(txtTH.Text) - datH If tmp <> 0 Then datL = &H80 I2CSTART Send8BIT &H90

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 149


Ack Send8BIT &HA1 Ack Send8BIT datH Ack Send8BIT datL Ack I2CSTOP End Sub

‘Access TH Register Command

¨Ò¡â»Ãá¡ÃÁ¢ŒÒ§µŒ¹ à˵ءÒó cmdWrTL_Click ¶Ù¡á¡Œä¢ãËŒÃºÑ ¤‹Ò¨Ò¡ txtTL.Text áÅР㪌 Command &HA2 15.18 Ãѹâ»Ãá¡ÃÁáŌÇà¢Õ¹¤‹Ò Config ãˌ໚¹ A ¤ÅÔ¡é »ØÁ† Write Config à¾×Íè ¡íÒ˹´âËÁ´¡Òà á»Å§¤‹Òµ‹Íà¹×Íè § áÅÐãˌ Thermostat ·íÒ§Ò¹âËÁ´ Active High 15.19 ãʋ¤Ò‹ 30 㹪‹Í§ TH áÅÐ 28 㹪‹Í§ TL ¤ÅÔ¡é »ØÁ† Write ¢Í§ TH áÅÐ TL 15.20 ¤ÅÔ¡é »ØÁ† Start Convert ãˌ DS1621 àÃÔÁè á»Å§¤‹ÒÍسËÀÙÁÔ ãªŒ¹ÇÔé ËÃ×ÍÇѵ¶Ø͹×è áµÐãˌ DS1621 à»ÅÕÂè ¹ÍسËÀÙÁÔ ¤ÅÔ¡é »ØÁ† Read Temp ÊѧࡵÍسËÀÙÁ·Ô ÍÕè ҋ ¹ä´Œ ¶ŒÒÁդҋ ÁÒ¡¡Ç‹Ò 30 LED º¹ºÍÏ´ EX-10 ¨ÐµÔ´¾ÃŒÍÁ¡ÑºÁÕàÊÕ§áÅÐÃÕàŏ·Òí §Ò¹µÒÁ¨ÑÁê à»ÍÏ·µÕè §Ñé änj àÁ×Íè ͋ҹ¤‹Ò¨Ò¡ÃÕ¨ÊÔ àµÍÏ Config ¨ÐÁդҋ ໚¹ 2A à¾ÃÒкԵ THF Áդҋ ໚¹ “1” ·Ñ§é ¹Õàé »š¹¼ÅÁÒ¨Ò¡ÍسËÀÙÁ·Ô ÇÕè ´Ñ ä´ŒÁÕ ¤‹ÒÁÒ¡¡Ç‹Ò TH ·Õµè §Ñé änj ÊÒÁÒö´ÙÃÒÂÅÐàÍÕ´¢Í§â»Ãá¡ÃÁ¾ÃŒÍÁ¡Ñº·´Åͧ㪌§Ò¹ä´Œ¨Ò¡ä¿Å LAB15C.VBP 㹠Ἃ¹«Õ´ÃÕ ÍÁ

àÃÕ¹ÃٌáÅл¯ÔºÑµÔ¡ÒÃàª×èÍÁµ‹Í¤ÍÁ¾ÔÇàµÍϡѺÍØ»¡Ã³ÀÒ¹͡¼‹Ò¹¾Íϵ¢¹Ò¹ 150


..

เรียนรู้และปฏิบัติการเชื่อมต่อคอมพิวเตอร์ผ่านพอร์ตขนาน  

พอร์ตขนานเป็นช่องทางหนึ่งที่ใช้การเขียนโปรแกรมจากคอมพิวเตอร์ไปติดต่ออุปกรณ์ต่อพ่วงภายนอกได้ โดยใช้ตัวอย่างการเขียนโปรแกรมง่ายๆ ผ่านVisual Ba...

Read more
Read more
Similar to
Popular now
Just for you