Piwars 3.0, back from radio silence

3rd Mar 2017

Sorry for no posts recently, it appears life can get really busy, really quickly!

Since the last post we haven’t been idle though. The prototype bot is now drive-able both remotely and autonomously using distance sensors. We have a short video of it following a wall (albeit very slowly), but it is doing it!


Whilst busily working away testing sensors, we encountered a problem…and I quote Martin

“After some initial success with autonomously driving our test chassis using an old analog distance sensor, we set about upgrading to some snazzier laser distance sensors with much better resolution, talking to the Pi Zero over I2C.  In the test setup the sensors dutifully reported the distance they measured, but as soon as we tried to actually drive the robot the sensors started to reset themselves, losing their bus addresses and returning garbage values. As the problems started when we started turning the motors, the suspected causes were either noise on the power supply, or radio interference.  

We had previously had some problems with these sensors which turned out to be a loose ground pin, but tightening up all the connections and adding a capacitor to smooth the power supply didn’t help.  We then put together a test setup with a Pi reading values from the distance sensor, and a motor wired up to a separate battery through a switch so it would have no effect on the Pi’s power supply. Sure enough, a quick spin of the motor was enough to disrupt the I2C sensor, so radio interference had to be the culprit.
We brought out the oscilloscope, and probed the XSHUT (or “don’t turn off”) pin on the sensor. This pin has to be held at 2.8V for normal running, as bringing it to ground will reset the sensor. There was a little noise on the signal when the sensor was running which was likely to be crosstalk from the signal wires, but at 0.1V it wasn’t significant enough to cause problems. As soon as we ran the motor, however, the scope lit up like the proverbial Christmas tree.  The wire from the XSHUT pin to the Pi’s GPIO header was acting as an antenna, picking up interference from the motor next to it and triggering the sensor’s reset function. 
We tried a couple of different changes to keep the signal under control, with the eventual winner proving to be a large capacitor that would soak up the interference and banish the electrical gremlins.  With the capacitor in place, the oscilloscope showed the XSHUT signal staying calm, and the motor could happily spin away right next to the sensor with no interference issues.  Result: four happy roboteers :)”
Interference before and after
Above is a screenshot of the oscilloscope before and after. Note how the before (upper half) is looking all over the place, and how it has been resolved (mostly) in the lower half of the image to a single static line.
Not only have we managed to resolve a very problematic issue, we have done away with most of the additional controller boards. We moved to a PiZero as was always the intention, but we have dropped the requirement for an arduino as we are now using digital I2C distance sensors. Not only that but we then decided to use a Zero4U board to allow both wifi and bluetooth dongles without a huge USB hub plugged into the USB OTG port. That said, the Pi foundation has just released the Pi Zero W that has those two components on-board…so we dropped the Zero4U from the requirements as well. Other than ESC’s, sensors, battery/regulator and the voltage monitor, the whole thing is run from one single Pi Zero W at the moment.
If you watch the video linked above, you will see exactly how much the hardware has been reduced. Its all coming together now!