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 ofconfigBusSpeed. 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.SJWspecifies the maximum width (in time) that you can add toTSeg1(in a slower transmitter), or subtract fromTSeg2(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 channelcanchtobusspeedusing 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 ofcanchusing 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 ofcanchusing 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 ofcanchusing 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 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: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:5

Data Types:double

数据时钟时间prescalar量子,指定了s a double.

Example:2

Data Types:double

See Also

Functions

Properties

External Websites

Introduced in R2009a