Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: mstacho on October 01, 2012, 09:39:41 AM

Title: Pull-up resistors and weird noise spikes on interrupts?
Post by: mstacho on October 01, 2012, 09:39:41 AM
Hi all,

Having a really interesting problem that I've managed to get around very badly.

We have a fairly simple setup: a hall-effect sensor is acting like an encoder, which is attached to an interrupt on a 32 bit PIC uC (It's one of those PIC32 based Arduino Mega lookalike boards, the Digilent Chipkit max32). The rest  of the circuit is set up exactly like the "connection diagram" part of this website: http://www.dfrobot.com/wiki/index.php?title=MD1.3_2A_Dual_Motor_Controller_(SKU:_DRI0002), (http://www.dfrobot.com/wiki/index.php?title=MD1.3_2A_Dual_Motor_Controller_(SKU:_DRI0002),) with more or less all of the same components.

For some reason, sometimes, the interrupts will trigger the uC board to start rapidly oscillating voltage from on to off (Note: probably NOT "high to low".  I'll explain more below).  This caused a massive set of rising edges, and my interrupts would trigger thousands of times per second, essentially saying that the motors had turned around 30 times  and destroying the effectiveness of my PD controller.

Now, the reason I said on to off, and not high to low, is because once we put a pull-up resistor on the interrupts, the strange noise spikes never went away (although they are much harder to trigger now), but the interrupts stopped triggering when the noise was there.  I suspect that the board power is rapidly switching between on and off, so the circuit opens, and the pull-up keeps the interrupt pin at the HIGH level.   When the pullup wasn't there, the interrupt was floating, and we got the weird behaviour. 

Since this circuit is so simple, I don't understand how these noise spikes can happen.  Also interesting is, once the noise spikes occur, I just need to send the robot another command and they go away.  Probably resetting the uC, I don't know, but it doesn't take very long for that to happen.

Any thoughts?  There are no moving parts in the board, so it's not like we're physically breaking connections.  I've tried on multiple interrupts with multiple robots and things still spike.  When I am NOT using interrupts (ie: I'm just dumping PWM into a motor) nothing happens, no noise spikes or anything.

My solution (the pullups) is a bit of a hack: sure, we're supposed to pull up the inputs, so now I can at least USE the robot, but it's still not fixed since the noise spikes are still present. 

MIKE 
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: waltr on October 01, 2012, 03:49:33 PM
It will take some troubleshooting on your part. My guess is:
1- the spikes are from the PWM frequency from the motor driver/motor.
 Use a separate power and ground from the battery to the motor drive circuits that is not common with the processor board.

2- A pull-up could be good. Also, a series resistor and a small cap to ground near the processor input could help. Select values to kill the spikes but not the maximum frequency you expect for the sensor.
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: mstacho on October 01, 2012, 06:00:09 PM
Hm, yes, I suspect it has to do with the PWM, but why would the PWM only affect the board when the interrupts are enabled?  Also, wouldn't I need to tie the grounds together between the motor control board and the uC?  Otherwise I wouldn't be able to send them a reliable input signal, not so?

MIKE
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: Soeren on October 01, 2012, 06:36:16 PM
Hi,

Hm, yes, I suspect it has to do with the PWM, but why would the PWM only affect the board when the interrupts are enabled?
How do you verify there's noise?
Do you know how the noise is reaching the interrupt pins (via supply lines, inductively or capacitively coupled, radiated)?


Also, wouldn't I need to tie the grounds together between the motor control board and the uC?
They'd be joined at the battery (which gives you a low impedance to dampen noise on the wires).
If it's radiated noise OTOH... Photos of the board and the wiring would probably be helpful.
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: cosminnci on October 02, 2012, 05:52:40 AM
Hi,

I had a similar problem with optical sensors, but my cable length was 1.5m and near the drive cables.
my fix was to use shielded utp cable.
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: mstacho on October 02, 2012, 06:42:41 AM
Hm, yeah I'm thinking that cable length is also a possibility.  I'll have to scope the encoder inputs at the board, since I've been scoping them right at the encoders.  I'm using about 1m of ribbon cable, and I've been told that that can have some... repercussions :-P It's something to check today.

To Soeren: I verify there is noise by scoping the encoder output.  Strangely, it's not just that there is noise, but that the noise only shows up some of the time, and when it does it's really bad (0 - 3.3V, like it's turning on and off rapidly).  I'll try to post some pics today if shielding the wires doesn't work.

MIKE
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: mstacho on October 02, 2012, 08:58:41 AM
Wow, was it ever a problem with cable length!  We shortened the cables (from...uh...2m down to about 20cm...) and it works flawlessly.

Thanks everyone who replied!

MIKE
Title: Re: Pull-up resistors and weird noise spikes on interrupts?
Post by: Soeren on October 04, 2012, 05:20:03 PM
Hi,

If you need to use flat cable and have noise issues due to the length, a few things that will help is running a ground wire every second wire and terminating the cable in a sensible way (passive/active - there's more than one way to shave that goat).
If the budget can handle it, you can get screened flat cable as well.