How to make this circuit more secure?

Discussion in 'General Electronics Chat' started by hspalm, Oct 2, 2010.

  1. hspalm

    Thread Starter Active Member

    Feb 17, 2010
    Thanks to all of you for commenting my other topic about the relay h-bridge circuit. I have decided to test my circuit using the l293d h-bridge IC's, complete with microcontroller.

    About the circuit. My atmega8 is programmed to read the width of the two servo pulses from a RC receiver. It will output a PWM waveform according to the pulse width, increasing in duty cycle from 1.5ms and descending, and ascending. Like this
    Servo pulse width
    PWM cycle
    PORTB pins 3-6 to the l293d input 1-4 goes high or low according to the motor direction.

    The circuit in my schematic is working, but as I am not to comfortable with electronics, I was hoping maybe you could help me adding resistors or maybe capacitors to make my circuit more failproof? Caps on the 7905 regulator for more stability? Resistors between atmega outputs and l293d inputs in case of current/voltage spikes? Does the motors need any caps? You don't have to worry about the motor specifications, as I already know I am pushing the l293d's limits of 1.2A peak current per channel.

    I appreciate your comments greatly!

    edit: I know you usually should use flywheel diodes across the motors, but the l293d claims to have these included in the IC. Is this sufficient?
  2. Markd77

    Senior Member

    Sep 7, 2009
    What exact regulator are you using? LM78L05 recommends at least 7V input. If the micro can run at 3.3V you could swap to a 3.3V regulator, or you could use a LDO regulator like the LE50CZ which will be OK with anything over 5.2V on the input.
  3. hspalm

    Thread Starter Active Member

    Feb 17, 2010
    The voltage regulator is of type L7805CV, which by the looks of the datasheets also recommends at least 7v input. Comments? Unfortunately the microcontroller can only run at 4.5-5.5 volts. I have several lm317, but this also seem to be recommended 7v minimum for 5 volts regulation.

    If it wasn't so time consuming and expensive to obtain parts here in Norway, I could just go and buy another regulator, or have it delivered next day. Unfortunately this is not the case. What I could do, is to use a 9 volt battery as microcontroller power with 7805, and use the bigger 6v battery for motor power only. Maybe this could also help on disturbance in the circuit, to use separate voltage sources?
    Last edited: Oct 2, 2010
  4. SgtWookie


    Jul 17, 2007
    A 7805 regulator must have a 0.33uF cap from input to ground, and a 0.1uF cap from output to ground; otherwise you risk instability as documented in several manufacturer's datasheets. I have seen 7805 regulators oscillate in the MHz range when the caps were omitted.

    As has already been noted, you will need a MINIMUM of 7V as an input to get a regulated 5v output. 6v just won't work.

    If you can get a 5.6v Zener diode, you can make a simple 5v regulator with an NPN transistor, resistor, and a couple of small capacitors, like this:


    Use ceramic or metal poly film for C1, C2.
    C3 is an optional aluminum electrolytic, but will provide for better transient response. Since you're driving a motor, I suggest that you use an even larger C2; 100uF or more.
    Note that you must have 0.1uF bypass capacitors across your IC's power/ground leads, and you do not show them in your schematic.

    Even though the L293 has intrinsic diodes, it wouldn't hurt to add external Schottky diodes; that will help to keep the IC itself cooler.
  5. jpanhalt

    AAC Fanatic!

    Jan 18, 2008
    Have you considered any of the lithium batteries, like LiPo, Li-ion, or A123? Two in series might just get you enough head room for the MCU/regulator and not over power the motor too much.

  6. tom66

    Senior Member

    May 9, 2009
    At only 50mA of load I found a LM7805 actually dropped out around 6.25V. 7V drop-out only applies for higher loads, which I doubt the OP's circuit is using. Further, it managed had a 4.5V output with 6V input, which would be in spec for the MCU.
  7. Audioguru

    AAC Fanatic!

    Dec 20, 2007
    The L293D is spec'd for a max output of only 600mA but survives (with no spec's) 1.2A.
    Its max loss is 3.6V when its load is 600mA so the motor gets only 2.4V when the supply is 6V.
  8. hspalm

    Thread Starter Active Member

    Feb 17, 2010
    Thank you for all the info guys. My circuit is now up, but not yet running smoothly, with only the two caps sgtWookie suggested as difference to the posted schematic. I also use 9 volt battery for the 5 volt regulator. The bigger 6v battery is connected to motor supply on l293d, but I might have to reconsider my power sources with all these voltage drops all around. I love microcontrollers, and I love drawing schematics like this, hoping it will work, but it is still just not in my nature to consider all of this "electronics" like you experienced do so naturally. Thank you for your help, I will keep posting when I figure out more about what is wrong with the stripboarded proto.
  9. marshallf3

    Well-Known Member

    Jul 26, 2010
    In your case a simple LDO such as the NJM2396F05 is not only a great match but also affordable.