FPGARelated.com
Forums

generating sine-like waveforms

Started by Unknown August 2, 2006
hello everybody,


are there any _simple_ ways of generating a sine waveform, maybe from a
reference pulse/saw/triangle signal?

(Thanks to Ray :) I know that there are more complicated ways of doing
this, but for now i am interested in the simplest possible way for
getting something that looks like a sine.

actually, i am also interested on algorithms for generating any type of
periodic signals (both low and high on harmonics) that works well in
FPGAs. Jitter and variations are ok (in fact, they are welcome up to
some degree).


(for the record, it will be used for sound synthesis)


regards, -Burns

burn.sir@gmail.com wrote:

> are there any _simple_ ways of generating a sine waveform, maybe from a > reference pulse/saw/triangle signal?
What about lookup-tables? After D/A conversion one should get a sine-like signal. Ralf
Simple accumulator (DDS - nothing fancy) and a DAC.

If you want to be simpler, there's a huge number of parameters that 
determine what's "good" and what isn't.  Is the frequency variable across a 
huge range?  Many Decades or half an octave?  What kind of harmonics are 
permitted?  ...the purer, the tougher.  Noise floor?  Power supply 
rejection?  Modulation rate?  How about a VCO with a voltage-tuned filter? 
Maybe just a bunch of resistors from a few output?

There's just too much not known about what's considered "good" for your 
needs.


<burn.sir@gmail.com> wrote in message 
news:1154546507.601031.265860@p79g2000cwp.googlegroups.com...
> hello everybody, > > > are there any _simple_ ways of generating a sine waveform, maybe from a > reference pulse/saw/triangle signal? > > (Thanks to Ray :) I know that there are more complicated ways of doing > this, but for now i am interested in the simplest possible way for > getting something that looks like a sine. > > actually, i am also interested on algorithms for generating any type of > periodic signals (both low and high on harmonics) that works well in > FPGAs. Jitter and variations are ok (in fact, they are welcome up to > some degree). > > > (for the record, it will be used for sound synthesis) > > > regards, -Burns >
wow, that was one quick answer :)


Nop, sorry. LUTs wont do. Too much logic for linear-filtering and the
result is still crappy, IMO. There is no D/A, every thing is pure
digital. The LUT solution would make it "too" pure.

I was thinking of something like a unstable feedback loop that
hopefully doesnt require a multiplier/divider to work.

I had another idea about simple filtering (e.g. next=current +
target/2) of a pulse wave, but cant adjust the frequency for it.


-bruns



Ralf Hildebrandt wrote:
> burn.sir@gmail.com wrote: > > > are there any _simple_ ways of generating a sine waveform, maybe from a > > reference pulse/saw/triangle signal? > > What about lookup-tables? After D/A conversion one should get a > sine-like signal. > > Ralf
burn.sir@gmail.com a &#4294967295;crit :
> hello everybody, > > > are there any _simple_ ways of generating a sine waveform, maybe from a > reference pulse/saw/triangle signal?
Hi I once made a _very_ crude sin & cos generator (for short simulations) with only 2 adders : ... signal c, s : signed(SIZE-1 downto 0); ... process (clk, rst) variable ds, dc : signed(SIZE-1 downto 0); begin if rst = '1' then c <= (c'left => '0', others => 1); -- cos(0) = 1 s <= (others => '0'); -- sin(0) = 0 elsif rising_edge(clk) then ds := c/8; dc := -(s/8); c <= c + dc; s <= s + ds; end if; end process; Hope this helps. Nicolas
Its for sound synthesis, not radar. And its for a hobby project, not
job related. Hence, I am looking for the quick and dirty solution for
now. If this was serious stuff, I would use DSP blocks or cordic
algorithms :)


Frequency range is 40 to 96K Hz, resolution is 12 bits for now (24-32
internal). The sampling frequency is low enough to serialize
multipliers for this, but i wanted to check if there were any other
solutions first.

No power supply problems, the signal is digital all the way (no DAC).
Neither is noise a problem, as long as it is random (thats why i don't
like lookup tables).



I have a pulse and a sawtooth running at the same frequency. Is there
any way i can use them for this? i can multiply their frequency by a
power of two by simple bit-shifting...

bruns


John_H wrote:
> Simple accumulator (DDS - nothing fancy) and a DAC. > > If you want to be simpler, there's a huge number of parameters that > determine what's "good" and what isn't. Is the frequency variable across a > huge range? Many Decades or half an octave? What kind of harmonics are > permitted? ...the purer, the tougher. Noise floor? Power supply > rejection? Modulation rate? How about a VCO with a voltage-tuned filter? > Maybe just a bunch of resistors from a few output? > > There's just too much not known about what's considered "good" for your > needs. > > > <burn.sir@gmail.com> wrote in message > news:1154546507.601031.265860@p79g2000cwp.googlegroups.com... > > hello everybody, > > > > > > are there any _simple_ ways of generating a sine waveform, maybe from a > > reference pulse/saw/triangle signal? > > > > (Thanks to Ray :) I know that there are more complicated ways of doing > > this, but for now i am interested in the simplest possible way for > > getting something that looks like a sine. > > > > actually, i am also interested on algorithms for generating any type of > > periodic signals (both low and high on harmonics) that works well in > > FPGAs. Jitter and variations are ok (in fact, they are welcome up to > > some degree). > > > > > > (for the record, it will be used for sound synthesis) > > > > > > regards, -Burns > >
On 2006-08-02, burn.sir@gmail.com <burn.sir@gmail.com> wrote:
> > are there any _simple_ ways of generating a sine waveform, maybe from a > reference pulse/saw/triangle signal?
There are schemes for choosing ladder-style DAC resistor values such that an output ramp generates a sine wave. A quick google turned up a similar idea with illustration at: http://www.edn.com/contents/images/6321527f1.pdf I seem to recall a recent thread on one of the electronics newsgroups where someone had written a program to select optimal resistor values for this sort of thing. -- Ben Jackson AD7GD <ben@ben.com> http://www.ben.com/
> are there any _simple_ ways of generating a sine waveform, maybe from a > reference pulse/saw/triangle signal?
Use a Numerically Controlled Oscillator(NCO). All it really is an 'n' bit accumulator that accumulates phase. The range of the accumulator represents one complete cycle of the waveform you are generating. I.e. 0-360 degrees, or 0 to 2pi. Then use the 'm' most significant bits of the phase(accumulator) to address into a LUT or BRAM lookup table containing the waveform shape. The phase accumulator clock frequency sets the output jitter. Higher the clock, less jitter. If you want a constant frequency, then accumulate a constant phase each cycle. This constant sets your output frequency. 'n' controls the frequency resolution. I guess 'm' controls the "accuracy" of your waveform shape. If you want a square wave you don't even need the waveform lookup table, just use the most significant bit.
Thats a nice one. It works really well with floating points:
http://www.musicdsp.org/archive.php?classid=3D1#10

the problem is the frequency parameter calculation (your "magic" 8
here).

maybe I can use a clock-enable to vary frequency and do some sort of
interpolation on top of that?



Nicolas Matringe wrote:
> burn.sir@gmail.com a =E9crit : > > hello everybody, > > > > > > are there any _simple_ ways of generating a sine waveform, maybe from a > > reference pulse/saw/triangle signal? > > Hi > I once made a _very_ crude sin & cos generator (for short simulations) > with only 2 adders : > > ... > signal c, s : signed(SIZE-1 downto 0); > ... > process (clk, rst) > variable ds, dc : signed(SIZE-1 downto 0); > begin > if rst =3D '1' then > c <=3D (c'left =3D> '0', others =3D> 1); -- cos(0) =3D 1 > s <=3D (others =3D> '0'); -- sin(0) =3D 0 > elsif rising_edge(clk) then > ds :=3D c/8; > dc :=3D -(s/8); > c <=3D c + dc; > s <=3D s + ds; > end if; > end process; >=20 > Hope this helps. >=20 > Nicolas
burn.sir@gmail.com wrote:
> hello everybody,
> are there any _simple_ ways of generating a sine waveform, maybe from a > reference pulse/saw/triangle signal?
> (Thanks to Ray :) I know that there are more complicated ways of doing > this, but for now i am interested in the simplest possible way for > getting something that looks like a sine.
> actually, i am also interested on algorithms for generating any type of > periodic signals (both low and high on harmonics) that works well in > FPGAs. Jitter and variations are ok (in fact, they are welcome up to > some degree).
> (for the record, it will be used for sound synthesis)
Look for the Xilinx DDS core. If I remember right, you could use it even with Webpack -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------