NI-CAN Hardware and Software Manual
NI-CAN Hardware and Software Manual
October 2006
370289K-01
Support
Worldwide Offices
Australia 1800 300 800, Austria 43 0 662 45 79 90 0, Belgium 32 0 2 757 00 20, Brazil 55 11 3262 3599,
Canada 800 433 3488, China 86 21 6555 7838, Czech Republic 420 224 235 774, Denmark 45 45 76 26 00,
Finland 385 0 9 725 725 11, France 33 0 1 48 14 24 24, Germany 49 0 89 741 31 30, India 91 80 41190000,
Israel 972 0 3 6393737, Italy 39 02 413091, Japan 81 3 5472 2970, Korea 82 02 3451 3400,
Lebanon 961 0 1 33 28 28, Malaysia 1800 887710, Mexico 01 800 010 0793, Netherlands 31 0 348 433 466,
New Zealand 0800 553 322, Norway 47 0 66 90 76 60, Poland 48 22 3390150, Portugal 351 210 311 210,
Russia 7 095 783 68 51, Singapore 1800 226 5886, Slovenia 386 3 425 4200, South Africa 27 0 11 805 8197,
Spain 34 91 640 0085, Sweden 46 0 8 587 895 00, Switzerland 41 56 200 51 51, Taiwan 886 02 2377 2222,
Thailand 662 278 6777, United Kingdom 44 0 1635 523545
For further support information, refer to the Technical Support and Professional Services appendix. To comment
on National Instruments documentation, refer to the National Instruments Web site at ni.com/info and enter
the info code feedback.
Copyright
Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying,
recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent of National
Instruments Corporation.
National Instruments respects the intellectual property of others, and we ask our users to do the same. NI software is protected by copyright and other
intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to others, you may use NI software only
to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.
Trademarks
National Instruments, NI, ni.com, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section
on ni.com/legal for more information about National Instruments trademarks.
Other product and company names mentioned herein are trademarks or trade names of their respective companies.
Members of the National Instruments Alliance Partner Program are business entities independent from National Instruments and have no
agency, partnership, or joint-venture relationship with National Instruments.
Patents
For patents covering National Instruments products, refer to the appropriate location: Help»Patents in your software, the patents.txt file
on your CD, or ni.com/patents.
FCC/DOC Warnings
This equipment generates and uses radio frequency energy and, if not installed and used in strict accordance with the instructions
in this manual and the CE marking Declaration of Conformity*, may cause 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 modifications not expressly approved by NI could void the user’s authority to operate the equipment under the
FCC Rules.
Class A
Federal Communications Commission
This equipment has been tested and found to comply with the limits for a Class A digital device, pursuant to part 15 of the FCC
Rules. These limits are designed to provide reasonable protection against harmful interference when the equipment is operated
in a commercial environment. This equipment generates, uses, and can radiate radio frequency energy and, if not installed and
used in accordance with the instruction manual, may cause harmful interference to radio communications. Operation of this
equipment in a residential area is likely to cause harmful interference in which case the user is required to correct the interference
at their own expense.
* The CE marking Declaration of Conformity contains important supplementary information and instructions for the user or
installer.
Contents
Chapter 1
Introduction
CAN Overview ..............................................................................................................1-1
Simplified CAN Data Frame ...........................................................................1-1
LIN Overview ................................................................................................................1-2
NI CAN Hardware Overview ........................................................................................1-2
About the NI CAN Series 2 Hardware ............................................................1-2
Series 2 Vs. Series 1 ........................................................................................1-4
PCI and PXI ......................................................................................1-6
PCMCIA ...........................................................................................1-7
PCMCIA Cables ...............................................................................1-7
About the USB-847x Hardware.......................................................................1-8
CAN: USB-8472, USB-8472s, USB-8473, USB-8473s...................1-8
LIN: USB-8476, USB-8476s ............................................................1-9
NI-CAN Software Overview .........................................................................................1-9
MAX................................................................................................................1-9
Frame API .......................................................................................................1-10
Channel API ....................................................................................................1-10
Chapter 2
Installation and Configuration
Safety Information .........................................................................................................2-1
Measurement & Automation Explorer (MAX) .............................................................2-3
Verify Installation of CAN and LIN Hardware .............................................................2-3
Configure CAN and LIN Ports........................................................................2-4
CAN Channels.................................................................................................2-5
LabVIEW Real-Time (RT) Configuration ....................................................................2-6
PXI System......................................................................................................2-6
CompactRIO System .......................................................................................2-7
Chapter 3
NI CAN and LIN Hardware
Philips SJA1000 CAN Controller ................................................................................. 3-1
PCI-CAN ....................................................................................................................... 3-2
High-Speed Physical Layer............................................................................. 3-2
Transceiver ....................................................................................... 3-2
Bus Power Requirements.................................................................. 3-2
VBAT Jumper................................................................................... 3-2
Low-Speed/Fault-Tolerant Physical Layer ..................................................... 3-4
Transceiver ....................................................................................... 3-4
Bus Power Requirements.................................................................. 3-5
VBAT Jumper................................................................................... 3-5
Low-Speed/Fault-Tolerant VBAT Jumper Settings ......................... 3-6
Single Wire Physical Layer............................................................................. 3-7
Transceiver ....................................................................................... 3-7
Bus Power Requirements.................................................................. 3-7
VBAT Jumper................................................................................... 3-8
XS Software Selectable Physical Layer.......................................................... 3-8
RTSI ............................................................................................................... 3-9
PXI-846x........................................................................................................................ 3-11
High-Speed Physical Layer............................................................................. 3-11
Transceiver ....................................................................................... 3-11
Bus Power Requirements.................................................................. 3-11
VBAT Jumper................................................................................... 3-11
Low-Speed/Fault-Tolerant Physical Layer ..................................................... 3-13
Transceiver ....................................................................................... 3-13
Bus Power Requirements.................................................................. 3-13
VBAT Jumper................................................................................... 3-14
Single Wire Physical Layer............................................................................. 3-15
Transceiver ....................................................................................... 3-15
Bus Power Requirements.................................................................. 3-16
VBAT Jumper................................................................................... 3-16
XS Software Selectable Physical Layer.......................................................... 3-16
PXI Trigger Bus (RTSI)................................................................................. 3-18
PCMCIA-CAN .............................................................................................................. 3-20
PCMCIA-CAN High-Speed Cables................................................................ 3-20
Transceiver ....................................................................................... 3-20
Bus Power Requirements.................................................................. 3-20
Chapter 4
Connectors and Cables
High-Speed CAN Pinout Cable .....................................................................................4-1
High-Speed PCI, PXI, and USB Connector Pinout.........................................4-1
PCMCIA Connector Pinout ..............................................................4-2
Cabling Requirements for High-Speed CAN....................................4-4
Cable Lengths ...................................................................................4-4
Number of Devices ...........................................................................4-5
Cable Termination.............................................................................4-5
Cabling Example...............................................................................4-6
Low-Speed/Fault-Tolerant CAN Pinout Cable..............................................................4-6
Low-Speed/Fault-Tolerant PCI, PXI, and USB Connector Pinout .................4-6
PCMCIA Connector Pinout PCMCIA Connector Pinout.................4-8
Cabling Requirements for Low-Speed/Fault-Tolerant CAN ..........................4-9
Number of Devices ...........................................................................4-9
Termination .......................................................................................4-10
Chapter 5
Application Development
Choose the Programming Language ............................................................................. 5-1
LabVIEW ........................................................................................................ 5-1
LabWindows/CVI ........................................................................................... 5-2
Visual C++ 6 ................................................................................................... 5-2
Borland C/C++................................................................................................ 5-3
Microsoft Visual Basic.................................................................................... 5-4
Other Programming Languages ...................................................................... 5-4
Choose Which API To Use ........................................................................................... 5-6
Chapter 6
Using the Channel API
Choose Source of Channel Configuration .....................................................................6-1
Already Have a CAN Database File?..............................................................6-2
Application Uses a Subset of Channels? .........................................................6-2
Import CAN Database into MAX....................................................................6-2
Access CAN Database within Application......................................................6-3
User Must Create within Application? ............................................................6-3
Use Create Message Function in Application .................................................6-3
Create in MAX ................................................................................................6-4
Channel API Basic Programming Model ......................................................................6-4
Init Start ...........................................................................................................6-5
Read.................................................................................................................6-6
sample rate = 0 ..................................................................................6-6
sample rate > 0 ..................................................................................6-7
Read Timestamped ..........................................................................................6-8
Write ................................................................................................................6-8
sample rate = 0 ..................................................................................6-9
sample rate > 0, Output mode ...........................................................6-9
sample rate > 0, Output Recent mode ...............................................6-10
Clear ................................................................................................................6-10
Channel API Additional Programming Topics..............................................................6-11
Get Names .......................................................................................................6-11
Synchronization...............................................................................................6-11
Set Property .....................................................................................................6-12
Frame to Channel Conversion .......................................................................................6-12
When Should I Use Frame to Channel Conversion?.......................................6-13
Logging .............................................................................................6-13
CompactRIO .....................................................................................6-14
Development without CAN Hardware..............................................6-15
Database Queries...............................................................................6-15
Enhance an Existing Frame API Application ...................................6-15
USB-847x..........................................................................................6-15
Virtual Bus Timing..........................................................................................6-16
Limitations.......................................................................................................6-17
Programming Model for Virtual Bus Timing Disabled ..................................6-21
Mode Dependent Channels ............................................................................................6-23
Mode Dependent Channels in MAX ...............................................................6-24
Chapter 7
Channel API for LabVIEW
Section Headings ........................................................................................................... 7-1
List of VIs...................................................................................................................... 7-1
CAN Clear.vi................................................................................................................. 7-4
CAN Clear with NI-DAQ.vi.......................................................................................... 7-6
CAN Clear with NI-DAQmx.vi .................................................................................... 7-8
CAN Clear Multiple with NI-DAQ.vi........................................................................... 7-10
CAN Clear Multiple with NI-DAQmx.vi...................................................................... 7-12
CAN Connect Terminals.vi ........................................................................................... 7-14
CAN Create Message.vi ................................................................................................ 7-24
CAN Create MessageEx.vi............................................................................................ 7-30
CAN Disconnect Terminals.vi ...................................................................................... 7-37
CAN Get Names.vi........................................................................................................ 7-39
CAN Get Property.vi ..................................................................................................... 7-42
CAN Initialize.vi ........................................................................................................... 7-55
CAN Init Start.vi ........................................................................................................... 7-59
CAN Read.vi ................................................................................................................. 7-65
CAN Set Property.vi...................................................................................................... 7-73
CAN Start.vi .................................................................................................................. 7-88
CAN Stop.vi .................................................................................................................. 7-90
CAN Sync Start with NI-DAQ.vi.................................................................................. 7-92
CAN Sync Start with NI-DAQmx.vi............................................................................. 7-94
CAN Sync Start Multiple with NI-DAQ.vi................................................................... 7-97
CAN Sync Start Multiple with NI-DAQmx.vi.............................................................. 7-100
CAN Write.vi ................................................................................................................ 7-103
Chapter 8
Channel API for C
Section Headings ........................................................................................................... 8-1
Data Types..................................................................................................................... 8-1
List of Functions............................................................................................................ 8-2
nctClear.......................................................................................................................... 8-4
nctConnectTerminals..................................................................................................... 8-5
nctCreateMessage.......................................................................................................... 8-15
nctCreateMessageEx ..................................................................................................... 8-20
nctDisconnectTerminals ................................................................................................ 8-26
nctGetNames ................................................................................................................. 8-28
nctGetNamesLength ...................................................................................................... 8-31
nctGetProperty............................................................................................................... 8-33
nctInitialize .................................................................................................................... 8-44
nctInitStart ..................................................................................................................... 8-47
nctRead ..........................................................................................................................8-53
nctReadTimestamped.....................................................................................................8-57
nctSetProperty................................................................................................................8-60
nctStart ...........................................................................................................................8-75
nctStop ...........................................................................................................................8-76
nctWrite .........................................................................................................................8-77
Chapter 9
Using the Frame API
Choose Which Objects To Use ......................................................................................9-1
Using CAN Network Interface Objects...........................................................9-1
Using LIN Network Interface Objects ............................................................9-2
Using CAN Objects.........................................................................................9-3
Frame API Basic Programming Model for CAN ..........................................................9-4
Frame API Basic Programming Model for LIN ............................................................9-7
LIN Interface as Bus Monitor..........................................................................9-7
LIN Interface as Master...................................................................................9-10
LIN Interface as Slave Device.........................................................................9-14
LIN Interface Accesses Single Subscribing Slave Device ..............................9-17
LIN Interface Accesses Single Publishing Slave Device ................................9-20
LIN Interface Sleep and Wakeup Behavior.....................................................9-23
Frame API Additional Programming Topics.................................................................9-25
RTSI ...............................................................................................................9-25
Remote Frames................................................................................................9-25
Using Queues...................................................................................................9-26
State Transitions ..............................................................................................9-26
Empty Queues .................................................................................................9-26
Full Queues......................................................................................................9-27
Disabling Queues.............................................................................................9-27
Using the CAN Network Interface Object with CAN Objects........................9-27
Detecting State Changes..................................................................................9-29
Frame to Channel Conversion .........................................................................9-29
Differences between CAN and LIN ................................................................9-30
Chapter 10
Frame API for LabVIEW
Section Headings ...........................................................................................................10-1
List of VIs ......................................................................................................................10-2
ncAction.vi.....................................................................................................................10-4
ncClose.vi ......................................................................................................................10-8
ncConfigCANNet.vi ......................................................................................................10-10
ncConfigCANNetRTSI.vi..............................................................................................10-15
ncConfigCANObj.vi...................................................................................................... 10-19
ncConfigCANObjRTSI.vi ............................................................................................. 10-27
ncConnectTerminals.vi.................................................................................................. 10-32
ncDisconnectTerminals.vi ............................................................................................. 10-41
ncGetAttr.vi ................................................................................................................... 10-43
ncGetHardwareInfo.vi ................................................................................................... 10-58
ncGetTimer.vi................................................................................................................ 10-63
ncOpen.vi....................................................................................................................... 10-65
ncReadNet.vi ................................................................................................................. 10-68
ncReadNetMult.vi ......................................................................................................... 10-79
ncReadObj.vi ................................................................................................................. 10-90
ncReadObjMult.vi ......................................................................................................... 10-93
ncSetAttr.vi.................................................................................................................... 10-96
ncWaitForState.vi.......................................................................................................... 10-125
ncWriteNet.vi ................................................................................................................ 10-129
ncWriteNetMult.vi......................................................................................................... 10-137
ncWriteObj.vi ................................................................................................................ 10-149
Chapter 11
Frame API for C
Section Headings ........................................................................................................... 11-1
Data Types..................................................................................................................... 11-2
List of Functions............................................................................................................ 11-3
ncAction ........................................................................................................................ 11-5
ncCloseObject................................................................................................................ 11-8
ncConfig ........................................................................................................................ 11-9
ncConnectTerminals...................................................................................................... 11-29
ncCreateNotification...................................................................................................... 11-39
ncDisconnectTerminals ................................................................................................. 11-44
ncGetAttribute ............................................................................................................... 11-46
ncGetHardwareInfo ....................................................................................................... 11-61
ncOpenObject ................................................................................................................ 11-66
ncRead ........................................................................................................................... 11-68
ncReadMult ................................................................................................................... 11-81
ncSetAttribute................................................................................................................ 11-83
ncStatusToString ........................................................................................................... 11-112
ncWaitForState .............................................................................................................. 11-115
ncWrite .......................................................................................................................... 11-118
ncWriteMult .................................................................................................................. 11-126
Appendix A
Troubleshooting and Common Questions
Troubleshooting with the Measurement & Automation Explorer (MAX) ....................A-1
Troubleshooting Self Test Failures................................................................................A-2
Common Questions........................................................................................................A-3
Appendix B
Summary of the CAN Standard
History and Use of CAN................................................................................................B-1
CAN Identifiers and Message Priority...........................................................................B-2
CAN Frames ..................................................................................................................B-3
CAN Error Detection and Confinement ........................................................................B-5
Low-Speed CAN............................................................................................................B-8
Appendix C
Summary of the LIN Standard
History and Use of LIN .................................................................................................C-1
LIN Frame Format .........................................................................................................C-1
LIN Bus Timing.............................................................................................................C-4
LIN Topology and Behavior..........................................................................................C-5
LIN Error Detection and Confinement ..........................................................................C-6
LIN Sleep and Wakeup..................................................................................................C-6
Advanced Frame Types .................................................................................................C-7
Additional LIN Information...........................................................................................C-8
Appendix D
Frame Types for CAN and LIN Hardware
Appendix E
Specifications
PCI-CAN Series 2..........................................................................................................E-1
PXI-846x Series 2 ..........................................................................................................E-4
PCMCIA-CAN Series 2.................................................................................................E-7
USB-CAN and USB-LIN ..............................................................................................E-10
Safety .............................................................................................................................E-12
Appendix F
Technical Support and Professional Services
Glossary
Index
Use the NI-CAN Software and Hardware Installation Guide included with
your kit to install and configure the NI-CAN hardware and software. Use
this manual to learn the basics of NI-CAN, as well as how to develop an
application.
This manual also describes the hardware features. Unless otherwise noted,
this manual applies to the NI CAN Series 2 products, which include the
following.
PCI-CAN
• PCI-CAN Series 2 (High-Speed; 1 port)
• PCI-CAN/2 Series 2 (High-Speed; 2 ports)
• PCI-CAN/LS Series 2 (Low-Speed/Fault-Tolerant; 1 port)
• PCI-CAN/LS2 Series 2 (Low-Speed/Fault-Tolerant; 2 ports)
• PCI-CAN/XS Series 2 (Software Selectable; 1 port)
• PCI-CAN/XS2 Series 2 (Software Selectable; 2 ports)
PXI-846x
• PXI-8461 Series 2 (High-Speed; 1 or 2 ports)
• PXI-8460 Series 2 (Low-Speed/Fault-Tolerant; 1 or 2 ports)
• PXI-8464 Series 2 (Software Selectable; 1 or 2 ports)
PCMCIA-CAN
• PCMCIA-CAN Series 2 (High-Speed; 1 port)
• PCMCIA-CAN/2 Series 2 (High-Speed; 2 ports)
• PCMCIA-CAN/LS Series 2 (Low-Speed/Fault-Tolerant; 1 port)
• PCMCIA-CAN/LS2 Series 2 (Low-Speed/Fault-Tolerant; 2 port)
• PCMCIA-CAN/SW Series 2 (Single Wire; 1 port)
USB-CAN
• USB-8473 (High-Speed CAN; 1 port)
• USB-8473s (High-Speed CAN; 1 port, with Synchronization)
• USB-8472 (Low-Speed CAN; 1 port)
• USB-8472s (Low-Speed CAN; 1 port, with Synchronization)
USB-LIN
• USB-8476 (LIN; 1 port)
• USB-8476s (LIN; 1 port, with Synchronization)
NI-CAN hardware products that pre-date the Series 2 product line are now
referred to as Series 1. NI CAN Series 2 products contain several
enhancements over Series 1 products, including the Philips SJA1000 CAN
controller, improved RTSI synchronization features, updated CAN
transceivers, and XS Software Selectable hardware for PCI and PXI.
NI-CAN software continues to fully support Series 1 hardware. However,
some advanced features are available only with Series 2 hardware. For
instance, with PCMCIA, both the card and the cable must be Series 2 to use
the advanced features. For a complete description of the differences
between Series 1 and Series 2 NI CAN hardware, refer to the Series 2 Vs.
Series 1 section of Chapter 1, Introduction.
» 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, and select Options
from the last dialog box.
bold Bold text denotes items that you must select or click in the software, such
as menu items and dialog box options. Bold text also denotes parameter
names.
monospace Text in this font denotes text or characters that you should enter from the
keyboard, sections of code, programming examples, and syntax examples.
This font is also used for the proper names of disk drives, paths, directories,
programs, subprograms, subroutines, device names, functions, operations,
variables, filenames, and extensions.
monospace bold Bold text in this font denotes the messages and responses that the computer
automatically prints to the screen. This font also emphasizes lines of code
that are different from the other examples.
monospace italic Italic text in this font denotes text that is a placeholder for a word or value
that you must supply.
Related Documentation
The following documents contain information that you might 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-1, 2 Road Vehicles—Low Speed Serial
Data Communications, Part 1 and 2
CAN Overview
The data frame is the fundamental unit of data transfer on a CAN network.
Figure 1-1 shows a simplified view of the CAN data frame.
The ID is followed by a length code that specifies the number of data bytes
in the frame. The length ranges from 0 to 8 data bytes. The ID value
determines the meaning of the data bytes.
In addition to the data frame, the CAN standard specifies the remote frame.
The remote frame includes the ID, but no data bytes. A CAN device
transmits the remote frame to request that another device transmit the
associated data frame for the ID. In other words, the remote frame provides
a mechanism to poll for data.
LIN Overview
The LIN bus uses a Master/Slave approach, comprised of a LIN Master and
one or more LIN Slaves. Figure 1-2 shows a simplified view of the LIN
message frame.
The message header consists of a break used to identify the start of the
frame and the sync field used by the slave node for clock synchronization.
The identifier (ID) consists of a 6-bit message ID and a 2-bit parity field.
The ID denotes a specific message address, but not the destination. Upon
reception and interpretation of the ID one slave will begin the message
response. The message response consists of 1–8 bytes of data and an 8-bit
checksum.
®
NI PCI-CAN
Series 2
Series 2
PCMCIA-CAN NI PCMCIA-CAN
with high & low speed CAN support Series 2
CA
N/
C
V-
A
HS
N
L V-
(I
S
C_ H
nt
L erie
er
S H C_ s2
na
C_ V+ ,P
lP
SH H or t 1
w
r)
C_
P,
O
J2
J2
V+
R
T
1
J1 J1
PCMCIA
• Philips SJA1000 CAN controller. Series 1 hardware supported the
Intel 82527 CAN controller. For more specific information about the
SJA1000 CAN controller, refer to the Philips SJA1000 CAN
Controller section of Chapter 3, NI CAN and LIN Hardware.
• Synchronization capability for PCMCIA hardware. For more
information about PCMCIA synchronization, refer to the
Synchronization section of Chapter 3, NI CAN and LIN Hardware.
• Improved performance and reduced power consumption. For more
information, refer to Appendix C, Summary of the LIN Standard.
PCMCIA Cables
• Single Wire CAN support.
• Upgraded CAN transceivers. High-speed hardware uses the Philips
TJA1041 transceiver; Low-Speed/Fault-Tolerant hardware uses the
Philips TJA1054A transceiver. Both transceivers have increased
voltage tolerance and improved EMC performance over their NI CAN
Series 1 predecessors.
• Internally powered physical layer for High-Speed and
Low-Speed/Fault Tolerant. This means High-Speed and
Low-Speed/Fault-Tolerant hardware is fully functional by default
without supplying any bus power. Note that Single Wire CAN requires
external bus power.
• NI-CAN 2.2 is required for full functionality of the PCMCIA cables.
Using these cables with any version of NI-CAN prior to 2.2 will
prevent use of the following functions:
MAX
The NI-CAN features within MAX enable you to:
• Verify the installation of the NI CAN hardware.
• Configure software properties for each CAN port.
• Create or import configuration information for the Channel API.
• Interact with the CAN network using various tools.
Frame API
As described in the CAN Overview section, the frame is the fundamental
unit of data transfer on a CAN network. The NI-CAN Frame API provides
a set of functions to write and read CAN frames.
Within the Frame API, the data bytes of each frame are not interpreted, but
are transferred in their raw format. For example, you can transmit a data
frame by calling a write function with the ID, length, and array of data
bytes.
Channel API
A typical CAN data frame contains multiple values encoded as raw fields.
Figure 1-8 shows an example set of fields for a 6-byte data frame.
When you use the NI-CAN Frame API to read CAN data frames, you must
write code in the application to convert each raw field to physical units such
as km/h. The NI-CAN Channel API enables you to specify this conversion
information at configuration time instead of within the application. This
configuration information can be imported from Vector CANdb files, or
specified directly in MAX.
For each ID you read or write on the CAN network, you specify a number
of fields. For each field, you specify its location in the frame, size in bits,
and a formula to convert to/from floating-point units. In other words, you
specify the meaning of various fields in each CAN data frame. In NI-CAN
terminology, a data frame for which the individual fields are described is
called a message.
Safety Information
The following section contains important safety information that you must
follow when installing and using the module.
If you need to clean the module, use a soft, nonmetallic brush. Make sure
that the module is completely dry and free from contaminants before
returning it to service.
You must insulate signal connections for the maximum voltage for which
the module is rated. Do not exceed the maximum ratings for the module.
Do not install wiring while the module is live with electrical signals.
1 Installation categories, also referred to as measurement categories, are defined in electrical safety standard IEC 61010-1.
2 Working voltage is the highest rms value of an AC or DC voltage that can occur across any particular insulation.
3 MAINS is defined as a hazardous live electrical supply system that powers equipment. Suitably rated measuring circuits may
be connected to the MAINS for measuring purposes.
are wiring, including cables, bus bars, junction boxes, switches, socket
outlets in the fixed installation, and stationary motors with permanent
connections to fixed installations.
• Installation Category IV is for measurements performed at the primary
electrical supply installation (<1,000 V). Examples include electricity
meters and measurements on primary overcurrent protection devices
and on ripple control units.
For information on the NI-CAN software within MAX, consult the online
help within MAX.
View help for items in the MAX Configuration tree by using the built-in
MAX help pane. If this help pane is not shown on the far right, select the
Show/Hide button in the upper right.
View help for a dialog box by selecting the Help button in the window.
If the CAN or LIN hardware is not listed here, MAX is not configured
to search for new devices on startup. To search for the new hardware,
press <F5>.
In the Properties dialog, you assign an interface name to the port, such as
CAN0 or CAN1. The interface name identifies the physical port within
NI-CAN APIs.
The Properties dialog also contains the default baud rate for MAX tools
and the Channel API.
CAN Channels
Within the Data Neighborhood branch of the MAX Configuration tree,
the CAN Channels branch lists information for the NI-CAN Channel API,
as shown in Figure 2-2.
The CAN Channels branch lists CAN messages for use with the Channel
API. A set of channels is specified for each message.
When you install the NI-CAN software, the installer checks for the
presence of the LabVIEW RT module. If LabVIEW RT exists, the NI-CAN
installer copies components for LabVIEW RT to the Windows system.
As with any other NI product for LabVIEW RT, you then download the
NI-CAN software to the LabVIEW RT system using the Remote Systems
branch in MAX. For more information, refer to the LabVIEW RT
documentation.
PXI System
After you have installed the PXI CAN cards and downloaded the NI-CAN
software to the LabVIEW RT system, you need to verify the installation.
Within the Tools menu in MAX, select NI-CAN»RT Hardware
Configuration. The RT Hardware Configuration tool provides features
similar to Devices & Interfaces on the local system. Use the RT Hardware
Configuration tool to self-test the CAN cards and assign an interface name
to each physical CAN port.
To use the Channel API on the LabVIEW RT system, you must also
download channel configuration information. Right-click the CAN
Channels heading, then select Send to RT System. This downloads all
information under CAN Channels to the LabVIEW RT system, so you can
execute the same LabVIEW VIs on the LabVIEW RT system as on the
Windows system.
CompactRIO System
After you have installed the CompactRIO CAN modules and downloaded
NI-RIO and NI-CAN software, you need to enable the CompactRIO
Reconfigurable Embedded Chassis for use in LabVIEW. For instructions
on how to enable the CompactRIO Reconfigurable Embedded Chassis for
use in LabVIEW, refer to the MAX help.
To use the Channel API on the LabVIEW RT system, you must download
the channel configuration information. Right-click the CAN Channels
heading, then select Send to RT System. This downloads all the
information under CAN Channels to the LabVIEW RT system. To utilize
the CAN channels on the CompactRIO system, you need to use Frame to
Channel Conversion. For more information, refer to the Frame to Channel
Conversion section of Chapter 6, Using the Channel API.
Tools
NI-CAN provides tools that you can launch from MAX.
• Bus Monitor—Displays statistics for CAN or LIN frames. This
provides a basic tool to analyze CAN or LIN network traffic. Launch
this tool by right-clicking a CAN or LIN interface (port).
• Test Panel—Read or write physical units for a CAN channel. This
provides a simple debugging tool to experiment with CAN channels.
Launch this tool by right-clicking a CAN channel.
• NI-Spy—Monitor function calls to the NI-CAN APIs. This tool helps
in debugging programming problems in the application. To launch this
tool, open the Software branch of the MAX Configuration tree,
right-click NI Spy, and select Launch NI Spy.
• FP1300 Configuration—FieldPoint 1300 is the National Instruments
modular I/O product for CAN. If you have installed the software for
the FP1300 product, launch this tool by right-clicking a CAN interface
(port).
You can view each Series 1 CAN card in MAX with either DeviceNet or
CAN features. To change the view of a CAN card in MAX, right-click the
card and select Protocol. In this dialog you can select either DeviceNet for
NI-DNET, or CAN for NI-CAN. When the CAN protocol is selected, you
can access CAN tools in MAX, such as the Bus Monitor tool.
Launch the setup.exe program for the NI-CAN installer in the same
manner as the original installation (CD or ni.com download). Within the
installer, select both NI-DNET and NI-CAN components in the feature
tree.
When you right-click a port in MAX and select Properties, the resulting
Interface selection uses the syntax CANx or DNETx based on the protocol
selection. Regardless of which protocol is selected, the number x is the only
relevant identifier with respect to NI-CAN and NI-DNET functions. For
example, if you select DNET0 as an interface in MAX, you can run an
NI-DNET application that uses DNET0, then you can run an NI-CAN
application that uses CAN0. Both applications refer to the same port, and
can run at different times, but not simultaneously.
PCI-CAN
High-Speed Physical Layer
The CAN physical layer circuitry interfaces the CAN protocol controller to
the physical bus wires. The PCI-CAN High-Speed physical layer is
powered internally (from the card) through a DC-DC converter, and is
optically isolated up to 500 VDC (withstand, 2s max) channel-to-bus. This
isolation protects the NI CAN hardware and the PC it is installed in from
being damaged by high-voltage spikes on the CAN bus.
Transceiver
PCI-CAN High-Speed hardware uses the Philips TJA1041 High-Speed
CAN transceiver. The TJA1041 is fully compatible with the ISO 11898
standard and supports baud rates up to 1 Mbps. This device also supports
advanced power management through a low-power sleep mode. This
feature is provided as the Transceiver Mode attribute of the Frame API
and the Interface Transceiver Mode property of the Channel API. For
detailed TJA1041 specifications, refer to the Philips TJA1041 data sheet.
VBAT Jumper
The TJA1041 features a battery voltage input pin, VBAT. This signal can
be supplied either internally or externally through the CAN bus V+ signal,
as controlled by the VBAT jumper setting. By default, the jumper is set to
INT, and VBAT is supplied internally. Some applications may require
explicit control of the transceiver VBAT pin; for example, to test the
performance of CAN devices on a network where battery power is lost.
If external control of VBAT is required, you can configure the PCI-CAN
hardware by switching the VBAT jumper from its default INT position to
EXT, as shown in Figure 3-1.
INT EXT
(Default)
With the VBAT jumper set to EXT, you must supply power on the CAN V+
signal. The power supply should be a DC power supply with an output of
8 to 27 V, as specified in Table 3-1. You should take these requirements into
account when determining the bus power supply requirements for the
system.
Characteristic Specification
Voltage 8–27 VDC on V+ connector pin
(referenced to V–)
Current 30 μA typical 40 μA maximum
If you are unsure how to configure VBAT, leave the jumper set to its default
value, INT.
Transceiver
PCI-CAN Low-Speed/Fault-Tolerant hardware uses the Philips TJA1054A
Low-Speed/Fault-Tolerant transceiver. The TJA1054A supports baud rates
up to 125 kbps. The transceiver can detect and automatically recover from
the following CAN bus failures:
• CAN_H wire interrupted
• CAN_L wire interrupted
• CAN_H short-circuited to battery
• CAN_L short-circuited to battery
• CAN_H short-circuited to VCC
• CAN_L short-circuited to VCC
• CAN_H short-circuited to ground
• CAN_L short-circuited to ground
• CAN_H and CAN_L mutually short-circuited
VBAT Jumper
The TJA1054A features a battery voltage input pin, VBAT. This signal can
be supplied either internally or externally through the CAN bus V+ signal,
as controlled by the VBAT jumper setting. By default, the jumper is set to
INT, and VBAT is supplied internally. Some applications may require
explicit control of the transceiver VBAT pin; for example, to test the
performance of CAN devices on a network where battery power is lost.
If external control of VBAT is required, you can configure the PCI-CAN
hardware by switching the VBAT jumper from its default INT position to
EXT, as shown in Figure 3-2, Low-Speed/Fault-Tolerant VBAT Jumper
Settings.
INT EXT
(Default)
Characteristic Specification
Voltage 8–27 VDC on V+ connector pin
(referenced to V–)
Current 30 μA typical 125 μA maximum
If you are unsure how to configure VBAT, leave the jumper set to its default
value, INT.
Transceiver
Single Wire hardware uses the Philips AU5790 Single Wire CAN
transceiver. The AU5790 supports baud rates up to 33.3 kbps in normal
transmission mode and 83.3 kbps in High-Speed transmission mode. The
achievable baud rate is primarily a function of the network characteristics
(termination and number of nodes on the bus), and assumes bus loading as
per SAE J2411. Each Single Wire CAN port has a local bus load resistance
of 9.09 kΩ between the CAN_H and RTH pins of the transceiver to provide
protection against the loss of ground. The AU5790 also supports advanced
power management through low-power sleep and wake-up modes. For
detailed AU5790 specifications, refer to the Philips AU5790 data sheet.
Characteristic Specification
Voltage 8–18 VDC (12 VDC typical) on V+ connector
pin (referenced to V–)
Current 40 mA typical 90 mA maximum
VBAT Jumper
Because the AU5790 requires external bus power, there is no option to
power the VBAT signal internally. For this reason, the VBAT jumper is not
present on Single Wire hardware, and external bus power must be
provided.
Note that the bus power requirements and VBAT jumper setting for an
XS port depend on the mode selected. Refer to the appropriate High-Speed,
Low-Speed/Fault-Tolerant, or Single Wire physical layer section to
determine the behavior for the mode selected. For example, the bus power
requirements and VBAT jumper operation for an XS port configured for
Single Wire mode are identical to those of a dedicated Single Wire node.
You can change the transceiver type within MAX using the Properties
dialog for each port. The transceiver type selected within MAX is used as
the default for NI-CAN applications. The initial transceiver configuration
in MAX is High-Speed for Port 1 and Low-Speed/Fault-Tolerant for Port 2.
You also can change the transceiver type within the application, which
overrides the value in MAX. This feature is provided as the Transceiver
Type attribute of the Frame API, and the Interface Transceiver Type
property of the Channel API.
RTSI
The RTSI bus gives you the ability to synchronize multiple NI CAN cards
with other National Instruments hardware products such as DAQ, IMAQ,
and Motion. The RTSI bus consists of a flexible interconnect scheme for
sharing timing and triggering signals in a system.
For PCI hardware, the RTSI bus interface is a connector at the top of the
card, and you can synchronize multiple cards by connecting a RTSI ribbon
cable between the cards that need to share timing and triggering signals.
Figure 3-3 shows the RTSI signal interconnect architecture for
NI PCI-CAN hardware.
RTSI Switch
Start Trigger
RTSI0–RTSI6
Interface Receive Event
Triggers
10 Hz Resync
RTSI Bus
RTSI7
Clock Master Timebase
20 MHz Timebase
PXI-846x
This section describes the PXI-846x hardware.
Transceiver
PXI-8461 hardware uses the Philips TJA1041 High-Speed CAN
transceiver. The TJA1041 is fully compatible with the ISO 11898 standard
and supports baud rates up to 1 Mbps. This device also supports advanced
power management through a low-power sleep mode. This feature is
provided as the Transceiver Mode attribute of the Frame API and the
Interface Transceiver Mode property of the Channel API. For detailed
TJA1041 specifications, refer to the Philips TJA1041 data sheet.
VBAT Jumper
The TJA1041 features a battery voltage input pin, VBAT. This signal can
be supplied either internally or externally through the CAN bus V+ signal,
as controlled by the VBAT jumper setting. By default, the jumper is set to
INT, and VBAT is supplied internally. Some applications may require
explicit control of the transceiver VBAT pin; for example, to test the
performance of CAN devices on a network where battery power is lost.
If external control of VBAT is required, you can configure the PXI-8461
hardware by switching the VBAT jumper from its default INT position to
EXT, as shown in Figure 3-4, High-Speed VBAT Jumper Settings.
INT EXT
(Default)
With the VBAT jumper set to EXT, you must supply power on the CAN V+
signal. The power supply should be a DC power supply with an output of
8 to 27 V, as specified in Table 3-4. You should take these requirements into
account when determining requirements of the bus power supply for the
system.
Characteristic Specification
Voltage 8–27 VDC on V+ connector pin
(referenced to V–)
Current 30 μA typical 40 μA maximum
If you are unsure how to configure VBAT, leave the jumper set to its default
value, INT.
Transceiver
PXI-8460 hardware uses the Philips TJA1054A Low-Speed/Fault-Tolerant
transceiver. The TJA1054A supports baud rates up to 125 kbps. The
transceiver can detect and automatically recover from the following CAN
bus failures:
• CAN_H wire interrupted
• CAN_L wire interrupted
• CAN_H short-circuited to battery
• CAN_L short-circuited to battery
• CAN_H short-circuited to VCC
• CAN_L short-circuited to VCC
• CAN_H short-circuited to ground
• CAN_L short-circuited to ground
• CAN_H and CAN_L mutually short-circuited
VBAT Jumper
The TJA1054A features a battery voltage input pin, VBAT. This signal can
be supplied either internally or externally through the CAN bus V+ signal,
as controlled by the VBAT jumper setting. By default, the jumper is set to
INT, and VBAT is supplied internally. Some applications may require
explicit control of the transceiver VBAT pin; for example, to test the
performance of CAN devices on a network where battery power is lost.
If external control of VBAT is required, you can configure the PXI-8460
hardware by switching the VBAT jumper from its default INT position to
EXT, as shown in Figure 3-5.
INT EXT
(Default)
With the VBAT jumper set to EXT, you must supply power on the CAN V+
signal. The power supply should be a DC power supply with an output of
8 to 27 V, as specified in Table 3-5. You should take these requirements into
account when determining the bus power supply requirements for the
system.
Characteristic Specification
Voltage 8–27 VDC on V+ connector pin
(referenced to V–)
Current 30 μA typical 125 μA maximum
If you are unsure how to configure VBAT, leave the jumper set to its default
value, INT.
Transceiver
Single Wire hardware uses the Philips AU5790 Single Wire CAN
transceiver. The AU5790 supports baud rates up to 33.3 kbps in normal
transmission mode and 83.3 kbps in High-Speed transmission mode. The
achievable baud rate is primarily a function of the network characteristics
(termination and number of nodes on the bus), and assumes bus loading as
per SAE J2411. Each Single Wire CAN port has a local bus load resistance
of 9.09 kΩ between the CAN_H and RTH pins of the transceiver to provide
protection against the loss of ground. The AU5790 also supports advanced
power management through low-power sleep and wake-up modes. For
detailed specifications of the AU5790, refer to the Philips AU5790 data
sheet.
Characteristic Specification
Voltage 8–18 VDC (12 VDC typical) on V+ connector
pin (referenced to V–)
Current 40 mA typical 90 mA maximum
VBAT Jumper
Because the AU5790 requires external bus power, there is no option to
power the VBAT signal internally. For this reason, the VBAT jumper is not
present on Single Wire hardware, and external bus power must be
provided.
The bus power requirements and VBAT jumper setting for an XS port
depend on the mode selected. Refer to the appropriate High-Speed,
Low-Speed/Fault-Tolerant, or Single Wire physical layer section to
determine the behavior for the mode selected. For example, the bus power
requirements and VBAT jumper operation for an XS port configured for
Single Wire mode are identical to those of a dedicated Single Wire node.
You can change the transceiver type within MAX using the Properties
dialog for each port. The transceiver type selected within MAX is used as
the default for NI-CAN applications. The initial transceiver configuration
in MAX is High-Speed for Port 1 and Low-Speed/Fault-Tolerant for
Port 2.
You also can change the transceiver type within the application, which
overrides the value in MAX. This feature is provided as the Transceiver
Type attribute of the Frame API, and the Interface Transceiver Type
property of the Channel API.
RTSI Switch
Start Trigger
RTSI0–RTSI6
Interface Receive Event
Triggers
10 Hz Resync
PXI Trigger Bus
PXI_Star
Start Trigger
20 MHz Timebase
PXI_Clk10
Master Timebase
Figure 3-6. RTSI Signal Interconnect Architecture for NI PXI CAN Hardware
PCMCIA-CAN
For PCMCIA-CAN cards, the physical layer is implemented inside the
cable.
The three types of physical layers available for PCMCIA-CAN cards are:
• High-Speed
• Low-Speed/Fault-Tolerant
• Single Wire
Transceiver
PCMCIA-CAN High-Speed hardware uses the Philips TJA1041
High-Speed CAN transceiver. The TJA1041 is fully compatible with the
ISO 11898 standard and supports baud rates up to 1 Mbps. This device also
supports advanced power management through a low-power sleep mode.
This feature is provided as the Transceiver Mode attribute of the Frame
API and the Interface Transceiver Mode property of the Channel API.
For detailed TJA1041 specifications, refer to the Philips TJA1041 data
sheet.
Transceiver
PCMCIA-CAN Low-Speed/Fault-Tolerant hardware uses the Philips
TJA1054A Low-Speed/Fault-Tolerant transceiver. The TJA1054A
supports baud rates up to 125 kbps. The transceiver can detect and
automatically recover from the following CAN bus failures:
• CAN_H wire interrupted
• CAN_L wire interrupted
• CAN_H short-circuited to battery
• CAN_L short-circuited to battery
• CAN_H short-circuited to VCC
• CAN_L short-circuited to VCC
• CAN_H short-circuited to ground
• CAN_L short-circuited to ground
• CAN_H and CAN_L mutually short-circuited
Transceiver
PCMCIA-CAN Single Wire hardware uses the Philips AU5790 Single
Wire CAN transceiver. The AU5790 supports baud rates up to 33.3 kbps in
normal transmission mode and 83.3 kbps in High-Speed transmission
mode. The achievable baud rate is primarily a function of the network
characteristics (termination and number of nodes on the bus), and assumes
bus loading as per SAE J2411. Each Single Wire CAN port has a local bus
load resistance of 9.09 kΩ between the CAN_H and RTH pins of the
transceiver to provide protection against the loss of ground. The AU5790
also supports advanced power management through low-power sleep and
wake-up modes. For detailed AU5790 specifications, refer to the Philips
AU5790 data sheet.
Characteristic Specification
Voltage 8–18 VDC (12 VDC typical) on V+ connector pin
(referenced to V–)
Current 40 mA typical 90 mA maximum
Synchronization
The PCMCIA-CAN synchronization cable provides the ability to
synchronize a Series 2 PCMCIA-CAN card with other National
Instruments hardware or external devices. The synchronization cable
provides a flexible interconnect scheme for sharing timing and triggering
signals in a system. For example, PCMCIA-CAN synchronization is
specifically designed to integrate well with National Instruments E Series
DAQCard hardware. Timing and triggering signals can be shared by wiring
the synchronization cable signals to the appropriate terminals on a DAQ
terminal block.
RTSI Switch
Start Trigger
TRIG0–TRIG3
Interface Receive Event
Triggers
10 Hz Resync
TRIG7_CLK
Clock
Master Timebase
Table 3-8, PCMCIA-CAN Trigger Lines and Wire Colors, shows the
function of each trigger line and its corresponding wire color.
To improve the signal integrity of the trigger lines, all GND wires should
be connected to digital logic ground of the system. Unused trigger lines
may also be grounded. Refer to Appendix E, Specifications, for detailed
DC operating characteristics.
USB-CAN
This section describes the hardware characteristics of the USB-CAN
hardware.
Transceiver
USB-CAN High-Speed hardware uses the Philips TJA1041 High-Speed
CAN transceiver. The TJA1041 is fully compatible with the ISO 11898
standard and supports baud rates up to 1 Mbps. This device also supports
advanced power management through a low-power sleep mode. This
feature is provided as the Transceiver Mode attribute of the Frame API. For
detailed TJA1041 specifications, refer to the Philips TJA1041 data sheet.
LED Indicators
Table 3-9 provides a description of the LEDs on the front panel of the
USB-8473 and USB-8473s.
Name Function
USB Indicates connectivity to a USB Host. Green indicates
a USB full speed connection. Amber indicates a USB
high speed connection.
CAN Flashes to indicate the presence of traffic on the
CAN bus.
Transceiver
USB-CAN Low-Speed/Fault-Tolerant hardware uses the Philips
TJA1054A Low-Speed CAN transceiver. The TJA1054A supports baud
rates up to 125 kbps. The transceiver can detect and automatically recover
from the following CAN bus failures:
• CAN_H wire interrupted
• CAN_L wire interrupted
• CAN_H short-circuited to battery
• CAN_L short-circuited to battery
• CAN_H short-circuited to VCC
• CAN_L short-circuited to VCC
• CAN_H short-circuited to ground
• CAN_L short-circuited to ground
• CAN_H and CAN_L mutually short-circuited
LED Indicators
Table 3-10 provides a description of the LEDs on the front panel of the
USB-8472 and USB-8472s.
Name Function
USB Indicates connectivity to a USB Host. Green indicates
a USB full speed connection. Amber indicates a USB
high speed connection.
CAN Flashes to indicate the presence of traffic on the
CAN bus.
USB-LIN
This section describes the USB-LIN hardware.
USB-8476/USB-8476s: LIN
The USB-LIN physical layer circuitry interfaces the LIN microcontroller to
the physical bus wires. The USB-LIN physical layer is powered externally
from VBat (required for the LIN bus), and is optically isolated up to
500 VDC (withstand, 2s max) channel-to-bus. This isolation protects your
NI-LIN hardware and the PC it is connected to from being damaged by
high-voltage spikes on the LIN bus.
Transceiver
USB-LIN hardware uses the Atmel ATA6620 LIN transceiver. The
ATA6620 is fully compatible with the ISO-9141 standard and supports
baud rates up to 20 kbps. This device also supports advanced power
management through a low-power sleep mode. This feature is provided as
the Transceiver Mode attribute of the Frame API. For detailed ATA6620
specifications, refer to the Atmel ATA6620 data sheet.
pin serves as the reference ground for the isolated signals. Refer to the
High-Speed PCI, PXI, and USB Connector Pinout section of Chapter 4,
Connectors and Cables, for information about how to connect signals to a
LIN interface.
Characteristic Specification
Voltage 8-18 VDC on VBat connector pin
(referenced to Gnd)
Current 55 mA maximum
LED Indicators
Table 3-12 provides a description of the LEDs on the front panel of the
USB-8476 and USB-8476s.
Name Function
USB Indicates connectivity to a USB Host. Green indicates a
USB full speed connection. Amber indicates a USB high
speed connection.
LIN Flashes to indicate the presence of traffic on the LIN bus.
VBAT Indicates the presence of LIN bus power.
4 3
Pin Description
CLK Clock pin
TRG Trigger pin
GND Ground pin
4 3
Pin Description
CLK Clock pin
TRG Trigger pin
GND Ground pin
What is CompactRIO?
National Instruments CompactRIO is an advanced embedded control and
acquisition system powered by NI reconfigurable I/O (RIO) technology.
CompactRIO combines a low-power-consumption, real-time embedded
processor with a high-performance RIO FPGA chipset. The RIO core has
built-in data transfer mechanisms to pass data to the embedded processor
for real-time analysis, post processing, data logging, or communication to
a networked host computer. CompactRIO provides direct hardware access
to the I/O circuitry of each I/O module using LabVIEW FPGA I/O
functions. Each I/O module includes built-in connectivity, signal
conditioning, conversion circuitry (such as ADC or DAC), and an optional
isolation barrier.
NI 985x
The NI 9853 is a CAN High-Speed I/O module for the CompactRIO
platform. For information on the NI 9853 CAN module, refer to the
NI 9853 Operating Instructions.
For information on the software support for the NI 9853 and NI 9852
modules, refer to the LabVIEW FPGA help.
No Connection
1
CAN_L
2
CAN_H
7
V–
3
No Connection
8
No Connection
4
V+
9
Shield
5
CAN_H and CAN_L are signals lines that carry the data on the CAN
network. These signals should be connected using twisted-pair cable.
CA
V- N (In
L t
C_ H erna
S H lP
C_ V+ wr), P
J2 OR
T1
J1
CAN_H and CAN_L are signal lines that carry the data on the CAN
network. These signals should be connected using twisted-pair cable.
Characteristic Value
Impedance 108 Ω minimum, 120 Ω nominal,
132 Ω maximum
Length-related resistance 70 mΩ /m nominal
Specific line delay 5 ns/m nominal
Cable Lengths
The allowable cable length is affected by the characteristics of the cabling
and the desired bit transmission rates. Detailed cable length
recommendations can be found in the ISO 11898, CiA DS 102, and
DeviceNet specifications.
ISO 11898 specifies 40 m total cable length with a maximum stub length
of 0.3 m for a bit rate of 1 Mb/s. The ISO 11898 specification says that
significantly longer cable lengths may be allowed at lower bit rates, but
each node should be analyzed for signal integrity problems.
Number of Devices
The maximum number of devices depends on the electrical characteristics
of the devices on the network. If all of the devices meet the requirements of
ISO 11898, at least 30 devices may be connected to the bus. Higher
numbers of devices may be connected if the electrical characteristics of the
devices do not degrade signal quality below ISO 11898 signal level
specifications. If all of the devices on the network meet the DeviceNet
specifications, 64 devices may be connected to the network.
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 communication failures.
Because communication flows both ways on the CAN bus, CAN requires
that both ends of the cable be terminated. However, this requirement does
not mean that every device should have a termination resistor. If multiple
devices are placed along the cable, only the devices on the ends of the cable
should have termination resistors. Refer to Figure 4-3 for an example of
where termination resistors should be placed in a system with more than
two devices.
CAN_H
CAN
120 Ω 120 Ω
Device CAN_L
Cabling Example
Figure 4-4, Cable Connecting Two CAN Devices, shows an example of a
cable to connect two CAN devices. For the internal power configuration,
no V+ connection is required.
SHIELD
Pin 3 Pin 5 Pin 5 Pin 3
V+
Pin 5 Pin 9 Pin 9 Pin 5
V–
Pin 1 Pin 3 Pin 3 Pin 1
Power
Connector
V+
V–
No Connection
1
Optional Ground (V–)
6
CAN_L
2
CAN_H
7
V–
3
No Connection
8
No Connection
4
V+
9
Shield
5
Figure 4-5. Pinout for 9-Pin D-SUB Connector
CAN_H and CAN_L are signals lines that carry the data on the CAN
network. These signals should be connected using twisted-pair cable.
S
R
_L
S
er
ie
-
s
V
2,
H
S
P
or
+
V
R H
t1
_
J2
H
T
J1
CAN_H and CAN_L are signal lines that carry the data on the CAN
network. These signals should be connected using twisted-pair cable.
Table 4-7. Specifications for Characteristics of a CAN_H and CAN_L Pair of Wires
Characteristic Value
Length-related resistance 90 mΩ /m nominal
Length-related capacitance: CAN_L and 30 pF/m nominal
ground, CAN_H and ground, CAN_L and
CAN_H
Number of Devices
The maximum number of devices depends on the electrical characteristics
of the devices on the network. If all of the devices meet the requirements of
typical Low-Speed/Fault-Tolerant CAN, up to 32 devices may be
connected to the bus. Higher numbers of devices may be connected if the
electrical characteristics of the devices do not degrade signal quality below
Low-Speed/Fault-Tolerant signal level specifications.
Termination
Every device on the low-speed CAN network requires a termination
resistor for each CAN data line: RRTH for CAN_H and RRTL for CAN_L.
Figure 4-7 shows termination resistor placement in a low-speed CAN
network.
CAN_H
CAN_L
The following sections explain how to determine the correct resistor values
for the low-speed CAN card, and how to replace those resistors, if
necessary.
1 1 1 1 1
-------------------------- = ------------------------ + ------------------------ + ------------------------ + ------------------------
R RTHoverall R RTHnode1 R RTHnode2 R RTHnode3 R RTHnoden
1
R RTHoverall = -----------------------------------------------------------------------------------------------------------------------------------------------------------------
1
⎛ ----------------------------------------------------------------------------------- 1 ⎞
⎝ R RTHoveralloflow – speedCANinterface - + ----------------------------------------------------------------
R RTHofexistingnetworkordevice⎠
where
RRTH overall should be between 100 and 500 Ω
RRTH of low-speed CAN interface = 510 Ω ±5% (mounted) or
15 kΩ ±5% (in kit)
|RRTH = RRTL
As the formula indicates, the 510 Ω ±5% shipped on the card will work
with properly terminated networks having a total RTH and RTL
termination of 125 to 500 Ω, or individual devices having an RTH and RTL
termination of 500 to 16 kΩ. For communication with a network having an
overall RTH and RTL termination of 100 Ω to 125 Ω, you will need to
replace the 510 Ω resistors with the 15 kΩ resistors in the kit. Refer to the
next section of this chapter, Replacing the Termination Resistors on the
PCMCIA-CAN/LS Cable. The PCMCIA-CAN/LS cable ships with
screw-terminal mounted RTH and RTL values of 510 Ω ±5% per port. The
PCMCIA-CAN/LS cable also internally mounts a pair of 15.8 kΩ ±1%
resistors in parallel with the external 510 Ω resistors for each port.
This produces an effective RTH and RTL of 494 Ω per port for the
PCMCIA-CAN/LS cable. After determining the termination of the existing
network or device, you can use the formula below to indicate which
1
R RTHoverall = ----------------------------------------------------------------------------------------------------------------------------------------------
1 1
⎛ ----------------------------------------------------------------- + ---------------------------------------------------------------- ⎞
⎝ R RTHoflow – speedCANinterface R RTHofexistingnetworkordevice⎠
where
RRTH overall should be between 100 Ω and 500 Ω
RRTH of PCMCIA-CAN/LS = 494 Ω (510 Ω ± 5% (external) in parallel
with 15.8 kΩ ± 1% (internal), or 15.8 kΩ ± 1% (internal) only
|RRTH = RRTL
1
R RTHoverall = -------------------------------------------------------------------------------------------------------------------------------
-
1
⎛ --------------------------------------------------- 1 ⎞
- + ----------------------------------------------------------------
⎝ R RTHofPCMCIA – CANLS R RTHofexistingnetworkordevice⎠
where
RInternal RTH of PCMCIA-CAN/LS = 15.8 kΩ ± 1%
|RRTH = RRTL
For information on replacing the external RTH and RTL resistors on the
PCMCIA-CAN/LS cable, refer to the Replacing the Termination Resistors
on the PCMCIA-CAN/LS Cable section of this chapter.
2. Cut and bend the lead wires of the resistors you want to install. Refer to
Figure 4-9.
0.3 in.
(8 mm)
0.165 in.
(4 mm)
2. Cut and bend the lead wires of the resistors you want to install. Refer to
Figure 4-11 for an example.
0.3 in.
(8 mm)
0.165 in.
(4 mm)
0.3 in.
(7.62 mm)
0.138 in.
(3.5 mm)
3. Mount RTL by inserting the leads of one resistor into pins 1 and 2 of
the pluggable terminal block and tightening the mounting screws.
Mount RTH by inserting the leads of the second resistor into pins 6 and
7 of the pluggable terminal block and tightening the mounting screws.
4. Refer to the NI-CAN Software and Hardware Installation Guide in the
jewel case of the program CD to complete the hardware installation.
Cabling Example
Figure 4-13 shows an example of a cable to connect two low-speed CAN
devices. For the PCMCIA-CAN/LS cables, only V–, CAN_L, and CAN_H
are required to be connected to the bus.
CAN_L
Pin 2 Pin 2 Pin 2 Pin 2
SHIELD
Pin 4 Pin 5 Pin 5 Pin 4
V+
Pin 5 Pin 9 Pin 9 Pin 5
V–
Pin 3 Pin 3 Pin 3 Pin 3
Power
Connector
V+
V–
No Connection
1
Optional Ground (V–)
6
CAN_L
2
CAN_H
7
V–
3
No Connection
8
No Connection
4
V+
9
Shield
5
Figure 4-14. Pinout for 9-Pin D-SUB Connector
CAN_H and CAN_L are signals lines that carry the data on the CAN
network. These signals should be connected using twisted-pair cable.
C
A
N
/S
W
-
V
S
_L
er
C
ie
s
H
2,
S
P
_H
J2
or
t1
C
+
V
(E r)
xt
P
w
J1
CAN_H is the signal line that carries the data on the CAN network.
Cable Length
There shall be no more than 60 m between any two network system
ECU nodes.
Number of Devices
As stated previously, the maximum number of Single Wire CAN nodes
allowed on the network depends on the electrical characteristics of the
devices and cable. If all of the devices and cables meet the requirements of
J2411, between 2 and 32 devices may be networked together.
Cabling Example
Figure 4-16 shows an example of a cable to connect two Single Wire CAN
devices.
9-Pin 9-Pin
D-Sub D-Sub
CAN_H
Pin 7 Pin 7
SHIELD
Pin 5 Pin 5
V+
Pin 9 Pin 9
V–
Pin 3 Pin 3
Power
Connector
V+
V–
No Connection
1
Optional Ground (V–)
6
CAN_L
2
CAN_H
7
V–
3
No Connection
8
No Connection
4
V+
9 Shield
RX and TX are the serial receive and transmit signals from the SJA1000
CAN controller. GND serves as the reference ground for RX and TX.
MODE0 and MODE1 are digital output signals for controlling the mode
selection of an external transceiver. For example, the TJA1041 and
TJA1054A have STB and EN input pins to select the transceiver operating
mode.
9-Pin
D-Sub
CAN_L TX
Pin 7
CAN_H RX
Pin 2
V– STATUS
Pin 8
Power
Connector
V+
V–
LIN
This section describes the USB-LIN hardware.
No Connection
1
Ground
6
No Connection
2
LIN
7
Ground
3
No Connection
8
No Connection
4
VBat
9
Shield
5
Figure 4-19. Pinout for 9-Pin D-SUB Connector
Cable Specifications
LIN cables should meet the physical medium requirement of a bus RC time
constant of 5 microseconds. For detailed formulas for calculating this
value, refer to the Line Characteristics section of the LIN specification.
Cable Lengths
The maximum allowable cable length is 40 meters, per the LIN
specification.
Number of Devices
The maximum number of devices on a LIN bus is 16, per the LIN
specification.
Termination
LIN cables require no termination, as nodes are terminated at the
transceiver. Slave nodes are typically pulled up from the LIN bus to VBat
with a 30 KΩ resistance and a serial diode. This termination is usually
integrated into the transceiver package. The master node requires a 1 KΩ
resistor and serial diode between the LIN bus and VBat.
LabVIEW
NI-CAN functions and controls are available in the LabVIEW palettes. In
LabVIEW 7.0 or later, the NI-CAN palette is located within the top-level
NI Measurements palette. In earlier LabVIEW versions, the NI-CAN
palette is located at the top-level. The top level of the NI-CAN function
palette contains subpalettes for the Channel API and Frame API. Each
subpalette of an API contains the most commonly used functions, with
subpalettes for advanced functions.
The NI-CAN software includes a full set of examples for LabVIEW. These
examples teach basic NI-CAN programming as well as advanced topics.
The example help describes each example and includes a link you can use
to open the VI.
LabWindows/CVI
Within LabWindows™/CVI™, the NI-CAN function panel is in
Libraries»NI-CAN. Like other LabWindows/CVI function panels, the
NI-CAN function panel provides help for each function and the ability to
generate code.
The header file for both NI-CAN APIs is nican.h. The library for both
NI-CAN APIs is nican.lib.
Visual C++ 6
The NI-CAN 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-CAN folder. The typical path to this folder is \Program
Files\National Instruments\NI-CAN\MS Visual C.
To use either NI-CAN API, include the nican.h header file in the code,
then link with the nicanmsc.lib library file.
The _cplusplus define enables the transition from C++ to the C language
NI-CAN functions.
You can find examples for the C language in the MS Visual C subfolder
of the NI-CAN folder. Each example is in a separate folder. A description of
each example is in comments at the top of the .c file.
Borland C/C++
The header file and library for Borland C/C++ are in the Borland C folder
of the NI-CAN folder. The typical path to this folder is \Program
Files\National Instruments\NI-CAN\Borland C.
To use either NI-CAN API, include the nican.h header file in the code,
then link with the nicanbor.lib library file.
The _cplusplus define enables the transition from C++ to the C language
NI-CAN functions.
You can find examples for the C language in the Borland C subfolder of
the NI-CAN folder. Each example is in a separate folder. A description of
each example is in comments at the top of the .c file.
The .BAS files are located in the MS Visual Basic folder of the NI-CAN
folder. The typical path to this folder is \Program Files\National
Instruments\NI-CAN\MS Visual Basic.
You can find examples for Visual Basic in the Channel API examples
and Frame API examples subfolders of the MS Visual Basic folder.
Each example is in a separate folder. A .vbp file with the same name as the
example opens the Visual Basic project. A description of the example is
located in a Help form within the project.
If the programming language supports the Microsoft Win32 APIs, you can
load pointers to NI-CAN functions in the application. The following text
demonstrates use of the Win32 functions for C/C++ environments other
than Visual C/C++ 6. For more detailed information, refer to Microsoft
documentation.
The application must de-reference the pointer to call the NI-CAN function,
as shown by the following code:
nctTypeStatus status;
nctTypeTaskRef TaskRef;
status = (*PnctInitStart)("mychannel1, mychannel2", 0,
nctModeInput, 1000.0, &TaskRef);
Before exiting the application, you must unload the NI-CAN DLL as
follows:
FreeLibrary(NicanLib);
For example, if you have one application that uses the Channel API and
another application that uses the Frame API, you cannot use CAN0 with
both at the same time. As an alternative, you can connect CAN0 and CAN1
to the same network, then use CAN0 with one application and CAN1 with
the other, if you have a 2-port CAN card. As another alternative, you can
use CAN0 in both applications, but run each application at a different time
(not simultaneously).
• The devices require use of remote frames. The Channel API does not
provide support for remote frames, but the Frame API has extensive
features to transmit and receive remote frames. For more information,
refer to the Remote Frames section of Chapter 9, Using the Frame
API, in this manual.
• The Frame API provides RTSI features that are lower level than the
synchronization features of the Channel API. If you have advanced
requirements for synchronizing CAN and DAQ cards, you may need to
use the Frame API. For more information, refer to the RTSI section of
Chapter 9, Using the Frame API, in this manual.
• The USB-847x is supported only by the Frame API. In addition, the
USB-847x hardware uses the Network Interface, not CAN objects.
In some cases, applications might require the ability to convert CAN data
between a CAN frame and a CAN channel. For information on frame to
channel conversion, channel to frame conversion, and virtual interfaces,
refer to the Frame to Channel Conversion section of Chapter 6, Using the
Channel API, in this manual.
Yes No Yes No
If you answer yes, refer to the Import CAN Database into MAX section of
this chapter. If you answer no, refer to the Access CAN Database within
Application section of this chapter.
For more information, refer to the description of the Init Start function in
the Channel API reference sections of this help file.
If you answer yes, refer to the Use Create Message Function in Application
section of this chapter.
If you answer no, you create the channel configuration within MAX. You
can save the MAX channel configuration to a file, so this method does not
prevent you from deploying the application for use by others. For more
information, refer to the Create in MAX section of this chapter.
The inputs to Create Message are relatively advanced for many users. Use
of MAX or a CAN database helps to isolate the application end user from
the specifics of CAN message encoding.
Mode dependent channels are a special kind of CAN message used within
some networks. Refer to the Mode Dependent Channels section of this
chapter for more information. If you must support creation of mode
dependent channel configurations within the application, use the Create
MessageEx function instead of Create Message. The Create MessageEx
function provides extensions for creation of mode dependent as well as
normal channels.
Create in MAX
To create channel configurations within MAX, right-click the CAN
Channels heading, then select Create Message. Enter the message
properties, then select OK. Right-click the message name, then select
Create Channel. Enter the channel properties, then select OK. Select
Create Channel again for each channel contained in the message. Channel
names are case sensitive.
Figure 6-2 shows a diagram describing the basic programming model for
the NI-CAN Channel API. Within the application, you repeat this basic
programming model for each task. The diagram is followed by a
description of each step in the model.
Init Start
Mode = Output
Mode = Input or Output Recent Mode = Timestamped Input
Read
Read Write
Timestamped
Clear
Init Start
The Init Start function initializes a list of channels as a single task, then
starts communication for that task.
The Init Start function simply calls the Initialize function followed by the
Start function. This provides an easy way to start a list of channels.
There are a few scenarios in which you cannot use Init Start:
• Set Property—If you need to set properties for the task, you must call
Initialize, Set Property, and Start in sequence. For example, use Set
Property if you need to specify the baud rate for the interface within
the application. For more information, refer to the Set Property section
of this chapter.
• Synchronization—If you need to synchronize multiple cards, you
must call Initialize, then the appropriate functions to synchronize and
start the cards. For more information, refer to the Synchronization
section of this chapter.
• Create Message—If you need to create channel configurations within
the application, you must call Create Message and Start in sequence.
For assistance is deciding whether Create Message is appropriate for
the application, refer to the Choose Source of Channel Configuration
section of this chapter.
The Init Start function is CAN Init Start in LabVIEW and nctInitStart
in other languages.
Read
If the mode of Init Start is Input, the application must call the Read function
to obtain floating-point samples. The application typically calls Read in a
loop until done.
The Read function is CAN Read in LabVIEW (all types that don’t end in
Time & Dbl) and nctRead in other languages.
sample rate = 0
Read returns a single sample from the most recent message(s) received
from the network. One sample is returned for every channel in the Init Start
list.
Start
A B C
def A C
Read Read Read
Figure 6-4 shows an example of Read with sample rate > 0. A, B, and C
represent messages for the initialized channels. <delta-t> represents the
time between samples as specified by the sample rate. def represents the
Default Value in MAX.
Start
A B C
Δt
Read Timestamped
If the Init Start mode is Timestamped Input, the application must call the
Read Timestamped function to obtain floating-point samples. The
application typically calls Read Timestamped in a loop until done.
Start
A B C
A B C
At Bt Ct
Read Timestamped
Write
If the Init Start mode is Output (or Output Recent), the application must call
the Write function to output floating-point samples. The application
typically calls Write in a loop until done.
sample rate = 0
Write transmits a message immediately on the network. The samples
provided to write are used to form the data bytes of the message. One
sample must be specified for every channel in the Init Start list. The Init
Start mode must be Output for this behavior (not Output Recent).
Start
A B C D
A B C D
Write Write
Figure 6-7, Example of Write with Sample Rate > 0, Output Mode, shows
an example of Write with sample rate > 0 and Output mode. A, B, C and D
represent messages for the initialized channels. <delta-t> represents the
time between message transmission as specified by the sample rate.
Start
A B C D
Δt
A B C D
Write Write
Figure 6-7. Example of Write with Sample Rate > 0, Output Mode
Figure 6-8 shows an example of Write with sample rate > 0 and Output
Recent mode.
Start
B B D D
Δt
A B C D
Write Write Write Write
Figure 6-8. Example of Write with Sample Rate > 0, Output Recent Mode
Clear
The Clear function stops communication for the task, then clears the
configuration.
For every task that you initialize, you must call Clear prior to exiting the
application.
Get Names
If you are developing an application that another person will use, you may
not want to specify a fixed channel list in the application. Ideally, you want
the end-user to select the channels of interest from user interface controls,
such as list boxes.
The Get Names function queries MAX or a CAN database and returns
a list of all channels in that database. You can use this list to populate
user-interface controls. The end-user can then select channels from these
controls, avoiding the need to type each name using the keyboard. Once the
user makes his selections, the application can pass the resulting list to Init
Start.
Synchronization
The NI-CAN Channel API uses RTSI to synchronize specific functional
units on each card. For CAN cards, the functional unit is the interface
(port). For DAQ cards, the functional unit is a specific measurement such
as Analog Input or Analog Output. Each function routes two signals over
the RTSI connection:
• timebase—This is a common clock shared by both cards. The shared
timebase ensures that sampling does not drift. The timebase applies to
all functional units on the card.
• start trigger—This signal is sent from one functional unit to the other
functional unit when sampling starts. The shared start trigger ensures
that both units start simultaneously.
Set Property
The Init Start function uses interface and channel configuration as specified
in MAX or the CAN database file. If you need to change this configuration
within the application, you cannot use Init Start, because most properties
cannot be changed while the task is running.
For example, to set the baud rate for the interface within the application, use
the following calling sequence:
• Initialize the task as stopped. The Initialize function is CAN Initialize
in LabVIEW and nctInitialize in other languages.
• Use Set Property to specify the new value for the baud rate property.
The Set Property function is CAN Set Property in LabVIEW and
nctSetProperty in other languages.
• Start the task with the Start function. The Start function is CAN Start
in LabVIEW and nctStart in other languages.
After the task is started, you may need to change properties again. To
change properties within the application, use the Stop function to stop the
task, Set Property to change properties, and then Start the task again.
You also can use the Get Property function to get the value of any property.
The Get Property function returns values whether the task is running or not.
Many applications require the ability to convert CAN data from one format
to another. As one example, consider an application that logs CAN traffic
to a file for an extended period of time. Since CAN frames occur in an event
driven manner, the most efficient means of file storage is to use CAN
frames as the data format. Nevertheless, when displaying the contents of
the log file, you may need to plot the data as waveforms for specific CAN
channels. Therefore, the application must convert the CAN frames in the
file into CAN channels for waveform display.
Figure 6-9 demonstrates how you can use NI-CAN to display waveforms
of CAN channels using a log file consisting of CAN frames. NI-CAN
provides a virtual CAN card with two interfaces, CAN256 and CAN257.
The two virtual interfaces are connected by a virtual bus. When you write
CAN frames to one virtual interface, those frames are received by the other
virtual interface, and can be read as channels. This feature allows you to
read and write CAN data in the same manner as two real CAN interfaces
connected by a real CAN cable. The conversion does not require real
NI CAN hardware, and your application is not required to check for
specific CAN IDs.
Application
Log
File
Read frames
from file, Read CAN
and write channels
to NI-CAN. from NI-CAN,
and plot as
waveforms.
Figure 6-9. Display Waveforms of CAN Channels Using a Log File of CAN Frames
Logging
As explained in the Introduction, logging is one of the primary applications
for frame to channel conversion. Since overall CAN traffic does not occur
at a fixed rate, the most efficient implementation is to store each CAN
frame as it is received. The file of CAN frames can later be displayed as
channels using NI-CAN’s frame to channel conversion.
In addition to displaying a log file as channels, you can also use NI-CAN
to create a log file using channel data. The process for this channel to frame
conversion is essentially a reversal of the operations shown in Figure 6-9
above. You obtain CAN channel data from front panel controls, and write
that CAN channel data to a Channel API output task on a virtual interface
(CAN257). Next, you read the resulting CAN frames from a Frame API
virtual interface (CAN256), and write those frames to the log file. At a
subsequent date, you can replay this log file to a real CAN interface using
the timestamped transmit feature (Transmit Mode attribute of the Frame
API network interface).
CompactRIO
The rugged enclosure and real-time capabilities of CompactRIO, as
discussed in the CAN for CompactRIO section of Chapter 3, NI CAN and
LIN Hardware, make it an ideal product for testing in the field, such as
drive testing of an automobile. Since the LabVIEW FPGA I/O interface for
CAN provides access to CAN frames only, you must use NI-CAN’s frame
to channel conversion features when access to CAN channels is required.
Database Queries
For large test applications that are deployed to several end-users, it is
common to query CAN databases for initial configuration of a test. For
example, you specify a list of channel names, each with parameters for
display in a single waveform graph, then save that test configuration to
a file. The application that queries the CAN database to create a test
configuration file often executes on a system without NI CAN hardware.
By initializing a Channel API task on CAN256, you can use the CAN Get
Property function to obtain detailed information for each message and
channel in a CAN database.
USB-847x
The USB-847x hardware is supported only by the Frame API. For some
applications with the USB-847x you may want to display CAN data as
channels. In this case you can use frame to channel conversion to convert
the frame data into channel data for display.
When Virtual Bus Timing is true (default), the time between frames is
simulated. Frame timestamps are recalculated as they transfer across the
virtual bus. This mode is useful when you want the virtual bus to behave as
much like a real bus as possible. For example, if you use the technique
shown in Figure 6-1 to display a log file that was captured over 200 seconds
of time, the channel waveforms will scroll slowly to display data for
200 seconds. This is due to the fact that when you write two frames whose
timestamps are a few seconds apart, NI-CAN will delay a few seconds on
the virtual bus, and therefore the Channel API Read of CAN257 will delay
between the two frames. The programming model used to write NI-CAN
applications for real CAN hardware can be used for a majority of
applications with Virtual Bus Timing enabled. Refer to the Channel API
Basic Programming Model of this chapter and the Frame API Basic
Programming Model for CAN section of Chapter 9, Using the Frame API,
for information on programming real CAN hardware.
When Virtual Bus Timing is false, the time between frames is not
simulated. Frame timestamps are unchanged as they transfer across the
virtual bus. This mode is useful when you want to convert CAN data from
frames to channels as quickly as possible. For example, if you use the
technique shown in Figure 6-1 to display a log file that was captured over
200 seconds of time, the channel waveforms will scroll by very quickly.
This is due to the fact that when you write two frames whose timestamps
are a few seconds apart, NI-CAN will not delay the transfer on the virtual
bus, and therefore the Channel API Read of CAN257 will not delay
between the two frames. Although the conversion occurs quickly, you will
presumably use products like LabVIEW or DIAdem to search the
waveforms for specific events. When Virtual Bus Timing is disabled, time
advances only up to the timestamp of the last frame written onto the virtual
bus. As a result, if NI-CAN detects that a frame with a timestamp lesser
than the previous frame timestamp is being written onto the virtual bus, an
error will be returned. Refer to the Programming Model for Virtual Bus
Timing Disabled section of this chapter for information on developing an
application that converts frames to channels or channels to frames without
simulating frame timing.
When you change the Virtual Bus Timing in your application, you must set
the same value on both virtual interfaces, CAN256 and CAN257.
Limitations
The virtual interface is not designed to support all of the features of a real
interface. This section serves as the primary reference for the limitations of
the virtual interface.
For each NI-CAN feature, the virtual interface will behave in one of
three ways:
• Error—The NI-CAN function returns an error. This occurs for
features that are not supported, and which represent high-level
capabilities that your application would require. For example, the
virtual interface does not support Frame API CAN Objects, so the error
helps to clarify that you cannot execute applications that rely on CAN
Objects.
• Non-operational—The NI-CAN function returns success, but the
feature performs in a fixed, non-operational manner. This occurs for
features that your application typically would not rely on. For example,
the virtual interface always returns zero for the Serial Number
attribute, because your application may display the serial number,
but operate correctly when the number is invalid.
• Operational—The NI-CAN function returns success, and operates as
expected with regard to the virtual bus. For example, if you write a
frame to a virtual network interface using the Frame API, that frame
will transfer across the virtual bus to the other virtual interface.
Table 6-1 lists all Error features for the virtual interface. The VBT column
lists the values (T=true, F=false) of the Virtual Bus Timing attribute for
which the Error behavior applies. If the VBT column lists both T and F,
then Virtual Bus Timing does not affect the Error feature listed.
Table 6-2 lists all Operational features for the virtual interface. The VBT
column lists the values (T=true, F=false) of the Virtual Bus Timing attribute
for which the Operational behavior applies. If the VBT column lists both
T and F, then Virtual Bus Timing does not affect the Operational features
listed.
All features that are not explicitly listed in these tables are
Non-operational. The behavior of Non-operational features is not
documented in this manual. Your application should not make assumptions
regarding the behavior of Non-operational features beyond the fact that
NI-CAN returns success.
Frame API: Set Attribute of Log Start T, F Determine whether to return a start trigger
Trigger frame from ReadMult. Start trigger frames
are useful for logging/replay applications.
Frame API: Set Attribute of Read Mult T Sets the number of frames used as a
Size for Notification threshold for the Read Multiple state. For
more information on the Read Multiple
state, refer to ncWaitForState.vi.
Frame API: Set Attribute of Timeline T Determine whether to perform timeline
Recovery recovery for simulated bus timing.
The mode channel is an implicit channel inside the CAN frame that cannot
be accessed by an application for read or write operations. Each channel
that relies on a mode channel is associated to a certain mode of that mode
channel. This way the mode channel determines the distribution of the data
in a CAN frame to the associated CAN channels in the application. Since a
single CAN frame no longer contains data for all of these mode dependent
channels associated with a CAN message, mode dependent channel data is
buffered inside the NI-CAN driver. If the application reads data from a
channel, the most recent received value will be returned for that channel.
Writing data from mode dependent channels will result in sending one
CAN frame per mode, defined for the appropriate task. If more than one
mode channel is defined for a CAN message, the NI-CAN driver assures
that each mode of each mode channel is sent at least once with every write
operation.
Within the multiplexer dialog box define the properties of the mode
channel. On a multiplexer item create a mode item and define the value of
the mode channel (mode value). On a mode item, create channels which are
only valid when the mode-channel contains the specified mode value. The
channels of different modes in the same multiplexer may overlap each
other, as shown in Figure 6-11, Mode Dependent Channels in the MAX
Configuration Tree.
Unless otherwise stated, each NI-CAN VI suspends execution of the calling thread until it
completes.
Section Headings
The following are section headings found in the Channel API for LabVIEW VIs.
Purpose
Each VI description includes a brief statement of the purpose of the VI.
Format
The format section describes the format of each VI.
Description
The description section gives details about the purpose and effect of each VI.
List of VIs
Table 7-1 is an alphabetical list of the NI-CAN VIs for the Channel API.
Function Purpose
CAN Clear.vi Stop communication for the task and then clear
the configuration.
CAN Clear with NI-DAQ.vi Stop and clear the CAN task and the NI-DAQ
task synchronized with CAN Sync Start with
NI-DAQ.vi.
Function Purpose
CAN Clear with NI-DAQmx.vi Stop and clear the CAN task and the NI-DAQmx
task synchronized with CAN Sync Start with
NI-DAQmx.vi.
CAN Clear Multiple with NI-DAQ.vi Stop and clear the list of CAN tasks and the list
of NI-DAQ tasks synchronized with CAN Sync
Start Multiple with NI-DAQ.vi.
CAN Clear Multiple with NI-DAQmx.vi Stop and clear the list of CAN tasks and the list
of NI-DAQmx tasks synchronized with CAN
Sync Start Multiple with NI-DAQmx.vi.
CAN Connect Terminals.vi Connect a terminal in the CAN hardware.
CAN Create Message.vi Create a message configuration and associated
channel configurations within the LabVIEW
application.
CAN Create MessageEx.vi Create a message configuration and associated
channel configurations within the LabVIEW
application. In addition you can specify mode
dependent channels with CAN Create
MessageEx.vi. For more information about
mode dependent channels, refer to the Mode
Dependent Channels section of Chapter 6,
Using the Channel API.
CAN Disconnect Terminals.vi Disconnect terminals in the CAN hardware.
CAN Get Names.vi Get an array of CAN channel names or message
names from MAX or a CAN database file.
CAN Get Property.vi Get a property for the task, or a single channel
within the task. The poly VI selection
determines the property to get.
CAN Initialize.vi Initialize a task for the specified channel list.
CAN Init Start.vi Initialize a task for the specified channel list,
then start communication.
CAN Read.vi Read samples from a CAN task initialized as
input. Samples are obtained from received CAN
messages. The poly VI selection determines the
data type to read.
Function Purpose
CAN Set Property.vi Set a property for the task, or a single channel
within the task. The poly VI selection
determines the property to set.
CAN Start.vi Start communication for the specified task.
CAN Stop.vi Stop communication for the specified task.
CAN Sync Start with NI-DAQ.vi Synchronize and start the specified CAN task
and NI-DAQ task.
CAN Sync Start with NI-DAQmx.vi Synchronize and start the specified CAN task
and NI-DAQmx task.
CAN Sync Start Multiple with NI-DAQ.vi Synchronize and start the specified list of
multiple CAN tasks and NI-DAQ tasks. This is
a more complex implementation of CAN Sync
Start with NI-DAQ.vi that supports multiple
CAN and a single NI-DAQ hardware product.
CAN Sync Start Multiple with NI-DAQmx.vi Synchronize and start the specified list of
multiple CAN tasks and NI-DAQmx tasks. This
is a more complex implementation of CAN
Sync Start with NI-DAQmx.vi that supports
multiple CAN and a single NI-DAQmx
hardware product.
CAN Write.vi Write samples to a CAN task initialized as
Output. (Refer to the mode parameter of CAN
Init Start.vi.) Samples are placed into
transmitted CAN messages. The poly VI
selection determines the data type to write.
CAN Clear.vi
Purpose
Stop communication for the task and then clear the configuration.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi, and then wired through
subsequent VIs.
Outputs
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
The CAN Clear VI must always be the final NI-CAN VI called for each task. If you do not
use the CAN Clear VI, the remaining task configurations can cause problems in execution of
subsequent NI-CAN applications.
If the cleared task is the last running task for the initialized interface (refer to CAN Init
Start.vi), the CAN Clear VI also stops communication on the CAN controller of the interface
and disconnects all terminal connections for that interface.
Unlike other VIs, this VI will execute when status is True in Error in.
Because this VI clears the task, the task reference is not wired as an output. To change
properties of a running task, use CAN Stop.vi to stop the task, CAN Set Property.vi to
change the desired property, and then CAN Start.vi to restart the task.
Purpose
Stop and clear the CAN task and the NI-DAQ task synchronized with CAN Sync Start with
NI-DAQ.vi.
Format
Inputs
task reference in is the NI-CAN task reference you passed through the
CAN Sync Start with NI-DAQ VI.
If you wire the same RTSI terminal that you passed into CAN Sync Start
with NI-DAQ.vi, this VI clears the routing in NI-DAQ. If you leave RTSI
terminal unwired, the VI retains the routing in NI-DAQ. This VI always
clears RTSI routing for NI-CAN.
NI-DAQ task ID is the same NI-DAQ task ID you wired into the CAN
Sync Start with NI-DAQ VI.
Outputs
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so that you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of the
VI for editing.
Purpose
Stop and clear the CAN task and the NI-DAQmx task synchronized with CAN Sync Start
with NI-DAQmx.vi.
Format
Inputs
task reference in is the NI-CAN task reference you passed through the
CAN Sync Start with NI-DAQmx VI.
DAQmx task in is the same DAQmx task in you wired into CAN
Sync Start with NI-DAQmx.vi.
Outputs
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so that you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of the
VI for editing.
Purpose
Stop and clear the list of NI-CAN tasks and the NI-DAQ task synchronized with CAN Sync
Start Multiple with NI-DAQ.vi.
Format
Inputs
CAN task reference list is the same array of NI-CAN task references you
wired into the CAN Sync Start Multiple with NI-DAQ VI.
If you wire the same RTSI terminal that you passed into CAN Sync Start
Multiple with NI-DAQ.vi, this VI clears the routing in NI-DAQ. If you
leave RTSI terminal unwired, the VI retains the routing in NI-DAQ. This
VI always clears RTSI routing for NI-CAN.
NI-DAQ task ID is NI-DAQ task ID you wired into the CAN Sync Start
Multiple with NI-DAQ VI.
Outputs
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
All tasks are cleared to their state prior to CAN Sync Start Multiple with NI-DAQ.vi.
For example, this VI clears terminal routing of all NI-DAQ devices to the default state.
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of
the VI for editing.
Purpose
Stop and clear the list of NI-CAN tasks and the NI-DAQmx task synchronized with CAN
Sync Start with NI-DAQmx.vi.
Format
Inputs
CAN task reference list is the same array of NI-CAN task references you
wired into the CAN Sync Start with NI-DAQmx.vi.
NI-DAQ task in is the same NI-DAQ task in you wired into the CAN Sync
Start Multiple with NI-DAQmx VI.
Outputs
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
All tasks are cleared to their state prior to CAN Sync Start Multiple with NI-DAQ. For
example, this VI clears terminal routing of all NI-DAQ devices to the default state.
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of
the VI for editing.
Purpose
Connect a terminal in the CAN hardware.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI.
The task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi, and then wired through
subsequent VIs.
RTSI0... RTSI6
RTSI7/RTSI Clock
For PCI and PXI form factors, this receives a 20 MHz (default)
timebase from another CAN or DAQ card. For example, you can
synchronize a CAN and DAQ E Series MIO card by connecting
the 20 MHz oscillator (board clock) of the DAQ card to
RTSI7/RTSI Clock, and then connecting RTSI7/RTSI Clock
to Master Timebase on the CAN card.
PXI_Star
Within a PXI chassis, some PXI products can source star trigger
from Slot 2 to all higher-numbered slots. PXI_Star enables the
PXI CAN card to receive the star trigger when it is in Slot 3 or
higher.
This value applies to Series 2 PXI CAN cards only. If you are
using a Series 1 CAN card or Series 2 PCI or PCMCIA CAN card,
selecting this value results in an error.
PXI_Clk10
This value applies to Series 2 PXI CAN cards only. If you are
using a Series 1 CAN card or Series 2 PCI or PCMCIA CAN card,
selecting this value results in an error.
20 MHz Timebase
This value applies to Series 2 PXI or PCI CAN cards only. If you
are using a Series 1 CAN card or Series 2 PCMCIA CAN card,
selecting this value results in an error.
10 Hz Resync Clock
This value is typically used with Series 1 CAN cards only. If all of
the CAN cards are Series 2, the 20 MHz timebase is preferable due
to the lack of drift. If you are using a mix of Series 1 and Series 2
CAN cards, you must use the 10 Hz Resync Clock.
The Interface Receive Event can be used as the start trigger for
other NI cards, or for external instruments.
This value applies to Series 2 CAN cards only. If you are using a
Series 1 CAN card, selecting this value results in an error.
Start Trigger
Start Trigger selects the start trigger, the event that begins
sampling for tasks.
The start trigger is the same for all tasks using a given interface,
such as the interface input to CAN Initialize.vi.
RTSI0... RTSI6
RTSI7/RTSI Clock
This value applies to Series 2 CAN cards only. If you are using a
Series 1 CAN card, selecting this value results in an error.
Master Timebase
Master Timebase instructs the CAN card to use the source of the
connection as the master timebase. The CAN card uses this master
timebase for input sampling (including timestamps of received
messages) as well as periodic output sampling.
For PCI and PXI form factors, you can use RTSI7/RTSI Clock as
the source terminal. By default, this receives a 20 MHz timebase
from another CAN or DAQ card. For example, you can
synchronize a CAN and DAQ E Series MIO card by connecting
the 20 MHz oscillator (board clock) of the DAQ card to
RTSI7/RTSI Clock, and then connecting RTSI7/RTSI Clock to
Master Timebase on the CAN card. To change the Master
Timebase Rate to 10 MHz, use CAN Set Property.vi to change
the Hardware Master Timebase Rate.
For PXI form factor, you also can use PXI_Clk10 as the source
terminal. This receives the PXI 10 MHz backplane clock for use
as the master timebase.
For PCMCIA form factor, you can use RTSI7/RTSI Clock as the
source terminal. Unlike PCI and PXI, the PCMCIA CAN card
requires a 10 MHz timebase on RTSI7/RTSI Clock. For
synchronization with a PCMCIA DAQ card, this is done by
programming the FREQOUT signal of the DAQ card to 10 MHz,
This value applies to Series 2 CAN cards only. If you are using a
Series 1 CAN card, selecting this value results in an error.
10 Hz Resync Clock
This value is typically used with Series 1 CAN cards only. If all of
the CAN cards are Series 2, the 20 MHz timebase is preferable due
to the lack of drift. If you are using a mix of Series 1 and Series 2
CAN cards, you must use the 10 Hz Resync Clock.
Start Trigger
Start Trigger selects the start trigger, the event that begins
sampling for tasks. The start trigger occurs on the first low-to-high
transition of the source terminal.
The start trigger is the same for all tasks using a given interface,
such as the interface input to CAN Initialize.vi.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
Description
This VI connects a specific pair of source/destination terminals. One of the terminals is
typically a RTSI signal, and the other terminal is an internal terminal in the CAN hardware.
By connecting internal terminals to RTSI, you can synchronize the CAN card with another
hardware product such as an NI-DAQ card.
The most common uses of RTSI synchronization are demonstrated by CAN Sync Start with
NI-DAQ.vi, CAN Sync Start with NI-DAQmx.vi, CAN Sync Start Multiple with
NI-DAQ.vi, and CAN Sync Start Multiple with NI-DAQmx.vi. The diagram for each of
these example VIs uses CAN Connect Terminals, and therefore serves as a good starting point
when learning this VI.
When the final task for a given interface is cleared with CAN Clear.vi, NI-CAN disconnects
all terminal connections for that interface. Therefore, CAN Disconnect Terminals.vi is not
required for most applications. NI-DAQ terminals remain connected after the tasks are
cleared, so you must disconnect NI-DAQ terminals manually at the end of the application.
The series of the NI CAN hardware determines what combinations of source terminal to
destination terminal are valid. In Table 7-2, 1 indicates Series 1 hardware, and 2 indicates
Series 2 hardware. You can determine the series of the NI CAN hardware by selecting the
name of the card within the Devices and Interfaces view in the left pane of MAX.
Destination
10 Hz
RTSI0 to RTSI_CLO Master Resync Start
Source RTSI6 CK Timebase Clock Trigger
RTSI0 to — — — 1,2 1,2
RTSI6
RTSI7/RTSI — — 2 — —
Clock
PXI_Star — — — — 2
PXI_Clk10 — — 2 — —
20 MHz — 2 — — —
Timebase
10 Hz Resync 1,2 — — — 1,2
Clock
Interface 2 — — — 2
Receive
Event
Interface 2 — — — —
Transceiver
Event
Start Trigger 1,2 — — — —
Event
Purpose
Create a message configuration and associated channel configurations within the LabVIEW
application.
Format
Inputs
interface specifies the CAN interface to use for this task.
The interface input uses a ring typedef in which value 0 selects CAN0,
value 1 selects CAN1, and so on.The interface input is required. Since the
messages and channels are not defined in MAX, you cannot use MAX
default as the interface.
The default baud rate for the interface is defined within MAX, but you can
change it by setting the Interface Baud Rate property with CAN Set
Property.vi.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
mode specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
Input
Input channel data from received CAN messages. Use CAN Read.vi
to obtain input samples as single point, array, or waveform.
Use this input mode to read waveforms of timed samples, such as for
comparison with NI-DAQ waveforms. You also can use this input
mode to read a single point from the most recent message, such as for
control or simulation.
Output
Output channel data to CAN messages for transmit. Use CAN
Write.vi to write output samples as single-point, array, or waveform.
Each sample value that you write is transmitted in a message on the
network. If you write an array or waveform, the samples are buffered
for subsequent transmit.
Output Recent
Output channel data to CAN messages for transmit. This mode is used
with sample rate greater than zero (periodic transmit). Use CAN
Write.vi to provide a single sample per channel. Each periodic
message uses the sample values from the most recent CAN Write.vi.
For this mode, there are restrictions on using channels in channel list
that are contained in multiple messages. Refer to CAN Read.vi for
more information.
Timestamped Input
Input channel data from received CAN messages. Use CAN Read.vi
to obtain input samples as an array of sample/timestamp pairs (Poly VI
types ending in Timestamped Dbl).
Use this input mode to read samples with timestamps that indicate
when each message is received from the network.
sample rate specifies the timing to use for samples of the task. The sample
rate is specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For mode of Input, a sample rate of zero means that CAN Read.vi returns
a single point from the most recent message received, and greater than zero
means that CAN Read.vi returns samples timed at the specified rate.
For mode of Output, a sample rate of zero means that CAN messages
transmit immediately when CAN Write.vi is called, and greater than zero
means that CAN messages are transmitted periodically at the specified rate.
When the interface specifies a virtual interface (256 or 257), and mode is
Output or Output Recent, this sample rate must be zero (greater than
zero not supported).
message ID
extended ID?
number of bytes
channel config list configures a list of channels for the new message. The
channel config list is an array of clusters, with one cluster for each channel.
The properties of each channel entry are similar to the channel properties
in MAX:
start bit
number of bits
Configures the number of bits for the raw data in the message. The
range is 1 to 64.
byte order
data type
scaling factor
scaling offset
min value
The CAN Read.vi and CAN Write.vi VIs do not coerce samples
when converting to/from CAN messages. You can use this value
with property nodes to set the range of front-panel controls and
indicators.
max value
The CAN Read.vi and CAN Write.vi VIs do not coerce samples
when converting to/from CAN messages. You can use this value
with property nodes to set the range of front-panel controls and
indicators.
default value
unit string
You can use this value to display units (such as volts or RPM)
along with the samples of the channel.
Outputs
Use task reference out with all subsequent VIs to reference the task. Wire
this task reference to CAN Start.vi before you read or write samples for the
message.
Description
To use message and channel configurations from MAX or a CAN database, use CAN Init
Start.vi or CAN Initialize.vi. The CAN Create Message provides an alternative in which
you create the message and channel configurations within the application, without use of
MAX or a CAN database.
CAN Create Message returns a task reference that you wire to CAN Start.vi to start
communication for the message and its channels.
Purpose
Create a message configuration and associated channel configurations within the application.
Format
Inputs
interface specifies the CAN interface to use for this task.
The interface input uses a ring typedef in which value 0 selects CAN0,
value 1 selects CAN1, and so on.
The interface input is required. Since the messages and channels are not
defined in MAX, you cannot use MAX default as the interface.
The default baud rate for the interface is defined within MAX, but you can
change it by setting the Interface Baud Rate property with CAN Set
Property.vi.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
mode specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
Input
Input channel data from received CAN messages. Use CAN Read.vi to
obtain input samples as single point, array, or waveform.
Use this input mode to read waveforms of timed samples, such as for
comparison with NI-DAQ waveforms. You also can use this input mode to
read a single point from the most recent message, such as for control or
simulation.
Output
Output channel data to CAN messages for transmit. Use CAN Write.vi to
write output samples as single-point, array, or waveform. Each sample
value that you write is transmitted in a message on the network. If you write
an array or waveform, the samples are buffered for subsequent transmit.
Output Recent
Output channel data to CAN messages for transmit. This mode is used with
sample rate greater than zero (periodic transmit). Use CAN Write.vi to
provide a single sample per channel. Each periodic message uses the
sample values from the most recent CAN Write.vi.
For this mode, there are restrictions on using channels in channel list that
are contained in multiple messages. Refer to CAN Read.vi for more
information.
Timestamped Input
Input channel data from received CAN messages. Use CAN Read.vi to
obtain input samples as an array of sample/timestamp pairs (Poly VI types
ending in Timestamped Dbl).
Use this input mode to read samples with timestamps that indicate when
each message is received from the network.
sample rate specifies the timing to use for samples of the task. The sample
rate is specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For mode of Input, a sample rate of zero means that CAN Read.vi returns
a single point from the most recent message received, and greater than zero
means that CAN Read.vi returns samples timed at the specified rate.
For mode of Output, a sample rate of zero means that CAN messages
transmit immediately when CAN Write.vi is called, and greater than zero
means that CAN messages are transmitted periodically at the specified rate.
When the interface specifies a virtual interface (256 or 257), and mode is
Output or Output Recent, this sample rate must be zero (greater than
zero not supported).
message ID
extended ID?
number of bytes
channel config list configures a list of channels for the new message. The
channel config list is an array of clusters, with one cluster for each channel.
The properties of each channel entry are similar to the channel properties
in MAX:
start bit
number of bits
Configures the number of bits for the raw data in the message. The
range is 1 to 64.
byte order
data type
scaling factor
scaling offset
min value
The CAN Read.vi and CAN Write.vi VIs do not coerce samples
when converting to/from CAN messages. You can use this value
with property nodes to set the range of front-panel controls and
indicators.
max value
The CAN Read.vi and CAN Write.vi VIs do not coerce samples
when converting to/from CAN messages. You can use this value
with property nodes to set the range of front-panel controls and
indicators.
default value
unit string
You can use this value to display units (such as volts or RPM)
along with the samples on a channel.
Mode channel config configures a list of the mode channels for this (data)
channel. Currently, only one mode channel is allowed per (data) channel.
Note that the same mode channel can be specified for several channels.
Mode value
Start Bit
Num Bits
byte order
Default Value
Outputs
Use task reference out with all subsequent VIs to reference the task. Wire
this task reference to CAN Start.vi before you read or write samples for the
message.
Description
To use message and channel configurations from MAX or a CAN database, use the
nctInitStart or nctInitialize. CAN Create MessageEx provides an alternative in
which you create the message and channel configurations within the application, without use
of MAX or a CAN database. In addition, CAN Create MessageEx offers optionally the
possibility to specify mode dependent messages without using MAX or CAN databases.
CAN Create MessageEx returns a task reference that you wire to CAN Start.vi to start
communication for the message and its channels.
Purpose
Disconnect terminals in the CAN hardware.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi and then wired through
subsequent VIs.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
Description
This VI disconnects a specific pair of source/destination terminals that were previously
connected with CAN Connect Terminals.vi.
When the final task for a given interface is cleared with CAN Clear.vi, NI-CAN disconnects
all terminal connections for that interface. Therefore, the CAN Disconnect Terminals VI is
not required for most applications. This VI is typically used to change RTSI connections
dynamically while an application is running. First, use CAN Stop.vi to stop all tasks for the
interface, then use CAN Disconnect Terminals and CAN Connect Terminals to adjust RTSI
connections, then CAN Start.vi to restart sampling.
Purpose
Get an array of CAN channel names or message names from MAX or a CAN database file.
Format
Inputs
filepath is an optional path to a CAN database file from which to get
channel names. The file must use either a .DBC or .NCD extension. Files
with extension .DBC use the CANdb database format. Files with extension
.NCD use the NI-CAN database format. You can generate NI-CAN
database files from the Save Channels selection in MAX.
The default (unwired) value of filepath is empty, which means to get the
channel names from MAX. The MAX CAN channels are in the MAX CAN
channels listing within Data Neighborhood.
message name is an optional input that filters the names for a specific
message. The default (unwired) value is an empty string, which means to
return all names in the database. If you wire a nonempty string, the channel
list output is limited to channels of the specified message. This input
applies to mode of channels only. It is ignored for mode of messages.
Outputs
channel list returns the array of channel names, one string entry per
channel.
The names in channel list use the minimum syntax required to properly
initialize the channels:
• If a channel name is used within only one message in the database,
CAN Get Names returns only the channel name in the array.
• If a channel name is used within multiple messages, CAN Get Names
prepends the message name to that channel name, with a decimal point
separating the message and channel name. This syntax ensures that the
duplicate channel is associated to a single message in the database.
For more information on the syntax conventions for channel names, refer
to CAN Init Start.vi.
To start a task for all channels returned from CAN Get Names, wire
channel list to CAN Init Start.vi to start a task.
You also can wire channel list to the property nodes of a front panel control
such as a ring or list box. The user of the VI can then select names using
this control, and the selected names can be wired to CAN Init Start.vi.
Purpose
Get a property for the task, or a single channel within the task. The poly VI selection
determines the property to get.
To select the property, right-click the VI, go to Select Type and select the property by name.
For LabVIEW 7.0 and later, you can right-click the VI and select Visible Items»Poly VI
Selector to select the property from within the diagram.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI.
The task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi, and then wired through
subsequent VIs.
channel name specifies an individual channel within the task. The default
(unwired) value of channel name is empty, which means the property
applies to the entire task, not a specific channel.
Properties that begin with the word Channel or Message do not apply to the
entire task, but an individual channel or message within the task. For these
channel-specific properties, you must wire the name of a channel from
channel list into the channel name input.
For properties that do not begin with the word Channel or Message, you
must leave channel name unwired (empty).
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
The poly output value returns the property value. You select the property
returned in value by selecting the Poly VI type. The data type of value is
also determined by the Poly VI selection. For information about the
different properties provided by CAN Get Property.vi, refer to the Poly VI
Types section in this function reference.
To select the property, right-click the VI, go to Select Type and select the
property by name.
Poly VI Types
Behavior After Final Output
Returns the Behavior After Final Output property, which is used with
some output task configurations. For more information, refer to the
Behavior After Final Output property in CAN Set Property.vi.
The value of this property cannot be changed using CAN Set Property.vi.
The value of this property cannot be changed using CAN Set Property.vi.
The value of this property is originally set within MAX or CAN Create
Message.vi. If the channel is initialized directly from a CAN database, the
value is 0.0 by default, but it can be changed using CAN Set Property.vi.
The CAN Read.vi and CAN Write.vi VIs do not coerce samples when
converting to/from CAN messages. You can use this value with CAN
database to set the range of front-panel controls and indicators.
The value of this property cannot be changed using CAN Set Property.vi.
The CAN Read.vi and CAN Write.vi VIs do not coerce samples when
converting to/from CAN messages. You can use this value with property
nodes to set the range of front-panel controls and indicators.
The value of this property cannot be changed using CAN Set Property.vi.
The value of this property cannot be changed using CAN Set Property.vi.
Returns the scaling factor used to convert raw bits of the message to/from
scaled floating-point units. The scaling factor is the A in the linear scaling
formula AX+B, where X is the raw data, and B is the scaling offset.
CAN messages use the raw data, and the CAN Read.vi and CAN Write.vi
VIs provide access to samples in floating-point units.
The value of this property cannot be changed using CAN Set Property.vi.
Returns the scaling offset used to convert raw bits of the message to/from
scaled floating-point units. The scaling offset is the B in the linear scaling
formula AX+B, where X is the raw data, and A is the scaling factor.
CAN messages use the raw data, and the CAN Read.vi and CAN Write.vi
VIs provide access to samples in floating-point units.
The value of this property cannot be changed using CAN Set Property.vi.
Returns the starting bit position in the message. The range is 0 (lowest bit
in first byte) to 63 (highest bit in last byte).
The value of this property cannot be changed using CAN Set Property.vi.
Returns the unit string of the channel. The string is no more than
80 characters in length.
You can use this value to display units (such as volts or RPM) along with
the samples on a channel.
The value of this property cannot be changed using CAN Set Property.vi.
Returns the hardware form factor for the NI-CAN hardware that contains
interface.
0 PCI
1 PXI
2 PCMCIA
3 AT
Returns the hardware serial number for the NI-CAN hardware that contains
interface.
Hardware Series
Returns the hardware series for the NI CAN hardware that contains
Interface.
Newer hardware series often have more features, so the application may
need to determine which is installed.
Interface
Returns the interface initialized for the task, such as with the CAN Init
Start VI.
Basic baud rates such as 125000 and 500000 are specified as the numeric
rate.
Advanced baud rates are specified as 8000XXYY hex, where YY is the value
of Bit Timing Register 0 (BTR0), and XX is the value of Bit Timing
Register 1 (BTR1) of the CAN controller chip. For more information, refer
to the Interface Properties dialog in MAX.
The value of this property is originally set within MAX, but it can be
changed using CAN Set Property.vi.
Returns a Boolean value that indicates whether the listen only feature of the
Philips SJA1000 CAN controller is enabled (TRUE) or disabled (FALSE).
For more information, refer to the Interface Listen Only? property in CAN
Set Property.vi.
Since the listen only feature requires the Philips SJA1000 CAN controller,
this property is supported on Series 2 NI CAN hardware only.
Since the error counts require the Philips SJA1000 CAN controller, this
property is supported on Series 2 NI CAN hardware only. If you are using
Series 1 NI CAN hardware, this property returns an error.
Returns the current values of the Error Code Capture register and
Arbitration Lost Capture register from the Philips SJA1000 CAN controller
chip.
The Error Code Capture register provides information on bus errors that
occur according to the CAN standard. A bus error increments either the
Interface Transmit Error Counter or the Interface Receive Error Counter.
When communication starts on the interface, the first bus error is captured
into the Error Code Capture register and retained until you get this property.
After you get this property, the Error Code Capture register is again enabled
to capture information for the next bus error.
For each of the capture registers, a single-bit New flag indicates whether a
new error has occurred since the last Get. If the New flag of a register is set,
the associated fields contain new information. If the New flag of a register
is clear, the associated fields are the same as the previous Get.
This property is commonly used with the Interface Single Shot Transmit
property. When CAN Write.vi is used to transmit the single frame, you can
get this property to determine if the transmit was successful. If the single
shot transmit was not successful, this property provides detailed
information for the failure.
This property is supported for Series 2 hardware only (not Series 1). Since
the information and bit format is very specific to the Philips SJA1000 CAN
controller on Series 2 hardware, National Instruments cannot guarantee
compatibility for this property on future hardware series. When using this
property in the application, it is best to get the Hardware Series to verify
that the CAN hardware is Series 2.
For information regarding the format of the bits in this property, refer to
Series 2 Error/Arb Capture attribute in the ncGetAttr.vi function of the
Frame API.
Returns the value of the Interface Series 2 Mask property (refer to CAN Set
Property.vi).
Returns the transceiver external inputs for the interface that was initialized
for the task.
This property uses a bit mask. When using the property, use bitwise AND
operations to check for values, not equality checks (equal, greater than, and
so on).
00000001 hex STATUS
This bit is set when 5 V exists on the STATUS pin.
This bit is clear when 0 V exists on the STATUS pin.
Returns the transceiver external outputs for the interface that was initialized
for the task.
For more information on the format of the value returned in this property,
refer to the description of Interface Transceiver External Outputs
property in CAN Set Property.vi.
Returns the transceiver mode for the interface that was initialized for the
task.
The transceiver mode changes when you set the mode within the
application, or when a remote wakeup transitions the interface from Sleep
to Normal mode. For more information, refer to CAN Set Property.vi.
Normal
Sleep
Transceiver and the CAN controller chip are both in sleep mode.
Returns the type of transceiver for the interface that was initialized for the
task. For hardware other than Series 2 XS cards, the transceiver type is
fixed. For Series 2 XS cards, the transceiver type reflects the most recent
value specified by MAX or CAN Set Property.vi.
High-Speed
Low-Speed/Fault-Tolerant
Single Wire
External
Disconnect
Since the error counts require the Philips SJA1000 CAN controller, this
property is supported on Series 2 NI CAN hardware only. If you are using
Series 1 NI CAN hardware, this property returns an error.
Message ID
The value of this property cannot be changed using CAN Set Property.vi.
Message ID is Extended?
The value of this property cannot be changed using CAN Set Property.vi.
Message Name
Returns the name of the channel message. The string is no more than
80 characters in length.
The value of this property cannot be changed using CAN Set Property.vi.
Returns the number of data bytes in the channel message. The range is
1 to 8.
The value of this property cannot be changed using CAN Set Property.vi.
Mode
Returns the mode initialized for the task, such as with CAN Init Start.vi.
Number of Channels
This property applies only to tasks initialized with mode of Input and
sample rate greater than zero. For all other configurations, it returns an
error.
Sample Rate
Returns the SampleRate initialized for the task, such as with CAN Init
Start.vi.
Timeout
Returns the value that is returned on time stamped read for mode dependent
channels that have not been received with the most recent CAN frame
associated with the CAN message. This property applies only to mode
dependent channels that are read with the time stamped read operation.
For more information, refer to the Mode Dependent Channels section of
Chapter 6, Using the Channel API.
Version Build
Returns the build number of the NI-CAN software. This number applies to
Development, Alpha, and Beta phase only, and should be ignored for
Release phase.
Version Comment
Version Major
Version Minor
Version Phase
0 Development
1 Alpha
2 Beta
3 Release
Version Update
CAN Initialize.vi
Purpose
Initialize a task for the specified channel list.
Format
Inputs
filepath is an optional path to a CAN database file from which to import
the channel (signal) configurations.
For more information, refer to the channel list input of CAN Init Start.vi.
The interface input uses a ring typedef in which value 0 selects CAN0,
value 1 selects CAN1, and so on.
The default (unwired) value is MAX default, which means to use the
default interface as defined in the Message/Channel configuration
properties. If the default interface in MAX is All, or if filepath is wired to
use a CAN database (not MAX), the interface is a required input to this VI.
The Channel API and Frame API cannot use the same CAN network
interface simultaneously. If the CAN network interface is already
initialized in the Frame API, this function returns an error.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
mode specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
Input
Input channel data from received CAN messages. Use CAN Read.vi to
obtain input samples as single-point, array, or waveform.
Use this input mode to read waveforms of timed samples, such as for
comparison with NI-DAQ waveforms. You also can use this input mode to
read a single point from the most recent message, such as for control or
simulation.
For this mode, the channels in channel list can be contained in multiple
messages.
Output
Output channel data to CAN messages for transmit. Use CAN Write.vi to
write output samples as single point, array, or waveform. Each sample
value that you write is transmitted in a message on the network. If you write
an array or waveform, the samples are buffered for subsequent transmit.
For this mode, there are restrictions on using channels in channel list that
are contained in multiple messages. Refer to CAN Write.vi for more
information.
Output Recent
Output channel data to CAN messages for transmit. This mode is used with
sample rate greater than zero (periodic transmit). Use CAN Write.vi to
provide a single sample per channel. Each periodic message uses the
sample values from the most recent CAN Write.vi.
For this mode, there are restrictions on using channels in channel list that
are contained in multiple messages. Refer to CAN Read.vi for more
information.
Timestamped Input
Input channel data from received CAN messages. Use CAN Read.vi to
obtain input samples as an array of sample/timestamp pairs (Poly VI types
ending in Timestamped Dbl).
Use this input mode to read samples with timestamps that indicate when
each message is received from the network.
For this mode, the channels in channel list must be contained in a single
message.
sample rate specifies the timing to use for samples of the task. The sample
rate is specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For mode of Input, sample rate of zero means that CAN Read.vi returns
a single point from the most recent message received, and greater than zero
means that CAN Read.vi returns samples timed at the specified rate.
For mode of Output, sample rate of zero means that CAN messages
transmit immediately when CAN Write.vi is called, and greater than zero
means that CAN messages are transmitted periodically at the specified rate.
For mode of Output Recent, sample rate must be greater than zero
(periodic transmit).
When the interface specifies a virtual interface (256 or 257), and mode is
Output or Output Recent, this sample rate must be zero (greater than
zero not supported).
Outputs
Use task reference out with all subsequent VIs to reference the task. Wire
this task reference to CAN Start.vi before you read or write samples for the
message.
Description
The CAN Initialize.vi VI does not start communication. This enables you to use CAN Set
Property.vi to change the properties of the task, or CAN Connect Terminals.vi to
synchronize CAN or DAQ cards. After you change properties or connections, use CAN
Start.vi to start communication for the task.
Purpose
Initialize a task for the specified channel list, then start communication.
Format
Inputs
filepath is an optional path to a CAn database file from which to import the
channel (signal) configurations.
channel list is the array of channel names to initialize and start as a task.
Each channel name is provided in an array entry.
You can type in the channel list entries as string constants, or you can obtain
the list from MAX or another CAN database by using CAN Get Names.vi.
Channel names are case sensitive.
You can initialize the same channel list with different interface, mode,
or sample rate, because each task reference is unique.
[message.]channel
• message refers to the message in which the channel is contained.
The message name must be followed by a decimal point.
If the channel name occurs in multiple messages, you must specify the
message name to identify the channel uniquely. Within MAX,
channels with the same name in multiple messages are shown with a
yellow exclamation point.
If the channel name is unique across all channels, the message name is
not required.
• channel refers to the channel (signal) name in MAX or the CAN
database (indicated by filepath).
If you are using mode dependent channels, and each channel name is not
unique, you will need to use a special syntax described in the Mode
Dependent Channel Syntax section at the end of the function description.
The interface input uses a ring typedef in which value 0 selects CAN0,
value 1 selects CAN1, and so on.
The default (unwired) value is MAX default, which means to use the
default interface as defined in the Message/Channel configuration
properties. If the default interface in MAX is All, or if filepath is wired to
use a CAN database (not MAX), the interface is a required input to this VI.
The Channel API and Frame API cannot use the same CAN network
interface simultaneously. If the CAN network interface is already
initialized in the Frame API, this function returns an error.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
mode specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
Input
Input channel data from received CAN messages. Use CAN Read.vi to
obtain input samples as single-point, array, or waveform.
Use this input mode to read waveforms of timed samples, such as for
comparison with NI-DAQ waveforms. You also can use this input mode to
read a single point from the most recent message, such as for control or
simulation.
For this mode, the channels in channel list can be contained in multiple
messages.
Output
Output channel data to CAN messages for transmit. Use CAN Write.vi to
write output samples as single-point, array, or waveform. Each sample
value that you write is transmitted in a message on the network. If you write
an array or waveform, the samples are buffered for subsequent transmit.
For this mode, there are restrictions on using channels in channel list that
are contained in multiple messages. Refer to CAN Write.vi for more
information.
Output Recent
Output channel data to CAN messages for transmit. This mode is used with
sample rate greater than zero (periodic transmit). Use CAN Write.vi to
provide a single sample per channel. Each periodic message uses the
sample values from the most recent CAN Write.vi.
For this mode, there are restrictions on using channels in channel list that
are contained in multiple messages. Refer to CAN Write.vi for more
information.
Timestamped Input
Input channel data from received CAN messages. Use CAN Read.vi to
obtain input samples as an array of sample/timestamp pairs (Poly VI types
ending in Timestamped Dbl).
Use this input mode to read samples with timestamps that indicate when
each message is received from the network.
For this mode, the channels in channel list must be contained in a single
message.
sample rate specifies the timing to use for samples of the task. The sample
rate is specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For mode of Input, a sample rate of zero means that CAN Read.vi returns
a single point from the most recent message received, and greater than zero
means that CAN Read.vi returns samples timed at the specified rate.
For mode of Output, a sample rate of zero means that CAN messages
transmit immediately when CAN Write.vi is called, and greater than zero
means that CAN messages are transmitted periodically at the specified rate.
For mode of Output Recent, sample rate must be greater than zero
(periodic transmit).
When the interface specifies a virtual interface (256 or 257), and mode is
Output or Output Recent, this sample rate must be zero (greater than
zero not supported).
Outputs
Use task reference out with all subsequent VIs to reference the running
task. Because CAN Init Start.vi starts communication, you can wire this
task reference to CAN Read.vi or CAN Write.vi.
Description
The diagram for this VI simply calls CAN Initialize.vi followed by CAN Start.vi. This
provides an easy way to start a list of channels.
The following list describes the scenarios for which CAN Init Start.vi cannot be used:
• If you need to set properties for the channels, use CAN Initialize.vi, then CAN Set
Property.vi, then CAN Start.vi. CAN Init Start.vi starts communication, and most
channel properties cannot be changed after the task is started.
• If you need to synchronize tasks for multiple NI-CAN or NI DAQ cards, refer to the VIs
in the CAN/DAQ Synchronization palette, such as CAN Sync Start with NI-DAQ.vi.
• If you need to create channel configurations entirely within LabVIEW, without using
MAX or a CAN database file, use CAN Create Message.vi, then CAN Start.vi. CAN
Init Start.vi accepts only channel names defined in MAX or a CAN database file.
[message name.[[multiplexer.]mode_value.]]channel.
• message name refers to the message in which the channel is contained. The message
name must be followed by a decimal point.
• multiplexer refers to the multiplexer name in MAX or the CAN database. The multiplexer
must be followed by a decimal point.
• mode_value refers to the multiplexer mode in MAX or the CAN database.
The mode_value must be followed by a decimal point.
• channel refers to the channel (signal) name in MAX or the CAN database.
You cannot use the same channel name for a normal CAN channel and a mode dependent
CAN channel within the same CAN message.
For more information on mode dependent channels, refer to the Mode Dependent Channels
section of Chapter 6, Using the Channel API.
CAN Read.vi
Purpose
Read samples from a CAN task initialized as input. Samples are obtained from received CAN
messages. The poly VI selection determines the data type to read.
To select the data type, right-click the VI, go to Select Type, and select the type by name. For
LabVIEW 7.0 and later, you can right-click the VI and select Visible Items»Poly VI Selector
to select the data type from within the diagram. For an overview of CAN Read, refer to the
Read and Read Timestamped sections of Chapter 6, Using the Channel API.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI.
The task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi, and then wired through
subsequent VIs.
The mode initialized for the task must be either Input or Timestamped
Input.
number of samples to read specifies the number of samples to read for the
task. For single-sample Poly VI types, CAN Read.vi always returns one
sample, so this input is ignored.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
The poly output samples returns the samples read from received CAN
messages. The type of the poly output is determined by the Poly VI
selection. For information on the different poly VI types provided by CAN
Read.vi, refer to the Poly VI Types section in this function reference.
To select the data type, right-click the VI, go to Select Type, and select the
type by name.
Poly VI Types
The name of each Poly VI type uses the following conventions:
• The first term is either Single-Chan or Multi-Chan. This indicates whether the type
returns data for a single channel or multiple channels. Multi-Chan types return an array
of analogous Single-Chan types, one entry for each channel initialized in channel list of
CAN Init Start.vi. Single-Chan types are convenient because no array indexing is
required, but you are limited to reading only one CAN channel.
• The second term is either Single-Samp or Multi-Samp. This indicates whether the type
returns a single sample, or an array of multiple samples. Single-Samp types are often
used for single point control applications, such as within LabVIEW RT.
• The third term indicates the data type used for each sample. The word Dbl indicates
double-precision (64-bit) floating point. The word Wfm indicates the waveform data type.
The words 1D and 2D indicate one and two-dimensional arrays, respectively. The words
Time & Dbl indicate a cluster of a LabVIEW timestamp and a double-precision sample.
If the initialized sample rate is greater than zero, this poly VI type waits for the next sample
time, then returns a single sample. This enables you to execute a control loop at a specific rate.
If the initialized sample rate is zero, this poly VI immediately returns a single sample.
The samples output returns a single sample from the most recent message received. If no
message has been received since you started the task, the Default Value of the channel is
returned in samples.
You can use error out to determine whether a new message has been received since the
previous call to CAN Read.vi (or CAN Start.vi). If no message has been received, the
warning code 3FF62009 hex is returned in error out. If a new message has been received,
the success code 0 is returned in error out.
To use this type, you must set the initialized mode to Input (not Timestamped Input).
The order of channel entries in samples is the same as the order in the original channel list.
If the initialized sample rate is greater than zero, this poly VI type waits for the next sample
time, then returns a single sample for each channel. This enables you to execute a control loop
at a specific rate.
If the initialized sample rate is zero, this poly VI immediately returns a single sample for
each channel.
The samples output returns a single sample for each channel from the most recent message
received. If no message has been received for a channel since you started the task, the Default
Value of the channel is returned in samples.
You can specify channels in channel list that span multiple messages. A sample from the
most recent message is returned for all channels.
You can use error out to determine whether a new message has been received since the
previous call to CAN Read.vi (or CAN Start.vi). If no message has been received for one or
more channels, the warning code 3FF62009 hex is returned in error out. If a new message
has been received for all channels, the success code 0 is returned in error out.
To use this type, you must set the initialized mode to Input (not Timestamped Input).
Unless an error occurs, number of samples returned is one. The samples array is indexed
by channel, and the entry for each channel contains a single sample.
If you need to determine the number of channels in the task after initialization, get the
Number of Channels property for the task reference.
The initialized sample rate must be greater than zero for this poly VI, because each sample in
the array indicates the value of the CAN channel at a specific point in time. In other words,
the sample rate specifies a virtual clock that copies the most recent value from CAN
messages for each sample time. The changes in sample values from message to message
enable you to view the CAN channel over time, such as for comparison with other CAN or
DAQ input channels.
This VI waits until all samples arrive in time before returning. To avoid internal waiting
within the VI, you can use CAN Get Property.vi to obtain the Number Of Samples
Pending, and pass that as the number of samples to read.
If the initialized sample rate is zero, this poly VI returns an error. If the intent is simply to
read the most recent sample for a task, use the Single-Chan Single-Samp Dbl type.
If no message has been received since you started the task, the Default Value of the channel
is returned in all entries of the samples array.
You can use error out to determine whether a new message has been received since the
previous call to CAN Read.vi (or CAN Start.vi). If no message has been received, the
warning code 3FF62009 hex is returned in error out. If a new message has been received,
the success code 0 is returned in error out.
To use this type, you must set the initialized mode to Input (not Timestamped Input).
Unless an error occurs, the number of samples returned is equal to number of samples to
read.
The order of channel entries in samples is the same as the order in the original channel list.
The initialized sample rate must be greater than zero for this poly VI, because each sample in
the array indicates the value of each CAN channel at a specific point in time. In other words,
the sample rate specifies a virtual clock that copies the most recent value from CAN
messages for each sample time. The changes in sample values from message to message
enable you to view the CAN channels over time, such as for comparison with other CAN
or DAQ input channels.
This VI waits until all samples arrive in time before returning. To avoid internal waiting
within the VI, you can use CAN Get Property.vi to obtain the Number Of Samples
Pending, and pass that as the number of samples to read.
If the initialized sample rate is zero, this poly VI returns an error. If the intent is simply to
read the most recent samples for a task, use the Multi-Chan Single-Samp 1D Dbl type.
If no message has been received for a channel since you started the task, the Default Value of
the channel is returned in samples.
You can specify channels in channel list that span multiple messages. At each point in time,
a sample from the most recent message is returned for all channels.
You can use error out to determine whether a new message has been received since the
previous call to CAN Read.vi (or CAN Start.vi). If no message has been received for one or
more channels, the warning code 3FF62009 hex is returned in error out. If a new message
has been received for all channels, the success code 0 is returned in error out.
To use this type, you must set the initialized mode to Input (not Timestamped Input).
Unless an error occurs, the number of samples returned is equal to number of samples to
read.
If you need to determine the number of channels in the task after initialization, get the
Number of Channels property for the task reference.
The initialized sample rate must be greater than zero for this poly VI, because each sample in
the array indicates the value of the CAN channel at a specific point in time. In other words,
the sample rate specifies a virtual clock that copies the most recent value from CAN
messages for each sample time. The changes in sample values from message to message
enable you to view the CAN channel over time, such as for comparison with other CAN or
DAQ input channels.
This VI waits until all samples arrive in time before returning. To avoid internal waiting
within the VI, you can use CAN Get Property.vi to obtain the Number Of Samples
Pending, and pass that as the number of samples to read.
The start time of a waveform indicates the time of the first CAN sample in the array. The delta
time of the waveform indicates the time between each sample in the array, as determined by
the original sample rate.
If the initialized sample rate is zero, this poly VI returns an error. If the intent is to simply
read the most recent sample for a task, use the Single-Chan Single-Samp Dbl type.
If no message has been received since you started the task, the Default Value of the channel
is returned in all entries of the samples waveform.
You can use error out to determine whether a new message has been received since the
previous call to CAN Read.vi (or CAN Start.vi). If no message has been received, the
warning code 3FF62009 hex is returned in error out. If a new message has been received,
the success code 0 is returned in error out.
To use this type, you must set the initialized mode to Input (not Timestamped Input).
Unless an error occurs, the number of samples returned is equal to number of samples to
read.
The order of channel entries in samples is the same as the order in the original channel list.
The initialized sample rate must be greater than zero for this poly VI, because each sample in
the array of a waveform indicates the value of the CAN channel at a specific point in time. In
other words, the sample rate specifies a virtual clock that copies the most recent value from
CAN messages for each sample time. The changes in sample values from message to message
enable you to view the CAN channel over time, such as for comparison with other CAN or
DAQ input channels.
This VI waits until all samples arrive in time before returning. To avoid internal waiting
within the VI, you can use CAN Get Property.vi to obtain the Number Of Samples
Pending, and pass that as the number of samples to read.
The start time of a waveform indicates the time of the first CAN sample in the array. The delta
time of a waveform indicates the time between each sample in the array, as determined by the
original sample rate.
If the initialized sample rate is zero, this poly VI returns an error. If the intent is simply to
read the most recent samples for a task, use the Multi-Chan Single-Samp 1D Dbl type.
If no message has been received for a channel since you started the task, the Default Value of
the channel is returned in samples.
You can specify channels in channel list that span multiple messages. At each point in time,
a sample from the most recent message is returned for all channels.
You can use error out to determine whether a new message has been received since the
previous call to CAN Read.vi (or CAN Start.vi). If no message has been received for one or
more channels, the warning code 3FF62009 hex is returned in error out. If a new message
has been received for all channels, the success code 0 is returned in error out.
To use this type, you must set the initialized mode to Input (not Timestamped Input).
Unless an error occurs, the number of samples returned is equal to number of samples
to read.
If you need to determine the number of channels in the task after initialization, get the
Number of Channels property for the task reference.
To use this type, you must set the initialized mode to Timestamped Input (not Input).
The Timeout property determines whether this VI will wait for the number of samples to
read messages to arrive from the network. The default value of Timeout is zero, but you can
change it using CAN Set Property.vi.
If Timeout is greater than zero, the VI will wait for number of samples to read messages to
arrive. If number of samples to read messages are not received before the Timeout expires,
an error is returned. Timeout is specified as milliseconds.
If Timeout is zero, the VI will not wait for messages, but instead returns samples from the
messages received since the previous call to CAN Read.vi. The number of samples returned
is indicated in the number of samples returned output, up to a maximum of number of
samples to read messages. If no new message has been received, number of samples
returned is 0, and error out indicates success.
Because the timing of values in samples is determined by when the message is received,
the sample rate input is not used with this poly VI type.
The order of channel entries in samples is the same as the order in the original channel list.
To use this type, you must set the initialized mode to Timestamped Input (not Input).
You cannot specify channels in channel list that span multiple messages.
The Timeout property determines whether this VI waits for the number of samples to read
messages to arrive from the network. The default value of Timeout is zero, but you can
change it using CAN Set Property.vi.
If Timeout is greater than zero, the VI will wait for number of samples to read messages to
arrive. If number of samples to read messages are not received before the Timeout expires,
an error is returned. Timeout is specified as milliseconds.
If Timeout is zero, the VI will not wait for messages, but instead returns samples from the
messages received since the previous call to CAN Read.vi. The number of samples returned
is indicated in the number of samples returned output, up to a maximum of number of
samples to read messages. If no new message has been received, number of samples
returned is 0, and error out indicates success.
Because the timing of values in samples is determined by when the message is received,
the sample rate input is not used with this poly VI type.
If you need to determine the number of channels in the task after initialization, get the
Number of Channels property for the task reference.
Purpose
Set a property for the task, or a single channel within the task. The poly VI selection
determines the property to set.
To select the property, right-click the VI, go to Select Type and select the property by name.
For LabVIEW 7.0 and later, you can right-click the VI and select Visible Items»Poly VI
Selector to select the property from within the diagram.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from VIs such as CAN Initialize.vi or
CAN Create Message.vi, and then wired through subsequent VIs.
channel name specifies an individual channel within the task. The default
(unwired) value of channel name is empty, which means that the property
applies to the entire task, not a specific channel.
Properties that begin with the word Channel or Message do not apply to the
entire task, but an individual channel or message within the task. For these
channel-specific properties, you must wire the name of a channel from
channel list into the channel name input.
For properties that do not begin with the word Channel or Message,
you must leave channel name unwired (empty).
The poly input value specifies the property value. You select the property
to set as value by selecting the Poly VI type. The data type of value is also
determined by the Poly VI selection. For information on the different
properties provided by CAN Get Property.vi, refer to the Poly VI Types
section in this function reference.
To select the property, right-click the VI, go to Select Type and select the
property by name.Error in describes error conditions occurring before the
VI executes. If an error has already occurred, the VI returns the value of the
Error in cluster in Error out.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
Description
You cannot set a property while the task is running. If you need to change a property prior to
starting the task, you cannot use CAN Init Start.vi. First, call CAN Initialize.vi, followed by
CAN Set Property.vi and then CAN Start.vi. After you start the task, you also can change
a property by calling CAN Stop.vi, followed by CAN Set Property.vi, and then CAN
Start.vi again.
Poly VI Types
Behavior After Final Output
The Behavior After Final Output property applies only to tasks initialized
with mode of Output, and sample rate greater than zero. The value
specifies the behavior to perform after the final periodic sample is
transmitted.
Transmit messages for the final sample(s) repeatedly. The final messages
are transmitted periodically as specified by sample rate.
Repeat Final Sample is the default value of the Behavior After Final
Output property.
Cease Transmit
For information on how the Channel Default Value is used, refer to CAN
Read.vi and CAN Write.vi.
The value of this property is originally set within MAX. If the channel is
initialized directly from a CAN database, the value is 0.0 by default, but it
can be changed using CAN Set Property.vi.
Sets the rate (in MHz) of the external clock that is exported to the CAN
card.
10 MHz (10 The master timebase rate should be set to 10 MHz when
decimal) synchronizing a CAN card with an M-Series DAQ card.
The M-Series DAQ card can export a 20 MHz clock but
it does this by using one of its two counters.
If your CAN-DAQ application does not use the 2 DAQ counters then, you
can leave the timebase rate set to 20 MHz (default).
This property can be set either before or after calling CAN Connect
Terminals.vi to connect the RTSI_CLK to Master Timebase. However,
this property must always be called prior to starting the task.
This property is applicable only to PCI and PXI Series 2 cards. For
PCMCIA cards, setting this attribute will return an error. On PXI cards, if
PXI_CLK10 is routed to the Master Timebase, then the rate is fixed at
10 MHz (it over-rides any previous setting of this property). Setting this
property for Series 1 cards will also result in a NI-CAN error.
Sets the format of the timestamps reported by the on-board timer on the
CAN card. The default value for this property is Absolute.
A typical use case for this property would be if data received from two
RTSI synchronized CAN cards is to be correlated. For that use case, this
property must be set to 1 for all of the CAN cards being synchronized.
Setting this property on one port of a 2-port card will also reset the
timestamp of the second port, since resetting the timestamp on the CAN
port involves resetting the on-board timer.
This property should be set prior to starting any tasks on the CAN card.
You can specify the following basic baud rates as the numeric rate: 33333,
83333, 100000, 125000, 200000, 250000, 400000, 500000, 800000, and
1000000.You can specify advanced baud rates as 8000XXYY hex, where YY
is the value of Bit Timing Register 0 (BTR0), and XX is the value of Bit
Timing Register 1 (BTR1) of the CAN controller. For more information,
refer to the Interface Properties dialog in MAX.
Sets a Boolean value that indicates whether the listen only feature of the
Philips SJA1000 CAN controller is enabled (TRUE) or disabled (FALSE).
Since the listen only feature requires the Philips SJA1000 CAN controller,
this property is supported on Series 2 NI CAN hardware only. If you are
For self reception to operate properly, another CAN node must receive and
acknowledge each transmit.
FALSE disables self reception mode (default), and TRUE enables self
reception mode.
The self reception mode is not available on the Intel 82527 CAN controller
used by Series 1 CAN hardware. For Series 1 hardware, this property must
be left at its default (FALSE).
Specifies the filter comparator for the Philips SJA1000 CAN controller on
all Series 2 CAN hardware. This property is not supported for Series 1
hardware (returns error).
This property specifies a comparator value that is checked against the ID,
RTR, and data bits. The Interface Series 2 Mask determines the applicable
bits for comparison.
The mapping of bits in this property to the ID, RTR, and data bits of
incoming frames is determined by the value of the Interface Series 2 Filter
Mode property. The Series 2 filter mode determines the format of this
property as well as the Series 2 mask.
All Series 2 hardware uses the Philips SJA1000 CAN controller. The
Philips SJA1000 CAN controller provides sophisticated filtering of
received frames. This property specifies the filtering mode, which is used
in conjunction with the Interface Series 2 Mask and Interface Series 2
Comparator properties.
Since the format of the Series 2 filters is very specific to the Philips
SJA1000 CAN controller, National Instruments cannot guarantee
compatibility for this property on future hardware series. When using this
property in the application, it is best to get the Hardware Series property
to verify that the CAN hardware is Series 2.
The filtering specified by the Series 2 filter properties applies to all input
tasks for that interface. For example, if you specify filters that discard ID 5,
then open an Input task to receive channels of ID 5, the task will not receive
data.
The values for this property are summarized below. For detailed
information on each value, including the format of the Interface Series 2
Mask and Interface Series 2 Comparator properties for each mode, refer to
the Series 2 Filter Mode attribute in the ncSetAttr.vi function of the
Frame API.
Single Standard
Single Extended
Dual Standard
Dual Extended
Specifies the filter mask for the Philips SJA1000 CAN controller on all
Series 2 CAN hardware. This property is not supported for Series 1
hardware (returns error).
This property specifies a bit mask that determines the ID, RTR, and data
bits that are compared. If a bit is clear in the mask, the corresponding bit in
The default value of this property is hex FFFFFFFF, which means that all
messages are received.
The mapping of bits in this property to the ID, RTR, and data bits of
incoming frames is determined by the value of the Interface Series 2 Filter
Mode property. The Series 2 filter mode determines the format of this
property as well as the Series 2 comparator.
The single-shot transmit feature is not available on the Intel 82527 CAN
controller used by Series 1 CAN hardware (set returns error).
Sets the transceiver external outputs for the interface that was initialized for
the task.
For many models of CAN transceiver, EN and NSTB pins control the
transceiver mode, such as whether the transceiver is sleeping or
communicating normally. For such transceivers, you can wire the EN and
NSTB pins to the MODE0 and MODE1 pins of the CAN port.
The default value of this property is 00000003 hex. For many models of
transceiver, this specifies normal communication mode for the transceiver
and CAN controller chip. If the transceiver requires a different
MODE0/MODE1 combination for normal mode, you can use external
inverters to change the default 5 V to 0 V.
This property is supported for Series 2 XS cards only. This property is not
supported when the Interface Transceiver Type is any value other than
External. To control the mode of an internal transceiver, use the Interface
Transceiver Mode property.
This property uses a bit mask. Use bitwise OR operations to set multiple
values.
00000001 hex MODE0
Set this bit to drive 5 V on the MODE0 pin. This is the default
value. This bit is set automatically when a remote wakeup is
detected.
Clear this bit to drive 0 V on the MODE0 pin.
00000002 hex MODE1
Set this bit to drive 5 V on the MODE1 pin. This is the default
value. This bit is set automatically when a remote wakeup is
detected.
Clear this bit to drive 0 V on the MODE1 pin.
00000100 hex Sleep CAN controller chip
Set this bit to place the CAN controller chip into sleep mode. This
bit controls the mode of the CAN controller chip (sleep or
normal), and the independent MODE0/MODE1 bits control the
mode of the external transceiver. When you set this bit to place the
CAN controller into sleep mode, you typically specify
MODE0/MODE1 bits that place the external transceiver into sleep
mode as well.
When the CAN controller is asleep, a remote wakeup will
automatically place the CAN controller into its normal mode of
communication. In addition, the MODE0/MODE1 pins are
restored to their default values of 5 V. Therefore, a remote wakeup
causes this property to change from the value that you set for sleep
mode, back to its default 00000003 hex. You can determine when
this has occurred by getting Interface Transceiver External
Outputs using CAN Get Property.vi. For more information on
remote wakeup, refer to the Interface Transceiver Mode
property for internal transceivers.
Clear this bit to place the CAN controller chip into normal
communication mode. If the CAN controller was previously in
sleep mode, this performs a local wakeup to restore
communication.
Sets the transceiver mode for the interface that was initialized for the task.
The transceiver mode controls whether the transceiver is asleep or
communicating, as well as other special modes.
For Series 2 cards for the PCMCIA form factor, this property requires a
corresponding Series 2 cable (dongle). For information on how to identify
the series of the PCMCIA cable, refer to the Series 2 Vs. Series 1 section of
Chapter 1, Introduction.
For Series 2 XS cards, this property is not supported when the Interface
Transceiver Type is External. To control the mode of an external
transceiver, use the Interface Transceiver External Outputs property.
Normal
Sleep
Set transceiver and the CAN controller chip to sleep (or standby) mode.
You can set Sleep mode only while the interface is communicating. If at
least one task for the interface has not been started (such as with CAN
Start.vi), setting the transceiver mode to Sleep will return an error.
When the interface enters sleep mode, communication is not possible until
a wakeup occurs. All pending frame transmissions are deferred until the
wakeup occurs. The transceiver and CAN controller wake from sleep mode
when either a local wakeup or remote wakeup occurs.
If you set Sleep mode when the CAN controller is actively transmitting a
frame (that is, won arbitration), the interface will not enter Sleep mode until
the frame is transmitted successfully (acknowledgement detected).
A local wakeup occurs when the application sets the transceiver mode to
Normal (or some other communication mode).
For a remote wakeup to occur for Single Wire transceivers, the node that
transmits the wakeup frame must first place the network into the Single
Wire Wakeup Transmission mode by asserting a higher voltage
(typically 12 V). For more information, refer to the Single Wire Wakeup
mode.
When the local or remote wakeup occurs, frame transmissions resume from
the point at which the original Sleep was set.
You can detect when a remote wakeup occurs by using CAN Get
Property.vi with the Interface Transceiver Mode property.
The Single Wire transceiver does not support use of this mode in
conjunction with Sleep mode. For example, a remote wakeup cannot
transition from Sleep to this Single Wire High-Speed mode.
The default value for this property is specified within MAX. If you change
the transceiver type in MAX to correspond to the network in use, you can
avoid setting this property within the application.
This property applies to all tasks initialized with the same interface.
You cannot set this property for Series 1 hardware, or for Series 2 hardware
other than XS (fixed HS, LS, or SW cards).
High-Speed
Low-Speed/Fault-Tolerant
Single Wire
External
When this transceiver type is selected, you can use the Transceiver
External Outputs and Transceiver External Inputs properties to access
the external mode and status pins of the connector.
Disconnect
Disconnect the CAN controller chip from the connector. This value is used
when you physically switch an external transceiver. You first set Interface
Transceiver Type to Disconnect, then switch from one external
transceiver to another, then set Interface Transceiver Type to External.
For more information on connecting transceivers externally, refer to
Chapter 3, NI CAN and LIN Hardware.
Virtual Bus Timing has to be set to the same value on both virtual
interfaces. This property must be set prior to starting the virtual interface.
Refer to the Frame to Channel Conversion section of Chapter 6, Using the
Channel API for more information.
Timeout
Sets a time in milliseconds to wait for samples. The default value is zero.
For all task configurations, the Timeout specifies the time that Read will
wait for the start trigger. If the application does not use CAN Connect
Terminals, the start trigger occurs when the task starts (CAN Start). If you
connect a start trigger from a RTSI line or other source, Timeout specifies
the number of milliseconds to wait. Timeout of zero means to wait up to
10 seconds for the start trigger.
Use of the Timeout property depends on the initialized mode of the task:
• Output— For each Output task, NI-CAN uses a buffer to store
samples for transmit. If the number of samples that you provide to
CAN Write.vi exceeds the size of the underlying buffer, NI-CAN
waits for sufficient space to become available (due to successful
transmits). The Timeout specifies the number of milliseconds to wait
for available buffer space. Timeout of zero means to wait up to
10 seconds.
• Input— The timeout value does not apply. For Input tasks initialized
with sample rate greater than zero, the number of samples to read
input to CAN Read.vi implicitly specifies the time to wait. For Input
tasks initialized with sample rate equal to zero, the CAN Read.vi VI
always returns available samples immediately, without waiting.
• Timestamped Input— A timeout of zero means to return available
samples immediately. A timeout greater than zero means that CAN
Read.vi will wait a maximum of Timeout milliseconds for number of
samples to read samples to become available before returning.
• Output Recent— The timeout value does not apply.
Sets the value that is returned on time stamped read for mode dependent
channels that have not been received with the most recent CAN frame
associated with the CAN message. This property applies only to mode
dependent channels that are read with the time stamped read operation.
For more information, refer to the Mode Dependent Channels section of
Chapter 6, Using the Channel API.
CAN Start.vi
Purpose
Start communication for the specified task.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from VIs such as CAN Initialize.vi or
CAN Create Message.vi, and then wired through subsequent VIs.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
Description
You must start communication for a task to use CAN Read.vi or CAN Write.vi. After you
start communication, you can no longer change the configuration of the task with CAN Set
Property.vi or CAN Connect Terminals.vi.
CAN Stop.vi
Purpose
Stop communication for the specified task.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi, and then wired through
subsequent VIs.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
Description
This VI stops communication so that you can change the configuration of the task, such as by
using CAN Set Property.vi or CAN Connect Terminals.vi. After you change the
configuration, use CAN Start.vi to start again.
This VI does not clear the configuration for the task; therefore, do not use it as the last
NI-CAN VI in the application. CAN Clear.vi must always be the last NI-CAN VI for each
task.
Purpose
Synchronize and start the specified CAN task and NI-DAQ task.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from VIs such as CAN Initialize.vi or
CAN Create Message.vi.
When this VI returns, do not call an NI-DAQ start VI for the task. The
LabVIEW diagram of this VI starts the NI-DAQ task ID for you, so you
can immediately call NI-DAQ read or write VIs.
RTSI terminal specifies the RTSI terminal number to use for the shared
start trigger. This input uses a ring typedef to select terminals from RTSI0
to RTSI6.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent NI-CAN VIs for this task.
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
status is True if an error occurred.
code is the error code number identifying an error. A value of 0
means success. A negative value means error: VI did not execute
the intended operation. A positive value means warning: VI
executed intended operation, but an informational warning is
returned. For a description of the code, wire the error cluster to a
LabVIEW error-handling VI, such as the Simple Error Handler.
source identifies the VI where the error occurred.
Description
The CAN and NI-DAQ task execute on different NI hardware products. To use the
input/output samples of these tasks together in the application, the NI hardware products must
be synchronized with RTSI terminal connections. Both NI hardware products must use a
common timebase to avoid clock drift, and a common start trigger to start input/output at the
same time.
This VI uses NI-CAN and NI-DAQ RTSI functions to synchronize the NI hardware products
to a common timebase and start trigger, and then it starts sampling on both tasks. The function
used to connect RTSI terminals on the CAN card is CAN Connect Terminals.vi.
When you use this VI to start the tasks, you must use CAN Clear with NI-DAQ.vi to clear
the tasks.
This VI synchronizes a single CAN hardware product to a single NI-DAQ hardware product.
To synchronize multiple CAN cards and/or multiple NI-DAQ cards, refer to CAN Sync Start
Multiple with NI-DAQ.vi.
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so that you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of the
VI for editing.
The diagram of this VI assumes that the NI-DAQ product is an E Series MIO device. If you
are using a different NI hardware product, refer to the diagram as a starting point.
The diagram of this VI issues the start trigger immediately. To implement more complex
triggering, such as using an AI trigger to start, refer to the diagram as a starting point.
Purpose
Synchronize and start the specified CAN task and NI-DAQmx task.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI. The
task reference is originally returned from VIs such as CAN Initialize.vi or
CAN Create Message.vi.
RTSI terminal specifies the RTSI terminal number to use for the shared
start trigger. This input uses a ring typedef to select terminals from RTSI0
to RTSI6.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent NI-CAN VIs for this task.
Description
The CAN and NI-DAQmx tasks execute on different NI hardware products. To use the
input/output samples of these tasks together in the application, the NI hardware products must
be synchronized with RTSI terminal connections. Both NI hardware products must use a
common timebase to avoid clock drift, and a common start trigger to start input/output at the
same time.
This VI uses NI-CAN and NI-DAQmx RTSI functions to synchronize the NI hardware
products to a common timebase and start trigger, and then it starts sampling on both tasks.
The function used to connect RTSI terminals on the CAN card is CAN Connect
Terminals.vi.
When you use this VI to start the tasks, you must use CAN Clear with NI-DAQmx.vi to clear
the tasks.
This VI synchronizes a single CAN hardware product to a single NI-DAQ hardware product.
To synchronize multiple CAN cards and/or multiple NI-DAQ cards, refer to CAN Sync Start
with NI-DAQmx.vi.
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so that you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of the
VI for editing.
This VI is designed to support most E Series MIO devices and M Series MIO devices through
NI-DAQmx. If you are using a different NI hardware product, refer to the diagram as a starting
point.
The diagram of this VI issues the start trigger immediately. To implement more complex
triggering, such as using an AI trigger to start, refer to the diagram as a starting point.
Purpose
Synchronize and start the specified list of multiple CAN tasks and a single NI-DAQ task.
This is a more complex implementation of CAN Sync Start with NI-DAQ.vi that supports
multiple CAN hardware products.
Format
Inputs
CAN task reference list in is an array of NI-CAN task references. Each
task reference is originally returned from VIs such as CAN Initialize.vi or
CAN Create Message.vi. You can build the task references into an array
using the LabVIEW Build Array VI.
RTSI terminal specifies the RTSI terminal number to use for the shared
start trigger. This input uses a ring typedef to select terminals from RTSI0
to RTSI6.
Outputs
CAN task reference list out is the same as CAN task reference list in.
Description
The CAN and NI-DAQ tasks execute on different NI hardware products. To use the
input/output samples of these tasks together in the application, the NI hardware products must
be synchronized with RTSI terminal connections. Both NI hardware products must use a
common timebase to avoid clock drift, and a common start trigger to start input/output at the
same time.
This VI uses NI-CAN and NI-DAQ RTSI functions to synchronize the NI hardware products
to a common timebase and start trigger, and then it starts sampling on all tasks. The function
used to connect RTSI terminals on the CAN card is CAN Connect Terminals.vi.
When you use this VI to start the tasks, you must use CAN Clear Multiple with NI-DAQ.vi
to clear the tasks.
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so that you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of the
VI for editing.
This VI does not demonstrate synchronization of multiple NI-DAQ hardware products. Refer
to NI-DAQ for examples of synchronizing the timebase and trigger of multiple DAQ cards.
The diagram of this VI assumes that all NI-DAQ products are E Series MIO devices. If you
are using a different NI hardware product, refer to the diagram as a starting point.
The diagram of this VI issues the start trigger immediately. To implement more complex
triggering, such as using an AI trigger to start, refer to the diagram as a starting point.
Purpose
Synchronize and start the specified list of multiple CAN tasks and a single NI-DAQmx task.
This is a more complex implementation of CAN Sync Start with NI-DAQmx.vi that
supports multiple CAN hardware products.
Format
Inputs
CAN task reference list in is an array of NI-CAN task references. Each
task reference is originally returned from VIs such as CAN Initialize.vi or
CAN Create Message.vi. You can build the task references into an array
using the LabVIEW Build Array VI.
RTSI terminal specifies the RTSI terminal number to use for the shared
start trigger. This input uses a ring typedef to select terminals from RTSI0
to RTSI6.
Outputs
CAN task reference list out is the same as CAN task reference list in.
Description
The CAN and NI-DAQmx tasks execute on different NI hardware products. To use the
input/output samples of these tasks together in the application, the NI hardware products must
be synchronized with RTSI terminal connections. Both NI hardware products must use a
common timebase to avoid clock drift, and a common start trigger to start input/output at the
same time.
This VI uses NI-CAN and NI-DAQmx RTSI functions to synchronize the NI hardware
products to a common timebase and start trigger, and then it starts sampling on all tasks. The
function used to connect RTSI terminals on the CAN card is CAN Connect Terminals.vi.
When you use this VI to start the tasks, you must use CAN Clear Multiple with
NI-DAQmx.vi to clear the tasks.
This VI is intended to serve as an example. You can use the VI as is, but the LabVIEW
diagram is commented so that you can use the VI as a starting point for more complex
synchronization scenarios. Before you customize the LabVIEW diagram, save a copy of the
VI for editing.
This VI is designed to support most E Series MIO devices and M Series MIO devices through
NI-DAQmx. If you are using a different NI hardware product, refer to the diagram as a starting
point.
The diagram of this VI issues the start trigger immediately. To implement more complex
triggering, such as using an AI trigger to start, refer to the diagram as a starting point.
CAN Write.vi
Purpose
Write samples to a CAN task initialized as Output (refer to the mode parameter of CAN Init
Start.vi). Samples are placed into transmitted CAN messages. The poly VI selection
determines the data type to write.
To select the data type, right-click the VI, go to Select Type, and select the type by name.
For LabVIEW 7.0 and later, you can right-click the VI and select Visible Items»Poly VI
Selector to select the data type from within the diagram.
For an overview of CAN Write, refer to the Write section of Chapter 6, Using the Channel
API.
Format
Inputs
task reference in is the task reference from the previous NI-CAN VI.
The task reference is originally returned from CAN Init Start.vi, CAN
Initialize.vi, or CAN Create Message.vi, and then wired through
subsequent VIs.
To select the data type, right-click the VI, go to Select Type, and select the
type by name.
Outputs
task reference out is the same as task reference in. Wire the task reference
to subsequent VIs for this task.
Poly VI Types
The name of each Poly VI type uses the following conventions:
• The first term is either Single-Chan or Multi-Chan. This indicates whether the type
specifies data for a single channel or multiple channels. Multi-Chan types specify an
array of analogous Single-Chan types, one entry for each channel initialized in channel
list of CAN Init Start.vi. Single-Chan types are convenient because no array indexing
is required, but you are limited to writing only one CAN channel.
• The second term is either Single-Samp or Multi-Samp. This indicates whether the type
specifies a single sample, or an array of multiple samples. Single-Samp types are often
used for single-point control applications, such as within LabVIEW RT. Single-Samp
types are required for the Output Recent mode.
• The third term indicates the data type used for each sample. The word Dbl indicates
double-precision (64-bit) floating point. The word Wfm indicates the waveform data type.
The words 1D and 2D indicate one and two-dimensional arrays, respectively.
You can use this type with Output mode or Output Recent mode.
If the initialized sample rate is greater than zero, the task transmits a CAN message
periodically at the specified rate. The first CAN Write.vi transmits a message immediately,
and then begins a periodic timer at the specified rate. Each subsequent message transmission
is based on the timer, and uses the most recent sample provided by CAN Write.vi.
If the initialized sample rate is zero, the message is transmitted immediately each time you
call CAN Write.vi.
Because all channels of a message are transmitted on the network as a unit, CAN Write.vi
enforces the following rules:
• You cannot write the same message in more than one Output task.
• You can write more than one message in a single Output task.
• You can write a subset of channels for a message in a single Output task. For channels
that are not included in the task, the Default Value is transmitted in the CAN message.
Because this Poly VI writes only one channel, the Default Value will always be used for
any remaining channels in the associated message.
For many applications, the most straightforward technique is to assign a single task for each
message you want to transmit. In each task, include all channels of that message in the
channel list. This ensures that you can provide new samples for the entire message with each
CAN Write.vi.
You can use this type with Output mode or Output Recent mode.
The messages transmitted by CAN Write.vi are determined by the associated channel list.
If all channels are contained in a single message, only that message is transmitted. If a few
channels are contained in one message, and the remaining channels are contained in a second
message, two messages are transmitted.
If the initialized sample rate is greater than zero, the task transmits associated CAN messages
periodically at the specified rate. The first CAN Write.vi transmits messages immediately,
and then begins a periodic timer at the specified rate. Each subsequent transmission of
messages is based on the timer and uses the most recent samples provided by CAN Write.vi.
If the initialized sample rate is zero, the messages are transmitted immediately each time you
call CAN Write.vi.
Because all channels of a message are transmitted on the network as a unit, CAN Write.vi
enforces the following rules:
• You cannot write the same message in more than one task.
• You can write more than one message in a single task.
• You can write a subset of channels for a message in a single task. For channels that are
not included in the task, the Default Value is transmitted in the CAN message.
For many applications, the most straightforward technique is to assign a single task for each
message that you want to transmit. In each task, include all channels of that message in the
channel list. This ensures that you can provide new samples for the entire message with each
CAN Write.vi.
You can use this type with Output mode only (not Output Recent mode).
If the initialized sample rate is greater than zero, the task transmits a CAN message
periodically at the specified rate. This Poly VI is used to transmit a sequence of messages
periodically, with a unique sample value in each message. The first CAN Write.vi transmits
a message immediately using the first sample in the array, and then begins a periodic timer at
the specified rate. Each subsequent message transmission is based on the timer, and uses the
next sample in the array. After the final sample in the array has been transmitted, subsequent
behavior is determined by the Behavior After Final Output property. The default Behavior
After Final Output is to retransmit the final sample each period until CAN Write.vi is called
again.
If the initialized sample rate is zero, a message is transmitted immediately for each entry in
the array, with as little delay as possible between messages. After the message for the final
sample is transmitted, no further transmissions occur until CAN Write.vi is called again,
regardless of the Behavior After Final Output property.
Because all channels of a message are transmitted on the network as a unit, CAN Write.vi
enforces the following rules:
• You cannot write the same message in more than one task.
• You can write more than one message in a single task.
• You can write a subset of channels for a message in a single task. For channels that are
not included in the task, the Default Value is transmitted in the CAN message. Because
this Poly VI writes only one channel, the Default Value will always be used for any
remaining channels in the associated message.
For many applications, the most straightforward technique is to assign a single task for each
message that you want to transmit. In each task, include all channels of that message in the
channel list. This ensures that you can provide new samples for the entire message with each
CAN Write.vi.
You can use this type with Output mode only (not Output Recent mode).
The messages transmitted by CAN Write.vi are determined by the associated channel list.
If all channels are contained in a single message, only that message is transmitted. If a few
channels are contained in one message, and the remaining channels are contained in a second
message, two messages are transmitted.
If the initialized sample rate is greater than zero, the task transmits associated CAN messages
periodically at the specified rate. This Poly VI is used to transmit a sequence of messages
periodically, with unique sample values in each set of messages. The first CAN Write.vi
transmits associated messages immediately using the first sample in the array of each channel,
and then begins a periodic timer at the specified rate. Each subsequent transmission of
messages is based on the timer, and uses the next sample in the array of each channel. After
the final sample in the array of each channel has been transmitted, subsequent behavior is
determined by the Behavior After Final Output property. The default Behavior After Final
Output is to retransmit the final sample each period until CAN Write.vi is called again.
If the initialized sample rate is zero, the task transmits associated messages immediately for
each entry in the array of each channel, with as little delay as possible between messages.
After the message for the final sample is transmitted, no further transmissions occur until
CAN Write.vi is called again, regardless of the Behavior After Final Output property.
Because all channels of a message are transmitted on the network as a unit, CAN Write.vi
enforces the following rules:
• You cannot write the same message in more than one task.
• You can write more than one message in a single task.
• You can write a subset of channels for a message in a single task. For channels that are
not included in the task, the Default Value is transmitted in the CAN message.
For many applications, the most straightforward technique is to assign a single task for each
message that you want to transmit. In each task, include all channels of that message in the
channel list. This ensures that you can provide new samples for the entire message with each
CAN Write.vi.
The start time and delta time of the waveform does not affect the beginning of message
transmission. Therefore, this Poly VI type is equivalent to the Single-Chan Multi-Samp 1D
Dbl Poly VI type.
The start time and delta time of each waveform does not affect the beginning of message
transmission. Therefore, this Poly VI type is equivalent to the Multi-Chan Multi-Samp 2D
Dbl Poly VI type.
Unless otherwise stated, each NI-CAN function suspends execution of the calling thread until
it completes. The functions in this chapter are listed alphabetically.
Section Headings
The following are section headings found in the Channel API for C functions.
Purpose
Each function description includes a brief statement of the purpose of the function.
Format
The format section describes the format of each function for the C programming language.
Description
The description section gives details about the purpose and effect of each function.
Data Types
The following data types are used with functions of the NI-CAN Channel API for C.
List of Functions
Table 8-1 contains an alphabetical list of the NI-CAN Channel API for C functions.
Function Purpose
nctClear Stops communication for the task and then clears the
configuration.
nctConnectTerminals Connects terminals in the CAN hardware.
nctCreateMessage Creates a message configuration and associated
channel configurations within the application.
Function Purpose
nctCreateMessageEx Creates a message configuration and associated
channel configurations within the application.
nctCreateMessageEx allows you to create normal
CAN channels and mode dependent channels. For more
information about mode dependent channels, refer to
the Mode Dependent Channels section of Chapter 6,
Using the Channel API.
nctDisconnectTerminals Disconnects terminals in the CAN hardware.
nctGetNames Gets an array of CAN channel names or message names
from MAX or a CAN database file.
nctGetNamesLength Gets the required size for a specified list of channels to
allocate an array for the ChannelList input of
nctGetNames.
nctClear
Purpose
Stops communication for the task and then clears the configuration.
Format
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
The nctClear function must always be the final NI-CAN function called for each task.
If you do not use the nctClear function, the remaining task configurations can cause
problems in execution of subsequent NI-CAN applications.
If the cleared task is the last running task for the initialized Interface (refer to
nctInitStart for more information), the nctClear function also stops communication on
the CAN controller of the interface and disconnects all terminal connections for that interface.
Because this function clears the task, TaskRef cannot be used with subsequent functions.
To change the properties of a running task, use nctStop to stop the task, nctSetProperty
to change the desired property, and then nctStart to restart the task.
nctConnectTerminals
Purpose
Connects terminals in the CAN hardware.
Format
nctTypeStatus nctConnectTerminals(
nctTypeTaskRef TaskRef,
u32 SourceTerminal,
u32 DestinationTerminal,
u32 Modifiers);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
SourceTerminal
Specifies the connection source.
Once the connection is successfully created, behavior flows from
SourceTerminal to DestinationTerminal.
For a list of valid source/destination pairs, refer to the Valid
Combinations of Source/Destination section in this function reference.
The following list describes each value of SourceTerminal:
nctSrcTermRTSI0... nctSrcTermRTSI6
Selects a general-purpose RTSI line as source (input) of the
connection.
nctSrcTermRTSI_Clock
Selects the RTSI clock line as source (input) of the
connection. This terminal is also RTSI line 7. RTSI7 is
dedicated for routing of a timebase (10 MHz or 20 MHz)
The only valid DestinationTerminal for this source is
nctDestTermMasterTimebase.
DestinationTerminal
Specifies the destination of the connection.
The following list describes each value of DestinationTerminal:
nctDestTermRTSI0... nctDestTermRTSI6
Selects a general-purpose RTSI line as destination (output) of
the connection.
nctDestTermRTSI_Clock
Selects the RTSI clock line as destination (output) of the
connection. This terminal is also RTSI line 7. RTSI7 is
dedicated for routing of a timebase. The CAN card can import
a 10 MHz or 20 MHz timebase, but can only export a 20 MHz
timebase. The only valid SourceTerminal for this source is
nctSrcTerm20MHzTimebase.
This value applies to Series 2 CAN cards only. If you are
using a Series 1 CAN card, selecting this value results in an
error.
nctDestTermMasterTimebase
nctDestTermMasterTimebase instructs the CAN card to
use the source of the connection as the master timebase.
The CAN card uses this master timebase for input sampling
(including timestamps of received messages) as well as
periodic output sampling.
For PCI and PXI form factors, you can use
nctSrcTermRTSI_Clock as the SourceTerminal. By
default this receives a 20 MHz timebase from another CAN
or DAQ card. For example, you can synchronize a CAN and
DAQ E Series MIO card by connecting the 20 MHz oscillator
(board clock) of the DAQ card to RTSI Clock (RTSI7),
and then connecting nctSrcTermRTSI_Clock to
nctDestTermMasterTimebase on the CAN card. To
change the Master Timebase Rate to 10 MHz, use
nctSetProperty to change the
nctPropHwMasterTimebaseRate.
For PXI form factor, you also can use
nctSrcTermPXI_Clk10 as the SourceTerminal. This
receives the PXI 10 MHz backplane clock for use as the
master timebase.
For PCMCIA form factor, you can use
nctSrcTermRTSI_Clock as the SourceTerminal. Unlike
PCI and PXI, the PCMCIA CAN card requires a 10 MHz
Modifiers
Provides optional connection information for certain
source/destination pairs. The current release of NI-CAN does not use
this information for any source/destination pair, so you must pass
Modifiers as zero.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
This VI connects a specific pair of source/destination terminals. One of the terminals is
typically a RTSI signal, and the other terminal is an internal terminal in the CAN hardware.
By connecting internal terminals to RTSI, you can synchronize the CAN card with another
hardware product such as an NI-DAQ or NI-DAQmx card.
The most common uses of RTSI synchronization are demonstrated by the CAN/DAQ
programming examples.
When the final task for a given interface is cleared with nctClear, NI-CAN disconnects all
terminal connections for that interface. Therefore, the nctDisconnectTerminals function
is not required for most applications. NI-DAQ and NI-DAQmx terminals remain connected
after the tasks are cleared, so you must disconnect NI-DAQ/NI-DAQmx terminals manually
at the end of the application.
• For CAN cards with one or more Low-Speed (LS) ports, two RTSI signals are available
for input (source), and three RTSI signals are available for output (destination).
Destination
10 Hz
RTSI0 to Master Resync Start
Source RTSI6 RTSI_Clock Timebase Clock Trigger
RTSI0 to — — — 1, 2 1, 2
RTSI6
RTSI_Clock — — 2 — —
PXI_Star — — — — 2
PXI_Clk10 — — 2 — —
20 MHz — 2 — — —
Timebase
10 Hz Resync 1, 2 — — — 1, 2
Clock
Interface 2 — — — 2
Receive
Event
Destination
10 Hz
RTSI0 to Master Resync Start
Source RTSI6 RTSI_Clock Timebase Clock Trigger
Interface 2 — — — —
Transceiver
Event
Start Trigger 1, 2 — — — —
nctCreateMessage
Purpose
Creates a message configuration and associated channel configurations within the
application.
Format
nctTypeStatus nctCreateMessage(
nctTypeMessageConfig MessageConfig,
u32 NumberOfChannels,
nctTypeChannelConfig *ChannelConfigList,
i32 Interface,
i32 Mode,
f64 SampleRate,
nctTypeTaskRef *TaskRef)
Inputs
MessageConfig
Configures properties for a new message. This function creates a task
for a single message with one or more channels. You provide the
properties in a C struct.
The properties are similar to the message properties in MAX:
u32 MsgArbitrationID
Configures the arbitration ID of the message.
Use the Extended Boolean to specify whether the ID is
standard (11-bit) or extended (29-bit).
u32 Extended
Configures a Boolean value that indicates whether the
message arbitration ID is standard 11-bit format (0) or
extended 29-bit format (1).
u32 MsgDataBytes
Configures the number of data bytes in the message.
The range is 0 to 8.
NumberOfChannels
Specifies the number of channel configurations you provide in
ChannelConfigList.
ChannelConfigList
Configures the list of channels for the new message.
ChannelConfigList is an array of a C struct, with one C struct
for each channel.
The properties of each channel are similar to the channel properties in
MAX:
u32 StartBit
Configures the starting bit position in the message. The range
is 0 (lowest bit in first byte), to 63 (highest bit in last byte).
u32 NumBits
Configures the number of bits in the message. The range
is 1 to 64.
u32 DataType
Configures the data type of the channel in the message.
Values are nctDataSigned, nctDataUnsigned, and
nctDataFloat.
u32 ByteOrder
Configures the byte order of the channel in the message.
Values are nctOrderIntel (little-endian), and
nctOrderMotorola (big-endian).
f64 ScalingFactor
Configures the scaling factor used to convert raw bits of the
message to/from scaled floating-point units. The scaling
factor is the A in the linear scaling formula AX+B, where X is
the raw data, and B is the scaling offset.
f64 ScalingOffset
Configures the scaling offset used to convert raw bits of the
message to/from scaled floating-point units. The scaling
offset is the B in the linear scaling formula AX+B, where X is
the raw data, and A is the scaling factor.
f64 MaxValue
Configures the maximum value of the channel in scaled
floating-point units.
The nctRead and nctWrite functions do not coerce
samples when converting to/from CAN messages. You can
Interface
Specifies the CAN interface to use for this task.
The interface input uses an enumeration in which value 0 selects CAN0,
value 1 selects CAN1, and so on.
The default baud rate for the Interface is defined within MAX, but
you can change it by setting the nctPropIntfBaudRate property
with nctSetProperty.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
Mode
Specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
nctModeInput
Input channel data from received CAN messages. Use the
nctRead function to obtain input samples as single-point, array,
SampleRate
Specifies the timing to use for samples of the task. The sample rate is
specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For Mode of NctModeInput, SampleRate of zero means nctRead
returns a single point from the most recent message received, and
greater than zero means nctRead returns samples timed at the
specified rate.
For Mode of NctModeOutput, SampleRate of zero means CAN
messages transmit immediately when nctWrite is called, and greater
than zero means CAN messages are transmitted periodically at the
specified rate.
Outputs
TaskRef
Use TaskRef with all subsequent functions to reference the task. Pass
this task reference to nctStart before you read or write samples for
the message.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
To use message and channel configurations from MAX or a CAN database, use the
nctInitStart or nctInitialize functions. The nctCreateMessage function provides
an alternative in which you create the message and channel configurations within the
application, without use of MAX or a CAN database.
nctCreateMessageEx
Purpose
Create a mode dependent message configuration and associated channel configurations
within the application.
Format
nctTypeStat nctCreateMessageEx(
us
u32 ConfigID,
void *MessageConfig,
u32 NumberOfChannels,
void *ChannelConfigList,
i32 Interface,
i32 Mode,
f64 SampleRate,
nctTypeTaskRef *TaskRef)
Inputs
ConfigID
MessageConfig
Configures properties for a new message. For both ConfigId = 1 and
ConfigId = 2, you provide the properties as a pointer to a C struct.
The properties are similar to the message properties in MAX:
u32 MsgArbitrationID
Configures the arbitration ID of the message.
Use the Extended property to specify whether the ID is
standard (11-bit) or extended (29-bit).
u32 Extended
Configures a Boolean value that indicates whether the
message arbitration ID is standard 11-bit format (0) or
extended 29-bit format (1).
u32 MsgDataBytes
Configures the number of data bytes in the message.
The range is 0 to 8.
NumberOfChannels
Specifies the number of channel configurations you provide in
ChannelConfigList.
ChannelConfigList
Configures the list of channels for the new message.
ChannelConfigList is an array of a C struct, with one C struct
for each channel. The properties of each channel are similar to the
channel properties in MAX. For ConfigId = 1, refer to the
ChannelConfigList parameter of the nctCreateMessage
function. For ConfigId = 2 use this structure:
u32 StartBit
Configures the starting bit position in the message. The range
is 0 (lowest bit in first byte), to 63 (highest bit in last byte).
u32 NumBits
Configures the number of bits in the message. The range
is 1 to 64.
u32 DataType
Configures the data type of the channel in the message.
Values are nctDataSigned, nctDataUnsigned, and
nctDataFloat.
u32 ByteOrder
Configures the byte order of the channel in the message.
Values are nctOrderIntel (little-endian), and
nctOrderMotorola (big-endian).
f64 ScalingFactor
Configures the scaling factor used to convert raw bits of the
message to/from scaled floating-point units. The scaling
factor is the A in the linear scaling formula AX+B, where X is
the raw data, and B is the scaling offset.
f64 ScalingOffset
Configures the scaling offset used to convert raw bits of the
message to/from scaled floating-point units. The scaling
offset is the B in the linear scaling formula AX+B, where X is
the raw data, and A is the scaling factor.
f64 MaxValue
Configures the maximum value of the channel in scaled
floating-point units.
The nctRead and nctWrite functions do not coerce
samples when converting to/from CAN messages. You can
use this value with the user-interface functions of the
development environment to set the range of front-panel
controls and indicators.
f64 MinValue
Configures the minimum value of the channel in scaled
floating-point units.
The nctRead and nctWrite functions do not coerce
samples when converting to/from CAN messages. You can
use this value with the user-interface functions of the
development environment to set the range of front-panel
controls and indicators.
f64 DefaultValue
Configures the default value of the channel in scaled
floating-point units.
For information on how the DefaultValue is used, refer to
the nctRead and nctWrite functions.
Interface
Specifies the CAN interface to use for this task.
The interface input uses an enumeration in which value 0 selects
CAN0, value 1 selects CAN1, and so on.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
Mode
Specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
nctModeInput
Input channel data from received CAN messages. Use the
nctRead function to obtain input samples as single-point, array,
or waveform. Each sample value that you write is transmitted in a
message on the network. If you write an array or waveform, the
samples are buffered for subsequent transmit.
Use this input mode to read waveforms of timed samples, such as
for comparison with NI-DAQ or NI-DAQmx waveforms. You also
can use this input mode to read a single point from the most recent
message, such as for control or simulation.
SampleRate
Specifies the timing to use for samples of the task. The sample rate is
specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For Mode of NctModeInput, SampleRate of zero means nctRead
returns a single point from the most recent message received, and
greater than zero means nctRead returns samples timed at the
specified rate.
For Mode of nctModeOutput, SampleRate of zero means CAN
messages transmit immediately when nctWrite is called, and greater
than zero means CAN messages are transmitted periodically at the
specified rate.
For Mode of NctModeTimestampedInput, SampleRate is ignored.
Outputs
TaskRef
Use TaskRef with all subsequent functions to reference the task. Pass
this task reference to nctStart before you read or write samples for
the message.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
To use message and channel configurations from MAX or a CAN database, use the
nctInitStart or nctInitialize functions. The nctCreateMessage function provides
an alternative in which you create the message and channel configurations within the
application, without use of MAX or a CAN database.
nctDisconnectTerminals
Purpose
Disconnect terminals in the CAN hardware.
Format
nctTypeStatus nctDisconnectTerminals(
nctTypeTaskRef TaskRef,
u32 SourceTerminal,
u32 DestinationTerminal,
u32 Modifiers);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
SourceTerminal
Specifies the source of the connection.
For a description of values for SourceTerminal, refer to
nctConnectTerminals.
DestinationTerminal
Specifies the destination of the connection.
For a description of values for DestinationTerminal, refer to
nctConnectTerminals.
Modifiers
Provides optional connection information for certain
source/destination pairs. The current release of NI-CAN does not use
this information for any source/destination pair, so you must pass
Modifiers as zero.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
This function disconnects a specific pair of source/destination terminals you previously
connected with nctConnectTerminals.
When the final task for a given interface is cleared with nctClear, NI-CAN disconnects all
terminal connections for that interface. Therefore, the nctDisconnectTerminals function
is not required for most applications. You typically use this function to change RTSI
connections dynamically while the application is running. First use nctStop to stop all tasks
for the interface, then use nctDisconnectTerminals and nctConnectTerminals to
adjust RTSI connections, then nctStart to restart sampling.
nctGetNames
Purpose
Get an array of CAN channel names or message names from MAX or a CAN database file.
Format
nctTypeStatus nctGetNames(
cstr FilePath,
u32 Mode,
cstr MessageName,
u32 SizeofChannelList,
str ChannelList);
Inputs
FilePath
FilePath is an optional path to a CAN database file from which to
get channel names. The file must use either .DBC or .NCD extension.
Files with extension .DBC use the CANdb database format. Files with
extension .NCD use the NI-CAN database format. You can generate
NI-CAN database files from the Save Channels selection in MAX.
If you pass NULL or empty-string to FilePath, this function gets the
channel names from MAX. The MAX CAN channels are in the MAX
CAN channels listing within Data Neighborhood.
Mode
Specifies the type of names to return.
nctGetNamesModeChannels
Return list of channel names. You can pass the returned
ChannelList to nctInitStart.
nctGetNamesModeMessages
Return list of message names.
MessageName
MessageName is an optional input that filters the names for a specific
message. If you pass NULL or empty-string to MessageName, this
function returns all names in the database. If you pass a non empty
string, the ChannelList output is limited to channels of the specified
message.
This input applies to Mode of nctGetNamesModeChannels only. It is
ignored for Mode of nctGetNamesModeMessages.
SizeofChannelList
Number of bytes allocated for the ChannelList output.
If all of the channel names do not fit in the allocated ChannelList,
this function returns as much as possible with an error.
Use the nctGetNamesLength function to determine the proper
SizeofChannelList.
Outputs
ChannelList
Returns the comma-separated list of channel names.
Each name in ChannelList uses the minimum syntax required to
properly initialize:
• If a channel name is used within only one message in the database,
nctGetNames returns only the channel name in the list. If a channel
name is used within multiple messages, nctGetNames prepends the
message name to that channel name, with a decimal point separating
the message and channel name. This syntax ensures that the duplicate
channel is associated to a single message in the database.
For more information on the syntax conventions for channel names,
refer to the nctInitStart function.
To start a task for all channels returned from nctGetNames, pass
ChannelList to the nctInitStart function to start a task.
You also can use ChannelList with a user-interface control such as a
ring or list box. The user of the application can then select names using
this control, and the selected names can be passed to nctInitStart.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Note The function nctGetNames returns the string results as an array of char (*char).
VB is not able to convert this array to a string automatically. Therefore, VB users should
call the wrapper function nct_GetNames.
nctGetNamesLength
Purpose
Get the required size for a specified list of channels to allocate an array for the ChannelList
input of nctGetNames.
Format
nctTypeStatus nctGetNamesLength(
cstr FilePath,
u32 Mode,
cstr MessageName,
u32 *SizeofChannelList);
Inputs
FilePath
FilePath is an optional path to a CAN database file from which to
get channel names. The file must use either the .DBC or .NCD
extension.
If you pass NULL or empty-string to FilePath, this function examines
the channel names from MAX.
For more information on FilePath, refer to the nctGetNames
function.
Mode
Specifies the type of names to examine.
nctGetNamesModeChannels
Examine the list of channel names.
nctGetNamesModeMessages
Examine the list of message names.
MessageName
MessageName is an optional input that filters the names for a specific
message. If you pass NULL or empty-string to MessageName, this
function returns all names in the database. If you pass a nonempty
string, the SizeofChannelList output is limited to channels of the
specified message.
Outputs
SizeofChannelList
Number of bytes required for nctGetNames to return all names for the
specified FilePath, Mode, and MessageName. After calling
nctGetNamesLength, you can allocate an array of size
SizeofChannelList, then pass that array to nctGetNames using
the same input parameters. This ensures that nctGetNames will return
all names without error.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
nctGetProperty
Purpose
Get a property for the task, or a single channel within the task.
Format
nctTypeStatus nctGetProperty(
nctTypeTaskRef TaskRef,
cstr ChannelName,
u32 PropertyId,
u32 SizeofValue,
void *Value);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
ChannelName
Specifies an individual channel within the task. If you pass
empty-string to ChannelName, this means the property applies to the
entire task, not a specific channel.
Properties that begin with the word Channel or Message do not apply
to the entire task, but an individual channel or message within the task.
For these channel-specific properties, you must pass the name of a
channel from a channel list into the ChannelName input.
For properties that do not begin with the word Channel or Message,
you must pass empty-string ("") into ChannelName. You must not
pass NULL into ChannelName.
PropertyId
Selects the property to get.
For a description of each property, including its data type and
PropertyId, refer to the Properties section of this function reference.
SizeofValue
Number of bytes allocated for the Value output. This size normally
depends on the data type listed in the description of the property.
Outputs
Value
Returns the property value. PropertyId determines the data type of
the returned value.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Properties
u32 nctPropBehavAfterFinalOut
Returns the nctPropBehavAfterFinalOut property, which is used
with some output task configurations. For more information, refer to
the nctPropBehavAfterFinalOut property in nctSetProperty.
u32 nctPropChanByteOrder
Returns the byte order of the channel in the message. Values are
nctOrderIntel (little-endian), and nctOrderMotorola
(big-endian).
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropChanDataType
Returns the data type of the channel in the message. Values are
nctDataSigned, nctDataUnsigned, and nctDataFloat.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
f64 nctPropChanDefaultValue
Returns the default value of the channel in scaled floating-point units.
For information on how nctPropChanDefaultValue is used, refer
to the nctRead and nctWrite functions.
The value of this property is originally set within MAX. If the channel
is initialized directly from a CAN database, the value is 0.0 by default,
but it can be changed using nctSetProperty
u32 nctPropChanIsModeDependent
Returns if a channel is mode dependent (1) or not (0).
f64 nctPropChanMaxValue
Returns the maximum value of the channel in scaled floating-point
units.
The nctRead and nctWrite functions do not coerce samples when
converting to/from CAN messages. You can use this value with the
user-interface functions of the development environment to set the
range of front-panel controls and indicators.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
f64 nctPropChanMinValue
Returns the minimum value of the channel in scaled floating-point
units.
The nctRead and nctWrite functions do not coerce samples when
converting to/from CAN messages. You can use this value with the
user-interface functions of the development environment to set the
range of front-panel controls and indicators.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropChanModeValue
Returns the value of the mode channel associated to this channel.
This property applies only to mode dependent channels. For more
information, refer to the Mode Dependent Channels section of
Chapter 6, Using the Channel API.
u32 nctPropChanNumBits
Returns the number of bits in the channel. The range is 0 to 64.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
f64 nctPropChanScalFactor
Returns the scaling factor used to convert raw bits of the message
to/from scaled floating-point units. The scaling factor is the A in the
linear scaling formula AX+B, where X is the raw data, and B is the
scaling offset.
CAN messages use the raw data, and the nctRead and nctWrite
functions provide access to samples in floating-point units.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
f64 nctPropChanScalOffset
Returns the scaling offset used to convert raw bits of the message
to/from scaled floating-point units. The scaling offset is the B in the
linear scaling formula AX+B, where X is the raw data, and A is the
scaling factor.
CAN messages use the raw data, and the nctRead and nctWrite
functions provide access to samples in floating-point units.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropChanStartBit
Returns the starting bit position in the message. The range is 0
(lowest bit in first byte), to 63 (highest bit in last byte).
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
str nctPropChanUnitString
Returns the unit string of the channel. The string is no more than
80 characters in length.
You can use this value to display units (such as volts or RPM) along
with the samples of the channel.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropHwFormFactor
Returns the hardware form factor for the NI-CAN hardware that
contains interface. Values are nctHwFormFactorPCI,
nctHwFormFactorPXI, nctHwFormFactorPCMCIA, and
nctHwFormFactorAT.
u32 nctPropHwMasterTimebaseRate
Returns the present Hardware Master Timebase Rate in MHz,
programmed into the CAN hardware. For PCMCIA, this property will
always return 10 MHz.
u32 nctPropHwSerialNum
Returns the hardware serial number for the NI-CAN hardware that
contains Interface.
u32 nctPropHwSeries
Returns the hardware series for the NI CAN hardware that contains
Interface. Values are nctHwSeries1 and nctHwSeries2.
Newer hardware series are often capable of more features, so the
application may need to determine which is installed.
u32 nctPropHwTimestampFormat
Returns the present Timestamp Format programmed into the CAN
hardware. This property applies to the entire card.
u32 nctPropInterface
Returns the Interface initialized for the task, such as with the
nctInitStart function.
u32 nctPropIntfBaudRate
Returns the baud rate in use by the Interface.
Basic baud rates such as 125000 and 500000 are specified as the
numeric rate.
Advanced baud rates are specified as 8000XXYY hex, where YY is the
value of Bit Timing Register 0 (BTR0), and XX is the value of Bit
Timing Register 1 (BTR1). For more information, refer to the Port
Properties dialog in MAX.
The value of this property is originally set within MAX, but it can be
changed using nctSetProperty.
u32 nctPropIntfListenOnly
Returns a Boolean value that indicates whether the listen only feature
of the Philips SJA1000 CAN controller is enabled (true) or disabled
(false). For more information, refer to the nctPropIntfListenOnly
property in nctSetProperty.
Since the listen only feature requires the Philips SJA1000 CAN
controller, this property is supported on Series 2 NI CAN hardware
only.
u32 nctPropIntfRxErrorCounter
Returns the Receive Error Counter as described in the CAN
specification.
Since the error count requires the Philips SJA1000 CAN controller,
this property is supported on Series 2 NI CAN hardware only. If you
are using Series 1 NI CAN hardware, this property returns an error.
u32 nctPropIntfSelfReception
Returns the nctPropIntfSelfReception property as configured
with nctSetProperty. This property is supported on Series 2
NI CAN hardware only (returns error for Series 1).
u32 nctPropIntfSeries2ErrArbCapture
Returns the current values of the Error Code Capture register and
Arbitration Lost Capture register from the Philips SJA1000 CAN
controller chip.
The Error Code Capture register provides information on bus errors
that occur according to the CAN standard. A bus error increments
either the Transmit Error Counter or the Receive Error Counter. When
communication starts on the interface, the first bus error is captured
into the Error Code Capture register, and retained until you get this
property. After you get this property, the Error Code Capture register
is again enabled to capture information for the next bus error.
The Arbitration Lost Capture register provides information on a loss of
arbitration during transmits. Loss of arbitration is not considered an
error. When communication starts on the interface, the first arbitration
loss is captured into the Arbitration Lost Capture register, and retained
until you get this property. After you get this property, the Arbitration
Lost Capture register is again enabled to capture information for the
next arbitration loss.
For each of the capture registers, a single-bit New flag indicates
whether a new error has occurred since the last Get. If the New flag of
a register is set, the associated fields contain new information. If the
New flag of a register is clear, the associated fields are the same as the
previous Get.
This property is commonly used with the
nctPropIntfSingleShotTx property. When nctWrite is used to
transmit the single frame, you can get this property to determine if the
transmit was successful. If the single shot transmit was not successful,
this property provides detailed information for the failure.
This property is supported for Series 2 hardware only (Series 1 returns
error). Since the information and bit format is very specific to the
u32 nctPropIntfSeries2Comp
Returns the value of the nctPropIntfSeries2Comp property
(refer to nctSetProperty).
u32 nctPropIntfSeries2FilterMode
Returns the value of the nctPropIntfSeries2FilterMode
property (refer to nctSetProperty).
u32 nctPropIntfSeries2Mask
Returns the value of the nctPropIntfSeries2Mask property
(refer to nctSetProperty.html).
u32 nctPropIntfSingleShotTx
Returns the value of the nctPropIntfSingleShotTx property
(refer to nctSetProperty).
u32 nctPropIntfTransceiverExternalIn
Returns the transceiver external inputs for the interface that was
initialized for the task.
Series 2 XS cards enable connection of an external transceiver. For an
external transceiver, this property allows you to determine the input
voltage on the STATUS pin of the CAN port.
For many models of CAN transceiver, an NERR pin is provided for
detection of faults and other status. For such transceivers, you can wire
the NERR pin to the STATUS pin of the CAN port.
This property is supported for Series 2 XS cards only.
This property uses a bit mask. When using the property, use bitwise
AND operations to check for values, not equality checks (equal,
greater than, and so on).
nctTransceiverInStatus (00000001 hex, STATUS pin)
This bit is set when 5 V exists on the STATUS pin.
This bit is clear when 0 V exists on the STATUS pin.
u32 nctPropIntfTransceiverExternalOut
Returns the transceiver external outputs for the interface that was
initialized for the task.
Series 2 XS cards enable connection of an external transceiver. For an
external transceiver, this property allows you to determine the output
voltage on the MODE0 and MODE1 pins of the CAN port, and it
allows you to determine if the CAN controller chip is sleeping.
For more information on the format of the value returned in this
property, refer to the description of
nctPropIntfTransceiverExternalOut in nctSetProperty.
This property is supported for Series 2 XS cards only.
u32 nctPropIntfTransceiverMode
Returns the transceiver mode for the interface that was initialized for
the task. The transceiver mode changes when you set the mode within
the application, or when a remote wakeup transitions the interface
from Sleep to Normal mode. For more information, refer to
nctSetProperty.
This property is supported for Series 2 cards only.
This property uses the following values:
nctTransceiverModeNormal
Transceiver is awake in Normal communication mode.
nctTransceiverModeSleep
Transceiver and the CAN controller chip are both in Sleep mode.
nctTransceiverModeSWWakeup
Single Wire transceiver is in Wakeup Transmission mode.
nctTransceiverModeSWHighSpeed
Single Wire transceiver is in High-Speed Transmission mode.
u32 nctPropIntfTransceiverType
Returns the type of transceiver for the interface that was initialized for
the task. For hardware other than Series 2 XS cards, the transceiver
type is fixed. For Series 2 XS cards, the transceiver type reflects the
most recent value specified by MAX or nctSetProperty.
This property is not supported on the PCMCIA form factor.
This property uses the following values:
nctTransceiverTypeHS
Transceiver type is High-Speed (HS).
nctTransceiverTypeLS
Transceiver type is Low-Speed/Fault-Tolerant (LS).
nctTransceiverTypeSW
Transceiver type is Single Wire (SW).
nctTransceiverTypeExternal
Transceiver type is External. This transceiver type is available on
Series 2 XS cards only. For more information, refer to
nctSetProperty.
nctTransceiverTypeDisconnect
Transceiver type is Disconnect. This transceiver type is available
on Series 2 XS cards only. For more information, refer to
nctSetProperty.
u32 nctPropIntfTxErrorCounter
Returns the Transmit Error Counter as described in the CAN
specification.
Since the error count requires the Philips SJA1000 CAN controller,
this property is supported on Series 2 NI CAN hardware only. If you
are using Series 1 NI CAN hardware, this property returns an error.
u32 nctPropIntfVirtualBusTiming
Returns a Boolean value of True or False to indicate whether Virtual
Bus Timing has been set or not for the specified virtual task. This
property is applicable to all tasks opened on the virtual interface.
If this property is selected on real hardware, an error will be returned.
u32 nctPropMode
Returns the mode initialized for the task, such as with the
nctInitStart function.
u32 nctPropMsgArbitrationId
Returns the arbitration ID of the channel message.
To determine whether the ID is standard (11-bit) or extended (29-bit),
get the nctPropMsgIsExtended property.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropMsgByteLength
Returns the number of data bytes in the channel message. The range
0 to 8.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropMsgIsExtended
Returns a Boolean value that indicates whether the arbitrationID of the
channel message is standard 11-bit format (0) or extended 29-bit
format (1).
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
str nctPropMsgName
Returns the name of the channel message. The string is no more than
80 characters in length.
The value of this property is originally set within MAX or the CAN
database and cannot be changed using nctSetProperty.
u32 nctPropMsgDistribution
Returns the nctPropMsgDistribution which is used to determine
if the CAN frames associated to a group of mode dependent channels
are sent even spaced or in burst mode. This property applies only for
mode dependent channels that are transmitted periodically. For more
information, refer to the Mode Dependent Channels section of
Chapter 6, Using the Channel API.
f64 nctPropNoValue
Returns the value that is returned on timestamped read for mode
dependent channels that have not been received with the most recent
CAN frame associated with the CAN message. This Property applies
only to mode dependent channels that are read with the timestamped
read operation. For more information, refer to the Mode Dependent
Channels section of Chapter 6, Using the Channel API.
u32 nctPropNumChannels
Returns the number of channels initialized in channel list. This is the
number of array entries required when using nctRead or nctWrite.
f64 nctPropSampleRate
Returns the sample rate initialized for the task, such as with the
nctInitStart function.
u32 nctPropSamplesPending
Returns the number of samples available to be read using nctRead.
If you set the NumberOfSamplesToRead input of nctRead to this
value, nctRead returns immediately without waiting.
This property applies only to tasks initialized with Mode of
NctModeInput, and SampleRate greater than zero. For all other
configurations, it returns an error.
f64 nctPropTimeout
Returns the nctPropTimeout property, which is used with some task
configurations. For more information, refer to the nctPropTimeout
property in nctSetProperty.
u32 nctPropVersionBuild
Returns the build number of the NI-CAN software. This number
applies to nctPhaseDevelopment, nctPhaseAlpha, and
nctPhaseBeta phase only, and should be ignored for
nctPhaseRelease phase.
str nctPropVersionComment
Returns a comment string for the NI-CAN software. If you received a
custom release of NI-CAN from National Instruments, this comment
often describes special features of the release.
u32 nctPropVersionMajor
Returns the major version of the NI-CAN software, such as the 2 in
version 2.1.5.
u32 nctPropVersionMinor
Returns the minor version of the NI-CAN software, such as the 1 in
version 2.1.5.
u32 nctPropVersionPhase
Returns the phase of the NI-CAN software. Values are
nctPhaseDevelopment, nctPhaseAlpha, nctPhaseBeta, and
nctPhaseRelease. Versions of NI-CAN in hardware kits or on
ni.com will always be nctPhaseRelease.
u32 nctPropVersionUpdate
Returns the update version of the NI-CAN software, such as the 5 in
version 2.1.5.
nctInitialize
Purpose
Initialize a task for the specified channel list.
Format
nctTypeStatus nctInitialize(
cstr ChannelList,
i32 Interface,
i32 Mode,
f64 SampleRate,
nctTypeTaskRef *TaskRef);
Inputs
ChannelList
Comma-separated list of channel names to initialize as a task.
For more information, refer to the channel list input of
nctInitStart.
Interface
Specifies the CAN interface to use for this task.
The interface input uses an enumeration in which value 0 selects
CAN0, value 1 selects CAN1, and so on.
If you pass the special value -1 to Interface, this function uses the
default interface as defined in the Message/Channel configuration
properties. If the default interface in MAX is All, or if one or more
channels in ChannelList specifies a filepath, the Interface is a
required input to this function.
The Channel API and Frame API cannot use the same CAN network
interface simultaneously. If the CAN network interface is already
initialized in the Frame API, this function returns an error.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
Mode
Specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
nctModeInput
Input channel data from received CAN messages. Use the
nctRead function to obtain input samples as single-point, array,
or waveform. Each sample value that you write is transmitted in a
message on the network. If you write an array or waveform, the
samples are buffered for subsequent transmit.
Use this input mode to read waveforms of timed samples, such as
for comparison with NI-DAQ or NI-DAQmx waveforms. You also
can use this input mode to read a single point from the most recent
message, such as for control or simulation.
For this mode, the channels in ChannelList can be contained in
multiple messages.
nctModeOutput
Output channel data to CAN messages for transmit. Use the
nctWrite function to write output samples as single-point, array,
or waveform.
For this mode, there are restrictions on using channels in
ChannelList that are contained in multiple messages. Refer to
nctWrite for more information.
nctModeOutputRecent
Output channel data to CAN messages for transmit. This mode is
used with sample rate greater than zero (periodic transmit). Use
nctWrite to provide a single sample per channel. Each periodic
message uses the sample values from the most recent nctWrite.
For this mode, there are restrictions on using channels in channel
list that are contained in multiple messages. Refer to nctWrite
for more information.
nctModeTimestampedInput
Input channel data from received CAN messages. Use the
nctRead function to obtain input samples as an array of
sample/timestamp pairs (refer to nctReadTimestamped).
Use this input mode to read samples with timestamps that indicate
when each message is received from the network.
For this mode, the channels in ChannelList must be contained
in a single message.
SampleRate
Specifies the timing to use for samples of the task. The sample rate is
specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For Mode of NctModeInput, SampleRate of zero means nctRead
returns a single point from the most recent message received, and
greater than zero means nctRead returns samples timed at the
specified rate.
For Mode of NctModeOutput, SampleRate of zero means CAN
messages transmit immediately when nctWrite is called, and greater
than zero means CAN messages are transmitted periodically at the
specified rate.
For Mode of NctModeTimestampedInput, SampleRate is ignored.
When the Interface specifies a virtual interface (256 or 257), and
Mode is nctModeOutput or nctModeOutputRecent, this
SampleRate must be zero (greater than zero not supported).
Outputs
TaskRef
Use TaskRef with all subsequent functions to reference the task. Pass
this task reference to nctStart before you read or write samples for
the message.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
The nctInitialize function does not start communication. This enables you to use
nctSetProperty to change the properties of the task, or nctConnectTerminals to
synchronize CAN or DAQ cards. After you change properties or connections, use nctStart
to start communication for the task.
nctInitStart
Purpose
Initialize a task for the specified channel list, then start communication.
Format
nctTypeStatus nctInitStart(
cstr ChannelList,
i32 Interface,
i32 Mode,
f64 SampleRate,
nctTypeTaskRef *TaskRef);
Inputs
ChannelList
Comma-separated list of channel names to initialize as a task.
You can type in the channel list as a string constant, or you can obtain
the list from MAX or another CAN database by using the
nctGetNames function. Channel names are case sensitive.
You can initialize the same ChannelList with different Interface,
Mode, or SampleRate, because each task reference is unique.
If you are using mode dependent channels, and each channel name is
not unique, you will need to use a special syntax described in the Mode
Dependent Channel Syntax section at the end of the function
description.
The following paragraphs describe the syntax of each channel name.
Brackets indicate optional fields.
[filepath::][message.]channel
• filepath is the path to a CAN database file from which to import the
channel (signal) configurations. The filepath must use Windows
directory syntax, and must be followed by a double-colon.
If filepath is not included, the channel configuration is obtained
from MAX. The MAX CAN channels are in the MAX CAN
Channels listing within Data Neighborhood.
Interface
Specifies the CAN interface to use for this task.
The interface input uses an enumeration in which value 0 selects CAN0,
value 1 selects CAN1, and so on.
If you pass the special value -1 to Interface, this function uses the
default interface as defined in the Message/Channel configuration
properties. If the default interface in MAX is All, or if one or more
channels in ChannelList specifies a filepath, the Interface is a
required input to this function.
The Channel API and Frame API cannot use the same CAN network
interface simultaneously. If the CAN network interface is already
initialized in the Frame API, this function returns an error.
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
Mode
Specifies the I/O mode for the task. For an overview of the I/O modes,
including figures, refer to the Channel API Basic Programming Model
section of Chapter 6, Using the Channel API.
nctModeInput
Input channel data from received CAN messages. Use the
nctRead function to obtain input samples as single-point, array,
or waveform. Each periodic message uses the sample values from
the most recent nctWrite.
Use this input mode to read waveforms of timed samples, such as
for comparison with NI-DAQ or NI-DAQmx waveforms. You also
can use this input mode to read a single point from the most recent
message, such as for control or simulation.
For this mode, the channels in ChannelList can be contained in
multiple messages.
nctModeOutput
Output channel data to CAN messages for transmit. Use the
nctWrite function to write output samples as single-point, array,
or waveform.
For this mode, there are restrictions on using channels in
ChannelList that are contained in multiple messages. Refer to
nctWrite for more information.
nctModeOutputRecent
Output channel data to CAN messages for transmit. This mode is
used with sample rate greater than zero (periodic transmit). Use
nctWrite to provide a single sample per channel. Each periodic
message uses the sample values from the most recent nctWrite.
For this mode, there are restrictions on using channels in channel
list that are contained in multiple messages. Refer to nctWrite
for more information.
nctModeTimestampedInput
Input channel data from received CAN messages. Use the
nctRead function to obtain input samples as an array of
sample/timestamp pairs (refer to nctReadTimestamped).
For this mode, the channels in ChannelList must be contained
in a single message.
Use this input mode to read samples with timestamps that indicate
when each message is received from the network.
If nctModeTimestampedInput mode is used, the task cannot be
started with nctInitStart because the Value for invalid
data must be set up through nctSetProperty before calling
nctStart. Use the sequence nctInitialize,
nctSetProperty (nctPropNoValue), and nctStart instead.
SampleRate
Specifies the timing to use for samples of the task. The sample rate is
specified in Hertz (samples per second). A sample rate of zero means
to sample immediately.
For Mode of NctModeInput, SampleRate of zero means nctRead
returns a single point from the most recent message received, and
greater than zero means nctRead returns samples timed at the
specified rate.
For Mode of NctModeOutput, SampleRate of zero means CAN
messages transmit immediately when nctWrite is called, and greater
than zero means CAN messages are transmitted periodically at the
specified rate.
For Mode of NctModeTimestampedInput, SampleRate is ignored.
When the Interface specifies a virtual interface (256 or 257), and
Mode is nctModeOutput or nctModeOutputRecent, this
SampleRate must be zero (greater than zero not supported).
Outputs
TaskRef
Use TaskRef with all subsequent functions to reference the running
task. Because nctInitStart starts communication, you can pass this
task reference to nctRead or nctWrite.
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
The code for this function simply calls nctInitialize followed by nctStart. This
provides an easy way to start a list of channels.
The following list describes the scenarios for which nctInitStart cannot be used:
• If you need to set properties for the channels, use nctInitialize, then
nctSetProperty, then nctStart. The nctInitStart function starts
communication, and most channel properties cannot be changed after the task is started.
• If you need to synchronize tasks for multiple NI-CAN, NI-DAQ, or NI-DAQmx cards,
use nctInitialize, then nctConnectTerminals to synchronize, the nctStart to
start communication.
• If you need to create channel configurations entirely within the application, without using
MAX or a CAN database file, use nctCreateMessage, then nctStart. The
nctInitStart function accepts only channel names defined in MAX or a CAN
database file.
Within MAX, channels with the same name are shown with a yellow exclamation point. This
feature can be changed in the CAN Channels»Options dialog box.
If the channel name is unique across all channels, the message name is not required.
• multiplexer refers to the multiplexer name in MAX or the CAN database. The message
name must be followed by a decimal point. It applies only to mode dependent messages
and must be omitted for normal CAN channels. If more than one multiplexer is defined
for the message and the channel name is not unique within the CAN message, you must
specify the multiplexer name to identify the channel uniquely.
• mode_value refers to the multiplexer mode in MAX or the CAN database. The message
name must be followed by a decimal point. It applies only to mode dependent messages
and must be omitted for normal CAN channels. If the channel name is not unique within
the multiplexer, you must specify the mode to identify the channel uniquely.
• channel refers to the channel (signal) name in MAX or the CAN database.
You cannot use the same channel name for a normal CAN channel and a mode dependent
CAN channel within the same CAN message.
If the name of a channel is unique within MAX or the database, it can be referenced by the
channel API using its channel name.
For more information on mode dependent channels, refer to the Mode Dependent Channels
section of Chapter 6, Using the Channel API.
nctRead
Purpose
Read samples from a CAN task initialized with Mode of nctModeInput. Samples are
obtained from received CAN messages. For an overview of nctRead, refer to the Read
section of Chapter 6, Using the Channel API.
Format
nctTypeStatus nctRead(
nctTypeTaskRef TaskRef,
u32 NumberOfSamplesToRead,
nctTypeTimestamp *StartTime,
nctTypeTimestamp *DeltaTime,
f64 *SampleArray,
u32 *NumberOfSamplesReturned);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
The Mode initialized for the task must be NctModeInput.
NumberOfSamplesToRead
Specifies the number of samples to read for the task. For single-sample
input, pass 1 to this parameter.
If the initialized sample rate is zero, you must pass
NumberOfSamplesToRead no greater than 1. SampleRate of zero
means nctRead immediately returns a single sample from the most
recent message(s) received.
Outputs
StartTime
Returns the time of the first CAN sample in SampleArray.
This parameter is optional. If you pass NULL for the StartTime
parameter, the nctRead function proceeds normally.
If the initialized SampleRate is greater than zero, the StartTime is
determined by the sample timing.
If the initialized sample rate is zero, the StartTime is zero, because
the most recent sample is returned regardless of timing.
StartTime uses the nctTypeTimestamp data type. The
nctTypeTimestamp data type is a 64-bit unsigned integer compatible
with the Microsoft Win32 FILETIME type. This absolute time is kept
in a Coordinated Universal Time (UTC) format. UTC time is loosely
defined as the current date and time of day in Greenwich, England.
Microsoft defines its UTC time (FILETIME) as a 64-bit counter of
100 ns intervals that have elapsed since 12:00 a.m., January 1, 1601.
Because nctTypeTimestamp is compatible with Win32 FILETIME,
you can pass it into the Win32 FileTimeToLocalFileTime function
to convert it to the local time zone, and then pass the resulting local
time to the Win32 FileTimeToSystemTime function to convert to
the Win32 SYSTEMTIME type. SYSTEMTIME is a struct with fields for
year, month, day, and so on. For more information on Win32 time
types and functions, refer to the Microsoft Win32 documentation.
DeltaTime
Returns the time between each sample in SampleArray.
This parameter is optional. If you pass NULL for the DeltaTime
parameter, the nctRead function proceeds normally.
If the initialized sample rate is greater than zero, the DeltaTime is
determined by the sample timing.
If the initialized sample rate is zero, the DeltaTime is zero, because
the most recent sample is returned regardless of timing.
DeltaTime uses the nctTypeTimestamp data type. The delta time is
a relative 64-bit counter of 100 ns intervals, not an absolute UTC time.
Nevertheless, you can use functions like the Win32
FileTimeToSystemTime function to convert to the Win32
SYSTEMTIME type. In addition, you can use the 32-bit LowPart of
DeltaTime to obtain a simple 100 ns count, because SampleRate s
as slow as 0.4 Hz are still limited to a 32-bit 100 ns count.
SampleArray
Returns an array of arrays (2D array), one array for each channel
initialized in the task. The array of each channel must have
NumberOfSamplesToRead entries allocated.
For example, if you call nctInitStart with ChannelList of
mych1,mych2,mych3, then call nctRead with
NumberOfSamplesToRead of 10, SampleArray must be
allocated as:
f64 SampleArray[3][10];
The order of channel entries in SampleArray is the same as the order
in the original channel list.
If you need to determine the number of channels in the task after
initialization, get the nctPropNumChannels property for the task
reference.
If no message has been received since you started the task, the default
value of the channel (nctPropChanDefaultValue) is returned in all
entries of SampleArray.
NumberOfSamplesReturned
Indicates the number of samples returned for each channel in
SampleArray. The remaining entries are left unchanged (zero).
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
When using Mode of nctModeInput, you can specify channels in ChannelList that span
multiple messages.
If the initialized SampleRate is greater than zero, this function returns an array of samples,
each of which indicates the value of the CAN channel at a specific point in time. The
nctRead function waits for these samples to arrive in time before returning. In other words,
the SampleRate specifies a virtual clock that copies the most recent value from CAN
messages for each sample time. The changes in sample values from message to message
enable you to view the CAN channel over time, such as for comparison with other CAN or
DAQ input channels. To avoid internal waiting, you can use nctGetProperty to obtain the
nctPropSamplesPending property, and pass that as the NumberOfSamplesToRead
parameter to nctRead.
If the initialized SampleRate is zero, nctRead immediately returns a single sample from the
most recent message(s) received. For this single-point read, you must pass the
NumberOfSamplesToRead parameter as 1.
You can use the return value of nctRead to determine whether a new message has been
received since the previous call to nctRead (or nctStart). If no message has been received,
the warning code CanWarnOldData is returned. If a new message has been received, the
success code 0 is returned.
If no message has been received since you started the task, the default value of the channel
(nctPropChanDefaultValue) is returned in all entries of SampleArray.
nctReadTimestamped
Purpose
Read samples from a CAN task initialized with Mode of nctModeTimestampedInput. For
an overview of nctReadTimestamped, refer to the Read Timestamped section of Chapter 6,
Using the Channel API.
Format
nctTypeStatus nctReadTimestamped(
nctTypeTaskRef TaskRef,
u32 NumberOfSamplesToRead,
nctTypeTimestamp *TimestampArray,
f64 *SampleArray,
u32 *NumberOfSamplesReturned);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
The Mode initialized for the task must be
NctModeTimestampedInput.
NumberOfSamplesToRead
Specifies the number of samples to read for the task.
Outputs
TimestampArray
Returns the time at which each corresponding sample in
SampleArray was received in a CAN message.
The timestamps are returned as an array of arrays (2D array), one array
for each channel initialized in the task. The array of each channel must
have NumberOfSamplesToRead entries allocated.
For example, if you call nctInitStart with ChannelList of
mych1,mych2, then call nctReadTimestamped with
SampleArray
Returns the sample value(s) for each received CAN message.
The samples are returned as an array of arrays (2D array), one array
for each channel initialized in the task. The array of each channel
must have NumberOfSamplesToRead entries allocated.
You must allocate SampleArray exactly as TimestampArray,
and the order of channel entries is the same for both.
NumberOfSamplesReturned
Indicates the number of samples returned for each channel in
SampleArray, and the number of timestamps returned for each
channel in TimestampArray. The remaining entries are left
unchanged (zero).
Return Value
The return value indicates the function call status as a signed 32-bit integer. Zero means the
function executed successfully. A negative value specifies an error, which means the function
did not perform the expected behavior. A positive value specifies a warning, which means the
function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
Each returned sample corresponds to a received CAN message for the channels initialized in
channel list. For each sample, nctReadTimestamped returns the sample value and a
timestamp that indicates when the message was received.
The nctPropTimeout property determines whether this function waits for the
NumberOfSamplesToRead messages to arrive from the network. The default value of
nctPropTimeout is zero, but you can change it using the nctSetProperty function.
If nctPropTimeout is zero, the function does not wait for messages, but instead returns
samples from the messages received since the previous call to nctReadTimestamped. The
number of samples returned is indicated in the NumberOfSamplesReturned output, up to a
maximum of NumberOfSamplesToRead messages. If no new message has been received,
NumberOfSamplesReturned is 0, and the return value indicates success.
nctSetProperty
Purpose
Set a property for the task, or a single channel within the task.
Format
nctTypeStatus nctGetProperty
(
nctTypeTaskRef TaskRef,
cstr ChannelName,
u32 PropertyId,
u32 SizeofValue,
void *Value);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
ChannelName
Specifies an individual channel within the task. If you pass NULL or
empty-string to ChannelName, this means the property applies to the
entire task, not a specific channel.
Properties that begin with the word Channel or Message do not apply
to the entire task, but an individual channel or message within the task.
For these channel-specific properties, you must pass the name of a
channel from the channel list into the ChannelName input.
For properties that do not begin with the word Channel or Message,
you must pass empty-string ("") into ChannelName. You must not
pass NULL into ChannelName.
PropertyId
Selects the property to set.
For a description of each property, including its data type and
PropertyId, refer to the Properties section in this function reference.
SizeofValue
Number of bytes provided for the Value output. This size will
normally depend on the data type listed in the description of the
property.
Value
Provides the property value. PropertyId determines the data type of
the value.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
You cannot set a property while the task is running. If you need to change a property prior to
starting the task, you cannot use nctInitStart. First call nctInitialize, followed by
nctSetProperty, and then nctStart. After you start the task, you also can change a
property by calling nctStop, followed by nctSetProperty, and then nctStart again.
Properties
u32 nctPropBehavAfterFinalOut
The nctPropBehavAfterFinalOut property applies only to tasks
initialized with mode of NctModeOutput, and sample rate greater
than zero. The value specifies the behavior to perform after the final
periodic sample is transmitted.
nctPropBehavAfterFinalOut uses the following values:
nctOutBehavRepeatFinalSample
Transmit messages for the final sample(s) repeatedly. The
final messages are transmitted periodically as specified by
SampleRate.
If there is significant delay between subsequent calls to
nctWrite, this value means periodic messages continue
f64 nctPropChanDefaultValue
Sets the default value of the channel in scaled floating-point units.
For information on how the nctPropChanDefaultValue is used,
refer to the nctRead and nctWrite functions.
The value of this property is originally set within MAX. If the channel
is initialized directly from a CAN database, the value is 0.0 by default,
but it can be changed using nctSetProperty.
u32 nctPropHwMasterTimebaseRate
Sets the rate (in MHz) of the external clock that is exported to the CAN
card.
The decimal values for this property are:
20
When synchronizing 2 CAN cards or synchronizing a CAN card
with an E-Series DAQ card, the 20 MHz master timebase rate is to
be used. By default, this property is set to 20 MHz.
10
The master timebase rate should be set to 10 MHz when
synchronizing a CAN card with an M-Series DAQ card. The
M-Series DAQ card can export a 20 MHz clock but it does this by
using one of its two counters.
If your CAN-DAQ application does not use the 2 DAQ counters then,
you can leave the timebase rate set to 20 MHz (default).
This property can be set either before or after calling
nctConnectTerminals to connect the RTSI_CLK to Master
Timebase. However, this property must always be called prior to
starting the task.
This property is applicable only to PCI and PXI Series 2 cards. For
PCMCIA cards, setting this attribute will return an error. On PXI cards,
u32 nctPropHwTimestampFormat
Sets the format of the timestamps reported by the on-board timer on the
CAN card. The default value for this property is Absolute.
The values for this property are:
0 (Absolute)
Sets the timestamp format to absolute. In the absolute format, the
timestamp returned by NI-CAN read functions is the LabVIEW
date/time format (DBL representing the number of seconds
elapsed since 12:00 a.m., Friday, January 1, 1904).
1 (Relative)
Sets the timestamp format to relative. In the relative format,
the timestamp returned by the NI-CAN read functions will be
zero based (DBL representing the number of seconds since the
CAN controller for that task was started).
A typical use case for this property would be if data received from
two RTSI synchronized CAN cards is to be correlated. For that use
case, this property must be set to 1 for all of the CAN cards being
synchronized. Setting this property on one port of a 2-port card will
also reset the timestamp of the second port, since resetting the
timestamp on the CAN port involves resets the on-board timer.
This property should be set prior to starting any tasks on the CAN card.
u32 nctPropIntfBaudRate
Sets the baud rate in use by the Interface.
This property applies to all tasks initialized with the interface.
You can specify the following basic baud rates as the numeric rate:
33333, 83333, 100000, 125000, 200000, 250000, 400000, 500000,
800000, and 1000000.
You can specify advanced baud rates as 8000XXYY hex, where YY is
the value of Bit Timing Register 0 (BTR0), and XX is the value of Bit
Timing Register 1 (BTR1). For more information, refer to the Port
Properties dialog in MAX.
The value of this property is originally set within MAX, but it can be
changed using nctSetProperty.
u32 nctPropIntfListenOnly
Sets a Boolean value that indicates whether the listen only feature of
the Philips SJA1000 CAN controller is enabled (1) or disabled (0).
This property applies to all tasks initialized with the Interface.
If nctPropIntfListenOnly is 0, the Interface can transmit CAN
messages; therefore the nctWrite function operates normally. When
CAN messages are received by the Interface, those messages are
acknowledged. Because disabled (0) is the behavior specified in the
CAN specification, it is the default value of
nctPropIntfListenOnly.
If nctPropIntfListenOnly is 1, the Interface cannot transmit
CAN messages; therefore the nctWrite function returns an error.
When CAN messages are received by the Interface, those messages are
not acknowledged. The Philips SJA1000 CAN controller enters error
passive state when listen only is enabled (but no error-passive warning
is returned). The enabled (1) value of nctPropIntfListenOnly
enables passive monitoring of network traffic, which can be useful for
debugging scenarios in which only one device exists on the network.
Since the listen only feature requires the Philips STA1000 CAN
controller, this property is supported on Series 2 NI CAN hardware
only. If you are using Series 1 NI CAN hardware, an attempt to set this
property returns error code CanErrRequiresSeries2.
u32 nctPropIntfSelfReception
Specifies whether to echo successfully transmitted CAN frames as
received frames. Each reception occurs just as if the frame were
received from another CAN device. This enables you to initialize the
same channels for both input and output.
For self reception to operate properly, another CAN node must receive
and acknowledge each transmit.
False disables self reception mode (default), and True enables self
reception mode.
The self reception mode is not available on the Intel 82527 CAN
controller used by Series 1 CAN hardware. For Series 1 hardware,
this property must be left at its default (False).
u32 nctPropIntfSeries2Comp
Specifies the filter comparator for the Philips SJA1000 CAN controller
on all Series 2 CAN hardware. This property is not supported for
Series 1 hardware (returns error).
u32 nctPropIntfSeries2FilterMode
All Series 2 hardware uses the Philips SJA1000 CAN controller. The
Philips SJA1000 CAN controller provides sophisticated filtering of
received frames. This property specifies the filtering mode, which is
used in conjunction with the nctPropIntfSeries2Mask and
nctPropIntfSeries2Comp properties.
This property is not supported for Series 1 hardware (returns error).
Since the format of the Series 2 filters is very specific to the Philips
SJA1000 CAN controller, National Instruments cannot guarantee
compatibility for this property on future hardware series. When using
this property in the application, it is best to get the nctPropHwSeries
property to verify that the CAN hardware is Series 2.
The filtering specified by the Series 2 filter properties applies to all
input tasks for that interface. For example, if you specify filters that
discard ID 5, then open an Input task to receive channels of ID 5,
the task will not receive data. The default value for this property is
nctFilterSingleStandard.
The values for this property are summarized below. For detailed
information on each value, including the format of the
nctPropIntfSeries2Mask and nctPropIntfSeries2Comp
properties for each mode, refer to the
NC_ATTR_SERIES2_FILTER_MODE attribute in the ncConfig
function of the Frame API.
nctFilterSingleStandard (Single Standard)
Filter all standard (11-bit) frames using a single mask/comparator
filter.
nctFilterSingleExtended (Single Extended)
Filter all extended (29-bit) frames using a single mask/comparator
filter.
u32 nctPropIntfSeries2Mask
Specifies the filter mask for the Philips SJA1000 CAN controller on all
Series 2 CAN hardware. This property is not supported for Series 1
hardware (returns error).
This property specifies a bit mask that determines the ID, RTR, and
data bits that are compared. If a bit is clear in the mask, the
corresponding bit in the nctPropIntfSeries2Comp is checked. If a
bit in the mask is set, that bit is ignored for the purpose of filtering
(don’t care).
The default value of this property is hex FFFFFFFF, which means that
all messages are received.
The mapping of bits in this property to the ID, RTR, and data bits of
incoming frames is determined by the value of the
nctPropIntfSeries2FilterMode property. The Series 2 filter
mode determines the format of this property as well as the Series 2
comparator.
u32 nctPropIntfSingleShotTx
Specifies whether to retry failed CAN frame transmissions (Series 2
only).
If nctPropIntfSingleShotTx is 0 (default), failed transmissions
retry as defined in the CAN specification. If a CAN frame is not
transmitted successfully, the CAN controller will immediately retry.
If nctPropIntfSingleShotTx is 1, all transmissions are single
shot. If a CAN frame is not transmitted successfully, the CAN
controller will not retry.
The single-shot transmit feature is not available on the Intel 82527
CAN controller used by Series 1 CAN hardware (returns error).
u32 nctPropIntfTransceiverExternalOut
Sets the transceiver external outputs for the interface that was
initialized for the task.
Series 2 XS cards enable connection of an external transceiver. For an
external transceiver, this property allows you to set the output voltage
on the MODE0 and MODE1 pins of the CAN port, and it allows you
control the sleep mode of the on-board CAN controller chip.
For many models of CAN transceiver, EN and NSTB pins control the
transceiver mode, such as whether the transceiver is sleeping, or
communicating normally. For such transceivers, you can wire the EN
and NSTB pins to the MODE0 and MODE1 pins of the CAN port.
The default value of this property is 00000003 hex. For many models
of transceiver, this specifies normal communication mode for the
transceiver and CAN controller chip. If the transceiver requires a
different MODE0/MODE1 combination for normal mode, you can use
external inverters to change the default 5 V to 0 V.
This property is supported for Series 2 XS cards only. This property is
not supported when the nctPropIntfTransceiverType property is
any value other than External. To control the mode of an internal
transceiver, use the nctPropIntfTransceiverMode property.
This property uses a bit mask. Use bitwise OR operations to set
multiple values.
nctTransceiverOutMode0 (00000001 hex, MODEO pin)
Set this bit to drive 5 V on the MODE0 pin. This is the default
value. This bit is set automatically when a remote wakeup is
detected.
Clear this bit to drive 0 V on the MODE0 pin.
nctTransceiverOutMode1 (00000001 hex, MODE1 pin)
Set this bit to drive 5 V on the MODE1 pin. This is the default
value. This bit is set automatically when a remote wakeup is
detected.
Clear this bit to drive 0 V on the MODE1 pin.
nctTransceiverOutSleep (00000100 hex, Sleep CAN
controller chip)
Set this bit to place the CAN controller chip into sleep mode.
This bit controls the mode of the CAN controller chip (sleep
or normal), and the independent MODE0/MODE1 bits
control the mode of the external transceiver. When you set
this bit to place the CAN controller into sleep mode, you
u32 nctPropIntfTransceiverMode
Sets the transceiver mode for the interface that was initialized for the
task. The transceiver mode controls whether the transceiver is asleep
or communicating, as well as other special modes.
This property is supported on Series 2 cards only.
For Series 2 cards for the PCMCIA form factor, this property requires
a corresponding Series 2 cable (dongle). For information on how to
identify the series of the PCMCIA cable, refer to the Series 2 Vs.
Series 1 section of Chapter 1, Introduction.
For Series 2 XS cards, this property is not supported when the
nctPropIntfTransceiverType property is External. To control
the mode of an external transceiver, use the
nctPropIntfTransceiverExternalOut property.
The default value for this property is Normal.
This property uses the following values:
nctTransceiverModeNormal
Set transceiver to normal communication mode. If you set Sleep
mode previously, this performs a local wakeup of the transceiver
and CAN controller chip.
nctTransceiverModeSleep
Set transceiver and the CAN controller chip to sleep (or standby)
mode.
nctTransceiverModeSWWakeup
Set Single Wire transceiver to Wakeup Transmission mode.
This mode is supported on Single Wire (SW) ports only.
The Single Wire Wakeup Transmission mode drives a higher
voltage level on the network to wakeup all sleeping nodes. Other
than this higher voltage, this mode is similar to Normal mode.
CAN frames can be received and transmitted normally.
Since you use the Single Wire Wakeup mode to wakeup other
nodes on the network, it is not typically used in combination with
Sleep mode for a given interface.
The timing of how long the wakeup voltage is driven is controlled
entirely by the application. The application will typically change
to Single Wire Wakeup mode, transmit a wakeup frame, then
return to Normal mode.
The following sequence demonstrates a typical sequence of steps
for sleep and wakeup between two Single Wire NI CAN
interfaces. The sequence assumes that CAN0 is the sleeping node,
and CAN1 originates the wakeup.
1. Start both CAN0 and CAN1. Both use the default Normal mode.
2. Set nctPropIntfTransceiverMode of CAN0 to Sleep.
3. Set nctPropIntfTransceiverMode of CAN1 to Single Wire
Wakeup.
4. Write data to CAN1 to transmit a wakeup frame to CAN0.
5. Set nctPropIntfTransceiverMode of CAN1 to Normal.
6. Now both CAN0 and CAN1 are in Normal mode again.
nctTransceiverModeSWHighSpeed
Set Single Wire transceiver to High-Speed Transmission mode.
This mode is supported on Single Wire (SW) ports only.
The Single Wire High-Speed Transmission mode disables the
internal waveshaping function of the transceiver, which allows
baud rates up to 100 kbytes/s to be used. The disadvantage versus
Normal (which allows up to 40 kbytes/s baud) is degraded EMC
performance. Other than the disabled waveshaping, this mode is
similar to Normal mode. CAN frames can be received and
transmitted normally.
u32 nctPropIntfTransceiverType
For XS software selectable physical layer cards that provide a
software-switchable transceiver, the
nctPropIntfTransceiverType property sets the type of
transceiver. When the transceiver is switched from one type to another,
NI-CAN ensures that the switch is undetectable from the perspective
of other nodes on the network.
The default value for this property is specified within MAX. If you
change the transceiver type in MAX to correspond to the network in
use, you can avoid setting this property within the application.
This property applies to all tasks initialized with the same interface.
You cannot set this property for Series 1 hardware, or for Series 2
hardware other than XS (fixed HS, LS, or SW cards).
This property uses the following values:
nctTransceiverTypeHS
Switch the transceiver to High-Speed (HS).
nctTransceiverTypeLS
Switch the transceiver to Low-Speed/Fault-Tolerant (LS).
nctTransceiverTypeSW
Switch the transceiver to Single Wire (SW).
nctTransceiverTypeExternal
Switch the transceiver to External. The External type allows you
to connect a transceiver externally to the interface. For more
information on connecting transceivers externally, refer to
Chapter 3, NI CAN and LIN Hardware.
When this transceiver type is selected, you can use the
nctPropIntfTransceiverExternalOut and
nctPropIntfTransceiverExternalIn properties to access
the external mode and status pins of the connector.
nctTransceiverTypeDisconnect
Disconnect the CAN controller chip from the connector. This
value is used when you physically switch an external transceiver.
You first set nctPropIntfTransceiverType to
nctTransceiverTypeDisconnect, then switch from one
external transceiver to another, then set
nctPropIntfTransceiverType to
nctTransceiverTypeExternal. For more information on
connecting transceivers externally, refer to Chapter 3, NI CAN
and LIN Hardware.
u32 nctPropIntfVirtualBusTiming
Sets the Virtual Bus Timing of the virtual device.
The values for this property are:
FALSE (0)
Virtual Bus Timing is turned off. By turning Virtual Bus Timing
off, the CAN bus simulation is disabled and CAN frames are
copied from the write queue of one virtual interface to the read
queue of the second virtual interface. This setting is useful if you
desire to only convert frames to channels or vice versa and not
simulate actual CAN bus communication.
TRUE (1)
Virtual Bus Timing is turned on (default). By turning Virtual Bus
Timing on, frame timestamps are recalculated as they transfer
across the virtual bus. This mode is useful when you want the
virtual bus to behave as much like a real bus as possible.
If this property is set on real hardware, an error will be returned.
The Virtual Bus Timing has to be set to the same value on both
virtual interfaces. This property must be set prior to starting the
virtual interface.
Refer to the Frame to Channel Conversion section of Chapter 6,
Using the Channel API for more information.
u32 nctPropMsgDistribution
Sets the nctPropMsgDistribution property which is used to
determine if the CAN frames associated with a group of mode
dependent channels are sent even-spaced or in burst mode.
nctDistrUniform
Transmits mode dependent messages uniformly (evenly spaced)
on the network.
nctDistrBurst
Transmits mode dependent messages back to back on the network.
This property applies only to mode dependent channels that are
transmitted periodically. For more information, refer to the Mode
Dependent Channels section of Chapter 6, Using the Channel API.
f64 nctPropNoValue
Sets the value that is returned on timestamped read for mode
dependent channels that have not been received with the most recent
CAN frame associated with the CAN message. This property applies
only to mode dependent channels that are read with the timestamped
read operation. For more information, refer to the Mode Dependent
Channels section of Chapter 6, Using the Channel API.
f64 nctPropTimeout
Sets a time in milliseconds to wait for samples. The default value is
zero.
For all task configurations, nctPropTimeout specifies the time that
Read will wait for the start trigger. If the application does not use
nctConnectTerminals, the start trigger occurs when the task starts
(nctStart). If you connect a start trigger from a RTSI line or other
source, nctPropTimeout specifies the number of milliseconds to
wait. nctPropTimeout of zero means to wait up to 10 seconds for the
start trigger.
Usage of the nctPropTimeout property depends on the initialized
mode of the task:
• NctModeOutput: For each NctModeOutput task, NI-CAN uses a
buffer to store samples for transmit. If the number of samples you
provide to nctWrite exceeds the size of the underlying buffer,
NI-CAN waits for sufficient space to become available (due to
successful transmits). The nctPropTimeout specifies the number of
milliseconds to wait for available buffer space. Timeout of zero means
to wait up to 10 seconds.
• NctModeInput: The timeout value does not apply. For
NctModeInput tasks initialized with SampleRate greater than zero,
the NumberOfSamplesToRead input to nctRead implicitly specifies
the time to wait. For NctModeInput tasks initialized with
SampleRate equal to zero, the nctRead function always returns
available samples immediately, without waiting.
nctStart
Purpose
Start communication for the specified task.
Format
nctTypeStatus nctStart(
nctTypeTaskRef TaskRef,
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from functions such as nctInitialize or
nctCreateMessage.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
You must start communication for a task to use nctRead or nctWrite. After you start
communication, you can no longer change the configuration of the task with
nctSetProperty or nctConnectTerminals.
nctStop
Purpose
Stop communication for the specified task.
Format
nctTypeStatus nctStop(
nctTypeTaskRef TaskRef,
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
This function stops communication so you can change the configuration of the task, such as
by using nctSetProperty or nctConnectTerminals. After you change the
configuration, use nctStart to start again.
This function does not clear the configuration for the task; therefore, do not use it as the last
NI-CAN function in the application. The nctClear function must always be used as the last
NI-CAN function for each task.
nctWrite
Purpose
Write samples to a CAN task initialized as NctModeOutput. Samples are placed into
transmitted CAN messages. For an overview of nctWrite, refer to the Write section of
Chapter 6, Using the Channel API.
Format
nctTypeStatus nctWrite(
nctTypeTaskRef TaskRef,
u32 NumberOfSamplesToWrite,
f64 *SampleArray);
Inputs
TaskRef
Task reference from the previous NI-CAN function. The task reference
is originally returned from nctInitStart, nctInitialize, or
nctCreateMessage.
The Mode initialized for the task must be NctModeOutput.
NumberOfSamplesToWrite
Specifies the number of samples to write for the task.
For single-sample output, pass 1 to this parameter.
SampleArray
Provides an array of arrays (2D array), one array for each channel
initialized in the task. The array of each channel must have
NumberOfSamplesToWrite samples.
For example, if you call nctInitStart with ChannelList of
mych1,mych2,mych3, then call nctWrite with
NumberOfSamplesToWrite of 10, SampleArray must be allocated
as:
f64 SampleArray[3][10];
You must provide a valid sample value in each entry of the arrays.
The order of channel entries in SampleArray is the same as the order
in the original channel list.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value. The ncStatusToString and ncGetHardwareInfo functions are the only
Frame API functions that can be called within a Channel API application.
Description
The associated ChannelList determines the messages transmitted by nctWrite. If all
channels are contained in a single message, only that message is transmitted. If a few channels
are contained in one message, and the remaining channels are contained in a second message,
then two messages are transmitted.
If the initialized sample rate is greater than zero, the task transmits associated CAN messages
periodically at the specified rate. The first nctWrite transmits associated messages
immediately using the first sample in the array of each channel, and then begins a periodic
timer at the specified rate. Each subsequent transmission of messages is based on the timer,
and uses the next sample in the array of each channel. After the final sample in the array of
each channel has been transmitted, subsequent behavior is determined by the
nctPropBehavAfterFinalOut property. The default nctPropBehavAfterFinalOut
behavior is to retransmit the final sample each period until nctWrite is called again.
If the initialized SampleRate is zero, the task transmits associated messages immediately for
each entry in the array of each channel, with as little delay as possible between messages.
After the message for the final sample is transmitted, no further transmissions occur until
nctWrite is called again, regardless of the nctPropBehavAfterFinalOut property.
Because all channels of a message are transmitted on the network as a unit, nctWrite
enforces the following rules:
• You cannot write the same message in more than one NctModeOutput task.
• You can write more than one message in a single NctModeOutput task.
• You can write a subset of channels for a message in a single NctModeOutput task.
For channels that are not included in the task, the channel default value
(nctPropChanDefaultValue) is transmitted in the CAN message.
You use the CAN Network 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 frames from this read queue using the ncRead or
ncReadMult function. The read functions provide a timestamp of when
the frame was received, the arbitration ID of the frame, the type of frame
(data, remote, or RTSI), the data length, and the data bytes. You also can
use the CAN Network Interface Object to write CAN frames using the
ncWrite function.
Some possible uses for the CAN Network Interface Object include the
following:
• You can use the read queue to log all CAN frames transferred across
the network. This log is useful when you need to view CAN traffic to
verify that all CAN devices are functioning properly.
• You can use the write queue to transmit a sequence of CAN frames in
quick succession.
• You can read and write CAN frames for access to configuration
settings within a device. Because such settings generally are not
In general, you use CAN Network Interface Objects for situations in which
you need to transfer arbitrary CAN frames.
You can retrieve LIN frames from this read queue using the ncRead or
ncReadMult function. The read functions provide a timestamp of when
the frame was received, the arbitration ID of the frame, the type of frame
(full, bus inactive, wakeup received, or bus error), the data length, and the
data bytes. You also can use the LIN Network Interface Object to write any
of three NI LIN frame types (response entry, header, or full), using the
ncWrite or ncWriteMult function.
Some possible uses for the LIN Network Interface Object include the
following:
• You can use the read queue and the LIN device in slave mode, to log
all LIN frames transferred across the network. This log is useful when
you need to view LIN traffic to verify that all LIN devices are
functioning properly.
• You can use the write and read queues and the LIN device in slave
mode, to emulate one or more slave nodes.
• You can use the write queue and the LIN device in master mode,
to transmit a sequence of LIN frames in quick succession.
• You can loop individual writes with a variable delay between each, and
the LIN device in master mode, to emulate LIN descriptor file (LDF)
control of scheduling of LIN traffic.
In general, you use CAN Objects for data transfer for a specific arbitration
ID, especially when that data transfer needs to occur periodically.
START
Configure Object
Are All No
Objects Configured?
Yes
Are All No
Objects Open?
Yes
Finished No
CAN Programming?
Yes
Are All No
Objects Closed?
Yes
END
1. Configure Objects.
Prior to opening the objects used in the application, you must configure
the objects with their initial attribute settings. Each object is
configured within the application by calling the ncConfig function.
This function takes the name of the object to configure, along with a
list of configuration attribute settings.
2. Open Objects.
You must call the ncOpen function to open each object you use within
the application.
The ncOpen function returns a handle for use in all subsequent Frame
API calls for that object. When you are using the LabVIEW function
library, this handle is passed through the upper left and right terminals
of each Frame API function used after the open.
3. Start Communication.
You must start communication on the CAN network before you can
use the objects to transfer data.
If you configured the CAN Network Interface Object to start on open,
that object and all of its higher level CAN Objects are started
automatically by the ncOpen function, so nothing special is required
for this step.
If you disabled the start-on-open attribute, when the application is
ready to start communication, use the CAN Network Interface Object
to call the ncAction function with the Opcode parameter set to
NC_OP_START. This call is often useful when you want to use
ncWrite to place outgoing data in write queues prior to starting
communication. This call is also useful in high bus load situations,
because it is more efficient to start communication after all objects
have been opened.
4. Communicate Using Objects
After you open the objects and start communication, you are ready to
transfer data on the CAN network. The manner in which data is
transferred depends on the configuration of the objects you are using.
For this example, assume that you are communicating with a CAN
device that periodically transmits a data frame. To receive this data,
assume that a CAN Object is configured to watch for data frames
received for its arbitration ID and store that data in its read queue.
4a. Wait for Available Data
To wait for the arrival of a data frame from the device, you can call
ncWaitForState with the DesiredState parameter set to
NC_ST_READ_AVAIL. The NC_ST_READ_AVAIL state tells you that
data for the CAN Object has been received from the network and
placed into the read queue of the object.
When receiving data from the device, if the only requirement is to
obtain the most recent data, you are not required to wait for the
NC_ST_READ_AVAIL state. If this is the case, you can set the read
queue length of the CAN Object to zero during configuration, so that
it only holds the most recent data bytes. Then you can use the ncRead
function as needed to obtain the most recent data bytes received.
4b. Read Data
Read the data bytes using ncRead. For CAN Objects that receive data
frames, ncRead returns a timestamp of when the data was received,
followed by the actual data bytes (the number of which you configured
in step 1).
Steps 4a and 4b should be repeated for each data value you want to
read from the CAN device.
5. Close Objects.
When you are finished accessing the CAN devices, close all objects
using the ncClose function before you exit the application.
Start
Are all
No
attributes
set?
Yes
Finished LIN No
Programming?
Yes
End
Start
Are all
No
attributes
set?
Yes
Write to the master task and read from the slave task using the
Network Interface Object
• Write NI LIN header frame type (ncWriteNet)
• Wait for reception of a full LIN Frame
(ncWaitForState--Read Available)
• Read resulting NI LIN full frame type (cnReadNet)
• Insert delay for this ID as specified in the LDF
Update
Yes
response
entry(s)?
No
No Finished LIN
Programming?
Yes
End
Figure 9-3. Frame API – LIN interface emulating a master executing the
behavior specified in an LDF
Start
Are all
No
attributes
set?
Yes
Read from the slave task using the Network Interface Object
• Wait for reception of a full LIN frame
(ncWaitForState--Read Available)
• Read NI LIN full frame type(s) (ncWriteNet or ncWriteNetMult)
resulting from reception of master headers
Update
Yes
response
entry(s)?
No
No Finished LIN
Programming?
Yes
End
5. Read from the slave task using the Network Interface Object
As the external master issues headers, the LIN interface slave task will
either subscribe to data or publish data in response to each. Each time
the slave task subscribes to data in response, it will combine the header
and response into a single full frame type which is placed into the read
queue. If self-reception is enabled, then each time the slave task
publishes data in response, it will combine the header and response
into a single full frame type which is placed into the read queue. If log
bus errors is enabled, then the first bus error that occurs within the
header or response portion of each LIN frame will be placed into a bus
error frame and loaded into the read queue. The LIN interface slave
task will ignore the remainder of the frame transaction on the bus and
prepare for the reception of the next header. The loading of the full or
bus error frame into the read queue will set a read available flag in the
interface. ncWaitForState should be used to wait for read available
before executing the ncRead or ncReadMult function.
Typically, slave devices that publish data update it as a result of a
change in one or more inputs. Response entries within the LIN
interface slave task response queue may be updated at any point to
emulate this behavior. Steps 4 and 5 should be repeated as necessary to
create the desired slave behavior.
6. Stop communication.
Stop communication on the LIN bus before closing the Network
Interface Object.
7. Close the Network Interface Object.
When you are finished accessing the LIN bus, close the Network
Interface Object using the ncCloseObject function before you exit
the application.
Start
Are all
No
attributes
set?
Yes
Read from the slave task using the Network Interface Object
• Read resulting NI LIN full frame type (ncReadNet)
Finished LIN No
Programming?
Yes
End
5. Read from the slave task using the Network Interface Object.
If the slave device is working as expected, it will subscribe to data in
response to the header transmitted in step 4. The NI LIN interface slave
task will publish data in response and, if self-reception is enabled,
combine the header and response data into a full frame type to be
logged in the read queue. If the slave device is not working as expected
(perhaps it publishes in response to the header, in which case there is a
collision on the LIN), the resulting bus error frame will be placed into
the read queue, since logging of bus errors has been enabled. Steps 4
and 5 should be repeated for each data set you want to write to the slave
device.
6. Stop communication.
Stop communication on the LIN bus before closing the Network
Interface Object.
7. Close the Network Interface Object.
When you are finished accessing the LIN bus, close the Network
Interface Object using the ncCloseObject function before you exit
the application.
Start
Are all
No
attributes
set?
Yes
Read from the slave task using the Network Interface Object
• Wait for reception of a full LIN frame
(ncWaitForState--Read Available)
• Read resulting NI LIN full frame type (ncReadNet)
Finished LIN No
Programming?
Yes
End
Figure 9-7, Frame API – LIN interface sleep and wakeup behavior, shows
how to implement sleep and wakeup behavior when the interface is acting
as either a master or slave device. The flowchart assumes that an interface
has been opened, the desired attribute values have been initialized, it has
been started, and ncWaitForState (to check for read available) combined
with ncReadNet or ncReadNetMult, are being used to read frames from
the bus.
Start
No
Bus inactive
No frame or full frame containing Yes Do you
sleep request message received want the LIN interface to
(ncReadNet, go to sleep?
ncReadNetMult)?
Yes
Figure 9-7. Frame API – LIN interface sleep and wakeup behavior
RTSI
The Frame API provides RTSI features that are lower level than the
synchronization features of the Channel API. The following list describes
some of the more commonly used RTSI features in the Frame API.
• You can configure the CAN Network Interface Object to log a special
RTSI frame into the read queue when a RTSI input transitions from
low to high. This RTSI frame is timestamped, so you can use it to
analyze the time of the RTSI pulse relative to the CAN frames on the
network.
• You can configure the CAN Object to generate a RTSI output pulse
when its ID is received. This allows you to trigger other products based
on the reception of a specific CAN frame.
• You can configure the CAN Object to transmit a CAN frame when a
RTSI input transitions from low to high. This allows you to transmit
based on a functional unit in another product, such as a counter in an
NI-DAQ or NI-DAQmx E Series MIO product.
• You can use ncConnectTerminals and the Timestamp Format
attribute to synchronize multiple CAN cards by connecting timebases
and start triggers. The ncConnectTerminals function provides
additional RTSI features that can be used in conjunction with the
object-based RTSI features described above.
Remote Frames
The Frame API has extensive features to transmit and receive remote
frames. The following list describes some of the more commonly used
remote frame features in the Frame API.
• The CAN Network Interface Object can transmit arbitrary remote
frames.
• If you are using Series 2 hardware or later, the CAN Network Interface
Object can receive remote frames, such as to monitor bus traffic. Series
1 hardware uses the Intel 82527 CAN controller, which cannot receive
arbitrary remote frames.
Using Queues
To maintain an ordered history of data transfers, NI-CAN supports the use
of queues, also known as FIFO (first-in-first-out) buffers. The basic
behavior of such queues is common to all NI-CAN objects.
There are two basic types of NI-CAN queues: the read queue and the write
queue. NI-CAN uses the read queue to store incoming network data items
in the order they arrive. You access the read queue using ncRead to obtain
the data. 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 Transitions
The NC_ST_READ_AVAIL state transitions from false to true when NI-CAN
places a new data item into an empty read queue, and remains true until you
read the last data item from the queue and the queue is empty.
Empty Queues
For both read and write queues, the behavior for reading an empty queue is
similar. When you read an empty queue, the previous data item is returned
again. For example, if you call ncRead when NC_ST_READ_AVAIL is false,
the data from the previous call to ncRead is returned again, along with the
CanWarnOldData warning. If no data item has yet arrived for the read
queue, a default data item is returned, which consists of all zeros. You
should generally wait for NC_ST_READ_AVAIL prior to the first call to
ncRead.
Full Queues
For both read and write queues, the behavior for writing a full queue
is similar. When you write a full queue, NI-CAN returns the
CanErrOverflowWrite error code. For example, if you write too many
data items to a write queue, the ncWrite function eventually returns the
overflow error.
Disabling Queues
If you do not need a complete history of all data items, you can disable the
read queue and/or write queue by setting its length to zero. Zero length
queues are typically used only with CAN objects, not the CAN Network
Interface Object. Using zero length queues generally saves memory, and
often results in better performance. When a new data item arrives for a zero
length queue, it overwrites the previous item without indicating 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 the read
buffer, the NC_ST_READ_AVAIL state becomes true until the data item is
read. If you only want the most recent data, you can ignore the
NC_ST_READ_AVAIL state, as well as the CanWarnOldData warning
returned by ncRead.
When one or more CAN Objects are open, the CAN Network Interface
Object cannot receive frames which would normally be handled by the
CAN Objects. The following flowchart shows the steps performed by the
Frame API when a CAN frame is received.
Frame Received
Arbitration ID
Handled by an Open CAN Object Uses Frame
CAN Object? Yes
Standard or
Extended Frame?
Standard Extended
Standard Extended
Comparator Disabled? Comparator Disabled?
Frame Ignored (NC_CAN_ARBID_NONE) (NC_CAN_ARBID_NONE) Frame Ignored
Yes Yes
No No
Apply Standard Mask Apply Extended Mask
Masked Masked
Arbitration ID Arbitration ID
Frame Ignored Equal to Standard Equal to Extended Frame Ignored
No Comparator? Comparator? No
Yes Yes
Use the ncWaitForState function when the application must wait for a
specific state before proceeding. For example, if you call ncWrite to write
a frame, and the application cannot proceed until the frame is successfully
transmitted, you can call ncWaitForState to wait for
NC_ST_WRITE_SUCCESS.
There is no concept of master and slave in CAN. Any device may transmit
data or remote frames at any time. Collisions are acceptable and resolved
by ID prioritization. When a data or remote frame is transmitted, the full
frame is transmitted by the sender. In contrast, a single LIN master task is
responsible for initiating all frame transfers. The master task only sends the
first part of the frame (the header) with the expectation that a slave task will
complete the frame (by publishing a response). CAN provides advanced
mechanisms for reporting multiple errors within a single frame,
incrementing or decrementing error counters, and entering various error
states (bus off, for example). In contrast, LIN error handling is a single-shot
process. Upon encountering the first error in a frame, the LIN slave device
reports the error, ignores the remainder of the frame, and prepares for
reception of the next header from the master task.
Unless otherwise stated, each NI-CAN VI suspends execution of the calling thread until it
completes.
Section Headings
The following are section headings found in the Frame API for LabVIEW VIs.
Purpose
Each VI description includes a brief statement of the purpose of the VI.
Format
The format section describes the format of each VI.
Description
The description section gives details about the purpose and effect of each VI.
CAN Object
The CAN Object section gives details about using the VI with the CAN Object.
List of VIs
Table 10-1 is an alphabetical list of the NI-CAN VIs for the Frame API.
Function Purpose
ncAction.vi Perform an action on an object.
ncClose.vi Close an object.
ncConfigCANNet.vi Configure a CAN Network Interface Object before
opening it.
ncConfigCANNetRTSI.vi Configure a CAN Network Interface Object with
RTSI features.
ncConfigCANObj.vi Configure a CAN Object before using it.
ncConfigCANObjRTSI.vi Configure a CAN Object with RTSI features.
ncConnectTerminals.vi Connect terminals in the CAN or LIN hardware.
ncDisconnectTerminals.vi Disconnect terminals in the CAN or LIN hardware.
ncGetAttr.vi Get the value of an object attribute.
ncGetHardwareInfo.vi Get NI-CAN hardware information.
ncGetTimer.vi Get the absolute timestamp attribute.
ncOpen.vi Open an object.
ncReadNet.vi Read single frame from a CAN or LIN Network
Interface Object.
ncReadNetMult.vi Read multiple frames from a CAN or LIN Network
Interface Object.
ncReadObj.vi Read single frame from a CAN Object.
ncReadObjMult.vi Read multiple frames from a CAN Object.
ncSetAttr.vi Set the value of an object attribute.
ncWaitForState.vi Wait for one or more states to occur in an object.
ncWriteNet.vi Write a single frame to a CAN or LIN Network
Interface Object.
Function Purpose
ncWriteNetMult.vi Write multiple frames to a CAN or LIN Network
Interface Object.
ncWriteObj.vi Write a single frame to a CAN Object.
ncAction.vi
Purpose
Perform an action on an object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI.
The handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Description
ncAction.vi is a general purpose VI you can use to perform an action on the object specified
by ObjHandle in. Its normal use is to start and stop network communication on a CAN
Network Interface Object.
NI-CAN provides VIs such as ncOpen.vi and ncReadNet.vi for the most frequently used
and/or complex actions. ncAction.vi provides an easy, general purpose way to perform
actions that are used less frequently or are relatively simple.
Table 10-2, Actions Supported By A CAN or LIN Network Interface Object, describes the
actions supported by the CAN or LIN Network Interface Object.
CAN Object
All actions performed on a CAN Object affect that CAN Object alone, and do not affect other
CAN Objects or communication as a whole. Table 10-3, Actions Supported By A CAN Object,
describes the actions supported by the CAN Object.
ncClose.vi
Purpose
Close an object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
ncClose.vi closes an object when it no longer needs to be in use, such as when the application
is about to exit. When an object is closed, NI-CAN stops all pending operations and clears all
configuration for the object (including RTSI). The application can no longer use that specific
ObjHandle in.
Unlike other NI-CAN VIs, this VI always closes the object, regardless of the Status in
Error In.
CAN Object
ObjHandle in refers to an open CAN Object.
ncConfigCANNet.vi
Purpose
Configure a CAN Network Interface Object before opening it.
Format
Input
ObjName is the name of the CAN Network Interface Object to configure.
This name uses the syntax “CANx”, where x is a decimal number starting
at zero that indicates the CAN network interface (CAN0, CAN1, up to
CAN63). CAN network interface names are associated with physical CAN
ports using the Measurement and Automation Explorer (MAX).
The Frame API and Channel API cannot use the same CAN network
interface simultaneously. If the CAN network interface is already
initialized in the Channel API, this function returns an error.
The special interface values 256 and 257 refer to virtual interfaces. For
virtual interfaces, the only valid attribute is Start On Open. All other
attributes in the config cluster are ignored. The mask and comparator
attributes are always zero for virtual interfaces (receive all frames).
The 847x and 847x with Sync series LIN interfaces do not support
ncConfigCANNet.vi.
Baud Rate is the baud rate to use for communication. Basic baud
rates are supported, including 33333, 83333, 100000, 125000,
250000, 500000, and 1000000. If you are familiar with the
Bit Timing registers used in CAN controllers, you can use a
special hexadecimal baud rate of 0x8000zzyy, where yy is the
desired value for register 0 (BTR0), and zz is the desired value for
register 1 (BTR1) of the CAN controller.
For the Frame API, the Baud Rate has no relationship with the
baud rate property in MAX. You must always configure the Baud
Rate with ncConfigCANNet.vi.
The internal read queue exists between the CAN hardware and the
NI-CAN device driver. This internal read queue holds frames
temporarily prior to transfer a larger queue in the NI-CAN device
driver. The larger NI-CAN device driver queue grows as needed in
order to accommodate high bus loads.
The internal write queue exists between the CAN hardware and
the NI-CAN driver. This internal write queue holds frames
temporarily prior to transfer to CAN hardware from a larger queue
in the NI-CAN device driver.
Output
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
The Network Interface provides read/write access to all IDs on the network.
If you intend to use RTSI features to synchronize the Network Interface with other National
Instruments cards, refer to ncConfigCANNetRTSI.vi.
If you need to log transceiver fault indications to the Network Interface read queue, refer to
the Log Comm Warnings attribute of ncSetAttr.vi
For the 847x and 847x with Sync series CAN interfaces, only Start On Open and Baud Rate
are valid configuration attributes.
The 847x and 847x with Sync series LIN interfaces do not support ncConfigCANNet.vi.
ncConfigCANNetRTSI.vi
Purpose
Configure a CAN Network Interface Object with RTSI features.
Format
Input
ObjName is the name of the CAN Network Interface Object to configure.
This name uses the syntax “CANx”, where x is a decimal number starting
at zero that indicates the CAN network interface (CAN0, CAN1, up to
CAN63). CAN network interface names are associated with physical CAN
ports using the Measurement and Automation Explorer (MAX).
The 847x and 847x with Sync series CAN and LIN interfaces do not
support ncConfigCANNetRTSI.vi.
Disable RTSI
Disables RTSI behavior for the Network Interface. All other RTSI
attributes are ignored. Using this mode is equivalent to calling
ncConfigCANNet.vi.
Note When you configure a DAQ card to pulse the RTSI signal periodically, do not exceed
1000 Hertz (pulse every millisecond). If the RTSI input is pulsed faster than 1kHz on a
consistent basis, CAN performance will be adversely affected (for example, lost data
frames).
RTSI Signal defines the RTSI signal associated with the RTSI
Mode. Valid values are 0 to 6, corresponding to RTSI 0 to RTSI 6
on other National Instruments cards.
Output
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
RTSI is a bus that interconnects National Instruments DAQ, IMAQ, Motion, and CAN boards.
This feature allows synchronization of DAQ, IMAQ, Motion, and CAN boards by allowing
exchange of timing signals. Using RTSI, a device (board) can control one or more slave
devices.
If you are not using RTSI features to synchronize the Network Interface with other National
Instruments cards, refer to ncConfigCANNet.vi.
The 847x and 847x with Sync series LIN interfaces do not support
ncConfigCANNetRTSI.vi.
ncConfigCANObj.vi
Purpose
Configure a CAN Object before using it.
Format
Input
ObjName is the name of the CAN Object to configure. This name uses the
syntax “CANx::STDy” or “CANx::XTDy”. CANx is the name of the CAN
network interface that you used for the preceding ncConfigCANNet.vi.
STD indicates that the CAN Object uses a standard (11-bit) arbitration ID.
XTD indicates that the CAN Object uses an extended (29-bit) arbitration
ID. The number y specifies the actual arbitration ID of the CAN Object.
The number y is decimal by default, but you also can use hexadecimal by
adding 0x to the beginning of the number. For example, “CAN0::STD25”
indicates standard ID 25 decimal on CAN0, and
“CAN1::XTD0x0000F652” indicates extended ID F652 hexadecimal on
CAN1.
The special virtual interface names “CAN256” and “CAN257” are not
supported for CAN Objects.
The 847x and 847x with Sync series CAN and LIN interfaces do not
support ncConfigCANObj.vi.
CAN Object Config provides the core configuration attributes of the CAN
Object. This cluster uses the typedef ncObjAttr.ctl. You can wire in the
cluster by first placing it on the front panel from the NI-CAN Controls
palette, or you can right-click the VI input and select Create Constant or
Create Control.
Receive Unsolicited
Receive data frames for a specific ID.
This type is useful for receiving a few IDs (1-10) into dedicated
read queues. For high performance applications (more IDs, fast
frame rates), the Network Interface is recommended to receive
all IDs.
Period specifies a watchdog timeout, and Receive Changes Only
specifies whether to place duplicate data frames into the read
queue. Transmit by Response is ignored.
Data Length specifies the number of bytes in the data frames for
the ID of the CAN Object. This number is placed in the Data
Length Code (DLC) of all transmitted data frames and remote
frames for the CAN Object. This is also the number of data bytes
returned from ncReadObj.vi when the communication type
indicates receive.
Figure 10-1 shows a CAN Object that periodically transmits data to another CAN Object.
The receiving CAN Object can queue up to five data values.
Response Uses
Most Recent
ncReadObj.vi
Your Write Data Your
Application ncWriteObj.vi Application
ncWriteObj.vi
Figure 10-3 shows a CAN Object that polls data from another CAN Object. NI-CAN
transmits the remote frame periodically and places only changed data into the read queue.
Response Uses
Check For Most Recent
Different Value Write Data
Your Your
Application ncReadObj.vi ncWriteObj.vi Application
Periodic Timer
Output
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
The CAN Object provides read/write access to a specific ID on the network.
You normally call ncConfigCANNet.vi before this VI in order to configure the Network
Interface attributes, then call ncConfigCANObj.vi for each CAN Object desired.
If you intend to use RTSI features to synchronize the CAN Object with other National
Instruments cards, refer to ncConfigCANObjRTSI.vi.
When a network frame is transmitted on a CAN-based network, it always begins with the
arbitration ID. This arbitration ID is primarily used for collision resolution when more than
one frame is transmitted simultaneously, but often is also used as a simple mechanism to
identify data. The CAN arbitration ID, along with its associated data, is referred to as a CAN
Object.
ncConfigCANObjRTSI.vi
Purpose
Configure a CAN Object with RTSI features.
Format
Input
ObjName is the name of the CAN Object to configure. This name uses the
syntax “CANx::STDy” or “CANx::XTDy”. CANx is the name of the CAN
network interface that you used for the preceding ncConfigCANNet.vi VI.
STD indicates that the CAN Object uses a standard (11-bit) arbitration ID.
XTD indicates that the CAN Object uses an extended (29-bit) arbitration
ID. The number y specifies the actual arbitration ID of the CAN Object.
The number y is decimal by default, but you also can use hexadecimal
by adding “0x” to the beginning of the number. For example,
“CAN0::STD25” indicates standard ID 25 decimal on CAN0, and
“CAN1::XTD0x0000F652” indicates extended ID F652 hexadecimal
on CAN1.
The 847x and 847x with Sync series CAN and LIN interfaces do not
support ncConfigCANObjRTSI.vi.
CAN Object Config provides the core configuration attributes of the CAN
Object. This cluster uses the typedef ncObjAttr.ctl. You can wire in the
cluster by first placing it on the front panel from the NI-CAN Controls
palette, or you can right-click the VI input and select Create Constant or
Create Control. (For more information, refer to ncConfigCANObj.vi.)
CAN RTSI Config provides RTSI configuration attributes for the CAN
Object. This cluster uses the typedef ncCANRtsiAttr.ctl. You can wire in
the cluster by first placing it on the front panel from the NI-CAN Controls
palette, or you can right-click the VI input and select Create Constant or
Create Control.
Disable RTSI
Disables RTSI behavior for the CAN Object. All other RTSI
attributes are ignored. Using this mode is equivalent to calling
ncConfigCANObj.vi.
Note When you configure a DAQ card to pulse the RTSI signal periodically, do not exceed
1000 Hertz (pulse every millisecond). If the RTSI input is pulsed faster than 1kHz on a
consistent basis, CAN performance will be adversely affected (for example, lost data
frames).
RTSI Signal defines the RTSI signal associated with the RTSI
Mode. Valid values are 0 to 6, corresponding to RTSI 0 to RTSI 6
on other National Instruments cards.
Output
Error out describes error conditions. If the Error in cluster indicated an
error, the Error out cluster contains the same information. Otherwise,
Error out describes the error status of this VI.
Description
RTSI is a bus that interconnects National Instruments DAQ, IMAQ, Motion, and CAN boards.
This feature allows synchronization of DAQ, IMAQ, Motion, and CAN boards by allowing
exchange of timing signals. Using RTSI, a device (board) can control one or more slave
devices.
If you are not using RTSI features to synchronize the CAN Object with other National
Instruments cards, refer to ncConfigCANObj.vi.
ncConnectTerminals.vi
Purpose
Connect a terminal in the CAN or LIN hardware.
Format
Inputs
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle reference originated from ncOpen.vi.
RTSI7/RTSI Clock
Selects RTSI line 7 as source (input) of the connection. RTSI7 is
dedicated for routing of a timebase. RTSI7 is also known as RTSI
Clock in some National Instruments software products, such as
NI-DAQ.
For PCI and PXI form factors, this receives a 20 MHz (default)
timebase from another CAN or DAQ card. For example, you can
synchronize a CAN and DAQ E Series MIO card by connecting the
20 MHz oscillator (board clock) of the DAQ card to RTSI7/RTSI
PXI_Star
PXI_Star selects the PXI star trigger signal.
Within a PXI chassis, some PXI products can source a star trigger from
Slot 2 to all higher-numbered slots. PXI_Star enables the PXI CAN
card to receive the star trigger when it is in Slot 3 or higher.
This value applies to Series 2 PXI CAN cards only.
PXI_Clk10
PXI_Clk10 selects the PXI 10 MHz backplane clock.
This routes the 10 MHz PXI backplane clock for use as the timebase
of the CAN card. When you use PXI_Clk10 as the timebase for the
CAN card, you must also use PXI_Clk10 as the timebase for other
PXI cards to perform synchronized input/output.
This value applies to Series 2 PXI CAN cards only.
20 MHz Timebase
20 MHz Timebase selects the local oscillator of the CAN or LIN
hardware.
The only valid destination terminal for this source is RTSI7/RTSI
Clock. This routes the local clock of the hardware for use as a timebase
by other NI cards. For example, you can synchronize two CAN cards
by connecting 20 MHz Timebase to RTSI7/RTSI Clock on one CAN
card and then connecting RTSI7/RTSI Clock to Master Timebase on
the other CAN card.
20 MHz Timebase applies to the entire CAN or LIN hardware,
including both interfaces of a 2-port CAN card.
This value applies to Series 2 PXI or PCI CAN cards and 847x with
Sync interfaces only.
For 847x with Sync series CAN and LIN interfaces the internal
oscillator runs at 1 MHz.
10 Hz Resync Clock
10 Hz Resync Clock selects a 10 Hz, 50 percent duty cycle clock. This
slow rate is required for resynchronization of Series 1 CAN cards. On
each pulse of the resync clock, the other CAN card brings its clock into
sync.
By selecting RTSI0 to RTSI6 as the destination terminal, you route
the 10 Hz clock to synchronize with other Series 1 CAN cards.
NI-DAQ or NI-DAQmx cards cannot use the 10 Hz resync clock, so
this selection is limited to synchronization of two or more CAN cards.
10 Hz Resync Clock applies to the entire CAN card, including both
interfaces of a 2-port CAN card.
This value applies to Series 1 and Series 2 CAN cards, but is typically
used with Series 1 CAN cards only. If all of the CAN cards are Series
2, the 20 MHz timebase is preferable due to the lack of drift. If you are
using a mix of Series 1 and Series 2 CAN cards, you must use the
10 Hz Resync Clock.
Start Trigger
Start Trigger selects the start trigger, the event that starts objects.
The start trigger is the same for all tasks using a given interface,
as specified by the ObjName input to ncOpen.vi.
In the default (disconnected) state of the Start Trigger destination, the
start trigger occurs when communication begins on the interface.
By selecting RTSI0 to RTSI6 as the destination terminal, you route
the start trigger of this CAN or LIN hardware to the start trigger of
other CAN, LIN, or DAQ hardware. This ensures that sampling begins
at the same time on both cards. For example, you can synchronize
two CAN cards by routing Start Trigger as the source terminal on
one CAN card and then routing Start Trigger as the destination
terminal on the other CAN card, with both cards using the same
RTSI line for the connections.
RTSI7/RTSI Clock
Selects RTSI line 7 as destination (output) of the connection. RTSI7 is
dedicated for routing of a timebase. RTSI7 is also known as RTSI
Clock in some National Instruments software products, such as
NI-DAQ or NI-DAQmx. Series 2 CAN cards can import a 10 MHz or
20 MHz timebase, but can export only a 20 MHz timebase. 847x with
Sync cards can import 1 MHz, 10 MHz, or 20 MHz timebases, but can
export only a 1 MHz timebase.
Master Timebase
Master Timebase instructs the CAN or LIN hardware to use the
source of the connection as the master timebase. The CAN or LIN
hardware uses this master timebase for input sampling (including
timestamps of received messages) as well as periodic output sampling.
For PCI and PXI form factors, you can use RTSI7/RTSI Clock as the
source terminal. By default this receives a 20 MHz timebase from
another CAN or DAQ card. For example, you can synchronize a CAN
and DAQ E Series MIO card by connecting the 20 MHz oscillator
(board clock) of the DAQ card to RTSI7/RTSI Clock, and then
connecting RTSI7/RTSI Clock to Master Timebase on the CAN
10 Hz Resync Clock
10 Hz Resync Clock instructs the CAN card to use a 10 Hz, 50 percent
duty cycle clock to resynchronize its local timebase. This slow rate is
required for resynchronization of CAN cards. On each low-to-high
transition of the resync clock, this CAN card brings its local timebase
into sync.
When synchronizing to an E Series MIO card, a typical use of this
value is to use RTSI0 to RTSI6 as the source terminal, then use
NI-DAQ or NI-DAQmx functions to program the Counter 0 of the
MIO card to generate a 10 Hz 50 percent duty cycle clock on the
RTSI line.
When synchronizing to a CAN card, a typical use of this value is to use
RTSI0 to RTSI6 as the source terminal, then route the 10 Hz Resync
Clock of the other CAN card as the source terminal to the same
RTSI line.
10 Hz Resync Clock applies to the entire CAN card, including both
interfaces of a 2-port CAN card. The CAN card is specified by the
ObjName input to ncOpen.vi.
The default (disconnected) state of this destination means the
CAN card does not resynchronize its local timebase.
This value applies to Series 1 and Series 2 CAN cards, but is typically
used with Series 1 CAN cards only. If all of the CAN cards are
Series 2, the 20 MHz timebase is preferable due to the lack of drift.
If you are using a mix of Series 1 and Series 2 CAN cards, you must
use the 10 Hz Resync Clock.
Start Trigger
Start Trigger selects the start trigger, the event that starts
communication for all CAN objects on the same port. The start trigger
occurs on the first low-to-high transition of the source terminal.
The start trigger is the same for all CAN Objects using a given
interface, as specified by the ObjName input to ncOpen.vi.
By selecting RTSI0 to RTSI6, or PXI_Star for PXI hardware, as the
source terminal, you route the start trigger from another CAN, LIN,
or DAQ card. This ensures that sampling begins at the same time on
both cards. For example, you can synchronize with an E Series DAQ
MIO card by routing the AI start trigger of the MIO card to a RTSI line
and then routing the same RTSI line with Start Trigger as the
destination terminal on the CAN card.
The default (disconnected) state of this destination means the start
trigger occurs when communication begins on the interface.
Outputs
ObjHandle out is the object handle for the next VI.
Description
This VI connects a specific pair of source/destination terminals. One of the terminals is
typically a RTSI signal, and the other terminal is an internal terminal in the CAN or LIN
hardware. By connecting internal terminals to RTSI, you can synchronize the CAN or LIN
hardware with another hardware product such as an NI-DAQ or NI-DAQmx card.
When the final CAN object for a given port is cleared with ncClose.vi, NI-CAN disconnects
all terminal connections for that port. Therefore, ncDisconnectTerminals.vi is not required
for most applications. NI-DAQ and NI-DAQmx terminals remain connected after the CAN
objects are cleared, so you must disconnect NI-DAQ and NI-DAQmx terminals manually at
the end of the application.
• Signals received from a RTSI source must be at least 100 µs in length to be detected. This
prevents the card from receiving triggers in the nanoseconds range, such as the AI trigger
that E Series MIO hardware provides. Series 2 CAN cards also send RTSI pulses in the
nanoseconds range, so Series 1 CAN cards cannot receive RTSI input from Series 2 CAN
cards.
• For CAN cards with High-Speed (HS) ports only, four RTSI signals are available for
input (source), and four RTSI signals are available for output (destination). This
limitation applies to the number of signals per direction, not the RTSI signal number.
For example, if you connect RTSI0, RTSI1, RTSI3, and RTSI5 as input, connecting
RTSI4 as input will return an error.
• For CAN cards with one or more Low-Speed (LS) ports, two RTSI signals are available
for input (source), and three RTSI signals are available for output (destination).
Table 10-4 lists all valid combinations of source terminal and destination terminal.
Destination
10 Hz
RTSI0 to RTSI_CLO Master Resync Start
Source RTSI6 CK Timebase Clock Trigger
RTSI0 to — — — 1,2 1,2,3
RTSI6
RTSI7/RTSI — — 2,3 — —
Clock
PXI_Star — — — — 2
PXI_Clk10 — — 2 — —
20 MHz — 2,3 — — —
Timebase
10 Hz Resync 1,2 — — — 1,2
Clock
Interface 2 — — — 2
Receive
Event
Interface 2 — — — —
Transceiver
Event
Start Trigger 1,2,3 — — — —
Event
ncDisconnectTerminals.vi
Purpose
Disconnect terminals in the CAN or LIN hardware.
Format
Inputs
ObjHandle in is the object handle from the previous NI-CAN VI.
The handle reference originated from ncOpen.vi.
Outputs
ObjHandle out is the object handle for the next VI.
Description
This VI disconnects a specific pair of source/destination terminals that were previously
connected with ncConnectTerminals.vi.
When the final task for a given interface is cleared with ncClose.vi, NI-CAN disconnects all
terminal connections for that interface. Therefore, ncDisconnectTerminals.vi is not required
for most applications. This VI is typically used to change RTSI connections dynamically
while an application is running. First, use ncAction.vi to stop all tasks for the interface, then
use ncDisconnectTerminals.vi and ncConnectTerminals.vi to adjust RTSI connections.
Then use ncAction.vi with the opcode to start the network interface and higher-level CAN
Objects to restart communication.
ncGetAttr.vi
Purpose
Get the value of an object attribute.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI.
The handle originates from ncOpen.vi.
Baud Rate
Returns the value of the Baud Rate as configured with ncSetAttr.vi.
Form Factor
Returns the form factor of the card on which the Network Interface or
CAN Object is located.
The returned Form Factor is an enumeration.
0 PCI
1 PXI
2 PCMCIA
3 AT
4 USB
Interface Number
Returns the Interface Number of the port on which the Network
Interface or CAN Object is located.
This is the same number that you used in the ObjName string of the
previous Config and Open VIs.
0 FALSE (default)
1 TRUE
LIN Sleep
Returns the value of the LIN Sleep attribute. This attribute may be
updated by the user with ncSetAttr.vi or by the reception of a wakeup
signal on the LIN bus.
Listen Only?
Returns the Listen Only? attribute as configured with ncSetAttr.vi.
Object State
Returns the current state bit mask of the object. Polling with
ncGetAttr.vi provides an alternative method of state detection than
ncWaitForState.vi. For more information on the states returned from
this attribute, refer to the DesiredState input of ncWaitForState.vi.
Protocol Version
For NI-CAN, this returns 02000200 hex, which corresponds to
version 2.0B of the Bosch CAN specification and 2.0 of the LIN
specification. For more information on the encoding of the version,
refer to the Software Version attribute.
This attribute is available only from the Network Interface, not CAN
Objects.
Self Reception?
Returns the Self Reception attribute as configured with ncSetAttr.vi.
Serial Number
Returns the Serial Number of the card on which the Network
Interface or CAN Object is located.
Series
Returns the Series of the card on which the Network Interface or CAN
Object is located.
Series 1 hardware products use the Intel 82527 CAN controller.
Series 2 hardware products use the Philips SJA1000 CAN controller,
plus improved RTSI synchronization features.
The 847x and 847x with Sync series CAN hardware products use the
Philips SJA1000 CAN controller. The 847x and 847x with Sync series
LIN hardware products use the AMTEL ATA6620 LIN controller.
The 847x with Sync series hardware products add synchronization
features to the 847x hardware products.
The returned Series is an enumeration.
0 Series 1
1 Series 2
2 847x
Series 2 Comparator
Returns the Series 2 Comparator attribute as configured with
ncSetAttr.vi.
This attribute is available only from the Network Interface, not CAN
Objects.
This attribute is not supported for Series 1 CAN, 847x LIN, or 847x
with Sync LIN interfaces (returns error).
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
x x x x x x x x x x x x x x x x x ALC SEG
NEWALC ERCC
NEWECC DIR
Value in
SEG Field Meaning
0 No error (ignore DIR and ERRC as well)
2 ID.28 to ID.21 (most significant bits of identifier)
3 Start of frame
4 Bit SRTR (RTR for standard frames)
5 Bit IDE
6 ID.20 to ID.18
7 ID.17 to ID.13
8 CRC sequence
9 Reserved bit 0
10 Data field
11 Data length code
12 Bit RTR (RTR for extended frames)
13 Reserved bit 1
14 ID.4 to ID.0
15 ID.12 to ID.5
17 Active error flag
18 Intermission
19 Tolerate dominant bits
22 Passive error flag
23 Error delimiter
Table 10-5. SEG Field of the Error Code Capture Register (Continued)
Value in
SEG Field Meaning
24 CRC delimiter
25 Acknowledge slot
26 End of frame
27 Acknowledge delimiter
28 Overload flag
Value in
DIR Field Meaning
0 TX; error occurred during transmission
1 RX; error occurred during reception
Value in
ERRC Field Meaning
0 Bit error
1 Form error
2 Stuff error
3 Other type of error
Table 10-8. ALC Field Contains the Arbitration Lost Capture Register
Value in
ALC Field Meaning
0 ID.28 (most significant bit of identifier;
first ID bit in frame)
1 ID.27
2 ID.26
Table 10-8. ALC Field Contains the Arbitration Lost Capture Register (Continued)
Value in
ALC Field Meaning
3 ID.25
4 ID.24
5 ID.23
6 ID.22
7 ID.21
8 ID.20
9 ID.19
10 ID.18
11 SRTR (RTR for standard frames)
12 IDE
13 ID.17 (extended frames only)
14 ID.16 (extended frames only)
15 ID.15 (extended frames only)
16 ID.14 (extended frames only)
17 ID.13 (extended frames only)
18 ID.12 (extended frames only)
19 ID.11 (extended frames only)
20 ID.10 (extended frames only)
21 ID.9 (extended frames only)
22 ID.8 (extended frames only)
23 ID.7 (extended frames only)
24 ID.6 (extended frames only)
25 ID.5 (extended frames only)
26 ID.4 (extended frames only)
27 ID.3 (extended frames only)
Table 10-8. ALC Field Contains the Arbitration Lost Capture Register (Continued)
Value in
ALC Field Meaning
28 ID.2 (extended frames only)
29 ID.1 (extended frames only)
30 ID.0 (extended frames only)
31 SRTR (RTR for extended frames)
Table 10-9. NEWECC Field is the New Flag for the Error Code Capture Register
Value in
NEWECC
Field Meaning
0 SEG, DIR, and ERRC fields contain the same value as
the last Get of this attribute. If no error has occurred
since the start of communication, all fields are zero.
1 SEG, DIR, and ERRC fields contain information for a
new bus error.
Table 10-10. NEWALC Field is the New Flag for the Arbitration Lost Capture Register
Value in
NEWALC
Field Meaning
0 ALC field contains the same value as the last Get of
this attribute.
1 ALC field contains information for a new arbitration
loss.
Series 2 Mask
Returns the Series 2 Mask attribute as configured with ncSetAttr.vi.
This attribute is available only from the Network Interface, not CAN
Objects.
This attribute is not supported for Series 1 CAN, 847x LIN, or 847x
with Sync LIN interfaces (returns error).
Software Version
Version of the NI-CAN software, with major, minor, update, and beta
build numbers encoded in the U32 from high to low bytes. For
example, 2.0.1 would be 02000100 hex, and 2.1beta5 would be
02010005 hex.
This attribute is provided for backward compatibility.
ncGetHardwareInfo.vi provides more complete version information.
Termination
Returns the value of the Termination attribute as configured with
ncSetAttr.vi.
Timeline Recovery
Returns the Timeline Recovery attribute for the CAN Network
Interface Object.
Timestamp Format
Returns the present Timestamp Format programmed into the CAN or
LIN hardware. This attribute applies to the entire card.
Transceiver Mode
Returns the Transceiver Mode for the Network Interface.
This attribute is available only for the Network Interface, not CAN
Objects. Nevertheless, the attribute applies to communication by CAN
Objects as well as the associated Network Interface.
This attribute is not supported for Series 1 CAN, 847x LIN, or 847x
with Sync LIN interfaces (returns error).
For Series 2 cards for the PCMCIA form factor, this property requires
a corresponding Series 2 cable (dongle). For information on how to
identify the series of the PCMCIA cable, refer to the Series 2 Vs.
Series 1 section of Chapter 1, Introduction.
The Transceiver Mode changes when you set the mode within the
application, or when a remote wakeup transitions the interface from
Sleep to Normal mode. For more information, refer to ncSetAttr.vi.
This attribute uses the following values:
0 Normal
Transceiver is awake in normal communication mode.
1 Sleep
Transceiver and the CAN controller chip are both in sleep
mode.
Transceiver Type
Returns the type of transceiver for the Network Interface. For hardware
other than Series 2 XS cards, the Transceiver Type is fixed. For Series
2 XS cards, the Transceiver Type reflects the most recent value
specified by MAX or ncSetAttr.vi.
This attribute is available only for the Network Interface, not CAN
Objects. Nevertheless, the attribute applies to communication by CAN
Objects as well as the associated Network Interface.
This attribute is not supported on the PCMCIA form factor.
This attribute uses the following values:
0 High-Speed
Transceiver type is High-Speed (HS).
1 Low-Speed/Fault-Tolerant
Transceiver type is Low-Speed/Fault-Tolerant (LS).
2 Single Wire
Transceiver type is Single Wire (SW).
3 External
Transceiver type is External. This transceiver type is
available on Series 2 XS cards only. For more
information, refer to ncSetAttr.vi.
4 Disconnect
Transceiver type is Disconnect. This transceiver type is
available on Series 2 XS cards only. For more
information, refer to ncSetAttr.vi.
5 LIN
Transceiver type is LIN.
Transmit Error Counter
Returns the Transmit Error Counter from the Philips SJA1000 CAN
controller. This Transmit Error Counter is specified in the Bosch
CAN standard as well as ISO CAN standards.
This attribute is unsupported for Series 1 hardware (returns error). This
attribute is available only from the Network Interface, not CAN
Objects.
Transmit Mode
Returns the Transmit Mode the CAN Network Interface Object is
presently configured for.
The returned Transmit Mode is an enumeration.
0 Immediate Transmit
1 Timestamped Transmit
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Description
ncGetAttr.vi gets the value of the attribute specified by AttrId from the object specified by
ObjHandle. Within NI-CAN objects, you use attributes to access configuration settings,
status, and other information about the object, but not data.
ncGetHardwareInfo.vi
Purpose
Get CAN or LIN hardware information.
Format
Input
card number specifies the CAN or LIN card number from 1 to
Number of Cards, where Number of Cards is the number of CAN and
LIN cards in the system. You can determine the number of cards in the
system by using this VI with card number = 1, port number = 1, and
attribute ID = Number of Cards.
port number specifies the CAN or LIN port number from 1 to Number of
Ports, where Number of Ports is the number of ports on this card. You can
determine the number of ports on this card by using this VI with port
number = 1, and attribute ID = Number of Ports.
Version Major
Returns the major version of the NI-CAN software in the number
output. Use card number 1 and port number 1 as inputs.
The major version is the 'X' in X.Y.Z.
Version Minor
Returns the minor version of the NI-CAN software in the number
output. Use card number 1 and port number 1 as inputs.
The minor version is the 'Y' in X.Y.Z.
Version Update
Returns the update version of the NI-CAN software in the number
output. Use card number 1 and port number 1 as inputs.
The update version is the 'Z' in X.Y.Z.
Version Phase
Returns the phase of the NI-CAN software in the number output.
Use card number 1 and port number 1 as inputs.
Phase 1 specifies Alpha, phase 2 specifies Beta, and phase 3 specifies
Final release. Unless you are participating in an NI-CAN beta
program, you will always see 3.
Version Build
Returns the build of the NI-CAN software in the number output. Use
card number 1 and port number 1 as inputs.
With each software development phase, subsequent NI-CAN builds
are numbered sequentially. A given Final release version always uses
the same build number, so unless you are participating in an NI-CAN
beta program, this build number is not relevant.
Version Comment
Returns any special comment on the NI-CAN software in the string
output. Use card number 1 and port number 1 as inputs.
This string is normally empty for a Final release. In rare circumstances,
an NI-CAN prototype or patch may be released to a specific customer.
For these special releases, the version comment describes the special
features of the release.
Number of Cards
Returns the number of CAN and LIN cards in the system in the
number output. Use card number 1 and port number 1 as inputs.
If you are displaying all hardware information, you get this attribute
first, then iterate through all cards with a For loop. Inside the For loop,
you get all card-wide attributes including Number Of Ports, then use
another For loop to get port-wide attributes.
Serial Number
Card-wide attribute that returns the serial number of the card in the
number output. Use the desired card number, and port number 1
as inputs.
Form Factor
Card-wide attribute that returns the form factor of the card in the
number output. Use the desired card number, and port number 1
as inputs.
0 PCI
1 PXI
2 PCMCIA
3 AT
4 USB
Series
Card-wide attribute that returns the series of the card in the number
output. Use the desired card number, and port number 1 as inputs.
Series 1 hardware products use the Intel 82527 CAN controller.
Series 2 hardware products use the Philips SJA1000 CAN controller,
plus improved RTSI synchronization features.
The returned Series is an enumeration.
0 Series 1
1 Series 2
2 847x
Number of Ports
Card-wide attribute that returns the number of ports on the card in the
number output. Use the desired card number, and port number 1 as
inputs.
If you are displaying all hardware information, you get this attribute
within the For loop for all cards, then iterate through all CAN ports to
get port-wide attributes.
Transceiver Type
This port-wide attribute returns the type of transceiver in the number
output. Use the desired card number and port number as inputs.
For hardware other than Series 2 XS cards, the transceiver type is
fixed. For Series 2 XS cards, the transceiver type reflects the most
recent value specified by MAX or ncSetAttr.vi.
This attribute is not supported on the PCMCIA form factor.
Interface Number
Port-wide attribute that returns the interface number of the port in the
number output. Use the desired card number and port number as
inputs.
The interface number is assigned to a physical port using the
Measurement and Automation Explorer (MAX). The interface number
is used as a string in the Frame API (for example, “CAN0”). The
interface number is used for the interface input in the Channel API.
Output
If the attribute is a number, the value is returned in this output terminal.
Description
This VI provides information about available CAN and LIN cards, but does not require you
to open/start sessions. First get Number of Cards, then loop for each card. For each card, you
can get card-wide attributes (such as Form Factor), and you also can get the Number of
Ports. For each port, you can get port-wide attributes such as the Transceiver.
ncGetTimer.vi
Purpose
Get the absolute timestamp attribute.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Timestamp returns the absolute timestamp value. The value matches the
absolute timestamp format used within LabVIEW itself. LabVIEW time
is a DBL representing the number of seconds elapsed since 12:00 a.m.,
Friday, January 1, 1904, Coordinated Universal Time (UTC). You can
wire this Timestamp to LabVIEW time functions such as Seconds To
Date/Time. You also can display the time in a numeric indicator of type
DBL by using Format & Precision to select Time & Date format.
Note If you use Time & Date format, LabVIEW limits the Seconds Precision to 3, which
shows only milliseconds. The NI-CAN timestamp provides microsecond precision. If you
need to view microsecond precision, change the timestamp to decimal format, with
six digits of precision.
Description
This VI can be used only with the CAN or LIN Network Interface, and not with CAN Objects.
ncOpen.vi
Purpose
Open an object.
Format
Input
ObjName is the name of the object to open. For CAN interfaces, you must
have already wired this name into a previous config VI.
This name uses the syntax “CANx”, where x is a decimal number starting
at zero that indicates the CAN network interface (CAN0, CAN1, up to
CAN63). CAN network interface names are associated with physical CAN
ports using the Measurement and Automation Explorer (MAX).
The special interface values 256 and 257 refer to virtual interfaces. For
more information on usage of virtual interfaces, refer to the Frame to
Channel Conversion section of Chapter 6, Using the Channel API.
This name uses the syntax LINx, where x is a decimal number starting at
zero that indicates the LIN network interface (LIN0, LIN1, up to LIN63),
where CAN and LIN share the same range. LIN network interface names
are associated with physical LIN ports using the Measurement and
Automation Explorer (MAX).
CAN Object
The special virtual interface names “CAN256” and “CAN257” are not
supported for CAN Objects.
Output
ObjHandle out is the object handle for all subsequent NI-CAN VIs for this
object, including the final call to ncClose.vi.
Description
ncOpen.vi takes the name of an object to open and returns a handle to that object that you use
with subsequent NI-CAN function calls.
The Frame API and Channel API cannot use the same CAN network interface
simultaneously. If the CAN network interface is already initialized in the Channel API,
this function returns an error.
If ncOpen.vi is successful, a handle to the newly opened object is returned. You use this
object handle for all subsequent function calls for the object.
ncReadNet.vi
Purpose
Read single frame from a CAN or LIN Network Interface Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Note The description of the output terminals is specified by the frame type. The value of
IsRemote indicates the frame type. For a description of each frame type, refer to the Frame
Types section in this function reference.
Description
The ncReadNet.vi VI is useful when you need to process one frame at a time, because it
returns separate outputs for ArbitrationId, Timestamp, and so on. In order to read multiple
frames at a time, such as for high-bandwidth networks, use ncReadNetMult.vi.
Since NI-CAN handles the read queue in the background, this VI does not wait for new
frames to arrive. To ensure that a new frame is available before calling ncReadNet.vi, first
wait for the Read Available state using ncWaitForState.vi.
When you call ncReadNet.vi for an empty read queue (Read Available state false), the frame
from the previous call to ncReadNet.vi is returned again, along with the CanWarnOldData
warning (status=F, code=3FF62009 hex).
When a frame arrives for a full read queue, NI-CAN discards the new frame, and the next call
to ncReadNet.vi returns the error CanErrOverflowRead (status=T, code= BFF62028
hex). If you detect this overflow, switch to using ncReadNetMult.vi to read in a relatively
tight loop (few milliseconds each read).
Although the Network Interface allows Read Queue Length of zero, this is not
recommended, because every new frame will always overwrite the previous frame.
You can use the Network Interface and CAN Objects simultaneously. When a CAN frame
arrives from the network, NI-CAN first checks the ArbitrationId for an open CAN Object.
If no CAN Object applies, NI-CAN checks the comparators and masks of the Network
Interface (including the Series 2 Filter Mode attributes). If the frame passes that filter,
NI-CAN places the frame into the read queue of the Network Interface.
When the transmit error counter of the CAN communication controller increments above 255,
the network interface transfers into the bus off state as dictated by the CAN protocol. The
network interface stops communication so that you can correct the defect in the network, such
as a malfunctioning cable or device. When bus off occurs, NI-CAN returns the error
CanCommError (status=T, code=BFF6200B hex) from read VIs.
If no CAN devices are connected to the network interface port, and you attempt to transmit a
frame, the CanWarnComm warning is returned. This warning occurs because the missing
acknowledgment bit increments the transmit error counter until the network interface reaches
the error passive state, but bus off state is never reached.
For more information about low-speed communication error handling, refer to the Log
Comm Warnings attribute in ncSetAttr.vi.
Frame Types
IsRemote indicates the frame type. The frame type determines the interpretation of the
remaining fields. Table 10-11, IsRemote Value 0: CAN Data Frame, Table 10-12, IsRemote
Value 1: CAN Remote Frame, Table 10-13, IsRemote Value 2: Communication Warning or
Error Frame, Table 10-14, IsRemote Value 3: RTSI Frame, Table 10-15, IsRemote Value 4:
Start Trigger Frame, Table 10-16, IsRemote Value 6: CAN Bus Error Frame, Table 10-17,
IsRemote Value 7: Transceiver Fault Frame, Table 10-18, IsRemote Value 18: LIN Full
Frame, Table 10-19, IsRemote Value 19: LIN Wakeup Received Frame, Table 10-20,
IsRemote Value 20: LIN Bus Inactive Frame, and Table 10-21, IsRemote Value 21: LIN Bus
Error Frame, describe the fields of the cluster for each value of IsRemote.
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
Data
Field Name Type Description
IsRemote Value 0 represents a CAN data frame. The CAN data frame contains
data from the network.
Data
Field Name Type Description
IsRemote Value 1 represents a CAN remote frame.
Only Series 2, 847x CAN, or 847x with Sync CAN interfaces can
receive remote frames using the Network Interface. For Series 1
hardware, you must handle incoming remote frames with CAN
Object only.
ArbitrationId Specifies the arbitration ID to transmit in the CAN data frame.
DataLength Returns the Data Length Code in the remote frame, but with no data.
Data
Field Name Type Description
IsRemote Value 2 represents a communication warning or error frame.
This indicates a communication problem reported by the CAN
controller or the low-speed CAN transceiver. This frame type
occurs only when you set the Log Comm Warnings attribute to
TRUE and the CAN controller is in the error passive state. For more
information on communication problems, refer to the Description
section of this function reference.
ArbitrationId 8000000B hex—Comm. error: General
4000000B hex—Comm. warning: General
8001000B hex—Comm. error: Stuffing
4001000B hex—Comm. warning: Stuffing
8002000B hex—Comm. error: Format
4002000B hex—Comm. warning: Format
8003000B hex—Comm. error: No Ack
4003000B hex—Comm. warning: No Ack
8004000B hex—Comm. error: Tx 1 Rx 0
4004000B hex—Comm. warning: Tx 1 Rx 0
8005000B hex—Comm. error: Tx 0 Rx 1
4005000B hex—Comm. warning: Tx 0 Rx 1
8006000B hex—Comm. error: Bad CRC
4006000B hex—Comm. warning: Bad CRC
0000000B hex—Comm. Error/warnings cleared
8000000C hex—Transceiver fault warning
0000000C hex—Transceiver fault cleared
DataLength Ignored.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 3 represents a RTSI frame.
This indicates when a RTSI input pulse occurred relative to
incoming CAN frames. This frame type occurs only when you set
the RTSI Mode attribute to On RTSI Input–Timestamp event
(refer to ncConfigCANNetRTSI.vi for details).
ArbitrationId Is the special value 40000001 hex.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 4 represents the start trigger frame.
When the Log Start Trigger? attribute is enabled, this frame
indicates the time when the start trigger occurs. For example, if you
use ncConnectTerminals.vi to connect a RTSI input to the start
trigger, this frame occurs when the RTSI input pulses for the first
time. Another use case for logging the start trigger would be for
logging the received CAN frames in a file. This ensures that the first
frame in a logfile is a start trigger frame, which specifies the
absolute time (date/time) at which CAN communication started.
ArbitrationId Zero.
DataLength One.
Data
Field Name Type Description
Data The Data array contains a single byte that specifies the timestamp
format used for all the subsequent frames. The value is 0 for
absolute timestamps, and 1 for relative timestamps.
Timestamp This indicates the time of the start trigger in the absolute format.
Within a logfile, this timestamp indicates the date and time at which
communication started.
The timestamp is a LabVIEW numeric double with Format and
Precision of Absolute time (date/time). The format of this
timestamp is always absolute, even when Data byte 0 specifies
relative timestamp format. This absolute timestamp provides
date/time information even when the frames use the relative format.
Data
Field Name Type Description
IsRemote Value 6 represents a CAN bus error frame. Refer to the Log Bus
Errors? attribute description for more information on CAN Bus
Error frames.
ArbitrationId Zero.
DataLength Four.
Data
Field Name Type Description
Data 0—Comm State (See description below)
1—Transmit Error Counter
2—Receive Error Counter
3—ECC Register
4—X
5—X
6—X
7—X
Note: X means Reserved or Don’t Care.
The first data byte (Comm State) indicates the current
communication state of the CAN controller. The states are:
0—Error Active
1—Error Passive
2—Bus Off
Timestamp Time when the bus error was detected.
Data
Field Name Type Description
IsRemote Value 7 represents a transceiver fault frame. Refer to the Log
Transceiver Faults? attribute description for more information
on Transceiver Fault frames.
ArbitrationId Zero.
DataLength One.
Data
Field Name Type Description
Data 0—Transceiver fault (0=fault cleared, 1=fault present)
1—X
2—X
3—X
4—X
5—X
6—X
7—X
Timestamp Time when the transceiver fault was detected.
Data
Field Name Type Description
IsRemote Value 18 represents a full frame for LIN communication. A full
frame is reported when the LIN interface slave task has received one
complete LIN frame. All frames for which the LIN interface slave
task is a subscriber will be reported. Frames for which the LIN
interface slave task is a publisher will be reported only if the Self
Reception attribute is set to TRUE.
ArbitrationId Zero to sixty-three.
Data
Field Name Type Description
IsRemote Value 19 represents a wakeup received frame for LIN
communication. A wakeup received frame is reported when the LIN
interface is asleep, the LIN Log Wakeup attribute is set to TRUE,
and a wakeup event is detected.
ArbitrationId Zero.
DataLength Zero.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 20 represents a bus inactive frame for LIN communication.
Bus inactive detection begins when the LIN interface senses the first
activity on the bus. When activity ceases, a bus inactive frame is
reported if the inactivity lasts for more than four seconds.
ArbitrationId Zero.
DataLength Zero.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 21 represents a LIN bus error frame for LIN communication.
A LIN bus error frame is reported when the Log Bus Errors?
attribute is set to TRUE, and a bus error occurs.
ArbitrationId Zero.
DataLength Varies depending on the error. Refer to Table 10-33, LIN Bus Error
Codes and Descriptions, in ncSetAttr.vi for information.
Note If you use Time & Date format, LabVIEW limits the Seconds Precision to 3,
which shows only milliseconds. The NI-CAN timestamp provides microsecond precision.
If you need to view microsecond precision, change the timestamp to decimal format,
with six digits of precision.
ncReadNetMult.vi
Purpose
Read multiple frames from a CAN or LIN Network Interface Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Data returns an array of clusters. Each cluster in the array uses the typedef
CanFrameTimed.ctl, with the following elements.
Note Within each cluster, IsRemote indicates the frame type. The frame type determines
the interpretation of the remaining fields. For a description of each frame type, refer to the
Frame Types section of this function reference.
Description
Since NI-CAN handles the read queue in the background, this VI does not wait for new
frames to arrive. To ensure that new frames are available before calling ncReadNetMult.vi,
first wait for the Read Available state or Read Multiple state using ncWaitForState.vi.
When you call ncReadNetMult.vi for an empty read queue (Read Available state false),
Error out returns success (status=F, code=0), and ActualDataSize (Frames) returns 0.
When a frame arrives for a full read queue, NI-CAN discards the new frame, and the next call
to ncReadNetMult.vi returns the error CanErrOverflowRead (status=T, code= BFF62028
hex). If you detect this overflow, try to read in a relatively tight loop (few milliseconds each
read).
Although the Network Interface allows Read Queue Length of zero, this is not
recommended, because every new frame will always overwrite the previous frame.
You can use the Network Interface and CAN Objects simultaneously. When a CAN frame
arrives from the network, NI-CAN first checks the ArbitrationId for an open CAN Object.
If no CAN Object applies, NI-CAN checks the comparators and masks of the Network
Interface (including the Series 2 Filter Mode attributes). If the frame passes that filter,
NI-CAN places the frame into the read queue of the Network Interface.
When the transmit error counter of the CAN communication controller increments above 255,
the network interface transfers into the bus off state as dictated by the CAN protocol. The
network interface stops communication so that you can correct the defect in the network, such
as a malfunctioning cable or device. When bus off occurs, NI-CAN returns the error
CanCommError (status=T, code=BFF6200B hex) from read VIs.
If no CAN devices are connected to the network interface port, and you attempt to transmit a
frame, the warning CanWarnComm is returned. This warning occurs because the missing
acknowledgment bit increments the transmit error counter until the network interface reaches
the error passive state, but bus off state is never reached.
For more information about low-speed communication error handling, refer to the Log
Comm Warnings attribute in ncSetAttr.vi.
Frame Types
IsRemote indicates the frame type. The frame type determines the interpretation of the
remaining fields. Table 10-22, IsRemote Value 0: CAN Data Frame, Table 10-23, IsRemote
Value 1: CAN Remote Frame, Table 10-24, IsRemote Value 2: Communication Warning or
Error Frame, Table 10-25, IsRemote Value 3: RTSI Frame, Table 10-26, IsRemote Value 4:
Start Trigger Frame, Table 10-27, IsRemote Value 6: CAN Bus Error Frame, Table 10-28,
IsRemote Value 7: Transceiver Fault Frame, Table 10-29, IsRemote Value 18: LIN Full
Frame, Table 10-30, IsRemote Value 19: LIN Wakeup Received Frame, Table 10-31,
IsRemote Value 20: LIN Bus Inactive Frame, and Table 10-32, IsRemote Value 21: LIN Bus
Error Frame, describe the fields of the cluster for each value of IsRemote.
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
Data
Field Name Type Description
IsRemote Value 0 represents a CAN data frame. The CAN data frame contains
data from the network.
Data
Field Name Type Description
DataLength Indicates the number of data bytes in the Data array.
Data
Field Name Type Description
IsRemote Value 1 represents a CAN remote frame. Only Series 2 or later can
receive remote frames using the Network Interface. For Series 1
hardware, you must handle incoming remote frames with CAN
Object only.
ArbitrationId Specifies the arbitration ID to transmit in the CAN data frame.
DataLength Returns the Data Length Code in the remote frame, but with no data.
Data
Field Name Type Description
IsRemote Value 2 represents a communication warning or error frame.
This indicates a communication problem reported by the CAN
controller or the low-speed CAN transceiver. This frame type
occurs only when you set the Log Comm Warnings attribute to
TRUE and the CAN controller is in the error passive state. For more
information on communication problems, refer to the Description
section of this function reference.
ArbitrationId 8000000B hex—Comm. error: General
4000000B hex—Comm. warning: General
8001000B hex—Comm. error: Stuffing
4001000B hex—Comm. warning: Stuffing
8002000B hex—Comm. error: Format
4002000B hex—Comm. warning: Format
8003000B hex—Comm. error: No Ack
4003000B hex—Comm. warning: No Ack
8004000B hex—Comm. error: Tx 1 Rx 0
4004000B hex—Comm. warning: Tx 1 Rx 0
8005000B hex—Comm. error: Tx 0 Rx 1
4005000B hex—Comm. warning: Tx 0 Rx 1
8006000B hex—Comm. error: Bad CRC
4006000B hex—Comm. warning: Bad CRC
0000000B hex—Comm. Error/warnings cleared
8000000C hex—Transceiver fault warning
0000000C hex—Transceiver fault cleared
DataLength Ignored.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 3 represents a RTSI frame.
This indicates when a RTSI input pulse occurred relative to
incoming frames. This frame type occurs only when you set the
RTSI Mode attribute to On RTSI Input–Timestamp event (refer
to ncConfigCANNetRTSI.vi for details).
ArbitrationId Is the special value 40000001 hex.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 4 represents the start trigger frame.
When the Log Start Trigger? attribute is enabled, this frame
indicates the time when the start trigger occurs. For example, if you
use ncConnectTerminals.vi to connect a RTSI input to the start
trigger, this frame occurs when the RTSI input pulses for the first
time. Another use case for logging the start trigger would be for
logging the received CAN frames in a file. This ensures that the
first frame in a logfile is a start trigger frame, which specifies the
absolute time (date/time) at which CAN communication started.
ArbitrationId Zero.
DataLength One.
Data
Field Name Type Description
Data The Data array contains a single byte that specifies the timestamp
format used for all the subsequent CAN frames. The value is 0 for
absolute timestamps, and 1 for relative timestamps.
Timestamp This indicates the time of the start trigger in the absolute format.
Within a logfile, this timestamp indicates the date and time at which
communication started.
The timestamp is a LabVIEW numeric double with Format and
Precision of Absolute time (date/time). The format of this
timestamp is always absolute, even when Data byte 0 specifies
relative timestamp format. This absolute timestamp provides
date/time information even when the CAN frames use the relative
format.
Data
Field Name Type Description
IsRemote Value 6 represents a CAN bus error frame. Refer to the Log Bus
Errors? attribute description for more information on CAN Bus
Error frames.
ArbitrationId Zero.
DataLength Four.
Data
Field Name Type Description
Data 0—Comm State (See description below)
1—Transmit Error Counter
2—Receive Error Counter
3—ECC Register
4—X
5—X
6—X
7—X
Note: X means Reserved or Don’t Care.
The first data byte (Comm State) indicates the current
communication state of the CAN controller. The states are:
0—Error Active
1—Error Passive
2—Bus Off
Timestamp Time when the bus error was detected.
Data
Field Name Type Description
IsRemote Value 7 represents a transceiver fault frame. Refer to the Log
Transceiver Faults? attribute description for more information on
Transceiver Fault frames.
ArbitrationId Zero.
DataLength One.
Data
Field Name Type Description
Data 0—Transceiver fault (0=fault cleared, 1=fault present)
1—X
2—X
3—X
4—X
5—X
6—X
7—X
Timestamp Time when the transceiver fault was detected.
Data
Field Name Type Description
IsRemote Value 18 represents a full frame for LIN communication. A full
frame is reported when the LIN interface slave task has received one
complete LIN frame. All frames for which the LIN interface slave
task is a subscriber will be reported. Frames for which the LIN
interface slave task is a publisher will be reported only if the Self
Reception attribute is set to TRUE.
ArbitrationId Zero to sixty-three.
Data
Field Name Type Description
IsRemote Value 19 represents a wakeup received frame for LIN
communication. A wakeup received frame is reported when the LIN
interface is asleep, the LIN Log Wakeup attribute is set to TRUE,
and a wakeup event is detected.
ArbitrationId Zero.
DataLength Zero.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 20 represents a bus inactive frame for LIN communication.
Bus inactive detection begins when the LIN interface senses the first
activity on the bus. When activity ceases, a bus inactive frame is
reported if the inactivity lasts for more than four seconds.
ArbitrationId Zero.
DataLength Zero.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 21 represents a LIN bus error frame for LIN communication.
A LIN bus error frame is reported when the Log Bus Errors?
attribute is set to TRUE, and a bus error occurs.
ArbitrationId Zero.
DataLength Varies depending on the error. Refer to Table 10-33, LIN Bus Error
Codes and Descriptions, in ncSetAttr.vi for information.
Note If you use Time & Date format, LabVIEW limits the Seconds Precision to 3, which
shows only milliseconds. The NI-CAN timestamp provides microsecond precision. If you
need to view microsecond precision, change the timestamp to decimal format, with
six digits of precision.
ncReadObj.vi
Purpose
Read single frame from a CAN Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Data array returns 8 data bytes. The actual number of valid data bytes
depends on the CAN Object configuration specified in
ncConfigCANObj.vi.
Timestamp returns the absolute timestamp when the frame was placed into
the read queue. The value matches the absolute timestamp format used
within LabVIEW itself. LabVIEW time is a DBL representing the number
of seconds elapsed since 12:00 a.m., Friday, January 1, 1904, Coordinated
Universal Time (UTC). You can wire this Timestamp to LabVIEW time
functions such as Seconds To Date/Time. You also can display the time in
a numeric indicator of type DBL by using Format & Precision to select
Time & Date format.
Note If you use Time & Date format, LabVIEW limits the Seconds Precision to 3,
which shows only milliseconds. The NI-CAN timestamp provides microsecond precision.
If you need to view microsecond precision, change the timestamp to decimal format,
with six digits of precision.
Description
ncReadObj.vi is useful when you need to process one frame at a time. In order to read
multiple frames at a time, such as for high-bandwidth networks, use ncReadObjMult.vi.
Since NI-CAN handles the read queue in the background, this VI does not wait for a new
frame to arrive. To ensure that a new frame is available before calling ncReadObj.vi,
first wait for the Read Available state using ncWaitForState.vi.
When you call ncReadObj.vi for an empty read queue (Read Available state false), the frame
from the previous call to ncReadObj.vi is returned again, along with the warning
CanWarnOldData (status=F, code=3FF62009 hex).
When a frame arrives for a full read queue, NI-CAN discards the new frame, and the next call
to ncReadObj.vi returns the error CanErrOverflowRead (status=T, code= BFF62028 hex).
If you detect this overflow, switch to using ncReadObjMult.vi to read in a relatively tight
loop (few milliseconds each read).
If you only need to obtain the most recent frame received for the CAN Object, you can set
Read Queue Length to zero. When the read queue uses a zero length, only the most recent
frame is stored, and overflow errors do not occur.
You can use the Network Interface and CAN Objects simultaneously. When a CAN frame
arrives from the network, NI-CAN first checks the ArbitrationId for an open CAN Object.
If no CAN Object applies, NI-CAN checks the comparators and masks of the Network
Interface (including the Series 2 Filter Mode attributes). If the frame passes that filter,
NI-CAN places the frame into the read queue of the Network Interface.
ncReadObjMult.vi
Purpose
Read multiple frames from a CAN Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI.
The handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Data returns an array of clusters. Each cluster in the array uses the typedef
CanDataTimed.ctl with the following elements:
Data array returns 8 data bytes. The actual number of valid data
bytes depends on the CAN Object configuration specified in
ncConfigCANObj.vi.
Description
Since NI-CAN handles the read queue in the background, this VI does not wait for new
frames to arrive. To ensure that new frames are available before calling ncReadObjMult.vi,
first wait for the Read Available state or Read Multiple state using ncWaitForState.vi.
When you call ncReadObjMult.vi for an empty read queue (Read Available state false),
Error out returns success (status=F, code=0), and ActualDataSize (Frames) returns 0.
When a frame arrives for a full read queue, NI-CAN discards the new frame, and the next
call to ncReadObjMult.vi returns the error CanErrOverflowRead (status=T,
code=BFF62028 hex). If you detect this overflow, try to read in a relatively tight loop
(few milliseconds each read).
You can use the Network Interface and CAN Objects simultaneously. When a CAN frame
arrives from the network, NI-CAN first checks the ArbitrationId for an open CAN Object.
If no CAN Object applies, NI-CAN checks the comparators and masks of the Network
Interface (including the Series 2 Filter Mode attributes). If the frame passes that filter,
NI-CAN places the frame into the read queue of the Network Interface.
ncSetAttr.vi
Purpose
Set the value of an object attribute. The attributes provided in this VI allow for additional
configuration beyond the attributes of ncConfig VIs.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI.
The handle originates from ncOpen.vi.
Baud Rate
For NI CAN hardware you can specify the following basic baud rates
as the numeric rate: 5000, 6150, 7813, 8000, 10000, 12500, 15625,
16000, 20000, 25000, 31250, 33333, 40000, 50000, 62500, 80000,
83333, 100000, 125000, 160000, 200000, 250000, 400000, 500000,
800000, and 1000000.
You can specify advanced baud rates as 8000XXYY hex, where YY is
the value of Bit Timing Register 0 (BTR0), and XX is the value of
Bit Timing Register 1 (BTR1) of the SJA1000 CAN controller.
For NI LIN hardware you can specify any baud rate from 2400 to
20000 baud. If the baud rate you select varies more than .5% from the
calculated baud rate, you will receive a warning message. The
calculation for the baud rate is as follows:
Calculated Baud Rate = 1,500,000/x
where x = (1,500,000/Input Baud Rate), rounded to the nearest
integer.
0 Classic (default)
1 Enhanced
Setting the LIN Checksum Type to Classic indicates that the
LIN-specified checksum calculation algorithm should be applied only
to the data bytes. Setting the LIN Checksum Type to Enhanced
indicates that the checksum calculation algorithm should be applied to
the ID and data bytes.
0 FALSE (default)
1 TRUE
When the LIN interface transmits a header, it expects an external slave
to publish data in response. When writing headers, the LIN interface
detects end-of-response using either the LIN-specified response
timeout for a response containing the maximum number (8) of data
bytes (LIN Enable DLC Check=FALSE), or reception of a response
containing DLC number of data bytes (LIN Enable DLC
Check=TRUE). If LIN Enable DLC Check=FALSE, then the
minimum time separation between the transmission of headers will be
header time + time to subscribe to eight data bytes (DLC is ignored)
and checksum + LIN interface inter-frame delay. If LIN Enable DLC
Check=TRUE, then the minimum time separation between the
transmission of headers will be header time + time to subscribe to DLC
number of data bytes and checksum + LIN interface inter-frame delay.
If you want to transmit header frames, each separated by a unique
schedule table amount of delay with maximum timing accuracy, set
LIN Enable DLC Check to TRUE. Note that if LIN Enable DLC
Check=TRUE, the LIN interface will verify that a DLC in the range of
one to eight is in the header IsRemote type written by the host. If LIN
Enable DLC Check=FALSE, the LIN interface will ignore the DLC
in the header IsRemote type written by the host.
0 FALSE (default)
1 TRUE
0 (default)
LIN Sleep
Sets the sleep state of the LIN interface. The values for this attribute
are:
0 FALSE (default)
1 TRUE
The LIN interface powers up in the awake state (LIN Sleep=FALSE).
When the LIN Sleep attribute is set to FALSE, the user may set it to
TRUE at any time: upon reception of a sleep frame (four second
period of bus inactivity has passed), upon reception of a full frame
containing go-to-sleep command data, or when it is desired to simply
put the interface to sleep. When the LIN Sleep attribute is set to TRUE,
either the user or the state machines within the LIN interface may set
the attribute to FALSE, depending upon whether the interface is acting
as master or slave, and whether or not it is issuing or receiving the
wakeup request.
Listen Only?
Specifies whether to use the listen only feature of the Philips SJA1000
CAN controller.
Communication must be stopped to set this attribute. Use Start On
Open False with ncConfigCANNet.vi, set the attribute, then use
ncAction.vi to start communication.
0 FALSE (default)
When set to FALSE, bus errors will not be logged and
cannot be read (default).
When set to FALSE, listen only mode is disabled
(default).
Received frames are ACKnowledged, and frames can
be transmitted using ncWriteNet.vi and
ncWriteObj.vi.
1 TRUE
When set to TRUE, listen only mode is enabled.
The Network Interface and CAN Objects can only
receive frames. The interface does not transmit on the
network: no ACKnowledgements are transmitted for
received frames, and ncWriteNet.vi and
ncWriteObj.vi will return an error. The Philips
SJA1000 CAN controller enters error passive state
when listen only is enabled.
The listen only mode is not available on the Intel 82527
CAN controller used by Series 1 CAN hardware
(returns error).
This attribute is available only for the Network
Interface, not CAN Objects.
0 FALSE (default)
When set to FALSE, bus errors will not be logged and
cannot be read (default).
1 TRUE
When set to TRUE, the Network Interface reports bus
errors as a special frame in the read queue. For CAN, if
the Log Comm Warnings? attribute is set to 1 (TRUE),
the Log Bus Errors? attribute must be set to 0 (FALSE).
Data Bytes
0—Comm State (see description below)
1—Transmit Error Counter
2—Receive Error Counter
3—ECC Register
4—X
5—X
6—X
7—X
Note: X means Reserved or Don’t Care.
The first data byte (Comm State) indicates the
current communication state of the CAN
controller. The states are:
0—Error Active
1—Error Passive
2—Bus Off
For LIN interfaces, the bus error frame is logged into the read queue
when a timeout or bus errors such as Bit Framing or Checksum
occurs. This attribute must be set prior to starting the Network
Interface.
The LIN bus error frame has the following format:
Arbitration ID 0
IsRemote 21
Data Bytes
0—Error code (most significant byte)
1—Error code (least significant byte)
2—X
3—X
4—Received byte (for applicable error code)
5—Expected byte (for applicable error code)
6—LIN ID (for applicable error code)
7—X
Note: X means Reserved or Don’t Care.
Data bytes zero and one (Error code) indicate the type of LIN bus error.
Refer to Table 10-33 for a list of LIN bus error codes and descriptions.
Data bytes two and three are reserved for internal use. For errors in
which a received byte did not match the expected value, data byte four
indicates the received value and data byte 5 indicates the expected
value. For a bus error occurring at a point in the LIN frame after which
the break, sync, and ID fields have been processed, data byte six
indicates the LIN ID.
LinBusErrorRxIdFraming A020 The LIN interface slave task 6 A0 20 X X Expected Received N/A
received an ID byte with a framing ID Byte ID Byte
error.
LinBusErrorRxIdParity C020 The LIN interface slave task 6 C0 20 X X Expected Received N/A
received an ID byte with a parity ID Byte ID Byte
error.
LinBusErrorRxIdTimeout 9020 The LIN interface slave task did 4 90 20 X X N/A N/A N/A
not receive an ID byte within the
header timeout period.
LinBusErrorRxSyncBit C040 The LIN interface slave task 6 C0 40 X X Expected Received N/A
received a sync byte with a bit Sync Byte Sync Byte
error.
LinBusErrorRxSyncFraming A040 The LIN interface slave task 4 A0 40 X X N/A N/A N/A
received a sync byte with a
framing error.
LinBusErrorRxSyncTimeout 9040 The LIN interface slave task did 4 90 40 X X N/A N/A N/A
not receive a sync byte within the
header timeout period.
LinBusErrorWhenMasterIssues 0A00 The LIN interface failed to issue a 4 0A 00 X X N/A N/A N/A
Wakeup wakeup on the LIN as a master.
LinBusErrorWhenSlaveIssues 900 The LIN interface failed to issue a 4 09 00 X X N/A N/A N/A
Wakeup wakeup on the LIN as a slave.
0 FALSE
When set to FALSE, the Network Interface reports CAN
communication warnings (including transceiver faults) in
Error out of the read VIs. For more information, refer to
ncReadNetMult.vi.
1 TRUE
When set to TRUE, the Network Interface reports CAN
communication warnings (including transceiver faults)
by storing a special frame in the read queue. The
communication warnings are not reported in Error out.
For more information on communication warnings and
errors, refer to ncReadNetMult.vi. The special
communication warning frame uses the following
format:
IsRemote 2
DataLength 0
0 FALSE
Disables the logging of the start trigger (default) in the
read queue of the Network Interface Object.
1 TRUE
Enables the logging of the start trigger in the read queue of
the Network Interface Object. The start trigger is logged
when the hardware starts communication.
This attribute should be set prior to starting the Network Interface
Object. This attribute is applicable only to the Network Interface
Object and setting this attribute on CAN Objects will result in a
NI-CAN error.
Note Setting this attribute to true in applications that only transmit CAN frames has
no effect.
0 FALSE
When set to FALSE, transceiver faults will not be logged
as frames (default).
1 TRUE
When set to TRUE, the transceiver faults are logged as
special frames in the read queue of the Network Interface
Object. For CAN, if the Log Comm Warnings? attribute
is set to 1 (TRUE), Log Transceiver Faults must be set
to 0 (FALSE).
This attribute is supported only on High Speed and Low Speed CAN
transceivers.
This attribute can be set before or after starting the CAN Network
Interface Object. The frame will be logged each time the transceiver’s
NERR signal changes state. In order to filter out noise on this signal,
the logging can occur up to 10ms apart. The transceiver fault frame as
the following format:
Arbitration ID 0
IsRemote 7
DataLength 1
Data Bytes
0—Transceiver fault (0=fault cleared, 1=fault
present)
1—X
2—X
3—X
4—X
5—X
6—X
7—X
Note: X means Reserved or Don’t Care.
10 (10 MHz)
The Master Timebase Rate should be set to 10 MHz when
synchronizing a CAN card with an M-Series DAQ card. The
M-Series DAQ card can export a 20 MHz clock but it does this by
using one of its two counters.
If your CAN-DAQ application does not use the 2 DAQ counters then,
you can leave the timebase rate set to 20 MHz (default).
This attribute can be set either before or after calling
ncConnectTerminals.vi to connect the RTSI_CLK to Master
Timebase. However, this attribute must always be called prior to
starting the Network Interface Object.
This attribute is applicable only to PCI and PXI Series 2 cards. For
PCMCIA cards, setting this attribute will return an error. On PXI cards,
if PXI_CLK10 is routed to the Master Timebase, then the rate is
fixed at 10 MHz (it over rides any previous setting of this attribute).
Setting this attribute for Series 1 cards will also result in a NI-CAN
error.
For the 847x and 847x with Sync series CAN and LIN interfaces,
setting this attribute has no effect. The 847x and 847x with Sync series
CAN and LIN interfaces automatically synchronize to a Master
Timebase Rate of 1 MHz, 10 MHz, or 20 MHz. Refer to Appendix E,
Specifications, for details on synchronization triggers.
Self Reception?
For CAN, this specifies whether to echo successfully transmitted CAN
frames into the read queue of the CAN Network Interface and/or CAN
Objects. Each reception occurs just as if the frame were received from
another CAN device.
For self reception to operate properly, another CAN device must
receive and acknowledge each transmit. If a transmitted frame is not
successfully acknowledged, it is not echoed into the read queue.
0 FALSE
Disables Self Reception mode (default). Transmitted
frames do not appear in read queues.
1 TRUE
Enables Self Reception mode. Transmitted frames appear
in read queues as if they were received from another CAN
device.
The Self Reception mode is not available on the Intel 82527 CAN
controller used by Series 1 CAN hardware. For Series 1 interfaces, this
attribute must be left at its default (zero).
For LIN, this specifies whether or not to load frames for which the LIN
interface slave task is the publisher of the response into the read queue.
0 FALSE
Disables Self Reception mode (default). Frames for
which the LIN interface slave task is the publisher of the
response do not appear in read queues.
1 TRUE
Enables Self Reception mode. Frames for which the LIN
interface slave task is the publisher of the response appear
in read queues as if they were the result of an external
slave task publishing the response.
This attribute is available only for the Network Interface Objects, not
CAN Objects.
Series 2 Comparator
Specifies the filter comparator for the Philips SJA1000 CAN
controller. This attribute is not supported for Series 1 CAN, 847x LIN,
or 847x with Sync LIN interfaces (returns error).
This attribute specifies a comparator value that is checked against the
ID, RTR, and data bits. The Series 2 Mask determines the applicable
bits for comparison.
The default value of this attribute is zero.
The mapping of bits in this attribute to the ID, RTR, and data bits of
incoming frames is determined by the value of the Series 2 Filter
Series 2 Mask
Specifies the filter mask for the Philips SJA1000 CAN controller. This
attribute is not supported for Series 1 CAN, 847x LIN, or 847x with
Sync LIN interfaces (returns error).
This attribute specifies a bit mask that determines the ID, RTR, and
data bits that are compared. If a bit is clear in the mask, the
corresponding bit in the Series 2 Comparator is checked. If a bit
in the mask is set, that bit is ignored for the purpose of filtering
(don’t care). This interpretation is the opposite of the legacy
Standard/Extended Mask attributes.
The default value of this attribute is hex FFFFFFFF, which means that
all frames are received.
The mapping of bits in this attribute to the ID, RTR, and data bits of
incoming frames is determined by the value of the Series 2 Filter
Mode attribute. Refer to Series 2 Filter Mode to understand the
format of this attribute as well as the Series 2 Comparator.
Communication must be stopped to set this attribute. Use Start On
Open False with ncConfigCANNet.vi, set the desired attributes, then
use ncAction.vi to start communication.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11 Bit ID x x x x Data 0 Data 1
RTR
The 11 Bit ID compares all 11 bits of standard IDs. The RTR bit
determines whether the filter compares remote (1) or data (0)
frames. Bits marked as X are reserved, and should be cleared to
zero by the application. Data 0 compares the first data byte in the
frame, and Data 1 compares the second data byte.
1 (Single Extended)
Filter all extended (29-bit) frames using a single mask/comparator
filter.
Figure 10-6 describes the format of the Series 2 Mask and Series 2
Comparator attributes for this filter mode.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 Bit ID x x
RTR
The 29 Bit ID compares all 29 bits of extended IDs. The RTR bit
determines whether the filter compares remote (1) or data (0)
frames. Bits marked as X are reserved, and should be cleared to
zero by the application.
2 (Dual Standard)
Filter all standard (11-bit) frames using a two separate
mask/comparator filters. If either filter matches the frame, it is
received. The frame is discarded only when neither filter detects a
match.
Figure 10-7 describes the format of the Series 2 Mask and Series 2
Comparator attributes for this filter mode.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11 Bit ID Data 0 11 Bit ID
RTR RTR
Filter 1 Filter 2
Filter 1 includes the 11 Bit ID, the RTR bit, and the first data byte
in the frame. Filter 2 includes the 11 bit ID, and the RTR bit
(no data).
3 (Dual Extended)
Filter all extended (29-bit) frames using a two separate
mask/comparator filters. If either filter matches the frame, it is
received. The frame is discarded only when neither filter detects a
match.
Figure 10-8 describes the format of the Series 2 Mask and Series 2
Comparator attributes for this filter mode.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Upper 16 ID Upper 16 ID
Filter 1 Filter 2
For Series 1, 847x LIN, and 847x with Sync LIN interfaces, this
attribute must be left at its default (zero).
This attribute is available only for the Network Interface, not CAN
Objects.
Termination
Specifies the termination setting for your hardware. This attribute is
not supported on Series 1, Series 2, USB-8473, or USB-8473s
hardware. The values for this attribute are:
LS CAN
Timeline Recovery
Specifies whether to configure the CAN Network Interface Object to
recover the original timeline when a timestamped transmit is late.
This attribute is applicable only when the Transmit Mode attribute is
set to Timestamped Transmit (1).
Due to factors such as CAN bus arbitration, the time that a frame
transmits successfully may be later than the original time specified.
When a timestamped transmit is late, this attribute determines how
NI-CAN will adjust transmit times for subsequent frames.
The values for this attribute are:
0 (FALSE)
Do not recover the original timeline.
Frames always transmit with the original gap or greater. This
behavior is useful when you need to maintain a minimum gap
between frames. Figure 10-9 shows an original timeline of three
frames with a 10 ms gap. When frame B transmits 3 ms late, frame
C continues to transmit 10 ms later, so the actual timeline slips.
Original Timeline
Frame A Frame B Frame C
10 ms 23 ms 33 ms
Actual Timeline
1 (TRUE)
Recover the original timeline.
When a timestamped transmit is late, the subsequent frame will
transmit with a reduced gap. This behavior is useful when you
need to maintain a timeline, such as when synchronizing CAN
output with analog or digital output. Figure 10-10 shows an
original timeline of three frames with a 10 ms gap. When frame B
transmits 3 ms late, frame C transmits 7 ms later in order to
recover the timeline.
The default value for this attribute is FALSE.
This attribute has to be set prior to starting the CAN Network
Interface Object.
This attribute applies only to Series 1 and Series 2 hardware.
Original Timeline
Frame A Frame B Frame C
10 ms 23 ms 30 ms
Actual Timeline
Timestamp Format
Sets the format of the timestamps reported by the on-board timer on the
CAN or LIN hardware.
The default value for this attribute is Absolute.
The values for this attribute are:
0 (Absolute)
Sets the timestamp format to absolute. In the absolute format, the
timestamp returned by NI-CAN read functions is the LabVIEW
date/time format (DBL representing the number of seconds
elapsed since 12:00 a.m., Friday, January 1, 1904).
1 (Relative)
Sets the timestamp format to relative. In the relative format, the
timestamp returned by the NI-CAN read functions will be zero
based (DBL representing the number of seconds since the start
trigger occurred).
A typical use case for this attribute would be if data received from two
RTSI synchronized CAN or LIN cards is to be correlated. For that use
case, this attribute must be set to 1 for all of the CAN or LIN cards
being synchronized. Setting this attribute on one port of a 2-port card
will also reset the timestamp of the second port, since resetting the
timestamp on the port resets the on-board timer.
This attribute should be set prior to starting any communication on the
CAN or LIN hardware.
Transceiver Mode
Sets the transceiver mode for the Network Interface. The transceiver
mode controls whether the transceiver is asleep or communicating,
as well as other special modes.
This attribute is available only for the Network Interface, not CAN
Objects. Nevertheless, the attribute applies to communication by CAN
Objects as well as the associated Network Interface.
This attribute is supported on Series 2, 847x CAN, and 847x with Sync
CAN interfaces only.
For Series 2 cards for the PCMCIA form factor, this property requires
a corresponding Series 2 cable (dongle). For information on how to
identify the series of the PCMCIA cable, refer to the Series 2 Vs.
Series 1 section of Chapter 1, Introduction.
Transceiver Type
For XS software selectable physical layer cards that provide a
software-switchable transceiver, the Transceiver Type attribute sets
the type of transceiver. When the transceiver is switched from one type
to another, NI-CAN ensures that the switch is undetectable from the
perspective of other nodes on the network.
The default value for this attribute is specified within MAX. If you
change the transceiver type in MAX to correspond to the network in
use, you can avoid setting this attribute within the application.
This attribute is available only for the Network Interface, not CAN
Objects. Nevertheless, the attribute applies to communication by CAN
Objects as well as the associated Network Interface.
Communication for all objects on the Network Interface must be
stopped prior to setting this attribute. You typically do this by
calling ncConfigCANNet.vi with Start On Open set to false, then
ncOpen.vi of the Network Interface, then ncSetAttr.vi to set
Transceiver Type, then ncAction.vi to start communication. Prior to
changing the Transceiver Type again, you must use ncAction.vi to
stop communication.
You can only set this attribute for Series 2 XS interfaces.
This attribute uses the following values:
0 (High-Speed)
Switch the transceiver to High-Speed (HS).
1 (Low-Speed/Fault-Tolerant)
Switch the transceiver to Low-Speed/Fault-Tolerant (LS).
2 (Single Wire)
Switch the transceiver to Single Wire (SW).
3 (External)
Switch the transceiver to External. The External type allows you
to connect a transceiver externally to the interface. For more
information on connecting transceivers externally, refer to
Chapter 3, NI CAN and LIN Hardware.
When this transceiver type is selected, you can use the
Transceiver External Outputs and Transceiver External
Inputs attributes to access the external mode and status pins of the
connector.
4 (Disconnect)
Disconnect the CAN controller chip from the connector. This
value is used when you physically switch an external transceiver.
You first set Transceiver Type to Disconnect, then switch from
one external transceiver to another, then set Transceiver Type to
External. For more information on connecting transceivers
externally, refer to Chapter 3, NI CAN and LIN Hardware.
Transmit Mode
Specifies whether to configure the CAN Network Interface Object to
Immediate Transmit mode or Timestamped Transmit mode.
The default value for this attribute is zero (Immediate Transmit).
The values for this attribute are:
0 (Immediate Transmit)
Configures the Network Interface Object in the Immediate
Transmit mode. In the Immediate Transmit mode, the CAN
frames are transmitted as soon as they are written into the Network
Interface Object’s write queue. CAN frames can be written into
the Network Interface Objects write queue by either using
ncWriteNet.vi or ncWriteNetMult.vi. Timestamps are ignored
by NI-CAN when the Network Interface Object is configured in
this mode.
1 (Timestamped Transmit)
Configures the Network Interface Object in the Timestamped
Transmit mode. In this mode, NI-CAN spaces the frame
transmission according to the difference in timestamps between
across the virtual bus. This mode is useful when you want the
virtual bus to behave as much like a real bus as possible.
If this attribute is set on real hardware, an error will be returned.
The Virtual Bus Timing has to be set to the same value on both virtual
interfaces.
This attribute must be set prior to starting the virtual interface.
Refer to the Frame to Channel Conversion section of Chapter 6, Using
the Channel API for more information.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Description
ncSetAttr.vi sets the value of the attribute specified by AttrId in the object specified by
ObjHandle in.
ncWaitForState.vi
Purpose
Wait for one or more states to occur in an object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Description
Use ncWaitForState.vi to wait for one or more states to occur in the object specified by
ObjHandle. If an error occurs in the object, wait aborts and returns the error in Error out.
While waiting for the desired states, ncWaitForState.vi suspends execution of the current
LabVIEW thread. VIs assigned to other threads can still execute. The thread of a VI can be
changed in the Priority control in the Execution category of VI properties.
You cannot invoke ncWaitForState.vi twice from different VIs for the same object.
For different object handles, these functions can overlap in execution.
ncWriteNet.vi
Purpose
Write a single frame to a CAN or LIN Network Interface Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Note The description of the input terminals is specified by the frame type. The value of
IsRemote indicates the frame type. For a description of each frame type, refer to the Frame
Types section of this function reference.
Output
ObjHandle out is the object handle for the next NI-CAN VI.Error out
describes error conditions. If the Error in cluster indicated an error, the
Error out cluster contains the same information. Otherwise, Error out
describes the error status of this VI.
Description
You use ncWriteNet.vi to place a frame into the Network Interface write queue. Since
NI-CAN handles the write queue in the background, this VI does not wait for the frame to be
transmitted on the network.
To transmit a set of frames as quickly as possible, simply call ncWriteNet.vi once per frame,
without using ncWaitForState.vi after each write. This technique makes good use of the
write queue to optimize frame transmission.
Once you have written frames, if you need to wait for the final ncWriteNet.vi to be
transmitted successfully, use ncWaitForState.vi with the Write Success state. The Write
Success state sets when all frames of the write queue have been successfully transmitted. The
Write Success state clears whenever you call ncWriteNet.vi.
The ncWriteNet.vi and ncWriteNetMult.vi functions share a common write queue in the
Network Interface. Therefore, when you set the Transmit Mode attribute to Timestamped
Transmit, ncWriteNetMult.vi places timestamped frames into the queue, and ncWriteNet.vi
places non-timestamped frames into the queue. If you write timestamped frames followed by
a non-timestamped frame, the timestamped frames will transmit first, followed immediately
by the non-timestamped frame. For example, assume you write 3 frames A, B, and C with
ncWriteNetMult.vi, followed by frame D with ncWriteNet.vi, and frame E with
ncWriteNetMult.vi. Frames A, B, and C will transmit in their timed sequence. Frame D
immediately follows frame C. Frame E transmits with the expected time distance from frame
C, because the non-timestamped frame does not affect ncWriteNetMult.vi timing.
Sporadic, recoverable errors on the network are handled automatically by the CAN protocol.
As such, after ncWriteNet.vi returns successfully, NI-CAN eventually transmits the frame on
the network unless there is a serious network problem. Network problems such as missing or
If the write queue is full, a call to ncWriteNet.vi returns the error CanErrOverflowWrite
(status=T, code= BFF62008 hex). In many cases, this error is recoverable, so you should not
exit the application when it occurs. For example, if you want to transmit thousands of frames
in succession (for example, downloading code), the application can check for the error
CanErrOverflowWrite, and when detected, simply wait a few milliseconds for some of the
frames to transmit, then call ncWriteNet.vi again. If the second call to ncWriteNet.vi returns
an error, that can be treated as an unrecoverable error (no other device is ACKing the frames).
Although the Network Interface allows Write Queue Length of zero, this is not
recommended, because every new frame will always overwrite the previous frame.
Frame Types
IsRemote indicates the frame type. The frame type determines the interpretation of the
remaining fields. Table 10-34, IsRemote value 0: CAN Data Frame, Table 10-35, IsRemote
value 1: CAN Remote Frame, Table 10-36, IsRemote Value 16: LIN Response Entry Frame,
Table 10-37, IsRemote Value 17: LIN Header Frame, and Table 10-38, IsRemote Value 18:
LIN Full Frame, describe the fields of the cluster for each value of IsRemote.
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
Data
Field Name Type Description
IsRemote Value 0 represents a CAN data frame. The CAN data frame contains
data from the network.
Data
Field Name Type Description
IsRemote Value 1 represents a CAN remote frame.
Data
Field Name Type Description
IsRemote Value 16 represents a response entry frame for LIN
communication.The behavior resulting from writing a response type
to the LIN interface depends upon whether the LIN Sleep attribute is
set to TRUE or FALSE (the LIN interface is asleep or awake,
respectively).
If the LIN Sleep attribute is set to FALSE:
A response entry frame is issued when it is desired to configure the
LIN interface slave task to subscribe to or publish data, in response to
a particular header ID received from a master task. Each response
entry frame indicates the ID of the header for which it is to respond,
whether the response is to publish data or subscribe to data, and if it is
to publish data, the data length code (DLC) and data values. The DLC
determines whether the response will be to subscribe (DLC = 0), or
publish (DLC = data length), in response to a header containing the ID
of the response frame. Sixty-four response entry frames (one for each
of the sixty-four LIN IDs) may be written to the response queue in the
LIN interface. When the Network Interface is created or reset, the
interface is reset to act as a slave and to respond as subscriber to data
for all LIN IDs.
If the LIN Sleep attribute is set to TRUE:
A response entry frame is issued when the LIN interface has been
acting as a slave (processing master headers), has been put asleep, and
is desired to be used to wake the bus and initiate the transmission of
headers by the master. When the response entry type is written to the
LIN interface, two things occur. First, the response queue is loaded
with the ID, DLC, and data (if DLC is non-zero meaning the response
is to publish), of the response entry frame. Next the interface transmits
a wakeup break on the bus. Per the LIN specification, it either waits
until the master acknowledges the wakeup break by writing a header
within the specified time, or re-transmits the wakeup break if it does
not. When the master responds with a header, the LIN interface sets
the LIN Sleep attribute to FALSE, and responds to the ID contained
in the header in the manner (publish or subscribe) specified for that ID
in the response queue.
ArbitrationId Zero to sixty-three.
Table 10-36. IsRemote Value 16: LIN Response Entry Frame (Continued)
Data
Field Name Type Description
DataLength Zero if the response is to subscribe to data. Actual length of Data if
the response is to publish data.
Data
Field Name Type Description
IsRemote Value 17 represents a header frame for LIN communication. The
behavior resulting from writing a header type to the LIN interface
depends upon whether the LIN Sleep attribute is set to TRUE or
FALSE (the LIN interface is asleep or awake, respectively).
If the LIN Sleep attribute is set to FALSE:
A header frame is issued when it is desired to use the LIN interface
as a master, querying a slave task to publish data. Issuing a header
frame causes the LIN interface to write a break-sync-id sequence to
the LIN bus, with the expectation that a slave task will publish data.
Once a header frame is issued, the LIN interface will behave as a
master until the next time it is started.
If the LIN Sleep attribute is set to TRUE:
A header frame is issued when the LIN interface has been acting as
a master (transmitting header and full IsResponse types), has been
put asleep, and is desired to be used to wake the LIN bus and query
a slave task to publish data. Issuing a header frame causes the LIN
interface to write a wakeup break followed by break-sync-id
sequence to the LIN bus, with the expectation that all slaves will
wake up and a slave task will publish data in response. The LIN
interface also sets the LIN Sleep attribute to FALSE.
ArbitrationId Zero to sixty-three.
Data
Field Name Type Description
DataLength One to eight if the Enable DLC Check attribute is set to 1 (TRUE).
If the Enable DLC Check attribute is set to 0 (FALSE), the data
length is ignored.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 18 represents a full frame for LIN communication. The
behavior resulting from writing a full type to the LIN interface
depends upon whether the LIN Sleep attribute is set to TRUE or
FALSE (the LIN interface is asleep or awake, respectively).
If the LIN Sleep attribute is set to FALSE:
A full frame is issued when it is desired to use the LIN interface as
a master, publishing data to an external slave. Issuing a full frame
causes the LIN interface slave task response queue to be updated,
the master task to write a header to the LIN bus, then the LIN
interface slave task to publish a response, with the expectation that
one or more external slaves will subscribe to the data. Once a full
frame is issued, the LIN interface will behave as a master until the
next time it is started.
If the LIN Sleep attribute is set to TRUE:
A full frame is issued when the LIN interface has been acting as a
master (transmitting header and full IsResponse types), has been
put asleep, and is desired to be used to wake the LIN bus and publish
data to one or more external slaves. Issuing a full frame causes the
LIN interface slave task response queue to be updated, the master
task to write a wakeup break followed by a header to the LIN bus,
then the LIN interface slave task to publish a response, with the
expectation that all slaves will wake up and one or more external
slaves will subscribe to the published data. The LIN interface also
sets the LIN Sleep attribute to FALSE.
Data
Field Name Type Description
ArbitrationId Zero to sixty-three.
ncWriteNetMult.vi
Purpose
Write multiple frames to a CAN or LIN Network Interface Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
This input is optional. When this input is unwired, the function will write
all valid frames listed in the Data array. The NumberToWrite input is
most useful when you have a large array of frames, and you only want to
transmit a subset of that array.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Description
Use ncWriteNetMult.vi to place one or more frames into the Network Interface write queue.
This function does not wait for the frames to be transmitted on the network.
Timestamped Transmit
In addition to supporting multiple frames, this function is preferable to ncWriteNet.vi in that
it supports timestamped frames. To enable timestamped transmit, use ncSetAttr.vi to set the
Transmit Mode attribute to Timestamped Transmit mode (1).
In Timestamped Transmit mode, NI-CAN times the transmission according to the difference
in timestamps between consecutive frames. For example, if every frame provided to
ncWriteNetMult.vi increments by 10 milliseconds, the frames will be transmitted with a
10 millisecond gap.
If the timestamp of one frame is less than the timestamp of the preceding frame, the timeline
is reset, and both frames transmit back to back. For example, if you write a frame with relative
timestamp 30 ms followed by a frame with timestamp 15 ms, the two frames will be
transmitted back to back. This sort of behavior can occur when you transmit a logfile of
timestamped frames repeatedly, because on the second traversal of the logfile, the timestamp
of the first frame will be less than the timestamp of the last frame.
The first frame that you provide to ncWriteNetMult.vi always transmits immediately,
regardless of its timestamp. If you need to delay transmission of first frame after start, you can
write a Delay frame or Start Trigger frame as described in the Frame Types section of this
function reference.
847x CAN and LIN products do not support timestamped transmit. These products ignore the
timestamp provided in the cluster for ncWriteNetMult.vi. If you use ncWriteNetMult.vi to
write header and full frame types out of the USB LIN acting as master, then the frames will
be transmitted together as closely as possible. If you use ncWriteNetMult.vi to write
response frame types to the LIN interface acting as slave, then the frames will be loaded into
the response table as quickly as possible.
Immediate Transmit
The default value for the Transmit Mode attribute is Immediate Transmit mode (0).
In Immediate Transmit mode, NI-CAN ignores the timestamp in each frame, and transmits
the frames as fast as possible. This behavior is equivalent to the ncWriteNet.vi function,
except that you can write multiple frames for transmission in quick succession.
When the Network Interface write queue cannot hold all frames provided,
ncWriteNetMult.vi returns an overflow error. When this overflow error is returned, none of
the frames provided in the Data array have been written. This enables your application to try
the same Data array again at a later time.
To determine when adequate space is available in the write queue to retry ncWaitForState.vi
with the Write Multiple state. The Write Multiple state will transition from false to true
when space is available for at least 512 frames. Since you must limit the Data input of
ncWriteNetMult.vi to 512 frames or less, the Write Multiple state indicates that a retry will
succeed.
Another technique to recover from a write queue overflow is to use ncGetAttr.vi with the
Write Entries Free attribute. Although this technique requires you to call ncGetAttr.vi
periodically until the desired number of frame entries is available, it avoids the need to
determine a proper Timeout for ncWaitForState.vi. When the time difference between
frames varies from milliseconds to seconds, it may be difficult to determine how long to wait
for entries to become available.
After writing a sequence of timestamped frames with ncWriteNetMult.vi, you cannot close
the Network Interface, because you must wait for the last timestamped frame to transmit onto
the network. You can wait for the final transmit to complete using ncWaitForState.vi with
the Write Success state. You can also use ncGetAttr.vi with the Write Entries Pending
attribute to query periodically, which provides the option of aborting the timestamped
transmission by closing the Network Interface.
Frame Types
Within each cluster of the Data array, IsRemote indicates the frame type. The frame type
determines the interpretation of the remaining fields. Table 10-39, Cluster with IsRemote
value 0: CAN Data Frame, Table 10-40, Cluster with IsRemote value 1: CAN Remote Frame,
Table 10-41, Cluster with IsRemote value 4: Start Trigger Frame, Table 10-42, Cluster with
IsRemote value 5: Delay Frame, Table 10-43, IsRemote Value 16: LIN Response Entry
Frame, Table 10-44, IsRemote Value 17: LIN Header Frame, and Table 10-45, IsRemote
Value 18: LIN Full Frame, describe the fields of the cluster for each value of IsRemote.
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
Data
Field Name Type Description
IsRemote Value 0 specifies a CAN data frame.
The CAN data frame transfers data on the network.
Table 10-39. Cluster with IsRemote value 0: CAN Data Frame (Continued)
Data
Field Name Type Description
Timestamp If the Transmit Mode attribute is Immediate Transmit (default),
this field is ignored, and CAN frames transmit as quickly as
possible.
If the Transmit Mode attribute is Timestamped Transmit, this field
specifies a timestamp. The timestamp is used to time transmission
of CAN frames as described in the Timestamped Transmit section
of this function reference.
The timestamp is a LabVIEW numeric DBL with Format and
Precision of Absolute time (time and date) or Relative time
(zero based). The integer part contains seconds, and the fractional
part contains milliseconds and microseconds.
Data
Field Name Type Description
IsRemote Value 1 specifies a CAN remote frame.
The CAN remote frame requests data for its arbitration ID.
ArbitrationId Specifies the arbitration ID of the remote frame to transmit.
Table 10-40. Cluster with IsRemote value 1: CAN Remote Frame (Continued)
Data
Field Name Type Description
Timestamp If the Transmit Mode attribute is Immediate Transmit (default),
this field is ignored, and CAN frames transmit as quickly as
possible.
If the Transmit Mode attribute is Timestamped Transmit, this field
specifies a timestamp. The timestamp is used to time transmission
of CAN frames as described in the Timestamped Transmit section
of this function reference.
The timestamp is a LabVIEW numeric DBL with Format and
Precision of Absolute time (time and date) or Relative time
(zero based). The integer part contains seconds, and the fractional
part contains milliseconds and microseconds. You can use either
absolute or relative time, because the timing is determined solely on
the difference in the timestamps of sequential frames.
Data
Field Name Type Description
IsRemote Value 4 specifies a start trigger frame.
When you use ncWriteNetMult.vi to write frames from a logfile
for timestamped transmit, you can write the start trigger frame as
the first frame. The start trigger frame reproduces the delay from
start of communication to the first CAN frame. For example, if you
write a start trigger frame followed by a CAN data frame with
relative timestamp 20 ms, NI-CAN will delay 20 ms before
transmitting the CAN data frame. If you write the CAN data frame
without the start trigger frame, NI-CAN will transmit the CAN data
frame immediately.
ArbitrationId Value 0 is required.
Table 10-41. Cluster with IsRemote value 4: Start Trigger Frame (Continued)
Data
Field Name Type Description
Data The single data byte in the array specifies the Timestamp Format
(defined by ncSetAttr.vi) used for all subsequent CAN frames. The
value is 0 for absolute timestamps, and 1 for relative timestamps. In
order for NI-CAN to delay the proper time for the start trigger, this
timestamp format must match the format used in all subsequent
frames provided to ncWriteNetMult.vi.
Timestamp Absolute timestamp of the start trigger. Within a logfile, this
timestamp indicates the date and time at which CAN
communication started.
The timestamp is a LabVIEW numeric DBL with Format and
Precision of Absolute time (date/time). The format of this
timestamp is always absolute, even when Data byte 0 specifies
relative timestamp format. This absolute timestamp provides
data/time information even when the CAN frames of a logfile use
the relative format.
When Data byte 0 specifies absolute format (0), the difference
between this timestamp and the absolute timestamp of the
subsequent CAN frame is used as the delay for transmit of that CAN
frame. When Data byte 0 specifies relative format (1), this
timestamp is ignored by NI-CAN, and the relative timestamp of the
subsequent CAN frame is used as the transmit delay.
Data
Field Name Type Description
IsRemote Value 5 specifies a delay frame.
Use the delay frame to insert an additional delay between any
two timestamped frames. For example, if you write a CAN frame
with relative timestamp 20 ms, followed by a delay frame of 30 ms,
followed by a CAN frame with timestamp 55 ms, NI-CAN will
transmit the CAN frames 65 ms apart.
ArbitrationId Value 0 is required.
Data
Field Name Type Description
DataLength Value 0 is required.
Data Ignored.
Data
Field Name Type Description
IsRemote Value 16 represents a response entry frame for LIN communication.The
behavior resulting from writing a response type to the LIN interface
depends upon whether the LIN Sleep attribute is set to TRUE or FALSE
(the LIN interface is asleep or awake, respectively).
If the LIN Sleep attribute is set to FALSE:
A response entry frame is issued when it is desired to configure the LIN
interface slave task to subscribe to or publish data, in response to a
particular header ID received from a master task. Each response entry
frame indicates the ID of the header for which it is to respond, whether
the response is to publish data or subscribe to data, and if it is to publish
data, the data length code (DLC) and data values. The DLC determines
whether the response will be to subscribe (DLC = 0), or publish (DLC =
data length), in response to a header containing the ID of the response
frame. Sixty-four response entry frames (one for each of the sixty-four
LIN IDs) may be written to the response queue in the LIN interface.
When the Network Interface is created or reset, the interface is reset to
act as a slave and to respond as subscriber to data for all LIN IDs.
If the LIN Sleep attribute is set to TRUE:
A response entry frame is issued when the LIN interface has been acting
as a slave (processing master headers), has been put asleep, and is
desired to be used to wake the bus and initiate the transmission of
headers by the master. When the response entry type is written to the
LIN interface, two things occur. First, the response queue is loaded with
the ID, DLC, and data (if DLC is non-zero meaning the response is to
publish), of the response entry frame. Next the interface transmits a
wakeup break on the bus. Per the LIN specification, it either waits until
the master acknowledges the wakeup break by writing a header within
the specified time, or re-transmits the wakeup break if it does not. When
the master responds with a header, the LIN interface sets the LIN Sleep
attribute to FALSE, and responds to the ID contained in the header in the
manner (publish or subscribe) specified for that ID in the response
queue.
ArbitrationId Zero to sixty-three.
Table 10-43. IsRemote Value 16: LIN Response Entry Frame (Continued)
Data
Field Name Type Description
DataLength Zero if the response is to subscribe to data. Actual length of Data if the
response is to publish data.
Timestamp Ignored.
Data
Field Name Type Description
IsRemote Value 17 represents a header frame for LIN communication. The
behavior resulting from writing a header type to the LIN interface
depends upon whether the LIN Sleep attribute is set to TRUE or
FALSE (the LIN interface is asleep or awake, respectively).
If the LIN Sleep attribute is set to FALSE:
A header frame is issued when it is desired to use the LIN interface
as a master, querying a slave task to publish data. Issuing a header
frame causes the LIN interface to write a break-sync-id sequence to
the LIN bus, with the expectation that a slave task will publish data.
Once a header frame is issued, the LIN interface will behave as a
master until the next time it is started.
If the LIN Sleep attribute is set to TRUE:
A header frame is issued when the LIN interface has been acting as
a master (transmitting header and full IsResponse types), has been
put asleep, and is desired to be used to wake the LIN bus and query
a slave task to publish data. Issuing a header frame causes the LIN
interface to write a wakeup break followed by break-sync-id
sequence to the LIN bus, with the expectation that all slaves will
wake up and a slave task will publish data in response. The LIN
interface also sets the LIN Sleep attribute to FALSE.
ArbitrationId Zero to sixty-three.
DataLength One to eight if the Enable DLC Check attribute is set to 1 (TRUE).
If the Enable DLC Check attribute is set to 0 (FALSE), the data
length is ignored.
Data Ignored.
Timestamp Ignored.
Data
Field Name Type Description
IsRemote Value 18 represents a full frame for LIN communication. The
behavior resulting from writing a full type to the LIN interface
depends upon whether the LIN Sleep attribute is set to TRUE or
FALSE (the LIN interface is asleep or awake, respectively).
If the LIN Sleep attribute is set to FALSE:
A full frame is issued when it is desired to use the LIN interface as
a master, publishing data to an external slave. Issuing a full frame
causes the LIN interface slave task response queue to be updated,
the master task to write a header to the LIN bus, then the LIN
interface slave task to publish a response, with the expectation that
one or more external slaves will subscribe to the data. Once a full
frame is issued, the LIN interface will behave as a master until the
next time it is started.
If the LIN Sleep attribute is set to TRUE:
A full frame is issued when the LIN interface has been acting as a
master (transmitting header and full IsResponse types), has been
put asleep, and is desired to be used to wake the LIN bus and publish
data to one or more external slaves. Issuing a full frame causes the
LIN interface slave task response queue to be updated, the master
task to write a wakeup break followed by a header to the LIN bus,
then the LIN interface slave task to publish a response, with the
expectation that all slaves will wake up and one or more external
slaves will subscribe to the published data. The LIN interface also
sets the LIN Sleep attribute to FALSE.
ArbitrationId Zero to sixty-three.
Timestamp Ignored.
ncWriteObj.vi
Purpose
Write a single frame to a CAN Object.
Format
Input
ObjHandle in is the object handle from the previous NI-CAN VI. The
handle originates from ncOpen.vi.
Output
ObjHandle out is the object handle for the next NI-CAN VI.
Description
Use ncWriteObj.vi to place a frame into the CAN Object write queue. Since NI-CAN
handles the write queue in the background, this VI does not wait for the frame to be
transmitted on the network.
Once you have written frames, if you need to wait for the final ncWriteObj.vi to be
transmitted successfully, use ncWaitForState.vi with the Write Success state. The Write
Success state sets when all frames of the write queue have been successfully transmitted. The
Write Success state clears whenever you call ncWriteObj.vi.
The Write Success state does not necessarily mean that all transmission has stopped for the
CAN Object. For example, when the CAN Object Communication Type is Transmit Data
Periodically, the Write Success state sets when the final frame in the write queue is
transmitted, but the previous frame will be transmitted again once the Period expires.
Sporadic, recoverable errors on the network are handled automatically by the CAN protocol.
As such, after ncWriteObj.vi returns successfully, NI-CAN eventually transmits the frame
on the network unless there is a serious network problem. Network problems such as missing
or malfunctioning devices are often reported as the warning CanWarmComm (status=F,
code=3FF6200B hex).
If the write queue is full, a call to ncWriteObj.vi returns the error CanErrOverflowWrite
(status=T, code= BFF62008 hex). In many cases, this error is recoverable, so you should not
exit the application when it occurs. For example, if you want to transmit thousands of frames
in succession (for example, large waveform transmitted periodically), the application can
check for the error CanErrOverflowWrite, and when detected, simply wait a few
milliseconds for some of the frames to transmit, then call ncWriteObj.vi again. If the second
call to ncWriteObj.vi returns an error, that can be treated as an unrecoverable error (for
example, no other device is ACKing the frames).
If you need to write a sequence of frames to the CAN Object, and ensure that each frame is
transmitted, configure the Write Queue Length of the CAN Object to greater than zero. If
you only need to transmit the most recent frame provided with ncWriteObj.vi, you can set
the Write Queue Length to zero.
If the CAN Object Communication Type specifies Receive behavior, the ncWriteObj.vi VI
can be used to transmit a remote frame. When using ncWriteObj.vi to transmit a remote
frame, the Data input can be left unwired.
Unless otherwise stated, each NI-CAN function suspends execution of the calling thread until
it completes. The functions in this chapter are listed alphabetically.
Section Headings
The following are section headings found in the Frame API for C functions.
Purpose
Each function description includes a brief statement of the purpose of the function.
Format
The format section describes the format of each function for the C programming language.
Description
The description section gives details about the purpose and effect of each function.
CAN Object
The CAN Object section gives details about using the function with the CAN Object.
Data Types
The following data types are used with functions of the NI-CAN Frame API for C.
Table 11-1. Data Types for NI-CAN Frame API for C (Continued)
List of Functions
Table 11-2 contains an alphabetical list of the NI-CAN Frame API for C functions.
Function Purpose
ncAction Perform an action on an object.
ncCloseObject Close an object.
ncConfig Configure an object before using it.
ncConnectTerminals Connect terminals in the CAN or LIN hardware.
ncCreateNotification Create a notification call back for an object.
ncDisconnectTerminals Disconnect terminals in the CAN or LIN
hardware.
ncGetAttribute Get the value of an object attribute.
ncGetHardwareInfo Get CAN and LIN hardware information.
ncOpenObject Open an object.
ncRead Read the data value of an object.
ncReadMult Read multiple data values from the queue of an
object.
Function Purpose
ncSetAttribute Set the value of an object attribute.
ncStatusToString Convert status code into a descriptive string.
ncWaitForState Wait for one or more states to occur in an object.
ncWrite Write the data value of an object.
ncWriteMult Write multiple frames to a CAN or LIN
Network Interface Object.
ncAction
Purpose
Perform an action on an object.
Format
NCTYPE_STATUS ncAction(
NCTYPE_OBJH ObjHandle,
NCTYPE_OPCODE Opcode,
NCTYPE_UINT32 Param);
Input
ObjHandle
Object handle from ncOpenObject.
Opcode
Operation code indicating which action to perform.
Param
Parameter whose meaning is defined by Opcode.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncAction is a general purpose function you can use to perform an action on the object
specified by ObjHandle. Its normal use is to start and stop network communication on a
CAN Network Interface Object.
For the most frequently used and/or complex actions, NI-CAN provides functions such as
ncOpenObject and ncRead. ncAction provides an easy, general purpose way to perform
actions that are used less frequently or are relatively simple.
Table 11-3. Actions Supported by the CAN or LIN Network Interface Object
CAN Object
All actions performed on a CAN Object affect that CAN Object alone, and do not affect other
CAN Objects or communication as a whole.
ncCloseObject
Purpose
Close an object.
Format
NCTYPE_STATUS ncCloseObject
(
NCTYPE_OBJH ObjHandle);
Input
ObjHandle
Object handle.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncCloseObject closes an object when it no longer needs to be in use, such as when the
application is about to exit. When an object is closed, NI-CAN stops all pending operations
and clears RTSI configuration for the object, and you can no longer use the ObjHandle in the
application.
CAN Object
ObjHandle refers to an open CAN Object.
ncConfig
Purpose
Configure an object before using it.
Format
NCTYPE_STATUS ncConfig(
NCTYPE_STRING ObjName,
NCTYPE_UINT32 NumAttrs,
NCTYPE_ATTRID_P AttrIdList,
NCTYPE_UINT32_P AttrValueList);
Input
ObjName
ASCII name of the object to configure.
The 847x and 847x with Sync series LIN interfaces do not support
ncConfig.
NumAttrs
Number of configuration attributes.
AttrIdList
List of configuration attribute identifiers.
AttrValueList
List of configuration attribute values.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncConfig initializes the configuration attributes of an object before opening it. The first
NI-CAN function in the application will normally be ncConfig of the CAN Network
Interface Object.
The Frame API and Channel API cannot use the same CAN network interface
simultaneously. If the CAN network interface is already initialized in the Channel API,
this function returns an error.
The following sections describe how to use ncConfig with the Network Interface and CAN
Object. The description for each object specifies the syntax for ObjName, plus a description
of the commonly used attributes for AttrIdList.
The special ObjName values “CAN256” and “CAN257” refer to virtual interfaces. For virtual
interfaces, the only valid attribute is NC_ATTR_START_ON_OPEN. All other attributes in the
AttrIdList are ignored. The mask and comparator attributes are always zero for virtual
interfaces (receive all frames).
For more information on usage of virtual interfaces, refer to the Frame to Channel
Conversion section of Chapter 6, Using the Channel API.
The following attribute IDs are commonly used for CAN Network Interface Object
configuration.
For the 847x and 847x with Sync series CAN interfaces, only
NC_ATTR_START_ON_OPEN and NC_ATTR_BAUD_RATE are valid
configuration attributes. All other configuration attributes are ignored.
NC_True enables listen only mode. The Network Interface and CAN
Objects can only receive frames. The interface does not transmit on the
network: no ACKnowledgements are transmitted for received frames,
and ncWrite will return an error. The Philips SJA1000 CAN
controller enters the request/response state when listen only is enabled.
The listen only mode is not available on the Intel 82527 CAN
controller used by Series 1 CAN hardware. For Series 1 hardware,
this attribute must be left out of the AttrIdList.
programmed directly into the Intel 82527 CAN controller. Use those
attributes to specify filtering of received frames on Series 1 hardware.
The Philips SJA1000 does not support distinct standard and extended
masking. Therefore, on Series 2 interfaces the Standard
Mask/Comparator and Extended Mask/Comparator attributes are
implemented in software (for backward compatibility). Since software
masking can have an adverse impact on receive performance, National
Instruments recommends that you disable software masking for
Series 2 interfaces. Disable software masking by specifying don’t-care
(0) for all four mask/comparator attributes of ncConfig.
Since the format of the Series 2 filters is very specific to the Philips
SJA1000 CAN controller, National Instruments cannot guarantee
compatibility for this attribute on future hardware series. When
using this attribute in the application, it is best to get the
NC_ATTR_HW_SERIES (Series) attribute to verify that the CAN
hardware is Series 2, 847x, or 847x with Sync.
The filtering specified by this attribute and the Series 2
Mask/Comparator applies to the CAN Network Interface Object and
all CAN Objects for that interface. For example, if you specify filters
that discard ID 5, then open a CAN Object to receive ID 5, the CAN
Object will not receive data.
The default value for this attribute is
NC_FILTER_SINGLE_STANDARD.
This attribute uses the following values:
NC_FILTER_DUAL_EXTENDED (Dual Extended)
Filter all extended (29-bit) frames using a two separate
mask/comparator filters. If either filter matches the frame, it is
received. The frame is discarded only when neither filter detects
a match.
Figure 11-1 describes the format of the Series 2 Mask and Series 2
Comparator attributes for this filter mode.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Upper 16 ID Upper 16 ID
Filter 1 Filter 2
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11 Bit ID Data 0 11 Bit ID
RTR RTR
Filter 1 Filter 2
Filter 1 includes the 11 Bit ID, the RTR bit, and the first data byte
in the frame. Filter 2 includes the 11 bit ID, and the RTR bit
(no data).
NC_FILTER_SINGLE_EXTENDED (Single Extended)
Filter all extended (29-bit) frames using a single mask/comparator
filter.
Figure 11-3 describes the format of the Series 2 Mask and Series 2
Comparator attributes for this filter mode.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 Bit ID x x
RTR
The 29 Bit ID compares all 29 bits of extended IDs. The RTR bit
determines whether the filter compares remote (1) or data (0)
frames. Bits marked as X are reserved, and should be cleared to
zero by the application.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11 Bit ID x x x x Data 0 Data 1
RTR
The 11 Bit ID compares all 11 bits of standard IDs. The RTR bit
determines whether the filter compares remote (1) or data (0)
frames. Bits marked as X are reserved, and should be cleared to
zero by the application. Data 0 compares the first data byte in the
frame, and Data 1 compares the second data byte.
NC_ATTR_RTSI_MODE (RTSIMode)
RTSI Mode specifies the behavior of the Network Interface with
respect to RTSI, including whether the RTSI signal is an input or
output:
NC_RTSI_NONE
CAN Object
ObjName is the name of the CAN Object to configure. This string uses the syntax
“CANx::STDy” or “CANx::XTDy”. CANx is the name of the CAN network interface that you
used for the preceding ncConfig function. STD indicates that the CAN Object uses a
standard (11-bit) arbitration ID. XTD indicates that the CAN Object uses an extended (29-bit)
arbitration ID. The number y specifies the actual arbitration ID of the CAN Object. The
number y is decimal by default, but you also can use hexadecimal by adding “0x” to the
beginning of the number. For example, “CAN0::STD25” indicates standard ID 25 decimal on
CAN0, and “CAN1::XTD0x0000F652” indicates extended ID F652 hexadecimal on CAN1.
In order to configure one or more CAN Objects, you must configure the CAN Network
Interface Object first.
The special virtual interface names CAN256 and CAN257 are not supported for CAN
Objects.
The following attribute IDs are commonly used for CAN Object configuration:
the last frame is transmitted, the CAN Objects waits the specified
period, then transmits the first frame again.
If you need to change the waveform contents at runtime, or if you
need to transmit very large waveforms (more than 100 frames),
we recommend using the NC_CAN_COMM_TX_PERIODIC
type. Using that type, you can write frames to the Write Queue
until full (overflow error), then wait some time for a few frames to
transmit, then continue writing new frames.
This communication type has the following limitations:
• Write Queue Length must be greater than zero.
• You must write exactly Write Queue Length values before starting
communication (no less).
• Once communication is started, you cannot write additional values.
Period specifies the periodic rate. Transmit by Response
and Receive Changes Only are ignored.
NC_ATTR_DATA_LEN (DataLength)
Data Length specifies the number of bytes in the data frames for this
CAN Object ID. This number is placed in the Data Length Code
(DLC) of all transmitted data frames and remote frames for the CAN
Object. This is also the number of data bytes returned from ncRead
when the communication type indicates receive.
NC_ATTR_PERIOD (Period)
Period specifies the rate of periodic behavior in milliseconds.
The behavior depends on the Communication Type as follows:
NC_CAN_COMM_RX_BY_CALL
Period specifies a minimum interval between subsequent
transmissions. Even if ncWrite is called very frequently, frames
are transmitted on the network at a rate no more than Period.
Setting Period to zero disables the minimum interval timer.
NC_CAN_COMM_RX_PERIODIC
NC_CAN_COMM_RX_UNSOL
NC_ATTR_RTSI_MODE (RTSIMode)
RTSI Mode specifies the behavior of the CAN Object with respect to
RTSI, including whether the RTSI signal is an input or output:
NC_RTSI_NONE
Disables RTSI behavior for the CAN Object (default). All other
RTSI attributes are ignored.
NC_RTSI_OUT_ACTION_ONLY
The CAN Object will output the RTSI signal whenever the
ncAction function is called with Opcode NC_OP_RTSI_OUT.
This RTSI mode can be used to manually toggle/pulse a RTSI
output within the application.
NC_RTSI_OUT_ON_RX
The CAN Object will output the RTSI signal whenever a CAN
frame is stored in its read queue.
In order to use this RTSI Mode, you must configure the CAN
Object Communication Type to Receive Unsolicited.
NC_RTSI_OUT_ON_TX
The CAN Object will output the RTSI signal whenever a CAN
frame is successfully transmitted.
In order to use this RTSI Mode, you must configure the CAN
Object Communication Type to either Transmit Data by
Call, Transmit Data Periodically, or Transmit
Periodic Waveform.
NC_RTSI_TIME_ON_IN
When the RTSI input transitions from low to high, a timestamp is
measured and stored in the read queue of the CAN Object. The
special RTSI frame uses the following format:
Timestamp: Time when RTSI input transitioned from low to high.
Data: User-defined 4 byte data pattern (refer to the
NC_ATTR_RTSI_FRAME (RTSI Frame) attribute for details).
NC_RTSI_TX_ON_IN
The CAN Object will transmit a frame from its write queue
when the RTSI input transitions from low to high. To begin
transmission, at least one data frame must be written using
ncWrite. If the write queue becomes empty due to frame
transmissions, the last frame will be retransmitted on each RTSI
pulse until another frame is provided using ncWrite.
In order to use this RTSI Mode, you must configure the CAN
Object Communication Type to either Transmit Data by
Call, Transmit Data Periodically, or Transmit
Periodic Waveform. The Period attribute is ignored when
this RTSI mode is selected.
Figure 11-5 shows a CAN Object that periodically transmits data to another CAN Object.
The receiving CAN Object can queue up to five data values.
Figure 11-6 shows a CAN Object that polls data from another CAN Object. NI-CAN
transmits the CAN remote frame when you call ncWrite.
Response Uses
Most Recent
Your ncRead Write Data Your
Application ncWrite Application
ncWrite
Figure 11-7 shows a CAN Object that polls data from another CAN Object. NI-CAN
transmits the remote frame periodically and places only changed data into the read queue.
Response Uses
Check For Most Recent
Your Different Value Write Data Your
Application ncRead ncWrite Application
Periodic Timer
ncConnectTerminals
Purpose
Connect terminals in the CAN or LIN hardware.
Format
NCTYPE_STATUS ncConnectTerminals(
NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 SourceTerminal,
NCTYPE_UINT32 DestinationTerminal,
NCTYPE_UINT32 Modifiers);
Inputs
ObjHandle
The object handle from the previous NI-CAN function. The
ObjHandle is originally returned from ncOpenObject.
SourceTerminal
Specifies the connection source.
Once the connection is successfully created, behavior flows from
SourceTerminal to DestinationTerminal.
For a list of valid source/destination pairs, refer to the Valid
Combinations of Source/Destination section of this function reference.
The following list describes each value of SourceTerminal:
NC_SRC_TERM_RTSI0... NC_SRC_TERM_RTSI6
Selects a general-purpose RTSI line as source (input) of the
connection.
NC_SRC_TERM_RTSI_CLOCK
Selects the RTSI clock line as source (input) of the
connection. This terminal is also RTSI line 7. RTSI7 is
dedicated for routing of a timebase (10 MHz or 20 MHz)
The only valid DestinationTerminal for this source is
NC_DEST_TERM_MASTER_TIMEBASE.
For PCI and PXI form factors, this receives a 20 MHz
(default) timebase from another CAN or DAQ card. For
connecting NC_SRC_TERM_20MHZ_TIMEBASE to
NC_DEST_TERM_RTSI_CLOCK on one CAN card, and then
connecting NC_SRC_TERM_RTSI_CLOCK to
NC_DEST_TERM_MASTER_TIMEBASE on the other CAN
card.
NC_SRC_TERM_20MHZ_TIMEBASE applies to the entire CAN
or LIN card, including both interfaces of a 2-port CAN card.
The CAN card is specified by the ObjName input to
ncOpenObject.
This value applies to Series 2 PXI or PCI CAN cards only.
This value applies to Series 2 PXI or PCI CAN cards and
847x with Sync interfaces only.
For 847x with Sync series CAN and LIN interfaces the
internal oscillator runs at 1 MHz.
NC_SRC_TERM_10HZ_RESYNC_CLOCK
NC_SRC_TERM_10HZ_RESYNC_CLOCK selects a 10 Hz,
50 percent duty cycle clock. This slow rate is required for
resynchronization of Series 1 CAN cards. On each pulse of
the resync clock, the other CAN card brings its clock into
sync.
By selecting RTSI0-RTSI6 as the DestinationTerminal,
you route the 10 Hz clock to synchronize with other Series 1
CAN cards. NI-DAQ or NI-DAQmx cards cannot use the
10 Hz resync clock, so this selection is limited to
synchronization of two or more CAN cards.
NC_SRC_TERM_10HZ_RESYNC_CLOCK applies to the entire
CAN card, including both interfaces of a 2-port CAN card.
The CAN card is specified by the ObjName input to
ncOpenObject.
This value applies to Series 1 and Series 2 CAN cards, but is
typically used with Series 1 CAN cards only. If all of the
CAN cards are Series 2, the 20 MHz timebase is preferable
due to the lack of drift. If you are using a mix of Series 1 and
Series 2 CAN cards, you must use
NC_SRC_TERM_10HZ_RESYNC_CLOCK.
NC_SRC_TERM_INTF_RECEIVE_EVENT
NC_SRC_TERM_INTF_RECEIVE_EVENT selects the
dedicated receive interrupt output on the Philips SJA1000
CAN controller. When a received frame successfully passes
the acceptance filter, a pulse with the width of one bit time is
output during the last bit of the end of frame position of the
CAN frame. Incoming CAN frames can be filtered using the
NC_ATTR_SERIES2_FILTER_MODE attribute. The CAN
controller is specified by the ObjName input to
ncOpenObject.
NC_SRC_TERM_INTF_RECEIVE_EVENT can be used as the
start trigger for other NI cards, or for external instruments.
This value applies to Series 2 cards only.
NC_SRC_TERM_INTF_TRANSCEIVER_EVENT
NC_SRC_TERM_INTF_TRANSCEIVER_EVENT selects
the NERR signal from the CAN transceiver. The
Low-Speed/Fault-Tolerant transceiver and the High-Speed
transceiver provide the NERR signal. This signal asserts
when a fault is detected by the transceiver. The default value
of NERR is logic-high, which indicates no error.
The CAN card is specified by the ObjName input to
ncOpenObject.
This value applies to Series 2 CAN cards only.
NC_SRC_TERM_START_TRIGGER
NC_SRC_TERM_START_TRIGGER selects the start trigger,
the event that starts objects.
The start trigger is the same for all CAN Objects using a given
interface, such as the ObjName input to ncOpenObject.
In the default (disconnected) state of the
NC_DEST_TERM_START_TRIGGER destination, the start
trigger occurs when communication begins on the interface.
By selecting RTSI0-RTSI6 as the DestinationTerminal,
you route the start trigger of this CAN or LIN card to the start
trigger of other CAN, LIN, or DAQ cards. This ensures that
sampling begins at the same time on both cards. For example,
you can synchronize two CAN cards by routing
NC_SRC_TERM_START_TRIGGER as the SourceTerminal
on one CAN card, and then routing
NC_DEST_TERM_START_TRIGGER as the
DestinationTerminal on the other CAN card, with both
cards using the same RTSI line for the connections.
DestinationTerminal
Specifies the destination of the connection.
The following list describes each value of DestinationTerminal:
NC_DEST_TERM_RTSI0... NC_DEST_TERM_RTSI6
Selects a general-purpose RTSI line as destination (output) of
the connection.
NC_DEST_TERM_RTSI_CLOCK
Selects the RTSI clock line as destination (output) of the
connection. This terminal is also RTSI line 7. RTSI7 is
dedicated for routing of a timebase. The CAN card can import
a 10 MHz or 20 MHz timebase, but can only export a 20 MHz
timebase.
847x with Sync cards can import 1 MHz, 10 MHz, or
20 MHz timebases, but can export only a 1 MHz timebase.
NC_DEST_TERM_MASTER_TIMEBASE
NC_DEST_TERM_MASTER_TIMEBASE instructs the CAN or
LIN card to use the source of the connection as the master
timebase. The CAN or LIN card uses this master timebase for
input sampling (including timestamps of received messages)
as well as periodic output sampling.
For PCI and PXI form factors, you can use
NC_SRC_TERM_RTSI_CLOCK as the SourceTerminal. By
default this receives a 20 MHz timebase from another CAN
or DAQ card. For example, you can synchronize a CAN and
DAQ E Series MIO card by connecting the 20 MHz oscillator
(board clock) of the DAQ card to RTSI Clock (RTSI7),
and then connecting NC_SRC_TERM_RTSI_CLOCK to
NC_DEST_TERM_MASTER_TIMEBASE on the CAN card.
To change the Master Timebase Rate to 10 MHz, use
ncSetAttribute to change the
NC_ATTR_MASTER_TIMEBASE_RATE attribute.
For PXI form factor, you also can use
NC_SRC_TERM_PXI_CLK10 as the SourceTerminal. This
receives the PXI 10 MHz backplane clock for use as the
master timebase.
For PCMCIA form factor, you can use
NC_SRC_TERM_RTSI_CLOCK as the SourceTerminal.
Unlike PCI and PXI, the PCMCIA CAN card requires a
10 MHz timebase on NC_SRC_TERM_RTSI_CLOCK. For
synchronization with a PCMCIA DAQ card, this is done
by programming the FREQOUT signal of the DAQ card to
10 MHz, then wiring FREQOUT to the
NC_SRC_TERM_RTSI_CLOCK of the CAN card.
For the USB form factor, you can use RTSI7/RTSI Clock as
the source terminal. The USB hardware automatically senses
the incoming clock rate of 1 MHz, 10 MHz, or 20 MHz,
so no further configuration is required.
NC_DEST_TERM_MASTER_TIMEBASE applies to the entire
CAN or LIN card, including both interfaces of a 2-port CAN
card. The CAN card is specified by the ObjName input to
ncOpenObject.
The default (disconnected) state of this destination means the
CAN or LIN card uses its local 20 MHz timebase as the
master timebase.
NC_DEST_TERM_10HZ_RESYNC_CLOCK
NC_DEST_TERM_10HZ_RESYNC_CLOCK instructs the CAN
card to use a 10 Hz, 50 percent duty cycle clock to
resynchronize its local timebase. This slow rate is required
for resynchronization of CAN cards. On each low-to-high
transition of the resync clock, this CAN card brings its local
timebase into sync.
When synchronizing to an E Series MIO card, a typical use of
this value is to use RTSI0-RTSI6 as the SourceTerminal,
then use NI-DAQ or NI-DAQmx functions to program
Counter 0 of the MIO card to generate a 10 Hz 50 percent
duty cycle clock on the RTSI line.
When synchronizing to a CAN card, a typical use of this
value is to use RTSI0-RTSI6 as the SourceTerminal, then
route the NC_SRC_TERM_10HZ_RESYNC_CLOCK of the other
CAN card as the SourceTerminal to the same RTSI line.
NC_DEST_TERM_10HZ_RESYNC_CLOCK applies to the entire
CAN card, including both interfaces of a 2-port CAN card.
The CAN card is specified by the ObjName input to
ncOpenObject.
The default (disconnected) state of this destination means the
CAN card does not resynchronize its local timebase.
This value applies to Series 1 and Series 2 CAN cards, but is
typically used with Series 1 CAN cards only. If all of the
CAN cards are Series 2, the 20 MHz timebase is preferable
due to the lack of drift. If you are using a mix of Series 1 and
Series 2 CAN cards, you must use
NC_DEST_TERM_10HZ_RESYNC_CLOCK.
NC_DEST_TERM_START_TRIGGER
NC_DEST_TERM_START_TRIGGER selects the start trigger,
the event that begins sampling for tasks. The start trigger
occurs on the first low-to-high transition of the source
terminal.
The start trigger is the same for all tasks using a given
interface, such as the ObjName input to ncOpenObject.
By selecting RTSI0-RTSI6, or NC_SRC_TERM_PXI_STAR for
PXI hardware, as the SourceTerminal, you route the start
trigger from another CAN, LIN, or DAQ card. This ensures
that sampling begins at the same time on both cards. For
example, you can synchronize with an E Series DAQ MIO
card by routing the AI start trigger of the MIO card to a
RTSI line and then routing the same RTSI line with
NC_DEST_TERM_START_TRIGGER as the
DestinationTerminal on the CAN card.
The default (disconnected) state of this destination means the
start trigger occurs when communication begins on the
interface.
Modifiers
Provides optional connection information for certain
source/destination pairs. The current release of NI-CAN does not use
this information for any source/destination pair, so you must pass
Modifiers as zero.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value.
Description
This VI connects a specific pair of source/destination terminals. One of the terminals is
typically a RTSI signal, and the other terminal is an internal terminal in the CAN or LIN
hardware. By connecting internal terminals to RTSI, you can synchronize the CAN or LIN
hardware with another hardware product such as an NI-DAQ or NI-DAQmx card.
When the final CAN Object for a given port is cleared with ncCloseObject, NI-CAN
disconnects all terminal connections for that port. Therefore, the ncDisconnectTerminals
function is not required for most applications. NI-DAQ and NI-DAQmx terminals remain
connected after the tasks are cleared, so you must disconnect NI-DAQ/NI-DAQmx terminals
manually at the end of the application.
• PCMCIA cards do not support the 20 MHz Timebase, PXI_Star, and PXI_Clk10
terminals. Because 20 MHz Timebase is not supported, you cannot synchronize the
timebases of two PCMCIA CAN cards.
• On PCMCIA cards, RTSI4, RTSI5 and RTSI6 are not available.
Destination
10 Hz
RTSI0 to Master Resync Start
Source RTSI6 RTSI_Clock Timebase Clock Trigger
RTSI0 to — — — 1, 2 1, 2, 3
RTSI6
RTSI7/RTSI_ — — 2, 3 — —
Clock
PXI_Star — — — — 2
PXI_Clk10 — — 2 — —
20 MHz — 2, 3 — — —
Timebase
10 Hz Resync 1, 2 — — — 1, 2
Clock
Interface 2 — — — 2
Receive
Event
Destination
10 Hz
RTSI0 to Master Resync Start
Source RTSI6 RTSI_Clock Timebase Clock Trigger
Interface 2 — — — —
Transceiver
Event
Start Trigger 1, 2, 3 — — — —
Event
ncCreateNotification
Purpose
Create a notification call back for an object.
Format
NCTYPE_STATUS ncCreateNotification(
NCTYPE_OBJH ObjHandle,
NCTYPE_STATE DesiredState,
NCTYPE_UINT32 Timeout,
NCTYPE_ANY_P RefData,
NCTYPE_NOTIFY_CALLBACK Callback);
Input
ObjHandle
Object handle. The ncCreateNotification function is not
supported by the 847x and 847x with Sync series CAN and LIN
interfaces.
DesiredState
States for which notification is sent.
Timeout
Length of time to wait in milliseconds.
RefData
Pointer to user-specified reference data.
Callback
Address of the callback function.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncCreateNotification creates a notification callback for the object specified by
ObjHandle. The NI-CAN driver uses the notification callback to communicate state changes
to the application.
This function is normally used when you want to allow other code to execute while waiting
for NI-CAN states, especially when the other code does not call NI-CAN functions. If such
background execution is not needed, the ncWaitForState function offers better overall
performance. The ncWaitForState function cannot be used at the same time as
ncCreateNotification.
you call the read function, and less than the specified number of
frames exist in the read queue.
NC_ST_REMOTE_WAKEUP (00000040 hex, Remote Wakeup)
Remote wakeup occurred, and Transceiver Mode
(NC_ATTR_TRANSCEIVER_MODE) has changed from Sleep to
Normal. For more information on remote wakeup, refer to
NC_ATTR_TRANSCEIVER_MODE (Transceiver Mode).
This state is set when a remote wakeup occurs (end of wakeup
frame). This state is not set when the application changes
Transceiver Mode from Sleep to Normal (local wakeup).
This state is cleared when:
• You open the Network Interface, such as when the application begins.
• You stop the Network Interface.
• You set the Transceiver Mode, such as each time you set Sleep mode.
For as long as this state is true, the transceiver mode is Normal.
The transceiver mode also can be Normal when this state is false,
such as when you perform a local wakeup.
NC_ST_WRITE_MULT (00000080 hex)
The state is set whenever there is free space in the write queue to
accept at least 512 frames to write. The state is cleared when you
call the ncWrite or ncWriteMult function, and less than
512 frames can be accepted to write in the write queue.
This state is valid only on the Network Interface.
NC_ST_WRITE_SUCCESS (00000002 hex)
All frames provided with a write function have been successfully
transmitted onto the network. Successful transmit means that the
frame won arbitration, and was acknowledged by a remote device.
The state is set when the last frame in the write queue is
transmitted successfully. The state is cleared when a write
function is called.
When communication starts, the NC_ST_WRITE_SUCCESS state is
true by default.
For CAN Objects, Write Success does not always mean that
transmission has stopped. For example, if a CAN Object is
configured for Transmit Data Periodically, Write Success occurs
when the write queue has been emptied, but periodic transmit of
the last frame continues.
The NI-CAN driver waits up to Timeout for one of the bits set in
DesiredState to become set in the attribute NC_ATTR_STATE. You can
use the special Timeout value NC_DURATION_INFINITE to wait
indefinitely.
With the RefData parameter, you provide a pointer that is sent to all
notifications for the given object. This pointer normally provides reference
data for use within the Callback function. For example, when you create
a notification for the NC_ST_READ_AVAIL state, RefData is often the data
pointer that you pass to ncRead to read available data. If the callback
function does not need reference data, you can set RefData to NULL.
Callback Prototype
NCTYPE_STATE State,
NCTYPE_STATUS Status,
NCTYPE_ANY_P RefData);
Callback Parameters
ObjHandle
Object handle.
State
Current state of object.
Status
Object status.
RefData
Pointer to the reference data.
If you return a state from the callback, and that state is still set in the NC_ATTR_STATE
attribute, the callback is invoked again immediately after it returns. For example, if you return
NC_ST_READ_AVAIL when the read queue has not been emptied, the callback is invoked
again.
Callback Description
In the prototype for Callback, _NCFUNC_ ensures a proper calling scheme between the
NI-CAN driver and the callback.
The Callback function executes in a separate thread in the process. Therefore, it has access
to any process global data, but not to thread local data. If the callback needs to access global
data, you must protect that access using synchronization primitives (such as semaphores),
because the callback is running in a different thread context. Alternatively, you can avoid the
issue of data protection entirely if the callback simply posts a message to the application using
the Win32 PostMessage function. For complete information on multithreading issues, refer
to the Win32 Software Development Kit (SDK) online help.
In LabWindows/CVI, you cannot access User Interface library functions within the callback
thread. To defer a callback for User Interface interaction, use the CVI PostDeferredCall
function. For more information, refer to the LabWindows/CVI documentation.
The State parameter holds the current state(s) of the object that generated the notification
(NC_ATTR_STATE attribute). If the Timeout passed to ncCreateNotification expires
before the desired states occur, or if any other error occurs in the object, the NI-CAN driver
invokes the callback with State equal to zero.
The Status parameter holds the current status of the object. If an error occurs, State is zero
and Status holds the error status. The most common notification error occurs when the
Timeout passed to ncCreateNotification expires before the desired states occur
(CanErrFunctionTimeout status code). If no error is reported, Status is CanSuccess.
ncDisconnectTerminals
Purpose
Disconnect terminals in the CAN or LIN hardware.
Format
NCTYPE_STATUS ncDisconnectTerminals(
NCTYPE_OBJH ObjectHandle,
NCTYPE_UINT32 SourceTerminal,
NCTYPE_UINT32 DestinationTerminal,
NCTYPE_UINT32 Modifiers);
Inputs
ObjectHandle
The object handle from the previous NI-CAN function. The
ObjectHandle is originally returned from ncOpenObject.
SourceTerminal
Specifies the source of the connection.
For a description of values for SourceTerminal, refer to
ncConnectTerminals.
DestinationTerminal
Specifies the destination of the connection.
For a description of values for DestinationTerminal, refer to
ncConnectTerminals.
Modifiers
Provides optional connection information for certain
source/destination pairs. The current release of NI-CAN does not use
this information for any source/destination pair, so you must pass
Modifiers as zero.
Outputs
Return Value
The return value indicates the status of the function call as a signed 32-bit integer. Zero means
the function executed successfully. A negative value specifies an error, which means the
function did not perform the expected behavior. A positive value specifies a warning, which
means the function performed as expected, but a condition arose that may require attention.
Use the ncStatusToString function of the Frame API to obtain a descriptive string for the
return value.
Description
This function disconnects a specific pair of source/destination terminals you previously
connected with ncConnectTerminals.
When the final CAN Object for a given port is cleared with ncCloseObject, NI-CAN
disconnects all terminal connections for that port. Therefore, the ncDisconnectTerminals
function is not required for most applications. You typically use this function to change
RTSI connections dynamically while the application is running. First use ncAction
with the NC_OP_STOP opcode to stop all CAN Objects for the port, then use
ncDisconnectTerminals and ncConnectTerminals to adjust RTSI connections,
then use ncAction with the NC_OP_START opcode to start the network interface and
restart sampling.
ncGetAttribute
Purpose
Get the value of an object attribute.
Format
NCTYPE_STATUS ncGetAttribute(
NCTYPE_OBJH ObjHandle,
NCTYPE_ATTRID AttrId,
NCTYPE_UINT32 AttrSize,
NCTYPE_ANY_P AttrPtr);
Input
ObjHandle
Object handle.
AttrId
Identifier of the attribute to get.
AttrSize
Size of the attribute in bytes.
Output
AttrPtr
Pointer used to return an attribute value.
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncGetAttribute gets the value of the attribute specified by AttrId from the object
specified by ObjHandle. Within NI-CAN Objects, you use attributes to access configuration
settings, status, and other information about the object, but not data.
AttrPtr points to the variable used to receive the attribute value. Its type is undefined so that
you can use the appropriate host data type for AttrId. AttrSize indicates the size of the
variable that AttrPtr points to. AttrSize is typically 4, and AttrPtr references a 32-bit
unsigned integer.
You can get any value of AttrId mentioned in ncConfig using ncGetAttribute. The
following list describes other AttrId you can get using ncGetAttribute:
NC_HW_FORMFACTOR_PXI PXI
NC_HW_FORMFACTOR_PCMCIA PCMCIA
NC_HW_FORMFACTOR_AT AT
NC_HW_FORMFACTOR_USB USB
NC_ATTR_HW_SERIES (Series)
Returns the series of the card on which the Network Interface or CAN
Object is located.
Series 1 hardware products use the Intel 82527 CAN controller.
Series 2 hardware products use the Philips SJA1000 CAN controller,
plus improved RTSI synchronization features.
The 847x and 847x with Sync series CAN hardware products use the
Philips SJA1000 CAN controller. The 847x and 847x with Sync series
LIN hardware products use the AMTEL ATA6620 LIN controller.
The 847x with Sync series hardware products add synchronization
features to the 847x hardware products.
The returned Series is an enumeration.
NC_HW_SERIES_1 Series 1
NC_HW_SERIES_2 Series 2
NC_HW_SERIES_847x 847x
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
x x x x x x x x x x x x x x x x x ALC SEG
NEWALC ERCC
NEWECC DIR
Value in
SEG Field Meaning
0 No error (ignore DIR and ERRC as well)
2 ID.28 to ID.21 (most significant bits of identifier)
3 Start of frame
4 Bit SRTR (RTR for standard frames)
5 Bit IDE
Table 11-6. SEG Field of the Error Code Capture Register (Continued)
Value in
SEG Field Meaning
6 ID.20 to ID.18
7 ID.17 to ID.13
8 CRC sequence
9 Reserved bit 0
10 Data field
11 Data length code
12 Bit RTR (RTR for extended frames)
13 Reserved bit 1
14 ID.4 to ID.0
15 ID.12 to ID.5
17 Active error flag
18 Intermission
19 Tolerate dominant bits
22 Passive error flag
23 Error delimiter
24 CRC delimiter
25 Acknowledge slot
26 End of frame
27 Acknowledge delimiter
28 Overload flag
Value in
DIR Field Meaning
0 TX; error occurred during transmission
1 RX; error occurred during reception
Value in
ERRC Field Meaning
0 Bit error
1 Form error
2 Stuff error
3 Other type of error
Table 11-9. ALC Field Contains the Arbitration Lost Capture Register
Value in
ALC Field Meaning
0 ID.28 (most significant bit of identifier; first ID
bit in frame)
1 ID.27
2 ID.26
3 ID.25
4 ID.24
5 ID.23
6 ID.22
7 ID.21
8 ID.20
9 ID.19
10 ID.18
11 SRTR (RTR for standard frames)
12 IDE
13 ID.17 (extended frames only)
14 ID.16 (extended frames only)
15 ID.15 (extended frames only)
16 ID.14 (extended frames only)
Table 11-9. ALC Field Contains the Arbitration Lost Capture Register (Continued)
Value in
ALC Field Meaning
17 ID.13 (extended frames only)
18 ID.12 (extended frames only)
19 ID.11 (extended frames only)
20 ID.10 (extended frames only)
21 ID.9 (extended frames only)
22 ID.8 (extended frames only)
23 ID.7 (extended frames only)
24 ID.6 (extended frames only)
25 ID.5 (extended frames only)
26 ID.4 (extended frames only)
27 ID.3 (extended frames only)
28 ID.2 (extended frames only)
29 ID.1 (extended frames only)
30 ID.0 (extended frames only)
31 SRTR (RTR for extended frames)
Table 11-10. NEWECC Field is the New Flag for the Error Code Capture Register
Value in
NEWECC Field Meaning
0 SEG, DIR, and ERRC fields contain the same
value as the last Get of this attribute. If no error
has occurred since the start of communication,
all fields are zero.
1 SEG, DIR, and ERRC fields contain
information for a new bus error.
Table 11-11. NEWALC Field is the New Flag for the Arbitration Lost Capture Register
Value in
NEWALC Field Meaning
0 ALC field contains the same value as the last Get
of this attribute.
1 ALC field contains information for a new
arbitration loss.
NC_ATTR_TERMINATION (Termination)
Returns the value of the Termination attribute as configured with
ncSetAttribute.
0 Immediate Transmit
1 Timestamped Transmit
Description
ncGetAttribute gets the value of the attribute specified by AttrId from the object specified
by ObjHandle. Within NI-CAN Objects, you use attributes to access configuration settings,
status, and other information about the object, but not data.
ncGetHardwareInfo
Purpose
Get CAN or LIN hardware information.
Format
NCTYPE_UINT32 CardNumber,
NCTYPE_UINT32 PortNumber,
NCTYPE_ATTRID AttrId,
NCTYPE_UINT32 AttrSize,
NCTYPE_ANY_P AttrPtr);
Input
CardNumber
Specifies the CAN or LIN card number from 1 to Number of Cards,
where Number of Cards is the number of CAN and LIN cards in the
system. You can obtain Number of Cards using this function with
CardNumber=1, PortNumber=1, and AttrID=Number of Cards.
PortNumber
Specifies the CAN or LIN port number from 1 to Number of Ports,
where Number of Ports is the number of ports on the card. You can
obtain Number of Ports using this function with PortNumber=1,
and AttrID=Number of Ports.
AttrID
Specifies the attribute to get:
NC_ATTR_VERSION_MAJOR (Version Major)
Returns the major version of the NI-CAN software. Use
CardNumber 1 and PortNumber 1 as inputs.
The major version is the 'X' in X.Y.Z.
NC_ATTR_VERSION_MINOR (Version Minor)
Returns the minor version of the NI-CAN software. Use
CardNumber 1 and PortNumber 1 as inputs.
NC_ATTR_HW_SERIES (Series)
Card-wide attribute that returns the series of the card. Use the
desired CardNumber, and PortNumber 1 as inputs.
Series 1 hardware products use the Intel 82527 CAN controller.
Series 2 hardware products use the Philips SJA1000 CAN
controller, plus improved RTSI synchronization features.
The returned Series is an enumeration.
NC_HW_SERIES_1 Series 1
NC_HW_SERIES_2 Series 2
NC_HW_SERIES_847x 847x
NC_HW_SERIES_847x_SYNC 847x with Sync
AttrSize
Size of the attribute in bytes. Unless stated otherwise, AttrSize must
be 4.
Output
AttrPtr
Pointer used to return attribute value. Unless stated otherwise,
AttrPtr must point to NCTYPE_UINT32.
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
This function provides information about available CAN and LIN cards, but does not require
you to open/start sessions. First get Number of Cards, then loop for each card. For each
card, you can get card-wide attributes (such as Form Factor), and you also can get the Number
of Ports. For each port, you can get port-wide attributes such as the Transceiver.
ncOpenObject
Purpose
Open an object.
Format
NCTYPE_STATUS ncOpenObject(
NCTYPE_STRING ObjName,
NCTYPE_OBJH_P ObjHandlePtr);
Input
ObjName
ASCII name of the object to open.
Output
ObjHandlePtr
Pointer used to return the Object handle. Used with all subsequent
NI-CAN function calls.
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncOpenObject takes the name of an object to open and returns a handle to that object that
you use with subsequent NI-CAN function calls.
The Frame API and Channel API cannot use the same CAN network interface
simultaneously. If the CAN network interface is already initialized in the Channel API,
this function returns an error.
If ncOpenObject is successful, a handle to the newly opened object is returned. You use this
object handle for all subsequent function calls for the object.
The following sections describe how to use ncOpenObject with the CAN or LIN Network
Interface and CAN Object.
The special interface values 256 and 257 refer to virtual interfaces. For more information on
usage of virtual interfaces, refer to the Frame to Channel Conversion section of Chapter 6,
Using the Channel API.
CAN Object
ObjName is the name of the CAN Object to configure. This string uses the syntax
CANx::STDy or CANx::XTDy. CANx is the name of the CAN network interface that you
used for the preceding ncConfig function. STD indicates that the CAN Object uses a
standard (11-bit) arbitration ID. XTD indicates that the CAN Object uses an extended (29-bit)
arbitration ID. The number y specifies the actual arbitration ID of the CAN Object. The
number y is decimal by default, but you also can use hexadecimal by adding 0x to the
beginning of the number. For example, CAN0::STD25 indicates standard ID 25 decimal on
CAN0, and CAN1::XTD0x0000F652 indicates extended ID F652 hexadecimal on CAN1.
The special virtual interface names CAN256 and CAN257 are not supported for CAN
Objects.
ncRead
Purpose
Read single frame from a CAN or LIN Object.
Format
NCTYPE_STATUS ncRead(
NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 DataSize,
NCTYPE_ANY_P DataPtr);
Input
ObjHandle
Object handle.
DataSize
Size of the data in bytes.
Output
DataPtr
Pointer used to return the frame.
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncRead reads a single frame from the object specified by ObjHandle.
DataPtr points to the variable that holds the data. Its type is undefined so that you can use
the appropriate host data type. DataSize indicates the size of variable pointed to by
DataPtr, and is used to verify that the size you have available is compatible with the
configured read size for the object.
For information on the data type to use with DataPtr, refer to the following Network
Interface and CAN Object descriptions.
You use ncRead to obtain data from the read queue of an object. Because NI-CAN handles
the read queue in the background, this function does not wait for new data to arrive. To ensure
that new data is available before calling ncRead, first wait for the NC_ST_READ_AVAIL state.
The NC_ST_READ_AVAIL state transitions from false to true when NI-CAN places a new data
item into an empty read queue, and remains true until you read the last data item from the
queue.
The ncRead function is useful when you need to process one frame at a time. In order to read
multiple frames, such as for bus analyzer applications, use the ncReadMult function.
When you call ncRead for an empty read queue (NC_ST_READ_AVAIL false), the data from
the previous call to ncRead is returned to you again, along with the CanWarnOldData
warning. If no data item has yet arrived for the read queue, a default data item is returned,
which consists of all zeros.
When a new data item arrives for a full queue, NI-CAN discards the item, and the next call to
ncRead returns the CanErrOverflowRead error. You can avoid this overflow behavior by
setting the read queue length to zero. When a new data item arrives for a zero length queue,
it simply overwrites the previous item without indicating an overflow. The
NC_ST_READ_AVAIL state and CanWarnOldData warning still behave as usual, but you can
ignore them if you only want the most recent data. You can use the NC_ATTR_READ_Q_LEN
attribute to configure the read queue length.
Within the NCTYPE_CAN_STRUCT structure, the FrameType field determines the meaning of
all other fields. Table 11-12, NCTYPE_CAN_STRUCT Fields for FrameType
NC_FRMTYPE_DATA (0), Table 11-13, NCTYPE_FRAME_STRUCT Fields for FrameType
NC_FRMTYPE_REMOTE (1), Table 11-14, NCTYPE_CAN_STRUCT Fields for FrameType
NC_FRMTYPE_COMM_ERR (2), Table 11-15, NCTYPE_CAN_STRUCT Fields for
FrameType NC_FRMTYPE_RTSI (3), Table 11-16, NCTYPE_CAN_STRUCT Fields for
FrameType NC_FRMTYPE_TRIG_START (4), Table 11-17, NCTYPE_CAN_STRUCT
Fields for FrameType NC_FRMTYPE_CAN_BUS_ERROR_FRAME (4), Table 11-18,
NCTYPE_CAN_STRUCT Fields for FrameType NC_FRMTYPE_TRANSCEIVER
FAULT_FRAME (7), Table 11-19, NCTYPE_CAN_STRUCT Fields for FrameType
NC_FRMTYPE_LIN_FULL_FRAME (18), Table 11-20, NCTYPE_CAN_STRUCT Fields for
FrameType NC_FRMTYPE_LIN_WAKEUP_RECEIVED_FRAME (19), Table 11-21,
NCTYPE_CAN_STRUCT Fields for FrameType
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
When the transmit error counter of the CAN communication controller increments above 255,
the network interface transfers into the bus off state as dictated by the CAN protocol. The
network interface stops communication so that you can correct the defect in the network, such
as a malfunctioning cable or device. When bus off occurs, NI-CAN returns the CanErrComm
error code.
If no CAN devices are connected to the network interface port, and you attempt to transmit
a frame, the CanWarnComm status occurs. This warning occurs because the missing
acknowledgment bit increments the transmit error counter until the network interface reaches
the error passive state, but bus off state is never reached.
For more information about transceiver fault handling, refer to the description of the
NC_ATTR_LOG_COMM_ERRS attribute ID in the ncConfig function description.
CAN Object
The data type that you use with ncRead of the CAN Object is NCTYPE_CAN_DATA_TIMED.
When calling ncRead, you should pass size of (NCTYPE_CAN_DATA_TIMED) for the
DataSize parameter. Table 11-23, NCTYPE_CAN_DATA_TIMED Field Names, describes
the fields of NCTYPE_CAN_DATA_TIMED.
ncReadMult
Purpose
Read multiple frames from a CAN or LIN Object.
Format
NCTYPE_STATUS ncReadMult(
NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 DataSize,
NCTYPE_ANY_P DataPtr,
NCTYPE_UINT32_P ActualDataSize);
Input
ObjHandle
Object handle.
DataSize
The size of the data buffer in bytes.
DataPtr
Points to data buffer in which the data returned.
Output
ActualDataSize
The number of bytes actually returned.
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
This function returns multiple frames from the read queue of the object specified by
ObjHandle. When used with the Network Interface, ncReadMult is useful in analyzer
applications where data frames need to be acquired at a High-Speed and stored for analysis
in the future. For single frame and most recent data frame acquisition, you should use
ncRead.
Because NI-CAN handles the read queue in the background, this function does not wait for
new data to arrive. To ensure that new data is available before calling ncReadMult, first wait
for the NC_ST_READ_MULT state. Refer to NC_ST_READ_MULT (00000008 hex) in the
ncCreateNotification function description for more information on this state.
Unlike the ncRead function, the ncReadMult function does not return the
CanWarnOldData warning to indicate zero frames. If there is no new data, the function
returns with an ActualDataSize of zero.
The description for CanErrOverflowRead and the host data types is identical to that of
ncRead with the exception of CanWarnOldData, described above.
Refer to the ncRead function description for more details on the structures used with
ncReadMult.
ncSetAttribute
Purpose
Set the value of an object attribute.
Format
NCTYPE_STATUS ncSetAttribute(
NCTYPE_OBJH ObjHandle,
NCTYPE_ATTRID AttrId,
NCTYPE_UINT32 AttrSize,
NCTYPE_ANY_P AttrPtr);
Input
ObjHandle
Object handle.
AttrId
Identifier of the attribute to set.
AttrSize
Size of the attribute in bytes.
AttrPtr
New attribute value. You provide the attribute value using the pointer
AttrPtr.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncSetAttribute sets the value of the attribute specified by AttrId in the object specified
by ObjHandle.
AttrPtr points to the variable that holds the attribute value. Its type is undefined so that you
can use the appropriate host data type for AttrId. AttrSize indicates the size of variable
pointed to by AttrPtr. AttrSize is typically 4, and AttrPtr references a 32-bit unsigned
integer.
The ncSetAttribute function allows for additional configuration beyond the original
attributes used with ncConfig. For a listing of other attributes for the Network Interface and
CAN Object, refer to ncConfig. Unless stated otherwise, communication must be stopped
prior to changing an attribute with ncSetAttribute. While the Network Interface and all
CAN Objects are stopped, you can set any of the AttrId mentioned in ncConfig using
ncSetAttribute.
0 FALSE (default)
When set to FALSE, bus errors will not be logged and
cannot be read (default).
When set to FALSE, listen only mode is disabled
(default).
Received frames are ACKnowledged, and frames can
be transmitted using ncWrite.
1 TRUE
When set to TRUE, listen only mode is enabled.
The Network Interface and CAN Objects can only
receive frames. The interface does not transmit on the
network: no ACKnowledgements are transmitted for
received frames, and ncWrite will return an error.
The Philips SJA1000 CAN controller enters error
passive state when listen only is enabled.
The listen only mode is not available on the Intel
82527 CAN controller used by Series 1 CAN
hardware (returns error).
This attribute is available only for the Network
Interface, not CAN Objects.
NC_ATTR_LOG_BUS_ERRORS (Log Bus Errors?)
Specifies whether to log bus errors when the interface detects a
bus error. For CAN interfaces, the bus error frame is logged when
a bus error is detected. The NC_ATTR_LOG_BUS_ERRORS attribute
is not supported by Series 1 CAN interfaces. This attribute has to
be set prior to starting the Network Interface. The values for this
attribute are:
0 FALSE (default)
When set to FALSE, bus errors will not be logged
and cannot be read (default).
1 TRUE
When set to TRUE, the Network Interface reports
bus errors as a special frame in the read queue. For
CAN, if the NC_ATTR_LOG_COMM_WARNINGS
attribute is set to 1 (TRUE), the
NC_ATTR_LOG_BUS_ERRORS attribute must be set
to 0 (FALSE).
The CAN bus error frame has the following format:
Arbitration ID 0
IsRemote 6
DataLength 4
Data Bytes
0—Comm State (see description below)
1—Transmit Error Counter
2—Receive Error Counter
3—ECC Register
4—X
5—X
6—X
7—X
Note: X means Reserved or Don’t Care.
The first data byte (Comm State) indicates
the current communication state of the CAN
controller. The states are:
0—Error Active
1—Error Passive
2—Bus Off
For LIN interfaces, the bus error frame is logged into the read
queue when a timeout or bus errors such as Bit Framing or
Checksum occurs. This attribute must be set prior to starting the
Network Interface.
Arbitration ID 0
IsRemote 21
Data Bytes
0—Error code (most significant byte)
1—Error code (least significant byte)
2—X
3—X
4—Received byte (for applicable error code)
5—Expected byte (for applicable error
code)
6—LIN ID (for applicable error code)
7—X
Note: X means Reserved or Don’t Care.
Data bytes zero and one (Error code) indicate the type of LIN bus
error. Refer to Table 11-24 for a list of LIN bus error codes and
descriptions. Data bytes two and three are reserved for internal
use. For errors in which a received byte did not match the expected
value, data byte four indicates the received value and data byte 5
indicates the expected value. For a bus error occurring at a point
in the LIN frame after which the break, sync, and ID fields have
been processed, data byte six indicates the LIN ID.
LinBusErrorRxIdFraming A020 The LIN interface slave task 6 A0 20 X X Expected Received N/A
received an ID byte with a framing ID Byte ID Byte
error.
LinBusErrorRxIdParity C020 The LIN interface slave task 6 C0 20 X X Expected Received N/A
received an ID byte with a parity ID Byte ID Byte
error.
LinBusErrorRxIdTimeout 9020 The LIN interface slave task did 4 90 20 X X N/A N/A N/A
not receive an ID byte within the
header timeout period.
LinBusErrorRxSyncBit C040 The LIN interface slave task 6 C0 40 X X Expected Received N/A
received a sync byte with a bit Sync Sync Byte
error. Byte
LinBusErrorRxSyncFraming A040 The LIN interface slave task 4 A0 40 X X N/A N/A N/A
received a sync byte with a framing
error.
LinBusErrorRxSyncTimeout 9040 The LIN interface slave task did 4 90 40 X X N/A N/A N/A
not receive a sync byte within the
header timeout period.
LinBusErrorWhenMasterIssues 0A00 The LIN interface failed to issue a 4 0A 00 X X N/A N/A N/A
Wakeup wakeup on the LIN as a master.
LinBusErrorWhenSlaveIssues 900 The LIN interface failed to issue a 4 09 00 X X N/A N/A N/A
Wakeup wakeup on the LIN as a slave.
0 FALSE
When set to FALSE, the Network Interface reports
CAN communication warnings (including
transceiver faults). For more information, refer to
ncReadMult.
1 TRUE
When set to TRUE, the Network Interface reports
CAN communication warnings (including
transceiver faults) by storing a special frame in the
read queue. The communication warnings are not
reported the return value. For more information on
communication warnings and errors, refer to
ncReadMult. The special communication warning
frame uses the following format:
IsRemote 2
DataLength 0
Note Setting this attribute to true in applications that only transmit CAN frames has no
effect.
0 FALSE
When set to FALSE, transceiver faults will not be logged
as frames (default).
1 TRUE
When set to TRUE, the transceiver faults are logged as
special frames in the read queue of the Network Interface
Object. For CAN, if the NC_ATTR_LOG_COMM_WARNINGS
attribute is set to 1 (TRUE),
NC_ATTR_LOG_TRANSCEIVER_FAULTS must be set to 0
(FALSE).
This attribute is supported only on High Speed and Low Speed CAN
transceivers.
This attribute can be set before or after starting the CAN Network
Interface Object. The frame will be logged each time the transceiver’s
NERR signal changes state. In order to filter out noise on this signal,
the logging can occur up to 10ms apart. The transceiver fault frame as
the following format:
Arbitration ID 0
IsRemote 7
DataLength 1
Data Bytes
0—Transceiver fault (0=fault cleared, 1=fault
present)
1—X
2—X
3—X
4—X
5—X
6—X
7—X
Note: X means Reserved or Don’t Care.
NC_ATTR_MASTER_TIMEBASE_RATE (Master Timebase Rate)
Sets the rate (in MHz) of the external clock that is exported to the
CAN card.
0 FALSE
Disables Self Reception mode (default).
Transmitted frames do not appear in read
queues.
1 TRUE
Enables Self Reception mode. Transmitted
frames appear in read queues as if they were
received from another CAN or LIN device.
The Self Reception mode is not available on the Intel 82527 CAN
controller used by Series 1 CAN hardware. For Series 1 interfaces,
this attribute must be left at its default (zero).
This attribute is available only for the Network Interface Objects,
not CAN Objects.
For LIN, this specifies whether or not to load frames for which the LIN
interface slave task is the publisher of the response into the read queue.
0 FALSE
Disables Self Reception mode (default). Frames for
which the LIN interface slave task is the publisher of the
response do not appear in read queues.
1 TRUE
Enables Self Reception mode. Frames for which the LIN
interface slave task is the publisher of the response appear
in read queues as if they were the result of an external
slave task publishing the response.
NC_ATTR_SERIES_2_COMPARATOR (Series 2 Comparator)
Specifies the filter comparator for the Philips SJA1000 CAN
controller. This attribute is not supported for Series 1 CAN, 847x
LIN, or 847x with Sync LIN interfaces (returns error).
NC_ATTR_SERIES_2_MASK and
NC_ATTR_SERIES_2_COMPARATOR attributes.
This attribute is not supported for Series 1 CAN, 847x LIN, or
847x with Sync LIN interfaces (returns error). For Series 1, the
Standard Mask/Comparator and Extended Mask/Comparator
attributes are programmed directly into the Intel 82527 CAN
controller. Use those attributes to specify filtering of received
frames on Series 1 interfaces.
The Philips SJA1000 does not support distinct standard and
extended masking. Therefore, on Series 2 interfaces the Standard
Mask/Comparator and Extended Mask/Comparator attributes are
implemented in software (for backward compatibility). Since
software masking can have an adverse impact on receive
performance, National Instruments recommends that you disable
software masking for Series 2 interfaces. Disable software
masking by specifying don’t-care (0) for all four mask/comparator
attributes of ncConfig.
Communication must be stopped to set this attribute. Use Start
On Open False with ncConfig, set the desired attributes, then
use ncAction to start communication.
Since the format of the filters is very specific to the Philips
SJA1000 CAN controller, National Instruments cannot guarantee
compatibility for this attribute on future hardware series. When
using this attribute in the application, it is best to get the
NC_ATTR_HW_SERIES (Series) attribute to verify that the CAN
hardware is Series 2, 847x, or 847x with Sync.
The filtering specified by this attribute and the Series 2
Mask/Comparator applies to the CAN Network Interface Object
and all CAN Objects for that interface. For example, if you specify
filters that discard ID 5, then open a CAN Object to receive ID 5,
the CAN Object will not receive data.
The default value for this attribute is
NC_FILTER_SINGLE_STANDARD.
This attribute uses the following values:
NC_FILTER_SINGLE_STANDARD (Single Standard)
Filter all standard (11-bit) frames using a single
mask/comparator filter.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11 Bit ID x x x x Data 0 Data 1
RTR
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
29 Bit ID x x
RTR
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
11 Bit ID Data 0 11 Bit ID
RTR RTR
Filter 1 Filter 2
Filter 1 includes the 11 Bit ID, the RTR bit, and the first data
byte in the frame. Filter 2 includes the 11 bit ID, and the RTR
bit (no data).
NC_FILTER_DUAL_EXTENDED (Dual Extended)
Filter all extended (29-bit) frames using a two separate
mask/comparator filters. If either filter matches the frame, it
is received. The frame is discarded only when neither filter
detects a match.
Figure 11-12 describes the format of the Series 2 Mask and
Series 2 Comparator attributes for this filter mode.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Upper 16 ID Upper 16 ID
Filter 1 Filter 2
Original Timeline
Frame A Frame B Frame C
10 ms 23 ms 33 ms
Actual Timeline
NC_TRUE
Recover the original timeline. When a timestamped transmit
is late, the subsequent frame will transmit with a reduced gap.
This behavior is useful when you need to maintain a timeline,
such as when synchronizing CAN output with analog or
digital output. Figure 11-14 shows an original timeline of
three frames with a 10 ms gap. When frame B transmits 3 ms
late, frame C transmit 7 ms later in order to recover the
timeline.
Original Timeline
Frame A Frame B Frame C
10 ms 23 ms 30 ms
Actual Timeline
NC_FALSE
Disables Virtual Bus Timing. By turning Virtual Bus Timing
off, the CAN bus simulation is disabled and CAN frames are
copied from the write queue of one virtual interface to the
read queue of the second virtual interface. This setting is
useful if you desire to only convert frames to channels or vice
versa and not simulate actual CAN bus communication.
If this attribute is set on real hardware, an error will be returned.
The Virtual Bus Timing has to be set to the same value on both
virtual interfaces.
This attribute must be set prior to starting the virtual interface.
Refer to the Frame to Channel Conversion section of Chapter 6,
Using the Channel API for more information.
ncStatusToString
Purpose
Convert status code into a descriptive string.
Format
void ncStatusToString(
NCTYPE_STATUS Status,
NCTYPE_UINT32 SizeofString,
NCTYPE_STRING String);
Input
Status
Nonzero status code returned from NI-CAN function.
SizeofString
Size of String buffer (in bytes).
Output
String
ASCII string that describes Status.
Description
When the status code returned from an NI-CAN function is nonzero, an error or warning is
indicated. This function is used to obtain a description of the error/warning for debugging
purposes.
If you want to avoid displaying error messages while debugging the application, you can use
the Explain.exe utility. This console application is located in the Utilities subfolder
of the NI-CAN installation folder, which is typically \Program Files\National
Instruments\NI-CAN\Utilities. You enter an NI-CAN status code in the command
line, Explain 0XBFF62201 for example, and the utility displays the description.
The return code is passed into the Status parameter. The SizeofString parameter
indicates the number of bytes available in String for the description. The description will be
truncated to size SizeofString if needed, but a size of 400 characters is large enough to
hold any description. The text returned in String is null-terminated, so it can be used with
ANSI C functions such as printf.
For applications written in C or C++, each NI-CAN function returns a status code as a signed
32-bit integer. Table 11-24 summarizes the NI-CAN use of this status.
The application code should check the status returned from every NI-CAN function. If an
error is detected, you should close all NI-CAN handles, then exit the application. If a warning
is detected, you can display a message for debugging purposes, or simply ignore the warning.
The following piece of code shows an example of handling NI-CAN status during application
debugging.
status= ncOpenObject ("CAN0", &MyObjHandle);
PrintStat (status, "ncOpenObject CAN0");
where the function PrintStat has been defined at the top of the program as:
void PrintStat(NCTYPE_STATUS status,char *source)
{
char statusString[400];
if(status !=0)
{
ncStatusToString(status, size of (statusString), statusString);
printf("\n%s\nSource = %s\n", statusString, source);
if (status < 0)
{
ncCloseObject(MyObjHandle); exit(1);
}
}
}
In some situations, you may want to check for specific errors in the code. For example, when
ncWaitForState times out, you may want to continue communication, rather than exit the
application. To check for specific errors, use the constants defined in nican.h. These
constants have the same names as described in this help file. For example, to check for a
function timeout:
if (status ==CanErrFunctionTimeout)
The function ncStatusToString returns the string results as an array of char (* char).
VB is not able to convert this array to a string automatically. Therefore, VB users should call
the wrapper function ncStatToStr.
ncWaitForState
Purpose
Wait for one or more states to occur in an object.
Format
NCTYPE_STATUS ncWaitForState(
NCTYPE_OBJH ObjHandle,
NCTYPE_STATE DesiredState,
NCTYPE_UINT32 Timeout,
NCTYPE_STATE_P StatePtr);
Input
ObjHandle
Object handle.
DesiredState
States for which to wait.
Timeout
Length of time to wait in milliseconds.
Output
StatePtr
Current state of object when desired states occur. The state is returned
to you using the pointer StatePtr.
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
You use ncWaitForState to wait for one or more states to occur in the object specified by
ObjHandle.
This function waits up to Timeout for one of the bits set in DesiredState to become set in
the attribute NC_ATTR_STATE. You can use the special Timeout value
NC_DURATION_INFINITE (FFFFFFFF hex) to wait indefinitely.
DesiredState specifies a bit mask of states for which the wait should return. You can use a
single state alone, or you can OR them together.
For as long as this state is true, the transceiver mode is Normal. The
transceiver mode also can be Normal when this state is false, such as
when you perform a local wakeup.
If you want to allow other code in the application to execute while waiting
for NI-CAN states, refer to the ncCreateNotification function.
ncWrite
Purpose
Write a single frame to a CAN or LIN Network Interface Object.
Format
NCTYPE_STATUS ncWrite(
NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 DataSize,
NCTYPE_ANY_P DataPtr);
Input
ObjHandle
Object handle.
DataSize
Size of the data in bytes.
DataPtr
Data written to the object. You provide the data using the pointer
DataPtr.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
ncWrite writes a single frame to the object specified by ObjHandle.
DataPtr points to the variable from which the data is written. Its type is undefined so that
you can use the appropriate host data type. DataSize indicates the size of variable pointed
to by DataPtr, and is used to verify that the size you provide is compatible with the
configured write size for the object.
You use ncWrite to place data into the write queue of an object. Because NI-CAN handles
the write queue in the background, this function does not wait for data to be transmitted on
the network. To make sure that the data is transmitted successfully after calling ncWrite,
wait for the NC_ST_WRITE_SUCCESS state. The NC_ST_WRITE_SUCCESS state transitions
from false to true when the write queue is empty, and NI-CAN has successfully transmitted
the last data item onto the network. The NC_ST_WRITE_SUCCESS state remains true until you
write another data item into the write queue.
When you configure an object to transmit data onto the network periodically, it obtains data
from the object write queue each period. If the write queue is empty, NI-CAN transmits the
data of the previous period again. NI-CAN transmits this data repetitively until the next call
to ncWrite.
If an object write queue is full, a call to ncWrite returns the CanErrOverflowWrite error
and NI-CAN discards the data you provide. One way to avoid this overflow error is to set the
write queue length to zero. When ncWrite is called for a zero length queue, the data item
you provide with ncWrite simply overwrites the previous data item without indicating an
overflow. A zero length write queue is often useful when an object is configured to transmit
data onto the network periodically, and you simply want to transmit the most recent data value
each period. It is also useful when you plan to always wait for NC_ST_WRITE_SUCCESS after
every call to ncWrite. You can use the NC_ATTR_WRITE_Q_LEN attribute to configure the
write queue length.
For information on the proper data type to use with DataPtr, refer to the CAN Network
Interface Object and CAN Object descriptions below.
Within the NCTYPE_CAN_FRAME structure, the IsRemote (frame type) field determines the
meaning of all other fields. Table 11-26, NCTYPE_CAN_FRAME Fields for IsRemote
NC_FRMTYPE_DATA (0), Table 11-27, NCTYPE_CAN_FRAME fields for IsRemote
NC_FRMTYPE_REMOTE (1), Table 11-28, NCTYPE_CAN_FRAME fields for IsRemote
NC_FRMTYPE_RESPONSE_ENTRY_FRAME (16), Table 11-29, NCTYPE_CAN_FRAME
fields for IsRemote NC_FRMTYPE_LIN_HEADER_FRAME (17), and Table 11-30,
NCTYPE_CAN_FRAME fields for IsRemote NC_FRMTYPE_LIN_FULL_FRAME (18),
describe the fields of NCTYPE_CAN_FRAME for each value of IsRemote.
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
CAN Object
The data type that you use with ncWrite of the CAN Object is NCTYPE_CAN_DATA. When
calling ncWrite, you should pass size of (NCTYPE_CAN_DATA) for the DataSize parameter.
Table 11-31 describes the fields of NCTYPE_CAN_DATA.
ncWriteMult
Purpose
Write multiple frames to a CAN or LIN Network Interface Object.
Format
NCTYPE_STATUS ncWriteMult(
NCTYPE_OBJH ObjHandle,
NCTYPE_UINT32 DataSize,
NCTYPE_ANY_P DataPtr);
Input
ObjHandle
Object handle.
DataSize
Size of the data in bytes.
DataPtr
Pointer to the data to be written to the CAN Network Interface The data
consists of an array of structures, each of type NCTYPE_CAN_STRUCT.
Within each structure, FrameType indicates the frame type. The frame
type determines the interpretation of the remaining fields. For a
description of each frame type, refer to the Frame Types section of this
function reference.
The maximum number of structures you can provide to each
ncWriteMult is 512. For more information, refer to the Writing
Large Numbers of Frames section of this function reference.
Output
Return Value
Status of the function call, returned as a signed 32-bit integer. Zero means the function
executed successfully. Negative specifies an error, meaning the function did not perform
expected behavior. Positive specifies a warning, meaning the function performed as expected,
but a condition arose that might require attention. For more information, refer to
ncStatusToString.
Description
You use ncWriteMult to place one or more frames into the Network Interface write queue.
This function does not wait for the frames to be transmitted on the network. This function is
not supported for CAN Objects.
Timestamped Transmit
In addition to supporting multiple frames, this function is preferable to ncWrite in that it
supports timestamped frames. To enable timestamped transmit, use ncSetAttribute to
set the NC_ATTR_TRANSMIT_MODE (Transmit Mode) attribute to Timestamped Transmit
mode (1).
In Timestamped Transmit mode, NI-CAN times the transmission according to the difference
in timestamps between consecutive frames. For example, if every frame provided to
ncWriteMult increments by 10 milliseconds, the frames will be transmitted with a
10 millisecond gap.
If the timestamp of one frame is less than the timestamp of the preceding frame, the timeline
is reset, and both frames transmit back to back. For example, if you write a frame with relative
timestamp 30 ms followed by a frame with timestamp 15 ms, the two frames will be
transmitted back to back. This sort of behavior can occur when you transmit a logfile of
timestamped frames repeatedly, because on the second traversal of the logfile, the timestamp
of the first frame will be less than the timestamp of the last frame.
The first frame that you provide to ncWriteMult always transmits immediately, regardless
of its timestamp. If you need to delay transmission of first frame after start, you can write a
Delay frame or Start Trigger frame as described in the Frame Types section of this function
reference.
847x CAN and LIN products do not support timestamped transmit. These products ignore
the timestamp provided in the cluster for ncWriteMult. If you use ncWriteMult to write
header and full frame types out of the USB LIN acting as master, then the frames will be
transmitted together as closely as possible. If you use ncWriteMult to write response frame
types to the LIN interface acting as slave, then the frames will be loaded into the response
table as quickly as possible.
Immediate Transmit
The default value for the NC_ATTR_TRANSMIT_MODE (Transmit Mode) attribute is
Immediate Transmit mode (0). You can also use ncSetAttribute to set the
NC_ATTR_TRANSMIT_MODE attribute to Immediate Transmit mode.
In Immediate Transmit mode, NI-CAN ignores the timestamp in each frame, and transmits
the frames as fast as possible. This behavior is equivalent to the ncWrite function, except
that you can write multiple frames for transmission in quick succession.
When the Network Interface write queue cannot hold all frames provided, ncWriteMult
returns an overflow error. When this overflow error is returned, none of the frames provided
in the array referenced by DataPtr have been written. This enables your application to try
the same array again at a later time.
To determine when adequate space is available in the write queue to retry ncWriteMult after
an overflow, you can use ncWaitForState with the NC_ST_WRITE_MULT (Write Multiple)
state. The NC_ST_WRITE_MULT state will transition from false to true when space is available
for at least 512 frames. Since you must limit the array passed to ncWriteMult to 512 frames
or less, the NC_ST_WRITE_MULT state indicates that a retry will succeed.
After writing a sequence of timestamped frames with ncWriteMult, you cannot close the
Network Interface, because you must wait for the last timestamped frame to transmit onto the
network. You can wait for the final transmit to complete using ncWaitForState with the
NC_ST_WRITE_SUCCESS (Write Success) state. You can also use ncGetAttribute with the
NC_ATTR_WRITE_PENDING (Write Entries Pending) attribute to query periodically, which
provides the option of aborting the timestamped transmission by closing the Network
Interface.
Frame Types
Within each structure (type NCTYPE_CAN_STRUCT) of the array referenced by DataPtr,
FrameType indicates the frame type. The frame type determines the interpretation of the
remaining fields. Table 11-32, Structure with FrameType value NC_FRMTYPE_DATA (0):
CAN Data Frame, Table 11-33, Structure with FrameType value NC_FRMTYPE_REMOTE
(1): CAN Remote Frame, Table 11-34, Structure with FrameType value
NC_FRMTYPE_START_TRIG (4): Start Trigger Frame, Table 11-35, Structure with
FrameType value NC_FRMTYPE_DELAY (5): Delay Frame, Table 11-36, FrameType Value
NC_FRMTYPE_LIN_RESPONSE_ENTRY (16): LIN Response Entry Frame, Table 11-37,
To determine if your hardware supports one of the following frame types for this function,
refer to Appendix D, Frame Types for CAN and LIN Hardware.
Table 11-32. Structure with FrameType value NC_FRMTYPE_DATA (0): CAN Data Frame
Table 11-33. Structure with FrameType value NC_FRMTYPE_REMOTE (1): CAN Remote Frame
Table 11-34. Structure with FrameType value NC_FRMTYPE_START_TRIG (4): Start Trigger Frame
Table 11-34. Structure with FrameType value NC_FRMTYPE_START_TRIG (4): Start Trigger Frame (Continued)
Table 11-35. Structure with FrameType value NC_FRMTYPE_DELAY (5): Delay Frame
Table 11-36. FrameType Value NC_FRMTYPE_LIN_RESPONSE_ENTRY (16): LIN Response Entry Frame
Table 11-36. FrameType Value NC_FRMTYPE_LIN_RESPONSE_ENTRY (16): LIN Response Entry Frame
Table 11-37. FrameType Value NC_FRMTYPE_LIN_HEADER (17): LIN Header Frame (Continued)
You can test the CAN and LIN interfaces by choosing Tools»NI-CAN»
Test All Local Cards from the menu, or you can right-click on a CAN or
LIN interface and choose Self Test. If the Self Test fails, refer to the
Troubleshooting Self Test Failures section of this chapter.
If the interface still doesn’t show up, you may have a resource conflict
in the Windows Device Manager. Refer to the documentation for the
Windows operating system for instructions on how to resolve the problem
using the Device Manager.
Application In Use
This error occurs if you are running an application that is already using the
NI-CAN card. The self test aborts in order to avoid adversely affecting the
application. Before running the self test, exit all applications that use
NI-CAN. If you are using LabVIEW, you may need to exit LabVIEW in
order to unload the NI-CAN driver.
If the error continues after restart, uninstall NI-CAN and then reinstall.
Common Questions
How can I determine which version of the NI-CAN software is installed
on my system?
Within MAX, select Help Topics»NI-CAN within the Help menu. The
version is displayed at the top of the help text. The NI-CAN entry provides
version information.
How many CAN cards can I configure for use with my NI-CAN
software?
The NI-CAN software can be configured to communicate with up to
32 NI-CAN cards on all supported operating systems.
Can I use the Channel API and the Frame API at the same time?
Yes, you can use the Channel API and the Frame API at the same time, but
only on different ports. For example, you can use the Frame API on port 1
of a 2-port NI-CAN card and the Channel API on port 2 of that card.
Why can't I communicate with other devices on the CAN bus, even
though the Self Test in MAX passed?
If you have a Series 1 card, check the settings for the Power Source Jumper.
The position EXT is required for low-speed cards; High-Speed cards
should have it set to INT. For further information, refer to Chapter 4,
Connectors and Cables.
If the jumper settings are correct, or you are using Series 2 CAN cards, the
network may have a cabling or termination problem. Refer to Chapter 3,
NI CAN and LIN Hardware, for more information.
In addition, consult the documentation for the CAN nodes to ensure that the
baud rate is exactly the same as you specify in MAX and/or the application
code.
When a device transmits a message onto the CAN network, all other
devices on the network receive that message. Each receiving device
performs an acceptance test on the identifier to determine if the message is
relevant 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 message simultaneously, the
identifier is used as a priority to determine which device gains access to the
network. The lower the numerical value of the identifier, the higher its
priority.
Figure B-1 shows two CAN devices attempting to transmit messages, one
using identifier 647 hex, and the other using identifier 6FF hex. As each
device transmits the 11 bits of its identifier, it examines the network to
determine if a higher-priority identifier is being transmitted simultaneously.
If an identifier collision is detected, the losing device(s) immediately stop
transmission, and wait for the higher-priority message to complete before
automatically retrying. Because the highest priority identifier continues
its transmission without interruption, this scheme is referred to as
nondestructive bitwise arbitration, and CAN’s identifier is often referred to
as an arbitration ID. This ability to resolve collisions and continue with
high-priority transmissions is one feature that makes CAN ideal for
real-time applications.
Device A
ID = 11001000111 (647 hex) S
Device B
ID = 11011111111 (6FF hex) S
CAN Frames
In a CAN network, the messages transferred across the network are called
frames. The CAN protocol supports two frame formats as defined in the
Bosch version 2.0 specifications, the essential difference being in the length
of the arbitration ID. In the standard frame format (also known as 2.0A),
the length of the ID is 11 bits. In the extended frame format (also known
as 2.0B), the length of the ID is 29 bits. Figure B-2 shows the essential
fields of the standard and extended frame formats, and the following
sections describe each field.
Arbitration ID
The arbitration ID fields contain the identifier for a CAN frame. The
standard format has one 11-bit field, and the extended format has two
fields, which are 11 and 18 bits in length. In both formats, bits of the
arbitration ID are transmitted from high to low order.
Data Bytes
For data frames, this field contains from 0 to 8 data bytes. Remote CAN
frames always contain zero data bytes.
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.
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 can occur again.
CAN devices detect the following errors, which are described in the
following sections:
• Bit error
• Stuff error
• CRC error
• Form error
• Acknowledgment error
Bit Error
During frame transmissions, a CAN device monitors the bus on a bit-by-bit
basis. If the bit level monitored is different from the transmitted bit, a bit
error is detected. This bit error check applies only to the Data Length Code,
Data Bytes, and Cyclic Redundancy Check fields of the transmitted frame.
Stuff Error
Whenever a transmitting device detects five consecutive bits of equal value,
it automatically inserts a complemented bit into the transmitted bit stream.
This stuff bit is automatically removed by all receiving devices. The bit
stuffing scheme is used to guarantee enough edges in the bit stream to
maintain synchronization within a frame.
A stuff error occurs whenever six consecutive 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 occurs when a violation of the fundamental CAN frame
encoding is detected. For example, if a CAN device begins transmitting the
Start Of Frame bit for a new frame before the End Of Frame sequence
completes for a previous frame (does not wait for bus idle), a form error is
detected.
Acknowledgment Error
An acknowledgment error is detected by a transmitting device whenever it
does not detect a dominant Acknowledgment Bit (ACK).
Error Confinement
To provide for error confinement, each CAN device must implement a
transmit error counter and a receive error counter. The transmit error
counter is incremented when errors are detected for transmitted frames, and
decremented when a frame is transmitted successfully. The receive error
counter is used for received frames in much the same way. The error
counters are increased more for errors than they are decreased for
successful reception/transmission. This ensures that the error counters will
generally increase when a certain ratio of frames (roughly 1/8) encounter
errors. By maintaining the error counters in this manner, the CAN protocol
can generally distinguish temporary errors (such as those caused by
external noise) from permanent failures (such as a broken cable). For
complete information on the rules used to increment/decrement the error
counters, refer to the CAN specification (ISO 11898).
With regard to error confinement, each CAN device may be in one of three
states: error active, error passive, and bus off.
One special rule to keep in mind: When an error passive device detects an
acknowledgment error, it does not increment its transmit error counter.
Thus, if a CAN network consists of only one device (for example, if you do
not connect a cable to the National Instruments CAN interface), and that
device attempts to transmit a frame, it retransmits continuously but never
goes into bus off state (although it eventually reaches error passive state).
Low-Speed CAN
Low-speed CAN is commonly used to control “comfort” devices in an
automobile, such as seat adjustment, mirror adjustment, and door locking.
It differs from “High-Speed” CAN in that the maximum baud rate is 125K
and it utilizes CAN transceivers that offer fault-tolerant capability. This
enables the CAN bus to keep operating even if one of the wires is cut or
short-circuited because it operates on relative changes in voltage, and thus
provides a much higher level of safety. The transceiver solves many
common and frequent wiring problems such as poor connectors, and also
overcomes short circuits of either transmission wire to ground or battery
voltage, or the other transmission wire. The transceiver resolves the fault
situation without involvement of external hardware or software. On the
detection of a fault, the transceiver switches to a one wire transmission
mode and automatically switches back to differential mode if the fault is
removed.
Special resistors are added to the circuitry for the proper operation of the
fault-tolerant transceiver. The values of the resistors depend on the number
of nodes and the resistance values per node. For guidelines on selecting the
resistor, refer to the Low-Speed/Fault-Tolerant CAN Pinout Cable section
of Chapter 4, Connectors and Cables.
The basic unit of transfer on the LIN bus is the frame, which is divided into
a header and a response. The header is always transmitted by the master
node and consists of three distinct fields: the Break, the Synchronization
Field (Sync), and Identifier Field (ID). The response is transmitted by a
slave task (which can reside in either the master node or a slave node) and
consists of a data payload and a checksum.
Normally, the master task polls each slave task in a loop by transmitting a
header, which consists of a Break-Sync-ID sequence. Prior to starting the
LIN, each slave task is configured to either publish data to the bus or
subscribe to data in response to each received header ID. Upon receiving
the header, each slave task verifies ID parity and then checks the ID to
determine whether it needs to publish or subscribe. If the slave task needs
to publish a response, it transmits 1-8 data bytes to the bus followed by a
checksum byte. If the slave task needs to subscribe, it reads the data payload
and checksum byte from the bus and takes appropriate internal action. For
standard slave-to-master communication, the master will broadcast the
identifier to the network, and one and only one slave will respond with a
data payload.
Break
Every LIN frame begins with the Break, comprised of 13 dominant bits
(nominal) followed by a break delimiter of one bit (nominal) recessive.
This serves as a start-of-frame notice to all nodes on the bus.
Sync
The Sync field is the second field transmitted by the master task in the
header. Sync is defined as the character x55. The Sync field allows slave
devices that perform automatic baud rate detection to measure the period of
the baud rate and adjust their internal baud rate to synchronize with the bus.
ID
The ID field is the final field transmitted by the master task in the header.
This field provides identification for each message on the network and
ultimately determines which nodes in the network receive or respond to
each transmission. All slave tasks continually listen for Identifier Fields,
verify their parity and determine if they are publishers or subscribers for
this particular identifier. LIN provides a total of 64 IDs. IDs 0–59 are used
for signal-carrying (data) frames, 60–61 are used to carry diagnostic data,
62 is reserved for user-defined extensions, and 63 is reserved for future
protocol enhancements. The ID is transmitted over the bus as one protected
ID byte, with the lower 6 bits containing the raw ID and the upper two bits
containing the parity.
Figure C-1 shows how parity is calculated using the raw ID, and how the
protected ID is formed from the combination of the parity bits and raw ID.
Data Bytes
The Data Bytes field is transmitted by the slave task in the response.
This field contains from 1 to 8 bytes of payload data bytes.
Checksum
The Checksum field is transmitted by the slave task in the response. LIN
defines the use of one of two checksum algorithms to calculate the value in
the 8-bit checksum field. Classic checksum is calculated by summing the
data bytes alone, while Enhanced checksum is calculated by summing the
data bytes and the protected ID.
The LIN 2.0 specification defines the checksum calculation process as the
summing of all values and subtraction of 255 every time the sum is greater
than or equal to 256 (unlike modulo-255 or modulo-256). Per the LIN 2.0
specification, classic checksum is for use with LIN 1.3 slave nodes and
enhanced checksum with LIN 2.0 slave nodes. It further specifies that IDs
60–63 shall always use classic checksum. The NI LIN interface provides an
attribute to set the checksum type to classic or enhanced. The default setting
is classic. Per the LIN 2.0 specification, IDs 60–63 always use classic
checksum, regardless of the setting of the checksum attribute.
Figure C-2 illustrates how a master task header and a slave task response
combine to create a LIN full frame.
THeader_Nominal = 34 * TBit
THeader_Maximum = 14 * THeader_Nominal
In general terms, the LDF is used to configure and create the scheduling
behavior of the LIN cluster. For example, it defines the baud rate, the
ordering and time delays for the master task’s transmission of headers, and
the behavior of each slave task in response. The NI-CAN Frame API for
LIN and NI LIN hardware do not natively provide full support for LDFs,
meaning that scheduling behavior cannot be downloaded into the hardware.
However, the low-level support of accessing the bus (writing headers and
publishing or subscribing to responses) is provided such that the user may
create this scheduling behavior at the application level. As mentioned in the
description for the NI LIN response entry frame type, the NI LIN hardware
does provide a response queue for storing slave task responses. The
response queue holds 64 responses, one for each of the maximum number
of 64 IDs specified for LIN. This ensures that the LIN interface slave task
can respond to headers within the response time defined by the LIN
specification.
The NI-CAN Frame API for LIN provides a robust means of complete,
low-level interaction with the LIN bus. This provides the end user with the
basic functionality from which to develop complex applications involving
the analysis and prototyping of LIN networks. The NI-CAN Frame API for
LIN does not natively support LIN diagnostics or configuration, LIN
Description Files or schedule tables. However, these tasks may be
implemented in applications making use of the NI-CAN Frame API
for LIN.
LIN also provides for error reporting to the network. The LIN 2.0
specification defines a Response_Error status bit, which the slave is
required to report to the master in one of its transmitted frames. This bit is
set whenever a frame received or transmitted by a slave node contains an
error in the response field. The bit is cleared after it is transmitted in one of
the slaves published responses. The NI-CAN Frame API for LIN does not
natively support the Response_Error status bit, but provides the end user
with a means to easily implement this functionality at the application level.
The procedure is to set the log bus errors attribute equal to one, to enable
logging of bus error frames in the read queue. The application can then
monitor for a read of a bus error frame with the error code indicating an
error in the response. Upon this condition, the application can set a
Response_Error status bit in a local variable. The application can then use
the NI LIN response entry frame type to update the slave response queue
with data containing the Response_Error status bit and then clear the bit in
the local variable.
The NI-CAN Frame API for LIN provides great flexibility by allowing the
user to put the LIN interface to sleep as desired at the application level.
Upon receiving a full frame containing a sleep request message, or a bus
inactive frame indicating 4 seconds of bus inactivity, the user may choose
to put the LIN interface to sleep by setting the LIN Sleep attribute to
TRUE.
LIN also provides a mechanism for waking devices on the bus. Wakeup is
one task that may be initiated by any node on the bus (a slave as well as the
master). Per the LIN 2.0 specification, the wakeup request is issued by
forcing the bus dominant for 250 microseconds to 5 milliseconds. Each
slave should detect the wakeup request and be ready to process headers
within 100 milliseconds. The master should also detect the wakeup request
and start sending headers when the slave nodes are ready (within 100 to
150 milliseconds after receiving the wakeup request). If the master does not
issue headers within 150 milliseconds after receiving the first wakeup
request, then the slave requesting wakeup may try issuing a second wakeup
request (and waiting for another 150 milliseconds). If the master still
does not respond, the slave may issue the wakeup request and wait
150 milliseconds a third time. If there is still no response, the slave must
wait for 1.5 seconds before issuing a forth wakeup request. The NI-CAN
Frame API for LIN allows wakeup to be performed according to the LIN
2.0 specification regardless of whether the LIN interface is operating as a
master or slave.
The event triggered frame may have an ID in the range of 0–59. Each slave
that could potentially respond to the event triggered header ID has its first
data byte loaded with the protected ID it would respond to if the master was
querying it for an unconditional frame. The event triggered frame works as
follows. The master writes an event triggered ID in a header. The slaves
may only respond to the event triggered ID if their data has been updated.
If only one slave publishes a response, then the master receives it and
looking at the first data byte, knows from which slave (through the
protected ID), it was received. If multiple slaves publish a response then a
collision will occur, which the master device slave task will report as a bus
error. The master device will then query a response from each slave using
unconditional frames.
Diagnostic frames are always eight data bytes in length, and always carry
diagnostic or configuration data. Their ID is either 60 for a master request
frame, or 61 for a slave response frame. User defined frames have an ID of
62 and may carry any type of information. Reserved frames have an ID of
63 and must not be used in a LIN 2.0 cluster.
Frame
Value Type ncReadNet ncReadNetMult ncWriteNet ncWriteNetMult
0 CAN Data Series 1, Series Series 1, Series 2, Series 1, Series 2, Series 1, Series 2,
Frame 2, 847x, 847x 847x, 847x with 847x, 847x with 847x, 847x with
with Sync Sync Sync Sync
5 Delay — — — Series 1,
Frame Series 2
Frame
Value Type ncReadNet ncReadNetMult ncWriteNet ncWriteNetMult
4 Start 847x, 847x 847x, 847x — —
Trigger with Sync with Sync
Frame (Master/Slave) (Master/Slave)
18 LIN Full 847x, 847x with 847x, 847x with 847x, 847x with 847x, 847x with
Frame Sync (Slave) Sync (Slave) Sync Sync
(Master/Slave) (Master/Slave)
PCI-CAN Series 2
This section lists specifications for PCI-CAN Series 2 hardware.
Power Requirement
+5 VDC (±5%)
PCI-CAN ........................................ 800 mA typical
PCI-CAN/2 ..................................... 850 mA typical
PCI-CAN/LS................................... 800 mA typical
PCI-CAN/LS2................................. 850 mA typical
PCI-CAN/SW ................................. 750 mA typical
PCI-CAN/SW2 ............................... 800 mA typical
PCI-CAN/XS .................................. 800 mA typical
PCI-CAN/XS2 ................................ 900 mA typical
Physical
Dimensions............................................. 20.70 cm × 11.18 cm
(8.150 in. × 4.4 in.)
Operating Environment
Ambient temperature.............................. 0 to 55 °C
Storage Environment
Ambient temperature ..............................–20 to 70 °C
Optical Isolation
Isolation up to 500 VDC (withstand, 2s max) channel-to-bus
RTSI
Trigger lines............................................7 input/output
I/O compatibility.....................................TTL
High-Speed CAN
Transceiver .............................................Philips TJA1041
Low-Speed/Fault-Tolerant CAN
Transceiver ............................................Philips TJA1054A
XS Software Selectable
Relay service life
Mechanical...................................... 50,000,000 operations min.
(at 36,000 operations per hour)
PXI-846x Series 2
This section lists specifications for PXI-846x Series 2 hardware.
Power Requirement
+5 VDC (±5%)
PXI-8461 (1 port) ............................800 mA typical
PXI-8461 (2 ports)...........................850 mA typical
PXI-8460 (1 port) ............................800 mA typical
PXI-8460 (2 ports)...........................850 mA typical
PXI-8464 (1 port) ............................850 mA typical
PXI-8464 (2 ports)...........................900 mA typical
Physical
Dimensions .............................................16.0 cm × 10.0 cm
(6.3 in. × 3.9 in.)
Operating Environment
Ambient temperature ..............................0 to 55 °C
Storage Environment
Ambient temperature ..............................–20 to 70 °C
Functional Shock
30 g peak, half-sine, 11 ms pulse
Random Vibration
Operating................................................ 5 to 500 Hz, 0.3 grms
Optical Isolation
Isolation up to 500 VDC (withstand, 2s max) channel-to-bus
High-Speed CAN
Transceiver............................................. Philips TJA1041
Low-Speed/Fault-Tolerant CAN
Transceiver .............................................Philips TJA1054A
XS Software Selectable
Relay service life
Mechanical ......................................50,000,000 operations min.
(at 36,000 operations per hour)
PCMCIA-CAN Series 2
This section lists specifications for PCMCIA-CAN Series 2 hardware.
Power Requirement
+5 VDC (±5%)
PCMCIA-CAN ............................... 350 mA typical; active
1-port PCMCIA-CAN
internal power cable........................ +55 mA typical
PCMCIA-CAN/2 ............................ 350 mA typical; active
2-port PCMCIA-CAN
internal power cable........................ +115 mA typical
Physical
Dimensions............................................. 8.56 cm × 5.40 cm × 0.5 cm
(3.4 in. × 2.1 in. × 0.2 in.)
Operating Environment
Ambient temperature.............................. 0 to 55 °C
Storage Environment
Ambient temperature ..............................–20 to 70 °C
Optical Isolation
Isolation up to 500 VDC (withstand, 2s max) channel-to-bus
in PCMCIA-CAN cables
Synchronization Triggers
Trigger lines............................................4 input/output (TRIG_0-TRIG_3)
I/O compatibility.....................................TTL
Single-Wire Cable
Transceiver............................................. Philips AU5790
Power requirement
(always required).................................... +8 to +18 VDC
(12 VDC recommended)
on V+ connector pin
(referenced to V–)
Power Requirement
+5 VDC (±5%)
USB-CAN........................................250 mA typical
USB-LIN .........................................200 mA typical
Physical
Dimensions
Non-Sync.........................................7.87 cm × 6.35 cm × 2.54 cm
(3.1 in. × 2.5 in.×y 1.0 in.)
Sync .................................................7.87 cm × 7.11 cm × 2.54 cm
(3.1 in. × 2.8 in. × 1.0 in.)
Operating Environment
Ambient temperature ..............................0 to 55 °C
Storage Environment
Ambient temperature ..............................–20 to 70 °C
Optical Isolation
Isolation up to 500 VDC (withstand, 2s max) channel-to-bus
High-Speed CAN
Transceiver............................................. Philips TJA1041
Low-Speed/Fault-Tolerant CAN
Transceiver............................................. Philips TJA1054A
LIN
Transceiver ............................................AMTEL ATA6620
Safety
The NI-CAN hardware meets the requirements of the following standards
of safety for information technology equipment:
• IEC 60950-1, EN 60950-1
• UL 60950-1, CSA 60950-1
Note For UL and other safety certifications, refer to the product label, or visit
ni.com/certification, search by model number or product line, and click the
appropriate link in the Certification column.
Maximum altitude...................................2,000 m
Electromagnetic Compatibility
This product is designed to meet the requirements of the following
standards of EMC for electrical equipment for measurement, control,
and laboratory use:
• EN 61326 EMC requirements; Minimum Immunity
• EN 55011 Emissions; Group 1, Class A
• CE, C-Tick, ICES, and FCC Part 15 Emissions; Class A
Note For full EMC compliance, operate this device according to product documentation.
CE Compliance
This product meets the essential requirements of applicable European
Directives, as amended for CE marking, as follows:
• 73/23/EEC; Low-Voltage Directive (safety)
• 89/336/EEC; Electromagnetic Compatibility Directive (EMC)
Note Refer to the Declaration of Conformity (DoC) for this product for any additional
regulatory compliance information. To obtain the DoC for this product, visit
ni.com/certification, search by model number or product line, and click the
appropriate link in the Certification column.
If you searched ni.com and could not find the answers you need, contact
your local office or NI corporate headquarters. Phone numbers for our
worldwide offices are listed at the front of this manual. You also can visit
the Worldwide Offices section of ni.com/niglobal to access the branch
office Web sites, which provide up-to-date contact information, support
phone numbers, email addresses, and current events.
A
action See method.
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 networks,
actuators are devices that receive their primary data value from over the
network; examples include valves and motor starters. Also known as final
control element.
arbitration ID An 11- or 29-bit ID transmitted as the first field of a CAN frame. The
arbitration ID determines the priority of the frame, and is normally used to
identify the data transmitted in the frame.
attribute The Frame API provides attributes to access configuration settings or other
information. In the Channel API, the term property is used for similar
settings.
B
b Bits.
Behavior After Property in the Channel API that specifies the behavior to perform after the
Final Output final periodic output sample is transmitted. For more information, refer to
CAN Set Property.vi for LabVIEW, or nctSetProperty for C.
bus off A CAN node goes into the bus off state when its transmit error counter
increments above 255. The node does not participate in network traffic,
because it assumes that a defect exists that must be corrected.
C
CAN Controller Area Network.
CAN controller Communications ship used to transmit and receive frames on a CAN
network. The majority of the CAN specification is implemented within the
CAN controller. Examples of CAN controllers include the Intel 82527
(used by Series 1 NI CAN hardware), and the Philips SJA1000 (used by
Series 2 NI CAN hardware).
CANdb CAN database format defined by Vector Informatik. CANdb files use the
.dbc file extension.
CAN database Database file that describes channels and associated messages for a
collection of CAN nodes. NI-CAN supports two CAN database formats:
CANdb, and the NI-CAN database.
CAN data frame Frame used to transmit the actual data of a CAN Object. The RTR bit is
clear, and the data length indicates the number of data bytes in the frame.
CAN frame In addition to fields used for error detection/correction, a CAN frame
consists of an arbitration ID, the RTR bit, a four-bit data length, and zero to
eight bytes of data.
CAN Network Within the NI-CAN Frame API, an object that encapsulates a CAN
Interface Object interface on the host computer.
CAN Object Within the NI-CAN Frame API, an object that encapsulates a specific CAN
arbitration ID along with its raw data bytes.
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 desired (but no
data bytes are included).
channel Floating-point value in physical units (such as Volts, rpm, km/h, °C, and so
on) that is converted to/from a raw value in measurement hardware. The
Read and Write functions of the NI-CAN Channel API provide access to
CAN channels. When a CAN message is received, NI-CAN converts raw
fields in the message into physical units, which you then obtain using the
Channel API Read function. When you call a Channel API Write function,
you provide floating-point values in physical units, which NI-CAN
converts into raw fields and transmits as a CAN message. For an example
usage of the channel concept, refer to the Channel API section in
Introduction.
Channel API NI-CAN API that you use to read and write channels.
channel list Input parameter of the CAN Init Start function. The channel list specifies
the list of channels to read or write. For more information, refer to CAN Init
Start.vi for LabVIEW, or nctInitStart for C.
class A set of objects that share a common structure and a common behavior.
clock drift When two or more hardware products are used to measure a common
system, you typically need to compare data from the hardware products
simultaneously. Since each hardware product contains its own local
oscillator to perform measurements, and all oscillators differ slightly in
speed and tolerances, measurements on different hardware products can
drift relative to one another. For example, if you measure the same sine
wave on two different analog-input products, the measured sine waves
typically drift out of phase after a few minutes. National Instruments
products use RTSI to share timebases among different hardware products.
Since the products share the same oscillator, clock drift is eliminated.
controller With respect to CAN, this term often refers to a CAN controller. With
respect to real-time systems, this term refers to a device that receives input
data and sends output data in order to hold one or more external, real-world
variables at a certain level or condition. A thermostat is a simple example
of a controller.
D
Default Value Property in the Channel API that specifies the default value for a channel.
For more information, refer to CAN Get Property.vi for LabVIEW,
or nctSetProperty for C.
E
error active A CAN node is in error active state when both the receive and transmit error
counters are below 128.
error counters Every CAN node keeps a count of how many receive and transmit errors
have occurred. The rules for how these counters are incremented and
decremented are defined by the CAN protocol specification.
error passive A CAN node is in error passive state when one or both of its error counters
increment above 127. This state is a warning that a communication problem
exists, but the node is still participating in network traffic.
extended A 29-bit arbitration ID. Frames that use extended IDs are often referred to
arbitration ID as CAN 2.0 Part B (the specification that defines them).
F
FCC Federal Communications Commission.
Frame API NI-CAN API that you use to read and write frames.
H
hex Hexadecimal.
I
instance An abstraction of a specific real-world thing; for example, John is an
instance of the class Human. Also known as object.
Interface Baud Rate Property in the Channel API that specifies the baud rate of the interface.
For more information, refer to CAN Set Property.vi for LabVIEW, or
nctSetProperty for C.
Interface Receive Every CAN node keeps a count of how many receive errors have occurred.
Error Counter The rules for how this counter is incremented and decremented are defined
by the CAN protocol specification. This property in the Channel API
returns the receive error counter. For more information, refer to CAN Get
Property.vi for LabVIEW or nctGetProperty for C.
Interface Single Shot Property in the Channel API that determines whether to retry failed frame
Transmit transmissions or transmit as a single-shot. For more information, refer to
CAN Set Property.vi for LabVIEW, or nctSetProperty for C.
Interface Transmit Every CAN node keeps a count of how many transmit errors have occurred.
Error Counter The rules for how this counter is incremented and decremented are defined
by the CAN protocol specification. This property in the Channel API
returns the transmit error counter. For more information, refer to CAN Get
Property.vi for LabVIEW, or nctGetProperty for C.
K
KB Kilobytes of memory.
L
LabVIEW Laboratory Virtual Instrument Engineering Workbench.
local Within NI-CAN, anything that exists on the same host (personal computer)
as the NI-CAN driver.
local wakeup Wakeup of the CAN transceiver from sleep mode caused by the call to an
NI-CAN function, such as setting Transceiver Mode to Normal.
M
MAX Measurement & Automation Explorer provides a centralized location for
configuration of National Instruments hardware products. MAX also
provides many useful tools for interaction with hardware.
MB Megabytes of memory.
message CAN data frame for which the individual fields are described. From an OSI
perspective, NI-CAN usage of the term frame refers to a User Layer unit,
because the Application Layer is assumed (simple peer-to-peer protocol),
and the channel configurations specify User Layer meaning.
minimum interval For a given connection, the minimum amount of time between subsequent
attempts to transmit frames on the connection. Some protocols use
minimum intervals to guarantee a certain level of overall network
performance.
mode Input parameter of the CAN Init Start function. The mode specifies the
direction of data transfer (input or output), and the type of information
provided (input or timestamped input). For more information, refer to CAN
Init Start.vi for LabVIEW, or nctInitStart for C.
N
network interface A physical connection of a node onto a network.
NI-CAN database CAN database format defined by National Instruments. NI-CAN database
files use the .ncd file extension.
NI-CAN driver Device driver and/or firmware that implement all the specifics of a CAN
network interface. Within NI-CAN, this software implements the CAN
Network Interface Object as well as all objects above it in the object
hierarchy.
notification Within NI-CAN, an operating system mechanism that the NI-CAN driver
uses to communicate events to the application. You can think of a
notification of as an API function, but in the opposite direction.
O
object See instance.
P
peer-to-peer Network connection in which data is transmitted from the source to its
destination(s) without need for an explicit request. Although data transfer
is generally unidirectional, the protocol often uses low level
acknowledgments and error detection to ensure successful delivery.
poly VI LabVIEW VI that accepts different data types for a single input or output
terminal. In some cases, the data type can be selected based on the value
that you wire to the poly input or output. To select a specific poly VI type,
right-click the VI, go to Select Type, and select the desired type. For more
information, refer to the LabVIEW documentation. Like many other
National Instruments APIs, the NI-CAN Channel API implements Read
and Write as poly VIs in order to support a variety of data types.
port The physical CAN connector on the NI-CAN hardware product. You assign
an interface name to each port using MAX.
property nodes In LabVIEW, you can use property nodes to change the appearance or
behavior of front panel controls and indicators. For example, you can
change the label, minimum value, and maximum value of an indicator.
For more information, refer to the LabVIEW documentation.
protocol A formal set of conventions or rules for the exchange of information among
nodes of a given network.
R
RAM Random-access memory.
remote Within NI-CAN, anything that exists in another node of the device network
(not on the same host as the NI-CAN driver).
Remote Transmission This bit follows the arbitration ID in a frame, and indicates whether the
Request (RTR) bit frame is the actual data of the CAN Object (CAN data frame), or whether
the frame is a request for the data (CAN remote frame).
remote wakeup Wakeup of the CAN transceiver from sleep mode caused from an event on
the network. A remote wakeup occurs when a remote node transmits a
CAN frame (referred to as the wakeup frame). The wakeup frame wakes up
the transceiver and CAN controller chip of the NI CAN interface. The
wakeup frame is not received or acknowledged by the CAN controller chip.
When the wakeup frame ends, the NI CAN interface enters Normal mode,
and again receives and transmits CAN frames. If the node that transmitted
the wakeup frame did not detect an acknowledgement (such as if other
nodes were also waking), it will retry the transmission, and the retry will be
received by the NI CAN interface.For a remote wakeup to occur for Single
Wire transceivers, the node that transmits the wakeup frame must first place
the network into the Single Wire Wakeup Transmission mode by asserting
a higher voltage (typically 12 V).
RTSI Real Time System Integration bus. National Instruments technology that
can be used to synchronize multiple hardware products. For PCI products,
this refers to the ribbon cable that is used to route signals between cards.
For PXI products, the RTSI signals are provided on the backplane. For
PCMCIA products, RTSI signals can be connected between the sync cable
of a CAN card and the terminal block of a DAQ card.
S
s Seconds.
sample rate Input parameter of the CAN Init Start function. The sample rate specifies
whether to transfer data in a periodic or event-driven manner. For periodic
behavior, the rate specifies the number of read/write samples to perform per
second. For more information, refer to CAN Init Start.vi for LabVIEW,
or nctInitStart for C.
Series 1 National Instruments hardware for CAN that shipped prior to NI-CAN 2.0.
NI-CAN supports this hardware series, but some new features require
Series 2 hardware.
Series 2 National Instruments hardware for CAN that shipped after NI-CAN 2.0.
Improvements relative to Series 1 include a superior CAN controller
(Philips SJA1000), and improved RTSI features.
signal Term used by other vendors of CAN products to refer to a CAN channel.
For National Instruments products, this term usually refers to a physical
voltage that represents a predefined behavior. For example, RTSI
connections are used to exchange signals.
standard arbitration An 11-bit arbitration ID. Frames that use standard IDs are often referred to
ID as CAN 2.0 Part A; standard IDs are by far the most commonly used.
start trigger When two or more hardware products are used to measure a common
system, you typically need to compare data from the hardware products
simultaneously. Since each hardware product starts its measurement
independently, measurements on different hardware products can often be
skewed in time relative to one another. For example, if you measure the
same sine wave on two different analog-input products, the measured sine
waves start off out of phase. National Instruments products use RTSI to
share start triggers among different hardware products. Since the products
share the same start trigger, measurements begin at the same time.
T
task A collection of channels that you can read or write. The task is returned
as an output parameter of the CAN Init Start function, and is used for
all subsequent Channel API calls such as Read or Write. For more
information, refer to CAN Init Start.vi for LabVIEW, or nctInitStart for C.
terminal A physical pin on a hardware component. RTSI signals are one type of
terminal. Internal connections within hardware products are another type of
terminal.
Timeout Property in the Channel API that specifies the behavior the timeout in
milliseconds for Read and Write functions. For more information, refer
to CAN Set Property.vi for LabVIEW, or nctSetProperty for C.
U
unsolicited Connections that transmit data on the network sporadically based on an
external event. Also known as nonperiodic, sporadic, and event driven.
V
VI Virtual Instrument.
W
watchdog timeout A timeout associated with a connection that expects to receive network data
at a specific rate. If data is not received before the watchdog timeout
expires, the connection is normally stopped. You can use watchdog
timeouts to verify that the remote node is still operational.
waveform data type LabVIEW data type that represents a sequential list of samples in time. The
data type includes the array of samples (each a DBL), a start time that
specifies when the first sample was measured, and a delay time that
specifies the time between samples (sample rate) or more information, refer
to the LabVIEW documentation. The Read and Write functions of the
Channel API support the LabVIEW waveform data type.
A
additional information, LIN, C-8
B
advanced frame types, LIN, C-7 Borland C++, 5-3
API (Application Programming Interface) bus timing, LIN, C-4
Channel API
additional programming topics, 6-11 C
Get Names, 6-11
cable length, Single Wire CAN, 4-20
Set Property, 6-12
cable lengths, High-Speed CAN, 4-4
Synchronization, 6-11
cable termination, low-speed CAN, 4-10
basic programming model, 6-4
cabling example
Clear, 6-10
High-Speed CAN (figure), 4-6
Init Start, 6-5
Low-Speed/Fault-Tolerant CAN
Read, 6-6
(figure), 4-17
Read Timestamped, 6-8
Single Wire CAN (figure), 4-21
Read Timestamped (figure), 6-8
cabling requirements
Write, 6-8
LIN
choose source of Channel
lengths, 4-26
configuration, 6-1
number of devices, 4-26
decision process (figure), 6-1
specifications, 4-26
using, 6-1
termination, 4-26
choose which API to use, 5-6
Single Wire CAN, 4-20
Frame API
XS CAN, 4-23
choose which objects to use, 9-1
calibration certificate (NI resources), F-2
using CAN network interface
CAN
objects, 9-1
using CAN objects, 9-3 error detection and confinement, B-5
application development, 5-1 frame types, D-1
frames, B-3
choose the programming language, 5-1
choose which API to use, 5-6 history and use, B-1
choose your programming language identifiers and message priority, B-2
low-speed, B-8
Borland C++, 5-3
LabVIEW, 5-1 summary of standard, B-1
CAN and LIN hardware installation, 2-3 CAN Network Interface Objects, possible
CAN Channels uses, 9-1
example in MAX (figure), 2-5 CAN Objects
overview, 2-5 choosing NI-CAN Objects
CAN Clear Multiple with NI-DAQ.vi, 7-10 CAN Network interface Objects, 9-1
CAN Clear Multiple with NI-DAQmx.vi, 7-12 CAN Objects, 9-3
CAN Clear with NI-DAQ.vi, 7-6 using, 9-3
CAN Clear with NI-DAQmx.vi, 7-8 CAN overview, 1-1
CAN Clear.vi, 7-4 CAN ports, configuring, 2-4
CAN Connect Terminals.vi, 7-14 CAN Read.vi, 7-65
CAN Create Message.vi, 7-24 CAN Set Property.vi, 7-73
CAN Create MessageEx.vi, 7-30 CAN Start.vi, 7-88
CAN data frame fields example (figure), 1-10 CAN Stop.vi, 7-90
CAN Disconnect Terminals.vi, 7-37 CAN Sync Start Multiple with
CAN for CompactRIO, 3-32 NI-DAQ.vi, 7-97
CAN Get Names.vi, 7-39 CAN Sync Start Multiple with
CAN Get Property.vi, 7-42 NI-DAQmx.vi, 7-100
CAN hardware CAN Sync Start with NI-DAQ.vi, 7-92
SJA1000 CAN controller, 3-1 CAN Sync Start with NI-DAQmx.vi, 7-94
CAN identifiers and message priority, B-2 CAN Write.vi, 7-103
CAN Init Start.vi, 7-59 CE compliance, E-13
CAN Initialize.vi, 7-55 Channel API
CAN interface cables additional programming topics, 6-11
cable lengths, 4-4 Get Names, 6-11
cable termination, low-speed CAN, 4-10 Set Property, 6-12
cabling example Synchronization, 6-11
High-Speed CAN (figure), 4-6 basic programming model, 6-4
Low-Speed/Fault-Tolerant CAN Clear, 6-10
(figure), 4-17 Init Start, 6-5
PCI-CAN cable (figure), 4-19 Read, 6-6
PCMCIA-CAN cable (figure), 4-3 Read Timestamped, 6-8
PCMCIA-CAN/LS cable Read Timestamped (figure), 6-8
figure, 4-8 Write, 6-8
termination resistors, 4-16 choose source of Channel
pinout for 9-pin D-SUB connector, configuration, 6-1
High-Speed (figure), 4-1, 4-7, decision process (figure), 6-1
4-18, 4-22 overview, 1-10
termination resistor placement using, 6-1
figure, 4-5 checksum
low-speed CAN, 4-10 CRC, 10-44, 10-97, 11-49, 11-85
common questions, A-3
configuration of LabVIEW RT E
CompactRIO system, 2-7
electromagnetic compatibility, E-12
overview, 2-6
error detection and confinement
PXI system, 2-6
CAN, B-5
configure CAN and LIN ports, 2-4
LIN, C-6
connector pinout
example of CAN data frame fields
PCI and PXI (figure), 1-10
Single Wire CAN, 4-17 examples (NI resources), F-1
XS CAN, 4-21
PCI, PXI, and USB
High-Speed CAN, 4-1 F
Low-Speed/Fault-Tolerant CAN, 4-6 Frame API
PCMCIA additional programming topics, 9-25
High-Speed CAN, 4-2 basic programming model for
Low-Speed/Fault-Tolerant CAN, 4-8 CAN, 9-4, 9-7
PCMCIA-CAN choose which objects to use, 9-1
High-Speed CAN, 4-19 overview, 1-10
USB-LIN using, 9-1
LIN, 4-24 using CAN network interface objects, 9-1
connectors and cables using CAN objects, 9-3
LIN, 4-24 frame format, LIN, C-1
Low-Speed/Fault-Tolerant CAN, 4-6 frame to channel conversion, 6-12
Single Wire CAN, 4-17 frame types for CAN and LIN hardware, D-1
XS CAN, 4-21 frames, CAN, B-3
conventions, xvii
cyclic redundancy check (CRC), B-4
H
help, technical support, F-1
D High-Speed CAN
data length code (DLC), B-4 cabling requirements, 4-4
data types for Channel API for C, 8-1 PCI, PXI, and USB connector pinout, 4-1
Declaration of Conformity (NI resources), F-1 PCMCIA connector pinout, 4-2
diagnostic tools (NI resources), F-1 PCMCIA-CAN connector pinout, 4-19
differences between CAN and LIN, 9-30 history and use of
documentation CAN, B-1
conventions, xvii LIN, C-1
NI resources, F-1
related documentation, xvii
drivers (NI resources), F-1
replacing software
low-speed CAN, 4-15 application development, 5-1
PCI-CAN/LS board, 4-13 choose the programming language, 5-1
PCMCIA-CAN/LS cable, 4-16 choose which API to use, 5-6
software selectable, 4-13 choose your programming language
RT configuration Borland C++, 5-3
CompactRIO system, 2-7 LabVIEW, 5-1
overview, 2-6 LabWindows/CVI, 5-2
PXI system, 2-6 Microsoft Visual Basic, 5-4
other programming languages, 5-4
Visual C++ 6, 5-2
S NI resources, F-1
safety specifications
information, 2-1 CE compliance, E-13
specifications, E-12 electromagnetic compatibility, E-12
section headings for Channel API for C, 8-1 PCI-CAN, E-1
Series 2 and Series 1 PCI-CAN Series 2
differences, 1-4 High-Speed CAN, E-2
hardware series displayed in MAX Low-Speed/Fault-Tolerant CAN, E-2
(figure), 1-6 operating environment, E-1
PCI and PXI, 1-6 optical isolation, E-2
PCI-CAN labels (figure), 1-4 physical, E-1
PCMCIA cables, 1-7 power requirement, E-1
PCMCIA hardware, 1-7 RTSI, E-2
PCMCIA-CAN cables (figure), 1-5 Single Wire CAN, E-3
PCMCIA-CAN labels (figure), 1-5 storage environment, E-2
PXI-CAN labels (figure), 1-4 XS Software Selectable, E-3
Series 2 hardware overview, 1-2 PCMCIA-CAN Series 2
simplified CAN data frame, 1-1 High-Speed transceiver cable, E-8
Single Wire CAN Low-Speed/Fault-Tolerant
cable length, 4-20 transceiver cable, E-9
cabling example (figure), 4-21 operating environment, E-7
cabling requirements, 4-20 optical isolation, E-8
connectors and cables, 4-17 physical, E-7
number of devices, 4-20 power requirement, E-7
PCI and PXI connector pinout, 4-17 single-wire cable, E-9
termination, 4-20 storage environment, E-8
SJA1000 CAN controller overview, 3-1 synchronization triggers, E-8
slave task, C-1
sleep and wakeup, LIN, C-6
PXI-846x Series 2 T
functional shock, E-5
technical support, F-1
High-Speed CAN, E-5
termination resistance, determining, 4-10
Low-Speed/Fault-Tolerant CAN, E-6
termination resistor
operating environment, E-4
location of, low-speed CAN (figure), 4-15
physical, E-4
location on PCI-CAN/LS2 board
power requirement, E-4 (figure), 4-14
PXI trigger bus, E-5 placement figure, 4-5
random vibration, E-5 placement for low-speed CAN
Single Wire CAN, E-6 (figure), 4-10
storage environment, E-4 preparing lead wires
XS Software Selectable, E-6 PCMCIA-CAN/LS cable
safety, E-12 replacement (figure), 4-16
USB-CAN, E-10 preparing lead wires of replacement
High-Speed CAN, E-11 PCI-CAN/LS (figure), 4-14
LIN, E-12 preparing lead wires of, low-speed CAN
Low-Speed/Fault-Tolerant (figure), 4-16
CAN, E-11 replacing
operating environment, E-10 PCI-CAN/LS board, 4-13
optical isolation, E-10 PCMCIA-CAN/LS cable, 4-16
physical, E-10 software selectable, 4-13
power requirement, E-10 termination, Single Wire CAN, 4-20
storage environment, E-10 tools for installation and configuration, 2-7
synchronization triggers, E-11 topology and behavior, LIN, C-5
USB-LIN, E-10 training and certification (NI resources), F-1
High-Speed CAN, E-11 troubleshooting
LIN, E-12 NI resources, F-1
Low-Speed/Fault-Tolerant test failures, A-2
CAN, E-11 with MAX, A-1
operating environment, E-10
optical isolation, E-10
physical, E-10 U
power requirement, E-10 USB-847x
storage environment, E-10 CAN hardware, 1-8
synchronization triggers, E-11 LIN hardware, 1-9
Waste Electrical and Electronic overview, 1-8
Equipment (WEEE), E-13 USB-CAN
summary of the CAN standard, B-1 high-speed physical layer, 3-25
summary of the LIN standard, C-1 bus power requirements, 3-26
support, technical, F-1 LED indicators, 3-26, 3-28, 3-29
transceiver, 3-26