Connect with us

Best way to filter and amplify a Square Wave?

Discussion in 'General Electronics' started by ChronoFish, Feb 21, 2004.

  1. ChronoFish

    ChronoFish Guest

    Hi there,

    I am "successfully" capturing on my scope a series of (return to zero) bits (11001010 repeating) where each "1" bit is made up of 8
    square waves. The square waves are pulsing just under 1 MHz. If you need a visual it looks something like this:

    |||||||| |||||||| |||||||| ||||||||

    Where each "|" is a square wave.

    The real-world environment is quite noisy and so I have chosen this method in hopes that it will be easier to decipher the signal.
    Certainly with my eyes as the decoder this is the case so far.

    The goal is to feed the signal into a PIC microcontroller.

    My questions follow:
    1. How do I amplify the signal to TTL levels?

    2. Is there a simple way to translate the 8 square waves for a given bit into 1 long square wave? Certainly this can be done in
    software - I'm just wondering what can be done in hardware.

    I've been experimenting with a variety of amplifies and comparators - and though I can get a fairly clean signal, I don't seem to be
    able to amplify beyond 500mV. I'm under the impression that I need the final signal to be at least 1 1/2 V for the PIC to read it.
    The inability is almost certainly due to my inexperience and lack of knowledge.

    Thanks for sharing any insight you might have...
    -CF
     
  2. Jim Thompson

    Jim Thompson Guest

    If you can amplify to 500mV P-P differentially, then apply that to a
    PECL-to-CMOS converter.

    ...Jim Thompson
     
  3. bits (11001010 repeating) where each "1" bit is made up of 8
    a visual it looks something like this:
    in hopes that it will be easier to decipher the signal.
    bit into 1 long square wave? Certainly this can be done in
    though I can get a fairly clean signal, I don't seem to be
    final signal to be at least 1 1/2 V for the PIC to read it.
    Well,

    Don't know your incoming signal level, but the quick design below should
    fullfill at least some of our wishes.
    (Use Courier or other typewriter font)

    +------+-------Vcc
    | |
    .-. .-.
    | | | |
    | | | |
    '-'R3 '-'R4
    ___ | |
    -|___|- + |
    | R2 + -|<--+
    | | D |
    || ___ | |/ |
    ----||--|___|- +------| T1 ---
    C1 || R1 |> ---
    | C2 |
    | |
    ------------------------+------+-------GND
    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    You can use an hf transistor but I guess a general purpose transistor may
    also do.
    Some rules of thumb for the implementation.
    - R1 and R2 set the amplification. Let's say R1=10k and R2=220k set it to
    about 20x.
    - C1 decouples DC and can also be used to filter low frequency noise. Let
    's say 1/(2*pi*f*C1)~R1/10
    - R3 sets the current through the transistor. Consider the collector at
    about 1/2 Vcc to determine.
    - D, R4 and C2 make one pulse out of eight short ones. At a frequencie of
    1MHz R4*C2>2us
    The output pulses may not be good enough to feed to your PIC. If so, use an
    extra transistor or a comparator to fix them. This way the negative going
    pulses can be inverted to positive going ones as wel.

    petrus
     
  4. bits (11001010 repeating) where each "1" bit is made up of 8
    a visual it looks something like this:
    in hopes that it will be easier to decipher the signal.
    bit into 1 long square wave? Certainly this can be done in
    though I can get a fairly clean signal, I don't seem to be
    final signal to be at least 1 1/2 V for the PIC to read it.
    Well,

    Don't know your incoming signal level, but the quick design below should
    fullfill at least some of our wishes.
    (Use Courier or other typewriter font)

    +------+-------Vcc
    | |
    .-. .-.
    | | | |
    | | | |
    '-'R3 '-'R4
    ___ | |
    -|___|- + |
    | R2 + -|<--+
    | | D |
    || ___ | |/ |
    ----||--|___|- +------| T1 ---
    C1 || R1 |> ---
    | C2 |
    | |
    ------------------------+------+-------GND
    created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

    You can use an hf transistor but I guess a general purpose transistor may
    also do.
    Some rules of thumb for the implementation.
    - R1 and R2 set the amplification. Let's say R1=10k and R2=220k set it to
    about 20x.
    - C1 decouples DC and can also be used to filter low frequency noise. Let
    's say 1/(2*pi*f*C1)~R1/10
    - R3 sets the current through the transistor. Consider the collector at
    about 1/2 Vcc to determine.
    - D, R4 and C2 make one pulse out of eight short ones. At a frequencie of
    1MHz R4*C2>2us
    The output pulses may not be good enough to feed to your PIC. If so, use an
    extra transistor or a comparator to fix them. This way the negative going
    pulses can be inverted to positive going ones as wel.

    petrus
     
  5. ChronoFish

    ChronoFish Guest



    Wow, Thanks man. That was a lot more than I was hoping for. Probably not enough for my thick skull, but I will chew on it for a
    while before I post any additional questions.

    Thanks so much!

    -CF
     
  6. Ben Jackson

    Ben Jackson Guest

    I think what you want is a frequency decoder. You have a 8us long
    'beeps' with a frequency of 1Mhz. I've seen the NE567 in several
    PIC-based morse code decoders. Looks like it only goes to 500kHz,
    but there are probably comparable parts that go much faster.
     
  7. I believe I heard that his choice of 1MHz is arbitrary, so using a 567 would
    make some sense, assuming he drops the frequency to, say, 200kHz. However,
    I'm not sure that 8 cycles is enough for the 567 to lock on.

    Regards,
    Bob Monsen
     
  8. Robert Baer

    Robert Baer Guest

    I fail to understand why you are unable to produce signals larger than
    500mV.
    I assume that the noise is as large or larger than the signal of
    interest, so that amplifying it just makes everything larger, and maybe
    the peaks (of the noise) make the amplifier get too close to the rail,
    but the signal itself then is only 500mV in amplitude.
    That means that the use of comparitors, even with adjustable
    hysteresis, gives poor time resolution of the original waveform.
    So, one can limit the bandwidth by the use of synchronous detection,
    provided that the bit cell times are constant.
    The trick is to have a local oscillator that is in synch with the
    waveform (assume that for the moment).
    The output can gate the incoming amplified wave (for each bit time)
    into an averaging type filter of some sort, and the output of that
    filter would be an improved representation of the original value.
    Filters: 1) simple RC, 2) complex multi-pole/multi-zero of many types,
    or 3) digital averaging.
    For the digital averager, one could use have the signal go into a
    comparitor which drives a counter (that was reset at the start of the
    timeslice), the counter could drive a simple R2R ladder for D/A and that
    average value read near the end of the timeslice and used for a second
    comparitor 1/0 decision.
    The filtered and restored 1/0 signal can be used to help keep the
    oscillator in sync (PLL comes to mind).
    I am sure there are other tricks that could be used.
    Tha average value of noise is zero, so filtering can be of great help.
    However, if the S/N ratio is very poor, then the signal needs to be
    repetitive, and then the averaging time for each cell can be increased
    accordingly.
     
  9. M Webb

    M Webb Guest

    Brilliant program, just downloaded it. Thanks for bringing this to my attention.


    Mike.
     
  10. Gareth

    Gareth Guest

    What is the actual purpose of this project? If you want to send serial
    data down a cable to a microcontroller in a noisy environment there are
    some easy ways of doing this, such as using RS422 drivers. If you are
    interested in this ask in the group and I'm sure someone will be able to
    give you more information.
    I can't see what the problem is here, if you put your signal into a
    comparator the output should be a square wave going (almost) to the
    supply rails. What exactly did you do and what was the result?

    If you are using a cable to transmit the signal, and you can change the
    transmitting end then using RS422, or RS232 drivers would avoid this
    problem.
    I do not know of any practical analogue way to do this. You could do it
    with digital filters implemented in hardware, but why bother if you can
    do it in software?

    Gareth.

    --
     
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-