台达PLC通讯协议.docx
台达PLC通讯协议VI。12通讯接口 RS-232C RS-4852 .通讯协议ASGl模式,9600(传输速率),偶同位,1个起始位,1个停止位9600, 7,e, 13 .通讯资料格式STX起始字符S ,(3AH)ADRl通讯地址:ADR 0 8-bit地址包含了 2个ASCll码CMDl命令码:CMDO 8-bit命令包含了 2个ASQl码DATA(O)资料内容:DATA (1) n个8-bit资料包含了 2n个ASCll码n <=74 个 ASCIl 码DATA (n-l)LRC CHKl侦误值:LRCCHK 0 8-bit侦误值包含了 2个ASCll码ENDl结束字符:Endoendi = CR (odh) ,endo = lf(oah)PLC通讯地址出厂设定值为OXo1,因此(ADR 1, ADRO)="O, T侦错方式采用LRC(Longitudinal Redundancy Check)侦误值。LRC侦误值乃是将ADRI至最后一个资料内容加总,将该值取2补码(2,SComPlement)得至IJ之结果即为LRC侦误值。附录一 3例:STX':'ADROzl,CMDl tO,CMD0,3z起始资料地址'O''4'OT资料数OOOtl,LRCCHK IFLRC CHKO 6END 1 CRENDOLF01H+03H+04H+01H+00+01H = OAHOAH的2补码为F6H注12补码的求法:(1补码再加1)OA (H) = 0000 1010 (B)先取 1 补码(将 bb7 反相)得 IlllOIOl(B),再加 1 为 11110110(B) = F6(H)即为 OA (H)的 2 补码.注2因此在收到一串完整的通讯命令,要检查这串通讯命令是否有误,只要将(ADRl,0)至(LRCI,0) 加总等于0,则通讯无误,否则表示命令中资料有些是错误的。通讯异常PLC的响应:附录一 4PLC收到完整的通讯命令时,会判断命令是否有效,造成无效的原因有:原因 EXCEPTION CODELRC CHK ERROR 07DEIVCE ADDRESS INVALID 02要求的资料超过范围03COMMAND CODE INVALID 01通讯命令格式INVALID 07例:使用命令码01读取XOOOX017的状态Field Name Example (Hex)Heading 3ASlave Address 01Function 01Starting Address Hi 04Starting Address Lo 00Number of Points Hi 00Number of Points Lo 10Error Check ( LRC ) EA附录-5PLC响应:Field Name Example (Hex)Function 81Exception Code 02Error Check ( LRC ) 7C因为 AddreSSO400 对 FUnCtiOnol 是不合法的,所以响应 EXCePtiOnCOde = OX02,且 FIJnCtion 01被设为81 (b7被设为1),亦即由响应的FUnCtiOn code的MSB被设为1表示PLC响应ERRORMESSAGE,并且由EXCePtionCode可得知是何种错误。Code Name Description01 Read CoiIStatusS, Y, M,T,C02 Read Input Status S» X,Y, M, TC03 Read Holding Registers T,C, D05 Force Single Coil S, Y,M, TzC06 Preset Single Register T,C, D15 ForceMuItipIe CoiIsS, Y, M, T, C16 Preset Multiple RegisterT, C, D17 Report Slave ID None附录-6Function Code: 01, Read Coil StatusField Name Example (Hex)Heading 3ASlave Address OlFunction OlNumber of Points Lo 25Error Check ( LRC ) BFNumberofPoints (max) = 255 = OxOOFF例:由从动装置(SIaVedeViCe) Ol读取线圈T20T56PCIPLC “: 01 Ol 06 14 00 25 BF CR LFwPLCfPC ": 01 01 05 CD 6B B2 OE IB D6 CR LF''Field Name ContentsSlave Address 01Function 01Bytes Count 05Data(CoilsT27.T20) CDDatafCoiIs T35.T38) 6BData (CoilsT43.T36) B2Data(Coils T51.T44) OEDatafCoiIs T56.T52) IBError Check (LRC) E6附录-7Field Name Example (Hex)Heading 3ASlave Address 01Function 02Number of Points Lo 25Error Check ( LRC ) BF例:由从动装置Ol读取接点Y024Y070PCfPLCJ 01 02 05 14 00 25 BF CR LFwPLC÷PC ":01 01 05 CD 6B B2 OE IB E5 CR LF"Field Name ContentsSlave Address 01Function 02Bytes Count 05Data (Coils Y033.Y024) CDData (CoilsY043.Y034) 6BData (CoilsY053.Y044) B2Data (Coils Y063.Y054) OEData (Coils Y070.Y064) IBError Check (LRC) E5附录-8Holding Register: T, C, DField Name Example (Hex)Heading 3ASlave Address OlFunction 03Number of Points Lo 08Error Check ( LRC) DANumber of Pointsfmax)=18 (for 16 bit register)=9(for 32 bit register)例:由从动装置Ol读取线圈T20-T27PCTPLC”: Ol 03 06 14 00 08 DA CR LFwPLC- 01 03 10 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 B8 CR LF3A 30 31 30 33 31 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 3030 30 30 30 30 30 30 45 43 OD OA3A 30 Bl 30 33 Bl 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 3030 30 30 30 30 30 30 30 C5 C3 8D OA3A 8A 30 A6 83 30 82 30 82 30 82 30 82 30 82 30 82 30 82 30 82 30 82 30 82 30 2A C3 63 ElField Name ContentsSlave Address 01Function 03Bytes Count 10Data Hi (T20) 00Data Lo (T20) 01Data Hi (T21) 00Data Lo(T21) 02Data Hi (T22) 00附录一 9Data Lo (T22) 03Data Hi(T23) OOData Lo(T23) 04Data Hi (T24) 00Data Lo(T24) 05DataHi(T25) 00Data Lo (T25) 06Data Hi (T26) 00Data Lo(T26) 07Data Hi (T27) 00Data Lo(T27) 08Error Check (LRC) B8Field Name Example (Hex)Heading 3ASlave Address 01Function 05Coil Address Hi 05Coil Address Lo 00Force Data Hi FFForce Data Lo 00Error Check ( LRC ) F6MMNN =0xFF00.Coil ONMMNN = 0x0000.Coil OFF例:强制设定线圈YOOO ONPC->PLC ”:01 05 05 00 FF 00 F6 CR LF”PLCfPC”: Ol 05 05 00 FF 00 F6 CR LFz,附录一 10Field Name Example (Hex)Heading 3ASlave Address 01Function 05Coil Address Hi 05Coil Address Lo 00Force Data Hi FFForce Data Lo 00Error Check ( LRC ) F6Field Name Example (Hex)Heading 3ASlave Address 01Function 06Register Address Hi 06Register Address Lo 00Preset Data Hi 12Preset Data Lo 34Error Check ( LRC) AD例:设定缓存器TO to 00 03PClPLC ": 01 06 06 00 12 34 AD CR LF"PLC-PC ”:01 06 06 00 12 34 AD CR LF"Field Name Example (Hex)Heading 3ASlave Address OlFunction 06附录-11Register TO Address Hi 06Register TO Address Lo OOPreset Data Hi 12Preset Data Lo 34Error Check ( LRC ) ADSwitch ( c)Case 0:T0Q -÷l 06 06 OO 12 34 AD CR LFCase 1:COQ->: Ol 06 OE 00 12 34 AF CR LFCase 2: C232Q-÷: Ol 06 OE E8 12 34 56 78 EF CR LFCase 3: DlOQ -÷l 06 10 OA 12 34 99 CR LFCase 4:DlOOOQ÷: Ol 06 13 E8 12 34 BA CR LF附录一 12Field Name Example (Hex)Function OFCoil Address Hi 05Coil Address Lo OOQuantity of Coils Hi 00Quantity of Coils Lo OAByte Count 02Force Data Hi CDForce Data Lo OlError Check(LRC) 11Quantity of Coils (max) = 255例:设定线圈 Y007YooO = IloolI01, Y011.Y010 = 01oPC÷PLCw: Ol OF 05 00 00 OA 02 CD Ol 11 CR LF”PLCfPC”: Ol OF 05 00 00 OA El CR LFw附录一 13Field Name Example (Hex)Heading 3ASlave Address 01Function OFRegister TO Address Hi 05Register TO Address Lo 00Preset Data Hi 00Preset Data Lo OAError Check ( LRC ) ElField Name Example (Hex)Heading 3ASlave Address OlFunction 10Starting Address Hi 06Starting Address Lo 00Number of Register Hi 00Number of Register Lo 02Byte Count 04Data Hi 00Data Lo OAData Hi 01Data Lo 02Error Check (LRC) C6附录一 14Number of Register (max)=16 (for 16 bit register)=8 (for 8 bit register)例:设定缓存器TO为00 0A, Tl为0102oPC÷PLCw: 0110 06 00 02 00 04 00 OA 01 02 D6 CR LFPaPC ":oi io 06 oo oo 02 E7 cr lf”Field Name Example (Hex)Heading 3ASlave Address 01Starting Address Hi 06Starting Address Lo 00Number of Registers Hi 00Number of Registers Lo 02Error Check ( LRC ) E7Returns a description of controller present at the slave address, the current status of the slave Runindicator, and other information specific to the slave device(>Field Name Example (Hex)Heading 3ASlave Address 01Function 11Error Check (LRC) EE附录一 15Field Name Example (Hex)Heading 3ASlave Address 01Function 11Byte Count 04SIaveIDOlRun Indicator Status00 = OFFFF = ONFFDataO (D1001 HI) 40Data 1 (D1001 LOW) 10Error Check (LRC) 9A附录一 16台达DVP系列PLC装置地址(DEVICE ADDRESS)Device Range Effective Range AddressS 000255 000127 OoOOOOFFS 246511 0100-01FFS512767 020002FFS 7681023 030003FFX 000-377(8 进制)OOO177 (8 进制)040004FFY000377(8 进制)000177 (8 进制)050005FFT OoO255 OOo127 0600-06FFM OOO255 0000-1279 0800-08FFM 256511 0900-09FFM 512767 OAOO-OAFFM 7681023 OBOo OBFFM 10241279 OCoOOCFFC 000255 000127232255OEooOEFFD OOO255 Ooo599 IOOOIOFFD 256511 IOOo1143 11OO-11FFD 512767 120012FFD 10241279 140014FF