Re: input on comm ports


[ Follow Ups ] [ Post Followup ] [ Internet PLC Forum ] [ FAQ ]

Posted ByLeon on November 14, 2001 at 23:10:55:

In Reply to: input on comm ports posted bycharlie sims on November 14, 2001 at 20:40:07:

Yes, it is really easy! Write a custom function that contains the following lines:

A$ = INPUT$(1)
IF LEN(A$)<> 0 ' A string is available
CTRPV[1] = VAL(A$)
ENDIF

If there is nothing from the serial input port #1, INPUT$(1) returns an empty string, otherwise it returns a CR terminated ASCII string to A$. You then convert the string into integer using the VAL(x$) command and then assign it to a counter present value. Even if the string contains other characters, you can use the MID$() function to extract the value portion in order to convert to an integer.

: can i read a 4 digit ascii number from a serial output barcode reader into the plc counter? reader is model 20 accusort.




Follow Ups



Post Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ Internet PLC Forum ] [ FAQ ]