Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

configBusSpeed

Set bit timing rate of CAN channel

Syntax

configBusSpeed(canch,busspeed)
configBusSpeed(canch,busspeed,SJW,TSeg1,TSeg2,numsamples)
configBusSpeed(canch,arbbusspeed,databusspeed)
configBusSpeed(canch,arbbusspeed,arbSJW,arbTSeg1,arbTSeg2,databusspeed,dataSJW,dataTSeg1,dataTSeg2)
configBusSpeed(canch,clockfreq,arbBRP,arbSJW,arbTSeg1,arbTSeg2,dataBRP,dataSJW,dataTSeg1,dataTSeg2)

Description

example

configBusSpeed(canch,busspeed) sets the speed of the CAN channel in a direct form that uses baseline bit timing calculation factors.

  • Unless you have specific timing requirements for your CAN connection, use the direct form of configBusSpeed. Also note that you can set the bus speed only when the CAN channel is offline. The channel must also have initialization access to the CAN device.

  • Synchronize all nodes on the network for CAN to work successfully. However, over time, clocks on different nodes will get out of sync, and must resynchronize. SJW specifies the maximum width (in time) that you can add to TSeg1 (in a slower transmitter), or subtract from TSeg2 (in a faster transmitter) to regain synchronization during the receipt of a CAN message.

example

configBusSpeed(canch,busspeed,SJW,TSeg1,TSeg2,numsamples) sets the speed of the CAN channel canch to busspeed using the specified bit timing calculation factors to control the timing in an advanced form.

Note

Before you can start a channel to transmit or receive CAN FD messages, you must configure its bus speed.

example

configBusSpeed(canch,arbbusspeed,databusspeed) sets the arbitration and data bus speeds of canch using default bit timing calculation factors for CAN FD. This syntax supports NI and MathWorks virtual devices.

example

configBusSpeed(canch,arbbusspeed,arbSJW,arbTSeg1,arbTSeg2,databusspeed,dataSJW,dataTSeg1,dataTSeg2) sets the data and arbitration bus speeds of canch using the specified bit timing calculation factors in an advanced form for CAN FD. This syntax supports Kvaser and Vector devices.

example

configBusSpeed(canch,clockfreq,arbBRP,arbSJW,arbTSeg1,arbTSeg2,dataBRP,dataSJW,dataTSeg1,dataTSeg2) sets the data and arbitration bus speeds of canch using the specified bit timing calculation factors in an advanced form for CAN FD. This syntax supports PEAK-System devices.

Examples

collapse all

Configure the bus speed using baseline bit timing calculation.

Configure for CAN.

canch = canChannel('Vector','CANCaseXL 1',1);
configBusSpeed(canch,250000)

Configure CAN FD on MathWorks virtual channel.

canch = canChannel('MathWorks','Virtual 1',1,'ProtocolMode','CAN FD');
configBusSpeed(canch,1000000,2000000)

Configure CAN FD on National Instruments® device.

canch = canChannel('NI','CAN1','ProtocolMode','CAN FD');
configBusSpeed(canch,1000000,2000000)

Configure the bus speed, specifying the bit timing parameters.

Configure CAN on Kvaser device.

canch = canChannel('Kvaser','USBcan Professional 1',1);
configBusSpeed(canch,500000,1,4,3,1)

Configure CAN FD on Kvaser device.

canch = canChannel('Kvaser','USBcan Pro 1',1,'ProtocolMode','CAN FD');
 configBusSpeed(canch,1e6,2,6,3,2e6,2,6,3)

Configure CAN FD on Vector device.

canch = canChannel('Vector','VN1610 1',1,'ProtocolMode','CAN FD');
configBusSpeed(canch,1e6,2,6,3,2e6,2,6,3)

Configure CAN FD on PEAK-System device.

canch = canChannel('PEAK-System','PCAN_USBBUS1','ProtocolMode','CAN FD');
configBusSpeed(canch,20,5,1,2,1,2,1,3,1)

Input Arguments

collapse all

CAN channel, specified as a CAN channel object.

Bit rate for channel, specified as a double. Provide the speed of the network in bits per second.

Example: 250000

Data Types: double

Synchronization jump width, specified as a double. Define the length of a bit on the network.

Data Types: double

Time segment 1, specified as a double, which defines the section before a bit is sampled on the network.

Data Types: double

Time segment 2, specified as a double, which defines the section after a bit is sampled on a network.

Data Types: double

Number of samples for bit state, specified as a double. Specify the number of samples used for determining the bit state of a network.

Data Types: double

Arbitration bit rate for channel, specified as a double. Provide the speed of the network in bits per second.

Example: 250000

Data Types: double

Arbitration synchronization jump width, specified as a double. Define the length of a bit on the network.

Data Types: double

Arbitration time segment 1, specified as a double, which defines the section before a bit is sampled on the network.

Data Types: double

Arbitration time segment 2, specified as a double, which defines the section after a bit is sampled on a network.

Data Types: double

Data bit rate for channel, specified as a double. Provide the speed of the network in bits per second.

Example: 250000

Data Types: double

Data synchronization jump width, specified as a double. Define the length of a bit on the network.

Data Types: double

Data time segment 1, specified as a double, which defines the section before a bit is sampled on the network.

Data Types: double

Data time segment 2, specified as a double, which defines the section after a bit is sampled on a network.

Data Types: double

Clock frequency for channel in MHz, specified as a double.

Example: 250000

Data Types: double

Arbitration clock prescalar for time quantum, specified as a double.

Example: 250000

Data Types: double

Data clock prescalar for time quantum, specified as a double.

Example: 250000

Data Types: double

See Also

Functions

Introduced in R2009a

Was this topic helpful?