Shop OBEX P1 Docs P2 Docs Learn Events
Sine wave output from Propeller — Parallax Forums

Sine wave output from Propeller

PhilldapillPhilldapill Posts: 1,283
edited 2008-03-31 21:50 in Propeller 1
I'm designing a low power inverter, but it needs to have a pure sinewave. I've managed to create a pretty good waveform from the propeller using a DAC network of resistors and a small capacitor to further smooth the output. I've run into a roadblock, however, due to the relatively slow speed of spin. I've attached a spin file that shows the program.

What I need to do, is run this in PASM. I can't get over 50Hz output from the propeller using spin. If I go over this frequency, the ouput becomes high until the clock loops back around. I'm not using any sort of internal lookup table on the propeller to get e reference of the sine function. Instead, I created a table in Excel with the sine falues pre-calculated, and just copied them into the spin file. Right now, I'm using a 7bit DAC, but would like to use 8 bit so that I can completely utilize the size of a "byte" variable. I've heard there is some kind of internal lookup for sine functions on the prop, and if possible, would like to use these values·- if it doesn't limit the ouput frequency much. I'm sure this is a pretty simple excercise. All the PASM code would be is to get the next sine value, ouput it directly to the pins as binary, wait a set amount of time, fetch the next value, output, and repeat. This is basically what I'm doing in spin, but with 360 values a cycle and 50 Hz, it starts getting to be a bandwidth hog.

Any suggestions(or PASM code examples) are very welcome.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 21:28
    There's a document called "Propeller Guts" with a link in Graham Stabler's Good Thread Index that describes the use of the sine tables as well as lots of other useful stuff. Start here: http://forums.parallax.com/showthread.php?p=663638.
  • VIRANDVIRAND Posts: 656
    edited 2008-03-31 21:30
    You can get perfect sinewaves using only one or two pins
    if you output pulse-width-modulated pulses according to the sine table values
    and then low-pass-filter the output pulses below the pulse rate.

    For extensive info on a related technique you might want to search for "Don Lancaster Magic Sinewaves".

    Post Edited (VIRAND) : 3/31/2008 9:42:29 PM GMT
  • RaymanRayman Posts: 14,225
    edited 2008-03-31 21:50
    I've got a tone generator on this page:

    http://www.rayslogic.com/propeller/Programming/dac/dac.htm

    that can do between 8 and 2000 Hz.
Sign In or Register to comment.