#!/bin/more

        QUICKSTART file for PLC.pm v0.14 Copyright (c) 2004 by Dan Baker

	Licensed under the Artistic License (See the file 'Artistic')

   ###############################################################
   # You must edit the PLC rc file (usually /plc/PLCproc.rc)     #
   # with information on your PLC's before using this software.  #
   # (See the example PLCproc.rc file and PLC.pm for details)    #
   ###############################################################

## For best results, use the included program 'tns_server' to prevent
## conflicts between programs with the TNS parameter in Allen-Bradley
## communication packets.
I use the following line (in /etc/inittab) to automatically run tns_server:
T0:2345:respawn:/root/bin/tns_server > /dev/null 2>&1

Currently only Allen-Bradley(tm) PLC's, SLC's, and MicroLogix are supported
See PLC.pm for more information.

#  Send questions, ideas, etc. to Dan Baker (dan.baker@bigfoot.com)

ATTENTION -- This program and the PLC.pm module are still experimental,
although I have been using them for several years without trouble.
If you think the following warnings are too extreme,
you need to gain more experience with industrial controllers
before using this program:

This is experimental software, not to be used for mission-critical
applications. You assume all responsibility for its use.
Your production lines can grind to a halt, causing lost revenue,
or worse, equipment can be destroyed or people injured or killed.
You use this program at your own risk.

DANGER: DON'T write to a PLC unless you are certain it is safe to do so!!!
It is assumed that you are experienced in PLC programming/troubleshooting
and that you know EXACTLY what you are doing. PLC's are used to control
industrial processes, motors, steam valves, hydraulic presses, etc.
You are ABSOLUTELY RESPONSIBLE for ensuring that NO-ONE is in danger
of being injured or killed because you affected the operation
of a running PLC (with this software or any other).

(0) untar the distribution file PLC-0.14.tar.gz :

  tar zxvvf PLC-0.14.tar.gz

(1) change into the PLC directory (you are probably there already) :

  cd PLC

(2) make sure you have the Device::SerialPort module installed

  perl -e 'use Device::SerialPort'

If you don't have it, you'll get an error message.
so get it from CPAN before continuing.

(3) run Makefile.PL :

  perl Makefile.PL

(4) run make

  make 

(5) Create the directory /plc, and copy the example PLCproc.rc into it :

  mkdir /plc
  chmod 755 /plc
  cp PLCproc.rc /plc

(6) run make test

  make test

(7) if the test went OK, install the module

  make install

(8) Edit /plc/PLCproc.rc for your PLC's and SLC's. See below and also
check examples in PLCproc.rc.

(9) If you have at least one PLC or SLC connected, and you have an entry
for it in /plc/PLCproc.rc, try the example program plcx on it:

  ./executables/plcx YOUR_PLC_NAME

This should get the diagnostic status data from your PLC, and
display it. If you are communicating, you can try something like:

  ./executables/plcx YOUR_PLC_NAME N7:0

to read the value of integer N7:0

You probably will want to run tns_server (it's in the executables directory)
from /etc/inittab, or rc.local maybe. See the README and the PLC.pm source
for more information on tns_server.
I use the following line (in /etc/inittab) to automatically run tns_server:
T0:2345:respawn:/root/bin/tns_server > /dev/null 2>&1

(10 .. $InfinityAndBeyond) :

  See the README file for more information.


############################################################################

Allen-Bradley PLC5's, SLC's, and MicroLogix supported:


##### using RS232: (direct to PLC/SLC or via DF2/DF3 module) -----
Computer <-RS232-> (PLC5 or SLC503/SLC504/SLC505)
Computer <-RS232-> KF2 <- DH+ -> (PLC5 or SLC504)
Computer <-RS232-> KF3 <-DH485-> 1747AIC <----> (SLC500)

A typical entry in /plc/PLCproc.rc for an RS232 connected PLC is:

[MYPLC]
CommType = RS232
PLCtype = PLC5
RS232device = /dev/ttyS1
RS232bps = 9600      # 9600 bits/second
RS232parity = 'N'    # no parity
RS232crc_bcc = 'CRC' # using CRC error detection


##### using Ethernet: to ControlLogix Gateway Ethernet module, then through --
                DHRIO module(s) to PLC/SLC on DataHighwayPlus
Computer <-Ethernet-> (ControlLogix Gateway) <- DH+ -> (PLC5-Ethernet/SLC505)
The ControlLogix Gateway needs a 1756-ENET ethernet module,
a ControlLogix Gateway Rack (i.e. 1756-A7A), a Power Supply,
and at least one 1756-DHRIO module.


You should have a working setup (using RSLinx, etc.)
before trying this software for the first time.

#-----------------------------------------------------------------------------
A typical entry in /plc/PLCproc.rc for a CL-Gateway connected SLC504 is:

[MY504]
CommType = ControlLogixGateway
PLCtype = SLC504
GatewayIP = 192.168.0.10 # IP address of the ENET module in the Gateway
GatewaySlot = 1 # the DHRIO module is in slot 1 (slot 0 is first slot)
GatewayChan = 1 # each DHRIO has 2 DH+ channels (1=A,2=B)
DHnode = 005    # the SLC504's DH+ node address

(At work, I have a 1756-ENET in slot 0, and DHRIO's in slots 1-4)


##### using Ethernet: to a MicroLogix processor via a 1761-NET-ENI module
Computer <-Ethernet-> (1761-NET-ENI) <- 1761-CBL-HM02 cable -> (MicroLogix)

A typical entry in /plc/PLCproc.rc for an Ethernet-connected NET-ENI is:

[ENI_TEST1]
CommType = NET_ENI
GatewayIP = "192.168.0.77" # IP address of NET-ENI module
PLCtype = MicroLogix


##### or directly to Ethernet PLC/SLC --------------------------------------
Computer <-Ethernet-> (PLC5/Ethernet or SLC505)

A typical entry in /plc/PLCproc.rc for an Ethernet-connected PLC is:

[ETHPLC]
CommType = EthernetPLC
PLCtype = PLC5
PLC_IP = 192.168.0.20 # IP address of the Ethernet PLC

###########################################################################
#                                                                         #
#  NOTE: (ControlLogixGateway, DataHighwayPlus, PLC5, SLC, and MicroLogix #
#  are registered trademarks of Allen-Bradley Company Incorporated.       #
#  Allen-Bradley has no connection at all with this software,             #
#  and I have no connection with Allen-Bradley,                           #
#  so don't expect them to give you free technical support.               #
#                                                                         #
#  Information on Allen-Bradley's DF1 protocol can be found at:           #
# 		http://www.ab.com/manuals/cn/protocol.html                #
#  and in:	http://www.ab.com/manuals/cn/17706516.pdf                 #
#  Everything I know about these communication protocols comes from       #
#  the above AB manual (1770-6.5.16), from analysing RS232 and Ethernet   #
#  packets, and (for ethernet PLC stuff) from Ron Gage's abplc package.   #
#                                                                         #
###########################################################################

End of QUICKSTART for module PLC.pm -------------------------------------------

