User Tools

Site Tools


arduino:divide-by-1023-or-1024

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:divide-by-1023-or-1024 [2025/06/21 11:17] – [Finally, to get the voltage producing an ADC value, do we divide by 1023 or 1024? What do AI engines have to say?] Ilias Iliopoulosarduino:divide-by-1023-or-1024 [2025/06/21 11:56] (current) – [Finally, to get the voltage from the reading of analogRead(), do we divide by 1023 or 1024? What do AI engines have to say?] Ilias Iliopoulos
Line 7: Line 7:
 Discussion forums hosted several opinions, some purely theoretical, others practical and of course some totally misleading. During the past years, I have not encountered any forum that provided a conclusive response on this question. So, I wanted to check what our Artificial Intelligence friends have to say about that. Discussion forums hosted several opinions, some purely theoretical, others practical and of course some totally misleading. During the past years, I have not encountered any forum that provided a conclusive response on this question. So, I wanted to check what our Artificial Intelligence friends have to say about that.
  
-As expected, AI machines are trained by the information they find online. One was in favor of 1024, explaining that this is the correct value, because it is consistent to the theory of the operation of Analog to Digital Converters. It also considered 1024 as the value that provides the highest precision, making this approach more applicable to operations that require high accuracy. Yet, asking the machine why some people are in favor of 1023, it took an neutral position, stating that the results do not differ so much.+As expected, AI machines are trained by the information they find online. One was in favor of 1024, explaining that this is the correct value, because it is consistent to the theory of the operation of Analog to Digital Converters. It also considered 1024 as the value that provides the highest precision, making this approach more applicable to operations that require high accuracy. Yet, asking the machine why some people are in favor of 1023, it took an neutral position, stating that the results do not differ so much and that although 1024 is "dictated" by some obscure mathematical theory, 1023 provides more "practical" results, whatever that means.
  
-Another AI engine was absolutely and without any doubt in favor of 1023. After I insisted that 1024 would be a better option, it explained that the difference is subtle and provided a more detailed explanation. This same engine is do indoctrinated with 1023, that even after I asked it to summarize this article, it still insisted that this article considers 1023 as correct!!! +Another AI engine was absolutely and without any doubt in favor of 1023. After I insisted that 1024 would be a better option, it explained that the difference is subtle and provided a more detailed explanation. This same engine is so indoctrinated with 1023, that even after I asked it to summarize this very same article, it still insisted that this article considers 1023 as correct!!! 
  
 So, if our fellow colleagues of the future would like to be informed on our final verdict, would they consider that it is just a matter of personal opinion? At the time that scientists are arguing on quantum mechanics, how can we leave such a trivial issue without a clear and precise answer? So, if our fellow colleagues of the future would like to be informed on our final verdict, would they consider that it is just a matter of personal opinion? At the time that scientists are arguing on quantum mechanics, how can we leave such a trivial issue without a clear and precise answer?
Line 82: Line 82:
 ==== Any comments on the various arguments in the online discussions? ====  ==== Any comments on the various arguments in the online discussions? ==== 
  
-It seems that arguments regarding comparison of accuracy between the two methods are meaningless, when you try to compare different things. Of course there are issues to discuss about precision and resolutionbut it is pointless for this comparison.+Arguments regarding comparison of accuracy between the two methods are meaningless, when you try to compare different things. Would it be logical to say that 1 Kg is 999 grams, because the difference is very small? Or, would it be logical to say that we make a personal choice to select 1000 grams because it provides more accurate results to the calculations compared to 999 grams? Absolutely not. **This is not a matter of personal opinion**. It is a waste of brain power to discuss about accuracy and precisionwhen the approach is faulty by inception  
  
-Alsofor the "practicality" of some decisionswe should understand the controlling mechanisms, regardless if it is a device or a business process. It is not correct to make an non-educated judgement, because it would not be possible to predict how the system will behave in various unforeseen circumstances.+Yes, of course there are cases where we take decisions to exclude parameters that have a small incluence on our calculations. You will not be crazy to include the Special Theory of Relativity when you design a tachometer for your kid's bicycle. We only take shortcuts when we understand the controlling mechanisms, regardless if it is a device or a business process. The whole point of the simplification is to make things easier to implement, having defined the acceptable error that this simplification will cause.
  
-Induced errors should always be taken into account.  I am certain that most people complaining about getting "bad" readings from an ADC are experiencing problems with unstable power supplies, missing accurate voltage references, bad decoupling, crosstalk, stray inductance and capacitance, as well as several other causes of error lurking in the implementation of an electronic circuit. The ATMega328 manual itself provides several information on how to disable internal MCU functions in order to minimize the noise that would alter the readings of the ADC. Also, there is currently a lot of both scientific and practical/experimental documentation on the design of the cabling and PCB traces. Building a circuit that faces the hardness of the real world goes way beyond writing some lines of code.+Induced errors should always be taken into account.  I am certain that most people complaining about getting "bad" readings from an ADC, which I mentioned as "haters" above, are experiencing problems with unstable power supplies, missing accurate voltage references, bad decoupling, crosstalk, stray inductance and capacitance, as well as several other causes of error lurking in the implementation of an electronic circuit. The ATMega328 manual itself provides several information on how to disable internal MCU functions in order to minimize the noise that would alter the readings of the ADC. Also, there is currently online a lot of both scientific and practical/experimental documentation on the design of the cabling and PCB traces. Building a circuit that faces the hardness of the real world goes way beyond writing some lines of code and consider that the circuit will behave exactly as a well-mannered and predictable software.
  
 ====  Is it wrong to use 1023? ====  ====  Is it wrong to use 1023? ==== 
arduino/divide-by-1023-or-1024.1750493840.txt.gz · Last modified: 2025/06/21 11:17 by Ilias Iliopoulos

Except where otherwise noted, content on this wiki is licensed under the following license: Private License