Author Topic: Serial port 1 help  (Read 9884 times)

hubieg

  • Guest
Serial port 1 help
« on: March 25, 2005, 05:46:56 PM »
Greetings,

Thursday I received my t100md-888+ plc. After connecting my barcode reader and writing a simple function to query its status, I tried it. Didnt have any luck so I played with connections, baud and protocol settings hoping to get it to work. Still nothing. I finally connected a port sniffer onto port 1 (Im programming through port 3) and found that the function is sending 3 copies of the string to the scanner. Is this a bug or am I missing something?
The following is a copy of the function Im using whisch is producing this result:

PAUSE
Z$ = NETCMD$(1,CHR$(2)+"2?ST"+CHR$(3)+"~")
PAUSE
SETLCD 1,1,Z$
CLRBIT RELAY[1],0

Just for clarity, "RELAY[1],0" is the contact that initiates the function

Any help would be GREATLY appreciated!
Cheers,
Todd

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial port 1 help
« Reply #1 on: March 25, 2005, 07:05:50 PM »
Remember that NETCMD$ is supposed to send a string to the device and it expect to receive a response from the device that is terminated with the CR character. If the device does not send back a CR terminated string then the NETCMD$ function concludes that the device is not responding and will retry two more times and then return an empty string.

Is your bar code scanner supposed to send data to the PLC or it is a command/response type of system where the PLC supposed to send it a command and then it will respond accordingly? If it is the former, then use the INPUT$(1) or INCOMM(1) to  receive data from the barcode scanner. If it is the latter, you can use NETCMD$ if the command/response are CR terminated strings. If not, then you have to use OUTCOMM to send binary data to the device and use INCOMM to receive binary data from the device. In this case you have to examine the data read from the serial port and find the data enclosed between the delimiters determined by your bar code scanner.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

hubieg

  • Guest
Re:Serial port 1 help
« Reply #2 on: March 26, 2005, 06:18:37 PM »
Hi,

Well I added a CR into the response of the barcode scanner and still nothing  :-\ I tried using the print and input commands also and nothing.

Just for some backround, the way this scanner communicates is a command is issued and a response in sent. An example is as follows:

PLC --> Scanner:  <STX>2?SF<ETX>
Scanner --> PLC:  <STX>2SF000<CR>

The above is the ideal. As of now though I get no response to the message.
I hooked up the programming cable to plc comm 1 to pc comm 1. I then ran a sniffer on pc comm 1 and reset the plc. what came out was a well formed "<STX>2?SF<ETX>". I then connected the same cable to the scanner and issued the command "<STX>2?SF<ETX>". I got a response of "<STX>2SF000<CR>". Because of this I know Im running 38400,8,N,1 on both plc and scanner. The only thing I can figure at this point is flow control. Just so you know, I am connected pin 2-3, 3-2, and 5-5.

I sure hope you can figure this out. After 2 days I dont have much hair left to pull out.

Cheers,
Todd

hubieg

  • Guest
Re:Serial port 1 help
« Reply #3 on: March 27, 2005, 08:31:38 AM »
Well, another day another try :-(
Today I tried jumping pins 4-6 for a total connection as follows:

PLC      Scanner
 2     --     3
 3     --     2
 5     --     5
 4  --|
 6  --|

Now I get errors about bad network performance and trilogi will not allow me to do online monitoring. I just checked again and my scanner is still terminating with 0x0D so that shouldnt be a problem.
Since I kept getting "booted" from the online monitoring I changed my function block to the following:

Y$=CHR$(2)+"2?SF"+CHR$(3)+"~"
Z$=NETCMD$(1,Y$)


IF LEN(Z$) = 0
 SETBIT OUTPUT[1],7
ELSE
 SETBIT OUTPUT[1],0
ENDIF
CLRBIT RELAY[1],0

Once again, RELAY[1],0 is in series with this block. When I execute this the LED on output 8 illuminates indicating to me that its not receiving anything back from the scanner.
In case you want to check out the connections on the scanner it is a Sick CLV410.

Thanks,
Todd

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Serial port 1 help
« Reply #4 on: March 27, 2005, 01:10:10 PM »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS