Maker Pro
Maker Pro

DC motor spikes mess up chip

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
Hey!
I am controlling a relatively high RPM DC motor (not quite sure the exact RPM) with an SN754410 Hbridge at 12v connected to an Atmega 644p.
I can control the Atmega 644p over a serial line from my pc and tell it to turn the motor on/off.
My problem is, 8/10 times when the motor turns on the Atmega stops responding and the motor stays on and just acts plain weird until I reset the chip.

I'm pretty certain this is down to voltage spikes in from the motor, but I just cant seem to get rid of them. The important parts of my circuit are:

12v -> 5v Regulator -> Atmega -> Hbridge -> dc motor

5v Regulator -> L293d (power it)

12v -> Hbridge (motor runs off this)

12v -> 10uF Cap -> 0v

5v -> 10uF Cap -> 0v

I tried adding snubber diodes:
Each pole of motor -> Snubber diode (1N5817) -> GND
Each pole of motor -> Snubber diode (1N5817) -> 12V

But that doesn't affect it at all.

Has anyone got any ideas?

Thanks :)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Ensure that no part of the wiring for the Microcontroller carries current from the motors. (i.e. have separate wires leading to the power source.)

Ensure you have capacitors at the input and output of your regulator. You may even want to consider an inductor in series with the 12V leading to the 5V regulator -- sometimes you can use a low value resistor too.

Place a capacitor across the 12V to the motor as close as possible to the H bridge. a 10uF, 1uF and 0.1uF capacitors in parallel would be good. An 0.1uF capacitor directly across the motor is not a bad idea either.
 

edman222

May 23, 2013
3
Joined
May 23, 2013
Messages
3
Most likely the motor is drawing lots of current at start-up thus it drains the cap on the 12V line and the system, so the regulator cant maintain a good 5V if the 12V is unstable...

simplest fix... get a BIG capacitor, a few hundred uF (470uf+ or 1000uf if its a bigger motor) on the 12v side, and also try steve's suggestions.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Isolating the 5V regulator with a diode (and it having its own input cap) will also go a long way to prevent this.
 

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
simplest fix... get a BIG capacitor, a few hundred uF (470uf+ or 1000uf if its a bigger motor) on the 12v side

I have a 2200uF capacitor which I will try it out with :)

Place a capacitor across the 12V to the motor as close as possible to the H bridge. a 10uF, 1uF and 0.1uF capacitors in parallel would be good

Sorry just to be clear, you mean these capacitors from the 12v rail to each pole of the motor?
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Sorry just to be clear, you mean these capacitors from the 12v rail to each pole of the motor?

No, across the power supply rails, close to the H Bridge.

These will provide a low impedance path for spikes that get generated and should help eliminate them. Another 0.1uF capacitor should be placed across the motor.
 

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
Alright, thanks for all your help guys!
I tried all these things and couldnt get it to work, so in the end what ive done is just use a different motor which works absolutely fine. It seems a bit of a cop-out but it turns out this motor is better for the task in hand anyway.

If anyone got a chance it could be useful if someone could supply a standard motor control circuit to use for future projects but no real need.

Thanks alot for your help!

:)
 

Lord_grezington

May 3, 2013
124
Joined
May 3, 2013
Messages
124
Hello

With brushed dc motors, some have a varistor ring build in and some don't. A varistor ring will suppress the voltage spikes caused the brushes on the commutator.

Check if your motor has a varistor ring, if not you should be able to fit a varistor between the motor terminals (value dependent on voltage and Current).

A capacitor will work well to reduce EMC, however may cause issues if you are depending on the current for feedback.

Graham
 

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
How do I choose a suitable varistor? There doesn't seem to be much about them online. Looking at varistors online: http://www.digikey.com/product-detail/en/VAR-18080115M3P-XK/VAR-18080115M3P-XK-ND/970267

My motor is 12v and around 3A current.

I am really starting to loose my will to live. The motor works fine with an LMD18200 if I control all the voltages by connecting wires but when I try to drive the LMD18200 with my uC nothing happens (if I use a different motor it works, but I need this motor).
Is a varistor pretty certain to fix my issue?
 

Lord_grezington

May 3, 2013
124
Joined
May 3, 2013
Messages
124
I am no expert, I would try one of the varistors on the link below. (capable of withstanding current over 16.5A, Clamping voltage should be a couple volts above driving voltage)

Check you current sense resistor, on 12V during start up you will be drawing around 16.5A. Your uC may be seeing a high current then stopping. Try accelerating the motor from a low PWM duty cycle up to speed.

Graham

http://uk.farnell.com/jsp/search/br...arametricAttributeId=&prevNValues=2031+202851
 
Last edited:

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
I'm still looking into varistors, but I've discovered something odd:

If I connect the motor through the H-bridge and run it, it "crashes" the chip. But if I connect it directly to the power supply, with the electronics in parallel, everything is fine, ie the motor runs (but obviously I can't control it).
Now surely this suggests it isn't spikes? Otherwise it would cause spikes even when connected directly to the power supply and the electronics would fail!

This is really confusing me!
 

Lord_grezington

May 3, 2013
124
Joined
May 3, 2013
Messages
124
When a DC motor starts up it draws the stall current for a few ms. If you are driving the motor through the chip perhaps the current is going too high that the chip can not cope and going into the fail safe mode. An acceleration will get over this issue.

Running the motor in parallel does not mean much apart from saying that the PSU can supply enough current to drive both motor and drive chip.

I would put a scope on pin 9 to see if you get a flag for the current.
 

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
Hmm ok, another odd thing i've noticed is when I run the dc motor parallel to the electronics (ie directly connected to 12v and 0v), the voltage regulator gets hot.
To me this implies there is a large current being drawn through the 5v line? Or does it make sense that the VR gets hot when the 12v line has a large current through it?
 

Lord_grezington

May 3, 2013
124
Joined
May 3, 2013
Messages
124
Can you send a schematic? Running the motor in parallel should not affect the electronics, so you VR is getting hot even if the motor is not connected. This may be a fault in the electronics.
 

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
Hey! Sorry to have been a while. Since I last posted I've started redesigning the PCB since the old one could do with some improvement.
I've decided to have 2 separate boards: the control one, and the motor one.
The control board has the main uC, the rs232 interface and the inputs.
The motor board has all the H-bridges and motor connections.
Today I've finished the control board so I was hoping someone could review it and offer opinions. I've attached a JPEG of the image, it is annotated with numbers so here I will explain what is going on:

7 - 12V supply connected to here to voltage regulator
4 - 5v out of voltage regulator
2 - 0.1uF Capacitor from 5v - GND
8 - 0.33uF Capacitor from 12v - GND
3 - Diodes on 5v and 12v lines between voltage regulator and components/motors to help isolate the power supplies
1 - 100uF capacitors to help supply power for both 5v and 12v when large current is drawn
5 - 100nF capacitors right next to the VCC pins of the uC
6 - these will be connected by wires to the control pins of the motor board

Currently the motor board will have connections to the control board power supply so they can run off the one power supply. However, I intend on making room for another voltage regulator on the motor board so I can have completely separate power supplies and will use optoisolators to control the h-bridge.

Does this look like it should be able to support a few motors and suppress spikes well?

Thanks :D
 

Attachments

  • PCB.JPG
    PCB.JPG
    113.2 KB · Views: 126

Lord_grezington

May 3, 2013
124
Joined
May 3, 2013
Messages
124
Hi

I have had a look at the layout however its hard to distinguish what is happening.

I find if you use Design Spark, it takes a while to get the components you need but its very good ate putting schematics together and also very useful when you need to create the gerbers from the schematics (if you need them).
 

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
Ok sorry about that!

Here is a simplified schematic. I've left out the programming and serial stuff because I'm sure that stuff is ok. What I've included is all the power stuff.

Just to explain: -12V supply to Voltage regulator.
-Small capacitors across each side of the voltage regulator.
-Diode on both 12v and 5v lines to help isolate each from the other
-100uF capacitor after each diode to supply power when high current is used (could make bigger if that's better?)
-100nF across power supply to uC.
- LED controlled by uC
- LED which indicates power

[Edit] Please note that the uC symbol isn't the correct one for the chip I am using, ignore all pins that aren't connected as I only corrected the labels of the ones I am using [/Edit]

Can you see any improvements/problems?

Thanks! :)
 

Attachments

  • printer schem.JPG
    printer schem.JPG
    76 KB · Views: 154

codeeater

May 10, 2013
12
Joined
May 10, 2013
Messages
12
That's great! The diode looks ok to me? The power is coming from the rail labelled 12V. The current then flows from that rail through the diode on the left to the H-bridges.
 
Top