Construct CAN FD channel connected to specified device



canch = canFDChannel(vendor,device,devicechannelindex) returns a CAN FD channel connected to a device from a specified vendor.

For Vector and Kvaser products, device combines the device type and a device index, such as 'CANCaseXL 1'. For example, if there are two Vector devices, device can be 'VN1610 1' or 'VN1610 2'.

canch = canFDChannel(vendor,device) returns a CAN FD channel connected to a National Instruments® or PEAK-System device.

For National Instruments, vendor is the character vector 'NI', and the devicenumber is the interface number defined in the NI Measurement & Automation Explorer.

For PEAK-System devices vendor is the character vector 'PEAK-System', and devicenumber is the device number defined for the channel.


collapse all

Create CAN FD channels for each of several vendors.

ch1 = canFDChannel('Vector','VN1610 1',1);
ch2 = canFDChannel('Kvaser','USBcan Pro 1',1);
ch3 = canFDChannel('NI','CAN0');
ch4 = canFDChannel('PEAK-System','PCAN_USBBUS1');
ch5 = canFDChannel('MathWorks','Virtual 1',1)
ch5 = 

  Channel with properties:

   Device Information
            DeviceVendor: 'MathWorks'
                  Device: 'Virtual 1'
      DeviceChannelIndex: 1
      DeviceSerialNumber: 0
            ProtocolMode: 'CAN FD'

   Status Information
                 Running: 0
       MessagesAvailable: 0
        MessagesReceived: 0
     MessagesTransmitted: 0
    InitializationAccess: 1
        InitialTimestamp: [0×0 datetime]
           FilterHistory: 'Standard ID Filter: Allow All | Extended ID Filter: Allow All'

   Bit Timing Information
               BusStatus: 'N/A'
              SilentMode: 0
         TransceiverName: 'N/A'
        TransceiverState: 'N/A'
       ReceiveErrorCount: 0
      TransmitErrorCount: 0
     ArbitrationBusSpeed: []
            DataBusSpeed: []

   Other Information
                Database: []
                UserData: []

Input Arguments

collapse all

CAN device vendor, specified as 'MathWorks', 'Kvaser', 'NI', 'PEAK-System', or 'Vector'.

Example: 'MathWorks'

Data Types: char | string

CAN FD device to connect channel to, specified as a character vector or string. Valid values depend on the specified vendor.

Example: 'Virtual 1'

Data Types: char | string

CAN FD device channel port or index, specified as a numeric value.

Example: 1

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

CAN FD device channel returned as a CAN channel object, with the following properties.

CAN Channel Properties:

BusLoadLoad on CAN bus
DatabaseStore CAN database information
MessageReceivedFcnSpecify function to run
MessageReceivedFcnCountSpecify number of messages available before function is triggered
RunningDetermine status of channel
SilentModeSpecify if channel is active or silent
TransceiverNameName of device transceiver
TransceiverStateDisplay state or mode of transceiver
UserDataEnter custom data

CAN Device Properties:

DeviceDisplay channel device type
Device(NI)Display NI CAN channel device type
DeviceChannelIndexDisplay device channel index
DeviceSerialNumberDisplay device serial number
DeviceVendorDisplay device vendor name
InitializationAccessDetermine control of device channel

Bit Timing Properties:

BusSpeedBit rate of bus
NumOfSamplesDisplay number of samples available to channel
SJWSynchronization jump width (SJW) of bit time segment
TSEG1Display amount that channel can lengthen sample time
TSEG2Display amount that channel can shorten sample time


  • Use canFDChannelList to obtain a list of available device channels.

  • You cannot have more than one CAN FD channel configured on the same NI-XNET or PEAK-System device channel.

  • You cannot use the same variable to create multiple channels sequentially. Clear any channel in use before using the same variable to construct a new channel object.

  • You cannot create arrays of channel objects. Each object you create must exist as its own individual variable.

See Also


Introduced in R2018b