logo Welcome, Guest. Please Login or Register.
July 22, 2018, 04:23:55 AM
Home Help Search Login Register
 News: Self-Registration temporarily suspended due to abuse.To Register as a member, please email to webmaster@triplc.com with your email and username.

  Internet PLC Forum
  General
  Frequently Asked Questions
(Moderator: support)
  Connecting to Barcode or Smart Card Readers
? previous next ?
Pages: [1] Go Down Reply Notify of replies Send the topic Print
   Author  Topic: Connecting to Barcode or Smart Card Readers  (Read 7294 times)
support
Global Moderator
*****

Posts: 3070





View Profile WWW E-Mail
Connecting to Barcode or Smart Card Readers
« on: December 13, 2005, 11:05:38 AM »
Reply with quote

It is very simple to read from a barcode or smart card/RFID reader if the barcode reader can be connected to the PLC using RS232. Most bar code readers return data as ASCII string terminated by a Carriage Return (CR character, ASCII 13) so you can simply use the INPUT$(1) command to read the data from the COM1 port. The PLC keeps a 256 bytes circular buffer for incoming serial characters so you don't have to be monitoring the serial port all the time. As long as the data are read before the buffer overflows (i.e. more than 256 bytes are received) the buffered data will not be lost.

First, decide how often you need to check whether the bar code has read something. e.g. every 0.5s, then form a circuit:

  Clk:0.5s    Fn_#1
|---||--------{dCusF}



Within function #1:

  A$ = INPUT$(1)  ' read from COMM port 1

  IF LEN(A$)=0 RETURN: ENDIF  ' nothing from barcode
                              ' so just return
  ....          '  continue what you need to do

In the above code, if A$ receive an empty string from the COMM1 port it means there is no data available, so the function just quit. Otherwise, continue to process the data received in the string. You can convert strings to integer such as:

  X = VAL(A$)  or for hexadecimal string,
  Y = HEXVAL(A$)

function such as MID$() can be used to extract a certain
segment of a string from the string variable.
Report to moderator   Logged

Email: support@triplc.com
Tel: 1-877-TRI-PLCS
improtec
Newbie
*

Posts: 7



I'm a llama!

View Profile
Re:Connecting to Barcode or Smart Card Readers
« Reply #1 on: March 21, 2012, 09:14:16 AM »
Reply with quote

Hi, some card reader use RS-485 with wiegan protocol, it is posibble to get it with the RS-485 port of the Tri-PLC ?
« Last Edit: March 21, 2012, 09:31:43 AM by improtec » Report to moderator   Logged
support
Global Moderator
*****

Posts: 3070





View Profile WWW E-Mail
Re:Connecting to Barcode or Smart Card Readers
« Reply #2 on: March 21, 2012, 12:31:02 PM »
Reply with quote

According to: http://en.wikipedia.org/wiki/Wiegand_protocol

Wiegand is a 3 wire signal which is not RS485. If your reader actually convert the signal into RS485 and send out as individual bytes then it may be possible to use the INCOMM (n) command to read each byte of data from PLC's RS485 serial port #n. Once the byte are read into the data memory you can then apply any kind of extraction/conversion of the data to interpret the result.
Report to moderator   Logged

Email: support@triplc.com
Tel: 1-877-TRI-PLCS
Pages: [1] Go Up Reply Notify of replies Send the topic Print 
? previous next ?
Jump to: 


Login with username, password and session length

Powered by MySQL Powered by PHP Internet PLC Forum | Powered by YaBB SE
© 2001-2004, YaBB SE Dev Team. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!