background image

Chapter 1

Introduction

©

 National Instruments Corporation

1-5

NI-CAN User Manual

Acknowledgment Bit (ACK)

All receivers use the Acknowledgment Bit to acknowledge successful 
reception of the frame. The ACK bit is transmitted recessive (1), and is 
overwritten as dominant (0) by all devices that receive the frame 
successfully. The receivers acknowledge correct frames regardless of the 
acceptance test performed on the arbitration ID. If the transmitter of the 
frame detects no acknowledgment, it could mean that the receivers detected 
an error (such as a CRC error), the ACK bit was corrupted, or there are no 
receivers (for example, only one device on the network). In such cases, the 
transmitter automatically retransmits the frame.

End of Frame

Each frame ends with a sequence of recessive bits. After the required 
number of recessive bits, the CAN bus is idle, and the next frame 
transmission can begin.

CAN Error Detection and Confinement

One of the most important and useful features of CAN is its high reliability, 
even in extremely noisy environments. CAN provides a variety of 
mechanisms to detect errors in frames. This error detection is used to 
retransmit the frame until it is received successfully. CAN also provides an 
error confinement mechanism used to remove a malfunctioning device 
from the CAN network when a high percentage of its frames result in 
errors. This error confinement prevents malfunctioning devices from 
disturbing the overall network traffic.

Error Detection

Whenever any CAN device detects an error in a frame, that device 
transmits a special sequence of bits called an error flag. This error flag is 
normally detected by the device transmitting the invalid frame, which then 
retransmits to correct the error. The retransmission starts over from the start 
of frame, and thus arbitration with other devices is again possible.

CAN devices detect the following errors, which are described in the 
following sections:

Bit error

Stuff error

CRC error

Содержание NI-CAN

Страница 1: ...CAN NI CAN User Manual NI CAN User Manual August 2000 Edition Part Number 370290A 01...

Страница 2: ...ny 089 741 31 30 Greece 30 1 42 96 427 Hong Kong 2645 3186 India 91805275406 Israel 03 6120092 Italy 02 413091 Japan 03 5472 2970 Korea 02 596 7456 Mexico D F 5 280 7625 Mexico Monterrey 8 357 7695 Ne...

Страница 3: ...l Instruments installation operation or maintenance instructions owner s modification of the product owner s abuse misuse or negligent acts and power failure or surges fire flood accident actions of t...

Страница 4: ...interference to radio and television reception Classification requirements are the same for the Federal Communications Commission FCC and the Canadian Department of Communications DOC Changes or modif...

Страница 5: ...s Cet appareil num rique de la classe B respecte toutes les exigences du R glement sur le mat riel brouilleur du Canada European Union Compliance to EEC Directives Readers in the EU EEC EEA must refer...

Страница 6: ...de DLC 1 4 Data Bytes 1 4 Cyclic Redundancy Check CRC 1 4 Acknowledgment Bit ACK 1 5 End of Frame 1 5 CAN Error Detection and Confinement 1 5 Error Detection 1 5 Error Confinement 1 6 Low Speed CAN 1...

Страница 7: ...Step 3 Start Communication 2 8 Step 4 Communicate Using Objects 2 9 Step 5 Close Objects 2 9 Checking Status of Function Calls 2 10 NI CAN Status Format 2 10 Error and Warning Indicators Severity 2 10...

Страница 8: ...CAN Object 5 5 Add CAN Object Configurations 5 6 Remove CAN Object Configurations 5 6 Specify the Configuration Attributes 5 6 Exit the CAN Object Setting Dialog Box 5 7 Complete the Configuration 5...

Страница 9: ...Figure 4 2 Program Flowchart for Example 2 4 6 Figure 4 3 Program Flowchart for Example 3 4 8 Figure 5 1 NI CAN Settings Dialog Box for an AT CAN 2 5 3 Figure 5 2 CAN Object Configuration Dialog Box 5...

Страница 10: ...is 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 pull down the File menu select the Page Setup item...

Страница 11: ...may find helpful as you read this manual ANSI ISO Standard 11898 1993 Road Vehicles Interchange of Digital Information Controller Area Network CAN for High Speed Communication ANSI ISO Standard 11519...

Страница 12: ...ces can be thought of as a scaled down real time low cost version of networks used to connect personal computers Any device on a CAN network can communicate with any other device using a common pair o...

Страница 13: ...elevant to it If the received identifier is not relevant to the device such as RPM received by an air conditioning controller the device ignores the message When more than one CAN device transmits a m...

Страница 14: ...1898 specification supports only the standard frame format Figure 1 2 shows the essential fields of the standard and extended frame formats and the following sections describe each field Figure 1 2 St...

Страница 15: ...ource to transmit the data on its own Identifier Extension IDE The Identifier Extension bit differentiates standard frames from extended frames Because the IDE bit is dominant 0 for standard frames an...

Страница 16: ...n can begin CAN Error Detection and Confinement One of the most important and useful features of CAN is its high reliability even in extremely noisy environments CAN provides a variety of mechanisms t...

Страница 17: ...ve bits of equal value are detected on the bus CRC Error A CRC error is detected by a receiving device whenever the calculated CRC differs from the actual CRC in the frame Form Error A form error occu...

Страница 18: ...active state as long as the transmit and receive error counters are both below 128 In a normally functioning network of CAN devices all devices are in the error active state Error Passive State If eit...

Страница 19: ...lative changes in voltage and thus provides a much higher level of safety The fault tolerance feature means that communications capability is maintained even if any of the ISO11519 wiring failures occ...

Страница 20: ...eviceNet Smart Distributed System SDS and CANopen Device network independence largely applies to terminology such as function names and in no way limits access to the CAN network For example the funct...

Страница 21: ...s above it in the hierarchy As an example consider a CAN device network in which the network interface of a host computer is physically connected to two devices a pushbutton and an LED as shown in Fig...

Страница 22: ...ach object encapsulates Figure 1 4 Applying NI CAN Objects to the Example in Figure 1 3 The CAN Network Interface Object encapsulates the entire CAN network interface Its attributes are used to config...

Страница 23: ...d in this manner you can use the read function to obtain a single data byte that holds the most recent state of the pushbutton NI CAN Software Components The following section highlights important com...

Страница 24: ...predefined constants A 32 bit C language interface file nicanmsc lib is used by Microsoft C C applications to access the NI CAN DLL A 32 bit C language interface file nicanbor lib is used by Borland...

Страница 25: ...een the CAN board and other National Instruments RTSI equipped hardware Refer to the RTSI Bus Appendix in your CAN hardware getting started manual for detailed information about the PCI CAN and AT CAN...

Страница 26: ...with an RTSI bus that allows routing of timing trigger signals between them In a system coupled using the RTSI bus a CAN or DAQ board can be the Master driving the timing trigger signals while other D...

Страница 27: ...ual 1 16 ni com The last three modes configure the object Network Interface or CAN Object as a Master For more information on these modes and a list of examples that configure and test them refer to t...

Страница 28: ...tes by selecting Select Palette Set from the LabVIEW Edit menu then selecting nican_view The NI CAN functions can then be found in your LabVIEW Functions palette for placement into your diagram The NI...

Страница 29: ...ation with the NI CAN language interface for Borland C C nicanbor lib For Borland C C 4 5 you must use direct entry access for NI CAN For LabWindows CVI your application is linked with the NI CAN lang...

Страница 30: ...S _NCFUNC_ PncCloseObject NCTYPE_OBJH ObjHandle static NCTYPE_STATUS _NCFUNC_ PncRead NCTYPE_OBJH ObjHandle NCTYPE_UINT32 DataSize NCTYPE_ANY_P DataPtr PncOpenObject NCTYPE_STATUS _NCFUNC_ NCTYPE_STRI...

Страница 31: ...k Interface Object to read and write complete CAN frames As a CAN frame arrives from over the network it can be placed into the read queue of the CAN Network Interface Object You can retrieve CAN fram...

Страница 32: ...Object encapsulates a specific CAN arbitration ID and its associated data Every CAN Object is always associated with a specific CAN Network Interface Object used to identify the physical interface on...

Страница 33: ...ue A watchdog timeout is provided to ensure that incoming data is received periodically This configuration is useful when you want to apply a timeout to data received for a specific arbitration ID and...

Страница 34: ...ND Communicate Using Objects Wait for Data Available ncWaitForState ncCreateNotification Read Data ncRead Write Data ncwrite and so on Configure Object Yes Are All Objects Configured No Open Object nc...

Страница 35: ...all subsequent NI CAN calls for that object When you are using the G language LabVIEW function library this handle is passed through the upper left and right terminals of each NI CAN function used af...

Страница 36: ...to wait for the NC_ST_READ_AVAIL state is to call the ncCreateNotification function so you receive a callback when the state occurs For more information on ncWaitForState and ncCreateNotification ref...

Страница 37: ...hat all NI CAN errors generate a negative status and all NI CAN warnings generate a positive status The error bit is set when a function does not perform the expected behavior resulting in a negative...

Страница 38: ...rmation refer to the Error Handling section in the LabVIEW Online Reference In NI CAN s implementation of Error Clusters the status parameter is set to true when an error occurs and is set to false wh...

Страница 39: ...tects a warning it can display a warning message or simply ignore the warning If the function has the following prototype void CheckStat NCTYPE_STATUS stat char msg then your application invokes it as...

Страница 40: ...a NI CAN uses the write queue to transmit network frames one at a time using the network interface hardware You access the write queue using ncWrite to store network data items for transmission State...

Страница 41: ...g an overflow The NC_ST_READ_AVAIL and NC_ST_WRITE_SUCCESS states still behave as usual but you can ignore them if you want only the most recent data For example when NI CAN writes a new data item to...

Страница 42: ...disable all frame reception in the CAN Network Interface Object by setting the Yes No Arbitration ID Handled by an Open CAN Object No Yes Standard Extended Data Frame Standard or Extended Frame No St...

Страница 43: ...ground error has occurred for an object you can use ncGetAttribute to obtain the state and check for NC_ST_ERROR Use the ncWaitForState function when your application must wait for a specific state be...

Страница 44: ...er using the CAN Network Interface Object It also demonstrates usage of the ncCreateNotification function interact vi is the LabVIEW source code file for Example 3 In this example one CAN Network Inte...

Страница 45: ...eter which measures the speed of the vehicle and transmits it in a CAN frame every 100 milliseconds To use NI CAN to test the speed display the engineer uses a CAN Object to simulate the role of the s...

Страница 46: ...to configure the CAN Objects for both ports CAN0 STD5 and CAN1 STD5 Once again such configuration would normally be handled using the NI CAN Configuration utility 3 The application calls ncOpenObject...

Страница 47: ...engineer is writing a diagnostic utility for use in service bays This utility is used to diagnose problems with car models that use Yes No 1 2 3 4 5 6 7 8 9 Finished Ten Periods Configure CAN Objects...

Страница 48: ...which is used to receive frames into the buffer This is done by registering a callback function for the NC_ST_READ_AVAIL state After creating the notification thread the main thread proceeds to Step...

Страница 49: ...eract vi front panel provides CAN Network Interface and Baud Rate controls which are used to specify the CAN interface to use Yes No No 1 2 3 8 10 Timeout Error Detected Open CAN Network Interface Obj...

Страница 50: ...wo copies of interact vi to experiment Save a separate copy of the example such as interact2 vi then run one copy on one port such as CAN0 and the other copy on the other port such as CAN1 The followi...

Страница 51: ...bject then calls ncCloseObject to close the CAN Object Figure 4 3 Program Flowchart for Example 3 1 2 Open CAN Network Interface Object Configure CAN Network Interface Object ncConfig ncOpenObject Yes...

Страница 52: ...can use the NI CAN Configuration utility to create and modify CAN Objects The online help includes all of the information that you need to properly configure the objects of the NI CAN software The NI...

Страница 53: ...to configure the objects for the CAN interface For information on using the Settings tab to configure your objects refer to Configuring Objects with the NI CAN Configuration Utility later in this chap...

Страница 54: ...r resource assignment refer to your NI CAN getting started manual After you have finished configuring your CAN interfaces click on the OK button to close the dialog box Configuring Objects with the NI...

Страница 55: ...the Name drop down box to select the name of the CAN Network Interface Object CAN0 CAN1 and so on Your application uses the CAN Network Interface Object name as a logical reference to the port You mus...

Страница 56: ...Configuration dialog box for Windows 98 95 The Windows NT dialog box is similar Figure 5 2 CAN Object Configuration Dialog Box If you need help on a particular control in this dialog box right click t...

Страница 57: ...defined aliases refer to the description of ncOpenObject in the NI CAN Programmer Reference Manual After entering the arbitration ID click on the Add button to add the CAN Object to the list You may...

Страница 58: ...made or click Cancel to close the dialog box without saving any changes you have made After selecting OK or Cancel you are returned to the Settings tab so you can complete the configuration for the CA...

Страница 59: ...e Manager To remove the hardware information from Windows 98 95 double click on the System icon in the Control Panel which you can open from the Settings selection of the Start menu Select the Device...

Страница 60: ...he CAN interfaces Uninstalling the CAN Hardware from Windows NT Because the current version of Windows NT does not maintain hardware information for the CAN interfaces you need only to physically remo...

Страница 61: ...ure A 2 appears This dialog box lists the software available for removal Figure A 2 Add Remove Programs Properties Dialog Box 2 Select the NI CAN software you want to remove and click the Add Remove b...

Страница 62: ...u add anything to a directory that was created by the installation program the uninstall program does not delete that directory because the directory is not empty after the uninstallation You will nee...

Страница 63: ...re certain you have a CAN interface installed refer to the No National Instruments CAN Interfaces section of this appendix If the National Instruments CAN Interfaces item exists but the CAN interface...

Страница 64: ...N Interface That Is Not Working Properly This problem can occur for several reasons If you encounter this problem the Device Manager should list an error code that indicates why the problem occurred T...

Страница 65: ...General tab Code 24 The CAN interface is not present or the Device Manager is unaware that the CAN interface is present To solve this problem select the interface in the Device Manager and click on th...

Страница 66: ...After the conflict has been resolved run the NI CAN Diagnostic utility again NI CAN Software Problem Encountered This error occurs if the NI CAN Diagnostic utility detects that it is unable to commun...

Страница 67: ...Interfaces icon appears in the list of device types Double click this icon to see a list of installed CAN hardware How can I determine which version of the NI CAN software I have installed Run the NI...

Страница 68: ...ation about using NI CAN from within LabVIEW refer to Chapter 2 Developing Your Application Why does the uninstall program leave some components installed The uninstall program removes only items that...

Страница 69: ...aces the CAN interface is not properly installed For National Instruments CAN hardware this problem indicates that the interface is not physically present in the system If the interface is firmly plug...

Страница 70: ...the CAN interface After the conflict has been resolved run the NI CAN Diagnostic utility again NI CAN Software Problem Encountered This error occurs if the NI CAN Diagnostic utility detects that it i...

Страница 71: ...e currently installed What do I do if the NI CAN Diagnostic utility fails with an error Refer to the Troubleshooting Diagnostic Utility Failures section of this appendix for specific information about...

Страница 72: ...installed The uninstall program removes only items that the installation program installed If you add anything to a directory that was created by the installation program the uninstall program does no...

Страница 73: ...e latest example programs system configurators tutorials technical news as well as a community of developers ready to share their own techniques Customer Education National Instruments provides a numb...

Страница 74: ...es from the Worldwide Offices section of ni com Branch office Web sites provide up to date contact information support phone numbers e mail addresses and current events If you have searched the techni...

Страница 75: ...user application to access hardware Within NI CAN you use API functions to make calls into the NI CAN driver arbitration ID An 11 or 29 bit ID transmitted as the first field of a CAN frame The arbitra...

Страница 76: ...CAN identifier along with its associated data CAN remote frame Frame used to request data for a CAN Object from a remote node the RTR bit is set and the data length indicates the amount of data desir...

Страница 77: ...This state is a warning that a communication problem exists but the node is still participating in network traffic extended arbitration ID A 29 bit arbitration ID Frames that use extended IDs are ofte...

Страница 78: ...certain level of overall network performance multi drop A physical connection in which multiple devices communicate with one another along a single cable N network interface A node s physical connecti...

Страница 79: ...for data is sent to a device and the device sends back a response with the desired value protocol A formal set of conventions or rules for the exchange of information among nodes of a given network R...

Страница 80: ...s sensors are devices that send their primary data value onto the network examples include temperature sensors and presence sensors Also known as transmitter standard arbitration ID An 11 bit arbitrat...

Страница 81: ...uages accessing NI CAN software 2 1 status checking 2 12 CAN See also NI CAN arbitration 1 2 error confinement 1 6 error detection 1 5 history and usage 1 1 low speed 1 8 CAN frame reception flowchart...

Страница 82: ...ion calls checking class definition 1 9 closing CAN Objects 2 9 common questions See troubleshooting and common questions communicating with CAN network starting 2 8 using objects 2 9 configuring obje...

Страница 83: ...plication example 4 6 InteractLS vi example file 4 2 interrupt requirements Windows 98 95 B 5 Windows NT C 3 ISO 11898 standard 1 1 L LabVIEW G language function library 2 1 interactive front panel ap...

Страница 84: ...chy 1 10 applying NI CAN objects figure 1 11 simple CAN device network application figure 1 10 NI CAN software See also programming components 1 12 driver and utilities 1 12 firmware image files 1 13...

Страница 85: ...2 11 choosing NI CAN Objects 2 4 CAN Network Interface Objects 2 4 CAN Objects 2 5 detecting state changes 3 4 interaction of NI CAN software with your application figure 1 14 model for NI CAN applica...

Страница 86: ...emory resource conflict B 3 missing CAN interface B 2 NI CAN Diagnostic utility failures B 3 NI CAN software problem encountered B 4 problem shown in Device Manager B 2 Windows 98 95 Device Manager B...

Страница 87: ...e A 2 B 6 Windows NT NI CAN driver and utilities 1 12 starting NI CAN Configuration utility 5 1 troubleshooting and common questions C 1 CAN hardware problem encountered C 2 common questions C 3 inter...

Отзывы: