PWM ports can't drive motor properly. Possible hardware error?

Hi, i want to drive a motor with PWM and have connected it to two pins 10 and 11 on my Arduino UNO.

When i give 0 to 10 and 255 to 11 it runs let's say clockwise with full speed. When i give 255 to 10 and and 0 to 11 it runs counter-clockwise with full speed.

Everything's fine so far.

The problems start when i want to make it move slower by supplying a lower value to the PWM pins. If i give anything less than 255 to 10 (while giving 0 to 11) it doesn't run. However 11 works as it should driving the motor at different speeds.

I tried the other PWM pins and even if i'm not sure i tried all the combinations apparently only pin 11 gives me the desired and predicted result.

This doesn't work!

 void fullForward(){
  int speed = map(incomingInt[0],0, 100, 0, 255); 
    analogWrite(10, speed);
    analogWrite(11, 0);
 }

This does! :/

 void fullBackward(){
    int speed = map(incomingInt[0],-100, 0, 255, 0); 
    analogWrite(10, 0);
    analogWrite(11, speed);
 }

If i just switch the cables, then it'll just run the opposite way, in other words it's the pin number 10 (or all the others that i tried) problem! :/

Is this a feature of Arduino UNO or a possible hardware error? Any ideas on how to solve this or avoid this problem?

Thanks!

kuruki: Is this a feature of Arduino UNO or a possible hardware error?

You shouldn't be running a motor connected directly to your Arduino (microcontroller) pins.

kuruki: Any ideas on how to solve this or avoid this problem?

Yes, it's called an H-Bridge.

Yes, it's called an H-Bridge.

Yeah, an H-bridge is used (BTN7971), sorry not to mention that.... :~

What happens if you plug in numbers in your analogWrites instead of deriving them from map(...)?

11 works as it should, 10 doesn't work with anything less than 255 :/

Have you a link to the spec sheet for the BTN7971.

The one I found seems to be only half of a h-bridge? Have you two of them?

Can you provide a diagram of how everything is connected?

...R

I found this: http://www.datasheetdir.com/BTN7971B+download

Its a 3-die device, controller plus two power MOSFETs in a single epoxy case.

What value of Rsr is being used? It should probably be quite low to allow PWM to be most efficient. How are you driving all three digital signals, IS, IN and INH? How have you decoupled the motor supply?

Hi, sorry for the delayed answer.

This is the datasheet: http://wenku.baidu.com/view/694bd1c058f5f61fb73666ad.html and yes, we use two of those for each motor!

Our circuit to drive looks like these for the two motors: http://imgur.com/wDTC0Sq

It takes 4 inputs for each motor. Ground, 5V and two control signals (that come from the arduino's PWM ports). I explain how we drive it in the first port i think. (one port gives 0 and the other a value which will define the speed)

@MarkT unfortunately i am not sure how to answer your questions. Maybe explain a little more what exactly you are asking, for a beginner like me. :}

The strange thing is that only ONE of the ports works exactly as it supposed to (so we successfully drive the motor, there is no coding error) regardless where we connect it to, but the rest don't. :/

I can't make any sense of you lovely colourful picture. Could you provide a photo of a drawing of how everything is wired up. That would probably answer @MarkT's question also.

When you say one of the ports works as it is supposed to it would also be helpful to see that in the context of the wiring arrangements. Are you saying that you can move one pair of motor control chips to a different Arduino connection and it still works properly whereas the other pair won't work properly regardless of where they are connected. (That sounds like a fault in how the pair is wired up - is it possible one of the mosfets has blown?).

...R

alright, the first it's our drawing, where M is the motor. we actually connect the arduino to the ports in the bottom socket. (IN1 & IN2). Excuse one mistake in the registers' resistance (4.7K instead of 470?), the actual wiring and design is exactly the same as in the second picture. Hope that sheds some light!

P.S. We tried driving the motor with an stc12c5a microcontroller and it worked as it should, so there's no hardware error on that side.

Have you tried testing the pin (10) with an LED/resistor to see if you can vary the brightness of the LED to verify that PWM is working on that pin?

Also - what about the rest of your code, is it doing anything that could alter pin 10 PWM output?

Finally - what version of the Arduino IDE/software are you using?

You haven't answered my question about your statement that

only ONE of the ports works exactly as it supposed to

...R

Please post the code and how its connected to the Arduino - both of these are missing still.