7 Replies Latest reply on Feb 16, 2013 9:54 AM by user_14586677

    Noise in Analog Section

    joshua.koffman

      Hi all,

         

       

         

      First, a bit of background. I last used the PSoC about 8 years ago, on a project that was strictly digital, programmed in assembly. It worked great. Fast forward to today, and I'm trying to use the 8C29466. Since this project is fairly simple, I decided it would make a good first intro into programming in C. Recipe for disaster? I hope not...

         

       

         

      Here's what I'm up to. In short, I am building a small audio mixer. I started with the excellent app note AN16833 (http://www.cypress.com/?rID=2925) and the author's website and revisions here: http://www.cpeproto.com/mixer.html . What he's doing is using the SC and CT blocks in the PSoC to implement a 4 stereo input audio mixer, and in the process demonstrate some neat routing and use of the generic SC block User Module.

         

       

         

      My device shares the analog layout of his, but the rest is rather different. I'm using the standard DMX512 UM to receive DMX data to adjust the levels of the mixer. I'm doing this for testing at the moment, as I am easily able to generate a DMX stream to experiment with. Later I may switch protocols. However, the idea will remain the same, and is fairly simple. Take the data in, and use it to modify the levels of the op-amps in the mixer. My goal here is to have a small digitally controlled mixer to combine a few different audio streams. It doesn't have to be perfect, but I will be listening to it for a few hours at a time, so I'm making an effort to keep it clean. I have run into a few problems though, and after working on this without a ton of progress for the last couple days, I need some help. I should mention that I am currently breadboarding this on the CY3210 sample board, so keep that in mind in case it's part of my problem.

         

       

         

      My main problem right now is that the signal I'm passing is subject to a couple of different kinds of noise. First off, there is a hiss, centered around 4KHz, that is quite noticeable. That might be inherent in how the op-amps are configured, but I'm wondering if there's anything I can do to reduce it. The level does change as I adjust the op-amp levels, but even with everything at 0, it's still there.

         

       

         

      Second is a bit trickier to explain. The DMX512 UM handles receiving data and puts it into a buffer for you. Originally I had a main while(1) loop that read the values, matched them to the gain they were supposed to be adjusting, and then updated the correct SC block register. This caused a high pitched whine. Through a bunch of trial and error, I seem to have determined that if that loop is a certain length, it generates noise in the op-amps. This is with all gains at 0. I pared the loop down to a single if statement that checked the first channel, if the old and new values were different, it would update the current value, then update the SC block. That ran without noise. I copied it so that it ran twice in succession, and it made the noise. Changing the number of times it ran seemed to change the frequency of the noise. In fact, just running a counter in that loop, and not updating anything made a noise.

         

       

         

      What I've done for the moment is move those if statements into the DMX512 ISR, so that they only run once per packet. There's no reason to have them run more frequently, the data can't change in between packets anyway. It does feel like a bit of a cheat though, as I haven't really solved the problem. Even with this change, I can hear a ticking noise whenever I'm receiving DMX.

         

       

         

      So...what am I doing wrong? I am really confused. I can't imagine that the analog system would be this noisy and subject to interference, or what could would it do folks who are trying to use it to measure things?

         

       

         

      Any thoughts would be appreciated. I am happy to share my code and Designer files if that would help, I just didn't want to bombard the forum with files.

         

       

         

      Thank you!

         

       

         

      Josh

        • 1. Re: Noise in Analog Section
          user_14586677

          You might look at the following -

             

           

             

          1) Set Analog Ground bypass to external and bypass it.

             

           

             

          2) 4 Khz is suspicious, is VC2/3 and system clock set up such that the divisors result in

             

          4 Khz ?

             

           

             

          3) Do you have an LCD in the project, it has a refresh controller that might fall into that

             

          update range. Consider adding additional bypassing to it.

             

           

             

          4) Use polymer tantalums and add to Vdd line to get pk-pk Vdd noise down. This will help

             

          components affected by PSRR, like SC and CT blocks. Use scope on infinite persistance

             

          and chase pk-pk noise sources with additional bypassing.

             

           

             

          5) The 3210 is not "layed" out for pro audio quality work, eg. seperating Analog and Digital

             

          grounds where possible.

             

           

             

          6) The DMX module ISR, set a flag inside it, and process your stuff outside that loop, If

             

          you look at the notes, below, it might be you are adding enough latency to get to the 250

             

          uS noise source.

             

           

             

          The DMX512Rx User Module provides one interrupt each time space for break is detected and one interrupt for each byte received by the RX block. When data is sent with the mark time between slots set to zero, the interrupt occurrence frequency is equal to 44 µs. If the CPU clock is set to 24 MHz, the time required to execute the interrupt service routine (ISR) for bytes that are included into the active slot is 5.7 µs. For this reason, a CPU clock of 12 MHz is recommended. In no case should the CPU clock be set less than 6 MHz.

             

           

             

          7) Last, but more difficult, consider turning off all ancillary digital and only turn on DMX when a start

             

          of packet is detected. You would have to investigate how to do this.

             

           

             

          Just sone thoughts, Dana.

          • 2. Re: Noise in Analog Section
            joshua.koffman

            Hi Dana,

               

             

               

            Thank you for the ideas! Answers/Questions below:

               

             

               

            > 1) Set Analog Ground bypass to external and bypass it.

               

             What's the recommended way to do this? Just a 1uF cap to ground? I am leery about this as in the original schematic, the author was using the External AGnd pin as a ground reference for the inputs, but was told that could cause excessive current draw through that pin, damaging the PSoC.

               

             

               

            2) 4 Khz is suspicious, is VC2/3 and system clock set up such that the divisors result in 4 Khz ?

               

            I shouldn't. I currently have CPU Clock at SysClk/1 (though I should try setting it back to SysClk/2), VC1 = SysClk/6 (4MHz for the analog clock), VC2 = VC1/2 (2MHz for the DMX RX), and VC3 = VC2/13 (153.8 KHz for DMX Break detection).

               

             

               

            3) Do you have an LCD in the project, it has a refresh controller that might fall into that update range. Consider adding additional bypassing to it.

               

            Nope, no LCD.

               

             

               

            4) Use polymer tantalums and add to Vdd line to get pk-pk Vdd noise down. This will help components affected by PSRR, like SC and CT blocks. Use scope on infinite persistance and chase pk-pk noise sources with additional bypassing.

               

             I'm running the dev board off a 9V battery specifically to keep Vdd noise down. Eventually this will be run off a NiMH battery pack.

               

             

               

            5) The 3210 is not "layed" out for pro audio quality work, eg. seperating Analog and Digital grounds where possible.

               

             Agreed, and luckily this isn't really pro audio. I'm mixing together a few audio streams (a couple of radios, an intercom, etc) for me to listen to, but it isn't hi-fi. All the extra noise does make it hard to listen to though.

               

             

               

            6) The DMX module ISR, set a flag inside it, and process your stuff outside that loop, If you look at the notes, below, it might be you are adding enough latency to get to the 250 uS noise source.

               

            <Note snipped>

               

            I will try setting a flag and report back. I don't understand your comment about adding latency though. When I'm doing the processing in the ISR the noise is lower than if I do it in the main loop.

               

             

               

            7) Last, but more difficult, consider turning off all ancillary digital and only turn on DMX when a start of packet is detected. You would have to investigate how to do this.

               

            Interesting idea. I'm not sure how I'd do this either. I don't know that there's enough interpacket space to really make a difference. That said, it might not be a bad idea. I'm going to leave this one for now as I don't know how I'd do it, but I will come back to it if I can't make any headway on other things.

               

             

               

            Thank you!

               

             

               

            Josh

            • 3. Re: Noise in Analog Section
              user_14586677

              For analog ground just choose AgndBypass in Global properties, and enable

                 

              it. Add 1 uF cap to pin.

                 

               

                 

              http://www.cypress.com/?rID=2779

                 

               

                 

              Latency in an ISR occurs if you do API calls inside the ISR, because of additional stack push/pull

                 

              to call functions. Wheras in main(), if constructed properly, calls can be eliminated or reduced.

                 

              Additionaly if you have to do calls, design them to minimze stack demands, like use pointers

                 

              rather than values for example.

                 

               

                 

              The basic approach to turning off extraneous digital activity is embodied in simply turning off modules

                 

              not needed with a xxx_Stop() call. This may help (low power techniques, about turning stuff off) -

                 

               

                 

              http://www.cypress.com/?rID=34189

                 

               

                 

              The 4 Khz noise, all I can offer is try tests, like change main clk, did the 4 Khz change, 1:1, then

                 

              its a f() of the main clock. If not something else. If you have a spectrum analyzer, sniff some

                 

              pins to see if there is a pronouced fundamental component on one pin. Detective work. Power

                 

              off one module at a time to see if associated with a specific module.

                 

               

                 

              Regards, Dana.

              • 4. Re: Noise in Analog Section
                user_14586677

                Reagarding the cap for analog ground bypass, you might want to

                   

                connect a diode to Vdd, as well as the cap to ground, such that if Vdd

                   

                is rapidly discharged, the cap gets discharged with it. Not knowinjg the

                   

                device die level connections on that pin, just a safeguard.

                   

                 

                   

                Regards, Dana.

                • 5. Re: Noise in Analog Section
                  joshua.koffman

                  I'm still working through a few things, but wanted to post an interim report.

                     

                   

                     

                  I am working on changing my code to remove the gain setting function from the ISR. More on that when I finish that work. I have made a couple of observations though.

                     

                   

                     

                  Setting the AGndBypass to external and bypassing it has helped clean up a good chunk of the annoying whine. So that's a huge plus! There is still a noice in the background.

                     

                   

                     

                  At the moment, I am still getting a lot of background hiss in the audio stream. When I first apply power, with no DMX running to the unit, the audio output has a slight hiss. The code defaults all gains to 0, so this should be the quietest the system can get. When I start sending DMX packets, there is the audible ticking I mentioned earlier, which stops when I stop the DMX. I'm thinking that I might have the controller only send packets when there are changes on that end. That would mean no packets for most of the time. I'll have to add some code on the PSoC to implement a debounce routine (for lack of a better term). While the amps hold their values with no updates, the moment I re-enable DMX there's a small blip that I am guessing is coming from an incomplete first frame, or something like that. I'll have to look into that more. 

                     

                   

                     

                  The bigger problem is that the hiss level goes up dramatically when I raise the level on the main left and right SC Blocks. It doesn't go up dramatically after that when I raise the gain on blocks earlier on in the chain, or at least not that I can notice. I've tried setting the mains to a gain of 1 and bringing the others up all the way, and I don't hear much more hiss. I do hear a bit more of that whine, but that might be partially due to bad layout on my board. I wonder if there's a way to route the inputs of that SC Block to ground somehow to see if it gets rid of the noise. That said, with the gains set to 0 there shouldn't be any difference.

                     

                   

                     

                  Thanks!

                     

                   

                     

                  Josh

                  • 6. Re: Noise in Analog Section
                    user_14586677

                    I think one chief issue you have is dynamic range of human hearing, ~ 130 db, which is tough

                       

                    to do with discrete low noise OpAmps, let alone a sampled data approach with no filtering other

                       

                    than the effects of a sample data switch.

                       

                     

                       

                    Since whine source is still un-identified its a bit of a crap shoot trying to find problem. You could try

                       

                    alternate placement of components, or try different gain distributions in the signal chain. Or a notch

                       

                    filter targeting the 4 Khz. Although not knowing source of 4 Khz repeatability of that approach comes

                       

                    into question. Makes me wonder if 4 Khz comes from part of the sleep timer chain divider......

                       

                     

                       

                    Also possible is a differential approach to mixer, to see if the 4 Khz is common mode by nature.

                       

                    Just a thought.

                       

                     

                       

                    If you went to PSOC 5, with digital filter, do mixing in digital domain. But then PSOC 5 has no

                       

                    hi res DAC to reconstruct.

                       

                     

                       

                    Regards, Dana.

                    • 7. Re: Noise in Analog Section
                      joshua.koffman

                      Hi Dana,

                         

                       

                         

                      I'm sorry for the lack of response from me for a couple of days. I travel a fair bit for work, and wouldn't you know it, just as I was getting some good experimenting in, I've had to hit the road again. This means a little while away from my dev tools unfortunately. It does mean I can spend time doing research.

                         

                       

                         

                      What do you mean by a sampled data approach? I should be running the audio through the op-amp user modules alone, there should be no sampling.

                         

                       

                         

                       

                         

                      In regards to the sleep timer suggestion, it's currently set to 512Hz. Would you suggest trying a different setting and listening? It's a lot harder to hear now that the analog section is bypassed properly. At the moment it's being buried by the hiss, which like I mentioned previously is rapidly becoming my major concern.

                         

                       

                         

                      As for DSP, I'd love to. I originally thought that this was the perfect application for a DSP solution, as not only could I do all the mixing in the digital domain, but I could potentially add dynamics processing (compression and limiting) as well. MY only problem is that I haven't found a solution that I'm smart enough to use. This is my first C program, so I don't know if there are DSP modules that would make things like mixing signals easy to code.

                         

                       

                         

                      One option might be the SigmaDSP chips from Analog: http://www.analog.com/en/content/cu_over_sigmadsp_overview/fca.html - they have a graphical configuration program that might make it easy enough. 

                         

                       

                         

                       

                         

                      I am definitely open to other ways of solving this problem. The reason I gravitated towards the PSoC was the excellent app note, as well as being able to build a mixer that didn't involve a bunch of discrete op-amps. The digital control possibilities were the icing on the cake. 

                         

                       

                         

                      There used to be a chip called the SSM2163 which was a digitally controlled audio mixed that would have been perfect...it's been obsolete for a number of years though. Another is the ICS2101, also obsolete. I haven't found anything else like these, I would guess most people have moved to DSP.

                         

                       

                         

                      As always, thoughts welcome!

                      • 8. Re: Noise in Analog Section
                        user_14586677

                        In the context of noise using a PSOC sample data filter to suppress whine

                           

                        is what I was referring to.

                           

                         

                           

                        Regards, Dana.