2

I am using the L298N motor driver for a robotics project to control 4 motors. 2 motors in each input and output terminal. I have this connected to an Arduino Uno which is powered by about 7-8v from NiMH batteries. This battery source also powers a servo with a 470uF capacitor and the L298N board.

I have a strange problem when I use the servo attach method for my servo, only outputs 1 and 2 on the L298N start working meaning the wheels on the left of the robot start moving only. When I have the servo connected and imported the library but don't use the attach method, the L298N outputs to all DC motors meaning it works. Even when I use the servo attach method on a pin where nothing is connected to it, the motors on out 4 and 3 on the L298N don't move. For some reason this attach method is causing issues. Can anyone explain why?

Note: I applied a larger power supply, from my 7V to about 12V but the problem still persists. I don't think power is the issue since the problem even happens when the attach method is called on a pin that has no servo connected to it.

sa_leinad
  • 3,118
  • 1
  • 20
  • 49
Don Grey
  • 71
  • 1
  • 4
  • Are you using PWM outputs for driving L298? If there is any of PWM outputs on the same Counter/Timer as Servo, it won't work, as Servo needs different settings for that timer. – KIIV Oct 05 '16 at 18:23
  • what do you mean counter/timer – Don Grey Oct 05 '16 at 21:00
  • 2
    In the microcontroller used in the Arduino Uno, there are three Timer/Counter modules. Each of them has two hardware PWM channels. If you mix up one `PWM` output and one `Servo` output, it'll change settings for PWM and it might stop working (thats a problem mainly for Timer1). Pins `3` and `11` are on `Timer2`, `9` and `10` on `Timer1` and pins `5` and `6` are on `Timer0` (this one is used for `millis()` too) – KIIV Oct 05 '16 at 21:43
  • I agree with @KIIV . It seems a problem with Servo library and PWM outputs (specially with pins 9 and 10). – caligari Apr 06 '17 at 02:26
  • 1
    If possible, could you please include your code and your schematic? – sa_leinad May 10 '17 at 13:28
  • The L298N boards can either control stepper motors or general DC motors. You have mentioned that you are using the servo library which is for [servo motors](https://www.sparkfun.com/products/11884) which generally only rotate 180 degrees. Can you please clarify what motors you are using? – sa_leinad May 10 '17 at 13:32
  • We need to see your code and schematic. – Gabriel Staples Aug 05 '17 at 14:39

0 Answers0