Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Comparator or AD module?

Status
Not open for further replies.

Suraj143

Active Member
I need to light up 3LEDs when DC voltage is 3V=RED,4V=YELLOW,5V=GREEN.

Whats the best method to do this? Using a comparator or an AD module? Using 12F675.
 
Last edited:
A comparator is better. It's operates faster and is simpler to wire up and work with if you are using discrete components. You can do what you describe very simply with just comparators and no MCU. You just drive the LEDs directly with the comparator output (and current limiting resistor), or use the comparator output to control a transistor switch that drives the LED (and current limiting resistor).

THe only advantage in using an ADC for this is that:
1. If you need the MCU to do other things and the MCU has an ADC built-in that you can spare but no built-in comparator. It's already there, you might as well use it rather than adding on a discrete comparator.
2. If you need to be able to variable threshold voltage, but this can also be done with comparators too...it's just a little bit messier if you are using discrete components since you need to add in a DAC for the voltage reference and the interface with the MCU. But some MCUs with built-in comparators also have built-in DACs to serve as a variable voltage reference for their comparators so in this case, the comparator is still better than the DAC.
3. You have way too many levels you have to measure. You need one comparator for every level you want to measure, whereas one ADC can measure many different levels.
 
Last edited:
As you have an ADC you may as well use it.

Mike.

...if he needs the MCU to be doing other things. If this is the only task of the MCU he should just use comparators and drop the MCU. YOu don't need MCUs for this task.
 
Oops sorry guys I missed a word.Comparator I mean PIC's buit in comparator module & not a separate comparator IC.

Whats better AD module or Comparator Module?
 
Last edited:
The problem with using the comparator is that there is only one and three voltages (levels) to monitor. With the ADC you can just let it run, go off and do something else and when you return it's got the reading ready.

It's not actually clear what Suraj wants,
Is it,
less than 3V =red
3V to 4V = yellow
greater than 4V = green

Mike.
 
The problem with using the comparator is that there is only one and three voltages (levels) to monitor. With the ADC you can just let it run, go off and do something else and when you return it's got the reading ready.

It's not actually clear what Suraj wants,
Is it,
less than 3V =red
3V to 4V = yellow
greater than 4V = green

Mike.

You have totally understood.Thats what I'm going to do.

Is it ok every time sampling?Is it good to the micro controller every time sampling?
 
Depending on the accuracy you require you could use the comparator with the internal reference voltage.

These are the values you get with the Vref in low range,
Code:
12	2.5
13	2.708333333
14	2.916666667
15	3.125
16	3.333333333
17	3.541666667
18	3.75
19	3.958333333
20	4.166666667
21	4.375

If more accuracy is required then there is no problem using the ADC repeatedly.

<edit> I hope your not trying to measure the pics supply voltage here.</edit>

Mike.
 
Last edited:
Ah, yeah, if only one LED is going to be on for each voltage range, then an internal ADC is much more convenient.

With comparators you would either need 2 comparators for each voltage range you want to detect since you now need to know if the voltage is between two thresholds, rather than just above or below one threshold. Or if you used one comparator per voltage threshold you would need either code or logic gates to interpret the output of the comparators for the voltage range. Either way, probably more work than just using an ADC.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top