Thread: L297/L298N driver: determining exact phase current

1. L297/L298N driver: determining exact phase current

Hi all,

I have built 3-axis driver for my first CNC project. It uses one L297 controller and two L298Ns in paralleled configuration for each axis (circuitry basically copies datasheet schematic with 0.235Ω sense resistors). It will drive 57STH56-2804A 2.8A/phase bipolar steppers. Everything seems to work correctly so far and I'm slowly about to try to run it on "full" power (Vs = 42VDC) with almost full phase currents (I want to run my steppers at cca 2A per phase due to limited PSU capacity and warnings about L298N weaknesses). As it moves me into dangerous area where driver and/or steppers may end up burnt easily, I'm trying to be extra precautious.

So, long story short, when adjusting Vref how do I know I have adjusted 2A/phase? Is it that simple that I just freeze clock, attach DMM in VDC mode to sense resistor and adjust Vref to get 2A * 0.235Ω = 0.470VDC on sense resistor or is there some catch?

It is probably stupid question, but I must admit that PWM chopping, different modes of PWM chopping, inductance loads etc. make it bit complicated to me to see clearly what's going on there.

Thank you, T.

2. I'm not familiar with the l297, but a chopper waveform is not DC. A voltmeter won't give you an accurate reading. Use an oscilloscope, or just trust the design equations.

Originally Posted by H500
I'm not familiar with the l297, but a chopper waveform is not DC. A voltmeter won't give you an accurate reading. Use an oscilloscope..
I know that chopper waveform is not DC, but my understanding was that by integrating PWM signal on the sense resistor (which is what DMM in VDC mode attached to the sense resistor IMO does..?) I will get average value which (divided by sense resistor value) represent average (effective?) current going thru the given phase of the attached stepper.

My confusion was more about the fact that phase current does not go thru the sense resistor all the time, "current only flows in the sensing resistor when the winding is driven" (exact behavior depends on chopping mode selected: PHASE CHOPPING or INHIBIT CHOPPING, described in app. note, page 10+).

So, if I would attach oscilloscope to the sense resistor I would still not see phase current all the time.
Originally Posted by H500
..or just trust the design equations.
Problem is that I did not succeed to find any exact equation or algorithm describing how should be circuit adjusted for desired current

Btw. here's the current schematic of my driver (X-axis is shown, Y and Z are the same only with the OSC pins grounded; all XYZ SYNCs are hooked together). Find non-resized version here. I plan to add 3k3 pull-down resistors to step and dir pins and increase C7's to 2200uF yet. - Edit: Done by now

Thanks, T.

4. If I understand the l297 datasheet correctly, the coil current is equal to VREF/Rsense. Your calculated value of .47v appears correct.

The waveform depends on the decay mode the chip uses. If they use slow decay, the current would only flow through the resistor when the coil is driven. During the pwm off duration, the current circulates in the transistors.

Any reason why you did not go with a microstepping design? They run much smoother.

• i have same problem with l297 vref and sens pin

• I'm just jumping into your discussion. I have not studied the L297 datasheet fully.
However, I do know that the SENSE 1 and SENSE 2 pins only see a voltage. This voltage is the result of current flow through their respective sense resistor. It doesn't know anything else. Once the voltage reaches the threshold to trip the internal comparator, the flip-flops change state.

A multimeter measures average voltage. The average voltage is dependent upon the waveform shape. Only a true RMS multimeter will give the correct average regardless of waveshape. Hence which type of multimeter is used could give a different reading for the same waveform.

I would use an oscilloscope to monitor the sense line and use that peak (due to chopper waveform) voltage to calculate the current of the sense resistor. This info could be used to "calibrate" the multimeter reading so the two agree.

• I did some thinking yet and I probably understand it now. See attached chopping_vs_avg_current.gif (I wish I could add picture inside the post but it's not allowed here):

Red curve represents voltage at the sense resistor (Vsense) - as the current is routed different way during the PWM off (decay phase), Vsense is zero and it does not represent current going through the stepper coil during this phase (blue lines represent "missing" parts). This means that average value of the Vsense does not represent average current going through the stepper coil so it cannot be used to determine this current (no meter how precisely measured). Safe way (as H500 stated already) is to adjust VREF voltage (to the [desired current]*Rsense value) instead. Real average current is close and it is always lower (VREF/Rsense determines maximal current).

T.

• Thomeeque,

The RMS voltmeter will give a correct average voltage across the sense resistor since that is all it knows. As you pointed out this calculated average current is not the only current flowing through the motor coil. If you want to know the total current flowing through the motor coil you will need to find the "area under the curve", which in your drawing is the red and blue lines together times the Rsense value..

To be successful in this endeaver, you need to study the datsheet and understand well each section of the chip. This is not a simple task for those who have never designed a stepper driver. Without an oscilloscope you will definitely have a problem since you are designing blind.

I agree with H500 in that this chip does only 1/2 step at best. Smooth lower speed control need a "sinusoidal" drive - microstepping.

However, this project is still a good learning experience, or a stepping stone to better designs, in designing a stepper driver.

• An obvious way to verify the current setting would be to attach an ammeter in series with one of the motor coils. But take extra care to ensure that you don't accidentally break the connection when the power is on. Otherwise, there is a good chance that you will kill the driver.

• Supplying only one stepper motor and monitoring the supply current will give a good indication.

Especially as you are trying to find the right setting not to overload 2A supply.

• Part of the problem is that only a DMM (-an averaging device-) was used to monitor the pulse voltage across the sense resistor. It gives an inaccurate response. If an oscilloscope is not available it would useful to build a diode probe for his DMM such that it holds the peak value long enough to get an accurate reading of a waveform on the DMM. This would be an improvement for chopper circuit design work. Design frustrations are partly the result of inadequate test equipment for the job.

• Just put a 10K in series with the meter lead, and a 1uF across the meter.
That will do a good job of averaging it. Good enough to know what current you have.

A diode probe is used for this if you want to measure the PEAK current.

• Page 1 of 2 12 Last

1. www.C-N-C.cz ? Zobrazit téma - L297 + L298
03-10-2013, 05:02 PM