View Single Post
  #44  
Old 05-21-2007, 02:24 AM
b3lha's Avatar
b3lha b3lha is offline
Phil & Belha
 
Join Date: Aug 2001
Location: Alcyone Limited, Buckinghamshire UK
Posts: 2,671
Quote:
Originally Posted by cozykat
I wonder if Vikash's rounded calculations might be wrong?

My reasoning is because when reading voltages there must be some kind of A/D conversion going on (A/D => analog to digital). Normal analog conversion will produce something along the lines of 1024, 256, 512, 2^N.. etc.. Vikash's formula just took Kevin's and factored it out. (i.e. 5/256 => 1/51.2 and Vikash is essentially multiplying by 1/50). Depending on the # of bit conversion, rounding can loose a lot or just a little bit of information.
So I would think Vikash's math is losing some of the original value and therefore isn't as accurate unless he is trying to compensate for some kind of sampling error not mentioned??
just some thoughts...

~Marisa
I see what you're saying. 5 volts being the max and 256 being the number of steps, so 5/256 sounds right. Vikash's code simply left shifts the value and displays it to 2 decimal places. ie. N*2/100 = N/50

Thinking about it some more, wouldn't 5/255 make more sense? That way 0x00=0v and 0xFF=5v. Otherwise 0xFF=4.98 Kevin's way or 5.10 VIkash's way.

I'll have a read of the m377 datasheet and see what it says about how the built in A/D converters work. That's of course assuming that the TPS is connected to one of the internal A/D converters rather than an external one on the board.
__________________
Subaru ECU and TCU Website
1992 Alcyone SVX Version L
1992 Alcyone SVX Version L
1994 Alcyone SVX S40-II
2004 Subaru Legacy 2.5 SE Sports Tourer
1996 Subaru Legacy 2.2 GX Wagon
1988 Subaru Justy J12 SL-II
Reply With Quote