E-bike data analysis

As described in the previous post, I have a custom built e-bike data logger. I am now collecting data from the device, and here are some interesting bits I have found. Yesterday, for the first time, I was able to get the battery voltage/current/power sensor to work. I took a short 5 minute ride around a nearby park(“the test track”). The data sources used in this article come from the E-bike blackbox, which measures battery voltage/current/power while GPS position/speed and IMU acceleration comes from a mobile phone that was in my backpack while riding. Both devices are syncronised with real time clocks. The battery parameters are sampled at 100 samples/second, GPS sampled at 1 sample/second and IMU acceleration at ~100 samples/second(limited by how busy the processor on the Android phone is).

Cycling route. I traveled in the clockwise direction

All the data may be viewed on an interactive plot here. The interactive plot can be adjusted to different ranges. Another Protip: Different plots can be hidden/shown by double clicking the legend.

All the data collected so far, overlaid. The interactive plot allows you to zoom/select plots.

Preliminary info on Battery current/voltage/power

Using an INA226 current/voltage/power sensor, I measured the parameters it is capable of measuring. I went on a 5 minute ride on the e-bike around my area and collected the data.

In the following plot, I show the Battery voltage(V_bus[V]) and the Power from the battery(Power[mW]). Battery voltage is at 28 V – 29 V at rest, but falls to 26 V under load. The battery was fully charged at the beginning, and is nominally rated at 24V. The power parameters are measured by measuring the voltage drop across a shunt resistor.

Battery voltage(blue) and Power(purple)

Assuming the shunt resistor value is accurate, it shows that peak power consumption is 400 W. 2 shunt resistors were used: one that came with the INA226 breakout board( 100 mΩ ) and an external shunt resistor. The external Shunt resistor value was calculated by using the datasheet value which works out to be 2.5 mΩ. The resistors were arranged in parallel, working out a total resistance of 2.4 mΩ.

Power consumption is interesting. Under peak steady load, 400 W of power is exiting the battery. However, the motor is only rated to 250 W. Since the shunt resistance is not (yet) calibrated, it cannot be said for sure weather there is an error in power calculations or indeed it is drawing 400 W of power. The following posts on the Electric Bike Review forum sheds some light on the efficiency of the motor. It could well be due to inefficiencies, 400 W electric power only yields 250 W power from motor.

Current profile

Looking at the current consumption(see figure below), under peak steady load, it is drawing 14A. There is one peak in there where it goes up to 20A current. It appears that the controller powers the motor with simple digital on-off control. There does not seem to be any intermediate power level. On the trip, I was moving the whole time, without stopping. However, from the plots, the motor kicks in and out quite a lot.

Current consumption

The manual for this e-bike gives some clues about how the motor controller powers the motor. It seems to hit peak power as soon as the rider starts pedaling, and tapers off when close to the maximum allowed speed for the e-bike. In the data above, it does not appear that the e-bike every hit the peak speed so we don’t see the tapering happening. I have personally felt the motor cut off at peak speed so I must ride for longer at length to record this behaviour on the datalogger.

Diagram in the manual showing how much pedal assist the motor controller gives.

Acceleration vs power params: anti correlation?

When we include data from the acceleration data from a single axis from the accelerometer on my mobile phone, there appears to no correlation at all between the battery voltage/current/power. In the data below, Acceleration(in Red) seems to hold a roughly flat line as I am riding. However, only before and after my journey are there significant increases in acceleration. This is when I alight/board my e-bike. Note that the phone was in my backpack while I rode around. Maybe the backpack dampens all acceleration. It could be there is a high pass filter applied to the Accelerometer.

Acceration data(in red) along with the battery data

Battery output Power vs GPS speed

GPS speed(km/h, Red) plotted against Power(mW, Purple). The area circled yellow was on a downhill incline where I was going above 25 km/h, hence no motor support.

Looking at the GPS speed vs power plot, we see several interesting features. Firstly, it is very clear that the power output is almost a digital on/off. It looks like its either full power or no power. Second, we can see in the area circled in yellow, that there is no power from the motor yet I am going at top speed ~25 km/h. The reason is I was going down hill at that speed with no assistance from the motor.

Power profile highlighted while going down hill.

The data in the above plot gives us an idea of how the motor controller works. At the top of the hill, I accelerate to 25 km/h. The motor does not kick in because I am travelling too fast. However, as I travel downslope, the slope flattens out (you will have to take my word for it!), and hence I slow down to 17 km/h. At this point, the motor kicks in and gives me a boost. It could have been triggered by pedaling, through the Hall effect/pedal assist sensor. I soon go back up to 25 km/h, when again the motor cuts out.

The next thing I need to do is to plot the road incline and pedal assist sensor readings as well.

Battery power vs GPS acceleration

Plot showing GPS speed(Red), GPS acceleration(Green) derived from GPS speed/time and Power(Purple)

It appears that there is no obvious correlation between GPS acceleration and power from the battery. GPS acceleration is calculated from the derivative of GPS Speed over time. The GPS only gives me speed, not acceleration. One source of error could be that the GPS sample rate is too low; too little granularity. It samples at 1 sample/second and I think lots of changes in speed can happen within that 1 second. In comparison, the battery parameters are measured at 100 samples/second. Solution to fix this problem is to:

  1. Increase GPS sample rate. This can be done with using a dedicated GPS which samples at higher rate. The sample rate is limited by the android program I am running on my phone.
  2. Read the speed wire in the e-bike wiring harness. This speed sensor is mounted inside the motor hub, which is used by the controller to control power output to the motor. It cuts out the motor when the legal speed threshold is breached.

All data in one plot

If we combine all the unique data in one plot(interactive plot), this is how it looks:

All data in single plot

On this plot, we see the power[mW], Battery Voltage[V], GPS Speed[km/h],GPS Acceleration, GPS altitude and Barometric altitude. Two variables here are derived: GPS Acceleration and Barometric Altitude. GPS Acceleration is derived from GPS Speed by differentiating it with time. Barometric Altitude is derived from barometric pressure and temperature. However, in this graph, it has an offset error that gives it a negative altitude. This is because conversion function requires a constant which needs to be calibrated. However, relative changes in Barometric Altitude should be accurate.

Importantly, we can see that Barometric Altitude does not correlate very well with GPS Altitude. This is due to inaccuracies of the GPS in the altitude axis. It is a limitation of the instrument. GPSs are very accurate(to a few meters) in the horizontal plane but could have twice the error in the vertical direction.

As expected, we see that during the climb, the motor power is constant, maximum to power the climb. The power from the battery kicks in and out during the plateau. On the downhill descent, the motor is not used at all.

Elevation of Route

If we plot the barometric altitude with the GPS longitude/latitude, we get the plots below(interactive plot). The colour scheme is on a scale from dark blue to light green. The greener, the more Power [mW]. Note, I was travelling in the clockwise direction. Notice that on the uphill, it is all green because the motor is used most on the up hill section. However, on the downhill, there is no power expended at all. But on the flat section, the power kicks in and out. This is due to the e-bike hitting the top permitted speed and hence stops powering the motor. Conclusion: The e-bike consumes more power going uphill than going downhill!

Reverse current?

In the current data, it can be seen that during braking, there is a small amount of reverse current into the battery, up to 135 mA. This is likely “Inductive kickback” from motor coils while braking. It is not quite regenerative braking though since it happens for a very short time.

Current going negative

Battery model

Continueous discharge

What we see during continueous discharge is the battery voltage slowly falls. In this case above(voltage in blue, power in purple), it falls around 1 Volt during discharge. However, as soon as the load is removed, it shoots back up 3-4 Volts and slowly recovers. This can only be modeled by a Resistor/capacitor battery model.

Equivalent circuit model of the lithium-ion battery. | Download Scientific  Diagram
Battery Equivilant circuit model. Figure Credit: Mu, Dazhong & Jiang, Jiuchun & Zhang, Caiping. (2013). Online Semiparametric Identification of Lithium-Ion Batteries Using the Wavelet-Based Partially Linear Battery Model. Energies. 6. 2583-2604. 10.3390/en6052583.

This very phenomenon is modeled in the paper Fast Characterization Method for Modeling Battery Relaxation Voltage. The voltage relaxation curve is shown in the figure below. This will require further investigation.

Image source: Li A, Pelissier S, Venet P, Gyan P. Fast Characterization Method for Modeling Battery Relaxation Voltage. Batteries. 2016; 2(2):7. https://doi.org/10.3390/batteries2020007


Find out the correlations between speed, power, current and voltage. Also, look into the start and stop frequencies on a road. Does traffic conjection affect it? density of traffic lights and intersections?

Leave a Reply

Your email address will not be published. Required fields are marked *