Comparator Follower Circuit

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

Hi All,

 

I have a requirement but i don't know how to implement it in circuit form.

 

I require a circuit to switch on at a certain voltage and then follow that rising voltage.

 

So i essentially what a comparator to turn on at 1V and then the output to follow the input from 1V to 5V.

 

In electronics terms what is this circuit called?

 

Many thanks,

 

Tuurbo46

 

 

 

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

I'm not clear what you want.

 

Is it (in pseudo-code):

IF Vin < threshold 
   THEN Vout = 0
   ELSE Vout = Vin
   

If so, I think a comparator and an analogue switch could do that ... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

try term clamp (clamping) or limiter, especially if you want the min voltage to be 1V rather than zero.

Your description is not fully clear.

If the input is 0.35V, do you want 1V out or 0V out???   (a circuit to switch on at a certain voltage ???)

If 0V, this is a form of a stiction simulation circuit

 

You will likely be using opamps, not comparators for this!!

When in the dark remember-the future looks brighter than ever.

Last Edited: Wed. Jun 13, 2018 - 03:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
try term clamp (clamping) or limiter

I think that's the opposite of what he wants!

 

I think he effectively wants what sound techs would call a noise gate.

 

See my pseudocode.

 

Your description is not fully clear

agreed.

 

As ever, a diagram would be a far clearer way to express this - Output vs Input ...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jun 13, 2018 - 03:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

More details are below:

 

* 0 - 1V (OFF)

 

* 1 - 5V (ON) and the output follows the input

 

I think i need a comparator to turn on at 1V, then Vout to follow the Vin upto 5V.  I am struggling on the Vout following Vin part upto 5V.

 

Thanks,

 

Tuurbo46.

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

 

If the input is 0.35V, do you want 1V out or 0V out???   (a circuit to switch on at a certain voltage ???)

 

 

* 0 - 1V (OFF)....means nothing,  what voltage do you wanyt in OFF condition?

 

For clarity draw a graph of desired output voltage vs input voltage, your description is lacking

I think he effectively wants what sound techs would call a noise gate.

could be he wants a squelch circuit

When in the dark remember-the future looks brighter than ever.

Last Edited: Wed. Jun 13, 2018 - 03:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As avrcandies says, that really doesn't clarify anything!

 

So what about the idea of a comparator (to determine the switching point) and an analogue switch ... ?

 

 

EDIT

 

"analogue switch" could, perhaps, be a simple relay ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Jun 13, 2018 - 03:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
could be he wants a squelch circuit

indeed.

 

https://en.wikipedia.org/wiki/Squelch

 

https://en.wikipedia.org/wiki/Noise_gate

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi again,

 

Sorry I understand now:

 

* When the input is (0 - 1V), the output is (0V OFF)

 

* When the input is (1 - 5V) the output is (1 - 5V ON) and the output follows the input

 

Yes an analogue switch sounds good, but i cant cant think of a circuit.  Do you mean like a relay op-amp configuration?

 

Thanks,

 

Tuurbo46

 

 

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

Note that "off" and "0V" are not synonymous!

 

"Off" often means "disconnected" - ie, floating ...

 

Tuurbo46 wrote:
Do you mean like a relay op-amp configuration?

See my edit to #7

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tuurbo46 wrote:
Do you mean like a relay op-amp configuration?

 

Yes.  That would be the 'Easy' way to go.

 

Simply use a voltage comparator like an LM393(old yes, but it will work).  It's  dual comparator so  use one of the two to control the relay, use the other for logic signaling.  

 

Vref = 1v.

 

Vin to the other terminal and also connect Vin to the COM of your normal open relay.

 

Connect your comparator output to one of the relay coils terminals, the other coil terminal to the coil drive voltage

 

When Vin rises above Vref the relay will fire as the comparator will sink current and energise the coil.  The other comparator will also fire for logic indication of the 1 volt and up being detected

 

The other side of the relay contacts will now output Vin as you wish.

 

Very simple.

 

Jim

 

EDIT:

Like this:

 

 

EDIT AGAIN:

If you want to be all fancy, you could eliminate the comparators for an 8pin AVR that has an ADC in it and use that to track the input and provide the relay control and the indicator output.  Nice thing about that is you can change your 'Reference' in software to anything between 0 and Vcc for the most part.  Just Food for thought

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?  - Lee "theusch"

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

Last Edited: Wed. Jun 13, 2018 - 05:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How fast must the output voltage follow the input voltage?

 

To take Jim's suggestion a step further, one could use an AVR with an ADC and a DAC, (e.g. XmegaE5, or perhaps the newer chips I'm not as familiar with), and in a tight loop just read the ADC input voltage and either output 0V or copy the input voltage to the output ADC.

 

Easy, one chip, and one can change the threshold, either via a Pot on another ADC input, or via software.

 

This setup would eliminate the mechanical contraption, (relay), and use less current than the relay option.

 

The micro could run on its internal RC Osc, and would not require an external Xtal unless you needed the increased speed.

 

JC

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

You can do it simple with just one comparator and one resistor. Comparator MUST have a open collector output like lm393. When Vi > Vref output transistor is closed so Vo will follow Vi.  Otherwise Vo is shorted to GND. However this circuit has some drawbacks like a input and output impedance is "R" and switching oscillations may occurs near Vi = Vref. R must be much larger that Vi internal impedance and much smaller then Vo impedance :)

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

DocJC wrote:
This setup would eliminate the mechanical contraption, (relay), and use less current than the relay option.

I only really suggested the relay as it might be something easier for the OP to grasp.

 

The original analogue switch suggestion does not have any mechanical contraption, (relay), and use less current than the relay option.

 

And is simpler than a microcontroller!

 

It remains unclear whether any (significant) current is to be drawn from the output of this circuit - which might weigh in a relay's favour ...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not hassling you over the relay, I'm just still perturbed at myself for doing my last PCB with a polarized relay, and having the coil voltage polarity backwards...

 

Easier is in the eyes of the beholder.

 

I don't have any true comparators, or analog switches, on hand, but I have tons of small micros available.

I'd have the ADC to DAC option up and running in far less time than ordering the above chips...

 

OP's choice, it is good to have options!

 

JC

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

It could be as simple as an LED. Below the forward voltage it doesn't conduct. Above it does. As for precisely 1V, then it may not be the best solution.

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

It could be as simple as an LED. Below the forward voltage it doesn't conduct. Above it does.

???  I believe above 1V , OP wants Vout=Vin ...of course an LED has a varying Vdrop depending upon many factors.

 

When in the dark remember-the future looks brighter than ever.

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

My vote goes to #13, it does what the OP wants.

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

My vote goes to #13, it does what the OP wants

Looks pretty good, an open drain comparator (MIC7221) would likely be preferred, so it could pull closer to gnd, than the bipolar open collector .

When in the dark remember-the future looks brighter than ever.

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

Hi All,

 

Here goes my effort, I still struggle on op-amps but I think this is correct. 

 

Below is what I am trying to achieve.  I think my comparator and op-amp selection is correct but I am not sure if my circuit design is correct.  Could you offer any design advice.

 

The function of the circuit is:

 

* if(POT Voltage > +0.25V) then ADC 1 is supplied POT voltage.

 

* if(POT Voltage < -0.25V) then ADC 2 is supplied POT voltage.

 

Thanks,

 

Tuurbo46

 

 

 

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

You've got a changeover relay, surely that will perform the switching between adc1 and 2 without having two relays and two comparators? 

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

Hi Kartman,

 

The POT is a joystick left, stop, and right.  Below is the logic.

 

* Left = (+0.25 to +5V)

 

* Stop = (-0.25 to +0.25V)

 

* Right = (-0.25 to -5V)

 

I am modifying an old machine and adding in some electronics.

 

I have chosen 2 comparators to help with the stop (-0.25 to +0.25V) when the joystick is in neutral.

 

Thanks,

 

Tuurbo46

 

 

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

Did it even works?

Maybe I'm wrong but if there is e.g 1V at pot U1A+ > U1A-. So there is 5V at U1A output that goes (for what ever reason) into inverting amp that clamps it to ~0V. What opens Q1 and switch voltage into ADC1.

At the same time  U1B- > U1B+, what will put -5V into U1B output what will open Q2 and switch voltage into ADC2 at the same time as ADC1 is switched on.

For -1V at input, Q1 and Q2 are off and both ADCs are disconnected. This doesn't seem to be what you want.

 

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

Hi,

 

After another study of the datasheet, i was struggling to understand the open collector part.  I have changed the input wiring around and removed the inverting amp, so i think this should be correct now?

 

Thanks,

 

Tuurbo46

 

 

 

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

Tuurbo46 wrote:
After another study of the datasheet, i was struggling to understand the open collector part.

 

In practice, open collector or open drain means the low output is the negative rail, while the high output is high impedance (disconnected) instead of the positive rail.

Last Edited: Fri. Jun 15, 2018 - 03:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What signal goes to adc1 when the relay is open?  Likewise to ADC2?  Why not put both signals to adc1 & 2 at all times?  Perhaps a compatibility issue with the machine?

 

Anyhow, your ADC probably does not use (or is damaged by) negative voltages...Is this correct?  if not usable, get rid of them from your circuit!!  Get rid of the relay and use something like a 74hc4066 or other switch.

Otherwise, get rid of the fets , the comparator transistor can drive a small relay (say 15ma).  A beefier LM311 can handle 50ma!!

There needs to be a high ohm resistor from each comparator output to the + input terminal, or you will have chatter.

 

 

The POT is a joystick left, stop, and right.  Below is the logic.

* Left = (+0.25 to +5V)

* Stop = (-0.25 to +0.25V)

* Right = (-0.25 to -5V)

What does this have to do with having 2 signal lines???  Your explanation is lacking

When in the dark remember-the future looks brighter than ever.

Last Edited: Fri. Jun 15, 2018 - 03:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you need create just a "dead zone" for the joystick and you don't need exactly 0.25V, you may consider just use diodes. Schottky diode has about 0.2V drop across it and standard signal diode ~0.6V.

Upper diode for positive and lower one for negative voltages. Diodes doesn't conduct (much) if voltage across them is smaller than drop voltage.

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

Diodes doesn't conduct (much) if voltage across them is smaller than drop voltage

Don't let things float...Take your diode suggestion and add pulling resistors to gnd...Then, below the diodes threshold voltage, the ADC will stick close to zero.

 

Nor sure why the original poster is all of a sudden talking about negative voltages??  The first mention of negative was not til comment 22 !!!!!!!!!!!!!!

When in the dark remember-the future looks brighter than ever.

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

Hi avrcandies & the_mios,

 

Thanks for your inputs.

 

When I originally posted my question I did not really understand how to implement a design to my product.  I did not mention negative voltages because I was trying to not over complicate the questions.  So to confirm the below voltages are being feed into a micro ADC:

 

* Left = (+0.25 to +5V)

* Stop = (-0.25 to +0.25V) // I have set this limit, this could be reduced to suit the diode example in #27

* Right = (-0.25 to -5V)

 

The above pot/joystick control voltages are read into an Atmega324pa, but as I understand it this only reads ADC values from 0v-5v and not -5V to +5V (10v swing), so I thought the easiest way to read the pot data was to split the signal into two 5V signals, and put though two compactors and feed into two ADC channels.  This ADC data will then will be translated into to motor control left, stop and right.  I have the motor control part sorted, I am just struggling on the analogue input processing.

 

A couple of analogue learning questions:

 

1) Out of the two solutions #26 and #27 which do you think would best suit my application.  I can initially see #27 is easier to implement, but would this work as well as the #26 solution?

 

2) I always try to avoid using transistors because of thermal runaway and stick with FETs .  Is this considered correct and the modern practice?

 

Thanks in advance,

 

Tuurbo46

 

 

 

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

But in your earlier thread: https://www.avrfreaks.net/forum/... it has already been shown to you how to convert -5V to +5V into 0V to +5V with a simple circuit that makes Vout = Vin/2 + 2.5V.

You can feed that to the ADC and handle the dead zone in software.

 

edit: after conversion, the dead zone will be 2.5V ± 0.125V

Last Edited: Sat. Jun 16, 2018 - 03:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are completely wasting everyone's time here, since you still seem to have zero clue about describing what you are doing!!

 

You said these signals are going into some old machine, now your last post says they are going into a mega324???  

 

What is the new part (you are creating) and what is the old part (that must be compatible)???!!?  Is this some industrial machine?

 

The above pot/joystick control voltages are read into an Atmega324pa, but as I understand it this only reads ADC values from 0v-5v and not -5V to +5V (10v swing), so I thought the easiest way to read the pot data was to split the signal into two 5V signals, and put though two compactors and feed into two ADC channels.  This ADC data will then will be translated into to motor control left, stop and right.  I have the motor control part sorted, I am just struggling on the analogue input processing.

  

That's completely and utterly ridiculous.  If you have a -5 to +5 signal just feed it into a divider: 

joystick to ResistorApin1.  ResistorApin2 to resistorBpin1.   resistorBpin2 to 5V.   resistorBpin1 also goes to your ADC.

 

Resistors A & B should be 10 times your joystick ohms  (but less than 20K).   If more than 20k is needed use the higher value followed by a buffer op amp to feed the ADC.  stop fwd, rev, etc are determined by your software

 

Why wouldn't you use a divider in the first place?  Also, why can't you wire up the joystick to simply provide 0 to 5V?

 

  

 

When in the dark remember-the future looks brighter than ever.

Last Edited: Sat. Jun 16, 2018 - 04:23 PM