National Instruments DeviceNet NI-DNET User Manual - Contents

Manual is about: National Instruments DeviceNet NI-DNET User Manual

Summary of DeviceNet NI-DNET

  • Page 1

    Devicenet t ni-dnet tm user manual ni-dnet user manual may 2004 edition part number 370375b-01.

  • Page 2

    Support worldwide technical support and product information ni.Com national instruments corporate headquarters 11500 north mopac expressway austin, texas 78759-3504 usa tel: 512 683 0100 worldwide offices australia 1800 300 800, austria 43 0 662 45 79 90 0, belgium 32 0 2 757 00 20, brazil 55 11 326...

  • Page 3: Important Information

    Important information warranty the can/devicenet hardware is warranted against defects in materials and workmanship for a period of one year from the date of shipment, as evidenced by receipts or other documentation. National instruments will, at its option, repair or replace equipment that proves t...

  • Page 4: Contents

    © national instruments corporation v ni-dnet user manual contents about this manual how to use the manual set ...........................................................................................Ix conventions .......................................................................................

  • Page 5

    Contents ni-dnet user manual vi ni.Com programming model for ni-dnet applications ......................................................... 3-6 step 1. Open objects....................................................................................... 3-8 step 2. Start communication ...................

  • Page 6

    Contents © national instruments corporation vii ni-dnet user manual appendix b cabling requirements connector pinouts..........................................................................................................B-1 power supply information for the devicenet ports ...........................

  • Page 7: About This Manual

    © national instruments corporation ix ni-dnet user manual about this manual this manual describes the basics of devicenet and explains how to develop an application program, including reference to examples. The user manual also contains hardware information. How to use the manual set use the install...

  • Page 8: Conventions

    About this manual ni-dnet user manual x ni.Com conventions the following conventions appear in this manual: » the » symbol leads you through nested menu items and dialog box options to a final action. The sequence file»page setup»options directs you to open the file menu, select the page setup item,...

  • Page 9

    About this manual © national instruments corporation xi ni-dnet user manual • labview online reference • odva website, www.Odva.Org • microsoft win32 software development kit (sdk) online help.

  • Page 10: Ni-Dnet Software Overview

    © national instruments corporation 1-1 ni-dnet user manual 1 ni-dnet software overview the devicenet software provided with national instruments devicenet hardware is called ni-dnet. This section provides an overview of the ni-dnet software. Installation and configuration measurement & automation ex...

  • Page 11

    Chapter 1 ni-dnet software overview ni-dnet user manual 1-2 ni.Com figure 1-1. Ni-dnet cards listed in max note each card’s name uses the word can, because the controller area network is the communication protocol upon which devicenet is built. If your ni devicenet hardware is not listed here, max i...

  • Page 12

    Chapter 1 ni-dnet software overview © national instruments corporation 1-3 ni-dnet user manual configure devicenet port the physical port of each devicenet card is listed under the card’s name. To configure software properties, right-click the port and select properties . In the properties dialog, y...

  • Page 13: Ni-Dnet Objects

    Chapter 1 ni-dnet software overview ni-dnet user manual 1-4 ni.Com ni-spy this tool monitors function calls to the ni-dnet apis. This tool helps in debugging programming problems in your application. To launch this tool, open the software branch of the max configuration tree, right-click ni spy , an...

  • Page 14

    Chapter 1 ni-dnet software overview © national instruments corporation 1-5 ni-dnet user manual much like any other object-oriented system, ni-dnet device driver objects use the concepts of class, instance, attribute, and service to describe their features. The ni-dnet device driver software provides...

  • Page 15

    Chapter 1 ni-dnet software overview ni-dnet user manual 1-6 ni.Com • execute the devicenet set attribute single service on the remote device ( ncsetdnetattribute ) • send any other explicit message request to the remote device and receive the associated explicit message response ( ncwritednetexplmsg...

  • Page 16: Using Ni-Can With Ni-Dnet

    Chapter 1 ni-dnet software overview © national instruments corporation 1-7 ni-dnet user manual figure 1-2. Ni-dnet objects for a network of three devices using ni-can with ni-dnet controller area network (can) is the low-level protocol used for devicenet communications. In addition to the ni-dnet fu...

  • Page 17

    Chapter 1 ni-dnet software overview ni-dnet user manual 1-8 ni.Com ni-dnet (default), or can for ni-can. When the can protocol is selected, you can access can tools in max, such as the bus monitor tool that displays can messages in their raw form. In order to develop ni-can applications, you must in...

  • Page 18: Ni-Dnet Hardware Overview

    © national instruments corporation 2-1 ni-dnet user manual 2 ni-dnet hardware overview types of hardware the national instruments devicenet hardware includes the pci-can, pxi-8461, and pcmcia-can. The pci-can is software configurable and compliant with the pci local bus specification. It features th...

  • Page 19

    Chapter 2 ni-dnet hardware overview ni-dnet user manual 2-2 ni.Com for more information on the devicenet physical layer and cables used to connect to your devicenet devices, refer to appendix b, cabling requirements . For connection to the network, the pci-can, pxi-8461, and pcmcia-can for devicenet...

  • Page 20: Developing Your Application

    © national instruments corporation 3-1 ni-dnet user manual 3 developing your application this chapter explains how to develop an application using the ni-dnet functions. Accessing ni-dnet from your programming environment applications can access the ni-dnet driver software by using either labview, l...

  • Page 21

    Chapter 3 developing your application ni-dnet user manual 3-2 ni.Com labwindows/cvi within labwindows/cvi, the ni-dnet function panel is located in library»ni-dnet . Like other labwindows/cvi function panels, the ni-dnet function panel provides help for each function and the ability to generate code...

  • Page 22

    Chapter 3 developing your application © national instruments corporation 3-3 ni-dnet user manual microsoft c/c++ the ni-dnet software supports microsoft visual c/c++ version 6. The header file and library for visual c/c++ 6 are in the ms visual c folder of the ni-dnet folder. The typical path to thi...

  • Page 23

    Chapter 3 developing your application ni-dnet user manual 3-4 ni.Com for c applications (files with .C extension), include the header file by adding a #include to the beginning of your code, like this: #include "nidnet.H" for c++ applications (files with .Cpp extension), define _cplusplus before inc...

  • Page 24

    Chapter 3 developing your application © national instruments corporation 3-5 ni-dnet user manual 2. Get the addresses for the ni-dnet dll functions you will use. Your application must use the win32 getprocaddress function to get the addresses of the ni-dnet functions your application needs. For each...

  • Page 25

    Chapter 3 developing your application ni-dnet user manual 3-6 ni.Com 3. Configure your application to de-reference the pointer to call an ni-dnet function, as illustrated by the following code. Nctype_status status; nctype_objh myobjh; status = (*pncopendnetio) ("dnet0", &myobjh); if (status printf(...

  • Page 26

    Chapter 3 developing your application © national instruments corporation 3-7 ni-dnet user manual figure 3-1. General programming steps for an ni-dnet application 1. Open interface object 2. Open all i/o and explicit messaging (em) objects required for your application 3. Call ncsetdriverattr , if ne...

  • Page 27

    Chapter 3 developing your application ni-dnet user manual 3-8 ni.Com step 1. Open objects before you use an ni-dnet object in your application, you must configure and open it using either ncopendnetintf , ncopendnetexplmsg , or ncopendnetio . These open functions return a handle for use in all subse...

  • Page 28

    Chapter 3 developing your application © national instruments corporation 3-9 ni-dnet user manual 2. Call the ncwaitforstate function with the desiredstate parameter set to read available . This function waits for output data to be transmitted and for new input data to be received. If your applicatio...

  • Page 29

    Chapter 3 developing your application ni-dnet user manual 3-10 ni.Com step 4. Stop communication before you exit your application, stop communication to shut down devicenet connections to remote devices. Use the interface object to call the ncoperatednetintf function with the opcode parameter set to...

  • Page 30: Checking Status In Labview

    Chapter 3 developing your application © national instruments corporation 3-11 ni-dnet user manual if you use two different applications on the same interface and open i/o connections to different devices, you must set pollmode to either scanned or individual . You cannot use pollmode of automatic , ...

  • Page 31

    Chapter 3 developing your application ni-dnet user manual 3-12 ni.Com your application code should check the status returned from every ni-dnet function. If an error is detected, you should close all ni-dnet handles, then exit the application. If a warning is detected, you can display a message for ...

  • Page 32: Ni-Dnet Programming

    © national instruments corporation 4-1 ni-dnet user manual 4 ni-dnet programming techniques this chapter describes various techniques to help you program your ni-dnet application. The techniques include configuration of i/o connection timing, using i/o data (assemblies), using explicit messaging, an...

  • Page 33

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-2 ni.Com when you select an exppacketrate for an i/o connection, you must consider all i/o connections in your system. For example, although you might be able to configure an exppacketrate of 3 ms for a single i/o connection, you cannot ...

  • Page 34

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-3 ni-dnet user manual polled i/o polled i/o connections use a separate poll command and response message for each device. The overall scheme that ni-dnet uses to time polled i/o connections is determined by the pollmode pa...

  • Page 35

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-4 ni.Com • if you set the pollmode parameter of ncopendnetintf to scanned , to configure scanned i/o you must specify the exact same exppacketrate when you open each of your strobed/polled i/o connections. Using this scheme, you must det...

  • Page 36

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-5 ni-dnet user manual background polling maintains overall network consistency because ni-dnet evenly disperses all background poll commands among multiple foreground cycles. In other words, all background poll commands ar...

  • Page 37

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-6 ni.Com since the poll commands are not synchronized for individual polling, they can often be scattered relatively randomly. They can be evenly interspersed for a while, then suddenly occur in bursts of back-to-back messages. Because o...

  • Page 38

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-7 ni-dnet user manual change-of-state (cos) i/o change-of-state i/o connections use the same timing scheme as cyclic i/o connections, but in addition to the exppacketrate , cos i/o sends data to the master whenever a chang...

  • Page 39

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-8 ni.Com for strobed and polled i/o connections, determination of a valid exppacketrate can be somewhat complex. If you have trouble estimating an exppacketrate value for strobed/polled i/o, set the pollmode parameter of your initial cal...

  • Page 40

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-9 ni-dnet user manual • some device vendors provide comments about i/o assemblies in an electronic data sheet (eds). The eds file is a text file whose format is defined by the devicenet specification. • ask the device’s ve...

  • Page 41

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-10 ni.Com by consulting the specifications for the control supervisor object and the ac/dc drive object, you can determine that the devicenet data type for run fwd and fault reset is bool (boolean), and the devicenet data type for speed ...

  • Page 42

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-11 ni-dnet user manual 4. Right-click on the byteoffset terminal and select create constant , then enter 0 as the byte offset. 5. Right-click on the 8[tf] in terminal and select create control . In the front panel control ...

  • Page 43

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-12 ni.Com 2. Initialize the array to all zero. For (i = 0; i outputasm [i] = 0; 3. Assume you have two boolean variables, runfwd and resetfault , of type nctype_bool . For labwindows/cvi, these variables could be accessed from front pane...

  • Page 44

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-13 ni-dnet user manual easiest way to execute the set attribute single service on a remote device is to use the ni-dnet ncsetdnetattribute function. For a given attribute of a devicenet device, you need the following infor...

  • Page 45: Handling Multiple Devices

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-14 ni.Com specification defines the overall format of these services, in most cases their meaning and service data are object-specific or vendor-specific. Unless your device requires such services and documents them in detail, you probab...

  • Page 46

    Chapter 4 ni-dnet programming techniques © national instruments corporation 4-15 ni-dnet user manual for the c programming language, you can declare a structure typedef to store the parameters of ncopendnetio , similar to the following: typedef struct { nctype_uint32devicemacid; nctype_conn_typeconn...

  • Page 47

    Chapter 4 ni-dnet programming techniques ni-dnet user manual 4-16 ni.Com main loop if your application essentially accesses all devicenet input/output data as a single image, you would normally wait for read data to become available on one of the input connections (such as a strobed i/o connection),...

  • Page 48: Devicenet Overview

    © national instruments corporation a-1 ni-dnet user manual a devicenet overview this appendix gives an overview of devicenet. History of devicenet the controller area network (can) was developed in the early 1980s by bosch, a leading automotive equipment supplier. Can was developed to overcome the l...

  • Page 49

    Appendix a devicenet overview ni-dnet user manual a-2 ni.Com physical characteristics of devicenet the following list summarizes the physical characteristics of devicenet. • trunkline-dropline cabling—main trunk cable with a drop cable for each device • selectable baud rates of 125 k, 250 k, and 500...

  • Page 50

    Appendix a devicenet overview © national instruments corporation a-3 ni-dnet user manual figure a-1. Classes of geometric shapes all squares belong to the same class because they all have similar qualities, such as four equal sides. The term instance refers to a specific instance of a given class. F...

  • Page 51

    Appendix a devicenet overview ni-dnet user manual a-4 ni.Com figure a-2. Object modeling used in devicenet specification every devicenet device contains at least one instance (instance one) of the identity object. The identity object instance defines attributes which describe the device, including t...

  • Page 52

    Appendix a devicenet overview © national instruments corporation a-5 ni-dnet user manual in figure a-2, the term application object(s) refers to objects within the device which are used to perform its fundamental behavior. For example, within a photoelectric sensor, an instance of the presence sensi...

  • Page 53

    Appendix a devicenet overview ni-dnet user manual a-6 ni.Com the following tables describe the general format of devicenet explicit message requests and responses as they appear on the devicenet network. The devicenet specification defines a set of services supported in a common way by different dev...

  • Page 54: I/o Connections

    Appendix a devicenet overview © national instruments corporation a-7 ni-dnet user manual the get attribute single service obtains the value of a specific attribute within a device’s object, and the set attribute single service sets the value of an attribute. These get and set services are the most c...

  • Page 55

    Appendix a devicenet overview ni-dnet user manual a-8 ni.Com the devicenet specification defines four types of master/slave i/o connections: polled, bit strobed, change-of-state (cos), and cyclic. A slave device can support at most one polled, one strobed, and one cos or cyclic connection (cos and c...

  • Page 56

    Appendix a devicenet overview © national instruments corporation a-9 ni-dnet user manual slave. This strobe command (request) message is received by all slave devices simultaneously and can be used to trigger simultaneous measurements (such as to take multiple photoelectric readings simultaneously)....

  • Page 57

    Appendix a devicenet overview ni-dnet user manual a-10 ni.Com the cyclic i/o connection enables a slave device to send input data to its master at the configured epr interval. You normally configure the epr to be consistent with the rate at which the device measures its physical input sensors. For e...

  • Page 58: Assembly Objects

    Appendix a devicenet overview © national instruments corporation a-11 ni-dnet user manual figure a-5 shows an example of four cos/cyclic i/o connections. Figure a-5. Cos/cyclic i/o example assembly objects one of the more important objects in the devicenet specification is the assembly object. There...

  • Page 59

    Appendix a devicenet overview ni-dnet user manual a-12 ni.Com figure a-6. Input and output assemblies as a more specific example, consider a devicenet photoelectric sensor (photoeye) or a limit switch. These devices contain a single instance of a class called the presence sensing object. This instan...

  • Page 60

    Appendix a devicenet overview © national instruments corporation a-13 ni-dnet user manual as you can see, to use the data bytes contained in i/o messages, it is important to know the format of a device’s internal input and output assemblies. Device profiles to provide interoperability for devices of...

  • Page 61: Cabling Requirements

    © national instruments corporation b-1 ni-dnet user manual b cabling requirements this appendix describes the cabling requirements for the hardware. Cables should be constructed to meet these requirements as well as the requirements of devicenet. Devicenet cabling requirements can be found in the de...

  • Page 62

    Appendix b cabling requirements ni-dnet user manual b-2 ni.Com figure b-2 shows the end of a pcmcia-can bus-powered cable. The arrow points to pin 1 of the 5-pin screw terminal block. All of the signals on the 5-pin combicon-style pluggable screw terminal are connected directly to the corresponding ...

  • Page 63

    Appendix b cabling requirements © national instruments corporation b-3 ni-dnet user manual power supply information for the devicenet ports the bus must supply power to each devicenet port. The bus power supply should be a dc power supply with an output of 10 v to 30 v. The devicenet physical layer ...

  • Page 64

    Appendix b cabling requirements ni-dnet user manual b-4 ni.Com the pci-can is shipped with this jumper set in the ext position. In this position, the physical layer is powered from the bus (the v+ and v– pins on the combicon connector). The jumper must be in this position for the devicenet interface...

  • Page 65

    Appendix b cabling requirements © national instruments corporation b-5 ni-dnet user manual figure b-6. Pxi-8461 parts locator diagram connecting pins 1 and 2 of a jumper configures the pxi-8461 physical layer to be powered externally (from the bus cable power). In this configuration, the power must ...

  • Page 66: Cable Specifications

    Appendix b cabling requirements ni-dnet user manual b-6 ni.Com cable specifications cables should meet the requirements of the devicenet cable specification. Devicenet cabling requirements can be found in the devicenet specification . Belden cable (3084a) meets all of those requirements and should b...

  • Page 67: Cable Termination

    Appendix b cabling requirements © national instruments corporation b-7 ni-dnet user manual cable termination the pair of signal wires (can_h and can_l) constitutes a transmission line. If the transmission line is not terminated, each signal change on the line causes reflections that may cause commun...

  • Page 68: Cabling Example

    Appendix b cabling requirements ni-dnet user manual b-8 ni.Com cabling example figure b-8 shows an example of a cable to connect two devicenet devices. Figure b-8. Cabling example 9-pin d-sub 9-pin d-sub can_h can_l gnd v+ v+ v– v– 5-pin combicon 5-pin combicon pin 7 pin 4 pin 7 pin 4 pin 2 pin 2 pi...

  • Page 69: Troubleshooting and

    © national instruments corporation c-1 ni-dnet user manual c troubleshooting and common questions this appendix describes how to troubleshoot problems with the ni-dnet software and answers some common questions. Troubleshooting with the measurement & automation explorer (max) max contains configurat...

  • Page 70

    Appendix c troubleshooting and common questions ni-dnet user manual c-2 ni.Com troubleshooting self test failures the following topics explain common error messages generated by the self test in max. Application in use this error occurs if you are running an application that is using the can card. T...

  • Page 71: Common Questions

    Appendix c troubleshooting and common questions © national instruments corporation c-3 ni-dnet user manual if the error continues after restart, uninstall ni-can (and ni-dnet) and then reinstall. Ni-can hardware problem encountered this error occurs if the self test detects a defect in the can hardw...

  • Page 72

    Appendix c troubleshooting and common questions ni-dnet user manual c-4 ni.Com can i use multiple pcmcia cards in one computer? Yes, but make sure there are enough free resources available. Unlike pci or pxi can cards, pcmcia can cards cannot share resources, such as irqs, with other devices. I have...

  • Page 73: Hardware Specifications

    © national instruments corporation d-1 ni-dnet user manual d hardware specifications this appendix describes the physical characteristics of the devicenet hardware, along with the recommended operating conditions. Pci-can series dimensions............................................. 10.67 by 17.46 ...

  • Page 74

    Appendix d hardware specifications ni-dnet user manual d-2 ni.Com storage environment ambient temperature .......................–20 to 70 °c relative humidity ............................5 to 90%, noncondensing pxi-can series dimensions .............................................16.0 by 10.0 cm (...

  • Page 75

    Appendix d hardware specifications © national instruments corporation d-3 ni-dnet user manual port characteristics bus power .............................................. 0 to 30 v, 40 ma typical, 100 ma maximum can-h, can-l..................................... –8 to +18 v, dc or peak, cati safety ...

  • Page 76

    Appendix d hardware specifications ni-dnet user manual d-4 ni.Com ce compliance this product meets the essential requirements of applicable european directives, as amended for ce marking, as follows: low-voltage directive (safety)..............73/23/eec electromagnetic compatibility directive (emc) ...

  • Page 77: Technical Support and

    © national instruments corporation e-1 ni-dnet user manual e technical support and professional services visit the following sections of the national instruments web site at ni.Com for technical support and professional services: • support —online technical support resources at ni.Com/support includ...

  • Page 78: Glossary

    © national instruments corporation g-1 ni-dnet user manual glossary symbol prefix value m milli 10 –3 k kilo 10 3 a a amperes ac alternating current actuator a device that uses electrical, mechanical, or other signals to change the value of an external, real-world variable. In the context of device ...

  • Page 79

    Glossary ni-dnet user manual g-2 ni.Com b b bits background polling a polled i/o communication scheme in which all polled slaves are grouped into two different communication rates: a foreground rate and a slower background rate. Bit strobed i/o master/slave i/o connection in which the master broadca...

  • Page 80

    Glossary © national instruments corporation g-3 ni-dnet user manual d dc direct current device a physical assembly, linked to a communication line (cable), capable of communicating across the network according to a protocol specification. Device network multi-drop digital communication network for s...

  • Page 81

    Glossary ni-dnet user manual g-4 ni.Com h hex hexadecimal hz hertz i i/o connection connection used for exchange of physical input/output (sensor/activator) data, as well as other control-oriented data. In. Inches individual polling a polled i/o communication scheme in which each polled slave commun...

  • Page 82

    Glossary © national instruments corporation g-5 ni-dnet user manual master/slave devicenet communication scheme in which a master device allocates connections to one or more slave devices, and those slave devices can only communicate with the master and not one another. Mb megabytes of memory member...

  • Page 83

    Glossary ni-dnet user manual g-6 ni.Com p pc personal computer peer-to-peer devicenet communication scheme in which each device communicates as a peer and connections are established among devices as needed. Plc programmable logic controller polled i/o master/slave i/o connection in which the master...

  • Page 84

    Glossary © national instruments corporation g-7 ni-dnet user manual service an action performed on an instance to affect its behavior; the externally visible code of an object. Within ni-dnet, you use ni-dnet functions to execute services for objects. Also known as method and operation. Strobed i/o ...

  • Page 85: Index

    © national instruments corporation i-1 ni-dnet user manual index c ce compliance, d-4 change protocol, 1-3 common questions, c-3 and troubleshooting, c-1 components left after ni-can software uninstall, c-4 determining ni-can software version, c-3 how many can interfaces can be configured, c-3 inter...

  • Page 86

    Index ni-dnet user manual i-2 ni.Com l labview real-time (rt) software configuration, 1-3 tools, 1-3 m max ni-dnet cards listed in max (figure), 1-2 tools launched from, 1-3 measurement & automation explorer (max). See max memory resource conflict, troubleshooting, c-2 missing can card, troubleshoot...