Current Limiting for Driving Stepper Motors

Discussion in 'The Projects Forum' started by SpiderSpartanju, Apr 27, 2010.

  1. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    I've been looking at various explanations on limiting current for stepper motor control and I need some help. Can anyone verify my logic here? Thanks in advance.

    I hooked up the following circuit today and blew out the H-Bridge.
    http://img52.imageshack.us/img52/3073/ss20100427003002.png

    The Current Sense resistors R4 and R5 are 2Ω, 10W. I think I figured this out based on the explanations over at Jones on Stepping Motor Current Limiting. It looks like with a supply voltage of 24V, a winding resistance of 1.2Ω, and a current sense resistance of 2Ω, I'd be pushing about 7.5A.

    Based on what Jones says I need to use a 12Ω resistor to limit current to under 2A. That means 2A*2A*12Ω=48W. Is this correct? Thanks for any input.
     
  2. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    The L298 does not have internal current sensing.

    The sense resistor pins are there to allow sense resistors for use by external circuitry - have a look at the diagram on page 1 of the datasheet and also Figure 8 - note the sense voltage connections back to the controller.

    L298 Data:
    http://www.st.com/stonline/books/pdf/docs/1773.pdf

    The value of those resistors should be low enough to limit the voltage across them to under 1V at the motor's normal current, so 0.5 Ohms max for 2A current.

    You then monitor the voltage across the resistors using an opamp / comparator or read them using an ADC. Add a resistor & capacitor to filter the signal & protect the ADC from spikes in case of fault.

    It's then up to your control electronics to limit the PWM duty cycle or chip enables to keep the motor currents within the safe limits of the L298. You may still need ballast resistors in series with the motor.

    The other method is to ignore the sense circuit and connect power resistors directly in series with the motor windings, so the total DC resistance controls the maximum current.

    For 2A on a 24V supply, you would need 12 ohms total. Subtract the resistance of the motor winding and that gives you the required ballast resistor value. Allowing for the voltage drop in the driver IC, 10 Ohms would probably be reasonable with your 1.2 Ohm motor.

    If you use this method, look for metal cased power resistors - they are available up to hundreds of watts rating, but need either mounting on heatsinks or you use one about five times the rating you actually need.

    Note - That motor resistance seems very low for a 2 Amp system - what is the motor specification?
     
    Last edited: Apr 27, 2010
    SpiderSpartanju and kingdano like this.
  3. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    Thanks for the response. I understand that that is normally the position of the current sense resistors that are monitored by another chip.

    The motor I'm using is Lin 4218L-01 which is rated for 2A and has a winding resistance of 1.2Ω.

    What I'm wanting to do is use the DC resistance to limit current.
    So based on the L298 spec sheet, by putting the power resistors on the Current Sense pin I'm essentially putting them in series with the motor winding while avoiding a polarity switch across the resistors which are wire wound.

    Does that sound right? Thanks again for the reply.
     
  4. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Take a quick look at the L298 specs again under VCEsat(H) and VCEsat(L).
    VCEsat(H) @ 2A will be somewhere between 2v and 2.7v.
    VCEsat(L) @ 2A will be somewhere between 1.7v and 2.3v
    So, VCEsat(total) will be somewhere between 3.7v and 5v.
    You might just round it off to 4v.
    24v-4v = 20v, 20v/10 Ohms = 2A.
    The L298 will be dissipating about 8W power when conducting.
    You might consider just using an 8 Ohm power resistor from your 24v supply to +Vs, and 0.3 Ohm Rsense resistors. That plus your motor windings gives you exactly 10 Ohms.

    You can't use more than 1.15 Ohms for Rsense, or you will exceed the L298's ratings. R=E/I, since the max on the sense lines is 2.3v and I=2A, R=2.3/2=1.15 Ohms.
     
    SpiderSpartanju likes this.
  5. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    Thank you very much for the detailed response. That all makes sense. The only thing I'm still a little confused about here is this.

    If I use a 0.3Ω Rsense resistor for each motor, doesn't that make the overall resistance essentially 8Ω in series with 2 parallel 1.5Ω for a total of 8.75Ω?

    Now if I use a 10Ω between 24V and Vs and a 0.3Ω R_Sense that would give me 10.75Ω total meaning a current of about 1.85A. Right?

    Also, this would be 1.85A through the entire H-Bridge, which means just under 1A through each motor winding correct?

    Thanks for the help.
     
  6. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, it depends on which step mode you use.

    If you used an L297 along with the L298, the L297 will take care of the current flow - as long as you match the sense resistors and the Vref to the L297.

    You want to limit the maximum continuous current to 2A, or your stepper motor's max current rating, whichever is less. If Rsense is 0.5 Ohms, that means you'll need 1v on the Vref input. 2A through 0.5 Ohms will give a 1v drop across the resistor.

    If you're supplying the L297 with 5v, you can use a 10k resistor from Vref to 5v and a 2.5k resistor from Vref to GND to get a 1v reference.
     
    SpiderSpartanju likes this.
  7. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    So, If I do go with the L297 and I use 0.5 Ohms as Rsense I'll need to find 0.5 Ohm, 2 Watt resistor, right? That pretty much rules out using a pot there to adjust the current.

    Could I use a pot as part of the voltage divider for Vref to control the current?

    Thanks for putting up with all these questions. I'm not getting much sleep these days and running out of time to finish this project.
     
  8. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    You can certainly use a pot on the vref circuit of the L297.

    I'd also use fixed resistors and/or preset pots so you can 'tune' the limits of the reference voltage range you can get to with the main pot, so you can never accidentally get to the point things start smoking.
     
    SpiderSpartanju likes this.
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Actually, you should use a 5W resistor. The actual power dissipation will be 2W, but for reliability's sake, you double the power, so 4W. 4W resistors are rather rare, so you go up to 5W.

    As an alternative, you could drop Rsense down to 0.1 Ohm (100mOhms). This allows use of a lower rated power resistor (0.75W or higher would be OK), and will be much easier to get. It's also much easier to get non-inductive power resistors in that value.

    In the case of Rsense being 0.1 Ohms, your Vref would need to change to 0.2v. A 10k resistor to 5v and 430 Ohms to GND would be about right.

    You really wouldn't want to use a pot for Rsense. Ideally, Rsense should be non-inductive resistors.

    You could, but I recommend against it. Pots are not as reliable as fixed resistors. If the pot should fail, you may have a melt-down.

    The 10k and 2.5k resistors as a divider will give you 1v on the ref input, which is exactly what you need. 2A is the maximum continuous current that the L298 can pass if it has a large heat sink.

    Copper heat sinks conduct heat away much better than aluminum; aluminum is only about 59% as efficient in conducting heat as copper is. Water is considerably better than copper (1.4x as efficient) but water cooling is complex and can be messy if you spring a leak.
     
    Last edited: Apr 29, 2010
    SpiderSpartanju likes this.
  10. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    Ok, now I'm thoroughly confused and frustrated. I hooked up the following circuit and blew up a second L298 H-Bridge.

    The pot on the Vref was set to about 500 either way, so the Vref should be just under 1V. With the Rsense set to 0.5V the Current through each half of the H-Bridge should be under 2A.

    I've tied Half/Full line of the L297 to GND to get full steps.
    I tied the reset, enable, and control lines to 5V to constantly enable the chip, keep it from reseting, and set the chopper function to work on the ABCD lines to the H-Bridge.

    [​IMG]

    Please, can anyone tell me what I'm doing wrong here? I've read through the datasheets for both these chips several times and I've pretty much got the circuit set up exactly how they do in the datasheets, but things are not working as expected.
     
  11. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I can't read your schematic. I suspect you saved it in .jpg format, which is lossy.

    You also have quite a bit of "white space" around the schematic. Less white space, larger schematic.

    I'm not going to be much help unless you can post a legible schematic.

    You should also post an image of your board layout. Don't tell us that you are breadboarding this thing, because breadboards won't handle the current.
     
    SpiderSpartanju likes this.
  12. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    Sorry for the bad schematic image. This should be a much better one.
    http://img130.imageshack.us/img130/4329/ss20100501022803.png

    I have been breadboarding this. I wanted to make sure the circuit would work before going through the whole process of etching boards. I guess that might be the problem since I've set up my circuit almost identically to the one in the L297 datasheet and another example of the 297/298 combo. I would think if the breadboard failed it would just make the circuit not work, instead of making the H-Bridges blow up.

    Thank you so much for all the help on this. It's really been frustrating me.
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    It's too much current for a breadboard. You've probably damaged your breadboard; you likely have a number of breadboard sockets that have been overheated, and no longer connect (open circuit).

    If your L297's Vref is higher than 1v, you will put more than 2A through the L298.
    If your R1/C1 oscillator circuit isn't connected properly, the off-delay won't work properly.
    If you're using long wires running all over the place, you are adding inductance to the circuit.
     
    SpiderSpartanju likes this.
  14. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    Last edited: May 1, 2010
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You were using a pot for adjusting Vref in your schematic. I suggest that you use two fixed resistors; 10k from Vref to Vcc and 2.5k from Vref to ground. Metal film resistors are recommended.

    Pots are nowhere near as reliable as fixed resistors. If you do not have a reliable 1v level on your L297 Vref input, your L298 will quickly go up in smoke.

    Make certain that you have a heat sink on the L298. It will need to dissipate a good bit of power. An old Pentium-type copper CPU cooler with a fan makes for a good heat sink. Copper is 1.7 times more efficient at conduction of heat than aluminum is.
     
    SpiderSpartanju likes this.
  16. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    When you say unreliable 1V, do you mean fluctuating or over 1V? As long as it stays below 1V it shouldn't be a problem right?

    Thank you very much for all the help on this. I've etched circuit boards and plan on testing them today. I'll report back with the results.
     
  17. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    For your setup, 0v < Vref <=1v.
    Pots can be "flaky". If you happened to get a break internal to the pot between the wiper and ground, you will wind up with Vcc on Vref, and a BBQ'ed L297/L298 pair.

    If you really want to be able to "tweak" the motor current, then you could use the fixed 10k and 2.5k in series to establish the 1v Vref, and then use a high-value log pot in parallel with the 2.5k fixed resistor. That way you could decrease Vref, but it could never go beyond 1v - as long as your 5v supply was a constant 5v.
     
    SpiderSpartanju likes this.
  18. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    I hooked everything up in a driver board according to the schematic and I'm getting some weird results. The following is a list of voltages measured on the L297.

    PIN Voltage Function
    1 3.4 Sync(Not Used / floating)
    2 0 Ground
    3 0 Home(Not Used / floating)
    4 3.2 A output
    5 4.4 Enable 1
    6 4.4 B output
    7 3.2 C output
    8 4.4 Enable 2
    9 4.4 D output
    10 5 Enable input
    11 5 Control(Phase/Enable chopping select)(Phase)
    12 5 Vs
    13 0.35 V Rsense 2
    14 0.35 V Rsense 1
    15 1.11 Vref
    16 2.64 Oscillator
    17 2.65 CW/CCW
    18 0 Clock(STEP)
    19 0 Half/Full(Full)
    20 5 Reset

    It looks like it's always going to be trying to turn on all 4 outputs according to this and I'm not sure what's going on with that. At first I thought maybe the 297 was chopping the output, but with V_Rsense at 0.35V and Vref at 1.11V that shouldn't be the case. The outputs do cycle between 3.2V and 4.4V when I send a step pulse on the Clock pin.

    Also with Rsense closer to 0.75Ω and V Rsense=0.35V the current through each winding should be close to 0.5A. I need about 4 times that, but I'm afraid to turn up Vref with the outputs all appearing to be on like they are.

    I know it's about impossible to figure out what's happening without having the circuit, but any ideas what's going on here? Thanks for any help.
     
  19. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Did you not connect pin 17, the CW/CCW input? Right now, it's at an indeterminate level (2.65v) - you should give it 5v or 0v.
     
    SpiderSpartanju likes this.
  20. SpiderSpartanju

    Thread Starter Active Member

    Apr 10, 2009
    49
    1
    Pin 17 must not have been properly connected. It is reading 0V now connected to ground. Measuring the motor wires with everything powered up yields the following.
    PIN Voltage Function
    Motor 1 20 A+
    Motor 2 22 A-
    Motor 3 22 B+
    Motor 4 20 B-
    I also measure all of the voltages on the L297 with just the 5V logic on and then again with the 5V and the 24V on. Notice that the low outputs for A and C change from 0V to 3.3V when the 24V supply is turned on. Any idea what might be causing this?

    Could it maybe be leaking through the capacitors? Would it hurt to try running the circuit without the capacitors?

    Also I'm using 1N5404, 3A diodes for the output of the H-Bridge. Any idea if those would cause a problem?

    Could I possible put voltage dividers on the outputs from the L297 to the L298 to cut that 3.3V to under 1.5V? If I use a 10K and 7.5K I would cut the high voltage from 4.5V to 1.9V. Probably not a good idea, right?

    Thanks for any suggestions

    PIN Voltage(5V only) Voltage(5V & 24V) Function
    1 3.5 3.5 Sync(Not Used / floating)
    2 0 0 Ground
    3 0 0 Home(Not Used / floating)
    4 0 3.3 A output
    5 4.5 4.5 Enable 1
    6 4.5 4.5 B output
    7 0 3.3 C output
    8 4.5 4.5 Enable 2
    9 4.5 4.5 D output
    10 5 5 Enable input
    11 5 5 Control(Phase/Enable chopping select)(Phase)
    12 5 5 Vs
    13 0 0.35 V Rsense 2
    14 0 0.35 V Rsense 1
    15 1.1 1.1 Vref
    16 2.7 2.7 Oscillator
    17 0 0 CW/CCW
    18 0 0 Clock(STEP)
    19 0 0 Half/Full(Full)
    20 5 5 Reset
     
    Last edited: May 4, 2010
Loading...