Despite filtering, sensor interference from lego servo motor

I've encountered similar electrical noise issues before so I'm familiar with adding capacitors and resistors as shown in diagram. Searched the forums, Internet, and tried much troubleshooting, but problem remains.

Using a Lego NXT servo motor causes bad readings from the sonar sensor. Sensor readings are VERY consistent with no motor, but running motor causes distances to be mis-reported about 20% shorter than actual and vary +/- by ten inches or more.

Troubleshooting so far has not provided any clues...

  • Tried swapping out ping sensors (MaxSonar EZ1 and Parallax Ping)
  • Tried two different Lego NXT servo motors
  • Tried moving the sensor pin to D7, D11, and D12. No change in behavior.
  • Problem exists with or without capacitors and 100 ohm resistor.
  • Power source using 9V battery on motor shield terminals
  • Power source using wall adapter to UNO

QUESTION: What else could I do to ensure reliable distance readings?

Components
Arduino UNO
NXT Shield (motor shield from TKJ Electronics for use with LEGO NXT servo motors)
Parallax Ping Sensor (also tried MaxSonar EZ1)
Parallax RN-42 Bluetooth Module (don't think it's related, but it is part of the project)

Thanks in advance for any tips or suggestions!

It can be that you have interference over the power supply. Use decouplin capacitors an ALL units and preferably have separate power connections to each unit

I've found two workarounds that allow the servo motor to run without causing interference to the sonar readings, but haven't truly solved the issue yet. This is really weird...

  1. Use the motor2 jack instead of the motor1 jack on the NXT motor shield.
    or...
  2. Remove the RN-42 bluetooth module from the robot.

It would seem the bluetooth module, when used in combination with motor1 jack, is either drawing too much power or generating enough interference to disrupt the sonar sensor. I need the wireless communication for this project, so the bluetooth needs to stay. Luckily, using the motor2 jack instead of motor1 jack results in a fully functioning system. (!?!?)

I tried isolating the sensor's power source using another Arduino board to provide a clean 5v source. Grounded the sonar to both the new power source and the original circuit that involved the motor. No observed improvement, but I could have been doing something wrong. I probably need to get an oscilloscope and learn how to truly isolate motor interference once and for all. Such knowledge would definitely help future projects -and maybe this one.

Still investigating what is causing this odd scenario...

The cause: The source of my problem was related to the use of D11 pin. I did not know D11 was required by the NXT Shield motor1 jack. D11 was also (improperly) being used for the sonar sensor signal. Upon disconnecting all other components of my project and testing only the NXT Shield, the shield seemed to function fine.

My mistake: I had created a motor test sketch by commenting out most of my project code and simply running the motors forwards and backwards. However, there was a call in the init() portion that referenced a function which used pin D11. Even though I thought all of my code was deactivated, there was still one line of code using D11 during init(). The conflict did not result in a 100% failure; rather, the situation created spurious readings being provided by the sonar sensor.

Lessons re-learned: When isolating a problem, remove ALL other elements until the most simple test setup exists. Also, write a clean test sketch specifically designed for problem isolation.