Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Brandon121233 on May 25, 2007, 04:20:27 PM

Title: Ultrasonic interference
Post by: Brandon121233 on May 25, 2007, 04:20:27 PM
Hey guys
I just finished my robot Walbot 2.0 and it looks good, however my ultrasonic is malfunctioning. I have the LV-MaxSonar-EZ1 module, and the problem is that when I turn the power on (I am using the Arduino board) the ultrasonic seems to be getting lots of electrical interference from the motor controller. I know this because when I disconnect the power to the H-Bridge and leave the Sonar and board power on, the sonar works just fine. It's only when I have the power to the motors on that it seems to get a pretty much constant detect when nothing is there. My H-Bridge is the L298N heres a schematic as to how its wired up http://downloads.solarbotics.net/PDF/Solarbotics%20-L298_schematic.pdf (http://downloads.solarbotics.net/PDF/Solarbotics%20-L298_schematic.pdf). If anyone knows or could help me solve the electrical noise problem that would be fantastic.
Title: Re: Ultrasonic interference
Post by: Ro-Bot-X on May 25, 2007, 11:45:35 PM
1. Mount 3 ceramic 0.1uF capacitors on the motor like this: one between the leads, one between one lead and the motor case and the last one between the other lead and the motor case.
2. Twist the motor leads all the way to the PCB.
3. Mount a ceramic 0.1uF across the Sonar power pins (VCC and GND).

Usually this is enough.
Title: Re: Ultrasonic interference
Post by: Hal9000 on May 26, 2007, 09:39:39 AM
Dont people put a bit of foam around the metal casing of the sensors also?
Title: Re: Ultrasonic interference
Post by: Hal9000 on May 26, 2007, 09:40:22 AM
Is it also a good idea to isolate the power supplies from eachother?
Title: Re: Ultrasonic interference
Post by: Brandon121233 on May 26, 2007, 12:02:40 PM
OK first of all, yes the power supplies are separate, I have 6 x 1.2 volt AA NiMH batteries that power the 2 gear head motors (about 8.4 volts total when fully charged). And the arduino board is powered by a 9v NiMH battery.
1. Mount 3 ceramic 0.1uF capacitors on the motor like this: one between the leads, one between one lead and the motor case and the last one between the other lead and the motor case.
2. Twist the motor leads all the way to the PCB.
3. Mount a ceramic 0.1uF across the Sonar power pins (VCC and GND).

Usually this is enough.
1. I already did that
2. already did that too
3. I will try that

OK, HERE is the issue I tested a couple things and this is what I found... When I turn both the supplies on and the bot is running (in circles that is) I can actually unplug the 9v supply to the board and it still runs. The H-Bridge as you can see on the schematic link above requires a 5v logic supply and the motor output supply. To give the H-Bridge the 5v supply I used the regulated 5v out that the Arduino board can give. What I think is happening is that somehow the H-Bridge is leaking some of the motor supply voltage back to the logic supply of 5v. The reason why I think this is because when I monitor the voltage on components like the sonar's supply voltage, when I pug in the 9v battery supply to the Arduino it regulates 5v to the sonar and everything works fine. However when I flip the motor supply on the voltage coming out of the usually regulated 5v supply that Arduino gives, jumps up to about 6.5 volts, not good. Hence the reason why my sonar is malfunctioning is because the analog signal that it send to the ADC input in the Arduino is determined by the input voltage. My code is set up to convert 5v analog into its max distance, and 0v as its min distance, but if the supply voltage is bumped up to 6v, that throws off all the expected readings.
I don't just want to adjust the code because I'm pretty certain that if something requires a regulated 5 volt supply and it gets 6 volts, that's not good for it.

So here is my new question, what would be the best and easiest way to make sure those two power supplies stay separate? The two that come to my mind are:
A) make a regulated 5 volt power supply to the H-Bridge using the 8.2 volts that is used for the motor supply (use a step down linear regulator), but that  is rather time consuming and I have limited pref board space left
B) since I have never used them I'm not sure, but I think there are diodes (zener diodes I think they're called) that have a break down voltage, so maybe I could use them to make sure that nothing more than 5v comes or goes out of the logic supply of the H-Bridge

I have never really had to deal with something like this before so if anyone has some advice on how to make sure those two powers supplies stay separated, I would appreciate any help.
Thanks in advance: Brandon
Title: Re: Ultrasonic interference
Post by: Ro-Bot-X on May 26, 2007, 02:19:36 PM
Just insert a 1N4148 between your regulated power supply from Arduino board and the 5v power pin of the H bridge. The diode will allow the current to go only one way (from Arduino to H bridge) and not the other.
Title: Re: Ultrasonic interference
Post by: Hal9000 on May 26, 2007, 02:27:57 PM
After all, this is the whole back emf issue yes? I think vibration wise (i.e why foam is used) your robot may vibrate at 40kHz, or the harmonics.

Noise is a terrible terrible thing. There's something like using a massive capacitor and a smaller capacitor to get rid of noise. I think you need some sort of datasheet to know which ones you need for certain frequencies. This, after all, is how simple low order filters work.
Title: Re: Ultrasonic interference
Post by: Brandon121233 on May 26, 2007, 06:02:00 PM
hmmm. somehow I doubt my robot randomly vibrates at exactly the frequency the ultrasonic uses (but I've been proven wrong before)
Just insert a 1N4148 between your regulated power supply from Arduino board and the 5v power pin of the H bridge. The diode will allow the current to go only one way (from Arduino to H bridge) and not the other.
Thanks Ro-Bot-X, I will try this
Title: Re: Ultrasonic interference
Post by: Brandon121233 on May 26, 2007, 07:40:01 PM
OK, an update: I isolated the 5v supply to the H-Bridge powering it from the 8.2volt supply and using a 7805 to bring it down to 5v. This means that the H-Bridge power supplies, and the Arduino's supply voltages are COMPLETELY separate (yes I even put he .1uF and 22uF capacitors between the input and output). However somehow and it bewilders the heck out of me, the normally 5v regulated supply from the Arduino magically jumps up to 6 volts!!! I have absolutely NO clue how that is even possible, can anyone help ???
Title: Re: Ultrasonic interference
Post by: Ro-Bot-X on May 27, 2007, 12:02:24 AM
Try inserting 10k resistors between Arduino board and the H bridge, on the motor control lines.
Title: Re: Ultrasonic interference
Post by: Brandon121233 on May 27, 2007, 11:26:01 AM
OK, I got it, and I feel very stupid  :-\ When I looked at the schematic in my first post I absentmindedly connected the + side of the diodes that go across the motor outputs to the 5v instead of to the Vin. And that fixed everything, sorry to trouble everyone for my mistake. (P.S. I thought of the problem in my sleep... weird)
Title: Re: Ultrasonic interference
Post by: Ro-Bot-X on May 28, 2007, 02:02:21 AM
(P.S. I thought of the problem in my sleep... weird)

Yeah, it happened to me many times  ;)