Main Content

configBusSpeed

Set bit timing rate of CAN channel

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.

  • This function does not support SocketCAN devices.

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.

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 a MathWorks virtual channel.

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

Configure CAN FD on an NI device.

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

Configure the bus speed, specifying the bit timing parameters.

Configure CAN timing on a Kvaser device.

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

Configure CAN FD on a 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 a 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 a 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: 500000

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: 500000

Data Types: double

Arbitration synchronization jump width, specified as a double. Define the length of a bit on the network. Default value is 2 for Vector, 1 for PEAK-System.

Data Types: double

Arbitration time segment 1, specified as a double, which defines the section before a bit is sampled on the network. Default value is 6 for Vector, 5 for PEAK-System.

Data Types: double

Arbitration time segment 2, specified as a double, which defines the section after a bit is sampled on a network. Default value is 3 for Vector, 2 for PEAK-System.

Data Types: double

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

Example: 2000000

Data Types: double

Data synchronization jump width, specified as a double. Define the length of a bit on the network. Default value is 2 for Vector, 1 for PEAK-System.

Data Types: double

Data time segment 1, specified as a double, which defines the section before a bit is sampled on the network. Default value is 6 for Vector, 3 for PEAK-System.

Data Types: double

Data time segment 2, specified as a double, which defines the section after a bit is sampled on a network. Default value is 3 for Vector, 1 for PEAK-System.

Data Types: double

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

Example: 20

Data Types: double

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

Example: 5

Data Types: double

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

Example: 2

Data Types: double

Version History

Introduced in R2009a

See Also

Functions

Properties

External Websites