You are on page 1of 24

Network Communications

Session 8
Objectives
• Describe different forms of communication:
• PLC protocols
• FTP
• TCP/IP

• Understand basic Client / Server communication

Lab: Communicate between In-Sight and a PC


(HyperTerminal) using:
• TCP/IP (device functions)

8-2
For What is Networking Used?
• Data
• Transfer cell values between In-Sight sensors, PCs, or factory floor
devices

• Control
• Control of Events, Triggers, Jobs, Online/Offline Status from a third
party source

• Image
• For display purposes in third party applications
• For image archival

8-3
Who can Communicate?
• In-Sight <-> In-Sight

• In-Sight <-> Computer

• In-Sight <-> PLC/Controller

8-4
Supported Communication

8-5
Supported Communication (cont.)

8-6
Protocols for PLC
• EtherNet/IP *
• Rockwell such as the ControlLogix
• Can do Implicit and Explicit messaging
• ProfiNET *
• Siemens such as the S7-300 and S7-400
• Through Buffer commands and the variable table
• MC Protocol (MELSEC)
• Mitsubishi such as Q- and L- series PLCs
• CC link is the hardware implementation (remote registry)
• CIPSync
• Isochronous communication with embedded time stamps

* Interactive Tutorials available in Support section of the web (www.cognex.com)


8-7
TCP/IP: Client / Server

Between In-Sight & any other TCP/IP device, such as:

• Ethernet I/O module

• PLC

• PC running Visual Basic

• Another In-Sight

8-8
Terminology: TCP/IP and IP address

TCP/IP – Transmission Control Protocol / Internet Protocol, a


widely used protocol for communication on networks,
including the Internet

IP address - At any point in time, each host on a given network


must have a unique address of form xxx.xxx.xxx.xxx where
the xxx would be a number from 0 to 255

Microsoft’s default TCP/IP network is 192.168.0.xxx

8-9
Terminology: IP address

Two types of networks


• Static IP address – always same for a given host, usually
assigned by Network Administrator

• Dynamic IP address – assigned each time host joins network,


may be different each time. A network on which this occurs
uses a Dynamic Host Control Protocol (DHCP) server.

In-Sight can be configured for either

8-10
Terminology: Subnet
Subnet = networked In-Sights with similar IP addresses

• Allowable IP addresses on a subnet are defined by its subnet mask, which


is stored on every host

• Example: 255.255.255.0

255 means all IP addresses on this subnet are identical in this position
0 means each host IP address is different in this position

Addresses on this subnet could be


192.168.0.1
192.168.0.4
192.168.0.126
192.168.0.203

8-11
Hosts Not on the Same Subnet

To log onto a host not on the subnet, you need to specify the
host’s IP address

8-12
Device Functions
• WriteDevice – Sends one or more cell values to another device
over the network using TCP/IP
• If value is a number, sent as a string
• If value #ERR, nothing is sent

• ReadDevice – Receives data from another device on the network


• If running a job, waits to complete - otherwise, async

• TCPDevice
- Used with both WriteDevice and ReadDevice
- Establishes TCP/IP connection (Client/Server)

8-13
TCP
Client Server
(sender) (receiver)

Event

TCPDevice TCPDevice

WriteDevice ReadDevice

Data

8-14
TCP
Client Server
(sender) (receiver)

Event

TCPDevice TCPDevice

WriteDevice ReadDevice

Data
TCPDevice TCPDevice

Timeout ignored in server mode


8-15
TCPDevice: Auto-Inserted Functions
Inserts WriteDevice & “Test Inserts ReadDevice on
String” on Client Server

Change C2 reference to
cell containing number or string
such as FormatString

8-16
TCP/IP
• For In-Sight to In-Sight, both sender and receiver must go
Online before doing a WriteDevice or ReadDevice

• Can have multiple connections between 2 devices, so long


as each connection uses a different port number

• Jobs can have up to 12 connections (TCPDevices)

8-17
WriteImageFTP Parameters

• Event to initiate image write


• Name or IP address of FTP server
• Username for FTP server
• Password for FTP server
• Image to be saved
• Path where image is being saved
• Maximum image count
• Reset image count to 0
• BMP or JPG
• Saves with overlay (only with 3400 system)
• Resolution of saved image
• Drops subsequent images in FTP queue if
one is waiting

8-18
WriteImageFTP

• Spread Sheet cell contains a Structure

• The target device can be an In-Sight


emulator, or any other host acting as
an FTP server on the network.

• If a file path is not specified, the


image file will be written to the default
directory of the FTP server on the
target host.

Windows 7 Default Path:


C:\ProgramData\Cognex\In-Sight\In-Sight Explorer 4.7.3\Emulator 8-19
WriteFTP
Spread Sheet cell contains a Structure(s) and auto
Inserted cell(s) depending on Data Format selected

* Must leave String empty for auto-inserted functions

• Data Formats
0 = TEXT
Standard ASCII Text file format (.TXT)

1 = HTML (default)
Standard HTML file format (.HTM)

4 = XML
Standard XML file format (.XML)

8-20
WriteFTP – Neat Trick

• HTML format

Text to be written (replace


• Reference an auto inserted string (K13) with FormatString)
containing the formatted “HTML code”

• Auto Inserts a cell with a Write Image FTP


function

8-21
WriteFTP
• HTML format
• Web Page generated from Write FTP with HTML
selected

 With Visual Web Developer


• Change the look per your HTML code
• Free from Microsoft

8-22
Common Issues
• Make sure that system is online

• Username and password is case sensitive

• If path is stated, make sure that folder exists. In-Sight does


not create folders.

• To control which images are written, develop logic to control


the cell state of the WriteImageFTP function

• Numbering will wrap around when max is reached


8-23
Summary
• Many ways to Communicate with In-Sight
• Realtime communication protocols with PLC
• Simple way to add OPC data to another application

• Device Functions allow for asynchronous communication


• TCPDevice defines client and server as well as the channel
• Data is sent / received as strings - #ERR will not be sent

• FTP functions allow images (or data) to be written directly from


the sensor

8-24

You might also like