CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 35
Текст из файла (страница 35)
When a transmission issplit, the ends of the first and intermediate frames are marked by a delimiterinstead of a terminator.214SectionCPM2A/CPM2C Communications FunctionsDividing Commands4-3As each frame is transmitted by the host computer, the computer waits for thedelimiter to be transmitted from the CPM2A/CPM2C. After the delimiter hasbeen transmitted, the next frame will then be sent.
This procedure is repeateduntil the entire command has been transmitted.Frame 2 (command)Frame 1 (command)Frame 3 (command)Unit no.Header codeHostcomputerTextTextTextFCSDelimiterFCSDelimiterFCSTerminatorDelimiterCPM2A/CPM2CDelimiterUnit no.Header codeEnd codeTextFCSTerminatorFrame (response)Dividing ResponsesAs each frame is received by the host computer, a delimiter is transmitted to theCPM2A/CPM2C. After the delimiter has been transmitted, the CPM2A/CPM2Cwill transmit the next frame. This procedure is repeated until the entire responsehas been transmitted.Frame (command)Unit no.Header codeHostcomputerTextFCSTerminatorDelimiterUnit no.Header codeEnd codeCPM2A/CPM2CTextFCSDelimiterDelimiterTextTextFCSDelimiterFCSTerminatorFrame2 (response)Frame3 (response)Frame1 (response)215SectionCPM2A/CPM2C Communications FunctionsPrecautions for LongTransmissionsFrame 1@4-3When dividing commands such as WR, WL, WC, or WD that execute write operations, be careful not to divide into separate frames data that is to be writteninto a single word.
As shown in the illustration below, be sure to divide frames sothat they coincide with the divisions between words.(131 characters maximum)00x101 x100WNodeNo.↵DataDHeadercodeFCSOne word of dataDelimiterData from the same word is not divided.Frame 2 (128 characters maximum)↵*DataOne word of dataTerminatorFCSData from the same word is not divided.FCS (Frame Check Sequence)When a frame is transmitted, an FCS is placed just before the delimiter or terminator in order to check whether any data error has been generated.
The FCS is8-bit data converted into two ASCII characters. The 8-bit data is the result of anEXCLUSIVE OR performed on the data from the beginning of the frame until theend of the text in that frame (i.e., just before the FCS). Calculating the FCS eachtime a frame is received and checking the result against the FCS that is includedin the frame makes it possible to check for data errors in the frame.@10RR000Node No.
Header codeText142FCSFCS calculation rangeASCII code@10R00→→→→→→403130523030→→→→→→LeftmostRightmost01000000XOR00110001XOR00110000XOR01010010XOR00110000XOR00110000XORto0→1→Calculation results2163031→→00110000XOR00110100↓↓4200010010Converted to hexadecimal.Handled as ASCII characters.*↵TerminatorCPM2A/CPM2C Communications FunctionsSection4-3This example shows a BASIC subroutine program for executing an FCS checkon a frame received by the host computer.Normal reception data includes the FCS, delimiter or terminator, and so on.When an error occurs in transmission, however the FCS or some other data maynot be included. Be sure to program the system to cover this possibility.––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––400 *FCSCHECK410 L = LEN ( RESPONSE$ ) ’ .
........................ Data transmitted and received420 Q = 0 : FCSCK$ = ” ”430 A$ = RIGHT$ ( RESPONSE$ , 1)440 PRINT RESPONSE$ , A$ , L450 IF A$ = ”*” THEN LENGS = LEN ( RESPONSE$ ) – 3ELSE LENGS = LEN ( RESPONSE$ ) – 2460 FCSP$ = MID$ ( RESPONSE$ , LENGS + 1 , 2 ) ’ . ......... FCS data received470 FOR I = 1 TO LENGS ’ . ........................
Number of characters in FCS480Q = ASC ( MID$ ( RESPONSE$ , I , 1 ) ) XOR Q490 NEXT I500 FCSD$ = HEX$ ( Q )510 IF LEN ( FCS0$ ) = 1 THEN FCSD$ = ” 0 ” + FCSD$ ’ . ........ FCS result520 IF FCSD$ < > FCSP$ THEN FCSCK$ = ” ERR ”530 PRINT ” FCSD$ = ” ; FCSD$ , ” FCSP$ = ” ; FCSP$ , ” FCSCK$ = ” ; FCSCK$540 RETURN––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––Example Program forFCS217SectionCPM2A/CPM2C Communications Functions4-3CommandsHeadercodeCPM2A/CPM2C Operating ModeNamePageRRRUNValidMONITORValidPROGRAMValidIR/WR/SR AREA READ254RLValidValidValidLR AREA READ255RHValidValidValidHR AREA READ255RCValidValidValidTC PV READ256RGValidValidValidTC STATUS READ256RDValidValidValidDM AREA READ257RJValidValidValidAR AREA READ257WRNot ValidValidValidIR/WR/SR AREA WRITE258WLNot ValidValidValidLR AREA WRITE259WHNot ValidValidValidHR AREA WRITE259WCNot ValidValidValidTC PV WRITE260WGNot ValidValidValidTC STATUS WRITE260WDNot ValidValidValidDM AREA WRITE261WJNot ValidValidValidAR AREA WRITE262R#ValidValidValidSV READ 1262R$ValidValidValidSV READ 2263W#Not ValidValidValidSV CHANGE 1264W$Not ValidValidValidSV CHANGE 2265MSValidValidValidSTATUS READ266SCValidValidValidSTATUS WRITE267MFValidValidValidERROR READ268KSNot ValidValidValidFORCED SET269KRNot ValidValidValidFORCED RESET270FKNot ValidValidValidMULTIPLE FORCED SET/RESET271KCValidValidValidFORCED SET/RESET CANCEL272MMValidValidValidPC MODEL READ273TSValidValidValidTEST273RPValidValidValidPROGRAM READ274WPNot ValidNot ValidValidPROGRAM WRITE274QQValidValidValidCOMPOUND COMMAND275XZValidValidValidABORT (command only)277**ValidValidValidINITIALIZE (command only)277EXValidValidNot ValidTXD RESPONSE (response only)277IC---------Undefined command (response only)278Note ---: Not affected by the mode.218SectionCPM2A/CPM2C Communications Functions4-3Response CodesEndcode00Normal completion---01Not executable in RUN modeThe command that was sent cannot be executed when the PC is inRUN mode.02Not executable in MONITOR modeThe command that was sent cannot be executed when the PC is inMONITOR mode.04Address overCheck the program.0BNot executable in PROGRAMmodeThe user program area’s highestaddress was exceeded.The command that was sent cannot be executed when the PC is inPROGRAM mode.13FCS errorThe FCS is wrong.
Either the FCScalculation is mistaken or there isadverse influence from noise.Check the FCS calculation method.If there was influence from noise,transfer the command again.14Format errorThe command format is wrong.15Entry number data error16Command not supportedThe read/write area specification iswrong.The specified command does notexist in the specified address.(Reading the SV, etc.)Check the format and transfer thecommand again.Correct the areas and transfer thecommand again.Check the address and instruction.18Frame length error19Not executable23User memory write-protectedA3Aborted due to FCS error in transmit dataAborted due to format error intransmit dataAborted due to entry number dataerror in transmit dataAborted due to frame length errorin transmit data---A4A5A8OtherContentsProbable causeThe maximum frame length wasexceeded.Items to read not registered forcomposite command (QQ).The memory is write-protected inthe PC Setup.The error was generated while acommand extending over morethan one frame was beingexecuted.Corrective measures--Check the relation between thecommand and the PC mode.This code is not presently beingused.Divide the command into multipleframes.Execute QQ to register items toread before attempting batch read.Change the setting in the PC Setup(DM 6602).Check for corrupted frames, correctif necessary, and try the transferagain.Note: The data up to that point hasalready been written to the appropriate area of the CPU Unit.Influence from noise was received.Transfer the command again.Application ProcedureSetting the CPU Unit’scommunications switchConnecting the cablesCommands issued from the hostcomputer.Set the CPM2A CPU Unit’s communications switchor the CPM2C CPU Unit’s DIP switch.Make the 1:1 or 1:N connection.Ladder program(Communications initiated byCPM2A/CPM2C)219SectionCPM2A/CPM2C Communications FunctionsCommunications SwitchSetting4-3The CPM2A’s communications are controlled by the communications switch onthe front of the CPU Unit and the CPM2C’s communications are controlled bythe DIP switch on the front of the CPU Unit.CPM2A Communications Switch SettingWhen the communications switch is set to OFF, communications through the peripheral port and RS-232C port are governed by the settings in the PC Setup.When the communications switch is set to ON, communications through the peripheral port and RS-232C port are governed by the standard Host Link settings(1 start bit, 7 data bits, 2 stop bits, even parity, and 9,600 bps baud rate).Note When a Programming Console is connected to the peripheral port, communications with the Programming Console are unaffected by either the communications switch or PC Setup.Communications switchPeripheral portRS-232C portAn RS-232C Adapter is needed to perform Host Link communications from aperipheral port.CPM2C DIP Switch SettingsWhen pin 2 of the DIP switch is set to OFF, communications through the peripheral port are set to Programming Console protocol, regardless of the setting ofpin 1 or the settings in the PC Setup.DIP Switch220SectionCPM2A/CPM2C Communications Functions4-3When pin 2 is set to ON, the status of pin 1 determines whether communicationsthrough the peripheral port and RS-232C port are governed by the settings in thePC Setup or the standard settings (1 start bit, 7 data bits, 2 stop bits, even parity,and 9,600 bps baud rate).Pin settingsPin 1OFFOFFPin 2OFFONONONOFFONPeripheral portcommunicationsProgramming Console protocolGoverned by the PC Setup(DM 6650 to DM 6654)Programming Console protocolGoverned by standard settingsRS-232C portcommunicationsGoverned by the PC Setup(DM 6645 to DM 6649)Governed by standard settingsAn RS-232C Adapter is needed to perform Host Link communications from aperipheral port.Connecting the CablesThis section describes RS-232C connections.One-to-one ConnectionsThe RS-232C port on the Host Link computer and the RS-232C port on theCPM2A/CPM2C or CPM1-CIF01 RS-232C Adapter are connected as shown inthe following diagram when there is no CTS control on the RS-232C port.
Withthe CPM2C, the CPM2C-CN111 and CS1W-CN118 connecting cables can beused in place of the RS-232C Adapter.IBM PC/AT or compatibleSignalPin No.RS-232C portSignalPin No.HoodOne-to-N ConnectionsSet the DIP switch on the NT-AL001 RS-232C/RS-422 Conversion Adapter.Normally ONON when the Unit is at the end of the transmission path. OFF in all other cases.Used as a 4-conductor method. (Both switches set to OFF)According to RS-232C CTS control (5: OFF, 6: ON)The RS-232C port with the NT-AL001 RS-232C/RS-422 Conversion Adapterand the RS-232C port of the CPM2A/CPM2C or CPM1-CIF01 RS-232C Adapterare connected as shown in the following diagram when there is no CTS controlon the RS-232C port.