The answer to the maths is to scale it, you could use 16 bit maths, or even 24 or 32 bit. By scaling the input (to calculate 11,000/6) you get a result of 1833 - knowing full well the decimal point should be two digits in. You simply display the result placing the decimal point where it should be - integer maths, giving floating point results (very quickly and accurately).ivancho said:Problems you might encounter. When using a 5V reference with a 8-bit ADC you have a steps of 0.019V. So 0.019V = 1 and 0.39V =2 and so on. Well say you have a 110 and a 6 as your two numbers. If you wanted to divided 110/6 that will give you 18.33 right.... but since only integer math can be done the result will be 18.
depends, pc's x87 are faster in calculating complex floating point math then the main ALU is at integersNigel Goodwin said:You use a similar method programming a PC as well - it's far better to use integer maths where you can.
And on a PC as well - floating point tends to provide answers like 9.9978675646352377378 - when it should be 10. It's far easier, faster and more accurate, to scale the values and use integer arithmetic - particularly for financial calculations.Exo said:depends, pc's x87 are faster in calculating complex floating point math then the main ALU is at integersNigel Goodwin said:You use a similar method programming a PC as well - it's far better to use integer maths where you can.
On a µC, ofcourse, FP should be avoided
I'm sorry, I don't see the problem with scaling?.ivancho said:The problem with scaling is that while it works well with displaying on LCD, etc it is not so good when sending it to a 8-bit DAC. You are still going to need to send a 0-255 number, and when you scale back down you are doomed again :evil:
If you were to use a 10-bit DAC then you will not have the perfect relation ship between the division result and what you need to output.