problems with control of 2 servos and a DC motor with the SX
Vic Chaney
Posts: 10
Please help me solve a problem.
·
I am using a SX28 to control 2 servos, as well as occasionally turn on a small electric train car. When the train gets turned on, it goes forward but the servos also go crazy with sputtering in position, and the SX no longer works correctly until I power off/on. If the train is not on the track, the servos function normally.
·
It is not an electric train set. The project just has one little train car (replica of a hand car) that goes a short distance every now and then. It is not intended to run while the servo positions are changing.
·
The servos and the SX have separate 5V power supplies, and the train runs on a separate 12V power supply. All of these have a common ground. The train is triggered by a ULN2003a, and a relay acting as an “H” bridge. The servos are run by the VP on the SX forum:
http://forums.parallax.com/showthread.php?p=630723
Thank you, Jon Williams, for this! It works great, and allows me to do all kinds of other things with this SX in addition to the servos. I am avoiding PAUSE, and using the WAIT_MS routine for my delays. I am also triggering two electromagnets, a solenoid, another relay, and reading one mechanical and three optical switches with the same SX, and none of these bother the servos.
·
I am guessing that the train motor creates some kind of noise that disturbs the SX. Since it is on a separate power supply, and separated from the SX by the ULN2003A, and has a diode in the ULN and capacitors on the power supplies, I don’t understand why. (I am assuming that the commercial power supply that I got for the 12V has a capacitor at the output. It is also rated for well above the requirements for the train car.)
·
I am attaching a circuit diagram. The 33-ohm resistor in series with the motor is to slow it down a little. With a bigger resistor, the train won’t run, and the servos work fine. With a smaller resistor (or none) the train is too fast, and the servos go crazy.
·
Thank you, in advance, for any help you can give me. It may help stop me from pulling my hair out!
·
Vic Chaney
·
I am using a SX28 to control 2 servos, as well as occasionally turn on a small electric train car. When the train gets turned on, it goes forward but the servos also go crazy with sputtering in position, and the SX no longer works correctly until I power off/on. If the train is not on the track, the servos function normally.
·
It is not an electric train set. The project just has one little train car (replica of a hand car) that goes a short distance every now and then. It is not intended to run while the servo positions are changing.
·
The servos and the SX have separate 5V power supplies, and the train runs on a separate 12V power supply. All of these have a common ground. The train is triggered by a ULN2003a, and a relay acting as an “H” bridge. The servos are run by the VP on the SX forum:
http://forums.parallax.com/showthread.php?p=630723
Thank you, Jon Williams, for this! It works great, and allows me to do all kinds of other things with this SX in addition to the servos. I am avoiding PAUSE, and using the WAIT_MS routine for my delays. I am also triggering two electromagnets, a solenoid, another relay, and reading one mechanical and three optical switches with the same SX, and none of these bother the servos.
·
I am guessing that the train motor creates some kind of noise that disturbs the SX. Since it is on a separate power supply, and separated from the SX by the ULN2003A, and has a diode in the ULN and capacitors on the power supplies, I don’t understand why. (I am assuming that the commercial power supply that I got for the 12V has a capacitor at the output. It is also rated for well above the requirements for the train car.)
·
I am attaching a circuit diagram. The 33-ohm resistor in series with the motor is to slow it down a little. With a bigger resistor, the train won’t run, and the servos work fine. With a smaller resistor (or none) the train is too fast, and the servos go crazy.
·
Thank you, in advance, for any help you can give me. It may help stop me from pulling my hair out!
·
Vic Chaney
Comments
First, put a diode across the motor leads that power the motor to prevent the ULN2003a from getting destroyed. See this webpage..
madan.wordpress.com/2006/05/12/transistor-as-a-switch/
...for more info about that.
Second, add a capacitor directly across the motor leads (or as close as possible) to supress the noise it is generating. A .1 uf should do the job. The PDF file this link points to explains it in more detail:
www.teamdelta.com/pdf/tde_an1.pdf
Thanks,
PeterM
Are the two power supplies connected to the same ground? They need to be.
MikeS
You can also provide additional back-EMF protection by placing a bridge rectifier across the motor at the·source of another potential problem.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Peter - I will try the capacitor across the motor leads right away. One of the articles you referenced mentioned shielding the motor. I didn't mention that I am successfully using another DC motor on the same SX and with the same method. That motor is shielded, but the train motor is not shielded, in fact most of the train motor is quite open. I wonder if it would help to have the capacitor right at the train track, and not on the circuit board which is 3 feet away. The train gets its power through the wheels in contact with the track. I wonder if this less-than-ideal connection is contributing to the noise.
The power suppies have a common ground.
The relay is to change the direction of the motor, so I can't put a diode directly across the motor. Since the +12V to the motor is also connected to the +12V to the ULN, then the ULN's diode should also be across the motor. I don't see what harm there would be in putting another diode near the relay, so I'll try that, too, and use a bridge rectifier while I'm at it.
JonnyMac - I assume the com pin is the +12V? If yes, then I am OK there. My ULN just has 7 in and out pins, ground and positive power.
Thanks again for the help. I'll know about the extra diode and capacitor in a few hours.
Vic Chaney
Post Edited (Vic Chaney) : 1/2/2009 7:06:43 PM GMT
Thank you!
"The relay is to change the direction of the motor, so I can't put a diode directly across the motor..."· That's why I suggested putting a bridge rectifier across the motor with the AC terminals going to the motor, and the +/- terminals going back to the motor power supply terminals.· What this does is "cap" or limit any spikes produced by the motor to within +/- 1.2V (<-- two diode drops) of either the ground or supply voltage.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I am guilty of tunnel vision. I am thinking of bridge rectifiers only in terms of power supplies, and your suggestion is a whole different animal. I think it is ingenious. I got it almost ready to go. Thanks!
Vic Chaney
In general, when connecting high current noisey devices to low current noise sensitive devices, think "single point star ground". The topology of the wiring diagram can be just as important as the schematic itself.
Rick
I put a bridge rectifier across the train motor power.
I removed some daisy chaining of ground lines in the circuit.
I put a .1uf capacitor across the train power right at the track.
I twisted the train power wires going from the circuit board to the train track.
Now the servos remain quiet.
Instead, a stepper motor starts up, which is triggered by an IR reflective sensor, whose leads pass near the train power leads for about 30 inches. When I unplug the sensor, everything seems to work fine.
So I think the next step is to twist the wires going to the IR sensor, and if that doesn't work, then shield the train power leads, or the IR sensor leads, or both.
Thank you all so much for your help!
Vic Chaney
I put sheilded, twisted cables for the IR switch and for the train power, in addition to the changes above, and everything functions as it should.
Thanks to all who helped. It made a big difference to me and my project.
I spend time lurking on this forum, and learning a bunch from everyone else's questions and answers. Those of you who answer are generoulsy contributing some of your time, and making a difference!
Vic