0

I am new to the Arduino stuff and I am using L298N to drive two DC motors. When I searched online for sample code, I noticed that there are two types of design.

One type uses analogWrite(pin, pwmOutput) to control PWM on IN1/IN2 pin to adjust speed, and the other uses digitalWrite(pin, HIGH/LOW) to control IN1/IN2 but use analogWrite(enA, pwmOutput) to control speed.

I guess probably both can work, but I just feel it is not right to apply PWM on the enable pin. Any suggestion from the experts?

One more thing, many people say L298N is obsolete. Would anyone please recommend a replacement motor drive module?

1

I'd use PWM on EN input. Motor will be driven in HIGH and left floating in LOW. The other method means it'll be shorted (= full on brake).

L298N is based on bipolar transistors. That means relatively big voltage drop between drivers Emitter and Collector (about 2V on each transistor), so there are big power losses (= heat).

Maybe something like LMD18200 could be used as unipolar replacement.

  • Thanks for your reply, but I don't think the other method means shorted. For examle, IN1 = LOW (one bridge lower arm ON) and IN2 is PWM (the other bridge upper arm PWM), or vice versa, is the common way used in discrete MOSFET H-bridge circuit. – roTor-roTor May 14 '18 at 11:05
  • So you have one pin connected to the 0V and second one is alternating between 0V and 12V (I've omitted voltage drops) - what happen, if your motor rotates and you connect both ends to the 0V? Well, with voltage drops that big as in L298N it's not such a big short, but still. – KIIV May 14 '18 at 11:15
  • If both ends are connected to 0V, the motor terminals are temperarily connected together through the lower arms of the H-bridge. It is a short brake effect, but it shouldn't be a problem. – roTor-roTor May 14 '18 at 11:27
  • @roTor-roTor Except for lower efficiency, bigger losses on transistors... It might be interesting to measure RPMs vs current, minimal pulse width to start rotation from zero RPM .... – KIIV May 14 '18 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.