Weird drop in voltage, or something else, resets microcontroller

Discussion in 'General Electronics Chat' started by minulescu, Apr 25, 2008.

  1. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Hi all,

    The attached PDF has the basic block diagram of my system.

    First of all: The necessity of the switch to motor controller is because the way the motor controller works: it stalls the motors at 2.5V, turns them forward at 5V, turns them backwards at 0V. Thus, while the microcontroller boots, the motors would start spinning if it wasn't for that switch. After about 4 seconds (once the microcontroller boots, a 2.5V signal is sent to stall the motors, then the motors are ready to receive power and be controlled by the uC however the user chooses).

    The problem: When the switch gets closed, the uC resets for an unknown reason, thus defeating the whole point of the configuration. I don't know why this happens, since all other components (at 24V and 5V) continue to run without loss of power.

    Could it be that once power is allowed to the motor controllers, there is a slight drop in voltage, and the uC, being the most sensitive of the components reboots?

    I know it has nothing to do with the analog enable signal, because I have tried disconnecting that.

    I have also tried putting a big capacitor in parallel at the "entrance" of the uC to "keep it charged" for the split second when voltage might drop.

    Also: the motor controller does not draw that much power.. thus I'm hesitant to just think that it's a drop of voltage due to the motor controller drawing out a lot of power initially.

    Any ideas?!

    Thanks in advance!
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Put a 100uF cap on the output of your 5v regulator.

    At your microcontroller, put a 0.1uF ceramic and 10uF electrolytic capacitor across your supply pins.

    The larger cap takes care of the low frequency transients.
    The small cap takes care of the high frequency transients.
    You need both.
     
  3. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Thanks for the reply, I will try what you suggested and see how it works out.

    Do you have an explanation of why this might be happening?

    Thanks!
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,789
    It is certainly happening for one of the reason listed in the datasheet. Besides a drop in Vcc, don't forget that a rise in GND is equally problematic.
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, since it's happening when you enable the 2.5v signal, then it has something to do with that. I hope that you are not trying to drive the coil of a relay directly with an output from the uC. Ideally, you should be using an opto-isolator like a 4n25. The uC turns on an LED on one side of it, which causes a transistor on the other side to conduct. The relay coil should be powered by the motor side power supply, not the logic side power supply.

    Every IC should have a 0.1uF/100nF ceramic or tantalum capacitor across it's power and ground pins. These are commonly called "bypass capacitors". They cause medium to high frequency transients aka "power spikes" to be bypassed to ground, and help enormously to keep the supply to the IC constant.

    Sometimes, when large transients are present, the small caps alone aren't enough. Larger capacitors will help a great deal to take care of these conditions. However larger capacitors, due to their construction are not very effective in dealing with the high frequency transients. This is why you need to have both a smaller and a larger capacitor in parallel.

    Note that inductors (such as relay coils, motor windings, etc.) will create a large reverse-voltage EMF spike when the current being supplied to them is cut off. It is typical to use diodes connected in reverse polarity from how they're energized to absorb these voltage spikes.

    "Snubbers" are frequently used when the switching on and off to an inductor will be multiple times per second. A snubber basically consists of a fairly small capacitor in series with a resistor, the values of which are determined using various formulas. Snubbers have the effect of dampening the spike.
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Can you supply us with a sketch of the circuit with more detail? Particularly, it would be helpful if you would include that portion with which you are experiencing difficulty.

    hgmjr
     
  7. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Thanks for the great explanation!

    Note that this is NOT happening when I enable the 2.5V signal. I thought I labeled it on the block diagram but I guess I didn't ... The analog enable signal is the 2.5V signal.

    The reseting of the uC is happening when I flip on the switch in the diagram (there is only one switch). That is, when I switch power to the MOTOR CONTROLLER.

    I mentioned in my initial post that I have tried disconnecting the ANALOG ENABLE SIGNAL, and I'm still getting the same results.

    There is no RELAY driven with the uC. The only thing that the uC drives in the block diagram is the MOTOR CONTROLLER .. which I'm not sure how it works.. i'm treating it as a black box. (But I think it's just a H-Bridge anyway). But since you asked.. I am using a relay for the switch that is currently in place in the block diagram.., and I'm using it with a protecting diode... but the RELAY is not the problem. I have taken off the relay, and am currently troubleshooting with just a regular, physical switch.

    hgmjr: what would you like to know in more detail. I think the diagram is pretty detailed. The portion with which I'm experiencing difficulty is the entire system, reason why I provided a block diagram.

    Papabravo: It is happening for a reason given in the datasheet? What reason might this be? As far as I'm concerned I'm providing what the uC needs.. 5V regulated DC.

    Thanks to all for your help!
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,140
    1,789
    Your regulated 5V won't be regulated if the motor controller and the motor create conditions (eg. draw enough current) that prevent the regulator from doing its job. I also gave you the hint of looking at the ground. The processors brownout circuit looks at the difference between VCC and GND. That difference can be reduced if VCC drops OR if the ground level rises. This sometime happens with motors.

    You did not say if your setup is a PC Board or a breadboard. In either case you do not want the processor in between the battery and the motor. That is a prescription for disaster.
     
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You have not presented a schematic as of yet, with discrete components and values of them labeled. What you have presented thus far is an overall block diagram of your concept of how the system is supposed to work.

    SOMETHING connected to that switch is causing the uC to reset. Right now, it seems to be the motor controller. Apparently, enabling the motor controller is causing the uP to reset. So without further information, about all we can suggest is to provide better power isolation between the motor controller side and the digital logic side, add capacitors, add a diode between the power supply and the voltage regulator for the logic, with a LARGE cap to act as a reservoir, add a transient supression cap on the output of the voltage regulator, and add a couple of different sizes of caps across the uC power pins.

    Either that, or don't throw the switch.

    Or, post a schematic so we can see what's really going on.
     
  10. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Ok, I will provide a more detailed schematic. I didn't want to make it too complicated, but I guess you guys really wanna help me get to the bottom of this.

    And from the beginning I thought the idea of adding those Caps was very good, I just am not able to try it out until Monday, so I was trying to see if there are other possible causes that you guys might think of.

    The block diagram I have provided is indeed how the whole system is supposed to work. I will provide a block diagram with schematics showing a simplified system that still causes those problems (ex: motors not even connected to motor controllers, analog signal not even connected from uC to motor controllers).

    I will draw it all out and post it soon.

    Thanks!
     
  11. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Until you have a chance to post a schematic, can you tell us which microprocessor you are using?

    hgmjr
     
  12. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Here's the detailed simplified schematic.

    Again, when I turn the switch on, the uC board resets.

    As you can see, no motors are connected to the Motor Controller to draw out power.

    Thanks!
     
  13. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    I would check to make sure that the watchdog timer is not timing out. If the microcontroller is resetting at a predictable rate that would be a sign of the watchdog timer not being serviced at a suitable interval.

    hgmjr
     
  14. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Thanks for the quick reply. Yah, but it only resets when the switch is turned on. Meaning, I turn on the switch, uC resets, then stays on.. as long as there is battery power. Or.. the other way around. If the switch is closed to begin with, before I apply battery power, then the uC never resets.
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Have a look at the attached schematic. It's a little demonstration of what kind of improvement you can make on your 5v supply.

    The combination of BA1, L1, U2, C5, and Rload1 represent what I believe your 5v supply configuation is (approximately) - in this case, L1 represents the battery's internal resistance.
    BA1, L1, D1, C1, U1, C2, C3, Rload and C4 make up the modified supply. In this case, L1 actually represents a 24v 25W lamp, or two 12v 12.5W lamps in series. This works well to charge capacitors quickly and safely, because at high currents incandescent lamps have high resistance; as the current lessens so does the resistance. This limits the peak charge current through D1 while initially charging C1.

    D1 prevents current flow back towards BA1 in case there is a very heavy transient. C1 keeps a supply of current going to U1 during short-duration transients. C2 and C3 help to filter transients on the output 5v supply rail. Rload + C4 represent typical items connected to the 5v supply rail.

    D2 and the signal generator represent a transient spike generator. Every 300mS a 30mS long 0v transient is placed on the supply, simulating what might be happening when you flip the switch. You will note in the simulated O-scope display on the bottom, your current 5v supply setup (the yellow (A) trace) can't cope with such a transient. However, the modified 5v supply setup (the green (B) trace) is virtually unaffected by the transient.
     
  16. minulescu

    Thread Starter Member

    Apr 15, 2008
    13
    0
    Hey thanks so much for this demonstration!

    I will try and tweak my 5V regulator. Indeed if I had an oscilloscope available I could have checked this sort of thing from the beginning, but the only thing I have available is DMM, which shows 5.0V constant.

    I will let you know how this goes. Thanks so much to everyone for your input!
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Here's some typical automotive bulbs that are about the right wattage to use for L1 (use two wired in series):
    93 - 13w
    211-2 - 12w
    912 - 13w
    561 - 12w
    1003 - 12w

    Note that C1 (and all electrolytic caps for that matter) should have at least twice the voltage rating of what you expect to see in their portion of the circuit. This is to avoid high leakage currents, which will waste power and generate heat, which will also shorten the life of the capacitor(s).
     
Loading...