L298 question

Hello, I am using a L298n chip to control a motor speed the problem is when I use a PWM signal on the ENABLE PIN I also get a low frequency voltage PWM at the SENSE pin.
I am reading the voltage from a 1ohm resistor applied to the sense pin.

If I use 20V at 60% PWM = 12V, the torque is a lot less that I can very easly stop the motor with one finger.
If I use 12v at 100% PWM the torque is much stronger and more dificult to stop it from rotating.

I want to supply the motor with 20V and control it’s speed and such with a PWM signal.
If I regulate the voltage of the supply to use 20V or 12V or even 15V I dont get the same results as if I am using PWM on the 20V in order to get those voltage values.

Does anyone know why this is happening? How can I prevent it or bypass it?

I have the shield on the picture,


, I am using a L298n chip to control a motor speed the problem is when I use a PWM signal on the ENABLE PIN I also get a low frequency voltage PWM at the SENSE pin.

Isn't that what you would expect. If you are PWMing the enable you are effectively going between open circuit and a state where both motor inputs are at the same rail.

A resistor from the sense pin to Gnd would do that. http://www.st.com/web/en/resource/technical/document/datasheet/CD00000240.pdf Look at page 1 - current would flow from Vs thru the top left transistor of A, thru the motor connected to the Out pins, and then the bottom right transistor of A, to Gnd thru the sense resistor. You could use a much smaller resistor (aka shunt resistor) for the sense resistor, and monitor that voltage with an ADC input to know how much current was flowing in steady state conditions. With PWM, you're just dissipating power in the resistor, so you can leave it out. With 1 ohm, 2 amps of current, you would have 2 V across the resistor, and only 18V for the motor.

Do you have diodes on the motor? "An external bridge of diodes are required when inductive loads are driven and when the inputs of the IC are chopped ; Shottky diodes would be preferred."

You are chopping the inputs with PWM on the enable pin.

Grumpy_Mike: Isn't that what you would expect. If you are PWMing the enable you are effectively going between open circuit and a state where both motor inputs are at the same rail.

Hello, the thing is, I am using the arduino PWM which is not the half sec pwm I am getting at the output of the motor if you check the time.

Hello CrossRoads, I am using similar schematic as the one they have on the last pages with the diodes, and I am using also the sense resistor and yes i should use a shunt one instead of a 1ohm but what I really want to understand is that Half a sec PWM at the output when the arduino pwm is more than 300hz...

How could I rectify that pwm at the output of the motor ? And why there is an half sec pwm when I am using the arduino pwm at >300hz is just something I cannot understand.

Fill in some more info - what do you have for a motor? Your original post was PWM at the sense line, not at the output.

Why do you call it PWM when from your last post it is clearly not.

It looks to me like the power supply is going into hiccup mode caused by the over current protection kicking in.

Sry for not being clear. When i said output i meant the voltage at the sense pin. I will try another source. I am using a transformer it has max 4A max current at 20v i will try with a battery and se the results

@marcosmoura,
i think your problem is :

  1. Your way to measure the drive cuttent is OK, but notice, as the drive current is large, you should use large Power resistor, such as Cement Resistor. as i do not see such a resistor on your module, i think you added it by yourself. unplug the “current sense” jumper to add the resistor.
  2. the driver IC would be very hot when drive current > 1.5A; and the voltage 20V is too high, suggest voltage <15V;
  3. For the PWM, you can use the Arduino PWW library analogwrite(), but if you want the motor run steady , you shoud use a higer frequcy PWM.

at least , an alike Motr& stepper shield for your reference.

Hello, I am using an 1 ohm 4W resistor and a pittman mt14202C652-R2 30.3VDC 1000rpm/2v it has a Dynamo so I can read the speed.

At 12V it rotates at around 1800rpm

Today I found that the problem was not about the power. This does not happen when I use pin 13 OC0A or OC0B but it happens when I use all the others OC1A for example. By the way I am using an arduino MEGA 1280.

By chance I tried to use the pin 13/OC0A on the arduino and I also used diferent values of PWM on the enable pin and I got this:

With OC0x I get a steady value for the current/voltage but not when using all the other timer outputs OC1x or OC2x etc which I get that wave as i show you on the 2nd picture.

But for the OC0x When I use PWM I always get a significant lower value for the current I am reading aka voltage at the 1ohm Resistor at the sense pin and as you can see there is a really big diference from 99% PWM to 100%.

Maybe some kind of sync problem?

This is bugging my mind all day long as I cannot figure out why is this happening and also why the other timers outputs don't have the same behavior as the OC0x one.

What is happening is when the current gets above a certain level your supply is cutting out (or perhaps the L298 is thermally shutting down), and then after a short while it recovers, then the high current causes it to repeat this "hiccup".

With timer0 you have a faster PWM signal (about 1kHz rather than 500Hz for the other timers) and thus less peak current is being demanded and the system is working without the hiccups - take the drive level high enough and some current flows (but not enough to trigger the hiccup).

I think you need a much higher PWM rate, 8kHz or so. Your supply is probably inadequate for the motor (or maybe its the L298 not being powerful enough)

What is the resistor for?

Still it does not explain the current difference from 99% to 100% pwm as we can see in the picture, using pwm it significaly drops the current supplied and I have tried both a transformer and a battery as a power source with the same results.

The 1ohm resistor I use it to measure the voltage and then convert it to current, thats why it is 1ohm.

The current problem is a fact, because I feel a lot less power at, lets say, 95% voltage (pwm) than at 100%. The pwm reduces the power for some reason I cannot figure out still.

You are aware of the different modes of operation of an H-bridge with PWM, fast decay, slow-decay, synchronous rectification? And the the frequency of PWM has to be right for the motor. The default PWM from the Arduino is rather low frequency for most motors. Without an oscilloscope on the motor terminals its hard to guess what's happening.

I am aware but I am not stopping the motor or changing it's direction, I just keep it running in one direction. So I enable the top left and bottom right side of the bridge giving me one direction and then I just pulse the enable PIN.

My motor is a Pittman MT14202C652-R2 which I am using on my thesis but it is old and there is no data I could find online and as is my thesis job to model and identificate this motor and then generalize a technique for others.

And as you advised that it could be due to the low pwm frequency, does it causes a significant loss in torque? How would the voltage at the motor leads look like at the osciloscope, if it is good how does it look like and the other way around ? On monday I have acess to one oscilloscope and I can check it.

Another thing, this motor is rated at 30.3VDC, I am using 12V to 24V and it rotates at around 1600-2500 RPM, It has a generator that gives me 2V/1000RPM. - I am using matlab and simulink to interface and program the arduino, the only problem is that the Analog write blocks I have available to use with arduino don't have the option to choose the pwm frequency but this is something I will have to research later, maybe I can somehow edit the source code of the block in order to use fast pwm and a low prescaler.

If someone has worked with arduino and simulink knows something about this send me something I would really appreciate.

This is my setup, LEFT SIDE is what is running on the arduino - recieves the pwm value to output at the enable pin and sends the readings to calculate the current. RIGHT SIDE is the host that runs on my computer, sends signal, reads current and plots it.

Thank you in advance.

Here's the likely datasheet for your motor:

http://www.pittman-motors.com/Brush-DC-Motors/14202-Brush-DC-Motor.aspx

The 30.3 volt variant is listed in the table.

The key to finding the information (sometimes) for these motors is to take the number from the markings (in your case, "MT14202C652-R2") - and start knocking off parts while googling.

Generally, manufacturers use letters to designate differences in model numbers, so to find your motor, I first struck off the "-R2" and googled it. When that didn't work, I struck off the next bit ("C652") - with that, it worked ok by googling "Pittman MT14202". Note that the model # has changed to "DC054B-2" as well.

As you can see, while it's no-load current is fairly small (190 mA), it's peak current is fairly large (11 amps!) - much too large for the L298 (at least when loaded).

Hope this helps to sort things out...

I really have to thank you for finding that, somehow I was always thinking it should have the same serie number or it might have diferent caracteristics because mine has a dynamo attached like this one:

http://i.ebayimg.com/24/!CFmiOpQCGk~$(KGrHqMOKpIE0U64y,NrBNVr,Ivr+Q~~_35.JPG

But another thing is I am only supplying it with 12V and at that voltage even when I don't let it rotate the current doesnt go over 1.6A. I am not really expert about motors but the motor characteristics at 12V should be different ? like the torque if I use half the voltage will some of the characteristics also be half of whats on that sheet ?

DC motor: torque proportional to current, speed proportional to voltage

marcosmoura: Still it does not explain the current difference from 99% to 100% pwm as we can see in the picture, using pwm it significaly drops the current supplied and I have tried both a transformer and a battery as a power source with the same results.

The 1ohm resistor I use it to measure the voltage and then convert it to current, thats why it is 1ohm.

The current problem is a fact, because I feel a lot less power at, lets say, 95% voltage (pwm) than at 100%. The pwm reduces the power for some reason I cannot figure out still.

Ah, you are using a wire-wound resistor to sense current perhaps? You must not use an inductive resistor to sense current, it doesn't work well!

Thanks man! I think yes. It is a really big one.

The shape is like this:

http://speakerbug.com.au/shop/images/WireWound_39ohm_small.jpg

Try using a large surface mount 0.1 ohm resistor (2220 size or so). They are low-inductance. 1 ohm is too large for sensing amps - in general aim for 0.1V or so across the shunt.