20059()Sept12005123JOURNALOFBEIJINGBROADCASTINGINSTITUTEVol112,No13(SCIENCEANDTECHNOLOGY)S7-200PLCPC,(100024):S7-200PLC,VB6.0PLCPC:S7-200PLC;VB6.0;:TP391:A:1007-8819(2005)03-0041-06,PLC:,PLC,,PLCPC,,,PLC1PLCPLC,,PLCPLCPC:(1),InTouchWinCC,PLCPC:2004212227PC,PLC,I/O,I/OPLC,,,I/O,PLCPLC,(2)PLC,PLCPC,PLC,PLC,(3)PLCPLCPC,,,142S7-200PLCS7-200PLC,,,S7-200PLCS7-200PLC:(1)PPI,PLCPPI/,S7-200CPU,CPUSIMATICTD200PPI,S7-200CPURUN,CPUPPI,32PPI(2)ProfibusProfibusI/OS7-200CPUEM277Profibus-DPProfibus,I/OPLCProfibusDPProfibus,PLCPPIPROFIBUS7(3),S7-200CPU,,PCRS232S7-200CPU2262,Port1DP,Port0,RS485PC/PPIRS232/RS485,,PLCPC3S7-200PLCS7200PLC,PLC,PLC1SMB30pp,d,bbbmm0,mm=1,mm=0PPIppdbbbmm1:(1)XMT(TBL),(PORT),XMT1-255,,,09,126SM4.5SM4.6,TBL2,,,20,XMT,16(break),XMT,SM4.5SM4.6XMT(2)24()12RCV,(PORT),(TBL),,RCV,255,,,023,124SMB86SMB186,SMB86SMB186,RCV,,,01,825,SMB2,SM3.001SMB2SMB34PLCPLC,,,,PLC,(),(1)PC/PPI,S7-200CPU,9600bit/s19200bit/s,2ms1ms(2),,,,(),,,(3)8,,,ASCIIBCD,ASCII,,,5VisualBasic,VisualC++VisualBasic,C#VisualBasic,,Windows,,DOS,VisualBasicMicrosoftCommControl,MSCommVB6.0Mscomm,MSComm,Mscomm,:CommPort:,COM1,Mscomm16343:S7-200PLCPCPortopen:PortopenTrueFalse,Setting:49600,N,8,1,9600bps,N,8,1Input:,Output:,InputMode:Input,,65,InputMode,InputString,InputAInputMode,InputByte(),Input650-255,,,PLCRthreshold:OnCommInBuffercountRthreshold,RthresholdOnCommInBuffercountRthreshold,OnComm,InBuffercountRthreshold,,OnComm,,OncommInBuffercount:,InBuffercount8,8InBuffercount,Sthreshold:SthresholdSthreshold,OnCommInBufferSizeOutBufferSize::1,;2,,CommPort;3,();4,Settings;5,;6,(Output)(Input);7,Mscomm,6,,PLC,,,,Q1.01RCVPLC:MAINLDSM0.1CALLSBR_0LDNSM0.7EURSM30.0,1DTCH23DTCH9DTCH10SBR_0LDSM0.0MOVB9,SMB30MOVB16#EC,SMB87MOVB0,SMB88MOVB16#66,SMB89MOVW+1000,SMW92MOVB100,SMB94ATCHINT_0,2344()12ATCHINT_1,9ENIRCVVB100,0FCSLDSM0.0MOVB0,#XORCBTI#NUMB,#NUMIFOR#TEMP1,+1,#NUMILDSM0.0XORB3#PNT,#XORCINCD#PNTNEXTINT_0LDBSMB86,16#20JMP1NOTMOVBVB102,VB99RV96.0,24MOVD&VB103,VD92+DVD96,VD92MOVB3VD92,VB91INCBVB99CALLFCS,&VB102,VB99,VB90LDB=VB90,VB91RQ1.0,1MOVB5,SMB34ATCHINT_2,10CRETINOTSQ1.0,1LBL1LDSM0.0RCVVB100,0INT_1LDSM0.0=Q0.0RCVVB100,0INT_2LDSM0.0DTCH10=Q0.1XMTVB100,0:DimrcvlenthAsIntegerDimrcv()AsBytePrivateSubForm_load()WithMSComm1.CommPort=1.Settings=9600,n,8,1.InputMode=comlnputModeBinary.RThreshold=1.InputLen=0.OutBufferCount=0.InBufferCount=0IfNotMSComm1.PortOpenThenMSComm1.PortOpen=TrueEndIfEndSubPrivateSubCommand1_Click()rcvlenth=-1sdata=Array(0,4,7,9)DimnByte()AsByteReDimnByte(UBound(sdata)+5)AsBytenByte(0)=0nByte(1)=UBound(sdata)+1fcs=nByte(1)Fori=2ToUBound(sdata)+2nByte(i)=sdata(i-2)fcs=fcsXornByte(i)NextnByte(i)=fcsnByte(i+1)=&H66MSComm1.Output=nByteEndSubPrivateSubMSComm1_OnComm()Dimrcvtemp()AsByte543:S7-200PLCPCReDimPreserventV(100)AsByteText1=SelectCaseMSComm1.CommEventCasecomEvReceiveDimiAsIntegeri=MSComm1.InputLenrcvtemp=MSComm1.InputReDimrcv(UBound(rcvtemp)+1)AsByteFori=LBound(rcvtemp)ToUBound(rcvtemp)rcvlenth=rcvlenth+1rcv(rcvlenth)=rcvtemp(i)NextiReDimPreservercv(rcvlenth)AsByteEndSelectFori=LBound(rcv)ToUBound(rcv)Text1=Text1&Str(rcv(i))NextEndSub7,VisualBasicPCPLC,,PLC,:[1],.PLC[M].:.[2],.PLC[M].:.[3].[M].:.[4],.VisualBasicRS-232[M].:.[5],,.S7-200PLCPCVB6.0[J].,2003,13(4).[6],,,.VB[J].,2001(2).SerialCommunicationbetweenS7-200PLCandPCGAOGe,SUZhi2wu(InformationEngineeringSchool,CommunicationUniversityofChina,Bejjing100024,China)Abstract:ThispaperintroducesthefreeportmodeofS7-200PLCanditsconfiguration,andtheserialcommunicationbetweenS7-200PLCandPCbasedonVisualBasic6.0.Keyword:S7-200PLC;VB6.0;serialcommunications(:)64()12