DF1 protocol problems

N

Thread Starter

Nicolas

Hi everyone,

I'm new here and glad to become a member of this forum which contains relevant informtations.

Basically, I'm building my own driver in VB.NET following the AB DF1 protocol in order to communicate with a Micrologix 1200. I'm connected through the device by a RS-232 cable.

I'm trying to send data to the PLC, but the response I receive is always the same: DLE and NACK. I don't know what's wrong in my packets, I'm pretty sure to have a good CRC-Value, good node address, function value....

If someone know something that might help me, I may find the solution.

Regards.

Nicolas Chaillou
-------------------------------------------------
EXA Systems
Canada
 
R
Hello Nicolas.

ABDF1 Protocol is kind of simple to handle, I wrote a DF1 VCL for Delphi in avery short time and it works fine, perhaps you´re missing something.

it would help to see the code, you can copy-paste the code in text format and mail it to me if you want, i might be of assistance.

[email protected]
Mentor Software Solutions
 
DF1 code for VB6... with a few modifications, it should work with VB.NET. Not much, but it's a start.

CH
 
Make sure that the file and offset actually exists. If you try to read N7:100, and the N7 file ends at 99, Then - DLE NAK
 
Hi,

my problem is more basic than that, I'm still in the first steps of communication. I'm trying to build packets in order to send an ECHO command but unfortunately the response is always DLE NAK.

I'm pretty sure that my CRC checksum value is correct, and according to the document, packets seem to be correctly build.

I'm no really use to work with this kind of protocol, that's why I'm a little lost.

If you've got any idea, I will always be happy to discuss them with you!

Thanks in advance!
 
A

Automation Linse

Beep - wrong-o "Anon".

NAK will only come in situations such as:
1) CRC is wrong/invalid
2) CRC is sent but PLC is set to BCC (<< check this!)
3) PLC has run out of buffers.

You can send near total garbage to a DF1 peer and as long as the CRC is correct it will ACK. If the command is unsupported or tables incorrect you'll still get an ACK, but the response will include a bad STS byte (usually hex 10).

You will find the "DLE" escaping for DF1 is rather confusing - avoid sending any hex 0x10 values until you confirm operation.

best regards
- LynnL
 
I have been working on a DF1 for a micrologix 1000 plc. I have got it to communicate. You need to send a command to it. These type of characters.

example

If you want to write to the data tables.

You start with
chr(DLE)
then send
(STX)
Then
DST
then
SRC
Then
the Command the unprotectd write is command 8
The read command is 1
then
STS equal to zero
then
trans id
then you have to have the trans id increment.
trans id 2
then the address High byte
ADDH
Then the low byte
ADDL
then
Data High
then
Data Low
then
DLE
then
ETX end of text
then the
CRC bytes equal 2'

so to send data it should be
10>2>1>0>1>0>29>0>2>0>3>0>10>3>
this will read the contents of 3 bytes of register N7:1 of an micrologix plc.
It works on the one I tested anyway.

Good luck

A good book for that is home automation basics he writes a Df1protocol.
 
A

Automation Linse

Did you ever get your program to work?

I have some more DF1 tips at: http://www.iatips.com/df1_tips.html

Worst case, get an OPC server like Kepware, run it and see what bytes it sends on the serial port. You can connect the PC's RS-232 transmit pin to a "3rd device" to sniff what the OPC server (or RSLinx) is saying. Then make sure your VB app can recreate the same messages.

best regards
- LynnL, www.digi.com
 
I am tring to read the register N7:1 how can I getting?
What is the comand that I have to send? My PLC is micrologix 1000 and trying with Visual Basic 6.0

Thanks.
 
A

Automation Linse

These best commands for MicroLogix and SLC5 are the "protected typed logical read with three address fields" on DF1 spec page 7-17 and the matching "write" on page 7-18.

Here is a 100% valid DF1 request to read N7:0 to N7:9 from a MicroLogix or SLC5 PLC. Make sure your code can recreate this - including the correct CRC16 (all bytes are hex):
0x10 02 01 00 0f 00 e4 3a
0xa2 14 07 89 00 00
0x10 03 15 b9

I split the message into 3 parts, breaking them down for better understanding they are:

0x1002 01 00 0f 00 e43a
STX DST SRC CMD STS TNS
(TNS of E4 3A is a random value, but you must use this for the CRC given below to be correct. It must change for every new request. Avoid sending TNS=0 because it can cause problems if the serial device has just powered up)

0xa2 14 07 89 00 00
(This is SLC-style Read of 20 bytes from file #7 of type Integer, starting at first element)

0x1003 15b9
ETX CRC16

Once you get this message working in yoru code, then you can vary the fields.

I have more info on DF1 here: http://iatips.com/df1_tips.html

best regards
- LynnL, www.digi.com
 
Hi everyone,

I'm writing a PLC driver following AB DF1's protocol under VB.NET for a ML 1500. It works fine, I thought I had finish, but this error really bug me, I hope someone may have any idea of what's going wrong...

I can perform "protected typed logical write using three adress fields" as documented in DF1's manual p7-18 in order to send a value to PLC. Fact is that driver works great except for the value "16". If I have to send this value (like here, to Output slot 0), PLC denies to accept my packet replying me with a NAK. By making a diagnostic, I can see that It interprets this message as a bad packet, but I cannot understand why.

Here is a copy of a serial monitoring:
---
Port opened by process "PLC Tester.exe" (PID: 1860)

Request: 2005-08-05 10:56:00 AM.731635064 (+12.9262666000 seconds)

10 02 01 00 0F 00 50 9F AA 02 00 8B 00 00 10 00 ......Pª..‹....
10 03 BA 42 ..ºB

Answer: 2005-08-05 10:56:00 AM.731635064 (+0.0000000000 seconds)

10 15 ..

Request: 2005-08-05 10:56:05 AM.908149264 (+5.1765142000 seconds)

10 02 01 00 0F 00 E3 B7 AA 02 00 8B 00 00 10 00 ......ã·ª..‹....
10 03 63 44 ..cD

Answer: 2005-08-05 10:56:05 AM.918161864 (+0.0100126000 seconds)

10 15 ..

Request: 2005-08-05 10:56:06 AM.038313064 (+0.1201512000 seconds)

10 02 01 00 0F 00 86 30 AA 02 00 8B 00 00 10 00 ......†0ª..‹....
10 03 3A BB ..:»

Answer: 2005-08-05 10:56:06 AM.048325664 (+0.0100126000 seconds)

10 15 ..

Request: 2005-08-05 10:56:06 AM.138439064 (+0.0901134000 seconds)

10 02 01 00 0F 00 B0 CC AA 02 00 8B 00 00 10 00 ......°Ìª..‹....
10 03 1E CF ...Ï

Answer: 2005-08-05 10:56:06 AM.148451664 (+0.0100126000 seconds)

10 15 ..

Request: 2005-08-05 10:56:06 AM.198514664 (+0.0500630000 seconds)

10 02 01 00 0F 00 07 19 AA 02 00 8B 00 00 10 00 ........ª..‹....
10 03 46 C0 ..FÀ

Port closed
---

As you can see, every time it failed I retry to send the packet with a
different TNS value, but It still doesn't work.

Does anyone know what should I do in order to make this work? Thanks in advance!

Best regards!
Nicolas
 
Top