SMPS, Microcontroller and Analog Compressor

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

dirtyhanfri

Well-known member
Joined
Jan 16, 2011
Messages
677
Location
Madrid - Spain
Hi all

I’m experimenting with a microcontroller inside an 1176 clone, just for simple tasks, control some relays and read the GR signal going to the meter.

Compressor works nicely and noise free, but as soon as I power the microcontroller (an Arduino like dev board) I get a 2.4KHz peak (with even harmonics) in the audio path. Amplitude changes with output knob from -80 to -60 dbu at max level. I’m almost sure it’s noise coming from the microcontroller processor, as it changes its frequency with processor speed, when it’s running at 240MHz I get the mentioned noise, but if I run it at 80MHz, the noise goes to 800Hz, 1600Hz when running at 160Mhz... seems closely related.

Another issue is after a while powered on and working, the 5V supply suddenly starts going on and off intermittently, not sure if it’s related to the low current demand to the PSU (I’m using about 800mA in the worst case)

I’m using a 5V 5A SMPS just for the digital circuit, with a 0.1uF cap as decoupling for the microcontroller board (I ASSume processor circuitry is properly designed in the dev board) 100uF for the relays and 0.1uF for 4 RGB LEDs driven by the microcontroller.

Digital and analog 0Vs are completely separated, meeting only at one point, in the chassis, if I disconnect digital 0V from chassis I can see how 2.4KHz. peak goes 3db’s up.

Everything is built into a rack case, microcontroller, power transformer and 5V PSU on one side and analog circuit on the other side, keeping as much distance as possible and quite neat wiring.

My doubts are: Is there any way to reduce the noise coming from the processor? Maybe a LPF in the 5V supply?

Am I suffering from Hiccup mode from the SMPS and should I switch to a smaller 5V SMPS?

Thanks
 
dirtyhanfri said:
Am I suffering from Hiccup mode from the SMPS and should I switch to a smaller 5V SMPS?
Very likely. Now it's not difficult to diagnose. Just pust a resistor across the output of the smps as to draw about 20% of the nominal current.
That would be a 270 or 220 ohm 1W (for intermittent use, for continuous use, you  wouls use a 4-5W). If the noise disappears, you know what you have to do.
 
abbey road d enfer said:
That would be a 270 or 220 ohm 1W

Thanks for the tip, but shouldn't it draw just 22mA? given the PSU is 5V 5A, I would need to draw 1A.

Keeping in mind the circuit is rarely drawing 800mA (it would be more like 500 during in normal operation) maybe I could use a 10 Ohm, 5W resistor, just for testing until I order a smaller PSU, it should draw 500mA, plus the circuit I'll be around 1A total current consumption. Sorry if I'm saying something stupid...

I'm thinking in test with a cheap 5V psu from a cellphone, but I'm afraid I'll have another psu noises going on.
 
dirtyhanfri said:
Thanks for the tip, but shouldn't it draw just 22mA? given the PSU is 5V 5A, I would need to draw 1A.
Correct! What was I thinking?  :-[

Keeping in mind the circuit is rarely drawing 800mA (it would be more like 500 during in normal operation)
That was a missing info. So that definitely excludes the hiccup hypothesis.


I'm thinking in test with a cheap 5V psu from a cellphone, but I'm afraid I'll have another psu noises going on.
The definitive test would be with a linear PSU.
 
I am not familiar with arduino tricks (or "arduino like"), but most better micros support sleep mode, so you might be able to put it to sleep unless it needs to wake up and change something.

I designed a microprocessor based master section meter for a commercial console and had measurable noise floor interactions. I found the noise was related to the clock used for serial communication between micro and LED meter shift register latches. (I think our fix was to push the clock rate higher). Note: the noise was measurable but not audible.

Back to your topic the obvious thing to try is a good HF cap shunting directly across the micro PS.

JR
 
dirtyhanfri said:
I’m experimenting with a microcontroller inside an 1176 clone, just for simple tasks, control some relays and read the GR signal going to the meter.
Nice! I like it. Mixing microcontroller with analog circuits is a great idea. They can handle so much. But there are a lot of rules about mixed analog and digital circuits. It all has to be just so or you'll get ....

dirtyhanfri said:
Compressor works nicely and noise free, but as soon as I power the microcontroller (an Arduino like dev board) I get a 2.4KHz peak (with even harmonics) in the audio path.
Noise! So the 1-3kHz range. That sounds familar.

dirtyhanfri said:
Amplitude changes with output knob from -80 to -60 dbu at max level.
Ok, so lots of noise. That sounds familiar.

dirtyhanfri said:
I’m almost sure it’s noise coming from the microcontroller processor, as it changes its frequency with processor speed, when it’s running at 240MHz I get the mentioned noise, but if I run it at 80MHz, the noise goes to 800Hz, 1600Hz when running at 160Mhz... seems closely related.
Ok, that wasn't what I was thinking but like I said, there are multiple rules about mixed digital and analog which is to say you could have multiple problems going on simultaneously. So if you try one thing and the problem doesn't go away, that doesn't mean your fix didn't do anything.

dirtyhanfri said:
Another issue is after a while powered on and working, the 5V supply suddenly starts going on and off intermittently, not sure if it’s related to the low current demand to the PSU (I’m using about 800mA in the worst case)
Ah, that sounds familiar again.

dirtyhanfri said:
I’m using a 5V 5A SMPS just for the digital circuit, with a 0.1uF cap as decoupling for the microcontroller board (I ASSume processor circuitry is properly designed in the dev board) 100uF for the relays and 0.1uF for 4 RGB LEDs driven by the microcontroller.
5A!? Gadzooks! I think I definitely know what the part of the problem is.

dirtyhanfri said:
Digital and analog 0Vs are completely separated, meeting only at one point, in the chassis, if I disconnect digital 0V from chassis I can see how 2.4KHz. peak goes 3db’s up.
Then what do you use as the ground reference to feed the CV signal into the microcontroller? Are you connecting DGND and AGND together there too?

dirtyhanfri said:
Everything is built into a rack case, microcontroller, power transformer and 5V PSU on one side and analog circuit on the other side, keeping as much distance as possible and quite neat wiring.
Post a pic! If you're using wires for digital at all, that could be a problem.

dirtyhanfri said:
My doubts are: Is there any way to reduce the noise coming from the processor? Maybe a LPF in the 5V supply?
No.

dirtyhanfri said:
Am I suffering from Hiccup mode from the SMPS and should I switch to a smaller 5V SMPS?
Very likely.

I think building analog gear with SMPS and mircocontrollers is almost the only way to roll these days. Anything less is basically antiquated at this point. But it's not a good idea if you're not fluent in the rules of each. You should have knowledge of SMPS and how to make and use one with an analog circuit such that it's noise free. So a good first step is to make a mic pre, so that any noise from the supply is amplified, that you can then test and adjust to see that there's no noise whatsoever. Then you can try digital and start mixing stuff.

But clearly you're already committed so maybe we can make the best of what you have. Unfortunately I think you have multiple problems going on which makes it very difficult to diagnose one because they all manifest themselves as noise. So the first think that you're going to have to do is devise a rig for getting a spectrum of the noise. Pretty much everyone has a USB audio interface these days. Even a cheap one will out perform just about any analog circuit. Then get some software like Room EQ Wizard. When I was starting out, I used DSSF3 from ymec and thought it was actually pretty good but that was a maybe 15 years ago. Personally what I like to do is actually record a wav file and then study it offline. Whatever you do you're definitely going to need some visual way to see what the noise spectrum is so that as you make adjustments to your circuits, you can see if there is a change. Otherwise, you're "flying blind".

So what are these rules I keep teasing you about?

The rules for SMPS in analog gear:

1) You MUST load the SMPS with at least 20% of the rated current or it will switch into an efficient mode that modulates the output on and off at a low frequency. This is more commonly known as "hiccup mode". Hiccup mode often manifests itself as a whistle in the 1-3kHz range. For large supplies, it can create large amounts of noise at all frequencies.

The proper solution for this problems is to simply use a supply that is more closely rated to the current that you need. So at least 20% but in practice it should be more like 80%. Unlike linear supplies, SMPS actually work better when loaded. So you really could go to 90% or even near 100%. Above that and chances are that the SMPS would still work pretty well but the voltage would just start to drop. So if you needed say a 15V supply to make 300mA, you could probably use a 24V constant current supply that makes 250mA and just let the voltage drop a little. Although I've never done this. It would require some experimentation to find a supply that it really works well with. And you would loose regulation so you would need to regulate down but you would need to do that anyway if you wanted to make 15 from 24.

Another solution to this problem is to load the SMPS with a load resistor. But this is where you really need to pay attention to the power dissipated by the resistor. If your supply is 5A at 5V, to load it with 20%, that would be 5 ohms and 5V / 5R * 5V = 5W. So that would require probably one of those aluminum cased resistors mounted on a heatsink. That is not ideal. But for 500mA supply, 5V / 50R * 5V = 0.5W so strapping a 2W wirewound resistor with no heatsink directly to the output of the SMPS would probably work just fine.

One caveat to this is if the load varies a lot. For example, if you want to make a 48V phantom supply for a 16 channel console. If all of the 48V are off, the load is very low compared to when they're all on. I just posted a theoretical circuit for dynamically loading the SMPS more or less depending on the downstream load:

  https://groupdiy.com/index.php?topic=77291.msg984180#msg984180

2) You MUST not load the SMPS with more than 100% of the rated current for longer than a few ms or it will switch into a short circuit protection mode that modulates the output on and off at a very low frequency. The most likely cause of this is too much capacitance directly on the output. Usually this capacitance is limited to a few hundred uF. So if you have a bunch of 100uF capacitors all over, when you switch the supply on, those caps will create a significant initial surge current that will trigger the short circuit protection mode.

The proper solution to this problem is to use a capacitance multipler circuit. The load of the CM will turn on slowly regardless of what is downstream. However, this does incur a diode drop in voltage because of the pass transistor. But usually this isn't too much of a big deal. If you're using 48V for phantom for example, a diode drop isn't really that much. Also however, if the current is more than a couple hundred mA, a one-transistor CM is not enough. The voltage will start to drop. You need the two-transistor CM and that will incur two diode drops. Fortunately, the higher current SMPS frequently come with a trim control to trim the voltage up to compensate entirely for the two diode drops. Once you have the CM in place, then you want a fat filter cap right on the output. That will be super quiet.

If you're designing the device being powered, the proper solution is to simply design it with smaller and fewer filter capacitors. SMPS are pretty quiet to start so you really don't need a lot of filtering usually. And if you do, a little bit of series resistance (like the RC supply filters feeding the upstream parts of a discrete mic pre for example) make a big difference in limiting surge current.

The rules for mixing digital with analog:

I won't go in depth about this because it's a little too broad but I will skim over some points:
1) Return follows supply. This means that if you have say a digital signal going out over an FPC cable, you need to use a ground line right next to it for the return currents to follow right next to the digital signal going out (supply).
2) Use "termination", all digital outputs should have a 100R resistor directly on the output. This stops the digital signals from suffering from transmission line effects of high frequency signals.
3) Do not run digital signal likes next to analog. If you have a bundle of wires, you cannot have a digital wire running adjacent to an analog wire. In fact, I would not use wires at all. When I did a mixed project like this, I used conventional wire to board interconnects for audio on top of the PCBs and then I used all SMD mounted FPC connectors with FPC cables running under the PCBs along the bottom of the chassis.
4, 5, 6, .... my tea has died
 
abbey road d enfer said:
That was a missing info. So that definitely excludes the hiccup hypothesis.

My understanding is Hiccup would be caused due to small draw current from the PSU (please, correct me if I'm wrong, as I'm not so familiar with this) so smaller load would actually reinforce the hypotesis, doesn't it?

abbey road d enfer said:
The definitive test would be with a linear PSU.

Thanks, I didn't even think about it, I have some 7805s and I guess some suitable transformer, I'll try out when back in the shop.

JohnRoberts said:
I am not familiar with arduino tricks (or "arduino like"), but most better micros support sleep mode, so you might be able to put it to sleep unless it needs to wake up and change something.

Microprocessor is a ESP32, actually is reading GR signal every 100ms so I prefer not to mess with sleep mode, which is implemented in the microcontroller, but I don't see the need to use it as power consumption is not a limiting factor here as it could be on battery powered device maybe.

JohnRoberts said:
Back to your topic the obvious thing to try is a good HF cap shunting directly across the micro PS.
JR

I tried (with no evident results) with a WIMA MKS series 0.1uF Capacitor, not sure if the value is the right one or maybe another kind of cap would be better.

squarewave said:
I think building analog gear with SMPS and mircocontrollers is almost the only way to roll these days. Anything less is basically antiquated at this point. But it's not a good idea if you're not fluent in the rules of each.

Thanks for taking the time to write this massive response, highly appreciated, I absolutely agree about mixing analog gear with microcontrollers.

I'm not an electronic engineer, I understand analog circuits, and I'm learning about digital electronics, but I don't have a engineering background.

squarewave said:
5A!? Gadzooks! I think I definitely know what the part of the problem is.

So definetily I'll switch to a smaller PSU, I was using just what I had in the shop, funny I was thinking "it's big enough not to give me any trouble"  :p

squarewave said:
Then what do you use as the ground reference to feed the CV signal into the microcontroller? Are you connecting DGND and AGND together there too?

Actually this is something I'm working on, I though that if ultimately DGND and AGND meets at the chassis I shouldn't need any additional reference, probably I'm wrong.

Right now, I'm taking the CV Signal that should go to the VU Meter and feeding it to an ADC microcontroller pin.

But I'd like to use a VU Meter simultaneously, should I buffer the signal and then feeding it to both microcontroller and VU Meter? should I use a opto-isolator to feed the signal microcontroller?

squarewave said:
Post a pic! If you're using wires for digital at all, that could be a problem.
I'm out of the shop until monday, but I can tell I have some digital cables running, I tried to keep them as short as possible.

The thing is I tried to locate the noise source by taking out different elements, starting with LEDs, then GR reading, relays, pushbutton, both taking them out of the code and unplugging the wire and I didn't find any relevant changes there.

squarewave said:
Whatever you do you're definitely going to need some visual way to see what the noise spectrum is so that as you make adjustments to your circuits, you can see if there is a change. Otherwise, you're "flying blind".

Well, I already have a USB interface with spectrum analyzer software (Reaper and a plugin, nothing fancy) and a QA401 Audio Analyzer which is a bit more accurate, that's why I know the amplitude and frequency of the noise as well as the changes when I change processor speed.

squarewave said:
Another solution to this problem is to load the SMPS with a load resistor. But this is where you really need to pay attention to the power dissipated by the resistor. If your supply is 5A at 5V, to load it with 20%, that would be 5 ohms and 5V / 5R * 5V = 5W. So that would require probably one of those aluminum cased resistors mounted on a heatsink. That is not ideal. But for 500mA supply, 5V / 50R * 5V = 0.5W so strapping a 2W wirewound resistor with no heatsink directly to the output of the SMPS would probably work just fine.

2) You MUST not load the SMPS with more than 100% of the rated current for longer than a few ms or it will switch into a short circuit protection mode that modulates the output on and off at a very low frequency. The most likely cause of this is too much capacitance directly on the output. Usually this capacitance is limited to a few hundred uF. So if you have a bunch of 100uF capacitors all over, when you switch the supply on, those caps will create a significant initial surge current that will trigger the short circuit protection mode.

I think this is the problem I have about the 5V supply going on and off, I'll try with a loading resistor while I wait for the smaller supply. I'm not really sure as I'm not in front of it, but I think the 2,4Khz noise only appeared when I powered the microcontroller, with no load at all in the PSU

squarewave said:
The rules for mixing digital with analog:

I won't go in depth about this because it's a little too broad but I will skim over some points:
1) Return follows supply. This means that if you have say a digital signal going out over an FPC cable, you need to use a ground line right next to it for the return currents to follow right next to the digital signal going out (supply).
2) Use "termination", all digital outputs should have a 100R resistor directly on the output. This stops the digital signals from suffering from transmission line effects of high frequency signals.
3) Do not run digital signal likes next to analog. If you have a bundle of wires, you cannot have a digital wire running adjacent to an analog wire. In fact, I would not use wires at all. When I did a mixed project like this, I used conventional wire to board interconnects for audio on top of the PCBs and then I used all SMD mounted FPC connectors with FPC cables running under the PCBs along the bottom of the chassis.
4, 5, 6, .... my tea has died

Thanks again, I owe you a tea.

I didn't mention microcontroller is using Wi-Fi communication, maybe it's also related, but again, I think I tried to turn it off with no results, I'll try again
 
I've used and played around with arduino and teensy's in several analog projects, including compressors, guitar games, and monitor controllers. Looking at several "professional' hardware pieces one thing I noticed immediately from companies like Alesis or Peavey or ART or symetrix is they all had a separate analog and digital ground plain. The psu's ground was separated from the start and only at one small point were they connected via pcb or star point.
I copied this and received very low ground noise.
I used a digital vu meter for a gssl compressor along with 5v relays and as long as I kept the grounds separated it was noise free.
The monitor controller was a bit harder as the pushbuttons were used with an arduino nano and microcontrollers, but mechanically it was in an analog path.
Even the volume control via encoder was digital controlling an analog path. Not to mention all the pushbutton LED's fuzzing stuff up.
Looking back I should have gone all digital or all analog with the switching but my monkey brain is still struggling with microprocessors and code.
 
dirtyhanfri said:
My understanding is Hiccup would be caused due to small draw current from the PSU (please, correct me if I'm wrong, as I'm not so familiar with this) so smaller load would actually reinforce the hypotesis, doesn't it?
Semantics! A lighter load is a higher resistance (less current).

I tried (with no evident results) with a WIMA MKS series 0.1uF Capacitor, not sure if the value is the right one or maybe another kind of cap would be better.
Film caps are not prticularly good for PSU rail decoupling. Ceramic are better. And a ferrite bead or small inductor in series can really help.
 
Rocinante said:
Looking at several "professional' hardware pieces one thing I noticed immediately from companies like Alesis or Peavey or ART or symetrix is they all had a separate analog and digital ground plain. The psu's ground was separated from the start and only at one small point were they connected via pcb or star point.
Unlike with power supplies, technically it is not critical, and in some cases not practical, that the ground planes be connected only at one point. There are very specific layout rules (that I eluded to earlier) that must be followed to achieve a noise free mixed design. And in practice you need to actually understand why the rules are followed because there are unique conditions for interfacing each design. If someone is unsure of what these rules are or their digital skills are still a little green, then I strongly recommend staring with a modest design and be prepared to experience some failure and rebuilding.

But this is an area that I think DIY builders should explore. I think if people do these things and post questions about things like putting a high impedance analog circuit next to a relay and trying to understand why that's not good, that is the sort of discussion we need to have here for people to become successful in mixed analog / digital designs.
 
Well, I've been messing with it and found some interesting things.

I changed the PSU for a cheap phone charger (2A rated) and it stays on with no relevant change in noise from the original PSU.

Then I added a 100r resistor to the microcontroller pin driving the LED signal, which improved the 2'4khz noise about 7dbs, staying around -72dbu with the unit at max gain (+28dbs), setting it to unity gain the noise goes to around -100dbu.

Then I tried unplugging the GR Signal going to the ADC and the noise almost disappeared, at least it's not audible even at max gain.

I'm getting an optocoupler to check if that helps.
 
dirtyhanfri said:
Then I added a 100r resistor to the microcontroller pin driving the LED signal, which improved the 2'4khz noise
This touches on perhaps one of the most important rules about mixing digital and analog designs. If you turn on or off a high current over a long wire, it will emit electromagnetic pulse that will be picked up by high impedance circuitry and amplified by high gain circuitry. If you turn it on and off at say 2.4kHz, you will get a 2.4kHz noise in your analog signal.

There are a few ways to minimize this kind of noise. First, limit the rate at which the current turns on / off. When I created my channel strips I used the MAX7221 chip which actually uses constant current slew rate limiting outputs to minimize EMI. I also kept put the chip physically close to the LEDs it would be driving and I ran the FPC cables along the bottom of the chassis whereas any wires carrying signal would go over the top (actually sort of through because the boards were stacked and on their sides).

Anyways, this is the sort of thing that you need to think about to make this stuff work properly and noise free.
 
Back
Top