Post Go back to editing

SigmaDSP control from a micro - is there an update to "Basic SigmaDSP Microcontroller Integration" ?

I'm trying to help someone get a SigmaDSP integrated with a microcontroller. Specifically how to control the parameters of the blocks in the diagram. Code download is working. If it makes a difference this is for an ADAU1452 and control is over I2C.

The ADI wiki page: https://wiki.analog.com/resources/tools-software/sigmastudio/tutorials/microcontroller  does not have any actual code examples for controlling the provided SigmaStudio examples.  We would like to compare (for example) the code needed to control the blocks in:

Simple_SS_Project_145x_146x.dspproj

with the code needed for:

Simple_SS_Project_145x_146x_INDIRECT_ACCESS_TABLE.dspproj

to see if the indirect method would make our life easier.  The actual project has 8 channels and about 20 "knobs" for each channel that need to be controlled.

By googling a document "Basic SigmaDSP Microcontroller Integration" can be found; though authored by ADI it seems to only shows up on random sites that scraped it from somewhere else.  It also seems old, and does not include anything for indirect parameter access.

The questions are:

  • Is there any example code that shows a SigmaStudio diagram and the corresponding C code to control the blocks' parameters?
  • Same, except using the indirect method?
  • A tutorial document like the one found, but up to date and showing both methods?
  • A pros and cons of indirect parameter access when there's > 150 parameters to control?
  • Sadly I think the documentation in this area is a bit lacking.  What I did was reverse-engineer the I2C commands being sent by sigmastudio (they're on the output window) and wrote my own routines to mimic them.  It all made reasonable sense after that.

  • Hello Brewster,.

    Yes, you are correct that it would be good for the Wiki to be more complete. Some entries are good like the Volume Control but for the most part, as Joe42 said, it is so easy to move a control and see what is sent in the Capture window. The other place to look in addition is the Params tab of the Capture window. 

    Also, many of these topics have been explained here on the forum, it is just a matter of finding the posts which can sometimes be a challenge. 

    The Indirect Parameter Access Table is another long discussion. It is great for cases where only a few items need to be controlled, but for large numbers it becomes too large and might even run into the size limit. This is where the controller just needs to pick up the address of the first parameter for a cell and then know what the offset is for the other parameters. Then all that needs to be stored is the first parameter in the table. This is too long of a discussion for this post. 

    The project you referred to: Simple_SS_Project_145x_146x.dspproj

    Seems to be just text and not the actually project uploaded to the post. Drag and drop it into a response in the post and I can look at it. 

    By the way, the export system files headers do contain some functions that are useful. 

    Dave T

  • Hi Dave,

    The project you referred to: Simple_SS_Project_145x_146x.dspproj

    Not quite sure I follow your question so I'll restate mine...

    In the download teensy_sigmadsp_example_project_1.1.0.zip from the wikipage are 5 example projects:

    But there's no example code that shows how to interact with them. Since the title of wikipage is Interfacing SigmaDSP Processors with a Microcontroller it would not be unreasonable to have at least one example software program that shows how to interface/control at least one of those SS example projects?

    The software in the one main.cpp provided in the .zip does not have any code for interacting with the SS application on the DSP.

    We did as others, reversed engineered things and/or pieced to together from other forum posts.

    A possible approach that could make us customers happy and get our project(s) done faster - so we place the POs sooner, on the assumption ADI will someday have chips to sell Yum  - is every wiki page for a SS block should include example code for controlling the block from a micro.

    The document Basic SigmaDSP Microcontroller Integration seems like a good starting point for further documentation, but it's odd that I can't find that ADI document on the ADI website?

    Thanks,

    Brewster

  • Hi Brewster,

    I have a good knowledge of integrating ADAU DSPs with ESP8266 and ESP32, so I'll give you some tips, obs: the code below is pseudo/partial, it doesn't work.

    1) Whenever possible, choose to initialize the DSP using firmware in binary format, storing it in a byte array inside micro processor instead of using headers generated by sigma studio.

    2) You must write or use existing routines, to read and write to the DSP via I2C or SPI, these routines must include the safeload method separately, there are numerous code examples on the internet, but most of them never have all the features together or even function as they should, as they are specific to a single DSP model.

    uint16_t dspRead( unsigned short family, unsigned char regSize, uint32_c addr, uint8_t * buffer, unsigned short size ) {}

    uint16_t dspWrite( unsigned short family, unsigned char regSize, uint32_c addr, uint8_t * buffer, unsigned short size, bool safeload = false ) {}

    uint16_t dspSafeload( unsigned char regSize, uint32_c addr, uint8_t * buffer, unsigned short size ) {}

    3) If you are going to use level meters/rta, LCDs or rotary encoders via microprocessor, it is better to use SPI to avoid problems and have better performance.

    4) When sending data ( Parameters ) always use SAFELOAD when the amount of bytes is less than or equal to 25 "Even if Sigma Studio does not send it as a safeload", this method allows the data to be sent to the DSP, which will then be modified in a single audio frame, avoiding unwanted noise.

    5) Avoid using parameter tables, it is always better to calculate all data in real time, based on the user's choice, for example the volume/gain can be calculated using percentage or decibels, thus obtaining the bytes necessary to send to the DSP.

    unsigned char * volumePercent( unsigned short address, unsigned char value ) {
    return address + (( 0x800000 / 100.0 ) * value ); // need to convert to byte array[8]!
    }

    6) Filters and parametric equalizer, always calculate the coefficients and then send the data to the DSP, I made a calculator in javascript, which includes code example ( C++, C#, Arduino Sketch ), you can see it on this website

    coeficents_t coeficents( uint16_t family, uint8_t filter, uint32_t fs, uint32_t frequency, float quality, float gain, float boost = 0 ) {}

    7) Always keep your eyes on the capture window when modifying a parameter, this way you will be able to better understand how each module sends data to the DSP.

    8) Give preference to the XML file generated/exported by sigma studio, as it makes it easier for you to update the code, reading and setting the new addresses to your microprocessor code, as well as generating a binary file for the DSP.

    9) After starting your project, I believe you can get faster and more detailed information by asking unique and specific questions about a single subject.

    10) For personal use, you can use TCPi Interface, new version will be published soon and has customizable HTML interface and is compatible with most ADAUs.

    Best regards.

  • Hi Brewster,

    I'm going to need to disagree with Rocha on this. The code on the Wiki is tested and working on real hardware, across multiple MCU platforms (including Arduino, ESP8266, and Teensy) and all SigmaDSP processor families. Each function is commented and does not rely on processor-specific word sizes.

    That being said, it's example code and not a one-size-fits-all solution. You will need to adapt it to do what you need.

    If you are using an ADAU145x or 146x, it is best to self-boot from an EEPROM and then you can use the MCU from there. There is no point to storing the full DSP image in the microcontroller.

    You may experiment with Rocha's "TCPi" interface if you wish, but please keep in mind this is not developed by ADI, and not open source, so we cannot speak to its security. Keep in mind that this will be on your network.

    When it comes to controlling individual cells, there are a few cells that have example code:

    https://wiki.analog.com/resources/tools-software/sigmastudio/toolbox/filters/firfilter

    https://wiki.analog.com/resources/tools-software/sigmastudio/toolbox/volumecontrols/singlevolume#adjusting_the_volume_control_from_a_microcontroller

    Unfortunately, for the others, Rocha is correct that the Capture Window is your best friend in figuring out how each cell derives its parameters. But you do not need to hard code addresses; use the _PARAMS.h file to specify what you are writing to.

    Finally, you mentioned the Basic SigmaDSP Microcontroller Integration project; I recall that this was done over a decade ago, but you can find it here:

     How do I create the microcontroller code to interface to my SigmaDSP? 

    Best regards,

    Joshua

  • Hi 

    I didn't mention about the WiKi code whether it's functional or not, I just talked about generic codes found on the internet, but I think I wasn't clear about this, I didn't intend to evaluate your code posted on WiKi, I didn't mention any website or developer name too.

    I just signaled to the author of the questions, the tips, which I understood to be relevant and that helped me a lot in my projects and maybe they can help him.

    I'm really sorry, if I offended you with my answer, it wasn't my intention.

    My sincere apologies.

    But I felt offended, because you mention the security risk and point out the firmware that I made available as a source of insecurity, it's as if you said that my intervention would harm people or even steal data.

    I guess it's time to stop participating in this forum

  • Everyone take a deep breath :-)

    My question was:

    Is there a place/document that provides a comprehensive tutorial with examples that shows how to operate a Sigma DSP from a microcontroller. Specifically for someone that has never used SigmaDSP.

    We all agree the short answer is no.  The full answer is "no - and there's stuff smeared all over the internet". What follows is my wish list for Sigma Studio documentation and feedback on other comments that have been posted here.

    1] The ADI wiki page: https://wiki.analog.com/resources/tools-software/sigmastudio/tutorials/microcontroller .

    One would expect this is the place people would start, given that it's a wiki and the page title implies it explains what's needed when getting started.

    It lacks ANY code example(s) of controlling a Sigma DSP application from a microcontroller.

    I would like to encourage ADI to provide the code example(s) that shows how to set up and control the five Sigma DSP projects provided on that page.

    Specifically addressing when/why of using safeloading (as   mentions) and when/why/how to use indirect parameters.

    1b] wrote: The code on the Wiki is tested and working on real hardware, across multiple MCU platforms

    Other than the two links you pointed out, I don't see any general description of controlling a SigmaDSP application.  I don't find any complete examples on the ADI Wiki.  Maybe though there's some in the EngineerZone? If so can you add links to this thread and/or the Wiki page?

    2] Basic SigmaDSP Microcontroller Integration

    Aimed at ADI: This document can not be found on the ADI website (well now it can...)

    PDF

    This pdf does seem to parallel the page provided.  It seems like cleaning this up and adding to the Wiki primary page on microcontroller interfacing would be good?  It provides some sense of how things work.

    3] Examples and explanation n the (wiki) help page of controlling all blocks that can be controlled.

    The volume control example link provided above by is great start.    There's no explanation of the Alpha values (you can google to find a link to a paper that provided) that explains them.  But not clear if they have to be written at some point, nor is safeloading mentioned.  There's no discussion about a system with multiple volume controls where maybe they need to sometimes be adjusted as a group..

    ----------------------

    Each of these issues is small and can be solved.  As a developer though you start feeling like "everyone has to do this, why am I reinventing the wheel, I need to get my product shipping."

    Addressing some other things in the discussion:

    a]  wrote: There is no point to storing the full DSP image in the microcontroller.

    Have to disagree on this.  If there's a microcontroller then almost certainly the product is software updateable. If code is in a local DSP flash then you need to figure out how to load it in the field.  Putting the flash on the micro and having it download the code solves that problem and no increase in product cost; maybe even a decrease as the micro probably had an external flash already.

    In my specific case we actually load different DSP programs as the hardware can have some operating modes that are considerably different; one large uber diagram would be way to complex as well as blow out the CPU cycles.

    b] provided a lot of great guidance. 

    Thank you for that. If nothing else it helps this thread become more of a resource for others.

    Your TCPi Interface site looks very good.  I say this not to "take sides" here, but I too don't follow what the (security) concern would be about using the source code it creates. 

    For completeness I'm adding the link to your post about it:  [SHARING] Filter coeficents online calculator with sample code for C++, C#, MicroPython and Arduino Sketch

    If I had to complain, maybe you need to add a clarification that code is not copyrighted (I think you can't copyright algorithmically generated things but IANAL)

  • An alternative for controlling  SigmaDSP ADAU1701 / ADAU1401 from PC or ESP32 is:

    ez.analog.com/.../control-sigmadsp-adau1701-adau1401-from-pc-or-esp32

    If you are also interested in TCP/IP channel for remote access, please see:

    ez.analog.com/.../esp32-as-a-sigmastudio-tcp-ip-channel-server

  • Hi Friend,

    I have a platform MCU(NUCLEO-144 STM32F746)+ADAU1466EZ EVAL BOARD and PC with SigmaStudio. I'm able to program ADAU1466 either with SigmaStudio or through MCU. To do this you need to make some modificatios on ADAU1466EZ EVAL BOARD,ADAUSB2EBZ BOARD, and some wirings from ADAU1466EZ EVAL BOARD to  NUCLE-144. With this configuration MCU can read/write to ADAU1466EZ EVAL BOARD. I have working full functional code. if my platform suits your expectation I can provide these codes within 2-3 weeks, because ı Need to make some cleanup and remove confidential parts. As Dave mentioned there's no difference between ADAU1452 and ADAU146X in terms of basic functionalities. 

    Kind Regards,