Author Topic: DF1 driver/documentation/help  (Read 3334 times)

WellsCPak

  • Newbie
  • *
  • Posts: 28
    • View Profile
DF1 driver/documentation/help
« on: April 26, 2017, 03:56:46 PM »
Archie,

You have done fantastic work for the industrial community. I can't tell you how many times I search PLCTalk or Control forums and find the answer I need, authored by you! In addition to that, AdvancedHMI is really in a league of its own. I've been happily using AHMI for 3 years now, and it never fails to exceed my expectations! Thank you so much!

I have started working on a project where my license requirements are pretty strict, which sometimes means writing from the ground up (I wish I could use AHMI for this one!). The application is a Linux-based driver/HMI that can interface with a PLC-5 (no ethernet) and various SLC controllers (5/04, etc. also no ethernet) over a serial RS-232 connection.
So far, I've had quite a bit of luck with the SLC using this daemon application: https://github.com/leicht/Df1 The daemon handles the low-level comms over the serial port and listens on a TCP port so I can send commands to it from a different computer or loopback over localhost and use the same machine. It's been pretty slick so far.
I tried applying the same process to the PLC-5 and had far less success. I think I remember this topic coming up periodically, and the answer being that the packet format is different from the PLC-5 to the SLC. I've been using AHMI on my dev pc for troubleshooting, and looking at the AHMI serial logs, I can confirm that the packets are different, but I can't make much sense of why or how.
So here I am. The past few weeks of struggling have landed me here. I have an inkling that I'm doing something wrong, but I can't seem to figure out how to do things right. I was hoping you might be able to point me in the right direction.

Is there any source code or documentation available for the DF1 driver that communicates with the PLC-5? How similar or different is the AHMI version to the ABDF1 version you penned in 2006?

Thanks for taking the time to read my novel,

Alyssa Wells

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5260
    • View Profile
    • AdvancedHMI
Re: DF1 driver/documentation/help
« Reply #1 on: April 26, 2017, 05:07:42 PM »
When dealing with the DF1 protocol, this manual will become your best friend:

http://literature.rockwellautomation.com/idc/groups/literature/documents/rm/1770-rm516_-en-p.pdf

Pages 7-2 and 7-3 maybe the most useful table to refer to. It lists the commands to use and the processors they work with. Take for example, Protected Typed Logical Read with Three Address Fields. This command is used to read values from a SLC or Micro, but does not work with a PLC5. But if you look at the Word Range Read, you will see it is the command to use for reading data from the PLC5.

WellsCPak

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: DF1 driver/documentation/help
« Reply #2 on: May 11, 2017, 10:16:18 AM »
That manual looks great!
From my first look at the serial log files, it looks like there's more different between the two, but I didn't spend a lot of time trying to translate the hex codes... Here's a small excerpt with the differences underlined.

SLC:
15:03:12.3816199 Opening COM3: 20
15:03:12.4588267 Send   : 10 02 01 00 0F 00 59 40 A2 02 03 85 00 00 10 03 0F D3
15:03:12.5119691 Rcvd   : 10 06
15:03:12.5280121 Rcvd   : 10 02 00 01 4F 00 59 40 00 00 10 03 36 C4
15:03:12.5390412 SendACK: 10 06


PLC-5:
11:05:23.8592522 Opening COM3: 20
11:05:23.9404693 Send   : 10 02 01 00 0F 00 05 40 01 00 00 01 00 07 00 03 00 02 10 03 C7 9C
11:05:23.9785718 Rcvd   : 10 06 10 02 00 01 4F 00 05
11:05:24.0076493 Rcvd   : 40 00 00 10 03 27 05
11:05:24.0287057 SendACK: 10 06


Are the differences between the two just the different command codes?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5260
    • View Profile
    • AdvancedHMI
Re: DF1 driver/documentation/help
« Reply #3 on: May 11, 2017, 10:33:36 AM »
The 59 you have underlined is part of the TNS (transaction number), so it will be different with every packet. The last two bytes are the checksum.

The bytes of interest are the ones in between those.

A2 02 03 75 00 00
A2 = Command  (protected typed logical read with three address fields, Page 7-17)
02 = Byte Size
03 = File Number
75 = File Type
00 = Element Number
00 = Sub Element Number


01 00 00 01 00 07 00 03 00 02
Command = 01  (word range read , Page 7-34)
00 00 = Packet offset
01 00 = Total trans
07 00 03 00 = PLC System Address (Page 13-10)
02 = Size in bytes

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: DF1 driver/documentation/help
« Reply #4 on: December 30, 2017, 04:09:17 PM »
WellsCPak, can you describe how you installed the Df1?

This is what I have done so far on a Pi.
0. sudo git clone https://github.com/leicht/Df1.git
1. sudo apt-get install cmake
2. modify Makefile to point to my local path /home/pi/Df1
3. modify main.c to point to the right device in /dev/ttyS0
4. sudo make
5. sudo cp ./test/df1d /etc/init.d
6. sudo cp ./bin/df1 /usr/bin
7. /etc/init.d/df1d start
8. sudo apt-get install telnet
9. telnet locahost 17560
10. T4:0.ACC
11. Worked! 
12. Telnet from a different PC getting error -6 ERROR_BAD_QUERY
« Last Edit: December 30, 2017, 10:46:25 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================