View Single Post
Old 06-10-2008, 12:34 PM   #241 (permalink)
Yoshi
SuperMID designer
 
Yoshi's Avatar
 
Join Date: Mar 2008
Location: Yokohama, JAPAN
Posts: 37
Thanks: 0
Thanked 13 Times in 2 Posts
You're welcome.
Quote:
Originally Posted by dcb View Post
Any thoughts you'd be willing to share on the trip vs instant mpg discrepancy?
I've no time to figure it out yet, but I think you could.
I believe you can refer raw numbers for the variables and you'll find the cause is whether distance data or gallons, instead of the result of mpg value.
Quote:
Or better yet, a generic way to multiply and divide 32 bit numbers while not overflowing but retaining max resolution (without a bunch of "if" statements)?
I know 32 bit data is better than 16 bit, but...
We observe approx 1% variance on the VSS and injector pulse width, therefore 1% accuracy is my target. I believe 0.1% internal calc error is acceptable, then 5 digit decimal value (or 16 bit data) is enough for our instrument.

Again, my suggestion is to place cli()/sei() codes for another interrupt driven variables, such as vssPulse and injector pulses.
Following is an example in instruction level. A 32 bit variable is sent to registers as follows and interrupts can be occurred any timing between instructions.
Code:
; a 32 bit variable is 0x0000FFFF
        LDS     R14,0x0244 ; R14<-0xFF byte 0 of 0x0000FFFF
        LDS     R15,0x0245 ; R15<-0xFF byte 1 of 0x0000FFFF
; an interrupt occurred, then it became 0x00010000
        LDS     R16,0x0246 ; R16<-0x01 byte 2 of 0x00010000
        LDS     R17,0x0247 ; R17<-0x00 byte 3 of 0x00010000
; then R17..R14=0x0001FFFF
Regards,
Yoshi


Last edited by Yoshi; 06-10-2008 at 04:35 PM..
  Reply With Quote