Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Wierd Analog to Digital Problem with MK20DX256VLH7

  1. #1

    Wierd Analog to Digital Problem with MK20DX256VLH7

    I have the analog section set to 10 bits, but something strange is happening that I can't explain.

    I have an analog input that I set to give an output via USB to approximately 2048. Now there is some noise at the input, so the output dithers about 5 counts.

    However, after running for a period of time I see a significant jump where the output is 2303 (0x8FF) or 1792 (0x700). The input noise isn't the issue. The jump is 256 counts.

    That tells me that a most significant bit is either getting set or cleared when it shouldn't. At least that is how it manifests itself.

    I thought the A to D was on a 16-bit data buss or is it 8 bits and the processor does multiple reads to get the data?

    I can see the latter case as a possibility if the conversion takes place somehow between a read of the least significant byte and the most significant byte and if the input transitions from 2047 to 2048 (or vice versa).

    Not saying that is what is happening, but it appears that way. Anyone has an idea why this happens?

    Main.cpp included:
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    1,084
    Generic advice - keep simplifying the software until the problem goes away. So in this case, down to a single channel with no averaging.

  3. #3
    Quote Originally Posted by jonr View Post
    Generic advice - keep simplifying the software until the problem goes away. So in this case, down to a single channel with no averaging.
    Thanks for the reply. I'm having doubts it's the software being the culprit. I have two boards each connected via USB on a different Mac. One of the two boards consistently had this 255 count jump with one of the A2D channels, but the other did not.

    So, this morning I swapped the two boards between the two Macs. Oddly enough, I got the same error, but on the board that was working fine. In other words, the problem stayed with the one Mac. It seems one of the two Macs may be the problem or the USB port extender is causing the issue.

    So, the Teensy may be off the hook.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •