1

I have got all motors running correctly on the L298n. I want to set up speed control with them also. According to this tutorial, to do that I attach a PWM GPIO to the Ena on the L298n. They also are using GPIO 25 as the PWM pin.

Is it correct to attach a PWM GPIO to the Ena to control the speed? I thought it was just Pin 18 that had PWM capabilities(RasPi3)? Or is something else going on here.

0

GPIO 12/13/18/19 can be connected to the Pi's hardware PWM generator. This type of PWM is the most accurate and most flexible.

All the GPIO can be toggled by software and thus may provide software timed PWM.

Software timed PWM is fine for DC motor speed control. It will suffer with timing jitter but this will not be noticeable because of DC motor inertia. Software timing jitter would be noticeable if used to dim LEDs or drive servos.

There is a third type of PWM which the Pi may supply on all GPIO. That is hardware timed PWM. This is fine for DC motors, LEDs, and servos. This uses DMA to time the pulses. It is provided by modules such as (my) pigpio and servoblaster.

  • Might sound like a stupid question, GPIO as in BCM numbering? Are those pins setup just by "p = GPIO.PWM(channel, frequency)" or is there a hardware setup aswell? – dka13 Apr 5 '18 at 14:44
  • Broadcom numbering (BCM in RPi.GPIO). The RPi.GPIO module has no support for any form of hardware PWM. – joan Apr 5 '18 at 14:54

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.