### Machine Learning for Steady State Measurements

I had a problem… I indicated that I could produce an accurate chart of motor current flowing as a result of applied motor voltage on a motor fan setup. It was a DC motor with hall effect DC current measurement.

Conveniently the applied voltage to the motor could be controlled manually from a pot during an agreed data gathering experiment.

I intended to provide an up/down staircase voltage to the motor to provide steady current information at several points going both up and down. Since this was a one off measurement opportunity I took care that the recorded measurements were accurate, but not much care as to how they looked.

When I viewed the voltage and current charts later I noticed that the applied voltage was not steady as I’d assumed, but contained considerable fluctuations in magnitude.

Fig 1. Motor Voltage and Motor Current vs time

As you see the voltage fluctuations are reflected in the motor currents so it is not so easy to estimate the steady state current for each applied voltage.

Rather than a nice staircase current waveform that should produce a hand full of discrete points on a current vs voltage XY chart, I had a continually fuzzy voltage and current waveform. The most noticeable effect in the current being the high currents during acceleration and deceleration and not much of an obvious relationship between steady state current with respect to the voltage. It was looking like production of a precise smooth current voltage graph would require less of my technical ability and more of my creative ability in fudging the figures to make them look right!

Never the less, I continued as I had originally intended, that is to simply plot the measured currents against the measured voltages showing them on an XY plot. Fig 2 shows the result and looked more like modern art than a smooth scientific curve.

Fig 2 Motor Current vs Motor Voltage

My original plan was to present the data with the minimum amount of number massaging. I expected to have to remove the data from the times when I was ramping between steady speeds. However I hoped to be able to easily isolate sections of steady state running from my original test. It looked like I needed completely new data to get the result I wanted. If only I could do another experimental run on the system but this was not possible. I considered applying a low pass filter to the waveforms but there was not enough actual steady time to give a precise result.

What if the fluctuations were actually a blessing in disguise? The current fluctuations were directly caused by the voltage fluctuations acting on the motor and load characteristic. What if the formulae relating current and applied motor voltage could be worked out from the test data already taken?

If this formula could be produced, then couldn’t we now just apply the required voltage input to it for a suitably long time and read out the steady state current? Couldn’t we do that for the same number of staircase sections that I had already done and then have the ten or so precise points from which to produce my Current vs Voltage plot?

But I’m getting a bit ahead of myself as all this is based on the assumption that I can produce the correct formula to predict current caused by applied voltage for all conditions. It sounds a little tricky as the motor and load characteristic is a little complex having elements of static friction, windage in the motor, turbulence in the load, acceleration and deceleration along with changing moment of inertia and some springy elements as well!

Machine Learning can help here. It will allow an iterative algorithm to continually modify a formulae that we can use to predict the motor current. It will compare the result of the formulae with the actual measured values and continually strive to minimise the difference or error between them. Of course the formulae must be sufficiently complex to represent the required system and the gathered data must have sufficient information in the required ranges of current and voltage to do a good job.

So I used the gathered data along with a nonlinear dynamic formulae and set linear regression to work. It came up with a formulae involving 183 constants and reported that the predicted current for every sample of the voltage data could be computed. When those predicted currents were computed they could be compared to the actual measured currents and some sort of overall error shown. Fig 3 shows the actual current and the predicted current as a time series for the duration of the test.

Fig 3 Motor Current and Predicted Motor Current vs Time (20ms)

As can be seen, the prediction closely matches the actual values. The program reports that the RMS error of its prediction was 3.1% of the range of the currents during the test. A zoomed in look in Fig 4 shows that the result is not perfect, but very good.

Fig 4. Close up Motor Current and Predicted Motor Current vs Time (20ms)

Now that I had a formulae for predicting current from applied voltage I could apply my own voltage signal to it and see if the results looked reasonable. As an example I could apply a voltage step to the system and see what the predicted current waveform should look like. If I were to do this I would expect to see a high current as the motor accelerated. The current would then die off to a steady state value as the speed came up and stabilised.

Fig 5. Comparing actual motor voltage to predicted motor voltage for a step voltage input.

Back to the steady state. Our original attempt to use a staircase waveform to measure multiple steady state regions is ok but it would not give any information between the steps. It would be better to be able to produce a current reading for the full extent of the voltage range. We can do this since we have the precise current formula for steady state and dynamic conditions. So we can modify the formula to only produce the steady state value by cutting out all dynamic terms.

Fig 6. Measured Motor Current (Red) & Predicted Steady State Current (Black) vs Motor Voltage

In the time since we completed this project we have had a chance to go back and retest the original system with a non-noisy input signal. We generated a noise free staircase voltage input and measured the voltage and current of the motor during the test. Fig 7 shows this data.

Fig 7. Retested results with a clean input signal

We then plotted the motor voltage vs motor current for this clean signal and compared it to our formulae generated curve. This can be seen in figure 8.

Fig 8. Cleaned input data compared to machine learned relationship curve

As can be seen the experimental readings and the predicted curve appear to match very well in the sections where the readings have stabilised. We are confident that the machine learned relationship curve is accurate over it’s full range.

Fig 9. Shows the final chart that I was expected to produce.

So to summarise, the collection of accurate data, at the appropriate bandwidth has allowed the nonlinear dynamic relationship between motor current and motor voltage to be learned. Having learned this relationship, the system can be subjected to any desired input conditions and have the output accurately predicted. This allowed the steady state motor current vs motor voltage to be charted from data that had no such steady state sections in it.