ABC Testing with Momentary Switches

Using SigmaStudio 4.5 and ADAU1452 DSP. I am trying to setup an ABC test with one input and 3 outputs. I have a board with 3 momentary switches connected to 3 AUX ADC inputs. I'm using ADC inputs now because it's what I have available but eventually I will use GPIO or read from microcontroller via I2C.

Anyway, what I want to do is if one of the buttons are pressed it will activate that output and keep it on. If another button is pressed it will deactivate the currently active output and enable the selected output. Essentially, this is intended to operate like a relay board. Also, if the currently active channel is pressed again it will deactivate itself. However, I'm open to using a universal mute button instead, if that's easier.

It's easy to just add a Toggle On/Off block for each channel, but what's stumping me is how to check all the other toggle blocks and turn them off if they are on. I have an external index selected audio signal router setup with 4 mixes that routes the input (in this example a sine wave generator) to the respective output. Therefore, I've made it so that each control channel's output value is equal to the channel number. What's making this harder is I'm also hoping I can make this easily scalable for more or less outputs without having to change too much. I'm sure I could add a bunch of ABCD condition blocks but as I add channels that gets more complicated. Maybe I could also use a few logic blocks but I can't see how that could help me toggle off any active channels.

Am I fooling myself? Would it be simpler to just use a physical relay board and be done with it? Or is there an easy enough way to implement this in SigmaStudio?

Here's what I have right now:

resized image
[edited by: MattRobinson at 3:01 AM (GMT -4) on 27 Oct 2020]
  • 0
    •  Super User 
    on Oct 28, 2020 1:00 AM 4 months ago

         Hello Matt,

         Yes, it's not difficult to have individual channels toggle ON and OFF.  Also not hard to do a "radio button" select.  To accomplish both, however, is quite the stumper.  After a few hours of frustration I got something to work.  It's not pretty, though.  There's got to be a simpler way! Yet here it is, in case you find it useful.

        The ABCD Comparators output high for Aux ADC inputs exceeding  integer 512 (halfway).  This arrangement also works with GP inputs, although you can dispense with the comparators in that case.  Now the logic section is quite the mess.  It has several functions:

    • When a button is pressed it locks out the other two channels.
    • It latches the selected channel ON.
    • It remembers to reset the channel OFF if the same button is pressed again.

         The attached project uses the GUI switches since my eval board lacks convenient access to the Aux ADCs.  And I tested it with tone oscillators to save the trouble of attaching multiple audio inputs.

         Best regards,


  • 0
    •  Analog Employees 
    on Oct 29, 2020 11:09 AM 4 months ago

    Hello Matt, 

    Wow, I will echo what Bob says that this is a tricky problem. This is screaming for a cell that does this. Bob has a good solution but I went at it to see if I could come up with another way to do it that was simpler but it is difficult. I think my solution might be slightly simpler but I have not looked at the MIPS usage to see which is lighter on MIPS. So you have a couple of solutions here. 

    In my solution it starts up with the outputs all muted. This may or may not be good for your application. My example will have to be adjusted to work with AUXADCs. I suggest you use the example that Bob showed with the ABCD blocks to translate the AUXADC inputs to 32.0 format and to adjust the polarity. 

    I also went a little further and showed how to use a MUX to actually switch the audio so this is the full solution. If nothing is selected the output is muted. 

    Thanks for the challenge, I know Bob enjoys these challenges as do I. We also like showing how there are many ways to solve the same problem with the SigmaStudio tool. 

    Here is the main program page, I used a hierarchy board to simplify the screen. 

    Here is what is inside the board:

    Here is the project:

    ADAU1452 GPIO Controlled Mux Cross

    Dave T

  • 0
    •  Super User 
    on Oct 29, 2020 7:44 PM 4 months ago in reply to DaveThib


         I like the use of the PB counters and the bitwise ANDs.


  • , , thank you both for your replies. You're both awesome! I was thinking just what DaveThib said, that this is screaming for a block. Anyway, I'm sorry I haven't replied yet. I'm insanely busy trying to get this project out the door at the moment. But I will follow up once things calm down. I ended finding my own solution that's simpler than both of yours (I think) but requires a universal mute switch, which I decided is acceptable for this situation. I'll also include that in my reply later.

  • Hey  boy do things get crazy in this industry. I'm not going to have much time to investigate or follow up on this in the near future so I'm just going to post what I ended up with so you can see what I did.

    Note, I ended up using gain blocks to assign values to each channel because the multiply blocks were acting weird (I had never used multiply blocks before and they were not outputting results I would expect from basic integer arithmetic). Ended up cleaner that way anyway.

    Also, this only works for 3 channels. More than that and you'll need double the amount of OR blocks since you can't grow them.

    Lastly, this requires a universal mute button, but that ends up being a lot simpler than all the extra logic (as you found out) required to mute each channel with it's own button. I also realized that's not so intuitive for the user with momentary switches unless you have LED's signifying if the channel is active or not (which I did not include).

    Anyway, thanks again for your suggestions. Really appreciated. I will come back to this at a later date to look into it further.