Home » L298N » PWM enable pins L298N

SHARE WITH FRIENDS:  
        
          

Hello readers,

Trying out pwm pins to control the speed of the dc motors was not an easy story.  WiringPi has a software driven pwm handler which is used via PI4J.  In fact WiringPi is a GPI Access C library.  For more information see WiringPi.  The software handler makes it possible to have pwm functionality on all GPIO data pins on the raspberry pi.  There are also hardware pwm pins but there are only a couple of those dedicated hardware pins.  I have chosen to go for the software handled pwm pins.  What worried me was that the pin for the enable pin was not like the ones for the input pins (between the 2 enable pins) on the L298N.  I managed to get it wired but was not really satisfied because it didn’t fit right.  The result was that I could not manage at all the speed of the dc motors using pwm.  Whatever I tried in my little test program, it did not work work on the dc motors.  Just on the moment I was about to test with the hardware pwm pins, I found out there was a jumper on the enable pin, covering 2 pins.  At first sight when turning the L298N upside down, one pin was connected to the enable and the other pin had no real connection.  But since I am not a microchip nor electronics expert, that could be a wrong impression.  I connected 2 pwm (software handled) pins from the raspberry pi with the enable pins on the L298N which fitted right this time.  And guess what.  It worked.  I was able to increase and decrease speed of the dc motors.  Just like mentioned on the WiringPi site.

Shortly the pin wiring.  I am using the Raspberry Pi B+.  The port numbering is described at GPIO Port Numbering.

GPIO 0 -> enable A, GPIO 4 -> enable B, GPIO 2 -> input 1, GPIO 3 -> input 2, GPIO 5 -> input 3, GPIO 6 -> input 4, the output pins are wired to the dc motors, the battery (I used a 8,4V) positive wire is wired to the +V12 pin, the 3,3V power pin (Raspberry Pi) is wired to the +5V pin.  I know it sounds not logical +12V connected to 8,4V and +5V connected to 3,3V but it worked.  I bet my motor will turn like mad when I put higher voltage battery on it.

Jan

l298njumper

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website