1kHz precision sine generator using PIC 16F628


Posted on Feb 4, 2014

This is a very simple circuit where the PIC and an internal 1kHz sinewave table do all the hard work of making an accurate sinewave. Then it needs only a few external parts for filtering. The sinewave has a very high frequency accuracy as it is generated from a xtal. And with appropriate filter parts the sinewave is quite low in distortion. This m


1kHz precision sine generator using PIC 16F628
Click here to download the full size of the above Circuit.

akes the device useful for calibration testing and any use where you need a mathematically correct sinewave of a very precise fixed 1kHz frequency. The sine table was created in Excel spreadsheet and makes a sine ranging from PWM 14 to PWM 86, a total PWM amplitude of 73% which is accurately distributed around the mid voltage point of 50% PWM. The sinewave was deliberately made at this amplitude to get the best performance out of the PWM system. The sinewave has some tiny error in each sample, but every sample has been rounded up or down to the closest PWM value to a perfect sine. The max error for any sample is less than 0. 68% of the sine amplitude. Hopefully this will not matter in the final operation as the important thing is the overall shape of the sinewave, because all the tiny PWM errors will be easily integrated out by the hardware filter. A PIC 16F628 was set up with nothing more than a 5v regulator and 20MHz xtal (and a few PSU caps etc). A trimmer cap was used to trim the 20MHz xtal to better than 1 PPM against my GPS tuned frequency meter. This means the 1kHz output will be 1000. 000Hz (+/-0. 001Hz). The PWM output from PIC pin RB3 was filtered through a 1k trimpot and 0. 22uF cap. The trimpot was adjusted to about 800 ohms, and the output of the filter is shown below on the scope; The sine wave is about 3v amplitude peak to peak. You can see the 50kHz PWM frequency as the fine sawtooth "hash". But importantly,...




Leave Comment

characters left:

Related Circuits

  • New Circuits

    .

     


    Popular Circuits

    DC accurate low-pass filter
    Scr Capacitor Turn-Off Circuit
    Window Comparator Circuit
    Electric Heater Thermostat
    2 x 22W-BTL Car Audio Amplifier DA1553CQ Schematic Diagram
    Speaker Microphone circuit diagrams
    Raspberry Pi Driving a Relay using GPIO
    Complete SS Laser Power Supply Schematics
    The use of monolithic power IC 6 to W audio power amplifier
    Two models of DC motor reversing control circuit



    Top