2013-03-09 05:29 AM
Hello, I am trying to generate sinusoid signal via DAC. I can´t use look up table of sine values, because user will enter amplitude. So values of sine are first computed in program and than stored in buffer:
sine[i] = (sin(2*PI*i/number_of_samples)+1)*((amplitude+1)/2); But it isn´t generate anything. It is very strange because values are stored correctly. There is some problem with sine function. When I delete sin(), DAC works. Do you know why it doesn´t work with computing sin(x)? Thank you for answeres.2013-03-09 05:59 AM
Ok, so what data is actually generated?
Can you show the complete loop, with variables? Is it a problem with int vs float/double variables, and conversion/casting?2013-03-09 07:43 AM
Hi,
I generate sine wave(in the the audio frequency range), using pre-calculated 1024 point table in flash. To edit the output amplitude i just multiply/devide each sample by a float value. Although i am using external DAC, i think same technique should work on the internal one. Regards, Chris2013-03-09 02:19 PM
''I can´t use look up table of sine values, because user will enter amplitude''
Of course you can use a lookup table - it's just a matter of applying the appropriate scale factor to get the requested amplitude!!2013-03-17 06:46 AM
Dear Pavel,
You might find a chapter on DDS (16th from the top) at useful. Regards