Author Topic: RS232  (Read 13355 times)

dan

  • Newbie
  • Posts: 47
    • View Profile
RS232
« on: May 23, 2007, 07:31:40 AM »
Hi,

I have several devices connected to a T1616.
If I pool one device at a time it works Ok. If I do this in a sequence for 2 or more devices I got mixed results. Most probably is in the software but I just can't see it. I have a custFc that is activated every 1 sec.

DM[11]=0

If DM[11]=0 Then
Print #1 " cmd string "
A$=Input$ (1)
A$=MID$(A$,3,255)
A=Val(A$)
DM[11]=DM[11]+1
endif

If DM[11]=1 Then
Print #1 " cmd string "
B$=Input$ (1)
B$=MID$(B$,3,255)
B=Val(B$)
DM[11]=DM[11]+1
endif

Thanks

Dan

dan

  • Newbie
  • Posts: 47
    • View Profile
Re:RS232
« Reply #1 on: May 23, 2007, 08:18:29 AM »
Hi,

I have one more question.

From your documentation: "Input$(n).....all the characters that make up the string will be removed from the COMM buffer."

This means that after Input$ the buffer is empty or I have to use the Incomm() to verify if the buffer is empty?

Dan

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:RS232
« Reply #2 on: May 23, 2007, 12:35:09 PM »
How did you connect several devices to COMM1 port of T100MD1616 which is an RS232 port. Are you using an RS232 to Rs485 adapter? If you simply parallel the RS232 port to a few devices it is not going to work as each RS232 device will attempt to influence their Tx line and multiple unit will contend to change the Tx line to the state and it will corrupt the data.

INPUT$(1) only removes the oldest string (terminated by CR character) from the 256 bytes serial buffer. It doesn't empty the buffer after that. So it is possible for the PLC to receive multiple CR-terminated strings and INPUT$(1) will then retrieve them one by one from the serial buffer. Yes,you can test if the serial buffer is empty by the INCOMM command.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS