Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Get a voltage comparator to do the opposite switch.

Status
Not open for further replies.

boylesg

Advanced Member level 4
Advanced Member level 4
Joined
Jul 15, 2012
Messages
1,023
Helped
5
Reputation
10
Reaction score
6
Trophy points
1,318
Location
Epping, Victoria, Australia
Activity points
11,697
This comparator circuit works as follows - when the inverting input voltage level falls below the reference voltage (about 0.7V) the output goes high.

Which is to be expected.

What happens if I want the output to go high when the input voltage rises above the reference voltage?

I can't seem to figure out how to correctly modify the circuit to achieve this.

Any suggestions?
 
Last edited:

Hello,

First, this circuit is a Schmitt trigger with large hysteresis, as there is positive feedback via the voltage divider R1 and R3 (together with the impedance of the voltage divider for setting your reference voltage). I would not call this a comparator circuit. Increasing value of R1 reduces the hysteresis. I assume you use 0V for negative supply. Where is your LED connected, as this may modify the output low and high levels? If this happens the switching thresholds also change (due to the large hysteresis).

If you want inverse action, you should provide your reference voltage at the inverting input. so divider R2, R4 should connect to the inverting input and not to R3. The input signal you connect to the left side of R3. Note that I assume that the input signal has low output impedance and is able to sink and source current.

You may need to change R2 and R4 somewhat to get the correct switching threshold. Why you need such large hysteresis?
 
  • Like
Reactions: FvM

    FvM

    Points: 2
    Helpful Answer Positive Rating
This comparator circuit works as follows - when the inverting input voltage level falls below the reference voltage (about 0.7V) the output goes high.
Which input voltage? It's not shown in the schematic.

Is it asking too much to expect a schematic that fits the question?
 

@FvM: I had same problem! I assumed that his input is the inverting input and he just connected it to ground.
 

Hello,

First, this circuit is a Schmitt trigger with large hysteresis, as there is positive feedback via the voltage divider R1 and R3 (together with the impedance of the voltage divider for setting your reference voltage). I would not call this a comparator circuit. Increasing value of R1 reduces the hysteresis. I assume you use 0V for negative supply. Where is your LED connected, as this may modify the output low and high levels? If this happens the switching thresholds also change (due to the large hysteresis).

If you want inverse action, you should provide your reference voltage at the inverting input. so divider R2, R4 should connect to the inverting input and not to R3. The input signal you connect to the left side of R3. Note that I assume that the input signal has low output impedance and is able to sink and source current.

You may need to change R2 and R4 somewhat to get the correct switching threshold. Why you need such large hysteresis?

On my bread board I was using this circuit as a capacitive sensor to light up a LED when you touch the top surface of laminated paper with Al foil on the bottom surface connected to the input of my circuit and it works well. But not for the reason I was assuming.

So the output of the circuit is connected to the anode of the LED while the cathode of the LED is connected to GND, with no resistor.

Measuring the voltage at he anode of the LED with my multimeter I have discovered that the voltage sits at about -4.3V or so.

But when you touch above the Al foil, the voltage at the anode of the LED rises to about -2.3V and the LED turns on faintly.

I can't get my head around how this is working. An LED only turns on when the voltage at the anode is 1V or so above GND so how the devil is it turning on when the voltage at the anode is -2.3V????

- - - Updated - - -

This is what I have on my bread board at present.

The notes indicate what I have measured at those points with my multimeter in the real circuit.

Note the voltage at the anode of the LED. It starts at 1.8V and the LED on with out my finger on the capacitive sensor and drops to below 1V and the LED very slightly dimmed with my finger on the capacitive sensor.

I can't get my head around why the LED does not turn off completely or at least dim substantially when the voltage drops below 1V. What is the story here?

And for some reason the simulated circuit does not behave the same as the real circuit - the LED never lights up and the voltage at the anode is -1.2V when my Vdd is at 0.3V which is what I measured in the real circuit when my finger is NOT on the capacitive sensor.



- - - Updated - - -

Is there a better way to simulate my laminated paper/Al foil tape capacitive touch sensor than using Vdd?
 

Do you have an oscilloscope?

No I dont I am afraid WimRFP.

Even with your suggested modifications the multimeter tells me that the voltage drops to below 1V and yet the LED remains lit.

I also just measured the current and it goes from 0.7mA to 0.5mA which would explain the slight dimming when I touch the sensor.

But I just don't comprehend the voltage measurement.......aaaaaaaahhhh.......unless what I am measuring is not the voltage output of the schmitt trigger but rather the voltage drop across the LED, which would drop when it starts conducting. Is that correct?

I also added this modification to YOUR suggested modification and now the circuit behaves exactly as I want it to.

The LED remains unlit until I touch the sensor and the voltage output of the schmitt trigger goes from 0V to 2V or so.

And for some reason the simulated circuit below behaves in the opposite manner to the real circuit - the only thing that is different with the former is that I am attempting to simulate the touch sensor with Vdd.

I have measured the voltage at the + pin of the comparator when the sensor is touched (0.6V roughly) and not touched (0.3V roughly) and just setting Vdd to those values.

Is there a more accurate way to simulate my touch sensor?
 

A touch sensor like you described will inject AC, not DC into the circuit. If you don't have a scope, try replacing the LED with a loudspeaker. I suspect you will hear a buzz when you touch the sensor.
 

Is there a better way to simulate my laminated paper/Al foil tape capacitive touch sensor than using Vdd?
I fear, connecting a fixed DC voltage "Vdd" has about nothing to do with simulation of a touch sensor.

Beyond all the words in your posts, it would be helpful to know what you exactly want to achieve and how the sensor setup looks like.

Presumed you connected the open LM339 comparator input to the said "sensor", the pin is primarly floating, means it voltage rises according to the input current of the PNP transistors.

There are basically two operation principles for capacitive touch sensors
- utilizing 50/60 Hz mains AC "stray" voltage, often used e.g. by touch light switches
- utilizing a high frequent voltage generated by the sensor itself
 

The reason for asking for an oscilloscope is that you can't rely on your DC voltmeter as due to the AC present on the sensor, the output of the comparator flips up and down. So you can measure an average negative voltage across the LED though it does light. This may explain your observation regarding the LED voltage.

Given the application (not DC, but detecting AC from a capacitive sensor), I would definitely try to find somebody with an oscilloscope, as you really need it if you want to design a reliable circuit. Having a scope also can help you to model your sensor. It will very likely look like an AC (50 Hz + some harmonics?) voltage source in series with a small capacitor. You also need to experiment with providing a DC path for the input that has the sensor, as LM339 has relative high negative input bias current.
 

A touch sensor like you described will inject AC, not DC into the circuit. If you don't have a scope, try replacing the LED with a loudspeaker. I suspect you will hear a buzz when you touch the sensor.

I have a multimeter with frequency detection and previous measurement indicates it is a couple of tens of Hz. Addition of a capacitor seemed to smooth it out enough for any oscillation to be no longer detectable by my multimeter.

Essentially I have a printed piano keyboard (48 keys), laminated and with strips of Al foil **** beneath each 'key'.

These are connected to a wire that is in turn connected to the + pin of my comparator schmitt trigger circuit.

The out put of this goes into a PNP transistor to invert it, such that the LED remains off until I touch a key. This also produces a positive voltage output which I need.

Each key on my key board will have its own schmitt trigger plus PNP.

I then have 6 x dual opamps with one side soldered as a voltage summer and the the other side as an inverting amplifier. The output of the summing amplifier goes to the input of the inverting amplifier and the output of the inverting amplifiers will go to 6 analog pins of an arduino.

The outputs of each of the schmitt triggers will be soldered, with a 10k resistor, to one or more of the summing amplifiers according to a table I have prepared.

E.G. Suming amplifiers 1-6 - note C4 would 100001 or what ever or, in other words, the output of the schmitt trigger for note C4 would be connected to summing amplifiers 1 and 6. So in the arduino I would read 100001 on the analog pins.

The summing amplifiers means I will be able to 'stack' the 1s in the case of simultaneous key touches.

I have tested this on my bread board up to this stage and the inverting op amp output still manages to light up a LED each time I touch a key. Just need to connect another schmitt trigger to the same summing/inverting amplifier to make sure I get twice the voltage out of it.

Have not yet tested it with the arduino.

At some point I will prepare a complete circuit for one piano key in multisim and post the netlist in here. I suspect I wont be able to do a screen image as the complete circuit will be two large to fit in one screen shot.

P.S. Perhaps I should try the function generator rather than Vdd in multisim.
 
Last edited:

I don't believe that the implemented stray voltage sensing touch sensor principle will give good results for a piano keyboard, or any other application that requires exact key timing. It depends too much on arbitrary enviromental factors.
 

It depends too much on arbitrary enviromental factors.

Such as?

It seems responsive enough with an LED on my bread board and I have not noticed anything other than my finger triggering the circuit.

And bare in mind that I am not aiming to produce a consumer product here for use by professional musicians.
 

Power supply and external connections of the circuit, arrangement of power cables in the vincinity, devices the operator is touching at the same time...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top