Sie sind auf Seite 1von 19

Communicating with Allen-Bradleys Micrologix PLCs

This document describes EtherNet IP communications between the Banner PresencePLUS vision sensors and Allen-Bradleys Micrologix family of PLCs. This document is divided into three distinct parts; creating the vision sensor program in the Banner PresencePLUS software, understanding the communications methods, and programming the PLC to drive the camera and interpret the results. In this whitepaper, we will use the PresencePLUS P4 BCR as the example sensor, because it generates three different types of data that must be interpreted on the PLC; integer or bit data, floating point measurements, and string or text data. Most vision sensors will only generate integer and floating point values. The following steps are shown using Rockwell Softwares RS Logix 7, and RSLinx 2.5. The PLC used in the example is the Allen-Bradley Micrologix 1100, a low-cost brick PLC with a built-in Ethernet port. The ladder logic instructions should work on all of the Micrologix product family. The Banner vision sensor must have release 2005R7 or higher firmware, which includes the following sensor firmware versions: Pro P4 GEO P4 EDGE P4 GEO 1.3 P4 EDGE 1.3 P4 BCR P4 AREA P4 AREA 1.3 P4 OMNI 1.4.0 1.3.0 1.2.0 1.3.0 1.2.0 1.2.0 1.2.0 1.2.0 1.1.0

The PC software version for release 2005R7 is version 2.7.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 1 of 19 www.BannerEngineering.com

Creating the Vision Sensor Program Before starting our program creation, we will tell the vision sensor which Industrial Ethernet protocol we will be using. Click on the System button in the upper right hand corner, and the following dialog box will appear:

In the Settings group, choose the Protocol PCCC (SLC/PLC05). Leave the 32 Bit format at the default setting LSW-MSW. Press the OK button to accept this selection. Note: The vision sensor can only communicate via one Industrial Ethernet Protocol, since it is a system setting. This PCCC protocol covers SLC and PLC 5, as well as the Micrologix product families.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 2 of 19 www.BannerEngineering.com

On the Banner vision sensor, we will create a normal inspection with a Bar Code tool and a Test Tool to pass the inspection if there is a bar code and fail if no bar code if found. The user may add or change this inspection as desired. Note: The Banner vision sensor automatically transfers the discrete I/O and program Pass / Fail criterion to the PLC if it is connected to the Industrial Ethernet protocol on the camera. The communications tool data is only needed if you would like to send additional information, such as measurement values, or a bar code string to the PLC. Add a Communications Tool, and set its Connection to Industrial Ethernet, as shown in the image below:

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 3 of 19 www.BannerEngineering.com

Using the Select menu, choose the various vision tools in your inspection from which you would like to send data out to the PLC. You will see tabs along the top, one for each tool. Select each tab and choose the data to be sent. In the example shown, we are sending the string of number and/or letters in the bar code. This is called BC_1, Barcode Data Read.

Notice the register numbers shown on the bottom of the options screen on the right. These allow the user to configure where specific items will be in the PLC memory space, but the default settings should be adequate.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 4 of 19 www.BannerEngineering.com

Once all of the desired data items are selected from all of the tools in the program, click on the button called PLC Map. You will see the following dialog box:

Click on the Save Map button to save this PLC register map to your hard drive. You will need this information when writing the PLC program. Its shows the memory location of each specific tools output in the Vision Sensor data table. (See the next section of the report for an explanation about data tables) Put the camera in Run mode before continuing. Click on Run, (the vision sensor will prompt you to save the program to your hard drive), then click on Start to get the vision sensor running. At this point, you can minimize the vision sensor software, or close it.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 5 of 19 www.BannerEngineering.com

Understanding the Communications Methods Before beginning the PLC program, lets discuss how the memory is organized on the vision sensor. The vision sensor has two data tables; one is read-only memory in the vision sensors N7 integer data table, the other is read / write memory in the vision sensors N14 data table. Since the PLC is the master of this system, it initiates both reads and writes from its own data tables to the data tables on the camera. The read-only data table at N7 are outputs from the vision sensor that are inputs to the PLC. This data includes Pass / Fail information, camera status bits, and extended results. This data table is organized as shown below, all the tables use input and output from the point of view of the vision sensor.
N7 Read Only Data Table Vision Sensor Outputs LOC # 0 1 2 3 4-5 6-7 8-9 10 - 11 12 - 13 14 15 32 33 34 35 36 37 956 957 958 959 WORD NAME Output Flags ACK Flags Inspection Number System Error Count Frame Count Pass Count Fail Count Missed Triggers Iteration Count
res res res

Location 1 Location 2 Location 3

Location 463 Location 464

The Data locations marked res are reserved for future use. Location #32 (LOC 32) is the first data table location available for Communications Tool data (see the map on page 5, it begins at Location 32)

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 6 of 19 www.BannerEngineering.com

Locations N7:0 and N7:1 are further divided into individual bits that have the following meanings:
Tag Name Output Flags ACK Flags Bit Position 15 14 13
res res I/O 6 res

12
I/O 5 res

11
I/O 4 res

10
I/O 3 res

9
I/O 2 res

8
I/O 1 res

7
res

6
res

5
res

4
Ready

3
res

2
Error

1
Fail

0
Pass

res

res

res

res

res

res

res

Product Change Ack

Remote Teach Ack

Trigger Ack

These are the outputs from the vision sensor. Note: Because the I/O status Bits are in the read-only N7 data table, the outputs can not be forced ON or OFF via the Industrial Ethernet. Note: The Trigger ACK, Remote Teach ACK, and Product Change ACK bits are Acknowledge bits. They indicate that the corresponding command signal in the N14:0 data table was received (see following description of those bits). The ACK signals are needed because very fast inspections such as inspection on a P4 EDGE may not be busy long enough to use the traditional method of checking the READY bit going OFF. Because of the latency of the PLC scan and the latency of the Industrial Ethernet protocol, you could trigger an inspection and the camera would be done and have results back and the ready light would be back on before the next PLC scan was complete. In this case, the only way to know that the camera triggered is to use the Trigger ACK bit, and check the iteration count in N7:12 to see if it incremented. Next, there are inputs to the vision sensor that are outputs from the PLC. This data is stored in the N14 integer data tables on the Banner vision sensor. This data has the following format:
N14 Read Write Locations Vision Sensor Inputs LOC # 0 1 2 3 39 - 138 139 - 328 WORD NAME Input Flags Product Select res res res Barcode Compare String Barcode Mask

Note: For most PresencePLUS vision sensors, only the first 2 locations in N14 are valid. N14:39-328 only have meaning for Bar Code reader vision sensors.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 7 of 19 www.BannerEngineering.com

Again, like on the output side, the first word of N14:0 is further divided into individual bits that have the following meanings:
Tag Name Input Flags Bit Position 15 14 13
res res res

12
res

11
res

10
res

9
res

8
res

7
res

6
res

5
res

4
res

3
res

2
Product Change

1
Remote Teach

0
Trigger

These are the input bits to the Vision Sensor, outputs from the PLC. The purpose and function of the Inputs and Output bits are identical to the discrete I/O signals on the Banner Vision sensors. Reference the Help file for the appropriate sensor if you have questions about the functioning of a specific item. Note: The vision sensor triggers on the rising edge of a trigger signal. This means that the vision sensor will trigger only when the state of bit N14:0.0 transitions from a 0 to a 1. Therefore, in order to trigger the camera, you must write a 0 into this register first, then writing a 1 into the register will cause a trigger. The same logic holds true for the remote teach signal and the product change signal. The writing of a 1 and then a 0 should be linked in the same part of the PLC program, so that the write cycle includes both writes, leaving the camera in a state where it is ready to be triggered again quickly. The communications between the PresencePLUS vision sensor and the A-B PLC all take place using the two integer data tables on the vision sensor, N7 and N14. The A-B PLC uses message commands (MSG in the ladder logic) to transfer the integer data tables to or from the vision sensor. Once the data has been transferred, the vision sensor output may need to be moved to the appropriate register type on the PLC to be usable. For example floating point values will need to be moved (MOV in the ladder logic) from the N7 integer data table on the PLC to the F8 floating point data table on the PLC. Strings will also have to be moved from the N7 integer data table to an ST string data table on the PLC before they can be used.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 8 of 19 www.BannerEngineering.com

PLC Programming Note: The following description assumes that you have configured communications between your PC and the PLC, and that the PLC and vision sensor are connected to the same network. A minimum of three message commands will be needed to communicate with the vision sensor. The first message command transfers the N7 data from the vision sensor to the PLC memory continuously. This allows the PLC to monitor the vision system outputs in as near to real-time as is possible given the PLC scan time and the latency of the Industrial Ethernet protocol. The second and third message commands are needed for input to the vision sensor. Because the vision sensor must see a transition from 0 to 1 for each trigger, each trigger must do two writes from the PLC, the first MSG writes a 1 into the vision sensors N14 data table, causing the trigger, and the second MSG writes a 0 into the N14 data table to get the vision sensor ready for the next trigger. Note: On power-up, the vision sensors N14 bits are set to zero, so the first cycle will cause the vision sensor to trigger.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 9 of 19 www.BannerEngineering.com

The ladder logic shown below is a simple program implementing the first of the Three MSG commands to copy the Output Data from the vision sensor to the PLC. This ladder program may not be the best structure for your application, but it is functional, and demonstrates all of the communications features.

The message command runs on the first scan, and then the second rung of ladder logic causes the MSG command to run over and over again as fast as possible. The third rung of ladder logic simply copies the data from N7 registers to the B3 Binary data table where it is easier to work with. The fourth rung of logic sets the trigger bit in PLC memory if the Trigger Input (Photo 1, address I0:0.0, on ladder) is on, and the vision sensor ready bit is on. (Note that we have not as yet created the message command that would move the trigger bit from the PLC memory to the vision sensor memory and actually cause an inspection to happen) Before we move on to the next MSG command, we should fully explore the settings on this first command. The first setting is the MGS file number shown right on the ladder instruction itself. This particular instruction is MG9:0, the first entry in the MG file data table. You will have to create this data table, and also another data table called the Routing Info. data table. To do this, right-click on the data files list on the left side of the RSLogix programming software, you should be able to Add two new data tables of these two types to use with your MSG commands. Set up these two types of files with at least three entries each, as each MSG command requires a unique entry in each of these data tables. For more information on the MSG command, refer to the Allen-Bradley instruction set reference manual for the type of PLC that you are using.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 10 of 19 www.BannerEngineering.com

The following screenshot is the Setup Screen for the MSG command on ladder rung 0000.

Starting at the top and moving down, set the settings for This Controller: Channel = 1 (Integral) This setting is the hardware-specific number of the Ethernet port, however the Ethernet port number will be different if you are using the 1761-NET-ENI Ethernet communications module. Communication Command = PLC5 Read The Banner vision sensor looks like a PLC5 to the Allen-Bradley software. Data Table Address = N7:0 This is the location of the PLC data table where the data will be copied TO, since this is a Read command (from the Vision Sensor, to the PLC). Size in Elements = 50 A value of 100 or higher may be needed, depending on how much data you would like to move from the PLC into the vision sensor. See the PLC Map saved in the step on page 5 to see how much memory to move.
Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441 Page 11 of 19 www.BannerEngineering.com

Set the Target Device Settings: Message Timeout = 33 This is the default value, it was not changed. Data Table Address = N7:0 The beginning address of the data table on the Vision Sensor where the data is copied FROM. The amount of data copied is set above by the Size in Element parameter. Local / Remote = Local (Default Setting) You may have to change this if you are using an external Ethernet card in an SLC, PLC 5 or Micrologix device, see the appropriate A-B Documentation MultiHop = Yes When you set MultiHop to yes, you will see a second tab appear at the top for MultiHop, we will discuss that setting later. Routing Information File = RIxx where xx is a file number for a Routing Information file, as discussed on page 9, again, refer to the instruction set reference for the PLC that you are using if you have questions about the Routing Information file. The other settings in the dialog box where left at their default value; they can be left as is. Before closing the dialog box, check the settings shown on the next page.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 12 of 19 www.BannerEngineering.com

Click on the MultiHop tab, you should see a display like this:

The only setting to change in this dialog box is the To Address in line one of the hop table. This is where you enter the IP address of the vision sensor. The IP address of the vision sensor can be found in the lower left hand corner of the PresencePLUS PC software. Once this setting is done, the MSG command is complete, and you can close the MSG setup dialog box. Note: If you are using the 1761-NET-ENI Ethernet communications module, you may have an additional hop table entry through the DF1 port on your Micrologix processor. This is OK, but check the documentation for your specific processor and communications card.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 13 of 19 www.BannerEngineering.com

The next set of ladder commands send the next two MSG commands to write data from the PLC to the vision sensor.

The first rung on this screenshot, rung 0004 executes the MSG command if any one of the input bits is ON in the PLC memory. This MSG instruction will be explained in detail on the next page, but its main purpose is to copy the B3 trigger inputs into the vision sensors N14 data table, so that they cause a trigger to happen on the vision sensor. Rung 0005 unlatches the trigger bit if the MSG command is done, 0006 and 0007 do the same for the remote teach and product change trigger bits. Finally, rung 0008 is another MSG command that writes all zeros back into the vision sensor to get it ready for the next time a trigger is needed. The setup for the MSG command on rung 0008 is exactly the same as that on rung 0004, but they still need separate RI and MG files.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 14 of 19 www.BannerEngineering.com

The following screenshots are details from the second MSG command, shown on Rung 004 of the program:

Starting at the top and moving down, set the settings for This Controller: Channel = 1 (Integral) Same as before Communication Command = PLC5 Write This time we are copying from the PLC to the vision sensor. Data Table Address = B3:3 This is the location of the PLC data table where the data will be copied FROM. Size in Elements = 1 We only need to copy one word to cause the trigger event to happen on the Vision.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 15 of 19 www.BannerEngineering.com

Set the Target Device Settings: Message Timeout = 33 This is the default value, it was not changed. Data Table Address = N14:0 The beginning address for the data table on the vision sensor where the data is copied TO, since this is a write command from the PLC. Local / Remote = Local (Default Setting) Same setting as before. MultiHop = Yes Use the same hop table as the previous command, as shown on page 12. Routing Information File = RIxx where xx is a unique Routing Info. File, different for each MSG command. The other settings in the dialog box were left at their default value, they can be left as is. The third and final MSG command is configured exactly the same as the second, except that it must have its own unique MG and RI Files.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 16 of 19 www.BannerEngineering.com

The final task for the PLC program is to use the data that has been communicated to the PLCs N7 data tables in order to make a judgment. The integer and bit data can be used as is from the vision sensor, however, any floating point numbers or string data will need to be moved into the appropriate data table before it can be used. The ladder below shows an example of how this can be accomplished:

The first rung, 0009, shows the PLC using the pass bit from the vision sensor to set an output on the PLC, O0:0.0. Rung 0010 is setting an output if the inspection fails. The next rung, 0011, is jumping to a subroutine that is a list of MOV commands. See the screenshot below for listing of the subroutine. This subroutine was copied from a tech note on Allen-Bradleys knowledge base website, see the references section at the end of this report. The final rungs on the ladder, 0012 and 0013, copy the string data from the ST data table and display them on the small built-in display on the Micrologix 1100.
Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441 Page 17 of 19 www.BannerEngineering.com

The first rung of this sub-routine moves the string length field. The following rungs move a single word (two ASCII characters each). The vision sensor PLC Map from the step on page 5 shows that there are 20 characters, so that requires 10 more MOV commands to copy the entire string over from the N7 data table to the ST data table. The same MOV command can NOT be used to move the Floating point numbers from the N7 data table to the F8 data table. Instead, use the CPW command, with the Source set to the even word boundary of the N7 table (Floats are two 16-bit words), and the Destination set to F8 something. The CPW command can move multiple floats if they are in contiguous memory locations.

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 18 of 19 www.BannerEngineering.com

Resources: Banner Vision Sensor Software CD, p/n 72806, (Release 2005R7) Manuals Ethernet IP Users Guide December 13, 2005 AKA Ethernet/IP and Modbus/TCP Users Guide Communications Setup Instruction Instruction to install Banner EDS file Manuals P4 BCR Users Manual Micrologix 1100 Programmable Controllers Users Manual Allen Bradley publication 1763-UM001A-EN-P August 2005 See http://www.ab.com/literature/manuals Micrologix 1100 Programmable Controllers Instruction Set Reference Manual Allen Bradley publication 1763-RM001A-EN-P August 2005 See http://www.ab.com/literature/manuals Allen-Bradley Knowledge Base Article A21057774 How to move data from an N file to an ST file in the Micrologix 1200/1500 http://domino.automation.rockwell.com/applications/kb/RAKB.nsf/$$Search/?OpenForm Enter Article number A21057774 and hit enter to see the document and an example SLC 5/05 and PLC 5E Users Manuals and Instruction Set Reference Manuals See http://www.ab.com/literature/manuals

Banner Engineering 9714 10th Ave. North Minneapolis, MN 55441

Page 19 of 19 www.BannerEngineering.com

Das könnte Ihnen auch gefallen