mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 09:33:34 +08:00
docs: auto-sync metadata [skip ci]
Co-Authored-By: PX4 BuildBot <bot@px4.io>
This commit is contained in:
@@ -4,9 +4,10 @@ I2C is a packet-switched serial communication protocol that allows multiple mast
|
||||
It is intended for attaching lower-speed peripheral ICs to processors and microcontrollers in short-distance, intra-board communication.
|
||||
|
||||
Pixhawk/PX4 support it for:
|
||||
* Connecting off board components that require higher data rates than provided by a strict serial UART, such as rangefinders.
|
||||
* Compatibility with peripheral devices that only support I2C.
|
||||
* Allowing multiple devices to attach to a single bus (useful for conserving ports).
|
||||
|
||||
- Connecting off board components that require higher data rates than provided by a strict serial UART, such as rangefinders.
|
||||
- Compatibility with peripheral devices that only support I2C.
|
||||
- Allowing multiple devices to attach to a single bus (useful for conserving ports).
|
||||
For example, LEDs, Compass, rangefinders etc.
|
||||
|
||||
::: info
|
||||
@@ -22,15 +23,17 @@ The bus is not fast enough even with a single device attached to allow vibration
|
||||
|
||||
Drivers should `#include <drivers/device/i2c.h>` and then provide an implementation of the abstract base class `I2C` defined in **I2C.hpp** for the target hardware (i.e. for NuttX [here](https://github.com/PX4/PX4-Autopilot/blob/main/src/lib/drivers/device/nuttx/I2C.hpp)).
|
||||
|
||||
A small number of drivers will also need to include headers for their type of device (**drv_*.h**) in [/src/drivers/](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers) - e.g. [drv_led.h](https://github.com/PX4/PX4-Autopilot/blob/main/src/drivers/drv_led.h).
|
||||
A small number of drivers will also need to include headers for their type of device (**drv\_\*.h**) in [/src/drivers/](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers) - e.g. [drv_led.h](https://github.com/PX4/PX4-Autopilot/blob/main/src/drivers/drv_led.h).
|
||||
|
||||
To include a driver in firmware you must add the driver to the board-specific cmake file that corresponds to the target you want to build for.
|
||||
You can do this for a single driver:
|
||||
|
||||
```
|
||||
CONFIG_DRIVERS_DISTANCE_SENSOR_LIGHTWARE_LASER_I2C=y
|
||||
```
|
||||
|
||||
You can also include all drivers of a particular type.
|
||||
|
||||
```
|
||||
CONFIG_COMMON_DISTANCE_SENSOR=y
|
||||
```
|
||||
@@ -44,12 +47,13 @@ For example, you can see/search for `CONFIG_DRIVERS_DISTANCE_SENSOR_LIGHTWARE_LA
|
||||
To find I2C driver examples, search for **i2c.h** in [/src/drivers/](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers).
|
||||
|
||||
Just a few examples are:
|
||||
* [drivers/distance_sensor/lightware_laser_i2c](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/distance_sensor/lightware_laser_i2c) - I2C driver for [Lightware SF1XX LIDAR](../sensor/sfxx_lidar.md).
|
||||
* [drivers/distance_sensor/lightware_laser_serial](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/distance_sensor/lightware_laser_serial) - Serial driver for [Lightware SF1XX LIDAR](../sensor/sfxx_lidar.md).
|
||||
* [drivers/ms5611](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/barometer/ms5611) - I2C Driver for the MS5611 and MS6507 barometric pressure sensor connected via I2C (or SPI).
|
||||
|
||||
- [drivers/distance_sensor/lightware_laser_i2c](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/distance_sensor/lightware_laser_i2c) - I2C driver for [Lightware SF1XX LIDAR](../sensor/sfxx_lidar.md).
|
||||
- [drivers/distance_sensor/lightware_laser_serial](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/distance_sensor/lightware_laser_serial) - Serial driver for [Lightware SF1XX LIDAR](../sensor/sfxx_lidar.md).
|
||||
- [drivers/ms5611](https://github.com/PX4/PX4-Autopilot/tree/main/src/drivers/barometer/ms5611) - I2C Driver for the MS5611 and MS6507 barometric pressure sensor connected via I2C (or SPI).
|
||||
|
||||
## Further Information
|
||||
|
||||
* [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) (Wikipedia)
|
||||
* [I2C Comparative Overview](https://learn.sparkfun.com/tutorials/i2c) (learn.sparkfun.com)
|
||||
* [Driver Framework](../middleware/drivers.md)
|
||||
- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) (Wikipedia)
|
||||
- [I2C Comparative Overview](https://learn.sparkfun.com/tutorials/i2c) (learn.sparkfun.com)
|
||||
- [Driver Framework](../middleware/drivers.md)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
It is recommended for:
|
||||
|
||||
* Connecting offboard components that require low bandwidth and low latency communication, e.g. [rangefinders](../sensor/rangefinders.md), [magnetometers](../gps_compass/magnetometer.md), [airspeed sensors](../sensor/airspeed.md) and [tachometers](../sensor/tachometers.md).
|
||||
* Compatibility with peripheral devices that only support I2C.
|
||||
* Allowing multiple devices to attach to a single bus, which is useful for conserving ports.
|
||||
- Connecting offboard components that require low bandwidth and low latency communication, e.g. [rangefinders](../sensor/rangefinders.md), [magnetometers](../gps_compass/magnetometer.md), [airspeed sensors](../sensor/airspeed.md) and [tachometers](../sensor/tachometers.md).
|
||||
- Compatibility with peripheral devices that only support I2C.
|
||||
- Allowing multiple devices to attach to a single bus, which is useful for conserving ports.
|
||||
|
||||
I2C allows multiple master devices to connect to multiple slave devices using only 2 wires per connection (SDA, SCL).
|
||||
in theory, a bus can support 128 devices, each accessed via its unique address.
|
||||
@@ -15,7 +15,6 @@ in theory, a bus can support 128 devices, each accessed via its unique address.
|
||||
UAVCAN would normally be preferred where higher data rates are required, and on larger vehicles where sensors are mounted further from the flight controller.
|
||||
:::
|
||||
|
||||
|
||||
## Wiring
|
||||
|
||||
I2C uses a pair of wires: SDA (serial data) and SCL (serial clock).
|
||||
@@ -29,7 +28,6 @@ To ensure reliable communication and to reduce crosstalk it is advised to apply
|
||||
|
||||

|
||||
|
||||
|
||||
## Checking the Bus and Device Status
|
||||
|
||||
A useful tool for bus analysis is [i2cdetect](../modules/modules_command.md#i2cdetect).
|
||||
@@ -41,8 +39,8 @@ The tool can be run in the PX4 terminal with the following command:
|
||||
```
|
||||
i2cdetect -b 1
|
||||
```
|
||||
where the bus number is specified after `-b` parameter
|
||||
|
||||
where the bus number is specified after `-b` parameter
|
||||
|
||||
## Common problems
|
||||
|
||||
@@ -62,8 +60,9 @@ The bandwidth available for each device generally decreases as more devices are
|
||||
If too many devices are added, it can cause transmission errors and network unreliability.
|
||||
|
||||
There are several ways to reduce the problem:
|
||||
* Dividing the devices into groups, each with approximately the same number of devices, and connecting each group to one autopilot port
|
||||
* Increase bus speed limit (usually set to 100kHz for external I2C bus)
|
||||
|
||||
- Dividing the devices into groups, each with approximately the same number of devices, and connecting each group to one autopilot port
|
||||
- Increase bus speed limit (usually set to 100kHz for external I2C bus)
|
||||
|
||||
### Excessive Wiring Capacitance
|
||||
|
||||
@@ -71,9 +70,10 @@ The electrical capacity of bus wiring increases as more devices/wires are added.
|
||||
The problem can be analyzed using an oscilloscope, where we see that the edges of SDA/SCL signals are no longer sharp.
|
||||
|
||||
There are several ways to reduce the problem:
|
||||
* Dividing the devices into groups, each with approximately the same number of devices, and connecting each group to one autopilot port
|
||||
* Using the shorter and higher quality I2C cables, see the [cable wiring page](../assembly/cable_wiring.md#i2c-cables) for details
|
||||
* Separating the devices with a weak open-drain driver to smaller buses with lower capacitance by using [I2C Bus Accelerators](#i2c-bus-accelerators)
|
||||
|
||||
- Dividing the devices into groups, each with approximately the same number of devices, and connecting each group to one autopilot port
|
||||
- Using the shorter and higher quality I2C cables, see the [cable wiring page](../assembly/cable_wiring.md#i2c-cables) for details
|
||||
- Separating the devices with a weak open-drain driver to smaller buses with lower capacitance by using [I2C Bus Accelerators](#i2c-bus-accelerators)
|
||||
|
||||
## I2C Bus Accelerators
|
||||
|
||||
@@ -81,6 +81,7 @@ I2C bus accelerators are separate circuits that can be used to support longer wi
|
||||
They work by physically dividing an I2C network into 2 parts and using their own transistors to amplify I2C signals.
|
||||
|
||||
Available accelerators include:
|
||||
|
||||
- [Thunderfly TFI2CEXT01](https://docs.thunderfly.cz/avionics/TFI2CEXT01/):
|
||||

|
||||
- This has Dronecode connectors and is hence very easy to add to a Pixhawk I2C setup.
|
||||
@@ -89,7 +90,7 @@ Available accelerators include:
|
||||
### I2C Level Converter function
|
||||
|
||||
Some I2C devices have 5V on the data lines, while the Pixhawk connector standard port expects these lines to be 3.3 V.
|
||||
You can use the TFI2CEXT01 as a level converter to connect 5V devices to a Pixhawk I2C port. This feature is possible because the SCL and SDA lines of TFI2CEXT01 are 5V tolerant.
|
||||
You can use the TFI2CEXT01 as a level converter to connect 5V devices to a Pixhawk I2C port. This feature is possible because the SCL and SDA lines of TFI2CEXT01 are 5V tolerant.
|
||||
|
||||
## I2C Address Translators
|
||||
|
||||
@@ -112,6 +113,6 @@ Software development for I2C devices is described in [I2C Bus (Development Overv
|
||||
|
||||
## Further Information
|
||||
|
||||
* [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) (Wikipedia)
|
||||
* [I2C Comparative Overview](https://learn.sparkfun.com/tutorials/i2c) (learn.sparkfun.com)
|
||||
* [Driver Framework](../middleware/drivers.md)
|
||||
- [I2C](https://en.wikipedia.org/wiki/I%C2%B2C) (Wikipedia)
|
||||
- [I2C Comparative Overview](https://learn.sparkfun.com/tutorials/i2c) (learn.sparkfun.com)
|
||||
- [Driver Framework](../middleware/drivers.md)
|
||||
|
||||
@@ -28,7 +28,7 @@ If you need your own value for address translation, changing the configuration r
|
||||
## Example of Use
|
||||
|
||||
The tachometer sensor [TFRPM01](../sensor/thunderfly_tachometer.md) can be set to two different addresses using a solder jumper.
|
||||
If the autopilot has three buses, only 6 sensors can be connected and no bus remains free (2 available addresses * 3 I2C ports).
|
||||
If the autopilot has three buses, only 6 sensors can be connected and no bus remains free (2 available addresses \* 3 I2C ports).
|
||||
In some multicopters or VTOL solutions, there is a need to measure the RPM of 8 or more elements.
|
||||
The [TFI2CADT01](https://www.tindie.com/products/26353/) is highly recommended in this case.
|
||||
|
||||
@@ -39,7 +39,6 @@ By adding another TFI2CADT01, 4 more devices can be connected to the same bus.
|
||||
|
||||
[](https://mermaid-js.github.io/mermaid-live-editor/edit#pako:eNptkd9rwjAQx_-VcE8dtJB2ukEfBLEWfJCJy8CHvgRznQH7gzSBDfF_33VZB2oCyf3I576XcBc4dgohh08j-xMTRdUyWuX2I6LNErY7zJh0tuv1ubNP_7csSRZsudlHS22GHlGxAduhM3fEfrdNI1GS4emK8a85fwSyGyC9A0S5yVbrg_DZKfLtCxH9JsjhaU7VvI7pfK3_NCg_NXmO3pwl5uYt9D0yAXoWoFNP4yM9H-kspJ0FtF8CdObpURtiaNA0UisaymWsrsCesMEKcnIV1tKdbQVVeyXU9UpaXCttOwO5NQ5jGKf1_t0ep9gzhZY04sYnrz9BI4mU)
|
||||
|
||||
|
||||
<!-- original mermaid graph
|
||||
graph TD
|
||||
FMU(FMU - PX4 autopilot)
|
||||
@@ -54,7 +53,6 @@ graph TD
|
||||
ADT -- > RPM6(Out2: TFRPM01C 0x52 - 0x2e)
|
||||
-->
|
||||
|
||||
|
||||
::: info
|
||||
TFI2CADT01 does not contain any I2C buffer or accelerator.
|
||||
As it adds additional capacitance on the bus, we advise combining it with some bus booster, e.g. [TFI2CEXT01](https://docs.thunderfly.cz/avionics/TFI2CEXT01/).
|
||||
@@ -62,4 +60,4 @@ As it adds additional capacitance on the bus, we advise combining it with some b
|
||||
|
||||
### Other Resources
|
||||
|
||||
* Datasheet of [LTC4317](https://www.analog.com/media/en/technical-documentation/data-sheets/4317fa.pdf)
|
||||
- Datasheet of [LTC4317](https://www.analog.com/media/en/technical-documentation/data-sheets/4317fa.pdf)
|
||||
|
||||
Reference in New Issue
Block a user