This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
L298N and Arduino Nano
#1
Hi,

I'm having trouble with the L298N motor driver. I realize it is very weak (rated 2A) and not supported, but I just want to use it to be able to test a concept.
All info about the board is here: https://produktinfo.conrad.com/datenblae...L298N_.pdf

I was hoping someone could help me with the following:

- Which adjustments do I need to make in motor.ino to drive the motor in both directions
- Which pins from Arduino do I need to use

Now I have it setup like this:

- Pins 9 and 10 from Arduino Nano --> pins 1 and 2 on motor controller
- Motor.ino is configured for h-bridge mode

Sync in Pypilot is OK, and when pressing AP or << / >> there is movement. Only problem is:

- Motor spins in only one direction
- No matter what I configure, it rotates very slow (with about 2 watts and less dan 1 amp)

When testing the motor controller and electromotor by 'fooling' the connection by 'thinking' it receives a signal (did that with rs485) it is able to spin quickly, so I know it is capable of more power.
I've attached my motor.ino also. 
.txt   motornosensors.txt (Size: 36.95 KB / Downloads: 6)

Hope somebody can help.
  Reply
#2
don't use d9 d10 use d2 d3 to in1, in2.

Once this is working, feed d9 to the pwm (ena) pin to get speed control. You might want to switch to pwm_style = 2, since d10 will be pwm output in other direction.

Since it's dual motors, you could maybe parallel everything to get twice the output current?
  Reply
#3
(08-14-2019, 09:21 AM)seandepagnier Wrote: don't use d9 d10 use d2 d3 to in1, in2.

Once this is working, feed d9 to the pwm (ena) pin to get speed control.  You might want to switch to pwm_style = 2, since d10 will be pwm output in other direction.

Since it's dual motors, you could maybe parallel everything to get twice the output current?

don't use d9 d10 use d2 d3 to in1, in2.
Thanks, tried this and adjusted motor.ino for pwm_style = 2.
When trying the pypilot with this combination the motor does nothing.

feed d9 to the pwm (ena) pin to get speed control
I see that my servo has a jumper placed there, I'm not sure if I need to remove it or keep it.
If I need to remove it, to which of the pins do connect the d9?

 get twice the output current
That's a great idea!  Big Grin Thanks for that.  Wink
  Reply
#4
you would connect the first one to the ena d9.

I would review the L298N datasheet and look at what motor.ino does closely. I believe pwm_style ==2 is what you want but maybe need to tweak things.
  Reply
#5
Hi Sean,

I've found an article online which helped me understand more about the L289N board in combination with arduino, and an example sketch steering it.
https://www.teachmemicro.com/use-l298n-motor-driver/ and this is also a good one: https://howtomechatronics.com/tutorials/...-h-bridge/

I've also looked at motor.ino more closely, but don't know how to combine the information I've found in the example sketch from the article, and what to change in motor.ino
Hope I am not asking for too much, but I was wondering if you could help me.
  Reply
#6
(08-15-2019, 04:35 AM)jamos.tan@gmail.com Wrote: Hi Sean,

I've found an article online which helped me understand more about the L289N board in combination with arduino, and an example sketch steering it.
https://www.teachmemicro.com/use-l298n-motor-driver/ and this is also a good one: https://howtomechatronics.com/tutorials/...-h-bridge/

I've also looked at motor.ino more closely, but don't know how to combine the information I've found in the example sketch from the article, and what to change in motor.ino
Hope I am not asking for too much, but I was wondering if you could help me.

Ok, update here. I've downloaded the newest motor.ino from your github.
My bad, I didn't uncomment the #define VNH2SP30 // defined if this board is used

Autopilot has no errors! When engaging the AP and changing direction of the magnetic compass, polarity reverses OK.
Also manual buttons work.

However, the electromotor is not realy spinning I think. It makes a high pitch sound (recognize it from your video from youtube, makes the same sound)
When measuring it, it is only using about 2 volts.

I'll need to tweak with the gains / and the maximum / minimum settings in the client for that probably right?
Only thing I modified for compensating the low power board I have is change this line:

uint16_t max_current = 200; // 2 Amps
  Reply
#7
(08-15-2019, 06:54 AM)jamos.tan@gmail.com Wrote:
(08-15-2019, 04:35 AM)jamos.tan@gmail.com Wrote: Hi Sean,

I've found an article online which helped me understand more about the L289N board in combination with arduino, and an example sketch steering it.
https://www.teachmemicro.com/use-l298n-motor-driver/ and this is also a good one: https://howtomechatronics.com/tutorials/...-h-bridge/

I've also looked at motor.ino more closely, but don't know how to combine the information I've found in the example sketch from the article, and what to change in motor.ino
Hope I am not asking for too much, but I was wondering if you could help me.

Ok, update here. I've downloaded the newest motor.ino from your github.
My bad, I didn't uncomment the #define VNH2SP30 // defined if this board is used

Autopilot has no errors! When engaging the AP and changing direction of the magnetic compass, polarity reverses OK.
Also manual buttons work.

However, the electromotor is not realy spinning I think. It makes a high pitch sound (recognize it from your video from youtube, makes the same sound)
When measuring it, it is only using about 2 volts.

I'll need to tweak with the gains / and the maximum / minimum settings in the client for that probably right?
Only thing I modified for compensating the low power board I have is change this line:

uint16_t max_current = 200; // 2 Amps


Try just supplying vcc to the ena pin, and see if the motor spins both ways.

Maybe the frequency is too high.   Look for where the pwm parameters are set and change it.
  Reply
#8
(08-15-2019, 08:37 AM)seandepagnier Wrote:
(08-15-2019, 06:54 AM)jamos.tan@gmail.com Wrote:
(08-15-2019, 04:35 AM)jamos.tan@gmail.com Wrote: Hi Sean,

I've found an article online which helped me understand more about the L289N board in combination with arduino, and an example sketch steering it.
https://www.teachmemicro.com/use-l298n-motor-driver/ and this is also a good one: https://howtomechatronics.com/tutorials/...-h-bridge/

I've also looked at motor.ino more closely, but don't know how to combine the information I've found in the example sketch from the article, and what to change in motor.ino
Hope I am not asking for too much, but I was wondering if you could help me.

Ok, update here. I've downloaded the newest motor.ino from your github.
My bad, I didn't uncomment the #define VNH2SP30 // defined if this board is used

Autopilot has no errors! When engaging the AP and changing direction of the magnetic compass, polarity reverses OK.
Also manual buttons work.

However, the electromotor is not realy spinning I think. It makes a high pitch sound (recognize it from your video from youtube, makes the same sound)
When measuring it, it is only using about 2 volts.

I'll need to tweak with the gains / and the maximum / minimum settings in the client for that probably right?
Only thing I modified for compensating the low power board I have is change this line:

uint16_t max_current = 200; // 2 Amps


Try just supplying vcc to the ena pin, and see if the motor spins both ways.

Maybe the frequency is too high.   Look for where the pwm parameters are set and change it.

Its working! I've done it by adjusting the max skew settings. Tiller from the autohelm st4000 works like a charm now! You are the best.
  Reply
#9
I got myself an IR2104 (instead of an IR2101), which, in essence, has the similar inputs as the L298: direction and enable, instead on low side and high side. I tried the pwm_style=2 option as well, but found it unsatisfactory, with the sound coming out of the motor, and the motor hardly getting in motion, or very abrupt when slew parameters set close to 100. I then switched back to the pwm_style=0 ('h-bridge'), using only d2 and d3, whilst tying the EN pin of the driver to vcc. This seems to work fine for me in the lab. Tying EN to vcc was suggested as a test above, but I'm under the impression that the d2 and d3 outputs give me PWM as well, so I think I should not want for more. Is this true?  I'm aware that by doing so, the low side of my h-bridge is always engaged in rest, but frankly I don't really think I should care, should I?
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)