ÄãºÃ£¬»¶Ó­À´µ½¾­¹ÜÖ®¼Ò [µÇ¼] [×¢²á]

ÉèΪÊ×Ò³ | ¾­¹ÜÖ®¼ÒÊ×Ò³ | Êղر¾Õ¾

»ùÓÚVBµÄ´®¿ÚͨѶ¼°ÆäÈí¼þʵÏÖ_ͨÐŹ¤³Ì±ÏÒµÂÛÎÄ·¶ÎÄ

·¢²¼Ê±¼ä£º2015-03-13 À´Ô´£ºÈË´ó¾­¼ÃÂÛ̳
»ùÓÚVBµÄ´®¿ÚͨѶ¼°ÆäÈí¼þʵÏÖ_ͨÐŹ¤³Ì±ÏÒµÂÛÎÄ ÕªÒª:´®¿ÚͨÐÅÒòΪÆä¼òµ¥,Áé»îÒ×ÓÃ,ÔÚÐí¶àÁìÓòÓÐ׏ãÀ«µÄÓ¦ÓÃÇ°¾°¡£±¾ÎÄÔÚÉîÈëÁ˽⴮¿ÚͨѶ¼¼ÊõµÄ»ù´¡ÉÏ,½áºÏ×ÔÉíµÄ¹¤³Ìʵ¼ù¾­Ñé,²ûÊöÁËVB´®¿Ú±à³ÌµÄ¼¼ÊõÒªµã¡£²¢½áºÏÒ»¸öͨѶʵÀý,·ÖÎöͨѶµÄ¾ßÌåʵÏÖ,¸øÏà¹ØÁìÓòµÄÑо¿ÈËÔ±ÌṩֵµÃ²Î¿¼µÄÐÅÏ¢¡£ ¹Ø¼ü´Ê:´®¿Ú;RS232;API;Pcomm;Mscomm;ͨÐųÌÐò Abstract:Serial communication has broad application in many fields because of its simple communication circuitry and flexibility. Based on deep comprehension of the technology of the serial communications, this article expounds important technology detail integrated with practice experience. An example of communication program is presented and analyzed, which gives other researchers valuable reference information. Key words:serial; RS232; API; Pcomm; Mscomm; communication program ÏÖÔÚͨѶ·½Ê½Ô½À´Ô½¶à,ËÙ¶ÈÔ½À´Ô½¿ì,µ«´®ÐÐͨѶÓÉÓÚ×ÔÉí¼Û¸ñµÍ¡¢Ð­Òé͸Ã÷¡¢Ó²¼þͶ×ÊÉÙ¡¢Èí¼þ±à³Ì¼òµ¥µÈÖî¶àÓŵãÔÚÔ¶³ÌÊý¾Ý²É¼¯¡¢¼àÊÓ¡¢Í¨Ðż°¿ØÖÆÁìÓòÀïÒ»Ö±Õ¼¾Ý׿«ÆäÖØÒªµÄµØλ¡£Ëü²»½öûÓÐÒòΪʱ´úµÄ½ø²½¶ø±»ÌÔÌ­,·´¶øÔÚ¹æ¸ñÉÏÔ½À´Ô½ÍêÉÆ¡¢Ó¦ÓÃÔ½À´Ô½¹ã,³¤¾Ã²»Ë¥¡£ 1´®¿ÚͨÐŵÄͨÐÅ»úÀí PC´®ÐÐͨÐÅÊÇÖ¸Ö±½Ó¶Ô´®Ðж˿ڵÄUART(PC»úµÄͨÓÃÒì²½ÊÕ·¢Æ÷,Ò²½ÐÒ첽ͨÐÅÊÊÅäÆ÷,ÊÇPC»úÓÃÓÚÒ첽ͨÐŵĽӿÚ)½øÐбà³ÌʵÏÖµÄͨÐÅ¡£PC»úÿ¸öUARTÖеÄINS8250ÖÐÓÐ10¸ö¿É±à³ÌµÄµ¥×ֽڼĴæÆ÷,¿ÉÓÃÓÚ¿ØÖÆ¡¢¼àÊÓ²Ù×÷´®Ðж˿Ú,COM1µÄ¼Ä´æÆ÷µØÖ·3F8H-3FEH,COM2µÄ¼Ä´æÆ÷µØַΪ2F8H-2FEH¡£10¸ö¼Ä´æÆ÷ÓÉ7¸öµØÖ··ÃÎÊ,ÆäÖÐ5¸ö¼Ä´æÆ÷µÄ·ÃÎÊÌõ¼þÊÇÏÈÉèÖÃ3FBHÏß·¿ØÖƼĴæÆ÷µÄ×î¸ßλΪ1,¸ÃλҲ³ÆΪDLAB״̬λ¡£[1] Ò»°ã˵À´,PC»ú¶¼ÓÐÒ»¸ö»ò¶à¸ö´®Ðж˿Ú,ËüÃÇÒÀ´ÎΪCom1¡¢Com2¡­¡­¡£ÕâЩ´®¿ÚÌṩÁËÍⲿÉ豸ÓëPC½øÐÐÊý¾Ý´«ÊäºÍͨÐŵÄͨµÀ,ÔÚCPUºÍÍâÉèÖ®¼ä³äµ±Á˽âÊÍÆ÷µÄ½ÇÉ«¡£µ±×Ö·ûÊý¾Ý´ÓCPU·¢Ë͸øÍâÉèʱ,ÕâЩ×Ö·ûÊý¾Ý½«±»×ª»»³É´®ÐбÈÌØÁ÷Êý¾Ý;¶øµ±½ÓÊÜÊý¾Ýʱ,´ÓÍâ½ç½øÀ´µÄ±ÈÌØÁ÷Êý¾Ý±»×ª»»³É×Ö·ûÊý¾Ý´«µÝ¸øCPU½øÐд¦Àí¡£ÔÚ²Ù×÷ϵͳ·½Ãæ,WindowsÓÃͨÐÅÇý¶¯³ÌÐò(COMM.DRV)µ÷ÓÃAPIº¯Êý·¢ËͺͽÓÊÜÊý¾Ý¡£µ±ÓÃͨÐſؼþ»òÉùÃ÷µ÷ÓÃAPIº¯Êýʱ,ËüÃÇÓÉCOMM.DRV½âÊͲ¢´«µÝ¸øÉ豸Çý¶¯³ÌÐò¡£ ×÷Ϊһ¸öVB³ÌÐòÔ±,Òª±àд´®¿ÚͨÐųÌÐò,Ö»ÐèÖªµÀͨÐſؼþÌṩ¸øWindowsͨÐÅAPIº¯ÊýµÄ½Ó¿Ú¼´¿É,»»ÑÔÖ®,Ö»ÐèÉ趨ºÍ¼àÊÓͨÐſؼþµÄÊôÐÔºÍʱ¼ä¼´¿É¡£ 2´®ÐÐͨѶ½Ó¿ÚRS-232 Ç°Ò»Õ½ÚÌÖÂÛÁË´®¿ÚͨѶµÄͨÐÅ»úÀí,µ«ÎªÁËʵÏÖ¾ßÌåµÄÊý¾Ý²É¼¯¡¢¼àÊÓ¡¢Í¨ÐŹ¦ÄÜ,±ØÐëÁ˽â¾ßÌåµÄ´®¿ÚÐÎʽ¡£Ä¿Ç°Ê¹ÓÃ×î¹ã·ºµÄ´®ÐнӿÚÓÐÁ½ÖÖ:RS-232ºÍRS-485¡£±¾ÎÄ×ÅÖØÌÖÂÛRS-232,RS- 485²»×÷½éÉÜ¡£ RS-232C±ê×¼µÄÈ«³ÆÊÇEIA-RS-232C±ê×¼,ÆäÖÐEIA´ú±íÃÀ¹úµç×Ó¹¤ÒµÐ­»á,RS´ú±íÍƼö±ê×¼,232ÊDZêʶºÅ,C´ú±íRS232µÄ×îÐÂÒ»´ÎÐÞ¸Ä(1969Äê),ÔÚÕâ֮ǰ,ÓÐRS232A¡¢RS232BЭÒé¡£Ëü¹æ¶¨Á¬½ÓµçÀºͻúе¡¢µçÆøÌØÐÔ¡¢ÐźŹ¦Äܼ°´«Ë͹ý³Ì¡£EIA-RS-232C¶¨ÒåÁË°´Î»´®Ðд«ÊäµÄÊý¾ÝÖÕ¶ËÉ豸(DTE)ºÍÊý¾ÝͨѶÉ豸(DCE)Ö®¼äµÄ½Ó¿ÚÐÅÏ¢¡£RS-232CÊÇ´ÓDTE»ò¼ÆËã»ú´®ÐнӿڽǶÈÀ´¶¨ÒåÒý½ÅÐźŵġ£ Ä¿Ç°RS-232ÊÇPC»úÓëͨÐŹ¤ÒµÖÐÓ¦ÓÃ×î¹ã·ºµÄÒ»ÖÖ´®Ðнӿڡ£RS232±»¶¨ÒåΪһÖÖÔÚµÍËÙÂÊ´®ÐÐͨѶÖÐÔö¼ÓͨѶ¾àÀëµÄµ¥¶Ë±ê×¼¡£RS232²ÉÈ¡²»Æ½ºâ´«Ê䷽ʽ,¼´ËùνµÄµ¥¶ËͨѶ¡£[2] DB9(9Õë´®¿Ú)µÄ½ÓÏß·½Ê½ÈçÏÂ:1½Å,Êý¾ÝÔز¨¼ì²âDCD;2½Å,½ÓÊÕÊý¾ÝRXD;3½Å,·¢ËÍÊý¾ÝTXD;4½Å,Êý¾ÝÖÕ¶Ë×¼±¸DTR;5½Å,ÐźŵØGND;6½Å,Êý¾ÝÉ豸¾ÍÐ÷DSR;7½Å,ÇëÇó·¢ËÍRTS;8½Å,Çå³ý·¢ËÍCTS;9½Å,ÕñÁåָʾDELL¡£ DB25(25Õó´®¿Ú),³£ÓõÄÕë½ÅÒ²ÓÐ9¸ö,ÇÒºÍDB9¿ÉÒÔÒ»Ò»¶ÔÓ¦,¾ßÌå½ÓÏß·½Ê½Îª:8½Å,Êý¾ÝÔز¨¼ì²âDCD;3½Å,½ÓÊÕÊý¾ÝRXD;2½Å,·¢ËÍÊý¾ÝTXD;20½Å,Êý¾ÝÖÕ¶Ë×¼±¸DTR;7½Å,ÐźŵØGND;6½Å,Êý¾ÝÉ豸¾ÍÐ÷DSR;4½Å,ÇëÇó·¢ËÍRTS;5½Å,Çå³ý·¢ËÍCTS;22½Å,ÕñÁåָʾDELL¡£ Ò»°ãÀ´Ëµ,¶ÔÓÚÒªÇó²»Ì«¸ßµÄ³¡ºÏ,ʹÓýÓÊÕÊý¾ÝRXD,·¢ËÍÊý¾ÝTXD,ÐźŵØGNDÈý¸ö½Å¼´¿ÉʵÏÖÊý¾Ý´«Êä¡£Èç¹ûÒªÇóÓÐÓ²¼þÁ÷¿ØÖÆ,Ôò±ØÐëʹÓÃDTR¡¢DSR¡¢RTSºÍCTSÕâËĸö½Å¡£ ÖµµÃ×¢ÒâµÄÊÇRS-232CÊÇÓÃÕý¸ºµçѹÀ´±íʾÂß¼­×´Ì¬,ÓëTTLÒԸߵçƽ±íʾÂß¼­×´Ì¬µÄ¹æ¶¨²»Í¬¡£Òò´Ë,ΪÁËÄܹ»Óë¼ÆËã»ú½Ó¿Ú»òÖն˵ÄTTLÆ÷¼þÁ¬½Ó,±ØÐëÔÚRS-232CÓëTTLµç·֮¼ä½øÐеçƽºÍÂß¼­¹ØϵµÄ±ä»»¡£Ä¿Ç°½ÏΪ¹ã·ºµØʹÓü¯³Éµç·ת»»Æ÷¼þ,ÈçMC1489¡¢SN75150оƬ¿ÉÍê³ÉTTLµçƽµ½EIAµçƽµÄת»»,¶øMC1489¡¢SN75154¿ÉʵÏÖEIAµçƽµ½TTLµçƽµÄת»»¡£ 3ÈýÖÖ¶ÁÈ¡´®¿ÚÊý¾ÝµÄ·½Ê½
¾­¹ÜÖ®¼Ò¡°Ñ§µÀ»á¡±Ð¡³ÌÐò
  • ɨÂë¼ÓÈë¡°¿¼ÑÐѧϰ±Ê¼ÇȺ¡±
ÍƼöÔĶÁ
¾­¼ÃѧÏà¹ØÎÄÕÂ
±êÇ©ÔÆ
¾­¹ÜÖ®¼Ò¾«²ÊÎÄÕÂÍƼö