ncOpenDnetIntf (Open DeviceNet Interface)

NI-DNET Programmer

ncOpenDnetIntf (Open DeviceNet Interface)

Purpose

Configure and open an NI-DNET Interface Object.

Format

LabVIEW

C

NCTYPE_STATUS
ncOpenDnetIntf(	NCTYPE_STRING	IntfName,
		NCTYPE_UINT32	IntfMacId,
		NCTYPE_UINT32>	BaudRate,
		NCTYPE_UINT32	PollMode,
		NCTYPE_OBJH_P	ObjHandle);

Input

IntfName Name of DeviceNet interface
IntfMacId MAC ID of the DeviceNet interface
BaudRate Baud rate
PollMode Communication scheme for all polled I/O connections

Output

ObjHandle Object handle you use with all subsequent function calls for the Interface Object

Function Description

ncOpenDnetIntf configures and opens an NI-DNET Interface Object and returns a handle that you use with all subsequent function calls for that object.

The Interface Object represents a DeviceNet interface. Since this interface acts as a device on the DeviceNet network much like any other device, it is configured with its own MAC ID and baud rate.

Use the Interface Object to do the following:

  • Configure NI-DNET settings which apply to the entire interface.
  • Start and stop communication for all NI-DNET objects associated with the interface.

The Interface Object must be the first NI-DNET object opened by your application, and thus ncOpenDnetIntf must be the first NI-DNET function called by your application.

Parameter Descriptions

IntfName

Description Name of the DeviceNet interface as an ASCII string with format "DNETx", where x is a decimal number starting at zero that indicates which DeviceNet interface is being used. You associate DeviceNet interface names with physical ports using Measurement & Automation Explorer (MAX).
Values "DNET0", "DNET1", ..."DNET31"

In LabVIEW, the interface name is selected from an enumerated list. The LabWindows/CVI function panel also provides an enumerated list.

IntfMacId

Description MAC ID (device address) of the DeviceNet interface. This is the MAC ID used by your DeviceNet interface for communication with other DeviceNet devices.

A device's MAC ID indicates the priority of its DeviceNet messages on the network, with lower numbered MAC IDs having higher priority. If your DeviceNet interface is the only master in the network (the usual case), this MAC ID is often set to 0.
Values 0 to 63

BaudRate

Description Baud rate used for communication on the network connected to the DeviceNet interface. The DeviceNet protocol supports baud rates of 125,000, 250,000, and 500,000 b/s.
Values 125000, 250000, or 500000

In LabVIEW, you select the baud rate from an enumerated list. The LabWindows/CVI function panel also provides an enumerated list.

PollMode

Description Determines the communication scheme used for all polled I/O connections in which the interface acts as a master. The poll mode determines the overall scheme used to transmit poll requests to slave devices.

Automatic

The default poll mode is Automatic. Use this mode if you do not want to specify exact timing for polled and strobed I/O connections. In Automatic mode, the NI-DNET software automatically calculates a safe rate for production of all poll requests and strobe requests. This mode is similar to Scanned mode, except that you do not need to specify a valid ExpPacketRate for each polled/strobed I/O Object (ExpPacketRate is ignored).

If you use Automatic, you cannot call the ncOpenDnetIO function while communicating (after ncOperateDnetIntf with Start), because the automatic rate calculation occurs during Start. Use Scanned or Individual if you need to open I/O connections while communicating.

Scanned

This mode enables the traditional scanned I/O scheme for polled and strobed I/O connections. In Scanned mode, all poll requests and strobe requests are produced in quick succession, then NI-DNET waits to receive individual responses. The benefits of scanned I/O are reduced overhead and improved overall determinism on the DeviceNet network.

When using Scanned mode, since all poll and strobe requests are produced at the same time, you normally set the ExpPacketRate for all polled and strobed I/O Objects to a common value.

If you need to isolate devices that are slow to respond to poll requests, it is possible to use different ExpPacketRate values while still maintaining the benefits of scanned I/O. You can set all ExpPacketRate values for polled I/O Objects as two groups: one foreground group, and a second background group whose ExpPacketRate is an exact multiple of the foreground group's. All strobed I/O must use the same rate as the foreground group for polled I/O. For example, you can set some polled I/O (and all strobed I/O) to a common foreground rate of 100 ms, and other polled I/O to a background rate of 500 ms. To maintain overall network determinism, the background poll requests are interspersed evenly among each foreground scan.

Individual

This mode enables you to configure poll rates individually for each polled I/O connection. In Individual mode, poll requests are not produced as a group, but instead each polled I/O connection communicates at an independent rate. The rate at which each poll request is produced is determined solely by the ExpPacketRate of that connection's I/O Object.

Use individual polling when you have detailed knowledge of the time it takes each device to perform its physical measurement or control function. For example, if you have a discrete input device capable of acquiring a new measurement every 10 ms, an analog input device with a measurement rate of 45 ms, and a temperature sensor with a measurement rate of 200 ms, you could use individual polling to communicate with each device at its exact measurement rate. Since communication occurs only at the actual rate needed for each device, individual polling often provides optimum network usage.

For additional information on PollMode and ExpPacketRate, refer to the NI-DNET User Manual.

Values Automatic (constant NC_POLL_AUTO, value 0)

Scanned (constant NC_POLL_SCAN, value 1)

Individual (constant NC_POLL_INDIV, value 2)

In LabVIEW, you select the poll mode from an enumerated list. The LabWindows/CVI function panel also provides an enumerated list.

ObjHandle

Description If the ncOpenDnetIntf function is successful, a handle to the newly opened Interface Object is returned in ObjHandle. This handle is used with all subsequent function calls for that Interface Object.

The function most commonly used with the Interface Object is ncOperateDnetIntf.
Values The encoding of ObjHandle is internal to NI-DNET.

Examples

LabVIEW

Open Interface Object "DNET1" using baud rate 500000, MAC ID 3, and poll mode Scanned.

C

Open Interface Object "DNET0" using baud rate 125000, MAC ID 0, and poll mode Automatic.

NCTYPE_STATUS	status;
NCTYPE_OBJH	objh;
status = ncOpenDnetIntf("DNET0", 0, 125000, NC_POLL_AUTO, &objh);