2
\$\begingroup\$

I have been reading through the datasheet for the ATTiny84A, and noticed that it has both an analog comparator and the ability to use its ADC in unipolar or bipolar differential mode. From what I can tell, the main difference is that the comparator is faster, but it can only tell whether signals differ.

  • Are there any other benefits the comparator has over the ADC?
  • Are there situations in which one would be more accurate than the other? Will the either the comparator of ADC be more sensitive to small differences in input?
  • One use case mentioned for the bipolar differential mode of the ADC was to determine the polarity of a signal. Wouldn't the comparator be better suited for this?
\$\endgroup\$
  • 1
    \$\begingroup\$ The 30,000ft. answer is so that you can produce two different products with the same part. \$\endgroup\$ – Ignacio Vazquez-Abrams May 7 '16 at 7:46
5
\$\begingroup\$

Speed

Since the comparator is always active and is effectively an analog circuit it can generate an output at any time regardless of the current CPU task. This can be used to generate an interrupt for a near instantaneous response to the input crossing the threshold.

The ADC, on the other hand, has a settling time, conversion time, is usually multiplexed, has to be polled periodically and requires code. All of these make it a much slower solution to the comparator.

Comparator works in sleep mode

The device can be configured to wake on comparator changing state. See page 128 of the datasheet. There is a power penalty as the reference voltage and comparator have to be powered on. I don't think there is a comparable wake-up for ADC.

Are there situations in which one would be more accurate than the other?

Yes. If the reference signal is analog the threshold doesn't have to be a discrete digital step value. (This may be masked by differences in the two inputs so it might not be that relevant.)

Will the either the comparator of ADC be more sensitive to small differences in input?

As above. It depends on the quality of the comparator.

Bipolar ADC

One use case mentioned for the bipolar differential mode of the ADC was to determine the polarity of a signal. Wouldn't the comparator be better suited for this?

I had to do some reading on this. I think your interpretation of bipolar might be incorrect. The chip has a unipolar supply of 1.8 – 5.5 V so it would be unlikely to be able to accept negative voltages on the ADC or comparator. This is confirmed by section 20.1.

enter image description here

Figure 1. Absolute maximum ratings.

Instead, bipolar means that the ADC can carry out a measurement with respect to another positive reference and the result can be positive (if input > ref.) or negative (if input < ref.) with respect to the reference.

enter image description here

Figure 2. The ADC schematic on page 133.

Figure 2 shows the innards. The positive input MUX (multiplexor) (1) determines which input is fed to the gain amplifier (3). The negative input MUX (2) is fed to the other input of the gain amplifier. This stage is programmable and feeds to the normal ADC (4) via the single ended / differential selection.

\$\endgroup\$
  • \$\begingroup\$ Now this is how you write answer to such a question. I have a lot to learn from you guys! +1 Takes time and effort to read the datasheet and requires expertise to answer a question in such manner. \$\endgroup\$ – Jasser May 7 '16 at 18:20
  • 1
    \$\begingroup\$ Thanks for the kind comment. My approach to learning a new topic is often to speed-read through a datasheet such as this one - even if it's only the headings and the diagrams. In this way I get a grasp of what the capability is and maybe learn some new words (but not necessarily what they mean). I've never used the device in question and your question made me look it up. Other than that it's a matter of addressing each of your points in turn. I'll readily agree that a 286 page datasheet is quite daunting. \$\endgroup\$ – Transistor May 7 '16 at 19:09
  • \$\begingroup\$ @transistor, thanks for the fast and detailed response. The polarity check part I was wondering about was wondering about is in section 16.11.3 on p143. Also, I noticed that you emphasized the word "comparitor," possibly due to my spelling. According to the datasheet, it is "comparator." \$\endgroup\$ – Caleb Reister May 7 '16 at 20:25
  • \$\begingroup\$ "Comparator" is correct. I think I based my spelling on "comparison" and maybe your typo reinforced it. Are you satisfied that you understand the bipolar mode now or do you require any further clarification? \$\endgroup\$ – Transistor May 7 '16 at 20:38
0
\$\begingroup\$

Comparatpr compares two voltage levels Va and Vb and outputs a digital signal Va>Vb. ADC converts an anaolg signal level to a digital number rapresenting a value. Comparator and ADC have nothing in common.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.