Re: ADC glitches
OK sometimes there are "dybbuks" in the machine. I tried to increase Tad to some very large value, to no avail.
My math is good enough. But if I halt the debugger at the line where the result is read from the A/D, the values are somewhere from zero to some hundred LSB. The sampling time is of no importance, since the inputs are tied to separate ADC's. In other PIC devices I have used, if the inputs are tied to the ground, the result is always zero, or perhaps one.
And Ruben, floating point calculations are indeed reentrant. But that filtering, averaging thing seems very good. Perhaps the PIC32 are just too hitech - they are made to be super fast etc, so they perhaps are prone to errors.
But this story brought something good - I found that I didn't need this A/D approach at all. If it would have worked, I probably had been chasing a too complex solution. I firmly believe in the ghost in the machine. I have experienced so much strange stuff over the years that has no rational explanation. And those bugs, glitches etc, always appear when I'm mentally unbalanced or impatient, etc.
But I also believe that those ghosts only appears when the developer believes in them. A calm, mentally stable , rational, developer usually are left alone from those trolls - they know that it's no use. Even if they produces some far fetched problems, the developer still thinks it has a rational explanation. But since I believe in ghosts, they take the opportunity to make a mess from time to time. But this time they actually were on my side - they helped me to realise that I chased an overly complex solution.
Well this was a real OOT - out of topic.