Pages

Wednesday, May 29, 2013

MCP3201 debugging notes



































The MCP3208 related bug reminds me something similar when playing with MCP3201.  In developing the function TestMcp320101, I kept on patching and patching and forgot where and why I did the patching for.  And in the statement to get adcDecimalValue, I multiply adcOutPutDoubleByteList by 2 ** 7.   I vaguely remember I first try 2 ** 8, but found one order too high, so I changed it to 2 ** 7 and found it OK.  But I did not go deep if indeed I should use 2 ** 7.

The other big mistake is that I casually assume that I assume the most significant 4 bits sit in the least significant part of the first read in byte.  I also assume that the most significant part of the byte is zero.  But there is no reason to assume that!   I think that must be the reason that from time to time the function does not work and give a big and wrong analog voltage.

So I should do the same thing to make sure the indeterministic part should be cropped away.

.END

No comments:

Post a Comment