DF1 for PLC5

senthil@spk

Member
Join Date
May 2008
Location
California
Posts
9
Hi,

I am trying to communicate with PLC5 through VB.Net using DF1 protocol. To start with I am trying to get the plc to echo the data what I send. Here is the code that I am trying,

Dim DLE, STX, ETX, BCC As Byte
Dim DST, SRC As Byte
Dim TNSH, TNSL As Byte
Dim CMD, STS, FNC As Byte
Dim DATA As Byte
Dim R1, R2 As Byte

DLE = &H10
STX = &H2
DST = &H1
SRC = &H0
CMD = &H6
STS = &H0
TNSL = &H5
TNSH = &H0
FNC = &H0
DATA = &H64
ETX = &H3
BCC = &H9B

Dim TS() As Byte = {DLE, STX, DST, CMD, STS, TNSH, TNSL, FNC, DATA, ETX, BCC}

R1 = &H0
R2 = &H0

Dim RS() As Byte = {R1, R2}

Dim RS232 As New IO.Ports.SerialPort
RS232.PortName = "COM3"
RS232.BaudRate = 19200
RS232.DataBits = 8
RS232.StopBits = IO.Ports.StopBits.One
RS232.Parity = IO.Ports.Parity.None
If (RS232.IsOpen = False) Then
RS232.Open()
End If

RS232.Write(TS, 0, 10)

Threading.Thread.Sleep(500)

RS232.Read(RS, 0, 1)

RS232.Close()

MsgBox(RS(0).ToString)
MsgBox(RS(1).ToString)

I am trying to get the inital acknowledgement from the plc, but when the control comes to the read, it times out, without any reply.

I will appreciate if anybody who have experience with DF1 can help me out to find what I am doing wrong.

Thanks for the help in advance.

Regards.
 
A few things:

If you goto sourceforge.net and search DF1, you'll find some example projects in both VB and C.

DF1 echo is CMD 0x0F FNC 0x05.

If you keep sending a message w/ the same TNS, depending on the receiving device's configuration it may ignore you.

Make sure you're configured for full duplex.

As Eddie mentioned, end of message is indeed DLE ETX.
 
Jason, I will check on the website you mentioned.

The DF1 manual says CMD 06 and FNC 00 for echo. (Page 7-8). I am not sure we are refering to the same command.

About the configuration for full duplex, is there anything to be addressed from the software side??
 
Sorry about the CMD/FNC, you are indeed correct. That's what I get for not paying attention to the section of the page that refers to the command I am interested in.

Have you checked to see if anything is coming back from the PLC, a DLE NAK, DLE ENQ, or DLE ACK?

Fix the ETX to DLE ETX?

Make sure your checksum(BCC or CRC) configuration matches what you are trying to do, BCC in this case.

Another note, DF1 defines multibyte value transmission as little endian, IOW least significant bytes are transmitted first. It looks like your TS array has the TNS bytes swapped. A minor issue, and won't be a problem at this stage in your program.
 
Yes i fixed up the ETX to DLE ETX, I also found the SRC missing in the transmission. I fixed that one too.

I am getting the DLE NAK reply from the PLC. Previously you mentioned about configuring for full duplex. Can you brief that please.
 
This is the latest

Dim DLE, STX, ETX, BCC As Byte
Dim DST, SRC As Byte
Dim TNSH, TNSL As Byte
Dim CMD, STS, FNC As Byte
Dim DATA As Byte
Dim R1, R2, R3 As Byte

DLE = &H10
STX = &H2
DST = &H0
SRC = &H0
CMD = &H6
STS = &H0
TNSL = &HB
TNSH = &H0
FNC = &H0
DATA = &H0 '&H64
ETX = &H3
BCC = &H2 '&H9B

Dim TS() As Byte = {DLE, STX, DST, SRC, CMD, STS, TNSH, TNSL, FNC, DATA, DLE, ETX, BCC}

R1 = &H0
R2 = &H0
R3 = &H0

Dim RS() As Byte = {R1, R2, R3}

Dim RS232 As New IO.Ports.SerialPort
RS232.PortName = "COM3"
RS232.BaudRate = 19200
RS232.DataBits = 8
RS232.StopBits = IO.Ports.StopBits.One
RS232.Parity = IO.Ports.Parity.None

If (RS232.IsOpen = False) Then
RS232.Open()
End If
RS232.DiscardInBuffer()

RS232.Write(TS, 0, 12)

Threading.Thread.Sleep(500)


RS232.Read(RS, 0, 2)

I am using the channel 0. I am wondering is it right to give both the source and desitination to be zero. Some of the examples I have seen in the web uses that. I even tried the 1 and 0 for source and destination and vice versa, but still no sucess. Is there any specific configuration made to the serial port to be in full duplex mode??
 
For full duplex, your PLC5 isn't going to care much about the SRC and DST values.

I don't know VB, but you show the BCC to be "&H2 '&H9B". What exactly does that mean? Is that two bytes? A BCC checksum is one byte.
 

Similar Topics

Hi, I am using the Tuxeip library to talk to a customer's Allen-Bradley PLC5. Tuxeip currently uses DF1 command 0F 67 (Typed Write) to write...
Replies
2
Views
3,341
RSLinx 2.43 has been installed on my computer for months, but now when I try to autoconfigure a DF1 connection to a PLC5 Channel 0, the message...
Replies
9
Views
7,020
I have a client who has replaced an obsolete HMI with a PROFACE 2400. The original HMI was connected to the AB PLC5 using the DF1 full duplex...
Replies
7
Views
11,558
I am working on setting up a Prosoft Datalogger model PLX51-DLplus-232. This unit will be collecting data from a SLC 5/05 on the DB9 port set to...
Replies
3
Views
103
Hi, I appreciate any help to make connection between AB DF1 Micrologix 1200 and WinCC Adv project (PC station - not HMI) possible. For now I can...
Replies
5
Views
604
Back
Top Bottom