Author Topic: input$  (Read 10033 times)

tkidder2

  • Newbie
  • Posts: 6
  • I love YaBB 1G - SP1!
    • View Profile
input$
« on: March 25, 2005, 09:07:08 AM »
I am having a lot of difficulty receiving serial data
from a barcode scanner
using the input$(1) function.

After a bad code has been detected by the laser
the plc immediately looks for the data makeing up the
incorrect barcode. Instead of the offending barcde, I usually get previous data or half the data.

If I continue to trigger the laser, eventually the T100MD
will capture the correct data. I know that the laser is transmitting correctly because i can test its output on a terminal.

Any help would be appreciated.
 

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:input$
« Reply #1 on: March 25, 2005, 09:14:19 AM »
Does a bad barcode ended with a Carriage Return (CR - ASCII 13)? INPUT$(1) only report the whole string received that is terminated with the CR character. If the bad barcode does not terminate with the CR then the data are stored in the buffer until the CR is received which means that the bad barcode could be mixed with the good bar code.

If that is a concern, then you could CALL a custom function containing the following codes to clear the buffer in the serial port before attempting to read the next barcode:

  FOR I = 1 to 256
      IF INCOMM(1) < 0: RETURN : ENDIF
  NEXT

That will ensure that there will be no more bad character in the serial port before you attempt the next read.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS