Butterfly AREF

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have been trying to figure out the Vref for the voltage reading, but my results do not match the default application.

What is the PF3 output voltage and its output impedance? Am I doing somethin else wrong?

My formula are (8-bit conversion):

LDR-branch:
Rl=3300*(1+adc_value/(adc_value+0xff))
NTC-branch:
Rn=100000*(1+adc_value/(adc_value+0xff))
Both branches in parallel:
R=(Rl*Rn)/(rl+Rn)
PF3 output 3V
PF3 impedance (resistance)
Vcc=2.7V, Vout 2.3V, I=-5mA
(2.7 -2.3)/0.005 = 58 Ohm

My calculations give:
adc_valLDR adc_valNTC AREF
0 0 2.947
255 0 2.964
0 255 2.947
255 255 2.964

In the BF application code:

        ...
        // Find Vref
        for (i=0; i<=22; i++)
        {
            // mt if (ADCresult <= LIGHT_ADC[i])
			if (ADCresult <= pgm_read_word(&LIGHT_ADC[i]))
            {
                break;
            }
        }
        if(!i)              // if it's very bright
            Vref = 2.815;
        else if(i > 21)
            Vref = 2.942;   // if it's totally dark
        else
            // mt: Vref = LIGHT_VOLTAGE[i];   
			// mt using helper from pgmspacehlp.h - new code
			Vref = pgm_read_float_hlp(&LIGHT_VOLTAGE[i]);
 

I also tried some other interpretations of the output voltages and output impedances of PF3, but didn´t get very close. The default application has much wider variation of the AREF-voltage than I can get.

[edit]:
I know the default application is concerned only with LDR and considers the effect of NTC to AREF-voltage as negligible, but my LDR calculations still don´t match.

Debugging is for sissies and delivery for surgeons. Real men do demonstration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please, anyone?

Debugging is for sissies and delivery for surgeons. Real men do demonstration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Butterfly's measurement of the two variable resistor sensors can be confusing. It doesn't help that the nomenclature for the ADC inputs is confusing also.

By the way, the newer Butterfly's don't come with the cadmium sulfide light sensor as cadmium can't be used in Europe. But you can add one.

The Butterfly isn't measuring absolute voltages and so there is no known voltage, a.k.a. reference voltage, used.

Here's the way I look at it. There are three connections to a single ended ADC. Top, middle and bottom, where bottom is ground. The ADC measures the ratio of the middle voltage to the top voltage, ground referenced of course.

The light sensor and the temperature sensor are connected in series with known resistors to form a voltage divider. The ratio of the middle voltage to the top voltage is equal to the ratio of the lower resistor to the sum of the two resistors. So the value of the sensor resistance can be calculated.

The ADC formula is adc_count / max_count = middle_voltage / top_voltage. On the Butterfly, middle_voltage / top_voltage = bottom_resistor / (bottom_resistor + top_resistor).

I think of ADC operation this way. The ADC divides the top voltage into many equal sized segments. It then determines which segment best matches the voltage at the middle input. It numbers the segments from zero to max and the result is the segment number that matches. In the case of 10 bit ADCs, there are 1024 segments.

If you knew one voltage, you could calculate the other. But we aren't interested in voltages here. When two resistors are connected in series to form a voltage divider, if you know one resistance, you can calculate the other. That's what the Butterfly does. Vref has no meaning here. Instead we have Rref.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With the voltage input (max 5V) I need to know the AREF to have some kind of accuracy. The default BF application suggest that the effect of NTC is negligible but the LDR does affect it noticeably. The AREF is connected to PF3 and NTC-branch (100k + NTC) and LDR branch (3300 + LDR) are parallelly connected to the PF3. I think I can calculate the total resistance of the LDR- and NTC-branches connected in parallel, but what is the output voltage and the impedance?

Debugging is for sissies and delivery for surgeons. Real men do demonstration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think knowing the AREF voltage will help anything. It's irrelevant. It's simply the voltage at the top of the voltage divider.

The ratio of the voltage at the middle of the divider over the voltage at the top will be the ratio of the bottom resistor over the sum of both resistors. It doesn't matter if the voltage at the top is 1 millivolt or a thousand volts.

Similarly the adc count over the max count (1023) will be this ratio also. Again it doesn't matter what the voltage at the top is.

The accuracy of the reading only depends on the accuracy of the ADC. The accuracy of the light (or temperature) measurement is only dependent on this and also the accuracy of it's "transfer characteristic". That is the accuracy of the sensor resistance as a function of light intensity or temperature.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well if you want to get very precise, the current flowing through the sensors might influence the resistance slightly. For instance current flowing through the thermistor would heat it up slightly. But unless the current was fairly high, it probably wouldn't affect the temperature of the thermistor much because it's soldered to the board, which acts as a heat sink.

Anyway any such error correction could probably be applied by guessing at the voltage. It would be the supply voltage less any drop in the PF3 (or whatever) pin. You could measure that with a voltmeter.

By the way the supply voltage of the Butterfly will vary a little bit depending on what the current draw is at the moment because of the voltage drop through the Schottky diode that is in series with the supply.

And that assumes the battery or whatever power supply is used has a low internal resistance, which it may not have.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The other thing that limits accuracy is the precision of the "reference" resistor in series with the sensor. The user guide doesn't specify what the precision of the resistor is. In the old days, the common through hole resistors were +- 5%. I'm not very familiar with chip resistors but I have noticed that 1% chip resistors are common and cheap.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It looks like I really need to find out the AREF. Othewise the error exceeds 20% @ 5V.

The picture of the connection is attached. There are also capacitors (100nF) and a protective zener that are not included in the picture.

It is the open end of 1.5M resistor where the voltage to be measured is to be applied.

Attachment(s): 

Debugging is for sissies and delivery for surgeons. Real men do demonstration.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now I understand. You aren't talking about the LDR and NTC.

You mention a zener. If you really have a zener on the board, you must have an old board. Otherwise it's a vaporware zener that is only on the schematic.

I haven't used the voltage measuring capability of the Butterfly. I don't know how it's done. The user guide says the accuracy is about 0.1 volt. Pretty shabby. I guess PF3 isn't used for this measurement and should be tri-stated. (set as input with no pullup).

I presume it uses the 1.1 volt bandgap as a reference. I don't remember the details of the code.

You can measure the bandgap voltage with a digital voltmeter. To do this you set up the ADC to connect the bandgap as the "top" or reference input. Then I think you need to start a conversion to get the voltage to appear on the AREF pin. As you know, you don't need to put the probe right on the AREF pin, as this thing runs all over the board.

I always measure the bandgap as being right on the money. Something like 1.105 volts, but others have said theirs is way off. I should mention that the boards I measured probably didn't have the LDR mounted, and this would considerably reduce the current draw on the bandgap.

For whatever it's worth, the Butterfly (and other Atmegss) can measure it's supply voltage. The ADC has the capability of connecting AVCC to it's "top" or "AREF" input, and connecting the bandgap voltage to it's "middle" or "input" input. Then do a conversion. Just keep in mind that the connections are reversed from the usual way of measuring voltages. You know what the voltage is at the "middle" input, so you do the math to find the voltage at the "top" (AREF) input.

I don't know if this helps, but it's all I know.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it looks like the LDR is drawing down the bandgap voltage, you could remove it or try to block as much light as you can from hitting it. In pitch darkness, it will have a resistance of well over a million ohms. I don't know if you can block enough light from it with a piece of tape, but you can try.