Shop OBEX P1 Docs P2 Docs Learn Events
Offset sine output? Var freq and amplitutde? — Parallax Forums

Offset sine output? Var freq and amplitutde?

buckey29buckey29 Posts: 6
edited 2005-10-18 20:30 in BASIC Stamp
First, I'm a newbie to some of this stuff. However, I did do a lot of searching on the internet and various sites including several of the Parallax manuals (all excellent I must say!) but didn't find something quite like I want to do.

What I want to do is to use a basic stamp to:

1. Create a sine wave out on two seperate pins.

2. Each of the 2 pins should be able to output a sine wave form 150hz to 2khz, which is controllable
via a variable or pot input.

3. I want to vary the amplitude of each independantly


4. I want the output (amplitutde and freq) to be continously variable. Reading some manuals implies that if I use freqout, the pin outputs the pwm, then stops and I have to tell it to start again. I want this to be continuous, and variable without a break in the output sine wave.

Am I asking too much? If this is possible I would appreciate any thoughts, or links to some examples that may help.
(Think of a cross fade stereo effect - see picture)
640 x 480 - 11K

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-10-18 17:04
    Buckey29 -

    Generating decent sine waves is a difficult task at best, and moreso directly from any digital resource, including digital microcontollers. That being said, your additional criteria of adjusting both the frequency and amplitude, on the fly, makes it all the more difficult.

    I won't say that it can't be done, but you'll find it to be a quicker and easier task if you use the Stamp as a driver for any of the various waveform generator chips that are available. I don't happen to know of a 2-channel chip, but it wouldn't surprise me if there wasn't one out there that might reveal itself after a bit of searching research.

    Regards,

    Bruce Bates
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-10-18 17:07
    With the fastest stamps you may be able to do it, it will require tight coding and optimized index generation of a lookup table for sine values. This type of application is better suited for the SX·using SX/B.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • buckey29buckey29 Posts: 6
    edited 2005-10-18 17:16
    I've looked at using something like the XR-2206 to generate the wave form. Of course I'd ahve to use two of them, one for each channel. It does have an amplitutde input, which I may be able to do something with. I guess that chapter on using the BS as a Potentiometer comes in handy about now..huh?

    http://www.exar.com/products/XR2206v103.pdf


    Not sure how to interface the BS to this yet, but if anyone has some input I'd greatly appreciate it.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-10-18 17:32
    You can use the Stamp as the controller for the variable resistance used to set the frequency in the XR-2206 by using it to control a digital potentiometer, you can use another to set the MO pin for amplitude out as well. Most I2C devices support 4 of the same type of chip on the same bus so you should be able to have 4 digital potentiometers on the same I2C bus, meaning only 2 stamp pins will be needed.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
  • buckey29buckey29 Posts: 6
    edited 2005-10-18 18:35
    Thanks for the replies. So, it sounds like using the BS alone isn't the method to use. It would be better suited to use the BS to control something like the 2206 or ICL8038. This would simplify the coding, and put the work of creating the sin output on the external IC.

    As another thought, I could use the freqout to control the sweep or modulation of the sin out for some intersting effects.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-18 20:30
    You can generate mixed sine waves on one pin with the BASIC Stamp, that's exactly what FREQOUT does. But waveforms on two simultaneous pins is not possible in PBASIC. As others have suggested, you could do this with an SX chip.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.