Author Topic: Receive RS232  (Read 9854 times)

Lance

  • Guest
Receive RS232
« on: June 05, 2006, 02:07:30 PM »
Please forgive me, I'me very new to this and will probably have several "obvious" questions.

I would like to use the RS232 input like a switch.  That is, when a "character" is received on the RS232 port, I'd like it to run a Custom Function. (will hopefully use the character to modify the period on a timer)

Is this possilbe or will I need to pole the port?  

What would the diagram look like?

Thank you.
Lance

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Receive RS232
« Reply #1 on: June 06, 2006, 12:03:04 AM »
Any T100MD+ PLC can handle this quite easily. You do need to periodically check the RS232 port to see if the "switch" character or string is received. Since the PLC buffers incoming serial data up to 256 bytes, you don't have to poll the RS232 port all the time since incoming character will not be lost even if they are not read by the PLC program unless more than 256 bytes has been received, then the oldest data is lost.

All you need is to set up a clock pulse to periodically run a custom function that checks the serial port:
    Clk:0.5s                Chk232
|---||---------------{dCusF}

The above circuit set up the PLC to check serial port once every 0.5s. Inside custom function "Chk232" you need to check for incoming characters:

   X = INCOMM(1)
   IF X = ???     ' whatever character used as switch
      ...              ' take action
   ELSE
      ....             ' otherwise do something else or just return.
   ENDIF

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