AC signal -> rectifier -> comparator?

Thread Starter

NateG

Joined Jun 20, 2008
22
I am using a guitar pickup to act as an on off switch for a synthesizer I am building.

The pickup produces an analog signal when the string is vibrating, my plan is to turn this into a DC signal with a rectifier, then use a comparator to compare that to a set DC voltage reference. The output from the comparator will be sent to a Basic Stamp 2.

My confusion is where to put all the grounds for this system. In order to see the DC voltage from the rectifier, I need to measure across the rectifier terminals, but the comparator needs to be able to see this voltage in order to make the comparison, and I do not think I can just put the negative terminal from the rectifier into the comparator (as it has the same ground as the pickup's ground).

I have tried a few different ways of connecting grounds, but each didnt seem to work correctly.

Schematic is attached.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Your rectifier bridge is not hooked up correctly.
Where you have GND connected is supposed to be the +out.
Where you have the signal input connected is supposed to be the -out, or GND.
AC input goes to the top and bottom connections.

However, using a standard rectifier bridge means that you'll lose somewhere between 0.7v-1v across the rectifiers due to the diodes' Vf.

IF you used a low-voltage Schottky rectifier (BAT54,1N5817, etc), you could get a much better Vf, and lower loss.

You should use a buffer amp to eliminate loading on the signal. Otherwise, you'll introduce distortion. If you used a cap in front of the input, you could use a high-resistance pot to add an offset voltage to negate the Vf of the Schottky diode.

[eta] See the attached for an example of what I'm talking about. The "signal generator" is simulating a 1v peak-peak signal. The 3.3uF cap blocks the average DC level, but permits the effects of an AC signal to pass through.

Above, there is a pot with resistors on both sides that are connected across Vee and Vcc. This allows you to set the offset voltage on the front end. It won't work too well if you're using batteries, because the offset will change as the batteries discharge. It's just the concept at the moment.

The opamp has very high input impedance, so it won't attenuate the signal. The output will be nearly identical to the input; with this particular opamp at such a low frequency, the differences were so slight they wouldn't show up on the simulated O-scope.
 

Attachments

Last edited:

Thread Starter

NateG

Joined Jun 20, 2008
22
Your rectifier bridge is not hooked up correctly.
Where you have GND connected is supposed to be the +out.
Where you have the signal input connected is supposed to be the -out, or GND.
AC input goes to the top and bottom connections.

However, using a standard rectifier bridge means that you'll lose somewhere between 0.7v-1v across the rectifiers due to the diodes' Vf.

IF you used a low-voltage Schottky rectifier (BAT54,1N5817, etc), you could get a much better Vf, and lower loss.

You should use a buffer amp to eliminate loading on the signal. Otherwise, you'll introduce distortion. If you used a cap in front of the input, you could use a high-resistance pot to add an offset voltage to negate the Vf of the Schottky diode.

Ah, you are right, I drew the schematic wrong. However for my board I have it laid out right (using a NTE5313 atm that has them marked).

For my ground problem, I found that the first ground should not be plugged into the rectifier or comparator, when I only connected these I was able to get an output.

I like the ideas of schottky rectifier and buffer amp, looking into those now.

I get an output signal now from the comparator that looks like 0 and 1 (based on whether the string is playing or not), but the signal for 1 looks really noisy.
 

Thread Starter

NateG

Joined Jun 20, 2008
22
heres the current output of the comparator, 0 is in the middle, so it actually looks like an AC voltage. However it is 0 when it should be 0 and shows this when it is supposed to be 1.

Sorry for the poor quality picture, my phone is all I had.
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
OK, I guess I should've made a new reply instead of adding to my post.

Have another look at my 1st reply additions.

Note that you must use a decent opamp. A TL071 or TL072 would be fine, too. Avoid the TL08x series; they are noisy. An LF351, LF353 would work, too.
 

Thread Starter

NateG

Joined Jun 20, 2008
22
That idea seems awesome, thanks. The only thing is, I will be using batteries. Right now i'm trying to stick to 4 AA's but I guess I can go up to 9V if I need to.

But yeah, is that still possible with the battery drain?

Oh, and what do you think about the noise off the comparator? Anyway I can make that look like more of a digital signal?
 

SgtWookie

Joined Jul 17, 2007
22,230
It's possible, but the offset will change as your batteries run down.

Resistors are inherently "noisy". Metal film resistors are less noisy than carbon composition resistors. You can quiet down the noise quite a bit by adding a bit of capacitance between the signal and ground.

Also, comparators are mighty sensitive at low signal levels. You might need some positive feedback to add some hysteresis. This would involve adding a large-value resistor from the output to the non-inverting input.

I'm too lazy to look at the moment - check your comparator's datasheet; if it has an open-collector output, make sure you have a suitable pull-up resistor to your V+ supply.
 

Thread Starter

NateG

Joined Jun 20, 2008
22
The comparator im using is an LM311. I have a 1k resistor from V+ to the output right now.

Also a 10pF cap and 10k resistor across the output and the noninverting input.

Ill try putting in a bigger resistor from V+ to the output.

edit: no luck, it just seems to cut the signal down a bit, but its still noisy.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Also a 10pF cap and 10k resistor across the output and the noninverting input.
The 10pF cap shouldn't be between the output and the noninverting input.
The feedback resistor should be much larger; 100k-330k
Ill try putting in a bigger resistor from V+ to the output.
What pullup resisotr you need to use depends on what your sink current capability is vs your supply voltage. Shoot for a resistor that will pass 1/2 the sink current capability at the V+ you're using.

I hope you're using 0.1uF caps from your comparator's V+ and V- supplies to ground; that's pretty standard. The cap leads should be as short as possible.
 

Thread Starter

NateG

Joined Jun 20, 2008
22
I think the comparator is doing that because of noise in my input signal coming from the pickup (osc reads almost 300 mV peak to peak).

Is there a good way to filter this out?
 

Thread Starter

NateG

Joined Jun 20, 2008
22
The 10pF cap shouldn't be between the output and the noninverting input.
The feedback resistor should be much larger; 100k-330k

What pullup resisotr you need to use depends on what your sink current capability is vs your supply voltage. Shoot for a resistor that will pass 1/2 the sink current capability at the V+ you're using.

I hope you're using 0.1uF caps from your comparator's V+ and V- supplies to ground; that's pretty standard. The cap leads should be as short as possible.
It was actually 100k not 10k, my mistake.

I didnt have those caps in either, will see what that gives me.

The caps made my signal better, but I think the noise definately is because my input jumps around too much. I guess I may be able to program around it a little to minimize my synthesizer going on and off infinately.
 
Last edited:
Top