Post Go back to editing

SigmaStudio+ / ADSP21569 - How to set the Sine Wave frequency externally

Category: Software
Software Version: 2.1

Hi!  Had a question and couldn't find the answer in the documentation or an forum post.

Adding a Sine generator in SigmaStudio+ 2.1 adds these parameters that can be controlled externally:

GUI Control Name Compiler Name Function Description
Frequency_cos ToneGenwithPhaseGainBlkAlg1cos Cos value for generating a particular frequency
Frequency_sin ToneGenwithPhaseGainBlkAlg1sin Sin value for generating a particular frequency
Phase ToneGenwithPhaseGainBlkAlg1phasevalues Cos and Sine value packed for all growths to generate a specific phase
Gain ToneGenwithPhaseGainBlkAlg1gain0 Gain value

How are these parameters used to setup the sine wave to output a certain frequency? (e.g. 1KHz)

Thread Notes

  • Hi, 
    The frequency UI control parameter can be updated to change the frequency of the module. Please refer the hep page,
    SineTone [Analog Devices Wiki]

  • I see, there is a 2nd help page for SS+, thank you for sending this.

    I did test this today, I have two notes and a further question:

    1. The documentation lists the number format as "float" but in fact seems is "FixPoint2d30"

    2. Both Sin and Cos parameters seem to be required to successfully set the frequency.

    One further question:

    -> When setting the Sin and Cos parameters, the frequency can be set correctly now.  But unfortunately, seems the gain may be affected as well?

    On reset, it always begins with full scale 0.0dBFS output.  But while setting the frequency, the gain may start to vary a lot, sometimes reduced by 10dB or more and sometimes I think higher than 0.0dBFS and clipping.  I tried setting also the Gain of the Sine generator- directly back to 1.0 after I set the Sin and Cos parameters, but it has no effect.

    I'm wondering if this this a known issue, and if so is there any workaround for it?

    If it helps, here are some example parameters I am passing to the sine generator that causes the gain to be reduced.  Our sample rate is 48KHz:

    2024-08-12T21:21:54 user.info runtime_engine: ifd_dsp_sine_freq_callback() - channel 0 freq change to 2000 Hz aka sin(0.258819), cos(0.965926)
    2024-08-12T21:21:54 user.info runtime_engine: write_all(): FLOAT_2_30_WRITE - writing float 0.258819 as 2.30 int 0x10907de0
    2024-08-12T21:21:54 user.info runtime_engine: write_all(): FLOAT_2_30_WRITE - writing float 0.965926 as 2.30 int 0x3dd1ba80
    2024-08-12T21:22:01 user.info runtime_engine: ifd_dsp_sine_freq_callback() - channel 0 freq change to 500 Hz aka sin(0.0654031), cos(0.997859)
    2024-08-12T21:22:01 user.info runtime_engine: write_all(): FLOAT_2_30_WRITE - writing float 0.0654031 as 2.30 int 0x42f9098
    2024-08-12T21:22:01 user.info runtime_engine: write_all(): FLOAT_2_30_WRITE - writing float 0.997859 as 2.30 int 0x3fdcebc0

    thanks!

  • There is no issue when we tried with scripting update for frequency change. Please refer the code snippet, 


    Are you using python or C# project to update the parameters?
    If possible, please share the sample schematic and script files to simulate the issue. 

  • We are using Linux host to communicate to the '569 part over SPI, then updating the SS+ parameter on the DSP with function adi_ss_control_fw_UpdateSSn()

    With the above working example, can you help to share the details of call client.Update_Property()?  Is this scripting SS+? 

    When we change the parameter in SS+, it is working as expected, it is only when calculating Sin and Cos values ourself  that the gain issue happens.  I'm wondering if there may be some issue in our calculations.

    Here is our code to calculate the parameters:
    float sin_freq_fs = std::sin(M_PI * 2.0f * frequency_hz / DEFAULT_SAMPLE_RATE);
    dsp_if->set(sin_command, sin_freq_fs, channel);
    float cos_freq_fs = std::cos(M_PI * 2.0f * frequency_hz / DEFAULT_SAMPLE_RATE);
    dsp_if->set(cos_command, cos_freq_fs, channel);
    dsp_if->set(gain_command, 1.0f, channel);
    std::cout << "ifd_dsp_sine_freq_callback() - channel " << channel << " freq change to " << frequency_hz
    << " Hz aka sin(" << sin_freq_fs <<"), cos(" << cos_freq_fs << ")";

    and also our code to calculate the 2.30 fixed point

    case FLOAT_2_30_WRITE:
    {
     float limited_data = buffered_write.data;
     limited_data = ( limited_data >= 2.0f ) ? 1.99999999f : limited_data;
     limited_data = ( limited_data <= (-2.0f) ) ? -1.99999999f : limited_data;
     int32_t int_data = ((double) 0x40000000) * limited_data;
     std::cout << "write_all(): FLOAT_2_30_WRITE - writing float " << limited_data << " as 2.30 int 0x" << std::hex << int_data;
     write_register_int(buffered_write.address, int_data);
     break;
    }

    thanks!

  • The sine and cosine parameter used in sine series formula calculate the next sample. The function what I have shared is SigmaStudioPlus script API's to change directly the frequency UI value which internal computes the sin and cos parameter.
    For more details,
    SigmaStudio+ Scripting [Analog Devices Wiki]

  • Could the reason be that these registers are Safeload?

    Is the process for safeload of registers in SigmaStudio+/SharcDSP the same as SigmaStudio 4.6/Sigma DSP? i.e.  How do I execute a software safeload write? 

    Thanks!

  • Hello   reminder on the above question.

    Just looking for the write address and procedure to Safeload into the 21569 running Sigma.  I didn't see any documentation for this anywhere, and also I see the same question being asked here I think ez.analog.com/.../adsp-21569-safeload

    Thanks!

  • are you trying to write parameters from external Host (MCU or Any tuning tool)?

  • Hello   yes, recap my above question. 

    • We are using SigmaStudio+ 2.1, CCES 2.11.1, and ADSP-21569
    • We are attempting to set the frequency of a Sine Wave object using a Linux external host, communicating to DSP over SPI interface 
    • Just setting the "Sin" and "Cos" parameters normally can cause some unexpected behavior
    • Per the documentation, I noted these parameters should be set by the Safeload procedure

    So I am wondering how an external host can use the Safeload procedure in Sigmastudio+ for Sharc, i.e. what addresses should be written to?  I did not find any documentation on this.  Thank you!