Sine wave


Closed Thread
Results 1 to 9 of 9

Thread: Sine wave

Hybrid View

  1. #1
    Join Date
    Mar 2004
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Thanks Daryl,
    I will give it a go when I get a spare hour. One concept that I had completely overlooked is the fact that the outputs go low (silly me). I was only calculating using the hi 5v state and not the low 0v (GND) state which will completly change my calculations.
    Thanks, I will let you know how I go

  2. #2
    Join Date
    Mar 2004
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Daryl,
    I had a go using your data and got the same result (not what I was hoping for a sine wave). I decided to increase to 6 bit and have another stab at it. I got the same triangle wave that you had on your example. (still not the expected sine wave). I then divided 180 degrees down to the same number of samples, used the sine function, added 1 (then no negative voltages), and scaled to same as actual voltages. I had a new set of data that I used to base my output on. essentialy I picked the closest actual value to the calculated value. I graphed the new data and got the attached waveform (more like a sine wave). This was acheieved by repeating some of the samples with the same voltage and on some skiping voltages. Now I am not sure how the best way to implement it is? do I create a table using this data and simply step through? or do I use the sine function in the pic basic to calculate the output?
    Attached Files Attached Files
    Last edited by Darrenmac; - 18th May 2009 at 03:01. Reason: forgot attachment

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The SIN function will be the easiest.
    It's what the FREQOUT statement uses to generate its sine waves.

    It's essentially a pre-made lookup command. So it'll save you some work.
    The result is an 8-bit number so you could just shift right twice and have your 6-bit value. But 8-bit would be better at such low frequencies.

    You may also want to look at this from sirvo ...
    http://www.picbasic.co.uk/forum/show...5843#post65843

    I've pointed to the video of the finished project, but further up you can see how he did it.

    It uses a lookup, and 10-bit PWM (with 8-bit values) instead of R2R.
    I wish I had a scope like that.
    DT

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, 14:39
  2. Generating 3-phase sine wave..
    By sirvo in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 6th November 2008, 15:07
  3. square to sine wave help
    By TONIGALEA in forum General
    Replies: 6
    Last Post: - 2nd July 2006, 10:32
  4. Replies: 1
    Last Post: - 16th February 2005, 21:05
  5. PBP Dampened Sine Wave
    By Keith55555 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd April 2004, 21:01

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