Filter/amplify pulse signals

  • Thread starter petterg
  • Start date
  • #1
162
6
Whats the way to go to apply filter to a pulse signal?

I have a signal with some weak triangle pulses, positive or negative, mixed with some very slow sine wave. I've tried to illustrate this in the attachment. The sine is actually slower than it looks in the chart I don't really know how low frequency it has, but I know it's less than 1Hz. The pulses has a length of 30-50us and they come about every 200-220us.

My goal is to feed this signal into a microcontroller. The controller needs to count pulses and know if they are negative or positive. My challenge is that the pulses are so weak that they have to be amplified, without amplifying everything else. In other words, a highpass filter. The thing with any kind of filter is that signals are weakened - in particular pulses. And that's really the issue I run into in my attempts with this.

So my idea to work around this is to send the signal through two parallel circuits with an opamp in each - one that do lowpass, and one that do nothing except for make the same delay as the lowpass. Then feed the output from those two circuits into a the next stage that subtracts the lowpass filtered signal from the original. The result should then contain pulses only - I thought.

It turns out that even with second order lowpass the output of the filter is affected by the pulses, and the signal that is supposed to pass untouched is also affected by the filter in the parallel circuit. And the subtraction method requires gain from the two parallel circuits to be equal - that wasn't so easy to get properly either.

So, what's the way to apply filter to pulse signals?
 

Attachments

Answers and Replies

  • #2
berkeman
Mentor
59,069
9,167
It sure sounds like you want to use a highpass filter, not a lowpass filter...


EDIT:

My challenge is that the pulses are so weak that they have to be amplified, without amplifying everything else. In other words, a highpass filter. The thing with any kind of filter is that signals are weakened - in particular pulses.
You can certainly have gain in your HPF opamp circuit. Why do you think that the input signal cannot be amplified as part of the HPF?
 
  • #3
meBigGuy
Gold Member
2,323
405
probably the simplest circuit is a series capacitor into the center of two resistors (say 1 to +5 and 1 to ground). You then get positive and negative pulses relative to the 2.5V divider voltage (this is a single pole highpass). Two comparators can detect the pulses and then you can do whatever you want, or you can amplify and filter some more before the comparators if needed. Size the resistors to not load down your source, and the capacitor to let just enough high frequency through.
 
  • #4
162
6
It sure sounds like you want to use a highpass filter, not a lowpass filter...


EDIT:



You can certainly have gain in your HPF opamp circuit. Why do you think that the input signal cannot be amplified as part of the HPF?
I need gain. The thing is that the filtering is weakening the pulse, so what is amplified is a weaker pulse and a weaker sine. The result looks much like I could drop the filter and just do amplification without filter.
 
  • #5
162
6
probably the simplest circuit is a series capacitor into the center of two resistors (say 1 to +5 and 1 to ground). You then get positive and negative pulses relative to the 2.5V divider voltage (this is a single pole highpass). Two comparators can detect the pulses and then you can do whatever you want, or you can amplify and filter some more before the comparators if needed. Size the resistors to not load down your source, and the capacitor to let just enough high frequency through.
I don't think I understand how you're thinking. After the highpass, the signal goes to two parallel comparators? What do they compare?
 
  • #6
meBigGuy
Gold Member
2,323
405
Look up LM339 window comparator.

Assume the resting voltage at the divider is 2.5V and it spikes up and spikes down. In addition some low frequency comes through, as well as the slower ramp you showed. But imagine for the moment that the filter is perfect and all that comes through are positive spikes and negative spikes. Assume for the moment that they are +-0.25 volts. Set a comparator reference input to 2.5 - 0.20 = 2.3V. whenever the pulse goes below 2.3V the comparator triggers. Set the other comparators reference to 2.7V. Whenever the input goes above 2.7V the comparator triggers.

That is the simplest from a conceptual viewpoint. If you need gain, amplify the signal and possibly filter it again. Or, go to more complex active filter architectures. Then send the signal to the "window comparator"
 
  • #7
meBigGuy
Gold Member
2,323
405
Here is a crude example. You will have to mess with the input polarities, decide on the input capacitor size and compute the proper reference resistor values and maybe change the output logic.
 

Attachments

  • #8
meBigGuy
Gold Member
2,323
405
Just looked at your signal levels. Look at Google Images for high pass active filter. Lots of circuit examples.
 
  • #9
162
6
I see your idea of using comparators. It introduces an other challenge thou; Trigger level needs to be dynamic. The signal strength may vary in the range of just a few mV to 500mV. The good thing is that the sine and pulses scale near proportional. Pulse amplitude will always be within 3-5 times the amplitude of the sine.

Any idea of how to make dynamic trigger level?
 
  • #10
jim hardy
Science Advisor
Gold Member
Dearly Missed
9,839
4,881
Read up on basics of "differentiator", which is a term closely related to high pass filter

trouble is it amplifies high frequency noise

One approach is to low pass to reduce noise, then high pass

another is to low pass at two different cutoff frequencies and subtract or compare the result

many ways to skin that cat

filters are math intensive

here's an old National appnote on filters you might enjoy
http://www.swarthmore.edu/NatSci/echeeve1/Ref/DataSheet/IntroToFilters.pdf

updated version at
http://www.ti.com/lit/an/snoa224a/snoa224a.pdf

THIS project will be educational for you !

Have fun, and my hat is off to you for building real stuff.
 
  • #11
meBigGuy
Gold Member
2,323
405
You could approach the wide dynamic range issue in different ways. One complexity is the time rate of change of the average signal amplitude. If it is slow enough you can build an Automatic Gain Control (AGC) based on either the peak or average signal level. Then you need to deal with attack and decay times. (lots of info through google).

The brain-dead approach is to design the circuit to work with the lowest signal level and then let the signals clip at the higher signal levels. The key to this is that your filter needs to be good enough that at the high signal levels the low frequency feedthrough isn't enough cause false detections. Your filter probably needs to be completely linear (no clipping) and then followed by a gain stage that can clip. If that can't work then the gain stage needs gain control of some kind.
 
  • #12
162
6
Thanks guys. I've got a lot to read into, and lots to learn.

And as expected, I ran into an unexpected issue. Why does the lm324 seem to behave very different from the ua741 (in simulation)? Even with the simplest circuit as attached, lm324 give 1.48V on the output. I expected 2.5V. Ua741 give 2.49V.
 

Attachments

  • #13
meBigGuy
Gold Member
2,323
405
Try connecting the rest of the opamps in the package? I don't know about how the model gets mapped to the schematic, but the pin numbering differs between package styles. Maybe there is an issue there.

BTW, You should use a rail to rail variant of the LM324. Standard LM324 only drives to (V+)-1.5V or in your case, 3.5V.
 
  • #14
jim hardy
Science Advisor
Gold Member
Dearly Missed
9,839
4,881
Thanks guys. I've got a lot to read into, and lots to learn.

And as expected, I ran into an unexpected issue. Why does the lm324 seem to behave very different from the ua741 (in simulation)? Even with the simplest circuit as attached, lm324 give 1.48V on the output. I expected 2.5V. Ua741 give 2.49V.
That circuit should give half your supply voltage.
Is your supply nice and quiet? Try a 6 or 9 volt battery.
What happens if you remove C1 ?
 
  • #15
162
6
Removing capacitors - no change.
Increase the values of capacitors to 1F (good thing this is simulation) - no change
Connecting all 4 opamps - no change (that's where I realized something didn't make sense and started to strip down the circuit to isolate the behavior, ending up with this simple test circuit). Pin numbering seems to agree with the datasheet.

Seems like lm324m simulates close to expected behavior. Lm324n outputs noisy 1,5V no matter what it get for input. Ni Multisim has 25 versions of lm324xxx in library, and 2-8 sub versions of each of them. I have no clue what the difference between those are (it can't be that many packaging) and they surely behave differently. Some of them even cause the simulator to crash. I'll stick to lm324m from now on as it seems to behave as expected, and hopefully the physical lm324n that I'll get in the mail soon won't be way off.
 
  • #16
162
6
Attached is my highpass approach.
Input is wires coming in from the left.
U1A is virtual ground generator.
U1B is an impedance buffer, having a DC block before it.
U1C and the RC's in front of it is the highpass filter.

Ch.A on the scoop is output from U1B. It's almost flat between the pulses. Voltage in the pulse max is about 4 times the level of voltage between the pulses.
Ch.B is output from U1C. It's starting to look more like sawtooth. Voltage in the pulse max is only about double the level of voltage between the pulses. And the voltage between the pulses are stronger than before the filter. So I've managed to get only the negative effects of the filter, none of the positive ones.

That's why I don't think highpass is the way to go.
Next up is lowpass + comparator.
 

Attachments

  • #17
162
6
Here comes lowpass scoopshots. I suspect the simulation is wrong, cause what I did between those two shots was to swap the input wires. I my head this should make signal mirror around 0V, which it doesn't.
If the simulation is correct, I don't see how I can use the lowpassed signal any further, as I seems to be independent of voltage level between the pulses.

RC-net for lowpass is set for 18Hz, 2nd order.
 

Attachments

  • #18
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
That's a weird circuit. Did you make it up? Where does the AC input connect to? Oh, it's a way to halve your supply voltage. Why aren't you using a double power supply?

attachment.php?attachmentid=61606&stc=1&=1378687651.png
 
  • #19
jim hardy
Science Advisor
Gold Member
Dearly Missed
9,839
4,881
Attached is my highpass approach.
Input is wires coming in from the left.
U1A is virtual ground generator.
U1B is an impedance buffer, having a DC block before it.
U1C and the RC's in front of it is the highpass filter.

Ch.A on the scoop is output from U1B. It's almost flat between the pulses. Voltage in the pulse max is about 4 times the level of voltage between the pulses.
Ch.B is output from U1C. It's starting to look more like sawtooth. Voltage in the pulse max is only about double the level of voltage between the pulses. And the voltage between the pulses are stronger than before the filter. So I've managed to get only the negative effects of the filter, none of the positive ones.

That's why I don't think highpass is the way to go.
Next up is lowpass + comparator.
not sure I understand the red part.

Observe C1R6 form a differentiator
and it looks to me like ChA is about what you wanted to accomplish.

What does it look like if you skip U1B and feed input straight into C4?

EDIT: PS I would connect my scope common to negative side of 5volt supply.

Why ?

Virtual ground is only as stout as the op-amp that's creating it.
Power supply rails are quite rigid in comparison, that's why they are called 'rails'.
Then your 'scope trace will center around mid power supply and it'll be clear when you hit a 0 or 4 volt limit.
And you could monitor virtual ground, too.

late addition: You're aware that C3-C2 form a capacitive voltage divider for power supply noise.... your virtual ground will be better behaved without C3. And C2 can be large.

old jim
 
Last edited:
  • #20
162
6
That's a weird circuit. Did you make it up? Where does the AC input connect to? Oh, it's a way to halve your supply voltage. Why aren't you using a double power supply?

attachment.php?attachmentid=61606&stc=1&=1378687651.png

Dual supply is not a option in the real circuit.
 
  • #21
162
6
not sure I understand the red part.

Observe C1R6 form a differentiator
and it looks to me like ChA is about what you wanted to accomplish.
ChA is the closest to the preferred signal I've been. This is basically the original signal. Ideally I'd have a signal that is constant 2.5V between the pulses. That is not the case for this signal. My goal is the make the signal closer to the ideal. I want to amplify the pulses, not the what-ever-voltage there is between them.

Values for C1R6 is chosen so that the filter does not affect the signal.

What does it look like if you skip U1B and feed input straight into C4?
U1B has one purpose only; secure that the input impedance is as stable as posible.
Connecting input directly to the highpass network in front of U1C makes output about 5% better than going through U1B. Still output from U1B is the best signal so far.

EDIT: PS I would connect my scope common to negative side of 5volt supply.
I agree. Just one problem thou; To see the pulses I need resolution of 1mV/Div. Max offset is 99 Div. Hence I don't get to see the signal if scoope is grounded to rail. To compensate I have an extra scoope that monitors rail - virtual ground at 50mV/Div.

late addition: You're aware that C3-C2 form a capacitive voltage divider for power supply noise.... your virtual ground will be better behaved without C3. And C2 can be large.
I was not aware that virtual ground generator would behave better without C3. (And I'm still not aware of that). Setting C2=220mF, and removing C3 makes virtual ground voltage = 0.06V. Removing also C2 makes virtual ground voltage = 2.5V. Should R1/R3 be changed in order to balance the virtual ground when using only one capacitor?

Powersupply for this circuit (at least the final stage of opamp) is planned to be the 5V regulated output from an arduino. This to make sure the voltage into the arduino board will be within the aurduinos spec. The arduino will be powered by a 12V battery.
 
  • #22
NascentOxygen
Staff Emeritus
Science Advisor
9,244
1,072
Are you at the moment constructing this, or are you relying on software simulation? It may be better to construct the normal dual-supply OP-AMP filter first, then when you have it tailored to your needs, convert it to single supply.

Although your need is for a high pass filter, in practice you'll be giving it a bandpass filter, so maybe go with that right from the start, using a designed upper falloff instead of letting it default to the OP-AMP limitations?

Is the shape, size, width or height of the pulses important? If you could trigger a monostable with your noisy signal would the pulse-train of fixed shape pulses satisfy your need for a cleaned up signal?

Those caps should have no effect on the DC output of your virtual ground. What you are finding is puzzling.
 
Last edited:
  • #23
meBigGuy
Gold Member
2,323
405
Are you really using milli-farads? Maybe you better wait a while for a transient sim to settle. I think you want uF.

100K 200uf is a 20 second time constant, BTW
 
  • #24
jim hardy
Science Advisor
Gold Member
Dearly Missed
9,839
4,881
Setting C2=220mF, and removing C3 makes virtual ground voltage = 0.06V. Removing also C2 makes virtual ground voltage = 2.5V.
That is absolutely bizarre. Sounds like when you remove C3 the connection is also lost between R1 and U1A's pin 3.

Get U1A working without either capacitor, just R1 and R3, then plug C2 back in. (could capacitors be backward? Electrolytics are polar devices and will conduct if installedbackward. )

Should R1/R3 be changed in order to balance the virtual ground when using only one capacitor?
That should be unnecessary. Electrolytics have insulation resistance in tens of megohms when polarity is right.

Onward ! Each little step is another piece of knowledge.
 
  • #25
162
6
I'm still in simulation. The shipment of lm342 is still in the mail somewhere (maybe in my mailbox, but I'm traveling this (and almost every) week)

Virtual ground simulates as expected without capacitors. I would expect with C2 connected the virtual ground would start low and increase to 2.5V. Simulation tells it starts at 59mV, increase to 60.[something]mV. Maybe it's something about the version of lm324 I'm using?
As far as I can see, there is no polarity of capacitors in NI multisim.

@meBigGuy
When Jim says big, I make it big :)


@NascentOxygen
Using a monostable may be a very good idea!
Whats important is to signal to the MPU the following three states: positive pulse, negative pulse, no pulse. This can be done either using two digital input pins, or one analog input pin. Using two monostable circuits, one that is triggered on positive pulses, another that is triggered by negative pulses would be good. Important that they do not trigger on the slow sine wave thou, even when the sine for a strong signal will have higher voltage than the pulse of a weak signal.
 

Related Threads on Filter/amplify pulse signals

  • Last Post
Replies
3
Views
5K
  • Last Post
Replies
11
Views
2K
  • Last Post
Replies
13
Views
2K
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
1
Views
5K
Replies
4
Views
1K
Replies
6
Views
4K
Replies
17
Views
14K
Replies
2
Views
1K
  • Last Post
Replies
5
Views
2K
Top