Shop OBEX P1 Docs P2 Docs Learn Events
Microcontroller resets on motor operations. — Parallax Forums

Microcontroller resets on motor operations.

danny99danny99 Posts: 10
edited 2013-01-16 20:34 in General Discussion
Hi

I am trying to make circuit to control four, 24VDC 3A motor in both directions, i am using DPDT relay driven by ULN2803.
problem is whenever i switch the direction, microcontroller resets. Uptill now i have damaged two arduino boards.
CB210 keeps resetting when ever motor operate forward or backward, Circuit is working fine but I want to get rid of resetting problem
cb210 resets.jpg
of CB210.
Any suggestion will be helpful.

Thank you
388 x 252 - 24K
«1

Comments

  • Mike2545Mike2545 Posts: 433
    edited 2012-01-09 08:49
    I would check your power supply, see if you have enough amperage to operate the motors and the microcontroller.
  • ercoerco Posts: 20,257
    edited 2012-01-09 08:56
    Seperate power supplies for the micro & motors. And flyback diodes on your relay coils. And some caps on your micro power supply, 100 uF filter and 1 nF decoupling.

    Any time a motor suddenly reverses, it's a dead short for a while and sucks current with wild abandon, which drops the supply voltage. You have 4 motors and 4 relays that require a lot of current. Either that voltage drop or the resulting noise on the power supply line is the probable cause of your micro resetting.
  • ercoerco Posts: 20,257
    edited 2012-01-09 09:26
    One other thought. You have an external voltage regulator taking 24V down to 9V to input to your micro, which presumably has its own onboard voltage regulator to take that down to 5V (or 3.3, whatever). You could try using a 12 or 15V regulator (the largest voltage your board will accept) with a nice big filter capacitor. That would give you a few more volts overhead and a small energy reserve which might be able to power your micro while the motors are reversing.

    Mike2545 is right, in any case. You probably need a whopper of a power supply. Try two BIG 12V gel cells (7AH or bigger) in series instead of a wall wart.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-01-09 09:31
    It sounds like you have two problems, though related. If this circuit is damaging your Arduinos there's something wrong that needs addressing. Your illustration shows flybacks on the relay coils, and the ULN2803 also has them internally. You should put this up under a scope to see what type of transients you're getting when the motors reverse directions. I can only imagine they're much larger than the filtering caps can handle.

    Your Arduino can operate on its own supply, from a 9-volt battery as a test. It's hard to see from your drawing what you're connecting the 9V supply to. It should be through the barrel connector, which gives you the additional protection of a reverse polarity diode. Don't connect it to just the Vin input on the bottom of the Arduino.

    Place dropping resistors between the Arduino and the ULN2803. That'll at least limit current pulled from the driver chip should it blow because of excess demand on the other side.

    And, as Erco says, dropping 24V to 9V through a linear regulator is wasting tons of energy in the form of heat. Your regulators won't last long, especially if they're not on heat sinks.

    -- Gordon
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-09 09:34
    How and where are your logic ground and motor/relay return connected?

    -Phil
  • kwinnkwinn Posts: 8,697
    edited 2012-01-09 18:09
    First try putting a diode between the 24V power supply and the left most (47uF?) capacitor in your diagram. That keeps the capacitor from discharging back to the motors.
  • jmgjmg Posts: 15,175
    edited 2012-01-09 22:29
    Wow, I see you have relays flipping motor direction in a very brutal way.
    Motors work as generators until they stop spinning, so when you flip direction, you are going to dump a > -20V supply, across your 24V,

    Try a separate 24V supply, with some current limiting to ease the flip-over.
    Relays are also a known reset scourge, as they can give sub-ns edges - if you must use them, separate the power supplies, and move them as far from sensitive electronics as is practical.
    There are Motor Bridge ICs from companies Like Allegro ?
  • danny99danny99 Posts: 10
    edited 2012-01-10 06:09
    Thanks Mike, Erco, Gordon, Phill, jmg and kwinn for your advices and comments.

    To clarify more I am updating the schematic diagram plus i am adding more information related to the project.

    I am designing a small window actuator control panel controlling 4 window actuator. HUWIN Linear Actuator

    I am powering they system using MeanWell switch mode power supply AD155B - 5A, I have a linear regulator 7809 to power my CB210,

    I am using DPDT relays to switch the directions of the window actuators, when I use separate supplies system tends to be stable but if I try to use same supplies to power motors and cb210, resetting problems occurs.

    Unfortunately design requirements is to have one supply for everything.

    Thank U , any help to sort the problem will be appreciated.

    cb210 resets 2.jpg
    1024 x 1586 - 192K
    1024 x 661 - 100K
  • T ChapT Chap Posts: 4,223
    edited 2012-01-10 07:21
    How is one relay allowing the motor to
    a. move direction A
    b. move direction B
    c. STOP

    Does the motor have a built in limit switch that kills power so you do not need a power off mode on the relay?


    You should have a large cap both in front of the 7809 and after it. ie.2200uf on the input (rated at >25V), similar on the output. This will mask any momentary drop out.

    I would recommend using P and N channel mosfets and an H bridge mosfet driver. This has some benefits over relays:
    1. Possible relay failure over time ( mechanical failure )
    2. With mosfets, you can use PWM to ramp the motors on and avoid hard starts
    3. Easier current limiting to the motors with an Hbridge driver.

    If you are damaging your processor, then you may need to further isolate the IC with a buffer. A cheap simple buffer you may have on hand would be a 4050 ( or two 4049 gates in series ). Drive the 2003 from a buffer.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-10 07:31
    You still have to protect the microcontroller from the voltage surges caused by suddenly reversing the motors. The schematic doesn't show the physical layout and the way you connect the microcontroller to the power supply may be contributing to the problem. There needs to be a separate power lead and ground lead from the microcontroller to the power supply where the motor power leads from each of the motors connects. You should also have additional filtering on the 7809 regulator. Don't be surprised if your relays wear out quickly from arcing from the rapid reversal of the high current. This article on "snubbers" is a starting point for trying to prevent this. An RC network or the back-to-back Zener diodes mentioned could be a starting point. You may also be transiently shorting out the power supply with the high peak currents from suddenly reversing the motors. You may need to add extra relays to turn off the motors briefly as they're reversed (turn off - reverse connections - turn on).
  • danny99danny99 Posts: 10
    edited 2012-01-10 07:43
    Few things i have came accross that might help to reduce reduce voltage spike.

    As DPDT was sparking alot, i have used extra SPST relay to switch over when DPDT relay contacts are in place, making sure contacts doesnt get shorted.

    cb210 resets 3.jpg


    Will see if it works.

    if not I am thinking of putting power mosfet in place of SPST any suggesstions. ?


    thank u .
    1024 x 661 - 104K
  • danny99danny99 Posts: 10
    edited 2012-01-10 07:54
    I agree with you, thanks for the help. System has improved i have connected the supply using following supply, it has improved the voltage supply line,
    I am going to properly filter the supplies and will have another go if its reliable enough to go into the final design.

    Now Snubber circuit, does anyone have any information or article to help me build a snubber for the bi directional motor control.

    Thank u for your help mark.
    7805-protected.gif
  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-10 07:57
    You need at least two SPST relays, possibly one for each motor, to satisfy your own criteria (only two motors on at a time). How about using H-Bridges after all instead of all the relays and the Darlington array? Look at this and that. Note that, for on/off/reversing, a pair of relays (DPDT & SPST) works fine. You do need snubbers to prevent the arcing and prevent these voltage / power surges from propagating back to the power source (and any other circuitry).
  • danny99danny99 Posts: 10
    edited 2012-01-10 08:41
    Mike Green wrote: »
    You need at least two SPST relays, possibly one for each motor, to satisfy your own criteria (only two motors on at a time). How about using H-Bridges after all instead of all the relays and the Darlington array? Look at this and that. Note that, for on/off/reversing, a pair of relays (DPDT & SPST) works fine. You do need snubbers to prevent the arcing and prevent these voltage / power surges from propagating back to the power source (and any other circuitry).

    I think i will try MOSFET H BRIDGE using opto isolator.

    do u have information on snubber circuit, struggling to find some ideas to protect relays.

    thank u
  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-10 09:19
    If you're using an SPST relay on each motor (preferably in the +24V lead, not the ground lead), you can use a reverse connected diode just like for the relays. This would be between the SPST relay contacts and the DPDT relay, between power and ground. You can also put a capacitor across the motor windings, something on the order of 0.1uF to 0.47uF with at least a 100V rating. The idea is that you turn off the power using the SPST relay, the diode absorbs the turn-off spikes, then (after a short pause ... a few milliseconds), you change the DPDT relay setting, then turn on the power with the SPST relay.
  • danny99danny99 Posts: 10
    edited 2012-01-11 08:44
    thanks for the suggestion,

    please have a look on the schematic. due to resolution picture are not coming clear from software. sorry
    three zone panel test1.jpg

    three zone panel test1.jpg
    s
    1024 x 522 - 53K
    1024 x 507 - 36K
  • Mike GreenMike Green Posts: 23,101
    edited 2012-01-11 10:34
    The new diode anodes have to be connected to ground. Remember that the DPDT relays don't change position until the back-EMF has a chance to die down (after turning off the power with the SPST relays). There should be no arcing at the DPDT contacts and these new diodes help prevent arcing at the SPST relay contacts. You will also need capacitors across the motor windings as I mentioned in post #16.
  • danny99danny99 Posts: 10
    edited 2012-01-13 03:33
    MICRO 1.jpg


    I am using an H bridge mosfet motor driver, when i connect manually the ground pins to ground circuit works fine.
    but when micro is used to control motor via opto coupler motor some time work as desire and some time doesnt responds.
    could any one help me. why mosfet are not working properly with optocoupler.
    Iam using PC817 optocoupler.

    thank u
    570 x 990 - 68K
  • T ChapT Chap Posts: 4,223
    edited 2012-01-13 06:14
    Hi. I am curious where you go that schematic? That schematic shows that the opto would turn off both the high side and low side at the same time on one side of the motor, and have both the high side and low side turned on on the other side of the motor. That shorts 24 almost to GND. Is that exactly what you have built?

    The mosfet configuration should allow the high side to be ON on one side of the motor only when the LOW side is ON on the other side, and vice versa. Also, I have not used those mosfets but in some cases, the voltage to the gate of the high side mosfet needs to be some amount higher that the 24v. This is often achieved by a mosfet driver IC.
  • kwinnkwinn Posts: 8,697
    edited 2012-01-13 11:25
    @T Chap,

    Unless I am mistaken one transistor is a P channel and the other is an N channel so both will not be on at the same time except when switching. Unfortunately that may cause a large current spike while switching, particularly if the optoisolators are not high speed units. Better to use an H bridge driver for this.
  • T ChapT Chap Posts: 4,223
    edited 2012-01-13 11:43
    Is 10k enough to turn on the low side?
  • kwinnkwinn Posts: 8,697
    edited 2012-01-13 11:47
    danny99, I would suggest the following:

    Power the micro from the 24V supply using a diode and large capacitor as in post 13.

    Use a switching regulator instead of the 7805.

    Use an H bridge driver to drive the transistors or a complete H bridge chip/module.

    Allow time for the motors to stop before reversing direction.

    Turn motors on one at a time and wait at least 100mSec before turning on the next motor.


    The circuit in post 19 may work initially but the large spikes caused by both transistors being on during the transition period will eventually cause them to fail. An H bridge driver chip turns one transistor off before turning the other one on to avoid this problem.
  • danny99danny99 Posts: 10
    edited 2012-01-16 07:31
    thanks Kewin, for the suggestion i will order some new components to drive as u said,
    @tchap yes it does work, but optocoupler are not able to work correctly with them resulting so many burnout mosfets.

    i will update the post with the final solutions soon

    thanks all for the help.
    kwinn wrote: »
    danny99, I would suggest the following:

    Power the micro from the 24V supply using a diode and large capacitor as in post 13.

    Use a switching regulator instead of the 7805.

    Use an H bridge driver to drive the transistors or a complete H bridge chip/module.

    Allow time for the motors to stop before reversing direction.

    Turn motors on one at a time and wait at least 100mSec before turning on the next motor.


    The circuit in post 19 may work initially but the large spikes caused by both transistors being on during the transition period will eventually cause them to fail. An H bridge driver chip turns one transistor off before turning the other one on to avoid this problem.
  • T ChapT Chap Posts: 4,223
    edited 2012-01-16 08:07
    If the opto is not fully turning on or off, then both mosfets could be partially on. If you are burning up parts, then you should look for where the problem is happening. For example, you could disconnect the gate to the PNP, then put a volt meter on the in to the opto, see what the voltages are for each state. If the opto is ON, the voltage should be close to 0V, when off it will be 24v. Post what the voltage is. You may need a smaller resistor controlling the opto to force the voltage closer to GND.

    I never like concepts that switch both the PNP and NPN at the same time, because there is a potential for both to be on during the transition. There is also the potential for both mosfets to be partially on if the opto is not fully turning on(pulling the gate V to gnd). The other option is to independently control each gate with the Propeller, I would control it via a buffer(even as simple as a 4050 or 4049, not opto). But, the problem again with independent switching is that if there is a state where both can be on, things burn up. On boot up, when the pins are in input on the Prop, you would need to define the states of the gates with pullups or pulldowns until the Prop takes over. Then hope there is no case for a hangup on the Prop. That is why an Hbridge controller is best of all options. Choose an Hbridge driver based on voltages, amps required per motor. Then you can feed the controller direction and speed( DAC) straight off the Prop, and let the driver worry about the transitions. I spent a lot of time watching mosfets burn up to learn this the hard way. You can get this to work with the Prop alone, but it will take effort to make sure there is a dead time between transitions. A scope is best to watch the control lines to be sure that you are not overlapping gate controls. If you are wanting to use PWM, then you do not want to be switching both PNP and NPN off the same pin, that is like getting in car and slamming the gas down then slamming the brake, back and forth as fast as possible, this is assuming you have only one side of an Hbridge.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2012-01-16 08:45
    I suspect that the Opto is turning on just fine ... One thing I see as mentioned is that the 10k is not providing enough pull-up current to the NMOS transistors.

    Another note: Unless you have adequate current to drive the gates, tying the NMOS and PMOS gates together like this can cause high current spikes... enough to reset a micro controller, this is why applying a brute force 'direct' connection will work, and it will fail when powered from the micro. Even if the NMOS and PMOS transistors are exactly matched ... i.e. complementary ... there is a certain amount of overlap during the transition from On to Off where BOTH transistors will be ON. This is due to the gate capacitance of the transistors. This is also why you see the gate drive split between an NMOS (low-side) and PMOS (high-side) driver. Other than supplying the correct gate voltage, high-side and low-side driver chips also introduce a small delay between turning one transistor OFF and turning the other transistor ON.

    If the Opto is capable of delivering an adequate gate current (many times they are only a few milli-amps.), I would go ahead and leave the 10k resistors there, but I would also split the gates. This means putting 10k resistors on the NMOS transistors to ground as well as leaving the 10k resistord from the PMOS transistors to the supply voltage. This way all of the transistors are off during power-up and micro controller initialization. This also means that an Opto is connected, not only to the NMOS, but also to the PMOS transistors.

    Another Note: the indicator LEDs that you have in series with the Opto might work with a 5V micro controller, but it will fail with a 3.3V micro controller... it's better to run your indicator lines from a separate parallel circuit rather than a series circuit.
  • T ChapT Chap Posts: 4,223
    edited 2012-01-16 09:48
    One way to avoid part of the guesswork is to actually determine what the mosfets are doing without the motor connected. For example, remove the motor and disconnect the PNP from the NPN from each other. Set the pin to a state( high or low ), read the resistance on both mosfets, change the pin state again and read the resistance again. When the mosfet is open, it should read very high(meg ohms), when it is closed (and depending on gate drive factors), it should read very low ohms. In some cases a mosfet is already damaged and you are still testing, and things are not behaving logically, so it is a good idea to test the mosfets as you go to confirm that the circuit is acting like a switch, and not hanging around in some in-between state. In the beginning stages of learning mosfets, this practice of experimenting with 'seeing' and understanding the mosfet as a switch is valuable. If you consider that a mosfet is not necessarily full on or full off, but can be partially conducting, then you can better plan your control voltages.

    Regarding using independent control of both the PNP and NPN with separate opto's, you cannot use a pullup or pulldown resistor on the input to the opto. But, you can insert a gate in front of the opto, and put a pullup or pulldown in front of the gate to serve the purpose of setting an initial boot up state for the gates until the Prop takes over.
  • danny99danny99 Posts: 10
    edited 2012-01-25 02:17
    Hi all there,

    thank you for your suggestions and comments. really kwin and tchap have very good knowledge on mosfets and electronics.
    the scheme i m using was not good becos mosfet were not able driven properly by the opto n resulted all my mosfets burned in doing this test.

    now i am trying to use relays again with a delay. Its working but i cannot address the spark ( arc ) in relays.

    One spst is providing 24v supply line to 4 DPDT motor relays, when i have to switch the direction of the motor i break the circuit by opening SPST then give a delay and then switch DPDT motor relays.

    this is not restting the micro now but, on scope i can see noise in supply plus spike in the supply lines on reversing the motors.

    Regards

    thank you .
  • kwinnkwinn Posts: 8,697
    edited 2012-01-25 20:11
    You might try running each motor with two solid state zero crossing relays and diodes directly connected to the AC voltage. One relay allows the positive half cycle to run a motor in one direction, the negative half cycle runs it in the other direction.
    Again, a short delay before reversing direction is recommended. Solid state zero crossing relays will avoid a lot of noise problems since they only turn power on or off when the AC voltage is crossing 0V.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-01-25 21:20
    danny99 wrote: »
    Hi all there,

    thank you for your suggestions and comments. really kwin and tchap have very good knowledge on mosfets and electronics.
    the scheme i m using was not good becos mosfet were not able driven properly by the opto n resulted all my mosfets burned in doing this test.

    now i am trying to use relays again with a delay. Its working but i cannot address the spark ( arc ) in relays.

    One spst is providing 24v supply line to 4 DPDT motor relays, when i have to switch the direction of the motor i break the circuit by opening SPST then give a delay and then switch DPDT motor relays.

    this is not restting the micro now but, on scope i can see noise in supply plus spike in the supply lines on reversing the motors.

    Regards

    thank you .

    Recommend RC snubber across the motor connections at the relay. Also, are you letting the motors stop prior to reversing them? If not, your going to have an additional time of high current. You also want to cure this arcing otherwise, you will have a relay contact weld shut bad news, the motor will not stop, or alternatively, the contact points will become charred and pitted resulting in a resistive or no contact at all. The worst of these being the resistive contact as it will heat up and eventually melt together of burn.

    Frank


    +
  • ampsamps Posts: 2
    edited 2013-01-16 20:34
    Dear sir,
    I wanna ask you few question on above circuit. I tried with SPDT relay not with DPDT
    1)Whether above circuit has been successed
    2) The above circuit dont have back emf protection. SO whenever it changes direction we assume freewheeling diode will take back emf current. But some time it wil try to move lease gnd path so that why arduino might get damage
    3) it dont have short circuit protection.
    4) Assume that you connected linear actuator to relay. What will happen if all relay drive get turn on
    5) assume that you checked status of pin @ programming , but @ arduino get power all pins will be high , You can test your code with powering arduino


    danny99 wrote: »
    Thanks Mike, Erco, Gordon, Phill, jmg and kwinn for your advices and comments.

    To clarify more I am updating the schematic diagram plus i am adding more information related to the project.

    I am designing a small window actuator control panel controlling 4 window actuator. HUWIN Linear Actuator

    I am powering they system using MeanWell switch mode power supply AD155B - 5A, I have a linear regulator 7809 to power my CB210,

    I am using DPDT relays to switch the directions of the window actuators, when I use separate supplies system tends to be stable but if I try to use same supplies to power motors and cb210, resetting problems occurs.

    Unfortunately design requirements is to have one supply for everything.

    Thank U , any help to sort the problem will be appreciated.

    cb210 resets 2.jpg
Sign In or Register to comment.