inductive load protection! - Page 1
Forum section: electronics / beginners

author: DigitalFlower
author_rank: Contributor
timestamp: June 14, 2015, 03:09:00 am
content: Hello! so, i've been using dc motors for a while but i can't seem to be able to avoid the huge current spikes when powered on, and the thing is, those spikes always find their way to my controller circuit. I've tried using fast diodes, RC-diode circuits, off the shelf H bridges with protection, and i haven't come across a good way to prevent those from happening or at least from affecting my controller circuit. i am considering using optocouplers to make sure both the motor circuit and the controller circuit are isolated, but i would really want to know what i might be doing wrong??thank you!!

author: rs20
author_rank: Super Contributor
timestamp: June 14, 2015, 03:38:12 am
content: Optocouplers aren't a relevant solution for your problem. You have a motor that's drawing a lot of current because it's stationary and low-impedance; that current is overwhelming the power supply whose voltage sags, and the controller browns out because it has insufficient voltage. Once you reason that out, the solutions become clear. Either:1) Use a schottky diode and a capacitor to power the control circuitry. The capacitor is placed directly at the power input to the control circuitry, to hold that voltage steady. The diode is placed so that if the motor/power supply voltage sags, the capacitor won't discharge backwards through the diode to feed the motor -- the schottky diode enforces that the capacitor's energy is reserved for the controller circuitry only. To determine the size of capacitor you need, measure A) how long the motor spike overwhelms the power supply for, B) how much current the control circuitry consumes, and C) how much voltage sag your controller circuitry can handle, and calculate A*B/C (with units) to figure out your capacitor value.For example, a 20 ms current spike, 50 mA control circuitry with can withstand a drop of 1V (e.g. nominal 5V to brownout at 4V) gives 1000uF (click for Google calculator).2) Last resort, use a completely separate power supply for the motor. But you should never need to do this.And/or as suggested above, implement soft-start and/or use a more powerful power supply. Or, combine all these methods: better power supply + soft start + schottky-enforced capacitor are all good practice to avoid this sort of issue. But regardless of all of the above, an optoisolator isn't relevant or useful for any of this.evb149, using heavy wire to the motor isn't going to help, because that just helps the motor drag the supply voltage down.Edit: Using an inductor achieves a similar goal as the schottky diode; i.e. preventing the capacitor from just being discharged by the motor -- but I'd opt for Schottky because it's easier/smaller/cheaper for a given level of performance.

author: DigitalFlower
author_rank: Contributor
timestamp: June 14, 2015, 06:39:21 am
content: Hi! thank you both for your replies! now, let me explain:The motors i am using are 12V gearmotors, and my controller circuit is basically just a PIC connected to sensors, whenever the motors activate, the pic resets and it has to wait for yet another sensing? so that the motor starts running again and the pic resets and it goes on and on forever!! i'm using 2 power supplies so using optocouplers would actually help since both circuits would be electrically isolated and there would be no interference, but that to me seems like the easy solution and is a solution that won't be possible all the time!!also using large capacitance can't be done in this case because the space i have is really really small, so fitting in large capacitors is a no no, at least for this projectagain, thank you guys!!

author: PSR B1257
author_rank: Frequent Contributor
timestamp: June 14, 2015, 07:14:59 am
content: QuoteWhat nominal power?QuoteWhat sensors?QuoteHow is the motor activated?QuoteGood idea.How did you wire the circuit up?A picture (or schematic) might help identifying the issue.

author: rs20
author_rank: Super Contributor
timestamp: June 14, 2015, 07:20:01 am
content: You need to attach a diagram of your setup, what you're saying makes no sense. In particular, what do the connections between the PIC and the motors look like? Because if you're using two separate power supplies properly, and the only connection between the PIC and the motors is control lines, it should be impossible for the motor to reset the PIC via those control lines. So what's between the PIC and the motors? A driver board? Relays? Transistors?Again, even though I'm now less sure I understand what you're doing than before, I'm still quite sure that optocouplers are not a sensible solution. Optocouplers are for transferring data between systems that are at different voltages for deliberate/safety purposes. If you've got two earth-referenced power supplies, optocouplers are of no use whatsoever, they're just overcomplication.

author: DigitalFlower
author_rank: Contributor
timestamp: June 14, 2015, 05:21:47 pm
content: Hi! sorry about the little information i provided, here is the schematic, MI and MD are pic outputs, both circuits share a common ground, the current draw from each motor is 300 mA when running continuously, so around 3.6 watts each. the sensors are 2 ultrasonic motion detectors.thank you again!!

author: SeanB
author_rank: Super Contributor
timestamp: June 14, 2015, 05:26:03 pm
content: D3 and D4 are not needed, but a capacitor of 1000uF 16V between the supply and ground would be a big improvement, connected as close as possible to the motor supply line and the emitter of the power transistors.

author: PSR B1257
author_rank: Frequent Contributor
timestamp: June 14, 2015, 05:32:19 pm
content: Quotecoupled to the motors?Perhaps it's just a false code...Have you tried to switch the motors by just applying a 0/1 to the transistors?QuoteOf course they do, otherwise it wouldn't work at all. But how did you connect the GND terminals?

author: DigitalFlower
author_rank: Contributor
timestamp: June 14, 2015, 06:18:19 pm
content: Hi! thank you for replying!i will try the capacitor thingy and see how it works, thank you!the sensors are connected to the inputs of the pic, the code works fine in the simulation!!i've tried that too, PSR, switching the motors using 1s directly to the MI and MD you see on the schematic, and the motors work fine because what i'm using as input to the transistors is just the 5v rail of the pic power supply, it's just when connected to the output of the pic that it doesn't work as expected :/it would work if i used an optocoupler, i wouldn't need to connect both grounds together!! there would not be interference and it would work just fine??thank you!

author: PSR B1257
author_rank: Frequent Contributor
timestamp: June 14, 2015, 07:49:18 pm
content: QuoteNo, you don't.But we still don't know, HOW you have them connected.

author: rs20
author_rank: Super Contributor
timestamp: June 14, 2015, 11:33:50 pm
content: I'm being redundant here, but you haven't showed us your overall wiring diagram yet. Your symptoms are indicative of a major wiring error or a failure to do proper star grounding. Again and again, the solution to this is moving a few wires around, not introducing optocouplers.You have two power supplies with grounds, you have a PIC controller with a ground, and motor drive circuitry with a ground.How have you connected these 4 points together?Where are the emitters of your BJT connected, directly to the ground of its dedicated power supply with dedicated wires, or what? What are these two separate power supplies, wall warts? Lab power supply? Or do you have a 5V power supply running off the motor's 12V power supply or something?A simple hand-drawn diagram, or a photo of your set-up, will answer all these questions.

author: DigitalFlower
author_rank: Contributor
timestamp: June 15, 2015, 01:47:30 am
content: Hi! ok, i drew the entire circuit, it's really a simple circuit so i didn't think you needed to see the entire thing, but here it is!! the power supplies are batteries, and everything is drawn as i connected it in the breadboard, i'm sorry if i'm being too annoying about the optocouplers, it just seem like a simple solution to me :/thank you guys again!!

author: rs20
author_rank: Super Contributor
timestamp: June 15, 2015, 02:06:57 am
content: Not annoying, I just wanted to be clear that optocouplers aren't relevant hereSo I want to really focus on the grounding; your pictureimpliesthat the wire leading from the emitters of the BJTs to the 12V supply ground is completely separate, physically distinct from the wires leading from the 5v supply ground to the PIC controller ground. Is this true? And the wire connecting the grounds of the two sides is connected at the ground of the PIC controller and the motor circuitry, not at the supply side?

author: DigitalFlower
author_rank: Contributor
timestamp: June 15, 2015, 02:24:24 am
content: Hi!hmmm, the ground terminals of my batteries are physically connected together by the same wire, then from the 5V side, the pic and the sensors, and from the 12 v side, the motors and transistors, like in the picture!!thank you again!

author: PSR B1257
author_rank: Frequent Contributor
timestamp: June 15, 2015, 04:51:32 pm
content: You should't take pictures through a jam jarQuoteWe know the circuit as to look like, but we have to make sure you also knowSince the motors are working, if you connect the base resistors direct to the 5V rail of the PIC board, the wiring seems to be o.k. You should measure the supply voltage of the PIC (directly on the chip, not at the input of the board or so), while the motors are running. Ideally with an oscilloscope.QuoteThat's not relevant.QuoteHave you tried a simpleblinking-LED-kinda-program, wihtout anysensor-whizbang?

author: DigitalFlower
author_rank: Contributor
timestamp: June 16, 2015, 01:03:59 am
content: Hi! sorry, but i have a bad camera, not thinking about getting a new one any time soon, i need to finish setting up my lab first!i've done that before and have seen the voltage drop but it happens so fast it's hard for me to see the voltage to which it drops, not even with the capacitors it's enough to prevent it from happening, but well, i'm only using 220 uF on each supply, tomorrow that i go back to the uni, i will change the capacitors to 1000 uF each and see how that works?why is it not relevant that the code works fine in the simulation? this is not my first program, i'm sure my code works fine, i used LEDs instead of the motors to see if there was a code problem or something and it works good too! it's the spikes that are killing it D:thank you!

author: rs20
author_rank: Super Contributor
timestamp: June 16, 2015, 01:19:58 am
content: Quote from: DigitalFlower on June 16, 2015, 01:03:59 amDone what? Seen the drop using an oscilloscope? If you're using a DSO, set up your trigger properly and use single-shot (or normal triggering mode instead of "auto") and it'll stay on the screen for days.Have you tried replacing the motors with some LEDs (along with protection resistors for the LEDs, of course), but keeping the rest exactly as it is (leave the transistors in place, just literally replace the motor with an LED + resistor). I'm beginning to suspect that you've miswired something, or your "1k" resistor isn't actually 1k. It makes no sense that your PIC's supply voltage is dying like it is, because there's nothing to pull it down, except for the "1k" resistors.

author: DigitalFlower
author_rank: Contributor
timestamp: June 16, 2015, 01:31:48 am
content: Quote from: DigitalFlower on June 16, 2015, 01:03:59 amHi! rs20, look at my complete post, i've done that as well, i used an analog scope they have at the uni, i don't have one myself :/i'm also quite sure about the resistor values? (black brown red...) i feel like everyone is asuming i know pretty much nothing at all about what i'm doing? inductance and how to manage inductive loads have been my weak spot, so far that's it?thank you again!

author: rs20
author_rank: Super Contributor
timestamp: June 16, 2015, 02:02:40 am
content: It's not that we're assuming you know nothing -- it's just that we've eliminated a whole bunch of possibilities so the likelihood that this is a PEBKAC gets higher and higherAt this point I can only braindump things I'd try. Check the resistors with a multimeter, check that they're not burnt short or something. On the oscilloscopes, how long are the sags on the supply line? Milliseconds? Nanoseconds? Is it just a sag, or is it symmetric (goes both above and below 5V)? Have you tried moving the motor, transistors and 12V supply very far away from the PIC and 5V supply, with just a ground and control lines between them (to reduce the coupled emissions from one to the other)? In addition to using larger electrolytic capacitors, can you get some ceramic capacitors (100n to 1u or so) right on the voltage input pins of the PIC? Big capacitors can have a poor ability to smooth out high frequency interference. Have a look at the PIC output pins that lead to the 1k resistor, are they sagging a lot? Are you working using a plug-in breadboard, or veroboard, or what?Basically, we're trying to establish whether the PIC is being taken out by conducted noise via the 1k resistor, or by emissions. Exactly what kind of supplies are you using, lab supplies or batteries? If they're earth-referenced supplies, you may be creating a large ground loop.

author: DigitalFlower
author_rank: Contributor
timestamp: June 16, 2015, 02:19:45 am
content: Hi!again, as i've mentioned above, i've physically replaced the motors with LEDs, and the circuit works great!! also, 've mentioned i am using batteries and uploaded a somewhat blurry drawing of how they are physically connected in the real world, i will have to check again in the scope for the time scale, i don't remember and i have to go to the uni since i don't have a scope of my own!! i am using a plug-in breadboard, that is also fine because the circuit works good when replacing the motors with LEDs? the pic is also not the issue, i've replaced it twice and got the same result, the one thing left to measure is the peak current when turning on the motors?thank you!

author: rs20
author_rank: Super Contributor
timestamp: June 16, 2015, 03:17:20 am
content: The plug-in breadboard isn'tnecessarilyfine because it increases the resistance and inductance between the PIC and its capacitors. I mean, the LED circuit probably works fine without a capacitor at all, so that proves that the capacitor doesn't help, right?So adding that ceramic 1u capacitor as close as possible to the actual IC is important, as well as moving the large electrolytic capacitor as physically close to the supply pins as possible. Does the PIC have multiple VCC and GND pins? If so, are they are all connected tightly together and decoupled separately? But yeah, I'm really running out of ideas, I wish I could be there in person.Edit: Subsequent comment made me realise I was very unclear. When I say "as physically close to the supply pins as possible", I mean as close to the VCC and GND pins on the PIC IC as possible.

author: PSR B1257
author_rank: Frequent Contributor
timestamp: June 16, 2015, 04:23:49 am
content: QuoteThey not belong to the power supply, they have to be placed near to the load (i.e. the motors and the PIC)

author: DigitalFlower
author_rank: Contributor
timestamp: June 17, 2015, 10:31:27 pm
content: Hi! well, i tried placing the capacitors as close as possible to the PIC and the motors, but the pic keeps resetting after the motors start, i needed it working for today, so i just used optocouplers and problem solved, wish i had found what was causing those issues :/thank you all!