Help with using op amp as a sine-to-square converter!


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    One thing to keep in mind with the revision I described is it is incredibly sensitive to noise if the signal goes away. It will chatter at some high frequency, so you either need to code against that or somehow just know when no signal is there so you ignore the input.

    Or... you could DC couple the sine signal to the comparator but use the comparator as an amplifier. Feed the amp output direct to a digital input. That should chop the sine wave into digital form while also driving any noise problems away (you either get a square wave or nothing out of it). Input R of 1K, input C of .01uf and a 10K feedback R should get you there with a gain of 10. Increase the feedback if your output signal isn't enough. (Ask me if you need this drawn up.)

    A quick check of the 16F628a data sheet shows RA2 is also AN2, so make sure you shut off the comparator function (the default) so it works as a digital input.

    I've used schemes such as this in a few products to measure a frequency. What I did there was use the signal to increment one of the counters while another timer would be set up a roll-over interrupt off the internal PIC clock. To start, I would clear both counters and enable the interrupt. When the interrupt occurs read how many counts I got in the first counter and reset it. That way every interrupt time I get a frequency measurement of cycles (counts) per unit time.

  2. #2
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    49


    Did you find this post helpful? Yes | No

    Default

    Thanks for all the good comments and suggestions!

    The oscillator is a wein-bridge oscillator, and DC drift could be the cause of it. I'll be hooking up an oscilloscope to check this weekend. Using the sine wave as it's own DC reference may be the solution.

    I'll be trying that this weekend and I'll post the results.

    Again, thanks for the suggestions!
    Dave

Similar Threads

  1. To Generate Sine Wave Using PCPWM of PIC18F4331 (Issue)
    By Cyborg in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 22nd March 2014, 13:39
  2. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  3. square to sine wave help
    By TONIGALEA in forum General
    Replies: 6
    Last Post: - 2nd July 2006, 09:32

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts