Virtual Sensors based on CAN-bus signals

Rudolf Kraft
COMPREDICT
Published in
7 min readApr 8, 2020

Virtual sensors

Sensors are units, that measure physical quantities and transform them into — mostly electrical — signals. Nowadays, sensors are omnipresent in nearly every electronic or mechatronic device we use, from smartphones to TVs going through cars. Sensor signals are used to monitor system states, detect changes in systems and/or control them (like a temperature regulation for an air conditioning system).

Sensors are physical hardware devices that make use of physical or chemical effects like electric resistance, temperature, pressure or capacity. Very often, the usage of sensors is restricted due to following aspects:

  • High costs
  • Limited installation space
  • Unsuitable environment conditions (temperature, chemical conditions, etc.)
  • Wear and/or non-reliability of the sensor

When physical sensors cannot be installed or are too expensive for a use in series-production devices, one possible alternative is the usage of so-called virtual sensors. Virtual sensors are software-based sensors, which do not directly make use of physical effects, but calculate an estimation of the targeted physical quantity by using other but measurable physical quantities. In a nutshell, virtual sensors deal with data extraction and fusion. The extraction consists of identifying the indirect physical quantities, which contain at least a part of the targeted quantity. The fusion aspect is about recombining the indirect signals by use of physical modeling or artificial intelligence in order to get access to the targeted quantity. Figure 1 demonstrates the difference between a hardware sensor and a virtual sensor: On the left side two physical quantities are measured using one hardware sensor per quantity. On the right the hardware sensor B is replaced by a virtual sensor. The sensor signal B is estimated based on the sensor signal of A and a model of the dependencies between A and B. Of course, in more complex systems an estimation of a quantity might require the fusion of multiple sensors and thus a more complex modeling of the dependencies between all quantities (like time-dependency). As well, approaches to re-calibrate the virtual sensors can be introduced according to the use case and the quality to be reached (e.g. closed-loop virtual sensors).

Figure 1: Left: Classic hardware sensors for two physical quantities, Right: hardware sensor B is replaced with a virtual sensor

Virtual sensors have many advantages over hardware sensors:

  • They are much cheaper in TCO (total cost of ownership), from the initial hardware cost, to installation and calibration.
  • They do not suffer damage under rough conditions like vibrations or extreme temperatures.
  • Via API/SDK, they can be interfaced with existing telematics solutions.
  • Their durability and reliability are only limited by the lifetime of the vehicle’s standard components and of the datalogger/telematics solution.
  • They do not alter the system under test, adding no additional mass, strain or effort like e.g. a wheel torque sensor would do.

Purely CAN-based sensor fusion

As you have probably already understood, to build a virtual sensor you also need hardware sensors, which are at other places measuring other quantities than the one you need. The good news is that, in most of the cases, you have hardware sensors anyway. Let’s take a look at the situation in the automotive field, which is our core competence area: a modern vehicle is similar to a driving computer. It contains electronic control units (ECUs) for engine, steering, brakes and much more. All these control units require sensor signals to monitor the current state of the vehicle components and take appropriate actions. This means, that there are standardly available sensors in a vehicle, which are installed by default, i.e. independently from the usage of virtual sensors. All these sensor signals are usually transmitted on the so-called CAN bus. CAN is the abbreviation for Controller Area Network and describes the most widespread communication protocol, that is used for signal transmission and communication between control units in a vehicle. Our virtual sensors take part of these signals as inputs to calculate physical quantities for almost all vehicle components (see Figure 2). For our customers this results in minimum effort: no additional sensors, no additional hardware, no specific space requirements, only lines of code. Comparison data coming from a dedicated sensor is only needed during the training phase of the virtual sensors, which are usually measured during development in test vehicles (i.e. measurements of the target signal to calibrate and validate the virtual sensor). We are also currently working intensively on limiting the need for comparison data and are leading research on topics like transfer learning. In any case, the most important thing is that, in operation, no additional physical sensor is required anymore: once the virtual sensor is trained, it is robust and accurate enough to be implemented in every single vehicle from the same type.

Figure 2: COMPREDICTs virtual sensors, in scopes: example of used CAN signals, in red: target signal

Given the signals on the CAN bus, we apply our sensor fusion algorithms for the estimation of the desired target. This process includes two main steps, which are:

  1. selecting the best CAN signals and signal contents.
  2. modeling of the dependencies between these CAN signals and the target signal

1. Feature selection and extraction: The first step is to find the CAN signals that are most suitable for estimating the target. Considering more signals may improve the estimation, but also make the training more difficult, and increase the required computation power and the memory footprint. If the dependencies between the CAN signals and the target are obvious, you may imagine that the process of selecting the signals is easy. However, when the dependencies are non-trivial or if only a specific part of a given feature is relevant, you must consider other approaches. These can be based on system knowledge, on frequency analysis or on statistics and probability theory. Feature selection and extraction are very wide fields that are still extensively investigated in the context of Machine Learning. For a bit more insight in our approaches, you can have a look at this previous article: Time series causality. We will publish some new articles about this topic soon.

2. Modeling of the dependencies: The features that have been chosen in the first step are then used to estimate the target signal. We use different approaches to handle this challenge. Besides mathematical modeling, we use various approaches of system identification, optimization algorithms and Machine Learning, all included in the more general area of the artificial intelligence. Depending on the complexity of the system, a virtual sensor can rely on only one of these approaches or on a combination of them. Analogous to the number of features, the efficiency of the algorithms directly affects the performance and memory consumption of the virtual sensor.

Implementation

The virtual sensor can be used both offline and online (see Figure 3). Offline means, that the CAN signals are gathered and saved in a database on a server, and then these data are used to calculate the target signals for further analysis. Online means, that the estimation of the target signal is performed embedded, on a vehicle’s Electronic Control Unit (ECU) and in real-time. The advantage of this approach is that the signal can directly be used to take actions during the vehicle operation or share on the CAN bus to other ECUs. On the other side, running the virtual sensor directly on the ECU requires a particular attention to memory and efficiency, and thus limits the use of certain modeling approaches.

Figure 3: Offline vs online virtual sensor

Example how data science can be used in automotive industry

Let’s take a look at an application example. One interesting physical quantity in automotive vehicles is the dynamic side shaft torque. It can be used not only to estimate the damage and thus the remaining service life of the side shafts and its subcomponents like the joints, but also of drivetrain systems like the gearbox or the tires. Furthermore, it is a useful information for traction and stability control. Unfortunately, measuring the side shaft torque with a dedicated sensor is not that easy. Usually, adhesive strain gauges are applied on the surface of the shafts, but since the shafts rotate during operation, special methods for signal transmission must be considered. Moreover, side shafts can easily come into contact with water, snow, dirt and particles which can damage the strain gauges. This results in expensive, sensitive and unreliable measuring systems that are not suited for series production.

In contrast, a purely CAN-based virtual sensor does not require any additional hardware sensors in series application. Figure 4 shows signals for a hardware sensor and a virtual sensor for the side shaft torque of our demonstration vehicle, a Tesla Model 3. In this particular case, for development reasons, the virtual sensor is implemented on a data logger connected to the CAN bus and not directly on a ECU (more info about our own developed data-logger incl. web server in a next post). The virtual sensor gives a real-time signal for the side shaft torque. As you can see, the signals match very good (almost perfectly) over the whole amplitude range.

Figure 4: Comparison of a hardware sensor and a virtual sensor for the side shaft torque of a Tesla Model 3

Of course, virtual sensors can be applied not only in automotive vehicles, but in every mechatronic device. We continuously expand our scope of activity, so if you have an interesting field of application, just contact us.

--

--