View Single Post
Old 03-01-2017, 01:38 AM   #86 (permalink)
t vago
MPGuino Supporter
t vago's Avatar
Join Date: Oct 2010
Location: Cedar Rapids, IA
Posts: 1,766

The Karen-Mobile - '05 Dodge Magnum SXT
Team Dodge
90 day: 26.72 mpg (US)

Fiat Dakota - '00 Dodge Dakota SLT RWD Quad Cab
90 day: 16.67 mpg (US)

The Red Sled - '01 Dodge Durango SLT 4WD
90 day: 16.96 mpg (US)
Thanks: 799
Thanked 681 Times in 437 Posts
Originally Posted by skybolt View Post
Well, then now is a good time as any to roll out this potato: I need your routine to calculate mileage down to the ten-thousandth, which will result in resolution of about a foot. (In my car, technically, 6.7 inches, which is actually good to display to the foot; based, sort of, on the 2x sampling principle).
I've been tossing around this potato in my head for the past week. I think I may have come up with a solution - it's based on how my code currently handles metric vs. SAE measurements. Been kind of busy lately, though, so can't give you a definitive date as to when it will be available.

Along with coding this, going to also strip out the validation checks on the VSS signal. I really can't see any point to having them there. Debouncing should work just fine for slower mechanical VSS generators, and more recent solid-state generators don't need debounce anyhow.

Originally Posted by skybolt View Post
That said, a quick question: Are conditional if/then statements computationally efficient?
Inasmuch as a conditional does not actually calculate anything, then no, they're not computationally efficient. However, conditionals are indispensable to computing, so there is that to consider.

There are different structures that conditionals may take, which tend to minimize the required overhead. Jump tables tend to be the most efficient, because the conditional has been boiled down to an index that can be used to pull an address from said jump table. Jump tables tend to be the most flexible, too, because you can assign a certain action to be performed if the conditional variable reaches a certain value, and then perform another related action that would normally be called for if the conditional variable reached some other value. Jump tables are generated by C++'s switch/case/default statement blocks.
The Fiat Dakota

The Karen-mobile

The Red Sled
  Reply With Quote