f2comex5.abm (F2-CP128)
10 REM ***
12 REM Example Communication Program for F2-CP128
14 REM
16 REM This is a generic example showing how to read data
18 REM from a bar code reader, parse data from the string
20 REM and write the numeric and ASCII code data to the PLC
22 REM
24 REM This example assumes that the data is in the following format:
25 REM PPPPPSLLPJJJUUUUUUU CR
26 REM PPPPP = Product Number
27 REM S = Shift Number
28 REM LL = Line Number
29 REM P = Plant Number
30 REM JJJ = Julian Day
31 REM UUUUUUU = Undefined Characters
32 REM Carriage Return Terminated String
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 2,9600,N,8,1,N : REM Scale
108 SETINPUT 1,1,13,0,1000,20 : REM Define how INPUT will work
110 REM —
112 PRINT1 “Waiting for Data”
130 REM —
132 INPUT2 ,$(0) : REM Input Data to String 0 ($(0))
134 IF INPLEN=0 THEN PRINT1 “Device Timed Out” : GOTO 130
136 REM $(0)=”12345SLLPJJJxxxxxxx” : REM Test String
140 REM *** Parse and Write Product Number to PLC
142 SDTA=VAL(MID$($(0),1,5)) : REM Parse 5 Digit Product Number
144 S205_VH(2000)=SDTA : REM Write to PLC in BIN Format
146 PRINT1 “Product Number = “,SDTA
150 REM *** Write String to a block of V-Memory in PLC
152 FOR X=0 TO LEN($(0))-1 STEP 2
154 SHARED(129+X,L)=ASC($(0),X+1)
156 SHARED(128+X,L)=ASC($(0),X+2)
157 NEXT X
158 BMOVE W,VH(2010),K(20)
160 REM —
162 REM GOTO 130 : REM Loop