CPM2A_PROGRAMMING MANUAL (W353-E1-2) (986750), страница 36
Текст из файла (страница 36)
A power supply of 5 VDC is supplied to theRS-232C/RS-422 Conversion Adapter. With the CPM2C, the CPM2C-CN111221SectionCPM2A/CPM2C Communications Functions4-3and CS1W-CN118 connecting cables can be used in place of the RS-232CAdapter.NT-AL001 RS-232C/RS-422Conversion AdapterSignalPin No.RS-232C portSignal Pin No.HoodNote Do not connect external devices other than the NT-AL001 Conversion Adapterto the 5 VDC power supply of pin number 6 on the CPM2A/CPM2C’s RS-232Cport. Doing so may result in damage to the CPM2A/CPM2C or to the externaldevice.The PC Setup settings that are required depend on whether a peripheral port oran RS-232C port is used.Settings for RS-232C PortPC SetupWordDM 6645Bit00 to 03FunctionPort settings0: Standard (1 start bit, 7-bit data, 2 stop bits, even parity, 9,600 bps; HostLink unit number: 0)SettingMatch hostparameters1: Settings in DM 664604 to 0708 to 1112 to 15DM 664600 to 07(Other settings will cause a non-fatal error, the default setting will be used,and AR 1302 will turn ON.)CTS control settings0 or 10: Disable; 1: SetLink words for 1:1 PC LinkAny0: LR 00 to LR 15; Other: Not effectiveCommunications mode00: Host Link (default setting); 1: RS-232C (no-protocol); 2: 1:1 PC Link Slave;3: 1:1 PC Link Master; 4: 1:1 NT Link(Other settings will cause a non-fatal error, the Host Link setting will be used,and AR 1302 will turn ON.)Baud rate:00: 1,200 bps 01: 2,400 bps 02: 4,800 bps 03: 9,600 bps 04: 19,200 bps08 to 15DM 664700 to 15Frame 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 beused, and AR 1302 will turn ON.)Transmission delay (Host Link)0000 to 9999 (BCD): Set in units of 10 ms, e.g., setting of 0001 equals 10 ms(Other settings will cause a non-fatal error, the default setting (0000) will beused, and AR 1302 will turn ON.)222Match hostparameters0000 to 9999SectionCPM2A/CPM2C Communications FunctionsWordDM 6648Bit00 to 0708 to 1112 to 15Function00 to 31 (BCD): Node number (Host Link)(Other settings will cause a non-fatal error, the default setting (00) will beused, and AR 1302 will turn ON.)Start 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, LF4-3Setting00 to 31AnyAny(Other settings will cause a non-fatal error, the disable setting will be used,and AR 1302 will turn ON.)DM 664900 to 0700 to 15Start code (01 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.)AnyAnySettings for Peripheral PortWordDM 6650Bit00 to 03FunctionPort settings0: Standard (1 start bit, 7-bit data, 2 stop bits, even parity, 9,600 bps; HostLink unit number: 0)SettingMatch hostparameters1: Settings in DM 665104 to 1112 to 15(Other settings will cause a non-fatal error, the default setting (0) will beused, and AR 1302 will turn ON.)Not usedCommunications mode0: Host Link or peripheral bus; 1: No-protocol00(Other settings will cause a non-fatal error, the Host Link setting (0) will beused, and AR 1302 will turn ON.)DM 665100 to 07Baud rate08 to 1500: 1,200 bps, 01: 2,400 bps, 02: 4,800 bps, 03: 9,600 bps, 04: 19,200 bpsFrame format00:01:02:03:04:05:06:07:08:09:10:11:Start111111111111Length Stop717171727272818181828282Match hostparametersParityEvenOddNoneEvenOddNoneEvenOddNoneEvenOddNone(Other settings will cause a non-fatal error, the default settings (03) will beused, and AR 1302 will turn ON.)DM 665200 to 15Transmission delay (Host Link)0000 to 9999 (BCD): Set in units of 10 ms.0000 to 9999(Other settings will cause a non-fatal error, the default setting (0000) will beused, and AR 1302 will turn ON.)223SectionCPM2A/CPM2C Communications FunctionsWordDM 6653Bit00 to 07FunctionNode number (Host Link)00 to 31 (BCD)4-3Setting00 to 31(Other settings will cause a non-fatal error, the default setting (03) will beused, and AR 1302 will turn ON.)08 to 11Start code enable (Peripheral port)0: Disable1: Use start code in DM 6654.Any12 to 15End code enable (Peripheral port)0: Disable (number of bytes received)1: Use end code in DM 6654.2: CR, LFAny(Other settings will cause a non-fatal error, the disable setting (0) will beused, and AR 1302 will turn ON.)DM 665400 to 07Start code(Peripheral port, effective when bits 08 to 11 of DM 6653 are set to 1.)01 to FF (Hex)Any08 to 15No.
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.)AnyThis example shows a BASIC program that reads the status of the CPM2A/CPM2C’s inputs in IR 000. For more details see 4-5 Host Link Commands.An FCS (frame check sequence) check isn’t performed on the received response data in this program.Be sure that the host computer’s RS-232C port is configured correctly beforeexecuting the program.1000 ’ ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––1010 ’ CPM2A/CPM2C Sample Program for BASIC1020 ’1050 ’ ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––1060 ’ –––Set value RS–232C SPEED:9600BPS,PARITY:EVEN,DATA:7,STOP:2–––1070 OPEN ”COM:E73” AS #11080 *REPEAT1090 –––Transmission data input–––––––––––––––––––––––––––––––––––––––––––––––1100 INPUT ” send data : ”,send$1110 ’ –––FCS Calculation–––––––––––––––––––––––––––––––––––––––––––––––1120 FCS=01130 FOR IFCS = 1 TO LEN ( send$ )1140FCS = FCS XOR ASC( MID$ ( SEND$ , IFCS , 1 ) )1150 NEXT1160 FCS$ = RIGHT$ ( ”0” + HEX$ ( FCS ) , 2 )1170 ’ –––Communications execute–––––––––––––––––––––––––––––––––––––––––––––––1180 ZZZ$ = SEND$ + SCS$ + ”*” + CHR$(13)1190 PRINT #1 , ZZZ$ ;1200 ’ –––Response check–––––––––––––––––––––––––––––––––––––––––––––––1210 RECCNT = 0 : TMP$ – ””1220 *DRECLOOP1230 IF LOC ( 1 ) < > 0 THEN *DREC11240 RECCNT = RECCNT + 11250 IF RECCNT = 5000 THEN *DRECERR ELSE *DRECLOOP1260 *DREC11270 TMP$ = TMP$ + INPUT$ ( LOC (1 ) , #1 )1280 IF RIGHT$ ( TMP$ , 1 ) = CHR$ (13) THEN *DRECEND ELSE RECCNT = 0 : GOTO *DRECLOOPIssuing Commands froma Host Computer224SectionCPM2A/CPM2C Communications Functions1290130013101320134013501360137013804-3*DRECERRTMP$ = ” No response !! ” + CHR$ ( 13 )*DRECENDPRINT ” receive data : ” ; RECV$’ –––Go to transmission data input––––––––––––––––––––––––––––––––––––––––GOTO *REPEAT’ –––Processing complete–––––––––––––––––––––––––––––––––––––––––––––––CLOSE #1ENDLadder Program(Mnemonics)The unsolicited Host Link communications are executed using TXD(48).MnemonicControl(@)TXD(48) Communications portoutputContentsReads data from I/O memory and transmitsit in the specified frame format.Host Link communications are controlled with the following AR area flags.WordAR 08Bit(s)Contents00 to 03RS-232C Port Error Code0: Normal completion1: Parity error2: Frame error3: Overrun error04RS-232C Communications Error FlagON: RS-232C port communications error occurredOFF: Normal05RS-232C Transmit Ready FlagON: The PC is ready to transmit data.Peripheral Port Error Code0: Normal completion1: Parity error2: Frame error3: Overrun error08 to 111213Peripheral Port Communications Error FlagON: Peripheral port communications error occurred.Peripheral Port Transmit Ready FlagON: The PC is ready to transmit data.Unsolicited CommunicationsA data transmission to the host computer is initiated by the PC.(@)TXD(48)SS: Leading address of data to be transmittedCC: Control dataNN: Number of bytes to be transmitted (BCD: 0001 to 0061)Communications port0: RS-232 port; 1: Peripheral portWhen Host Link communications are being used, TXD(48) converts the N-bytesof data starting at S to ASCII, adds the Host Link header, FCS, and terminator,and transmits this data as a Host Link frame.225SectionCPM2A/CPM2C Communications Functions4-3The transmitted Host Link frame will be as shown in the following diagram.Converted to ASCII.N bytesData (ASCII)Node No.↵In the following program example TXD(48) is used to transmit data from anRS-232C port to a host computer.