Well my machine is not going to pass any EMC regulations, my wife is complaining it is interfering with the digital TV downstairs! The amount of noise coming from the little GM3 gear motor is astonishing. This is the motor switching waveform on the top trace and the other lead of the motor which is at 12V on the bottom trace. The vertical scale is 20V and the timebase 0.4mS.
In this instance the motor is being powered for about 300 uS every 1.3 mS when its negative lead is driven to ground. When the motor is switched off the voltage shoots up above 12V due to the back emf. It gets capped at 48V by the over voltage protection of the BTS134 low side switch that I am using to drive it. It then has a damped oscillation at about 6KHz before settling down to 12V for the remainder of the off period. This will be due to the inductance of the motor windings resonating with the 100nF capacitor I put across the motor terminals. Although it looks violent it is actually the smaller burst of noise on the right which is causing all the problems.
Here is a close up of a similar burst of noise with a timebase of 10uS.
This is around 20MHz and you can see it gets onto the 12V rail. It is caused by the sparks at the motor brushes. Sparks emit RF energy from DC to daylight as I was once told by an EMC expert. My guess is that 20MHz is the resonant frequency of the motor windings with their own stray capacitance when they are momentarily disconnected from my suppression capacitor by the commutator.
One nasty aspect of this sort of noise is that it tends to get less as the motor brushes wear in and then get worse again as they start to wear out. I remember a project where a small motor was mounted close to a PIC. The PIC would frequently crash when the device was first run, but it would soon become impossible to recreate the problem until a new motor was fitted. I read that it is a good idea to "break in" DC motors by running them without any load at a low voltage for a few hours to allow the brushes to become a good fit to the commutator. Too late for mine though!
This is what the noise that gets onto the I²C lines looks like :-
A tough challenge then to make I²C reliable in this environment!
I began by stopping the comms from locking up so that I could add a retry scheme. To do that I had to put timeouts in all the points where I was waiting for the master controller to do something. When it times out I have to reset the controller and do one manual clock pulse to free up the slave before delaying 100uS and then re-enabling the controller. That stopped the comms locking up but did nothing to preserve data integrity. E.g., while I was sending motor commands and reading the temperature the heater came on of its own accord, not good!
The next thing I did was add an 8 bit CRC checksum to the end of each message so that I can detect when a message has been corrupted. 8 bits should be sufficient because the messages are only a few bytes long, i.e. less than 28 bits, and the bursts of noise are only a few bits long, i.e. less than 8. I used a table driven method so the software overhead is just a 256 byte table, one XOR and a table lookup.
I also added a sequence flag to the top bit of the command byte. This alternates when a new command is sent but does not on a retry. This enables the slave to ignore retried commands resent by the master because the previous reply from the slave has been corrupted.
The result seems to be robust even with the massive amount of noise present but I don't like to paper over hardware problems with software. To make systems like this completely reliable I aim to get no retries in normal operation and only rely on the protocol to handle exceptional events. The root cause is the noise from the motor so I decided to have a go at tackling that.
I took a closer look at the noise on the motor leads without any suppression :-
It looks pretty random and different on each wire which is to be expected because the two brushes spark independently. Here is a spectrum analysis :-
It peaks at 23 MHz but must in fact go all the way up to over 600 MHz to affect the television. There is also a lot of noise on the can. My first attempts to suppress it were to put a 100nF disc ceramic across the terminals and earth the can. That did not work well at all. I found that a more modern 1nF capacitor across the terminals worked better and leaving the can floating was better than grounding it because that just put noise on the ground rail. The old and new capacitors are shown below :-
It is no surprise the me that the smaller one works better at higher frequencies because it is so much physically smaller its inductance will be less. It is also much kinder to the MOSFET driving it!
Doing a bit of research I found that it is common practice to connect a capacitor from each terminal to the can, so I added two more 1nF caps forming a triangle. That worked well as it got the retries on the I2C bus down to zero, and also stopped the TV interference. I could have stopped there but there was still plenty of noise visible on the scope. I added two small ferrite bead inductors that I salvaged from a very old disc drive, one in series with each lead, and put a small 10nF ceramic across the cable. That made a fantastic filter leaving no noise visible on the scope.
I also decided to add a back emf clamping diode rather than rely on the over voltage protection of the MOSFET. 48V across a 5V motor is a bit much after all and is high enough to give an electric shock.
Here is the resulting filter mounted on Vero board and fitted to the motor :-
The 1nF cap across the motor is hidden by it and the other two are underneath :-
And here is the new switching waveform with pretty much all overshoot, ringing and noise eliminated :-
If only all EMC problems were that easy!
Tuesday, 18 September 2007
Subscribe to:
Post Comments (Atom)
This is brilliant work, Nop! Your extensive documentation pretty much sets a standard for how things ought to be reported.
ReplyDeleteI'm sure you said somewhere, but are you using a PIC chip to do the I2C comms? It looks as well if I got it right that the GM3 is causing virtually all of the noise problem. Is that correct?
No I am not using any PICs, my main controller which does all three axes and the Ethernet link to the PC is a Freescale MC9S12NE64 and my "head" controllers are Texas MSP430F2012s.
ReplyDeleteYes all the high frequency noise originates from the sparks at the brushes of the GM3. When I was using my Minicraft drill for milling, athough it has a bigger motor, I didn't have a problem with noise. Larger, more expensive, motors tend to have suppression built in to the armature, which is by far the best way to do it.
You might want to look at Solarbotics' GM17. That one has a very different electric motor driving it. It is much quieter and incredibly efficient.
ReplyDeleteWhat if i want to drive the motors with pwm and suppress the noise at the same time?
ReplyDeleteThe motor in this example was driven by PWM. As stated 300 uS every 1.3 mS which is 23% PWM. The PWM frequency will always be a lot lower than the frequency that the suppressor is filtering so it doesn't have any effect.
Delete