Control DC and Stepper Motors With L298N Dual Motor Controller Modules

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
asaf
Posts: 4
Joined: Sat Dec 29, 2018 4:32 pm

Control DC and Stepper Motors With L298N Dual Motor Controller Modules

Post by asaf » Sat Dec 29, 2018 4:44 pm

some one have example how to use l298n with pyboard?
i use it with arduino - Control DC and Stepper Motors With L298N Dual Motor Controller Modules and Arduino.
and now i need to use it on pyboard.
Thanks Asaf

OutoftheBOTS_
Posts: 480
Joined: Mon Nov 20, 2017 10:18 am

Re: Control DC and Stepper Motors With L298N Dual Motor Controller Modules

Post by OutoftheBOTS_ » Sat Dec 29, 2018 9:05 pm

First you have to explain whether your controlling steppers or DC motors as both are different code.

Second what are the specs of the motors you want to control(voltage/amperage)

The L298n has a very big forward voltage of 2.8v so is incredibly inefficient that's why they come with such a big heat sink. The only advantage is the the L298n will run at voltages as high as 48v at current as high as 4amp

For all my small robotics I tend to use the l9110s as it forward voltage is 0.7v so it is a really efficient H-bridge but it si only rated to 12v at peak current of 1.5amp

asaf
Posts: 4
Joined: Sat Dec 29, 2018 4:32 pm

Re: Control DC and Stepper Motors With L298N Dual Motor Controller Modules

Post by asaf » Sat Jan 05, 2019 12:35 pm

do you have example code of l9110s and example of connecting the wires to the pyboard.i need to take a car forward and back.
thanks asaf

OutoftheBOTS_
Posts: 480
Joined: Mon Nov 20, 2017 10:18 am

Re: Control DC and Stepper Motors With L298N Dual Motor Controller Modules

Post by OutoftheBOTS_ » Sat Jan 05, 2019 7:41 pm

First it is important for me to understand what type and size of m otors your using. Are you driving stepper motors or DC motors and what are the voltage and amperage of the motors for me to know if a L9110 is suitable for your motors.

Here's the hardware I use for small stepper motors https://www.aliexpress.com/item/3D-Prin ... st=ae803_5

so this is the hardware I normally use fro small DC motors https://www.aliexpress.com/item/L9110S- ... st=ae803_5

Here is the datasheet https://www.elecrow.com/download/datasheet-l9110.pdf

Wiring the L9110: it is dual H-bridge so can drive 2 DC motors. each motor will need 2 input pins from the micro-controller. I use 1 pin as a direction pin and the other as a PWM/speed pin. The power needed to drive the motor will go to Vcc and GND, you will also need to connect GND to your micro-controller. Each motors input controll pins will also need to be connected to the micro-controller where 1 pin can be connected as a digital high/;ow pin and the other as a PWM pin.

please note how setting the input pins relates to how the output power to the motor
truth.JPG
truth.JPG (22.02 KiB) Viewed 66 times
as you can see when ever the 2 input pins are the same the motor is off and when ever they are different the motor spin and it will spin depending upon the order of which 1 high and which 1 is low.

Software: I use 1 pin as direction pin and the other pin as speed pin. If the direction is low then the motor will get power when ever the speed pin is high so the speed the motor will spin at will be the duty with of the speed pin i.e PWM_duty = desired_speed. If the direction is high then motor will spin the other way and the motor will get power anytime the speed pin is low so you have to invert the PWM duty i.e PWM_duty = 100 - desired_speed

Post Reply