EmbDev.net

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


von Jason K. (Company: Myreka) (jasonkee111)


Rate this post
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

von Na sowas (Guest)


Rate this post
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.

von Jason K. (Company: Myreka) (jasonkee111)


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

von Na sowas (Guest)


Rate this post
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.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.