## Recommended Posts

Hi All,

I have connected the A3 analog pin direcly to the ground pin on the launchpad (rev v1.5 msp340g2553).

I then ran the Energia example "AnalogReadSerial".

I expected a constant stream of zeros on the serial monitor as the analog input was tied to ground.

Instead I got a stream of zeros with occasional ones.

0

0

0

1

0

0

1

0

0

0

Is this expected?

Thanks

Greg

##### Share on other sites

Short answer: yes. You will notice the same behaviour if you tie the pin to vcc. Just do some averaging of lets say 10 values and you will get much smoother results.

##### Share on other sites

With a 10 bit ADC, you have 1024 possible values. Using 3.3V as a reference, you end up with 3.3 / 1024 = 0.003v resolution. So 3 thousandths of a volt is the difference between 0 and 1 from the ADC. With 12 and 14 bit ADC, the difference between 0 and 1 from the ADC are 0.0008 and 0.0002v, respectively. Your hand passing near a wire will likely induce more voltage than that. Also, a little ripple in the supply voltage can often cause a bigger variation than that when sampling. So take note of the datasheet for the chip in question as they'll often list ADC accuracy in some manner such a 2 LSB- least significant bit. This means natural variations or fluctuations within the chip itself will reduce the accuracy by that much. In the case of 2 LSB, that means you could ignore those two bits because they are basically inseparable "noise" in the sample.

However, as @@yosh mentioned, oversampling, taking more than one sample and averaging the readings, reduces the amount of noise. Have to be careful though because too much oversampling might cause you to miss important signals.

Some people might simply take a reading and store it, then on each successive reading, add that to the stored value and divide by two, then store that value. Others might take some number of readings, add them together and average those. Some will have an array of the last X number of readings which are averaged and as a new one comes in, the oldest one goes out.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×
• Blog

• #### Activity

×
• Create New...