CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 37
Текст из файла (страница 37)
If AR 0805 (the RS-232C Transmit ReadyFlag) is ON when IR 00100 turns ON, the ten bytes of data (DM 0100 toDM 0104) will be transmitted to the host computer, leftmost bytes first.(48)Leading address of data to be transmittedRS-232C port specification10 bytes4-3-2 No-protocol CommunicationsOverviewWhen no-protocol communications are used, data can be exchanged with serialdevices such as bar code readers and serial printers using TXD(48) andRXD(47). No-protocol communications can be used with either an RS-232Cport or peripheral port.226SectionCPM2A/CPM2C Communications Functions4-3CPM2A ConnectionsCPM2A CPU UnitRS-232C devicesBar code readerSerial printerOtherRS-232C portCPM1-CIF01 RS-232C Adapter(CTS control cannot be used.)CPM2A CPU UnitRS-232C devicesBar code readerSerial printerOtherPeripheral portCPM2A CPU UnitRS-232C devicesCQM1-CIF01/02 RS-232C Adapter(CTS control cannot be used.)Bar code readerSerial printerOtherPeripheral portCPM2C ConnectionsCPM2C CPU UnitRS-232C devicesBar code readerSerial printerOtherNote A CPM1-CIF01 RS-232C Adapter can also be used for no-protocol communications through the peripheral port, or for a CPM2C, a CPM2C-CIF01 Peripheral/RS-232C Adapter Unit can be used to connect to external devices.
Refer to theCPM2C Operation Manual for details.Transmission Data ConfigurationWhen no-protocol communications are used, TXD(48) is used to send data andRXD(47) to receive data. The maximum amount of data that can be either sent orreceived is 259 bytes, including the start and end codes.227SectionCPM2A/CPM2C Communications Functions4-3No Start or End Code:Data (Specified No. of bytes)Only a Start Code:STData (Specified No.
of bytes)Only an End Code:Data (256 bytes max.)EDBoth a Start and End Code:STData (256 bytes max.)EDEnd Code of CR, LF:Data (256 bytes max.)CRLFCRLFStart Code 00-FF/End Code CR,LF:Data (256 bytes max.)STNote1. The start and end codes are set in DM 6648 to DM 6649 (RS-232C) orDM 6653 to DM 6654 (peripheral port) in the PC Setup.2. When there are several start or end codes in the transmission, the first ofeach will be effective.3. When the end code is accidentally duplicated in the transmission data andthe transmission is stopped part way through, use CR and LF as the endcode.4. The start and end codes themselves are not transmitted and received.Transmission FlagsWhen sending data from the CPM2A/CPM2C, check that the Transmission Enable Flag is ON for executing TXD(48).
The Transmission Enable Flag will turnOFF while the data is being transmitted and will turn ON again when transmission is complete.After the CPM2A/CPM2C has received data, the Receive Enable Flag turns ON.When RXD(47) is executed, the data received will be written to the specifiedwords and the Reception Complete Flag will turn OFF.FlagPeripheral portRS-232C portTransmit Ready FlagAR 0813AR 0805Reception Completed FlagAR 0814AR 0806Note The CPM2A/CPM2C starts and completes data reception at the followingpoints:Reception Start:Start code disabled:Start code enabled:Continually available for receptionAfter start code is receivedReception Complete:When either the end code, the specified no. of bytes, or 256 bytes are received.228SectionCPM2A/CPM2C Communications Functions4-3Application ProcedureSetting the Communications switchSet the CPM2A CPU Unit’s communications switch orthe CPM2C CPU Unit’s DIP switch.Connecting the cablesMake the RS-232C connection with the serial device.Ladder programCommunications SwitchSettingThe 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 SettingTurn OFF the Communications switch when using no-protocol communications.No-protocol communications will not be possible if the communications switch isON.Communications switchPeripheral portRS-232C portNote An RS-232C adapter is required for no-protocol communications on the peripheral port.CPM2C DIP Switch SettingsTurn OFF pin 1 of the DIP switch when using no-protocol communications sothat communications through the RS-232C port are governed by the settings in229SectionCPM2A/CPM2C Communications Functions4-3the PC Setup (DM 6645 to DM 6649).
When performing no-protocol communications through the peripheral port, turn ON pin 2 as well.Communications port setting switchPin 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 settingsNote An RS-232C Adapter is needed to perform no-protocol communications throughthe peripheral port.Connecting the CablesThis section describes RS-232C connections.The RS-232C port on the serial device and the RS-232C port of the CPM2A/CPM2C or CPM1-CIF01 RS-232C Adapter are connected as shown in the following diagram.
With the CPM2C, the CPM2C-CN111 and CS1W-CN118 connecting cables can be used in place of the RS-232C Adapter.RS-232C portSignalPin No.Serial device RD (receive data)Serial device SD (send data)Serial device SG (signal ground)HoodPC Setup230The PC Setup settings that are required depend on whether a peripheral port oran RS-232C port is used.SectionCPM2A/CPM2C Communications Functions4-3Settings for RS-232C PortWordDM 6645Bit00 to 03FunctionPort settings0: Standard (1 start bit, 7-bit data, 2 stop bits, even parity, 9,600 bps; Host Linkunit number: 0)SettingAs required1: Settings in DM 664604 to0708 to 1112 to 15(Other settings will cause a non-fatal error, the default setting will be used, and AR1302 will turn ON.)CTS control settings0: Disable; 1: SetLink words for 1:1 PC Link0: LR 00 to LR 15; Other: Not effectiveCommunications mode0: Host Link; 1: No-protocol; 2: 1:1 PC Link Slave; 3: 1:1 PC Link Master; 4: 1:1 NTLinkAny1(Other settings will cause a non-fatal error, the Host Link setting will be used, andAR 1302 will turn ON.)DM 664600 to 0708 to 15Baud rateAs required00: 1,200 bps; 01: 2,400 bps; 02: 4,800 bps; 3: 9,600 bps; 04: 19,200 bpsFrame formatStart Length Stop Parity00:171Even01:171Odd02:171None03:172Even04:172Odd05:172None06:181Even07:181Odd08:181None09:182Even10:182Odd11:182None(Other settings will cause a non-fatal error, the default settings (03) will be used,and AR 1302 will turn ON.)DM 664700 to 15Transmission delay (Host Link)0000 to 9999 (BCD): Set in units of 10 ms, e.g., setting of 0001 equals 10 ms0000 to9999(Other settings will cause a non-fatal error, the default setting (0000) will be used,and AR 1302 will turn ON.)DM 664800 to 0700 to 31 (BCD): Node number (Host Link)As required(Other settings will cause a non-fatal error, the default setting (00) will be used, andAR 1302 will turn ON.)08 to 11Start code enable (RS-232C)0: Disable; 1: Use start code in DM 6649.End code enable (RS-232C)0: Disable (number of bytes received)1: Use end code in DM 6649.2: CR, LF12 to 150 or 10 to 2(Other settings will cause a non-fatal error, the default setting (0) will be used, andAR 1302 will turn ON.)DM 664900 to 0708 to 15Start code (00 to FF)(No-protocol, effective when bits 8 to 11 of DM 6648 are set to 1.)No.
of bytes of data received(No-protocol, effective when bits 12 to 15 of DM 6648 are set to 0.)00: 256 bytes01 to FF: 1 to 255 bytesEnd code (00 to FF)(No-protocol, effective when bits 12 to 15 of DM 6648 are set to 1.)00 to FF00 to FF00 to FF231SectionCPM2A/CPM2C Communications Functions4-3Settings for Peripheral PortWordDM 6650Bit00 to 03FunctionPort settings0: Standard (1 start bit, 7-bit data, 2 stop bits, even parity, 9,600 bps; Host Linkunit number: 0)SettingAs required1: Settings in DM 665104 to 1112 to 15(Other settings will cause a non-fatal error, the default setting (0) will be used, andAR 1302 will turn ON.)Not usedCommunications mode0: Host Link or peripheral bus; 1: No-protocol01(Other settings will cause a non-fatal error, the Host Link setting will be used, andAR 1302 will turn ON.)DM 665100 to 0708 to 15DM 665200 to 15Baud rate00: 1,200 bps; 01: 2,400 bps; 02: 4,800 bps; 03: 9,600 bps; 04: 19,200 bpsFrame formatStart Length Stop Parity00:171Even01:171Odd02:171None03:172Even04:172Odd05:172None06:181Even07:181Odd08:181None09:182Even10:182Odd11:182None(Other settings will cause a non-fatal error, the default settings (03) will be used,and AR 1302 will turn ON.)Transmission delay (Host Link)0000 to 9999 (BCD): Set in units of 10 ms.As required0000 to9999(Other settings will cause a non-fatal error, the default setting (0000) will be used,and AR 1302 will turn ON.)DM 665300 to 0700 to 31 (BCD): Node number (Host Link)08 to 11(Other settings will cause a non-fatal error, the default setting (00) will be used, andAR 1302 will turn ON.)Start code enable (Peripheral port)0 or 10: Disable1: Use start code in DM 6654.12 to 15End code enable (Peripheral port)0: Disable (number of bytes received)1: Use end code in DM 6654.2: CR.
LFAs required0 to 2(Other settings will cause a non-fatal error, the default setting (0) will be used, andAR 1302 will turn ON.)DM 665400 to 0708 to 15232Start code (00 to FF)(Peripheral port, effective when bits 8 to 11 of DM 6653 are set to 1.)No.
of bytes of data received(Peripheral port, effective when bits 12 to 15 of DM 6653 are set to 0.)00: 256 bytes01 to FF: 1 to 255 bytesEnd code (00 to FF)(Peripheral port, effective when bits 12 to 15 of DM 6653 are set to 1)00 to FF00 to FF00 to FFSectionCPM2A/CPM2C Communications Functions4-3The following instructions are used in no-protocol communications.ProgramMnemonicControlContents(@)TXD(48)Communicationsport outputReads data from I/O memory and transmits it inthe specified frame format (the start and endcodes can be enabled/disabled).(@)RXD(47)Communicationsport inputReceives data in the specified frame format (thestart and end codes can be enabled/disabled)and stores only the data in I/O memory.No-protocol communications are controlled with the following AR area flags.WordAR 08Bit(s)Contents00 to 03RS-232C Port Error Code0: Normal completion;1: Parity error;2: Frame error;3: Overrun error04RS-232C Communications Error FlagON: RS-232C port communications error occurred.OFF: Normal05RS-232C Transmit Ready FlagON: The PC is ready to transmit data.RS-232C Reception Completed FlagON: The PC has completed reading data.RS-232C Reception Overflow FlagON: A reception overflow has occurred.Peripheral Port Error Code0: Normal completion;1: Parity error;2: Frame error;3: Overrun error060708 to 1112Peripheral Port Communications Error FlagON: A peripheral port communications error occurred.OFF: Normal13AR 0900 to 15Peripheral Port Transmit Ready FlagON: The PC is ready to transmit data.Peripheral Port Reception Completed FlagON: The PC has completed reading data.Peripheral Port Reception Overflow FlagON: A reception overflow has occurred.RS-232C Port Reception Counter (4 digits BCD)AR 1000 to 15Peripheral Port Reception Counter (4 digits BCD)1415No-protocol Data TransmissionTXD(48) is used to transmit data to RS-232C devices.(@)TXD(48)SS: Leading address of data to be transmittedCC: Control dataNN: Number of bytes to be transmitted (BCD: 0001 to 0256)Storage order0: Leftmost bytes first 1: Rightmost bytes firstCommunications port0: RS-232C port 1: Peripheral portWhen no-protocol communications are being used, TXD(48) transmits N bytesof data beginning at S.233SectionCPM2A/CPM2C Communications Functions4-3No-protocol Data ReceptionRXD(47) is used to receive data from RS-232C devices.(@)RXD(47)SD: Leading address for storing reception dataCC: Control dataN: Number of bytes to receive (BCD: 0001 to 0256)NStorage order0: Leftmost bytes first 1: Rightmost bytes firstCommunications port0: RS-232C port 1: Peripheral portThe following program example is for no-protocol communications conductedthrough a RS-232C port using TXD(48) and RXD(47) instructions.If AR 0805 (the RS-232C Transmit Ready Flag) is ON when 00100 turns ON,then data from DM 0100 to DM 0104 is transmitted from leftmost bytes to rightmost bytes.