I'm using ADC inside CC2430 MCU.
The ADC present the result (= digital voltage) over 2 bytes - ADCH, ADCL.
(ADCL uses only 6 MSB bits, the 2 LSB bits are always read 0).
I chose VREF = 3.3V, and entered to ADC a 1.5V battery.
When i chose 12-bit resolution, the ADC showed 15124.
When i chose 7-bits resolution, the ADC showed 15296
Now when i do
[(15124 / 4) / 2^13] * 3.3V = 1.523V
[(15296 / 4) / 2^13] * 3.3V = 1.54V
( the " / 4 " is because ADCL's 2 LSB bits are always read 0).
I have 2 questions please:
1. Did i calculate the analog input correctly?
2. Is there a minimal analog input, that below it the ADC starts being less accurate? how is it in general?
1. Regarding (-VREF), there's a problem which i dont understand.
According to datasheet : "For single ended configuration the result is always positive. This is because the result is the difference between ground and input signal which is always possitively signed".
On the other hand, when i short the ADC single-ended input to ground, I receive: 65496, which is a negative number (It must be negative becuase its larger then [(2^13) - 1] which is the largest possitive number the ADC presents over ADCH, ADCL (in 2's complement).
What do you think about it?
2. How do you defined counts?
3. I think i have a mistake, it should be
V_ADC_analog = V_ADC_digital_in_decimal / 4 / (2^13 -1) * 3.3V,
Right?
When i used circuit A, i received V_analog = 0.709V, which is around 5% error so its acceptable.
But when i used circuit B, i recived 0.7V which is weird because it says that the current in the circuit was: (1.5V - 0.7V) / 51 = 15mA, and according to datasheet, VF = 0.7V @ 45mA, which is large error.
What is the problem then with circuit B?
If you are only working with +V input signals, I would set the -Vref to 0V.
Set the +Vref to +3.3V [thats internal.?]
The datasheet says that for 14bit operation the MSBit is the SIGN bit.
So for always positive V input signals this bit will be '0'.
That means the ADCH and ADCL registers will have a maximum count of 8192,
which is 13bit resolution.
The sheet also states that the 'count' [ thats the register value after an A2D conversion has taken place] will be:
ADCH bits 7 to 0 are the highest bits of the 'count' and ADCL has the lowest bits of the 'count'... the ADCL register bits 7 to 2 [6] are the value and the least two bits 1,0 are always '0'.
I would do two right shifts of the count in regs ADCH and ADCL, this will divide the count by 4.
You now have the 'count' normalised [right justified] in ADCH and ADCL.
To convert the 'count to a 'voltage' use this formula:
Vinp[signal] = (3.3V) * (count/8192)
For example: say the count was 4096
Vinp = 3.3V * (4096/8192) = +1.65V
I'll reply to the other questions in a later post.
4. It said in the datasheet:
What does it mean "input resistance, signal"?
5.
When i used circuit A, i received V_analog = 0.709V, which is around 5% error so its acceptable.
But when i used circuit B, i recived 0.7V which is weird because it says that the current in the circuit was: (1.5V - 0.7V) / 51 = 15mA, and according to datasheet, VF = 0.7V @ 45mA, which is large error.
What is the problem then with circuit B?
hi,
Looking at the datasheet, the 'input resistance' is the equivalent resistance to 0V that the Vsource is connected to.... compare it to a fixed resistor of 197K connected from the adc input pin to 0V.
The reason for specifying the Rinput is to enable you to calculate what effect this resistance will have on your readings.
for example assume that you connected a 1.5V battery via a series resistor to the adc inpout, Let this resistor be say 197K,,, if you now measured with a DVM the voltage on the adc pin it would only be 0.75V...so your adc conversion 'count' would wrong.
It will cause other errors in the readings, due to the charge time/current required by the internal adc cap.
On PIC's it recommended that you keep the resistance of the input signal voltage less than 10K.
I dont have an option to set (-VREF) in ADC, only to set (VREF).
It is said that for single-ended input pin, the result is always possitive, thats why i was surprised to recevie 65,435 in the the registers (when i shorted ADC input to ground), becasue it represents a negative number in 2's complement representation (It means that the MSB bit in ADCH is '1').
You know why it happend?
I have a 3.3V that i supply to the MCU with external regulator, and I have an internal 1.25V regulator of MCU which I dont think it uses for any other purpose.
Will it be wrong to use the 1.25V as VREF instead of the 3.3V?
for example assume that you connected a 1.5V battery via a series resistor to the adc inpout, Let this resistor be say 197K,,, if you now measured with a DVM the voltage on the adc pin it would only be 0.75V...so your adc conversion 'count' would wrong.
In this case, both the FLUKE and the ADC would show 0.75V.
Why do you say that the FLUKE wont show 0.75V?
(after enough time for its internal cap. to charge, it should show 0.75V).
alphadog, you are trying to measure a voltage that is greater than Vref and this is yielding weird results in my opinion.
Try using a voltage divider connected to the battery or Vdd, in order to generate a voltage that is less than Vref.
I am not familiar with your mcu, but I noticed that its ADC has been downgraded to 12-bit. So when you read the results (2 bytes) ignore the two least significant bits. MSB should be 0 in single-ended mode. Then you have a 11-bit value (Vadc) and the analog voltage is Vadc / (2^11 - 1) * 1.25 (alternative formula with 12 bits could be used too)
BTW, the latest datasheet available on TI website is rev 2.1
It is said that for single-ended input pin, the result is always possitive, thats why i was surprised to recevie 65,435 in the the registers (when i shorted ADC input to ground), becasue it represents a negative number in 2's complement representation (It means that the MSB bit in ADCH is '1').
You know why it happend?
What was connected to the ADC input when this occurred.?
I have a 3.3V that i supply to the MCU with external regulator, and I have an internal 1.25V regulator of MCU which I dont think it uses for any other purpose.
Will it be wrong to use the 1.25V as VREF instead of the 3.3V?
No, it wont be wrong to use a 1.25Vref.
The Vref is often chosen to suit the scaling of the input voltage being converted.
eg: if you had a sensor which gave an outout of 0v thru 1.5v, it would logical to use a 1.25Vref.
if the sensor had say an output range of 2.5v, I would use the Vint ref of 2.5v
I'll reply to the other questions in a later post.
Dont you mean 2^(13) - 1 = 8191?
In this case, both the FLUKE and the ADC would show 0.75V.
Why do you say that the FLUKE wont show 0.75V?
(after enough time for its internal cap. to charge, it should show 0.75V).
GND was connected to ADC input.
Once I connected a wire from ADC input to GND, and the other time i configurated the ADC input to be the internal GND of MCU.
Received in both a very small negative number.
No, it wont be wrong to use a 1.25Vref.
The Vref is often chosen to suit the scaling of the input voltage being converted.
eg: if you had a sensor which gave an outout of 0v thru 1.5v, it would logical to use a 1.25Vref.
if the sensor had say an output range of 2.5v, I would use the Vint ref of 2.5v
So you're saying that for 12-bit resolution, bits 3, 2 will always be zero?
Because i checked it now, and when i entered VREF i received (ADCH,ADCL) = 32696, and
32696 = 0111-1111-1010-1000
and as you can see, bit 3 is not zero, so doesnt it mean that bit 3 does play a role ?
If you keep the resistance of the voltage source less than 10K it should be OK.
example: say you had a 5V voltage you wanted to convert A2D.
To reduce it to the 3.3V max input you could use say 0.66 ratio resistance divider.
If the bottom resistor was say 6600R then the top resistor would be 3400R, so the input rsesistance would be less than 10K
If you went OTT and made the top one 66K and the botton 34K... thats greater than 10K.. so the conversion could be inaccuarte.
Regarding the ADC capacitance,
Is the capacitor being charged only during the conversion?
Meaning when conversions arent being executed, the Vinp that you skected is not connected to the external circuit?
Regarding the ADC capacitance,
Is the capacitor being charged only during the conversion?
Meaning when conversions arent being executed, the Vinp that you skected is not connected to the external circuit?