I2C Error Compendium: Difference between revisions

From STorM32-BGC Wiki V1
Jump to navigation Jump to search
No edit summary
No edit summary
 
(25 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<span style="font-size:88%">''by OlliW</span>''
<span style="font-size:88%">''by OlliW, with edits by Bruce356</span>''


I2C errors are probably the most annoying side effect of the technology we are using in our brushless gimbals.
I2C errors are probably the most annoying side effect of the technology we are using in our brushless gimbals.


I2C errors occur then the signals on the I2C clock and data lines (SCL,SDA) are disturbed beyond certain limits, and this happens due to two main reason:
I2C errors occur when the signals on the I2C clock and data lines (SCL,SDA) are disturbed beyond certain limits, and this happens for two main reasons:
* capacitive load on the I2C clock and/or data lines
* capacitive load on the I2C clock and/or data lines
* induced signal disturbances due to capacitive coupling to outside fields
* induced signal disturbances due to capacitive coupling to outside fields


Importantly, all error sources add up. One hence can't give decisive threshold values, such as, for instance, that the length of the I2C wires should not be longer than 40 cm. Without any further error sources one might be able to use even much longer wires, while if motor wires are nearby only shorter wires might be acceptable.  
Importantly, all error sources add up. One therefore can't give decisive threshold values, for example, the length of the I2C wires should not be more than 40 cm long. Without any further error sources one might be able to use much longer wires, but if motor wires are too close to the IMU cabling then shorter wires might be required.  


It's like a glass of wine: When it's full, it's full. It doesn't matter if it had been filled with Bordeaux, Chianti, or any mixture. When the glass is filled with only a tiny bit of Bordeaux, one can add a lot of Chianti before it overflows, but when the glass is nearly filled with Bordeaux, only a tiny drop of Chianti is acceptable. So, you're not going to get an answer here to how much Chianti is acceptable, since this depends on how much Bordeaux is there, but "only" that the more Chianti you poor in the more probable it is that the glass spills over.
It's like a glass of wine: When it's full, it's full. It doesn't matter whether it was filled with Bordeaux, Chianti, or any other mixture. When the glass contains only a tiny bit of Bordeaux, one can add a lot of Chianti before it overflows, but when the glass is nearly full of Bordeaux, only a tiny amount of Chianti will fit before it reaches the overflow point. So, its not possible to tell how much Chianti is acceptable, since this depends on how much Bordeaux is already in the glass, the only thing that can be determined is that the more Chianti you poor in the glass the more likely it will overflow.


== Methods to Reduce I2C Error Rate ==
In the STorM32's GUI, you can find I2C errors displayed in the {{GUI|Dashboard}} tab, the status bar at the bottom of the main window, or in the Data Display window, which can be opened by clicking on the {{GUI|Data Display}} button near the bottom of the GUI.


Before we look at the I2C errors, the methods shall be briefly summarized which can help to reduce the error-proneness of the I2C connection to the IMU module:
== Ways to Reduce the I2C Error Rate ==


* reduce length of cable
Before looking at the I2C errors, here is a brief summary of methods, which help reduce problems with the I2C connection to an IMU module:


* twist wires of the cable; this comes in many variants such as twisting all four, just twisting SCL and SDL, twisting SCL with GND and SDA with VCC, and so on
* reduce length of I2C cables


* shield the wires; using e.g. a coax cable or wrapping the wires with (self adhesive) conductive cloth EMI shielding
* increase spacing between I2C cables and motor wires


* add ferrite rings; this comes in many variants such as to put it to the I2C wires and/or the motor wires, or to the left and/or right ends of the wires, and so on
* twist the I2C wires; this can be done in various ways, e.g. twisting all four wires together, just twisting SCL and SDL, twisting SCL with GND and SDA with VCC, etc.
 
* shield the I2C wires; using e.g. a coax cable or wrapping the wires with a self adhesive conductive cloth, "EMI shielding" (where the shield must be grounded to be effective)


* lower the (motor) voltage  
* lower the (motor) voltage  


* increase spacing between I2C cables and motor wires
* add ferrite rings; these can be fitted in various ways, such as, putting the rings on the I2C wires and/or the motor wires, they can be fitted at either ends of the wires.
 
* reduce the I2C pullup resistors on the IMU module
 
* add I2C hardening electronics


* reduce the I2C pullup resistors on e.g. the IMU module
* ditch I2C and use [http://www.olliw.eu/storm32bgc-wiki/Main_Page STorM32-NT], which would be the ultimative solution


== Capacitive Load ==
== Capacitive Load ==


Capacitive load decreases the slew rate of the signal, and eventually prevents the electronics to detect it correctly, and an I2C error occurs.
Capacitive load decreases the slew rate of the signal, and eventually prevents the electronics from detecting the signal correctly, and an I2C error occurs.


Capacitive load arises from the cables itself, and the longer the cables are the higher is the capacitive load.
Capacitive load arises from the cables themselves, and the longer the cables are the higher the capacitive load becomes.


Thus, for any I2C system there is an "intrinsic" maximal length up to which the I2C communication works. In practice this maximal length is not achieved, since, as discussed in the introduction, other I2C error source may be present, reducing the practical length. The capacitive load by the cables depends also on the type of cables. Thin wires for instance have a smaller capacity than thicker wires. In practice, however, there is usually little room to play with that factor.  
Therefore, for any I2C system there is an "intrinsic" maximum length up to which the I2C communication will work. In practice this maximum length is not achieved, since, as mentioned in the introduction, other I2C error sources may be present reducing the practical length. The capacitive load depends also on the used type of cable. Thin wires for instance have a smaller capacity than thicker wires. In practice, however, there is usually little room to play with this factor.  


Capacitive load also arises from anything conducting in the surrounding of the I2C clock and/or data wires.
Capacitive load also arises from anything conducting in the near surrounding area of the I2C clock and/or data wires.


That's indeed a major factor, and - fortunately - it is under our control to a high degree. The possible contributors falling into this category are very diverse; they range from things such as spacing between the wires among themselves or to GND or Vcc, shielding such as in coax wires, twisted or non-twisted wires and how they are twisted, conducting areas like metal bars or carbon plates to which the IMU module is mounted or the cables are fixed to, connectors, and so on. It is as it was said, it arises from '''''anything''''' conducting in the surrounding. Fortunately, the rules which determine the value of capacitors are well known. In a nutshell, the larger the conducting area the larger the capacitance, and the larger the distance to the conducting area the smaller the capacitance. This immediately gives us the rules at hand to control, and possibly avoid them.
This is indeed a major factor, and - fortunately - it is to a high degree under our control. The possible contributors falling into this category are very diverse; they range from things like spacing between the wires themselves or to GND or Vcc, shielding such as in coax wires, twisted or non-twisted wires and the manner in which they are twisted, conducting areas like metal bars or carbon plates to which the IMU module is mounted or the I2C cables are fixed to, and so on. It is as it was mentioned, it can arise from '''''anything''''' that is conducting in the surrounding area. Fortunately, the rules which determine the value for capacitance are well known. In a nutshell, the larger the conducting area the larger the capacitance, and the further the distance from the conducting area the smaller the capacitance. This immediately gives us the necessary rules to control, and possibly avoid the problem.


The acceptable capacitive load, from both the cables and the surrounding, depends on additional factors, such as the current capabilities of the I2C drivers and the pullup resistors.
The acceptable capacitive load, from both the cables and the conducting surrounding areas, depends on additional factors, such as the current capabilities of the I2C drivers and the pullup resistors.


== Induced Signal Disturbances ==
== Induced Signal Disturbances ==


Wires in the proximity to the I2C clock and data lines may, due to capacitive coupling, induce fault voltages in I2C lines and thus disturb the I2C signals. This again may prevent the electronics to detect the I2C signals correctly or even bring it into an unexpected state, and an I2C error occurs. The I2C errors due to induced disturbances are often fatal in the sense that it can be hard for the electronics to recover properly from them.
Wires in close proximity to the I2C clock and data lines may, due to capacitive coupling, induce fault voltages in the I2C lines and thus disrupt the I2C signals. This again may prevent the electronics from detecting the I2C signals correctly and even bring it into an unexpected state, therefore causing I2C errors to occur. The I2C errors due to induced disturbances are often fatal in the sense that it can be difficult for the electronics to recover from these errors.


For our gimbals, the primary origin of these disturbances is the motor wires. The motor wires carry high voltage signals, high in comparison to the ca. 3 V of the I2C signals, which moreover are pulsed with large slew rates. They hence, when the motor wires come close to the I2C lines, easily may disturb the signals on the I2C lines.
For our gimbals, the primary origin of these interferences are from the motor wires. The motor wires carry high voltage signals, high in comparison to the circa 3 volts of the I2C signals, which in addition are pulsed with large slew rates. When the motor wires come close to the I2C lines, they can easily disturb the signals on the I2C lines.


The strength of the induced disturbances depends on additional factors, such as the current capabilities of the I2C drivers and the pullup resistors.
The strength of the induced disturbances depends on some additional factors, such as the current capabilities of the I2C drivers and the pullup resistors.


== Practical Implications ==
== Practical Implications ==
Equipped with the understanding of the origin of the I2C errors, most of the counter measures listed in the above become obvious.
Some can have both positive and negative effects. For instance, twisting the I2C wires or shielding them can be very successful in protecting the I2C signals from the induced disturbances of the motor wires, but on the other hand they also increase the capacitive load. Whether these counter measures work or not therefore depends on the particular situation, whether the "induced disturbances" or "capacitive load" are the dominating I2C error sources.
Ferrite rings are very commonly used to suppress I2C errors. When placed on the motor wires they reduce the slew rate of the motor signals and thereby their ability to induce fault voltages in the I2C lines. When placed on the I2C lines they can compensate, to some degree, the capacitive load and thereby improve the I2C signal quality.
The probably most simple approach to avoid I2C errors is to lower the voltage, e.g. to run the controller/motors with 2S instead of 3S. This can be very effective, but can come at the cost of low motor torque, and some STorM32 boards do not run with 2S.
The alert reader will have noticed that increasing the current in the I2C lines or decreasing the pullup resistors, respectively, helps to diminish both the effects of the capacitive load and induced voltage disturbances. This in fact helps quite considerably, and it is a good idea to use small pullup resistors, e.g. 1k to 2k on the IMU module. One may wonder why not use really small pullup resistors instead of the typical 2k to 10k range. Well, the answer is that the common I2C drivers are not designed to handle currents larger than a few mA (and this in turn is related to the way in which I2C works). Therefore if very small pullup resistors are used this may damage your electronics. Circuitry exists to create low-impedance I2C communications, which can be added to the I2C wiring and may help significantly, but it is not used in our low-budget applications.

Latest revision as of 08:17, 29 July 2017

by OlliW, with edits by Bruce356

I2C errors are probably the most annoying side effect of the technology we are using in our brushless gimbals.

I2C errors occur when the signals on the I2C clock and data lines (SCL,SDA) are disturbed beyond certain limits, and this happens for two main reasons:

  • capacitive load on the I2C clock and/or data lines
  • induced signal disturbances due to capacitive coupling to outside fields

Importantly, all error sources add up. One therefore can't give decisive threshold values, for example, the length of the I2C wires should not be more than 40 cm long. Without any further error sources one might be able to use much longer wires, but if motor wires are too close to the IMU cabling then shorter wires might be required.

It's like a glass of wine: When it's full, it's full. It doesn't matter whether it was filled with Bordeaux, Chianti, or any other mixture. When the glass contains only a tiny bit of Bordeaux, one can add a lot of Chianti before it overflows, but when the glass is nearly full of Bordeaux, only a tiny amount of Chianti will fit before it reaches the overflow point. So, its not possible to tell how much Chianti is acceptable, since this depends on how much Bordeaux is already in the glass, the only thing that can be determined is that the more Chianti you poor in the glass the more likely it will overflow.

In the STorM32's GUI, you can find I2C errors displayed in the [Dashboard] tab, the status bar at the bottom of the main window, or in the Data Display window, which can be opened by clicking on the [Data Display] button near the bottom of the GUI.

Ways to Reduce the I2C Error Rate

Before looking at the I2C errors, here is a brief summary of methods, which help reduce problems with the I2C connection to an IMU module:

  • reduce length of I2C cables
  • increase spacing between I2C cables and motor wires
  • twist the I2C wires; this can be done in various ways, e.g. twisting all four wires together, just twisting SCL and SDL, twisting SCL with GND and SDA with VCC, etc.
  • shield the I2C wires; using e.g. a coax cable or wrapping the wires with a self adhesive conductive cloth, "EMI shielding" (where the shield must be grounded to be effective)
  • lower the (motor) voltage
  • add ferrite rings; these can be fitted in various ways, such as, putting the rings on the I2C wires and/or the motor wires, they can be fitted at either ends of the wires.
  • reduce the I2C pullup resistors on the IMU module
  • add I2C hardening electronics
  • ditch I2C and use STorM32-NT, which would be the ultimative solution

Capacitive Load

Capacitive load decreases the slew rate of the signal, and eventually prevents the electronics from detecting the signal correctly, and an I2C error occurs.

Capacitive load arises from the cables themselves, and the longer the cables are the higher the capacitive load becomes.

Therefore, for any I2C system there is an "intrinsic" maximum length up to which the I2C communication will work. In practice this maximum length is not achieved, since, as mentioned in the introduction, other I2C error sources may be present reducing the practical length. The capacitive load depends also on the used type of cable. Thin wires for instance have a smaller capacity than thicker wires. In practice, however, there is usually little room to play with this factor.

Capacitive load also arises from anything conducting in the near surrounding area of the I2C clock and/or data wires.

This is indeed a major factor, and - fortunately - it is to a high degree under our control. The possible contributors falling into this category are very diverse; they range from things like spacing between the wires themselves or to GND or Vcc, shielding such as in coax wires, twisted or non-twisted wires and the manner in which they are twisted, conducting areas like metal bars or carbon plates to which the IMU module is mounted or the I2C cables are fixed to, and so on. It is as it was mentioned, it can arise from anything that is conducting in the surrounding area. Fortunately, the rules which determine the value for capacitance are well known. In a nutshell, the larger the conducting area the larger the capacitance, and the further the distance from the conducting area the smaller the capacitance. This immediately gives us the necessary rules to control, and possibly avoid the problem.

The acceptable capacitive load, from both the cables and the conducting surrounding areas, depends on additional factors, such as the current capabilities of the I2C drivers and the pullup resistors.

Induced Signal Disturbances

Wires in close proximity to the I2C clock and data lines may, due to capacitive coupling, induce fault voltages in the I2C lines and thus disrupt the I2C signals. This again may prevent the electronics from detecting the I2C signals correctly and even bring it into an unexpected state, therefore causing I2C errors to occur. The I2C errors due to induced disturbances are often fatal in the sense that it can be difficult for the electronics to recover from these errors.

For our gimbals, the primary origin of these interferences are from the motor wires. The motor wires carry high voltage signals, high in comparison to the circa 3 volts of the I2C signals, which in addition are pulsed with large slew rates. When the motor wires come close to the I2C lines, they can easily disturb the signals on the I2C lines.

The strength of the induced disturbances depends on some additional factors, such as the current capabilities of the I2C drivers and the pullup resistors.

Practical Implications

Equipped with the understanding of the origin of the I2C errors, most of the counter measures listed in the above become obvious.

Some can have both positive and negative effects. For instance, twisting the I2C wires or shielding them can be very successful in protecting the I2C signals from the induced disturbances of the motor wires, but on the other hand they also increase the capacitive load. Whether these counter measures work or not therefore depends on the particular situation, whether the "induced disturbances" or "capacitive load" are the dominating I2C error sources.

Ferrite rings are very commonly used to suppress I2C errors. When placed on the motor wires they reduce the slew rate of the motor signals and thereby their ability to induce fault voltages in the I2C lines. When placed on the I2C lines they can compensate, to some degree, the capacitive load and thereby improve the I2C signal quality.

The probably most simple approach to avoid I2C errors is to lower the voltage, e.g. to run the controller/motors with 2S instead of 3S. This can be very effective, but can come at the cost of low motor torque, and some STorM32 boards do not run with 2S.

The alert reader will have noticed that increasing the current in the I2C lines or decreasing the pullup resistors, respectively, helps to diminish both the effects of the capacitive load and induced voltage disturbances. This in fact helps quite considerably, and it is a good idea to use small pullup resistors, e.g. 1k to 2k on the IMU module. One may wonder why not use really small pullup resistors instead of the typical 2k to 10k range. Well, the answer is that the common I2C drivers are not designed to handle currents larger than a few mA (and this in turn is related to the way in which I2C works). Therefore if very small pullup resistors are used this may damage your electronics. Circuitry exists to create low-impedance I2C communications, which can be added to the I2C wiring and may help significantly, but it is not used in our low-budget applications.