How to make a parameter follows the waveform of another parameter - C code -


in c code, gets input hardware (altera nios ii system), input "vref" sinusoidal waveform. edit: in altera quartus in vhdl, generates sinusoidal waveform "vref" becomes input c code. (c code used program processor nios ii)

in c code, have input "vref_new", "vref_new" variable value keeps changing based on calculations. edit: "vref_new" new value amplitude "vref"

edit: should when plot "vref_new" output on graph, "vref_new" plotted sinuisoial waveform instead of amplitude? frequency , sample rate of "vref_new" should follow of "vref". vref sinewave, vref_new updated amplitude replace amplitude in vref.

if know amplitude of "vref" constant 40, can this:

vref_new= vref_new*vref*(1/40); 

but trouble don't know amplitude of "vref" not constant.

edit: reason divide 40 correct amplitude given "vref_new".

edit: vref sine wave generated vhdl custom block in quartus, , vref_new value represents amplitude of sine wave.

vref varying sinusoidal signal, amplitude needs updated vref_new. after system vref, did calculations obtain vref_new, vref_new amplitude, how can plot vref_new show me sinusoidal signal?

i apologize if question sounds stupid....thank in advance

#define vref_base 0x00002220  int16_t vref=0, vref_new=0;  vref = iord_altera_avalon_pio_data(vref_base); vref_new = a*b/c; //some calculation amp_vrefnew=(int16_t)vref; vref_new = vref_new*vref/amp_vrefnew; //in order make vref_new follows sinewave of vref 

look @ green line in image, still not sinusoidal waveform, green line vref_new while black line vref

enter image description here

however, if following replacing "amp_vrefnew" constant "3920", can sinusoidal waveform vref_new,

#define vref_base 0x00002220  int16_t vref=0, vref_new=0;  vref = iord_altera_avalon_pio_data(vref_base); vref_new = a*b/c; //some calculation vref_new = vref_new*vref/3920; //in order make vref_new follows sinewave of vref 

is problem vref_new zero? that's because 1/40 0 in c's integer arithmetic.

if vref_new non-varying amplitude, , vref sinusoidal signal in range [-1, 1], then

x = vref_new * vref; 

is want.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -