Signal Generator using FPGA and DAC

Discussion in 'VHDL' started by Sheetal, Apr 24, 2007.

  1. Sheetal

    Sheetal Guest

    hi..I'm a university student familiar with the only the basics of VHDL
    and FPGA implementation..For my project, I'm trying a make a sine
    wave, ramp, triangular and square wave generator which outputs
    required wave of required amplitude and required frequency

    The FPGA is connected with DAC thru I2C bus..

    The development board (nanoboard) has on- board freq of 20 mhz...now the
    dac being connected to the I2c bus can work upto max 400 Mhz..so a
    suitable clock divisor has to be implemented ..thus a low frequency
    can be used as SCL input to DAC..

    a)Now, for the sine and square wave, I'm assuming that we can use the
    same look-up table(values ranging from 0 to 256)for the output values
    of DAC.for

    obtaining different frequencies, only the SCL needs to be changed .
    i.e.if SCl rate is high, the DAC would output from 0 to 256, then to 0
    at a faster rate,

    if SCL is low, it would output the same values, but with some delay.
    THus, variable frequency can be obtained by changing SCL rate..am I
    correct in assuming so?

    b)If this is correct, can anyone please tell me the relationship
    between SCL and output wave frequency..if such a formula/well defined
    relationship does exist

    c) Also, can anyone tell me about a good link for a simple tutorial on
    implementing look-up table?I did find some on the web, but they all
    seemed to be complicated..either because they ARE..or because my mind
    has gone all-blank right now, with the submission date coming so
    near..

    Any help at this time would be hugely appreciated

    Kind Regards,
    Sheetal
    Sheetal, Apr 24, 2007
    #1
    1. Advertising

  2. On Apr 24, 6:23 am, Sheetal <> wrote:
    > hi..I'm a university student familiar with the only the basics of VHDL
    > and FPGA implementation..For my project, I'm trying a make a sine
    > wave, ramp, triangular and square wave generator which outputs
    > required wave of required amplitude and required frequency
    >
    > The FPGA is connected with DAC thru I2C bus..
    >
    > The development board (nanoboard) has on- board freq of 20 mhz...now the
    > dac being connected to the I2c bus can work upto max 400 Mhz..so a
    > suitable clock divisor has to be implemented ..thus a low frequency
    > can be used as SCL input to DAC..
    >
    > a)Now, for the sine and square wave, I'm assuming that we can use the
    > same look-up table(values ranging from 0 to 256)for the output values
    > of DAC.for
    >
    > obtaining different frequencies, only the SCL needs to be changed .
    > i.e.if SCl rate is high, the DAC would output from 0 to 256, then to 0
    > at a faster rate,
    >
    > if SCL is low, it would output the same values, but with some delay.
    > THus, variable frequency can be obtained by changing SCL rate..am I
    > correct in assuming so?
    >
    > b)If this is correct, can anyone please tell me the relationship
    > between SCL and output wave frequency..if such a formula/well defined
    > relationship does exist
    >
    > c) Also, can anyone tell me about a good link for a simple tutorial on
    > implementing look-up table?I did find some on the web, but they all
    > seemed to be complicated..either because they ARE..or because my mind
    > has gone all-blank right now, with the submission date coming so
    > near..
    >
    > Any help at this time would be hugely appreciated
    >
    > Kind Regards,
    > Sheetal


    I don't really understand how your system is setup... You have an I2C
    bus between an FPGA and a 400M DAC? I2C typically runs around
    400kHz. You will never be able to get samples to the DAC at at rate
    of 400M samples using I2C

    You need to read up on the I2C standard a bit perhaps. Typically
    you'll transfer 1 byte per bus cycle. How many bits are the samples?

    What FPGA are you using? I know Xilinx (and I suspect that's true for
    Altera as well) has soft cores to generate sine waves in various
    ways. You don't need to be bothered implementing your own look up
    tables. Also you could use a cordic core (also a soft macro in
    xilinx) to generate your sine waves (to avoid using memory).

    Provide more details and I can try to help you

    -Jakub
    canadianJaouk, Apr 27, 2007
    #2
    1. Advertising

  3. Sheetal

    Hrishi Guest

    Hello Sheetal!!!

    I m Hrishikesh . I along with two of my friends are also currently
    trying to build a Function generator for my Final Year Engg course!!
    The on- board crystal for our FPGA board is 6MHz. We are using Xilinx
    FPGA Xc2s50 tq144 -6

    I have been successful in generating
    square wave upto 45kHz
    sine wave with 128 sample pts for one cycle upto 12kHz
    triangular wave with 128 sample points for one cycle upto 7.5kHz.

    The main restrictions that we faced were
    1. The on board clock is of too low frequency.
    2. The floating point values are not synthesisable.For higher
    frequency generation the count used for delays being floating point
    values were approximated to integer values.This reduces the accuracy
    of the frequencies generated.

    We also have done duty cycle variation for sqare and triangular wave
    though we have shown only 10,30,50 and 70% duty cycles. other values
    can also be obtained

    the DAC we have used is DAC0808.

    Sorry but i really haven't tried out interfacing it to an I2C bus but
    i'm sure u'll be succesful in doin that!!!
    all the best!!!
    Hrishi, May 2, 2007
    #3
  4. Hrishi wrote:

    > I m Hrishikesh . I along with two of my friends are also currently
    > trying to build a Function generator for my Final Year Engg course!!
    > The on- board crystal for our FPGA board is 6MHz. We are using Xilinx
    > FPGA Xc2s50 tq144 -6
    >
    > I have been successful in generating
    > square wave upto 45kHz
    > sine wave with 128 sample pts for one cycle upto 12kHz
    > triangular wave with 128 sample points for one cycle upto 7.5kHz.


    With a 6MHz clock and 150ns settling time, you should be able to
    generate square waves in the low MHz range?!? And 128-sample/cycle waves
    (of any shape) around 46kHz by my calculations.

    > The main restrictions that we faced were
    > 1. The on board clock is of too low frequency.


    With a 150ns settling time you won't need a faster clock, and even if
    you did you can use a DCM to multiply the clock internally.

    Regards,

    --
    Mark McDougall, Engineer
    Virtual Logic Pty Ltd, <http://www.vl.com.au>
    21-25 King St, Rockdale, 2216
    Ph: +612-9599-3255 Fax: +612-9599-3266
    Mark McDougall, May 3, 2007
    #4
  5. Sheetal wrote:

    > The development board (nanoboard) has on- board freq of 20 mhz...now
    > the dac being connected to the I2c bus can work upto max 400 Mhz..so
    > a suitable clock divisor has to be implemented ..thus a low frequency
    > can be used as SCL input to DAC..


    This is a Nanoboard-NB1?

    You need to read up on the I2C bus. BTW the maximum clock rate on the
    bus is 400kHz (not MHz) and taking a quick look at the data sheet, you
    need to write a minimum of 3 bytes to the device to update a DAC output.
    So the maximum rate you can output will be roughly 400k/(3*9) or 14kHz.

    Opencores has an I2C controller that should get you up-and-running at
    least. It interfaces to wishbone but generating simple wishbone cycles
    is trivial.

    Regards,

    --
    Mark McDougall, Engineer
    Virtual Logic Pty Ltd, <http://www.vl.com.au>
    21-25 King St, Rockdale, 2216
    Ph: +612-9599-3255 Fax: +612-9599-3266
    Mark McDougall, May 3, 2007
    #5
  6. canadianJaouk wrote:

    >> c) Also, can anyone tell me about a good link for a simple tutorial
    >> on implementing look-up table?I did find some on the web, but they
    >> all seemed to be complicated..either because they ARE..or because
    >> my mind has gone all-blank right now, with the submission date
    >> coming so near..


    Why do you need a lookup table?

    For example, if you have a single 128-byte sine wave stored in an array,
    you simply need to clock a counter to use as the array address (index)
    at your sampling rate.

    You could even clock this asynchronously to the process that writes the
    DAC, so your DAC is updated at the same rate regardless of your sampling
    rate. The usual precautions need to be taken when shuffling data across
    clock domains of course...

    Regards,

    --
    Mark McDougall, Engineer
    Virtual Logic Pty Ltd, <http://www.vl.com.au>
    21-25 King St, Rockdale, 2216
    Ph: +612-9599-3255 Fax: +612-9599-3266
    Mark McDougall, May 3, 2007
    #6
  7. Sheetal

    Andy Guest

    On May 2, 8:20 pm, Mark McDougall <> wrote:

    > Why do you need a lookup table?
    >
    > For example, if you have a single 128-byte sine wave stored in an array,
    > you simply need to clock a counter to use as the array address (index)
    > at your sampling rate.


    Your sine wave stored in an array is a lookup table!

    By reversing the sign of the output, and the direction of the counter,
    you can get by with only a quarter cycle of the wave due to symmetry.

    Andy
    Andy, May 3, 2007
    #7
  8. Andy wrote:

    > Your sine wave stored in an array is a lookup table!


    Umm, not really. A lookup table generally implies an associated search
    function for mapping one value to another - and an order of magnitude
    more difficult to implement.

    The sine wave in question is more akin to a waveform sample stored in,
    for example, a ROM. Or you could do away with the addressing altogether
    and use a circular shift-register.

    > By reversing the sign of the output, and the direction of the counter,
    > you can get by with only a quarter cycle of the wave due to symmetry.


    True.

    Regards,

    --
    Mark McDougall, Engineer
    Virtual Logic Pty Ltd, <http://www.vl.com.au>
    21-25 King St, Rockdale, 2216
    Ph: +612-9599-3255 Fax: +612-9599-3266
    Mark McDougall, May 4, 2007
    #8
  9. Sheetal

    Andy Guest

    On May 3, 7:50 pm, Mark McDougall <> wrote:
    > Andy wrote:
    > > Your sine wave stored in an array is a lookup table!

    >
    > Umm, not really. A lookup table generally implies an associated search
    > function for mapping one value to another - and an order of magnitude
    > more difficult to implement.
    >
    > The sine wave in question is more akin to a waveform sample stored in,
    > for example, a ROM. Or you could do away with the addressing altogether
    > and use a circular shift-register.
    >
    > > By reversing the sign of the output, and the direction of the counter,
    > > you can get by with only a quarter cycle of the wave due to symmetry.

    >
    > True.
    >
    > Regards,
    >
    > --
    > Mark McDougall, Engineer
    > Virtual Logic Pty Ltd, <http://www.vl.com.au>
    > 21-25 King St, Rockdale, 2216
    > Ph: +612-9599-3255 Fax: +612-9599-3266



    Umm, yes; there are more complex look up tables than simple arrays,
    but when an array is used to transform the input vector (address) into
    the output vector (data element), it is in fact a look up table, and
    if coded correctly will be implemented as a ROM or RAM in an FPGA.
    Just because the search function is implemented very efficiently in
    hardware (address decoding) does not mean there is no search function.

    For all but the smallest tables, an addressed ROM/RAM (using
    appropriate FPGA resources) is almost always more efficient than a
    circular shift register.

    Andy
    Andy, May 7, 2007
    #9
  10. Sheetal

    hsvjap

    Joined:
    Mar 15, 2008
    Messages:
    17
    signal generator using fpga

    Hello all,
    Iam new to this community.i am doing my final year engg proj on fpga.Sythesizable function generator. i have written the codes for sine wave generation,wat must be included to vary the frequency. can someone help me in generating square and triangular wave with variable frequency.
    plz mail me at




    Thanks in advance.
    sahana
    hsvjap, Mar 15, 2008
    #10
  11. Sheetal

    jtngangani

    Joined:
    Feb 19, 2010
    Messages:
    1
    hi
    i am trying to generate sine waves of different frequencies using LUT. i am using AD558JN as DAC having max 1.5us settling time.though i am able to generate diffrent frequencies ,the shape of waveform i am getting , does nt exactly resemble sinewave.

    cud anyone tell waht problem i am facing? i hv used 20Mhz clock and LUT has 256 samples.do i need to latch my FPGA o/p till it renders next sample to the dac?? i hv XC3s200 fpga
    jtngangani, Feb 19, 2010
    #11
  12. Sheetal

    vipinlal

    Joined:
    Feb 25, 2010
    Messages:
    38
    get the code from here..
    vhdlguru.blogspot.com/2010/03/simple-sine-wave-generator-in-vhdl.html
    vipinlal, Mar 17, 2010
    #12
  13. Sheetal

    argenteuilrocks

    Joined:
    Jun 16, 2010
    Messages:
    1
    Hi!
    I'm a university student too and need to produce a sine wave C code for a Nios II core. It will then be compared by a comparator, written in VHDL, with a triangular wave also written in VHDL. Will it be fine if I use the sin function to write my sine code? And how can vary the frequency in it?
    argenteuilrocks, Jun 16, 2010
    #13
  14. Sheetal

    Geethu

    Joined:
    Apr 13, 2011
    Messages:
    1
    generation of I&Q signals for sateliite communication

    hiiiiiiii everyone

    m workin n a project 4my finl year B.E
    its based n generating i/q sinals bt r8 nw i need details of Y SHOULD WE USE I/Q signals? also i hve written code bt m n need f mre details since i need 2prepare report...
    m usin cyclone III altera kit quartus II S/W..so pls gve me details regardin data sheet,flowcharts etc...
    Geethu, Apr 13, 2011
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sheetal
    Replies:
    1
    Views:
    1,268
    quantum_dot
    Apr 25, 2007
  2. hsvjap

    signal generator on fpga

    hsvjap, Mar 15, 2008, in forum: VHDL
    Replies:
    0
    Views:
    771
    hsvjap
    Mar 15, 2008
  3. Vikram
    Replies:
    0
    Views:
    801
    Vikram
    Jul 24, 2008
  4. enisosousse

    GPS signal generation using a FPGA

    enisosousse, Apr 3, 2010, in forum: VHDL
    Replies:
    1
    Views:
    758
    rman1234
    Apr 9, 2010
  5. picnanard

    fpga board with parallel dac?

    picnanard, Nov 22, 2010, in forum: VHDL
    Replies:
    0
    Views:
    719
    picnanard
    Nov 22, 2010
Loading...

Share This Page