Pyboard noise

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
gratefulfrog
Posts: 132
Joined: Sun Mar 01, 2015 12:10 pm

Re: Pyboard noise

Postby gratefulfrog » Thu Oct 13, 2016 6:53 pm

Thanks @dbc. I also doubt that it would be possible to filter the ticks.

As to my circuit, I did some more experiments without my circuit, in fact with nothing but the Pyboard and the amp cable:

Configuration
  • A Pyboard sitting on an insulating mat, connected to the PC via USB, powered from the PC via the same USB.
  • Nothing connected to the Pyboard.

Connect a short wire from the digital ground of the pyboard to the Amp ground:
  • run the digital, analog and accel read tests,
  • no ticking

Connect a short wire from the analog ground of the pyboard to the Amp ground:
  • run the digital, analog and accel read tests,
  • no ticking


Now connect a 20cm long wire to the Amp Plus and let it lay near the Pyboard:

Connect a short wire from the digital ground of the pyboard to the Amp ground:
  • run the digital, analog and accel read tests,
  • faint ticking

Connect a short wire from the analog ground of the pyboard to the Amp ground:
  • run the digital, analog and accel read tests,
  • very faint ticking

So there is some antenna effect, picking up the spikes generated by the pyboard, I guess?

It seems that this is going to be nearly impossible to fix, sigh...

But any thoughts are always welcome, and thanks to all !
Cheers,
B

User avatar
dbc
Posts: 84
Joined: Fri Aug 28, 2015 11:02 pm
Location: Sunnyvale, CA

Re: Pyboard noise

Postby dbc » Fri Oct 14, 2016 1:01 am

Now connect a 20cm long wire to the Amp Plus and let it lay near the Pyboard:


Do you mean this long wire is connected to the signal input of the amp?

In any case, you seem to have shown that with a short ground you do not have noise coming through the ground. Consider putting the pyboard in a shield of some kind, and using feed-through capacitors for signals that pass through the shield to your analog switch. The shielding should be grounded to the pyboard. An Altoids tin seems to be the container of choice these days, your you could bend up some kind of can out of copper flashing from the hardware store.

You might find this a good read: http://audiosystemsgroup.com/Pin_1_Revisited.pdf

Jim Brown, http://audiosystemsgroup.com, is a friend of mine. He is an audio engineer and a fanatical noise chaser. See the section under publications "Hum, Buzz, and RF Interference -- Written for Audio Professionals". Lots of good information there.

gratefulfrog
Posts: 132
Joined: Sun Mar 01, 2015 12:10 pm

Re: Pyboard noise

Postby gratefulfrog » Fri Oct 14, 2016 1:16 pm

thanks for those pointers, @dbc !

I'm not quite so sophisticated as all that is described in those docs, sigh... I am not at all an electronics expert (does it show?)...

Cheers,
Bob

chrismas9
Posts: 31
Joined: Wed Jun 25, 2014 10:07 am

Re: Pyboard noise

Postby chrismas9 » Sat Oct 15, 2016 2:13 pm

Hi Bob, @roberthh and @pythoncoder give good advice about grounding and using a star ground. This is not always enough. It helps to understand all the ways noise can get into sensitive circuits. I do a lot of mixed signal design and I will explain how I analyse noise sources and optimise PCB layouts. I have looked at your PCB design and will refer to it below.

First think about noise sources. In your case the noise is most likely being generated by spikes and surges in the 3V3 demand by the MCU and peripherals. The accelerometer I2C interface will generate bursts of fast edge pulses at probably 400KHz. There will be harmonics well into the MHz depending on the slew rate ot the GPIO's. During ADC conversion the ADC unit will wake up and very quickly do 12 successive approximations generating demands on the power supply again in the MHz range. In both cases there is a peak demand for power. Some will come form the bypass caps, the rest through the V+ and GND traces from the power supply V+. There will be spikes on V+ and transient voltage drops in the GND plane between the pyboard and power supply capacitor C3.

How does this noise couple into the analog circuits? By coupling (radiated) or injected (conducted).

CAPACITIVE COUPLING.

If an aggressor trace (noisy signal, eg SPI CLK) runs close to a receptor trace (analog line) the noise will couple capacitively. This can be reduced by reducing the mutual capacitance, increasing the aggressor impedance, reducing the receptor impedance or reducing the slew rate. When digital lines have to enter the analog world try to keep the traces separated and perpendicular. Add series resistors to the digital lines and decoupling capacitors to the analog input pins. For the SPI lines there is a limit as to how far you can filter them but lowering the SPI CLK frequency will help. The filter resistors or ferrite beads should be on the digital side and the shunt capacitors on the analog side so the control inputs to analog ICs are quiet with respect to their (analog) GND.

INDUCTIVE COUPLING

If noise current flows in a trace and back in a return trace, eg GND, the loop it flows around will couple that noise inductively into other traces. Minimise the area of current loops, eg the V+ and GND connection to the pyboard. This is done my making sure the trace and its return are close together, or the trace is over a GND plane. Note that at noise frequencies the return current only flows in the GND plane directly under the trace and not point to point. If you have a break in the plane the return current will flow around the gap and add area to the loop. So don't run noisy power traces over gaps in the GND plane, run them around the gap over the plane. The same applies on the analog side, keep the analog signal lines very close to their return GND lines. By reducing their loop area they won't receive as much noise.

INJECTION

Traces and even GND planes are inductive. Noise current flowing through GND traces or plane will generate significant voltage drops. If analog signal return or analog supply return shares this GND the noise will be coupled into the analog signal. This is where the star GND comes in. Keep all the noisy digital signal and power return in half the GND plane and keep the other side quiet. This will fail if there is noisy current flowing through the star. You have to filter all digital signal lines and the analog power to prevent this happening. When the digital circuit has a V+ current spike it will draw power from everywhere. Some will be from the power supply but some will be from the analog IC bypass caps which are connected to V+. The return path from the analog bypass caps will flow through the analog GND plane and through the star point. You have to add an LC or RC filter in series with V+ to generate a decoupled VA+. Likewise filtering the digital lines that control analog circuits will help.

With careful layout you don't need a star point. It is normally recommended to put a star point under an ADC, but you can't have a star point when there are multiple ADCs. So I draw a dividing line across the PCB which defines the analog / digital boundary. There is no cut in the GND plane. You just have to be very careful to ensure that there is no noisy current flowing across the line and no noisy current flowing parallel and close to the line which could induce voltage drops from one side of the analog half to the other.

There can also be external noise sources generating GND current. There is a loop through the Guitar amplifier mains GND, the Laptop mains, the USB cable and the audio cable. If your Laptop has a two pin mains plug then there will be about half supply voltage (60 to 120 VAC) on the USB cable at probably under 100uA. This is due to a 4n7 EMC cap between the mains rectifier and the DC output. This would flow down the USB cable and back up the audio cable to the amplifier.

RF DEMODULATION.

Most of the digital noise will be RF. This gets into audio two ways. The power supply will droop when there is high frequency activity. The time constant of this droop depends on the capacitor size and may well be directly audible. RF is often rectified in the analog circuits, either in the substrate isolation diodes, input protection diodes or the input transistors or fets. If you have a burst of high frequency activity for 100 uSec the envelope is a pulse that looks like a half cycle at 10 kHz. The rectification works like a crystal set. It AM demodulates the RF burst and makes audible noise. It is very important to keep all noise pulses and GND bounce well below 600mV to avoid this. I have often seen more than 1V GND bounce on boards without a good GND plane.

If you are going to make another version of your board I would do the following:

1. Drop the V+ plane and route the V+ like the V-. It is better to use both sides to build a lower impedance GND plane that provides a return path close to every signal. Once you have a really low impedance GND plane use bypass caps to reduce the impedance of the supplies. Try to get the plane to pour between the DIP and connector pads if design rules permit. Using rounded rectangular pads (long and narrow) will help. Spread out vias so you don't create big holes in the plane.
2. Move as many traces to the top side as possible, with only short jumper traces on the bottom.
3. Pour as much GND on both sides as possible and stitch them together with lot of vias. Whenever you need to run a trace on the bottom side keep it short and jump back to top. When a trace changes layers add a GND via nearby to allow the return current to follow the signal without creating a loop to the nearest GND stitching via. Try to patch over holes in the bottom plane with the top plane. Ideally you won't be able to see through the board when you hold it up to the light.
4 Put a cut in the GND plane on both sides between the pyboard and the analog circuit. The star point should be at the power supply. This is ok since you are not using the STM32 ADC. If you use the ADC then the star should be at AVDD but you may have to use separately regulated analog supplies. You don't want the analog supply current going through AVDD to the power supply GND via the noisy pyboard GND pin.
5. Make the power supply low noise and low impedance. Use a good low ESR high frequency filter cap like Panasonic FC series and a 100nF ceramic in parallel.
6. Filter the analog V+ with an LC filter.
7. Don't cross the GND plane split with noisy lines, eg SPI. Run the SPI around the power supply, over the star point. Otherwise you create a big loop area between the SPI and the GND return which has to run through the star point. Add series resistors at the pyboard end and small bypass caps after you cross the star point. Steady state control lines, eg direct GPIO to analog switch control should be filtered because they will be modulated with digital GND or VCC noise. For static lines use at least 1k, 100nF. For clocked lines it depends on how low you can run the clock speed and whether the inputs can tolerate slow clocks (do they have schmitt trigger inputs?). In the STM32 use the lowest GPIO port speed that works.
8. Try to keep the SPI lines separated and orthogonal to the analog lines.
9. Will the guitar coils work into a resistive load? the 100nF capacitor you tried has an impedance of 1k6 at 1 khZ. A 1k input resistor might help, but it would be less effective than a cap at higher frequencies.

IDENTIFYING THE NOISE COUPLING PATHS ON YOUR BOARD.

This is how I would test your board to find how noise is getting in.

1. Unplug the pyboard. Program it with your noisy script running in a loop. Unplug the USB cable and run it from a 6V or 9V battery.
2. Jumper any lines that need to be stable at the pyboard socket. For example tie SPI CS high through a 100k resistor to V+ (5V). Even if it's a 3V3 input 100k to 5V won't hurt it.
3. Move the pyboard around close to your board. Is it noisy? If so you have a problem with radiated noise. You need to reduce you input impedance or reduce loop areas. or quieten the pyboard. Try a bigger cap at the supply pins, eg low ESR electro.
4. Connect the pyboard to your PCB ground with one short wire. Is it noisier?
5. Remove the battery and connect V+ to the pyboard. Is it noisy? If so filter the V= with the same inductor and capacitors you use in the SMPS. Did that help?
6. Now connect SPI back. Is it noisy? Try RC filters on the SPI lines.
7. Find out what resistive load the coils can work into without signal loss.

8. Look at your layout. There is a trace blocking C7 from from the power supply side of the GND plane. Its GND path to the power supply is up around the pyboard pins then down the middle of the pyboard where it picks up digital GND noise.

9. Try making a cut in the GND plane between the pyboard and the analog switches. Go right up around the resistors then over to the top edge of the board near U4. link up any bit of analog GND plane that got separated. Jumper C7 GND over the trace to the low side of the GND plane. This gives you a star point at the power supply and digital supply current won't flow in the analog side of the plane.

Its taken a lot of reading and trial and error to understand all this. I hope it helps. Understanding all your noise sources and how they couple is the key. Let me know the results of each test.
Last edited by chrismas9 on Sun Oct 16, 2016 9:33 am, edited 1 time in total.

User avatar
dhylands
Posts: 2387
Joined: Mon Jan 06, 2014 6:08 pm
Location: Shuswap, BC, Canada
Contact:

Re: Pyboard noise

Postby dhylands » Sat Oct 15, 2016 9:19 pm

Excellent post - I'm saving that elsewhere so I'll be able to find it in the future :)

gratefulfrog
Posts: 132
Joined: Sun Mar 01, 2015 12:10 pm

Re: Pyboard noise

Postby gratefulfrog » Sat Oct 15, 2016 10:35 pm

@chrismas9

Thank you so much for all the work you did in trying to help me!!! I still can't imagine that you could even find my board design, let alone study it carefully and comment it!

And your post is a FANTASTIC reference that I will keep separately, like Dave said!

I did the tests as you suggested and my results are below

1. Unplug the pyboard. Program it with your noisy script running in a loop. Unplug the USB cable and run it from a 6V or 9V battery.
OK

2. Jumper any lines that need to be stable at the pyboard socket. For example tie SPI CS high through a 100k resistor to V+ (5V). Even if it's a 3V3 input 100k to 5V won't hurt it.
None!

3. Move the pyboard around close to your board. Is it noisy? If so you have a problem with radiated noise. You need to reduce you input impedance or reduce loop areas. or quieten the pyboard. Try a bigger cap at the supply pins, eg low ESR electro.
NO noise!

4. Connect the pyboard to your PCB ground with one short wire. Is it noisier?
No noise

5. Remove the battery and connect V+ to the pyboard. Is it noisy?
Yes, full noise!

If so filter the V+ with the same inductor and capacitors you use in the SMPS. Did that help?
I tried putting 100nF cap between Pyboard Vin & GND, no change
470µF slightly less noisy,
2X470µF same as one 470µ
2x 4700µF noise is no longer audible!


6. Now connect SPI back. Is it noisy? Try RC filters on the SPI lines.
No noise from SPI

7. 8,9
not attempted yet.

You have given me key insights and the problem is no longer the top of my problem list!

I realize that my naive circuit design is simply not good enough to produce clean analogue sound. I did not really expect that it would, but I hoped it would be ok, or good enough. With the 2 big caps between the V+ and GND planes, the noise is no worse than for most guitar circuits.

I can now finish the assembly and demo the cool results, because the project is a success!

Really, you guys on this forum and the micropython team have been absolutely great and provided huge help and support.

@chismas9, you have really gone above and beyond!!! Thanks so much!! I can't say how much!

Thank you all!

I'll be reporting soon on the demo!!!!

Cheers,
Bob

User avatar
pythoncoder
Posts: 1641
Joined: Fri Jul 18, 2014 8:01 am

Re: Pyboard noise

Postby pythoncoder » Sun Oct 16, 2016 7:12 am

@chrismas9 Excellent post. A great update for the quarter of a century since I last worked in electronic design ;)

You mentioned laptops with two pin connectors. This is a topic which has bothered me since reading recently that some Apple laptops have no ground. Do you consider these safe (in the sense of potential damage to circuitry) to use by experimenters? Quite apart from the 100uA AC current source you describe, they could acquire an arbitrary DC potential with respect to ground. My advice would be to explicitly ground such machines before connecting them to exposed test rigs. Do you agree?
Peter Hinch

gratefulfrog
Posts: 132
Joined: Sun Mar 01, 2015 12:10 pm

Re: Pyboard noise

Postby gratefulfrog » Sun Oct 16, 2016 8:45 am

@pythoncoder

I can tell you the story of my all metal Asus UX303LN laptop.

It is a very high end machine and very sweet. Except that the all metal housing gathers static electricity in huge quantities. So much so that I cannot put my hands on it while typing. I spoke to Asus about this and researched tn on Internet. Apparently their are norms and the machine respects the norms but ALL metal laptops suffer from this to a more or less. The very professional Asus technician told me that I could send it back but that there was a good chance that they would simply say that it was within the norm and return it to me. Also, I would have had to re-install the original OS (Win) and lose all my Linux setup that I use every day...

I thought about grounding and got a 3 pin power adulator but that changed nothing since the mains ground is not carried to the laptop.

At the end, I simply put a thin layer of rubber insulation on it so as to not get that electricity trickling into me all day long...

I realize that this has nothing to do with the subject of test equipment, but I thought it was pertinent ;-)

chrismas9
Posts: 31
Joined: Wed Jun 25, 2014 10:07 am

Re: Pyboard noise

Postby chrismas9 » Sun Oct 16, 2016 9:48 am

@greatfulfrog @dhylands @ pythoncoder Thanks for the comments.

I have edited the typos and added an extra bit about GND planes and some clarification. moral of the story - don't type in front of Netfix, don't type after midnight and don't trust orto korekt.

Part of the motivation for writing this is to document my own thoughts. I'm sure I forget some of the rules from time to time. I will try to write it up properly with drawings sometime.

I am very enthusiastic about MicroPython. Being a hardware guy I can't contribute much to the software so I am happy to help out where I can. A few hours here and there is nothing compared to the thousands of hours the software guys are contributing. Many thanks to all of you!

User avatar
pythoncoder
Posts: 1641
Joined: Fri Jul 18, 2014 8:01 am

Re: Pyboard noise

Postby pythoncoder » Sun Oct 16, 2016 10:05 am

@greatfulfrog The Asus guy misled you with the statement that all metal laptops suffer from this. It's false. It's only true if the AC adaptor lacks an earth connection. Sadly a growing number of PC's and peripherals use double insulated AC adaptors which are legal, safe in terms of shock hazard, but have drawbacks. You can get a tingle from capacitively coupled AC leakage current. They can (I assume) acquire high DC static potentials capable of provoking harmless but unpleasant shocks. I suspect that these issues are capable of damaging connected devices in experimental setups.

A way to ground such machines short of the ideal, finding a grounded AC adaptor, is to connect a peripheral such as a USB hub which employs a grounded AC adaptor. An alternative might be a cable with a USB connector at one end and a mains plug at the other, with only the ground lead connected. To anyone reading this, only do this if you're absolutely sure of what you're doing.
Peter Hinch


Return to “General Discussion and Questions”

Who is online

Users browsing this forum: No registered users and 3 guests