Jul 16

Using Machine Learning (ML) to predict remaining charging time for electric buses

This blog post was written by Erwin Poeze, Senior Machine Learning Engineer at ViriCiti

Why is it important to predict charging time? 

Since this year we added charging time prediction to the ViriCiti Charging Stations dashboard  (our basic package). This means that we are able to predict the remaining charging time until 100%  state of charge (SoC) for each charging session. 

Knowing the time it takes to charge a battery allows you to make operational decisions. For example, if you need a bus ready in 20 minutes but you see it will take 30 minutes to reach 100% SOC, you could then manually prioritize the charging for this bus. 

This decision requires knowledge of the remaining charging time. Only by knowing this information you can be sure if the electric bus will be sufficiently charged for the next route. 

But the remaining charging time depends on various factors like the current SoC percentage and the charging power. So it is not that straightforward to find out. 

In this blog, we explain how ViriCiti applies machine learning to predict the charging end time, thus giving the operator more certainty about which buses are available for dispatching soon.

Why predicting charge time is hard

First, let’s start with a bit more background information. 

Li-ion batteries have a long lifetime and can be charged and discharged often, provided that you charge them with care. The battery management system (BMS) of the vehicle advises the charger on the maximum power level to avoid unnecessary battery-cell damage. 

A battery is charged applying a voltage level to its cells that is higher than the current cell voltage.  The BMS measures these voltages and makes sure they stay within their limits. During charging the increased cell voltages reflect a higher charge, but when the maximum cell voltage is reached, the battery cells are not necessarily fully charged. The reason is the charge is applied to the surface of the battery cell and it takes time for the charge to get absorbed by the cell. You could say that the voltage is running ahead of the charge.

A nice analogy is filling a glass of beer. If you tap the glass with beer quickly, there will be an abundant amount of foam on top and you need to (temporarily) stop tapping. If you fill the glass slower, less foam is produced, and in the end, there will be more beer in the glass.

As you might have guessed, the glass represents the battery cell, the beer the charge, and the foam on top of the liquid the voltage. The top of the glass symbolizes the maximum voltage. If you charge the battery slowly with a C-rate of 0.1, both the charge and the voltage will increase slowly, and by the time the maximum voltage is reached the cell will be fully charged. But when you want to charge quicker using higher power, (C-rate for example 2 or higher) the maximum voltage will be reached before the cells are fully charged. 

The role of the BMS is to control this process. Starting from SoC levels above 50-60% the BMS will advise the charger to slow down the charging by reducing the power, allowing the charge in the cells to catch up. Once the voltage hits its maximum value, it is kept on that value until the cells are fully charged.

Coping with uncertainty

There are multiple sources of uncertainty when it comes to predicting the remaining charging time due of several unknowns. At what level does the BMS start to reduce the power? How is this power reduction taking place?

To answer these questions one needs to know how the BMS responds to different levels of power in relation to the SoC. This differs per BMS type and also depends on the factors like the battery-cell temperature. Also, the reduction of power might not be a linear process as you can see in figure 1. This figure shows the power values during charging for different levels of SoC. Each color represents a different charging session.

Figure 1: Charging power is reduced at increasing SoC levels

It can be stepwise (see green and orange lines) and there may even be a temporary increase in power (notice the bump in the red line). 

In figure 2  the charge power curves are shown for another vehicle model, where each color represents a charging session. Note the constant power curve at the 60 kW level for the transaction represented by a blue line. There is no need for the BMS to reduce the power until the SoC reached almost 100%.

Figure 2: Charging power versus soc for another vehicle model

Machine learning to the rescue

If we knew exactly how each BMS works, what the settings are, and what algorithms it uses one could easily calculate the remaining charging time. However, the BMS is a black box to us, only the manufacturer knows the exact details for their own vehicles. 

So we need another way to predict the charging time and we opted to use machine learning

This allows us to learn the behavior of the BMS by using historical data of charging sessions. The SoC at the start and the end of the charging session, the charging power, and the vehicle type are used as input and paired with the time the charging session took. 

We decided to use a Gaussian Process as the machine learning model. This is a statistical model that is not only capable of describing the non-linear relationship between inputs and outputs, but also returns the accuracy of the result. 

For 100 charging sessions, the actual duration of the session is depicted as a blue dot. The open circle is the predicted duration and the vertical bar shows how confident the model is of the solution (bar = 1 standard deviation = 68%). 

At ViriCiti we have a few dozen vehicle types that connect to the chargers we help monitor. As each vehicle type requires a different machine learning model, we need to automate the collection of data and training of the models. This automation is done with the help of Airflow. Airflow is a scheduler that automates the steps in the machine learning flow. These steps are depicted in the diagram.

This pipeline is run automatically on a regular basis to update the models with the latest data. This ensures the best predictions for the remaining charging time. The charging time models can be accessed by the ViriCiti Charging Stations dashboard. Passing the start soc and the charging power to the model results in a prediction of the remaining charging time. This result can be found in the column “TIME TILL 100%”, see the following screenshot:

The results 

Now you have the ability to optimize your operations knowing the remaining charging time. With one quick look at our dashboard, you can see an easy-to-read overview of all your charging buses and the remaining time to charge until 100% SOC. 

To our knowledge, ViriCiti is the only company able to offer this OEM-agnostic feature. 

 

About The Author

We are the ViriCiti marketing team. A group of EV enthusiasts writing about the most important aspects of operating electric fleets. From monitoring to smart charging.