I have these two sets of data, the first being a time stamp (ms) and the other being mechanical power (W). For each of these I have to work out the mechanical energy in KWh.
0 0
362 3.76
402 3.76
442 7.12
482 10.68
522 12.46
562 16.02
602 17.80
From my working out I have created the formula:
ME = (T-O)/3600000)x(P/1000)
ME = Mech energy
T = Current Time
O = Previous time
P = Power
But I have no means of checking if it is actually right. Can someone please confirm?
Energy is the integral of Power over time.
Since your data for power vs. time are discrete, you shall first of all decide for a reasonable (or acceptable, or hypothesized) interpolation of a continuous $P(t)$ with respect to the available data.
If your interpolation is stair-wise and you assume that the recorded value of power extends to the precedent $\Delta t$ (e.g. in the first interval $0..362$ you assume $P=3.76$) then your formula is correct: $E_n=P_n \dot (t_n-t_{n-1}) \quad |\;1 \leqslant n$.
Probably, a better approximation is to take that the power varies linearly between the recorded values, so that:
$E_0=0, \quad E_1= 1/2(P_1-P_0)(t_1-t_0),\quad \cdots$ (which is a trapezoidal approx.).
But you could make a more sophisticated approximation by using a spline or polynomial interpolation and then take the integral.