f0comex8.abm (F0-CP128)
10 REM ***
12 REM Example Communication Program for F0-CP128
14 REM
16 REM This is a generic example showing how to
18 REM trigger a request to a serial device using C0,
20 REM input the response, parse the numeric data, and
22 REM write the parsed data to V2000
24 REM
30 REM This example assumes that response is in the following format:
32 REM ####.##gCRLF
100 REM ***
102 STRING 2551,254 : REM Allocate String Space 10*254 Strings
104 SETPORT 1,9600,N,8,1,N : REM Programming/Monitoring
106 SETPORT 3,9600,N,8,1,N : REM Scale
108 SETINPUT 1,1,10,0,1000,20 : REM Define how INPUT will work
110 REM —
112 PRINT1 “Waiting for C0 Trigger”
114 DO : UNTIL S06_C(0) : REM Ladder SETs C0 to trigger request
116 S06_C(0)=0 : REM CoPro Turns off C0
120 REM —
122 PRINT1 “Requesting Data”
124 PRINT3 “S” : REM Send Request S plus CRLF
130 REM —
132 INPUT3 ,$(0) : REM Input Data to String 0 ($(0))
134 IF INPLEN=0 THEN PRINT1 “Device Timed Out” : GOTO 110
136 PRINT1 “Response= “,$(0)
138 SDTA=VAL(MID$($(0),1,7)) : REM Parse Data from String
140 S06_VB(2000)=INT(SDTA) : REM Write Integer Data to PLC in BCD Format
150 PRINT1 “Parsed Data= “,SDTA
160 REM —
162 GOTO 110 : REM Loop to wait for next trigger