Microntroller resets with L6203 Stepper driver

Discussion in 'The Projects Forum' started by Ahmed Adel Hosni, Jul 13, 2011.

  1. Ahmed Adel Hosni

    Thread Starter Active Member

    Aug 16, 2010
    I have a strange problem and i'll put both the schematic and pcb layout because i guess the problem happens because of the pcb.

    I designed a controller and a stepper driver to drive a 4.2A motor. That's the link http://ram-e-shop.com/test11/product_info.php?cPath=35_62&products_id=244

    The pcb layout was divided into two parts. the controller which receives the data to drive the motor. like the number of steps, direction and delay. these data are received using another circuit, i call it the master circuit. which controls several control circuits and is connected with them using I2c protocol. The master cct is connected to the computer using serial interface. so in brief. the laptop sends the X motor for example, and send the delay, steps & direction to the master and then the master choose the driver responsible to drive the X stepper motor and send the data to it's driver.

    The controller of the stepper motor and the driver itself are on one pcb unlike anything i saw on the internet, where the controller and the driver are separated. the controller which is a Pic18F452 is isolated from the driver which is designed using L6203, by Optocouplers.

    The schematic is attached.

    LOW_LOGIC defines a 5V for the controller and it has an individual power source.
    HIGH_LOGIC defines a 5V for the driver and it has another separte power source
    HIGH_POWER_LOGIC is the high voltage used to drive the motor. it can by 12 or 24V. HIGH_LOGIC & HIGH_POWER_LOGIC are common ground.

    L4-L8 are indicators. L4 lights up for one second when power turns on.
    I know that the microcontroller resets when it turn on & off again.

    The Problem:

    After designing the PCB it was tested using a small stepper motor before using the bigger stepper motor at the top. The motor worked very well but sometimes it resets but we thought the problem because of the power source due to the existence of several circuits so we got bigger source with more current and also we changed the value of the I2c pull up resistors and the problem was solved and we thought that it won't happen again.

    Later on, we bought the bigger stepper motor. we sent the data to the master then to the controller to drive the motor. but the micro keeps resetting. it just moves a second and stops because of the reset. The HIGH_LOGIC_POWER is 12V only. we thought maybe that's because of the motor noise which affects on the controller because we designed them on the same PCB. so we added the snubber network and put 5.5 ohm i guess and 15nf. but the problem wasn't solved. we even tried bypassing capacitors over the LOW_LOGIC supply and also nothing was solved.

    The 2 L6203 has two heat sinks. the heat sinks are big and we used the heat sink of a pentium 3 processor. The 2 L6203 are side-by-side and there is a small clearance, i guess, 7 mm between the heat sinks of them.
    the problem was solved by luck when i put a third heat sinks at the top of each of them where the bottom surface of the third heat sinks touches both the top sides of the 2 heat sinks. when that was done, the circuit no longer resets using the 12V supply. I didn't try high voltage because the transformer i ordered was sent by mistake to be 44 V and the max volt for the L6203 is 48V and the power supply reached 55 V after rectification.

    The PCB layout is attached.
    The controller is on the left side and the driver on the right, isolated by optocouplers. the power plane is the ground of the high side circuit which is for the driver.

    I need to know, does the UC resets because of the motor's noise and i need to make to separate circuits ??
    Why did the third heat sink solve the problem ??

    THanks in advance and sorry for my long story
  2. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    Ur circuit does not have the necessary bypass caps

    Use a electrolytic 100uf parallel with a 100nf at the supply line of the PIC, as close as possible to the IC.
    And put 100nf ceramic caps on all the supply in put terminals
  3. SgtWookie


    Jul 17, 2007
    You're depending on the copper pour of the ground plane to interconnect everything in the high_power portion, which it does - HOWEVER, the ground plane is almost nonexistent in a number of places.
    For example, the connector you have labeled HIGH_POWER at the upper right is grounded to the copper pour area. If you look to the left, there is only a VERY thin piece of copper connecting that pour area to the rest of the ground plane near R17. There are several other examples of that. Have a look at C2; it's practically all by itself. There is only a very thin area of copper connecting its' ground to the rest of the pour; that area passes under OC1 and OC2.

    Find the ground path for U4. It's almost like a "Where's Waldo" cartoon. Now for the real rub - Find the ground paths for R11 and R12. Those great big power resistors are grounded by a very narrow strip of copper.

    To try to save your board from this, you might use some rather heavy-duty solder wick (flat braided copper) with some heat shrink around it as jumpers to connect these almost isolated areas to the main ground plane, using the most direct route possible. However, the parts placement and routing really needs some work.

    I don't know what software you used to create the PCB, but in Cadsofts' Eagle, you can define many different copper fill areas using the Polygon tool, and use the Name command to join whatever node names together that you wish. You could have separate ground pours for the low_logic, high_logic and high_power areas of the board.

    The traces on your board are very convoluted, and the signal paths are very long - which causes the inductance of the traces to be very high. I suspect that you used an "auto-router" with very few (if any) rules.

    You put the current limiting resistors for the optocouplers on the ground side (cathode) of the emitter. This is somewhat unfortunate. You really should have put the resistors on the supply side (anode) of the emitter, as close as possible to it.

    Using resistors at the end of long runs will help to dampen the effects of inductance of the traces and capacitance of the receiving IC's will have; otherwise the signal will "ring" and cause all kinds of problems. Have a look at the attached to see what I'm talking about.
    Last edited: Jul 13, 2011
  4. Ahmed Adel Hosni

    Thread Starter Active Member

    Aug 16, 2010
    Thanks for you reply. I'll try to play with the values although i tried these solution before and didn't work
  5. Ahmed Adel Hosni

    Thread Starter Active Member

    Aug 16, 2010
    So you guess that the thin copper area at the OC1-4 are the problem ?? does the thickness of the ground affects and why ?? isn't it just ground and i don't need to care about it's thickness. it won't even carry current to make it thicker.

    I use Proteus ISIS for schematic and ARES for pcb layout. it's manually routed cas i hate auto routing.

    I didn't understand that point. the resistors for OC are just pull up resistors not for current limiting. i just wanted to make sure that it will give full five volt when the phototransistor is off, and give zero when the phototransistor is ON.

    But i don't really understand why does that affects on the PIC ?? the pic is at the lower power and has a separate source.

    THanks a lot sgt
  6. SgtWookie


    Jul 17, 2007
    That's part of the problem.
    Long traces without termination resistors are another part of the problem. Have a look at the attached simulation of ringing due to trace inductance and the capacitance of an IC's input.
    An infinite plane has virtually no inductance and very low resistance.
    A narrow, long conductor has comparatively high resistance and inductance.
    It does make a difference. Even a straight piece of wire has inductance and resistance.


    R1 through R4 are not pull-up resistors; they are current limiting resistors. It would have been better if they were on the anode side of the emitter, and close to the emitter.
    R11 and R12 are your motor M1's current sense resistors.
    All of motor M1s' current flows through that tiny narrow piece of ground plane that goes under OC1, OC2, and then sneaks between the left pad of R17 and the trace below it.
    All of motor M2s' current flows through R13 and R14 to what looks like a nice big ground plane - until you see that the return path to the power connector has to go through a narrow area by L3 and that same really narrow area by R17.
    OC3, OC4, U4 and C6 have another long and convoluted ground path.
    U4 and U5 need bypass capacitors. So does every IC that doesn't already have at least one, particularly your microcontroller which you say seems to be crashing a lot.

    You really don't have to believe me if you don't want to. But, I suggest that you re-think the board design, isolate the three separate grounds which you now have all connected together (causing ground loop problems), make the traces shorter by reorienting components, add bypass capacitors, etc.

    Another thing I didn't mention before is the LM324; it's a single-supply quad opamp, but it is very low-speed and you're using it as a comparator, running open loop. Why not use a comparator instead? Also, your POT signal trace runs another convoluted route, including paralleling R11/R12 so that it can pick up noise due to capacitive and inductive coupling - and there is no bypass capacitor to ground to try to keep the noise down. Can't you relocate the pot connector closer to where the signal is used? Also, consider adding pads for an on-board resistive divider; once you have determined what the optimal resistance is for the divider using the pot, replace it with a fixed resistor divider, as it will be far more reliable. Otherwise, if the low side of the pot opens up, you will have maximum current flow through the driver and stepper motor.

    The one major point that I forgot to add, is that because the ground path on your high_power side is so inductive and resistive, you wind up with high_power current flow through the high_logic and low_logic ground lines back through the power supply ground, through the power cords to mains ground or neutral then back through the high_power supply ground. It's a long and convoluted path, and the noise from the high power side gets coupled onto the high_logic and low_logic grounds.
    Last edited: Jul 16, 2011
  7. R!f@@

    AAC Fanatic!

    Apr 2, 2009
    Boy !!! this is one point I should keep in mind.
    You sure know ur stuff, Sgt.