ÕªÒª£º½éÉÜÒ»ÖÖÀûÓõ¥Æ¬»ú²É¼¯Êý¾Ý£¬LabVIEW×÷Ϊ¿ª·¢Æ½Ì¨£¬¶þÕßÖ®¼äͨ¹ý´®¿ÚʵÏÖÊý¾ÝͨѶµÄÊý¾Ý²É¼¯ÏµÍ³£¬Ïêϸ½éÉÜÁËÈí¡¢Ó²¼þÉè¼Æ·½°¸¡£
1 LabVIEW²¿·ÖÉè¼Æ
1.1 VISA¼ò½é
LabVIEWÌṩÁ˹¦ÄÜÇ¿´óµÄVISA¿â¡£VISA(Virtual Instrument Software Architecture)——ÐéÄâÒÇÆ÷Èí¼þ¹æ·¶£¬ÊÇÓÃÓÚÒÇÆ÷±à³ÌµÄ±ê×¼I/Oº¯Êý¿â¼°ÆäÏà¹Ø¹æ·¶µÄ×ܳơ£VISA¿âפÁôÓÚ¼ÆËã»úϵͳÖУ¬Íê³É¼ÆËã»úÓëÒÇÆ÷Ö®¼äµÄÁ¬½Ó£¬ÓÃÒÔʵÏÖ¶ÔÒÇÆ÷µÄ³ÌÐò¿ØÖÆ£¬ÆäʵÖÊÊÇÓÃÓÚÐéÄâÒÇÆ÷ϵͳµÄ±ê×¼µÄAPI¡£VISA±¾Éí²»¾ß±¸±à³ÌÄÜÁ¦£¬ËüÊÇÒ»¸ö¸ß²ãAPI£¬Í¨¹ýµ÷ÓõײãÇý¶¯³ÌÐòÀ´ÊµÏÖ¶ÔÒÇÆ÷µÄ±à³Ì£¬Æä²ã´ÎÈçͼ1Ëùʾ¡£VISAÊDzÉÓÃVPP±ê×¼µÄI/O½Ó¿ÚÈí¼þ£¬ÆäÈí¼þ½á¹¹°üº¬Èý²¿·Ö£¬Èçͼ2Ëùʾ¡£
ÓëÆäËûÏÖ´æµÄI/O½Ó¿ÚÈí¼þÏà±È£¬VISAµÄI/O¿ØÖƹ¦ÄܾßÓÐÈçϼ¸¸öÌص㣺ÊÊÓÃÓÚ¸÷ÖÖÒÇÆ÷ÀàÐÍ(ÈçVXIÒÇÆ÷¡¢GPIBÒÇÆ÷¡¢RS-232´®ÐÐÒÇÆ÷¡¢ÏûÏ¢»ùÆ÷¼þ¡¢¼Ä´æÆ÷Æ÷¼þ¡¢´æ´¢Æ÷Æ÷¼þµÈÒÇÆ÷);ÊÊÓÃÓÚ¸÷ÖÖÓ²¼þ½Ó¿ÚÀàÐÍ;ÊÊÓÃÓÚµ¥¡¢¶à´¦ÀíÆ÷½á¹¹»ò·Ö²¼Ê½ÍøÂç½á¹¹;ÊÊÓÃÓÚ¶àÖÖÍøÂç»úÖÆ¡£
VISAµÄI/OÈí¼þ¿âµÄÔ´³ÌÐòÊÇΨһµÄ£¬ÆäÓë²Ù×÷ϵͳ¼°±à³ÌÓïÑÔÎ޹أ¬Ö»ÊÇÌṩÁ˱ê×¼ÐÎʽµÄAPIÎļþ×÷ΪϵͳµÄÊä³ö¡£
1.2 VISA¿âÖеĴ®¿ÚͨѶº¯Êý
±¾ÎÄÓõ½µÄÖ÷ÒªµÄ´®¿ÚͨѶº¯Êýµ÷Ó÷¾¶Îª£ºFunctionsªíInstrument I/OªíVISAªíVISA AdvancedªíInterface SpecificªíSerialÖС£
(1)VISA Configure Serial Port½Úµã(ͼ3Ëùʾ)
¸Ã½ÚµãÖ÷ÒªÓÃÓÚ´®¿ÚµÄ³õʼ»¯¡£Ö÷Òª²ÎÊýÒâÒåÈçÏ£º
VISA resource name:VISA×ÊÔ´Ãû³Æ£¬±¾ÎÄÖ¸´®¿ÚºÅ¡£baud rate£º²¨ÌØÂÊ£¬Ä¬ÈÏΪ9600¡£
data bits£ºÒ»Ö¡ÐÅÏ¢ÖеÄλÊý£¬LabVIEWÖÐÔÊÐí5¡«8λÊý¾Ý£¬Ä¬ÈÏֵΪ8λ¡£
stop bits£ºÒ»Ö¡ÐÅÏ¢ÖеÄֹͣλµÄλÊý£¬¿ÉΪ1λ¡¢1λ°ë»ò2λ¡£
Parity£ºÆæżУÑéÉèÖ᣿ÉΪÎÞУÑé¡¢ÆæУÑé»òżУÑé¡£
flow control£º¸Ã²ÎÊýÊý¾ÝÀàÐÍΪ´Ø£¬ÓÃÓÚ´®ÐÐͨѶÖеÄÎÕÊÖ·½Ê½¡£
(2)VISA Read½Úµã(ͼ4Ëùʾ)ª¥
¸Ã½ÚµãΪ´®¿Ú¶Á×ÓVI£¬Îª±¾ÎÄÖеÄÖ÷Òª½Úµã£¬½«´®¿ÚÖеÄÊý¾Ý¶Á³ö£¬È»ºóÀûÓÃLabVIEWµÄÇ¿´óÊý¾Ý´¦Àí¹¦ÄܶÔÆä½øÐзÖÎö´¦Àí¡£Ö÷Òª²ÎÊýÒâÒåÈçÏ£º
VISA resource name£ºÍ¬ÉÏ¡£
byte count£ºÓÃÓÚÉèÖÃËùÒª¶ÁµÄ×Ö·ûÊý¡£ÓÉÓÚLabVIEWµÄ´®ÐÐͨѶ×ÓVIÖ»ÔÊÐí¶Ô×Ö·û´®µÄ¶Áд£¬Òò´Ë±¾ÎÄÖÐÔÚ½øÐÐÊý¾Ý´¦Àíʱ£¬±ØÐëҪʵÏÖ×Ö·û´®ÓëÊý×ÖÖ®¼äµÄÕýȷת»»¡£´ËÍ⣬ÈôÒª¶ÁÈ뵱ǰ´®¿ÚÖеÄËùÓÐ×Ö·û£¬ÔòÒªÖ´ÐГVISA Bytes at Serial Port”×ÓVI£¬ÓÃÒÔÈ·¶¨½«Òª¶ÁÈëµÄÈ·ÇеÄ×Ö½ÚÊý£¬È»ºó½«ÆäÊä³ö×÷ΪVISA Read½ÚµãµÄÊäÈë¼´¿É¡£
(3)VISA Close½Úµã(ͼ5Ëùʾ)ª¥
¸Ã½ÚµãÓÃÓÚ½«´ò¿ªµÄVISA×ÊÔ´¹Ø±Õ¡£Ö»ÓÐÒ»¸öÖ÷Òª²ÎÊý£º
VISA resource name£ºÒâÒåͬÉÏ¡£
±¾ÎÄËùÓÃLabVIEW´®¿ÚͨѶ³ÌÐòµÄ²¨ÌØÂÊΪ9600£¬ÎÞÆæżУÑ飬8λÊý¾Ý룬1λֹͣ룬½ûÖ¹Èí¡¢Ó²¼þÎÕÊÖ¡£
2 µ¥Æ¬»ú²¿·ÖÉè¼Æ
2.1 Ó²¼þ²¿·Ö
MCS-51µ¥Æ¬»úÄÚ²¿ÓÐÒ»¸ö¹¦ÄܺÜÇ¿µÄÈ«Ë«¹¤´®Ðпڣ¬¸Ã´®ÐпÚÓÐ4ÖÖ¹¤×÷·½Ê½£¬²¨ÌØÂÊ¿ÉÓÃÈí¼þÉèÖã¬ÓÉƬÄڵĶ¨Ê±Æ÷/¼ÆÊýÆ÷²úÉú£¬½ÓÊÕ¡¢·¢Ë;ù¿É´¥·¢ÖжÏϵͳ£¬Ê¹ÓÃÊ®·Ö·½±ã¡£ÓÐ2¸öÎïÀíÉ϶ÀÁ¢µÄ½ÓÊÕ¡¢·¢ËÍ»º³åÆ÷SBUF£¬¶ÔÍâÒ²ÓÐÁ½Ìõ¶ÀÁ¢µÄÊÕ¡¢·¢ÐźÅÏßRXD(P3.0)ºÍTXD(P3.1)¡£
±¾ÎIJÉÓÃRS232´®Ðнӿڱê×¼£¬ÔÚµçÆøÌØÐÔÉÏ£¬RSª²232²ÉÓøºÂß¼£¬ÒªÇó¸ßµÍÁ½ÐźżäÓнϴóµÄ·ù¶È£¬±ê׼Ϊ£ºÂß¼“1”ÔÚ-5V¡«-15VÖ®¼ä£¬Âß¼“0”ÔÚ+5V¡«+15VÖ®¼ä£¬Í¨³£²ÉÓÃ-10V×óÓÒΪÂß¼1£¬+10V×óÓÒΪÂß¼0¡£ÓÉÓÚMCS-51ϵͳµÄÐźÅÊäÈëÊä³öΪTTLµçƽ£¬Âß¼1Ϊ3.8V×óÓÒ£¬Âß¼0Ϊ0.4V×óÓÒ£¬Òò´Ë£¬±ØÐëÍâ½Óµç·ʵÏÖTTLµçƽµ½RSª²232µçƽµÄת»»¡£±¾ÎIJÉÓÃMAX232EʵÏÖ´Ëת»»¡£
²ÉÓÃTLC0831оƬ½øÐÐÊý¾ÝµÄ²É¼¯¡£TLC0831оƬΪ8λÖð´Î±Æ½üµçѹÐÍA/Dת»»Æ÷£¬Ö§³Öµ¥ÐŵÀÊäÈë´®¿ÚÊä³ö£¬¼«ÐÔÉèÖù̶¨£¬²»ÐèÑ°Ö·¡£ÆäÖ÷ÒªÌصãΪ£º8λ·Ö±æÂÊ;5VµÄµçÔ´Ìṩ0¡«5VµÄ¿Éµ÷»ù×¼µçѹ;ÊäÈëÊä³ö¿ÉÓëTTLºÍMOS¼æÈÝ¡£
ÈôÒªÌá¸ßÐźŵIJÉÑùƵÂÊ£¬Ö»ÐèÑ¡Ôñת»»ËٶȽϿìµÄA/DоƬ¼´¿É¡£Ó²¼þ²¿·ÖÔÀíͼÈçͼ6¡£
2.2 Èí¼þ²¿·Ö
ÏÂÃæ¸ø³öµ¥Æ¬»úÈí¼þ²¿·ÖµÄÖ÷Òª³ÌÐò¡£²¨ÌØÂÊÉèÖÃΪ9600£¬Óö¨Ê±Æ÷1²úÉú²¨ÌØÂÊ£¬´®¿Ú¹¤×÷ÔÚ·½Ê½1£¬ÎÞÆæżУÑé¡£¶¨Ê±Æ÷0É趨²ÉÑùµÄʱ¼ä¼ä¸ô¡£TLC0831ΪA/Dת»»Æ÷Êý¾Ý²ÉÑù×Ó³ÌÐò£¬SENDΪµ¥Æ¬»ú·¢ËÍ×Ó³ÌÐò¡£
3 ½áÂÛ
±¾ÎÄÀûÓõ¥Æ¬»ú½øÐÐÇ°¶ËÊý¾Ý²É¼¯£¬Í¨¹ý´®¿ÚʵÏÖÓëLabVIEWµÄÊý¾ÝͨѶ£¬ÀûÓÃLabVIEWµÄÇ¿´óÐźŷÖÎö´¦Àí¹¦ÄÜ£¬¿ª·¢ÁËÒ»Ì×Ͷ×ÊÉÙ¡¢²Ù×÷¼ò±ãµÄÊý¾Ý²É¼¯ÓëÐÅÏ¢·ÖÎöϵͳ(ÆäÐéÄâÃæ°åÈçͼ7Ëùʾ)¡£ÊµÑéÖ¤Ã÷£¬¸ÃϵͳÔËÐÐÁ¼ºÃ¡£
²Î¿¼ÎÄÏ×£º
[1] LabVIEW User Manual[M]. USA:National Instruments Corporation£¬1998.
[2] ÑîÀÖƽ£¬µÈ.LabVIEW³ÌÐòÉè¼ÆÓëÓ¦ÓÃ[M].µç×Ó¹¤Òµ³ö°æÉ磬2001.
[3] Áõ¾ý»ª£¬µÈ.ÐéÄâÒÇÆ÷ͼÐλ¯±à³ÌÓïÑÔLabVIEW½Ì³Ì[M].Î÷°²µç×ӿƼ¼´óѧ³ö°æÉ磬2001.
[4] ÕÅÒã¸Õ£¬µÈ.MCSª²51µ¥Æ¬»úÓ¦ÓÃÉè¼Æ[M].¹þ¶û±õ¹¤Òµ´óѧ³ö°æÉ磬1997.
×÷ÕߣºÂÞ¹âÀ¤ Ñîê» »ÆΩ¹« ËÄ´¨¹¤ÒµÑ§Ôº»úе¹¤³ÌÓë×Ô¶¯»¯ À´Ô´£º¡¶ÒÇ±í¼¼Êõ¡·2003Äê01ÆÚ