Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Filter/amplify pulse signals

  1. Sep 7, 2013 #1
    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?
     

    Attached Files:

  2. jcsd
  3. Sep 7, 2013 #2

    berkeman

    User Avatar

    Staff: Mentor

    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?
     
  4. Sep 7, 2013 #3

    meBigGuy

    User Avatar
    Gold Member

    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.
     
  5. Sep 8, 2013 #4
    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.
     
  6. Sep 8, 2013 #5
    I don't think I understand how you're thinking. After the highpass, the signal goes to two parallel comparators? What do they compare?
     
  7. Sep 8, 2013 #6

    meBigGuy

    User Avatar
    Gold Member

    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"
     
  8. Sep 8, 2013 #7

    meBigGuy

    User Avatar
    Gold Member

    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.
     

    Attached Files:

  9. Sep 8, 2013 #8

    meBigGuy

    User Avatar
    Gold Member

    Just looked at your signal levels. Look at Google Images for high pass active filter. Lots of circuit examples.
     
  10. Sep 8, 2013 #9
    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?
     
  11. Sep 8, 2013 #10

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    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.
     
  12. Sep 8, 2013 #11

    meBigGuy

    User Avatar
    Gold Member

    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.
     
  13. Sep 8, 2013 #12
    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.
     

    Attached Files:

  14. Sep 8, 2013 #13

    meBigGuy

    User Avatar
    Gold Member

    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.
     
  15. Sep 8, 2013 #14

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    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 ?
     
  16. Sep 8, 2013 #15
    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.
     
  17. Sep 9, 2013 #16
    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.
     

    Attached Files:

  18. Sep 9, 2013 #17
    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.
     

    Attached Files:

  19. Sep 9, 2013 #18

    NascentOxygen

    User Avatar

    Staff: Mentor

    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
     
  20. Sep 9, 2013 #19

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    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: Sep 9, 2013
  21. Sep 9, 2013 #20

    Dual supply is not a option in the real circuit.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Filter/amplify pulse signals
  1. Data signal filtering (Replies: 11)

Loading...