- Just to save a bit of time on all those floating point calculations... Why fart with all this floating point calculating stuff. That's just a lot of extra code libraries, and way more execution time. I know, in this particular app, it really doesn't matter, but in the old days, we did it differently.
Consider changing the divider ladder to use a 12M7 and 100K 1% resistors. Now the division ratio is 128:1. Maybe splurge on the 0.1% tolerance, if available. You're only buying 2 resistors. Now here's an old trick, from the old timers. Yes, even older than me. Accumulate 20 samples, then divide that number by 64. Magically 64 (32, 16, 8, 4 ...) doesn't need a divide routine, floating point, nor fixed point, nor integer. All it needs are a few right shifts. Explicit 'right shifts' are both available in assembler and c. Divide by 64 is equal to 6 right shifts. The decimal equivalent of the result will be the voltage, with 1 volt resolution. Now all you have to do is convert it from Integer to 3 BCD nibbles. BTW all the above stuff should have been handled as 16-bit integers. Also uses internal 2.5V reference. Here's a table of some values: Input. ./128 ...N.. .20xN ../64 ==== ==== ==== ==== ==== 320V 2.50V 1024 20480 320 300V 2.24V 960 19200 300 180V 1.41V 576 11520 180 100V 0.78V 320 6400... 100 Magic, how that works out ! Note: all the values are less than 32767, so you don't need to worry about all that signed/unsigned crap. If you don't want to go out and buy those two resistors, you can get the same ratio using a fixed resistor and a trim pot. Multi-turn preferred. I bet you have something that will make that 128:1 ratio in your junk box. -- You received this message because you are subscribed to the Google Groups "neonixie-l" group. To post to this group, send an email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/neonixie-l?hl=en-GB.
