if I had a signal that was +-5V, would I plug +5V into Vref, and -5V into AGND?
nooooooooooooooooooooooooo
You can only have these voltages between the main power rails.
AGND should be connected to ground and Vref to a voltage that is equal to or less than the power rails (+5v).
What ever voltage you chose that will be the voltage you get the maximum signal from. However if it is too low you get noise on the least significant bits.
it's OK to connect Vref on the chip to the power rail +5V?
Yes it's ok to do this. It's not the best thing you can do but it is what is done about 90% of the time. The down side is that any voltage you measure is referenced to the actual voltage of your supply. This might not be (will not be) exactly 5V.
Everything you have seen is consistent and understandable. With nothing connected the input is floating, that is it is subject to noise which is not very big and so the noise on the un connected input is bigger so you get the maximum value.
and I don't have anything connected to the pin I'm sampling
With nothing connected to an input all bets are off and there is no predicting what you will see.
I just did that and it seems to be spitting out subtle fluctuations representing noise of some sort.
That would be noise
With a 10-bit ADC (1024 steps) each step represents 5V/1024 --> 4.88mV. That kind of voltage is easily induced by fluorescent lights, microwave ovens, random galactic emissions, etc.
Putting a capacitor on VREF helps, as does isolating VREF from the supply voltage using an LC filter. See Section 23.6.2 of the ATmega328 datasheet:
As important as keeping VREF constant is conditioning the actual sensor input. Where is it going and how are you getting it to your board? The shorter the wire the better. Can you send it over twisted-pair wire in which one wire is GND?
--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons
What would be the preferred method for holding a constant Vref?
The best way is to use a stable source of voltage for Vref. There are a great number of voltage reference chips out there so one of those would be best. If you can't manage that then a zener diode, resistor and capacitor would be better than nothing.
Yes a capacitor would help, also a capacitor across the supply of the chip. I would put a 20R (or so) to the +5v and Vref and then another capacitor across the Vref input.
If you have 12 bits spread over 5V then you have a step size of 1.22 mV, this is quite small and I doubt you will get that level of quietness on a solder-less breadboard like you have.
This is called decoupling and it is a good idea anyway.
The main issue however is that you do not know your voltage....
When you use an external supply, your voltage is around 5.02 volts.
When you use a PC USB port it will be around 4.8 V. When you connect to a notebook it can be even lower.
So make a test:
Connect a 1.5 volts battery to the ADC input and take a reading. Then connect an external power supply to your Arduino. The reading will now be around 5% lower!
However there are (simple) means to make corrections for this...
Ok, so something like this for a voltage reference:
Although, I don't see where to go online to find it.
I'll be doing away with the breadboard when I'm done assembling & coding, and the sensor I'll be trying out has a very clean, precise output.
And I really need to know where zero is in a bi-directional signal, so it looks like this is the best way to go.
And I really need to know where zero is in a bi-directional signal, so it looks like this is the best way to go
But how do you want to handle bi-directional signals?
If you offset them to 1/2 of supply voltage than it is not necessary at all to know the supply voltage for zero detection....
But how do you want to handle bi-directional signals?
If you offset them to 1/2 of supply voltage than it is not necessary at all to know the supply voltage for zero detection....
What I meant was that I have a 0 to 5 volt signal that is centered around 2.5 volts. Less than 2.5 volts represent one direction and greater is the other direction. It's a flow sensor, and I need to know when the flow changes direction fairly precisely.
You have to supply it a voltage of btwn 7 & 16 Volts, and it will output the signal as I mentioned.
If the sensor was ratiometric (and +5V was sufficient) would it be reasonable to use the same power rails and assume that whatever fluctuations there were in power would be equally represented in the sensor and in the ADC?
If precision is important, am I better off supplying power to low-power sensors (~2mA) with a voltage reference chip? Or is that silly cause they aren't meant to supply any current. Is a capacitor better for some current draw?
If the sensor was ratiometric (and +5V was sufficient) would it be reasonable to use the same power rails and assume that whatever fluctuations there were in power would be equally represented in the sensor and in the ADC?
Brilliant! That was my hope to end all troubles
But it seems the sensor derives an internal 5 volt from the > 7 volts supply (the value of 7 volts is tell-taling..). This will be hardly done by a very high precision (?). So the 2.5 Volts zero level has to be questioned wrt its accuracy. Maybe you have to calibrate for this "zero" level.
It will make no sense to measure something with 12 bit resolution which has an error of 0.5%...