EtherNet/IP™ Adapter3.09.00
 
Loading...
Searching...
No Matches
Studio 5000 Logix Designer with Allen-Bradley CompactLogix Controller

The example is prepared to run on an Allen-Bradley CompactLogix 5370 controller communicating with an EtherNet/IP Adapter implementing a General Purpose Discrete I/O Device profile running on a Texas Instruments LP-AM243 LaunchPad™ development kit.

Both Explicit and Implicit messaging are demonstrated in the example.

Studio 5000 and Device Description Installation

Allen-Bradley CompactLogix 5370, model 1769-L16ER, controller is programmed using Studio 5000 development environment.

Adding an EDS File

To add a different EDS file that is not listed in the known EDS files click on "Tools → EDS Hardware Installation Tool". You need to do that if you are using EVM board instead of Launchpad becasue the EDS of Launchpad is already in the structure of this example.

Example Structure

The project is created in Structured Text and divided into three routines that are run from the main routine and triggerred by a timer every 3 seconds.

TONR(FbdTimer1);
FbdTimer1.PRE := 3000;
FbdTimer1.TimerEnable := NOT FbdTimer1.DN;
if FbdTimer1.DN then
// Get Attribute Single requests per 3 secs
JSR(ImplicitMsg_Discrete_IO_Device);
JSR(ExplicitMsg_Discrete_IO_Device);
end_if;

The subroutines are:

ExplicitMsg_with_DTK
Sends explicit messages for Identity and TCP/IP objects as well as the Discrete Output Point (Class ID = 0x09) Object's first instance.
/*
Routine with a CIP Explicit Messaging example for the
EtherNet/IP General Purpose Discrete I/O Device
on a Texas Instruments LP-AM243 Launchpad
*/
case LocalCounter2 of
0: // Identity Object's (0x01), Vendor ID Attribute (0x01)
GetAttrSingle_Discrete_IO_Device.Class := 16#01;
GetAttrSingle_Discrete_IO_Device.Attribute := 16#01;
GetAttrSingle_Discrete_IO_Device.Instance := 16#01;
1: // Identity Object's (0x01), Serial Number Attribute (0x06)
GetAttrSingle_Discrete_IO_Device.Class := 16#01;
GetAttrSingle_Discrete_IO_Device.Attribute := 16#06;
GetAttrSingle_Discrete_IO_Device.Instance := 16#01;
2: // TCP/IP Object's (0xF5), Configuration Capability Attribute (0x02)
GetAttrSingle_Discrete_IO_Device.Class := 16#F5;
GetAttrSingle_Discrete_IO_Device.Attribute := 16#02;
GetAttrSingle_Discrete_IO_Device.Instance := 16#01;
end_case;
// Counters
if LocalCounter2 < 2 then
LocalCounter2 := LocalCounter + 1;
else
LocalCounter2 := 0;
end_if;
// Message sending
MSG(GetAttrSingle_Discrete_IO_Device);

ImplicitMsg_with_DTK
Sends implicit messages to Configuration Assembly to set the mode (ENABLED/DISABLED) of Discrete Output Object I/O communication.

This example checks the two bytes of the Configuration Assembly and sets the Output Assemblies represented as two instances of Discrete Output Object. The results can be read on Input Assemblies represented as two instances of Discrete Input Object.

If the first byte of Configuration Assembly is set to "0" Discrete Output Point Object's first instance will be disabled for the I/O messaging. If it is set to "1" I/O communication for that instance will be enabled and changes on Output Assembly can be seen both on Input Assembly and LED on the board.

The example below shows that Configuration Assemblies set to "1" and enabled for both of the Discrete Output Point Object's instances. Industrial LEDs (LD 15 & LD 14) controlled by the TPIC2810 8-bit I2C LED driver will be toggled.

Discrete_IO_Device:C.Output6:= 16#01;
Discrete_IO_Device:C.Output7:= 16#01;
if LedStatus2 then
Discrete_IO_Device:O.Data[0]:= 16#00;
Discrete_IO_Device:O.Data[1]:= 16#00;
LedStatus2:=0;
else
Discrete_IO_Device:O.Data[0]:= 16#01;
Discrete_IO_Device:O.Data[1]:= 16#01;
LedStatus2:=1;
end_if;

Running the Example on PLC

Download the Example to the PLC

Verify the the hardware swith on the PLC (RUN/REM/PROG) is set into REM position. To download the example to the PLC, from dropdown menu click "Download".

Getting Online with The PLC

After downloading if you are not automatically prompted to move to "Rem Run", from the dropdown menu click "Run Mode".

Monitoring changes through Controller Tags

When online, you can observe these Implicit messages changes from Controller Tags on the left menu bar. In this example we can specifically observe "DTK_Discrete:O.Data[0]" & "DTK_Discrete:O.Data[1]" and "DTK_Discrete:I.Data[0]" & "DTK_Discrete:I.Data[1]" changing.