f0comex4.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 read data

18           REM from a serial device (scale, bar code, etc), parse numeric

20           REM data from the string and write the numeric data to the PLC

22           REM

24           REM This example assumes that the data is in the following format:

26           REM ##.#CRLF

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 Data”

130         REM —

132         INPUT3 ,$(0) :  REM Input Data to String 0 ($(0))

134         IF INPLEN=0 THEN  PRINT1 “Device Timed Out” :  GOTO 130

136         SDTA=VAL(MID$($(0),1,4)) :  REM Parse Data from String

137         SDTA=SDTA*10 : REM Multiply out decimal place / will be implied in PLC

138         S06_VB(2000)=INT(SDTA) : REM Write Data to PLC

140         PRINT1 “Data= “,SDTA

160         REM —

162         GOTO 130 :  REM Loop

×