G-Tech meter acceleration calculations

M HILL EAXMJHI at ean2.mecheng.nottingham.ac.uk
Fri May 2 08:17:16 GMT 1997


The way I did the calculations was as follows:
This was all done on an eight bit microcontroller
speed is set up as two bytes.  The upper byte is for mph, the lower 
byte for 1/256 of a mile per hour.  I.E. when lower byte overflows 
upper byte is incremented by one.
Distance was set up in the same way with the upper byte being in 
thousands of a mile and lower byte in 1/256 of a thousands of a mile.

Accelerometer was setup to give a full scale reading of 100 at 1G.  
calibrated using gravity.  
the interrupt to do the calculations set to run every 17.803mS.  At 
this speed the acceleration value can be added to or taken from the 
speed value (lower byte) and this will give the speed correct in mph 
in the speed upper byte.  The speed upper byte is then multiplied by 
1.2565 (cannot remember exact number but it around there) and is 
always added to the distance lower byte.  The upper byte of the 
distance value will now read in thousandths of a mile, enabling you 
to measure up to 0.255 miles.

The calibration of the accelerometers was done by tipping the board 
vertically and trimming the gain and offset pots to give + and - 1G.  
If anybody wants any more info I will be happy to help out.

Martin



More information about the Diy_efi mailing list