串行总线

除了:doc:digital <digital-inputs-hardware> 和 :doc:`analog <analog-inputs-hardware>`作为输入,roboRIO还提供了几种与外围设备进行串行通信的方法。

Both the digital and analog inputs are highly limited in the amount of data that can be sent over them. Serial buses allow users to make use of far more-robust and higher-bandwidth communications protocols with sensors that collect large amounts of data, such as inertial measurement units (IMUs) or 2D LIDAR sensors.

支持的串行总线类型

roboRIO支持许多基本类型的串行通信:

Additionally, the roboRIO supports communications with peripheral devices over the CAN bus. However, as the FRC® CAN protocol is quite idiosyncratic, relatively few peripheral sensors support it (though it is heavily used for motor controllers).

I2C

The I2C port on the roboRIO.I2C roboRIO port pin specifications.

To communicate to peripheral devices over I2C, each pin should be wired to its corresponding pin on the device. I2C allows users to wire a “chain” of slave devices to a single port, so long as those devices have separate IDs set.

The I2C bus can also be used through the MXP expansion port. The I2C bus on the MXP is independent. For example, a device on the main bus can have the same ID as a device on the MXP bus.

警告

Be sure to familiarize yourself on the following known issue before using the onboard I2C port: Onboard I2C Causing System Lockups

SPI

Show the SPI port on the roboRIO.SPI roboRIO port pin specifications.

To communicate to peripheral devices over SPI, each pin should be wired to its corresponding pin on the device. The SPI port supports communications to up to four devices (corresponding to the Chip Select (CS) 0-3 pins on the diagram above).

SPI总线也可以通过 `MXP expansion port`_使用。 MXP端口提供独立的时钟,输入/输出线和一个附加的CS。

RS-232

Location of the RS-232 port on the roboRIO.roboRIO RS-232 port pin specifications.

要通过RS-232与外围设备通信,应将每个引脚连接到设备上相应的引脚。

RS-232总线也可以通过`MXP expansion port`_使用。

The roboRIO RS-232 serial port uses RS-232 signaling levels (+/- 15v). The MXP serial port uses CMOS signaling levels (+/- 3.3v).

备注

By default, the onboard RS-232 port is utilized by the roboRIO’s serial console. In order to use it for an external device, the serial console must be disabled using the Imaging Tool or roboRIO 网络仪表板.

USB Client

roboRIO上的USB端口之一是USB-B或USB客户端端口。可以使用标准USB电缆将其连接到设备,例如Driver Station计算机。

USB主机

Location of the two USB ports on the roboRIO at top center.

roboRIO上的两个USB端口是USB-A或USB主机端口。可以使用例如相机或传感器的标准USB线将它们连接到设备。

MXP扩展端口

Location of the MXP port on the roboRIO directly above the NI logo.MXP pinout.

Several of the serial buses are also available for use through the roboRIO’s MXP Expansion Port. This port allows users to make use of many additional digital and analog inputs, as well as the various serial buses.

为了方便起见,许多外围设备都直接连接到MXP端口,不需要用户进行任何接线。

CAN总线

Show the location of the CAN bus terminals in the top left corner of the roboRIO.

此外,roboRIO支持通过CAN总线与外围设备进行通信。但是,由于FRC CAN协议非常特殊,因此很少有外围传感器支持该协议(尽管它广泛用于电机控制器)。使用CAN总线协议的优点之一是可以采用菊花链方式连接设备,如下所示。如果断开链中任何设备的电源,数据信号仍将能够到达链中的所有设备。

A CAN bus topology between motor controllers.

几个CAN主要使用的传感器。一些示例包括:

有关使用与CAN总线连接的设备的更多信息,请参见以下文章:ref:using can devices <docs/software/can-devices/using-can-devices:Using CAN Devices>