I found this calculation of HP:
1/2 * [veh_weight_lbs] / 32 * (5280 / 3600)^2 * (curr_speed_mph^2 - initial_speed_mph^2) / time / 550
1/2 and 32 adjust for acceleration
5280 adjusts miles to feet
3600 adjusts hours to seconds
550 adjusts to HP
The total weight is the car + fuel (@6lbs per gal) + driver + misc stuff. My car with 1/2 tank of gas is 3837 + 60 + 170 + 30 = 4097lbs.
I set up an array as a ring buffer in loop() that captures mph values over the last few loops. The oldest value is overwritten by the current value each time through loop(). For example, current MPH might be 50mph and 4 loops ago it was 30mph. 4 loops is about 2 seconds. So, currentmph & initialmph, time and weight are known. Plug them into the formula and calc away.
I've tried this in the car once but I' don't think what I'm seeing is correct. All the constants can be factored into a single constant but it will be a fraction so float types will be needed. Working on it.
|