EmbDev.net

Forum: FPGA, VHDL & Verilog sine wave: how to set amplitude?


Author: Jason Kee (Company: Myreka) (jasonkee111)
Posted on:

Rate this post
0 useful
not useful
Hi. If i generate a sine wave signal(Full Scale - 24bit - 5Vpp) using 
the altera NCO, how to generate a 0.8902 Vpp sine wave?

thanks

Author: Na sowas (Guest)
Posted on:

Rate this post
0 useful
not useful
If you are already able to generate the full scale signal, you will have 
to scale down the full scale value by multiplying it with a factor of 
0.17804. Because thats not the easiest task to build in hardware, its 
more convenient to multiply it with a value eg. 2917 and divide it by 
16384 = 2^14. Another pair of values with less error is a multiplication 
with 5974013 divided by 33554432 = 2^25. But here you should have a 
close look for the implementation because the AD value is 24 bits, plus 
the downscale is 25 bits, therefore you will need a intermediate result 
with 49 bits.

Author: Jason Kee (Company: Myreka) (jasonkee111)
Posted on:

Rate this post
0 useful
not useful
How do u get the number of 2917 and 16384?  Actually i want to generate 
a sine waveform with adjustable amplitude.

Author: Na sowas (Guest)
Posted on:

Rate this post
0 useful
not useful
> How do u get the number of 2917 and 16384?
Take the 0.17804 and multiply it by 2, repeat this until the fractional 
digits are 0. Count the multiplications. In case of 2917 it took 14 
multiplications to get 2917,00736. So the resulting factor is 2917/16384 
= 0.178039550781. This causes an error of 2.5e-6, which is 42 LSB of 24 
bits.

So this isn't enought accuracy for a 24 bit DAC. You will have to 
increase the accuracy at least by the factor 2^6 = 64, so the next 
matching number will be 5974013/2^25 = 0.178039461374.

> Actually i want to generate a sine waveform with adjustable amplitude.
Multiply the output with a value of 0...65535 and divide the result by 
2^16. this will give you a resolution of 16 bit in the output amplitude.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.