Post Go back to editing

Category: Software

Using that formula gives 11,252,238.3986163132

How do I calculate it, but does 1510.24987 come out?

Parents
• I've had the same issue today and found the solution. I started by calculating the error factor  \frac{1510.24}{11252238 }=0.000134216... . At first this seems weirdly similar to (10e-7 * TARGET_AVCC), but that was a coincidence. After some educated guessing I found the actual solution: The equation for TARGET_WCC is somehow missing a scaling factor to obtain µW/code from (µV/code * µA/code). Multiplying with (2^27/10^11) yields the exact value from the datasheet. What I cannot explain is that it seems to be off by a factor of 10. If you convert both TARGET_AICC and TARGET_AVCC to A/code and V/code by dividing each input by 10^9 (i.e. reversing what they did in the datasheet for visual purposes and thus using the actual value produced by their respective equations), you should end up with a value in Watts. Applying the true scaling factor (divide by 2^27) and additionally scaling down by 10^6 to obtain µW yields 151.024987 µW/Code and not 1510.24987. So something is still off, but this should be a start.

• I just look thru to document change list and found this. Will try to get this updated it can take a while. You found the exact thing that was wrong. Sorry for the inconvenience.

Equation incorrect, should be:

TARGET_WCC = TARGET_AICC * TARGET_AVCC * 2^27 * (1+APGAIN/2^27)

Dave

• I just look thru to document change list and found this. Will try to get this updated it can take a while. You found the exact thing that was wrong. Sorry for the inconvenience.

Equation incorrect, should be:

TARGET_WCC = TARGET_AICC * TARGET_AVCC * 2^27 * (1+APGAIN/2^27)

Dave

Children
• I investigated a bit further and can conclude that the document is just put together very badly. I also didn't like the magic value of 2^27, so I continued until I was able to derive all of this from first principles.

The issue is considering TARGET_AICC and TARGET_AVCC in their Unit/code values. Instead use the correct Full Scale Codes from Table 5. directly:

TARGET_AICC should afterwards be scaled down by 52725703
TARGET_AVCC by 26362852 and
TARGET_WCC by 10356306

Here is a short demonstration in python how I derived it from the beginning:

v_nom = 240 # Volts
i_max = 10 # Amperes
r_shunt = 0.001 # Ohms
r_big = 10e6 # Ohms
r_small = 1000 # Ohms
pga_gain = 16 # Whatever setting you use
ai_headroom = 1 / (pga_gain * r_shunt * i_max * 2**.5)
v_headroom  = (r_big / r_small + 1) * .5 / (v_nom * 2**.5)
aicc = i_max * ai_headroom # max measurable value in Amperes
avcc = v_nom * v_headroom # max measurable value in Volts
wcc = target_aicc * target_avcc # max measurable value in Watts
target_aicc = aicc / 52725703
target_avcc = avcc / 26362852
target_wcc = wcc / 10356306